This commit is contained in:
Kenny Root 2017-04-19 05:16:30 +00:00 committed by GitHub
commit 9451d11221
2 changed files with 19 additions and 1 deletions

View file

@ -18,6 +18,7 @@ while (<STDIN>) {
s/GList \* of ([^,]*)/glistptr_\1/g; s/GList \* of ([^,]*)/glistptr_\1/g;
s/GSList of (\w+)s/gslist_\1/g; s/GSList of (\w+)s/gslist_\1/g;
s/GBytes \*/gbytes/g;
s/char \*[^,]*/string/g; s/char \*[^,]*/string/g;
s/ulong \*[^,]*/ulongptr/g; s/ulong \*[^,]*/ulongptr/g;

View file

@ -80,6 +80,7 @@ void perl_signal_args_to_c(
unsigned long v_ulong; unsigned long v_ulong;
GSList *v_gslist; GSList *v_gslist;
GList *v_glist; GList *v_glist;
GBytes *v_gbytes;
} saved_args[SIGNAL_MAX_ARGUMENTS]; } saved_args[SIGNAL_MAX_ARGUMENTS];
void *p[SIGNAL_MAX_ARGUMENTS]; void *p[SIGNAL_MAX_ARGUMENTS];
PERL_SIGNAL_ARGS_REC *rec; PERL_SIGNAL_ARGS_REC *rec;
@ -101,6 +102,12 @@ void perl_signal_args_to_c(
c_arg = NULL; c_arg = NULL;
} else if (g_strcmp0(rec->args[n], "string") == 0) { } else if (g_strcmp0(rec->args[n], "string") == 0) {
c_arg = SvPV_nolen(arg); c_arg = SvPV_nolen(arg);
} else if (g_strcmp0(rec->args[n], "gbytes") == 0) {
char *bytes;
STRLEN len;
bytes = SvPV(arg, len);
c_arg = saved_args[n].v_gbytes = g_bytes_new(bytes, len);
} else if (g_strcmp0(rec->args[n], "int") == 0) { } else if (g_strcmp0(rec->args[n], "int") == 0) {
c_arg = (void *)SvIV(arg); c_arg = (void *)SvIV(arg);
} else if (g_strcmp0(rec->args[n], "ulongptr") == 0) { } else if (g_strcmp0(rec->args[n], "ulongptr") == 0) {
@ -181,7 +188,9 @@ void perl_signal_args_to_c(
continue; continue;
} }
if (g_strcmp0(rec->args[n], "intptr") == 0) { if (g_strcmp0(rec->args[n], "gbytes") == 0) {
g_bytes_unref(saved_args[n].v_gbytes);
} else if (g_strcmp0(rec->args[n], "intptr") == 0) {
SV *t = SvRV(arg); SV *t = SvRV(arg);
SvIOK_only(t); SvIOK_only(t);
SvIV_set(t, saved_args[n].v_int); SvIV_set(t, saved_args[n].v_int);
@ -291,6 +300,14 @@ static void perl_call_signal(PERL_SCRIPT_REC *script, SV *func,
/* "simple irssi object" - any struct that has /* "simple irssi object" - any struct that has
int type; as it's first variable (dcc) */ int type; as it's first variable (dcc) */
perlarg = simple_iobject_bless((SERVER_REC *) arg); perlarg = simple_iobject_bless((SERVER_REC *) arg);
} else if (g_strcmp0(rec->args[n], "gbytes") == 0) {
GBytes *tmp;
const char *data;
STRLEN data_len;
tmp = arg;
data = g_bytes_get_data(tmp, &data_len);
perlarg = newSVpvn(data, data_len);
} else { } else {
/* blessed object */ /* blessed object */
perlarg = plain_bless(arg, rec->args[n]); perlarg = plain_bless(arg, rec->args[n]);