mirror of
https://github.com/irssi/irssi.git
synced 2024-11-03 04:27:19 -05:00
Irssi::timeout_add() and Irssi::input_add() now accepts any type of variable
as data instead of just string. git-svn-id: http://svn.irssi.org/repos/irssi/trunk@1825 dbcabf3a-b0e7-0310-adc4-f8d773084564
This commit is contained in:
parent
b0ac3b83e7
commit
80dd9a15ca
@ -59,9 +59,9 @@ int
|
||||
timeout_add(msecs, func, data)
|
||||
int msecs
|
||||
char *func
|
||||
char *data
|
||||
void *data
|
||||
CODE:
|
||||
RETVAL = perl_timeout_add(msecs, func, data);
|
||||
RETVAL = perl_timeout_add(msecs, func, ST(2));
|
||||
OUTPUT:
|
||||
RETVAL
|
||||
|
||||
@ -91,9 +91,9 @@ input_add(source, condition, func, data)
|
||||
int source
|
||||
int condition
|
||||
char *func
|
||||
char *data
|
||||
void *data
|
||||
CODE:
|
||||
RETVAL = perl_input_add(source, condition, func, data);
|
||||
RETVAL = perl_input_add(source, condition, func, ST(2));
|
||||
OUTPUT:
|
||||
RETVAL
|
||||
|
||||
|
@ -29,7 +29,7 @@ typedef struct {
|
||||
int tag;
|
||||
int refcount;
|
||||
char *func;
|
||||
char *data;
|
||||
SV *data;
|
||||
} PERL_SOURCE_REC;
|
||||
|
||||
static GSList *perl_sources;
|
||||
@ -44,8 +44,8 @@ static void perl_source_unref(PERL_SOURCE_REC *rec)
|
||||
if (--rec->refcount != 0)
|
||||
return;
|
||||
|
||||
SvREFCNT_dec(rec->data);
|
||||
g_free(rec->func);
|
||||
g_free(rec->data);
|
||||
g_free(rec);
|
||||
}
|
||||
|
||||
@ -68,7 +68,7 @@ static int perl_source_event(PERL_SOURCE_REC *rec)
|
||||
SAVETMPS;
|
||||
|
||||
PUSHMARK(SP);
|
||||
XPUSHs(sv_2mortal(new_pv(rec->data)));
|
||||
XPUSHs(sv_mortalcopy(rec->data));
|
||||
PUTBACK;
|
||||
|
||||
perl_source_ref(rec);
|
||||
@ -94,23 +94,24 @@ static int perl_source_event(PERL_SOURCE_REC *rec)
|
||||
return 1;
|
||||
}
|
||||
|
||||
int perl_timeout_add(int msecs, const char *func, const char *data)
|
||||
int perl_timeout_add(int msecs, const char *func, SV *data)
|
||||
{
|
||||
PERL_SOURCE_REC *rec;
|
||||
|
||||
rec = g_new(PERL_SOURCE_REC, 1);
|
||||
perl_source_ref(rec);
|
||||
|
||||
SvREFCNT_inc(data);
|
||||
rec->data = data;
|
||||
|
||||
rec->func = g_strdup_printf("%s::%s", perl_get_package(), func);
|
||||
rec->data = g_strdup(data);
|
||||
rec->tag = g_timeout_add(msecs, (GSourceFunc) perl_source_event, rec);
|
||||
|
||||
perl_sources = g_slist_append(perl_sources, rec);
|
||||
return rec->tag;
|
||||
}
|
||||
|
||||
int perl_input_add(int source, int condition,
|
||||
const char *func, const char *data)
|
||||
int perl_input_add(int source, int condition, const char *func, SV *data)
|
||||
{
|
||||
PERL_SOURCE_REC *rec;
|
||||
GIOChannel *channel;
|
||||
@ -118,9 +119,10 @@ int perl_input_add(int source, int condition,
|
||||
rec = g_new(PERL_SOURCE_REC, 1);
|
||||
perl_source_ref(rec);
|
||||
|
||||
rec->func = g_strdup_printf("%s::%s", perl_get_package(), func);
|
||||
rec->data = g_strdup(data);
|
||||
SvREFCNT_inc(data);
|
||||
rec->data = data;
|
||||
|
||||
rec->func = g_strdup_printf("%s::%s", perl_get_package(), func);
|
||||
channel = g_io_channel_unix_new(source);
|
||||
rec->tag = g_input_add(channel, condition,
|
||||
(GInputFunction) perl_source_event, rec);
|
||||
|
@ -1,9 +1,8 @@
|
||||
#ifndef __PERL_SOURCES_H
|
||||
#define __PERL_SOURCES_H
|
||||
|
||||
int perl_timeout_add(int msecs, const char *func, const char *data);
|
||||
int perl_input_add(int source, int condition,
|
||||
const char *func, const char *data);
|
||||
int perl_timeout_add(int msecs, const char *func, SV *data);
|
||||
int perl_input_add(int source, int condition, const char *func, SV *data);
|
||||
|
||||
void perl_source_remove(int tag);
|
||||
/* remove all sources used by package */
|
||||
|
Loading…
Reference in New Issue
Block a user