summaryrefslogtreecommitdiff
path: root/src/perl/common
diff options
context:
space:
mode:
Diffstat (limited to 'src/perl/common')
-rw-r--r--src/perl/common/Core.xs63
1 files changed, 31 insertions, 32 deletions
diff --git a/src/perl/common/Core.xs b/src/perl/common/Core.xs
index c1e526bb..4032340a 100644
--- a/src/perl/common/Core.xs
+++ b/src/perl/common/Core.xs
@@ -65,6 +65,15 @@ static void add_tuple(gpointer key_, gpointer value_, gpointer user_data)
hv_store(hash, key, strlen(key), new_pv(value), 0);
}
+static void wrap_signal_emit(void *signal, void **p) {
+ signal_emit(signal, 6, p[0], p[1], p[2], p[3], p[4], p[5]);
+}
+
+static void wrap_signal_continue(void *dummy, void **p) {
+ (void)dummy;
+ signal_continue(6, p[0], p[1], p[2], p[3], p[4], p[5]);
+}
+
MODULE = Irssi::Core PACKAGE = Irssi
PROTOTYPES: ENABLE
@@ -72,44 +81,34 @@ void
signal_emit(signal, ...)
char *signal
CODE:
- void *p[SIGNAL_MAX_ARGUMENTS];
- int n;
-
- memset(p, 0, sizeof(p));
- for (n = 1; n < items && n < SIGNAL_MAX_ARGUMENTS+1; n++) {
- if (SvPOKp(ST(n)))
- p[n-1] = SvPV(ST(n), PL_na);
- else if (irssi_is_ref_object(ST(n)))
- p[n-1] = irssi_ref_object(ST(n));
- else if (SvROK(ST(n)))
- p[n-1] = (void *) SvIV((SV*)SvRV(ST(n)));
- else if (SvIOK(ST(n)))
- p[n-1] = (void *)SvIV(ST(n));
- else
- p[n-1] = NULL;
+ int signal_id;
+ SV *args[SIGNAL_MAX_ARGUMENTS];
+ int n, used;
+
+ signal_id = signal_get_uniq_id(signal);
+ used = items - 1;
+ if (used > SIGNAL_MAX_ARGUMENTS) {
+ used = SIGNAL_MAX_ARGUMENTS;
+ }
+ for (n = 0; n < used; ++n) {
+ args[n] = ST(n + 1);
}
- signal_emit(signal, items-1, p[0], p[1], p[2], p[3], p[4], p[5]);
+ perl_signal_args_to_c(wrap_signal_emit, signal, signal_id, args, used);
void
signal_continue(...)
CODE:
- void *p[SIGNAL_MAX_ARGUMENTS];
- int n;
-
- memset(p, 0, sizeof(p));
- for (n = 0; n < items && n < SIGNAL_MAX_ARGUMENTS; n++) {
- if (SvPOKp(ST(n)))
- p[n] = SvPV(ST(n), PL_na);
- else if (irssi_is_ref_object(ST(n)))
- p[n] = irssi_ref_object(ST(n));
- else if (SvROK(ST(n)))
- p[n] = (void *) SvIV((SV*)SvRV(ST(n)));
- else if (SvIOK(ST(n)))
- p[n] = (void *) SvIV(ST(n));
- else
- p[n] = NULL;
+ SV *args[SIGNAL_MAX_ARGUMENTS];
+ int n, used;
+
+ used = items;
+ if (used > SIGNAL_MAX_ARGUMENTS) {
+ used = SIGNAL_MAX_ARGUMENTS;
+ }
+ for (n = 0; n < used; ++n) {
+ args[n] = ST(n);
}
- signal_continue(items, p[0], p[1], p[2], p[3], p[4], p[5]);
+ perl_signal_args_to_c(wrap_signal_continue, NULL, signal_get_emitted_id(), args, used);
void
signal_add(...)