mirror of
https://github.com/irssi/irssi.git
synced 2024-12-04 14:46:39 -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)
|
timeout_add(msecs, func, data)
|
||||||
int msecs
|
int msecs
|
||||||
char *func
|
char *func
|
||||||
char *data
|
void *data
|
||||||
CODE:
|
CODE:
|
||||||
RETVAL = perl_timeout_add(msecs, func, data);
|
RETVAL = perl_timeout_add(msecs, func, ST(2));
|
||||||
OUTPUT:
|
OUTPUT:
|
||||||
RETVAL
|
RETVAL
|
||||||
|
|
||||||
@ -91,9 +91,9 @@ input_add(source, condition, func, data)
|
|||||||
int source
|
int source
|
||||||
int condition
|
int condition
|
||||||
char *func
|
char *func
|
||||||
char *data
|
void *data
|
||||||
CODE:
|
CODE:
|
||||||
RETVAL = perl_input_add(source, condition, func, data);
|
RETVAL = perl_input_add(source, condition, func, ST(2));
|
||||||
OUTPUT:
|
OUTPUT:
|
||||||
RETVAL
|
RETVAL
|
||||||
|
|
||||||
|
@ -29,7 +29,7 @@ typedef struct {
|
|||||||
int tag;
|
int tag;
|
||||||
int refcount;
|
int refcount;
|
||||||
char *func;
|
char *func;
|
||||||
char *data;
|
SV *data;
|
||||||
} PERL_SOURCE_REC;
|
} PERL_SOURCE_REC;
|
||||||
|
|
||||||
static GSList *perl_sources;
|
static GSList *perl_sources;
|
||||||
@ -44,8 +44,8 @@ static void perl_source_unref(PERL_SOURCE_REC *rec)
|
|||||||
if (--rec->refcount != 0)
|
if (--rec->refcount != 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
SvREFCNT_dec(rec->data);
|
||||||
g_free(rec->func);
|
g_free(rec->func);
|
||||||
g_free(rec->data);
|
|
||||||
g_free(rec);
|
g_free(rec);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -68,7 +68,7 @@ static int perl_source_event(PERL_SOURCE_REC *rec)
|
|||||||
SAVETMPS;
|
SAVETMPS;
|
||||||
|
|
||||||
PUSHMARK(SP);
|
PUSHMARK(SP);
|
||||||
XPUSHs(sv_2mortal(new_pv(rec->data)));
|
XPUSHs(sv_mortalcopy(rec->data));
|
||||||
PUTBACK;
|
PUTBACK;
|
||||||
|
|
||||||
perl_source_ref(rec);
|
perl_source_ref(rec);
|
||||||
@ -94,23 +94,24 @@ static int perl_source_event(PERL_SOURCE_REC *rec)
|
|||||||
return 1;
|
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;
|
PERL_SOURCE_REC *rec;
|
||||||
|
|
||||||
rec = g_new(PERL_SOURCE_REC, 1);
|
rec = g_new(PERL_SOURCE_REC, 1);
|
||||||
perl_source_ref(rec);
|
perl_source_ref(rec);
|
||||||
|
|
||||||
|
SvREFCNT_inc(data);
|
||||||
|
rec->data = data;
|
||||||
|
|
||||||
rec->func = g_strdup_printf("%s::%s", perl_get_package(), func);
|
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);
|
rec->tag = g_timeout_add(msecs, (GSourceFunc) perl_source_event, rec);
|
||||||
|
|
||||||
perl_sources = g_slist_append(perl_sources, rec);
|
perl_sources = g_slist_append(perl_sources, rec);
|
||||||
return rec->tag;
|
return rec->tag;
|
||||||
}
|
}
|
||||||
|
|
||||||
int perl_input_add(int source, int condition,
|
int perl_input_add(int source, int condition, const char *func, SV *data)
|
||||||
const char *func, const char *data)
|
|
||||||
{
|
{
|
||||||
PERL_SOURCE_REC *rec;
|
PERL_SOURCE_REC *rec;
|
||||||
GIOChannel *channel;
|
GIOChannel *channel;
|
||||||
@ -118,9 +119,10 @@ int perl_input_add(int source, int condition,
|
|||||||
rec = g_new(PERL_SOURCE_REC, 1);
|
rec = g_new(PERL_SOURCE_REC, 1);
|
||||||
perl_source_ref(rec);
|
perl_source_ref(rec);
|
||||||
|
|
||||||
rec->func = g_strdup_printf("%s::%s", perl_get_package(), func);
|
SvREFCNT_inc(data);
|
||||||
rec->data = g_strdup(data);
|
rec->data = data;
|
||||||
|
|
||||||
|
rec->func = g_strdup_printf("%s::%s", perl_get_package(), func);
|
||||||
channel = g_io_channel_unix_new(source);
|
channel = g_io_channel_unix_new(source);
|
||||||
rec->tag = g_input_add(channel, condition,
|
rec->tag = g_input_add(channel, condition,
|
||||||
(GInputFunction) perl_source_event, rec);
|
(GInputFunction) perl_source_event, rec);
|
||||||
|
@ -1,9 +1,8 @@
|
|||||||
#ifndef __PERL_SOURCES_H
|
#ifndef __PERL_SOURCES_H
|
||||||
#define __PERL_SOURCES_H
|
#define __PERL_SOURCES_H
|
||||||
|
|
||||||
int perl_timeout_add(int msecs, 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,
|
int perl_input_add(int source, int condition, const char *func, SV *data);
|
||||||
const char *func, const char *data);
|
|
||||||
|
|
||||||
void perl_source_remove(int tag);
|
void perl_source_remove(int tag);
|
||||||
/* remove all sources used by package */
|
/* remove all sources used by package */
|
||||||
|
Loading…
Reference in New Issue
Block a user