2000-10-01 20:48:48 +00:00
|
|
|
#ifndef __PERL_COMMON_H
|
|
|
|
|
#define __PERL_COMMON_H
|
|
|
|
|
|
2000-12-09 20:54:47 +00:00
|
|
|
/* helper defines */
|
2000-10-01 20:48:48 +00:00
|
|
|
#define new_pv(a) \
|
|
|
|
|
(newSVpv((a) == NULL ? "" : (a), (a) == NULL ? 0 : strlen(a)))
|
|
|
|
|
|
2000-10-18 01:32:14 +00:00
|
|
|
#define new_bless(obj, stash) \
|
|
|
|
|
sv_bless(newRV_noinc(newSViv(GPOINTER_TO_INT(obj))), stash)
|
|
|
|
|
|
2000-12-09 20:54:47 +00:00
|
|
|
#define push_bless(obj, stash) \
|
|
|
|
|
XPUSHs(sv_2mortal(new_bless(obj, stash)))
|
|
|
|
|
|
2000-12-06 05:03:11 +00:00
|
|
|
#define is_hvref(o) \
|
|
|
|
|
((o) && SvROK(o) && SvRV(o) && (SvTYPE(SvRV(o)) == SVt_PVHV))
|
|
|
|
|
|
|
|
|
|
#define hvref(o) \
|
|
|
|
|
(is_hvref(o) ? (HV *)SvRV(o) : NULL)
|
|
|
|
|
|
2000-12-09 20:54:47 +00:00
|
|
|
typedef void (*PERL_OBJECT_FUNC) (HV *hv, void *object);
|
2000-12-06 05:03:11 +00:00
|
|
|
|
2000-12-09 20:54:47 +00:00
|
|
|
typedef struct {
|
|
|
|
|
char *name;
|
|
|
|
|
PERL_OBJECT_FUNC fill_func;
|
|
|
|
|
} PLAIN_OBJECT_INIT_REC;
|
2000-10-01 20:48:48 +00:00
|
|
|
|
2000-11-26 09:22:18 +00:00
|
|
|
/* returns the package who called us */
|
|
|
|
|
char *perl_get_package(void);
|
|
|
|
|
|
2001-01-15 01:04:30 +00:00
|
|
|
/* For compatibility with perl 5.004 and older */
|
|
|
|
|
#ifndef HAVE_PL_PERL
|
|
|
|
|
# define PL_sv_undef sv_undef
|
|
|
|
|
#endif
|
|
|
|
|
|
2000-12-09 20:54:47 +00:00
|
|
|
#define irssi_bless(object) \
|
|
|
|
|
((object) == NULL ? &PL_sv_undef : \
|
|
|
|
|
irssi_bless_iobject((object)->type, (object)->chat_type, object))
|
|
|
|
|
SV *irssi_bless_iobject(int type, int chat_type, void *object);
|
|
|
|
|
SV *irssi_bless_plain(const char *stash, void *object);
|
2000-12-29 19:22:00 +00:00
|
|
|
int irssi_is_ref_object(SV *o);
|
2000-12-06 05:03:11 +00:00
|
|
|
void *irssi_ref_object(SV *o);
|
2000-10-01 20:48:48 +00:00
|
|
|
|
2000-12-09 20:54:47 +00:00
|
|
|
void irssi_add_object(int type, int chat_type, const char *stash,
|
|
|
|
|
PERL_OBJECT_FUNC func);
|
|
|
|
|
void irssi_add_plain(const char *stash, PERL_OBJECT_FUNC func);
|
|
|
|
|
void irssi_add_plains(PLAIN_OBJECT_INIT_REC *objects);
|
2000-10-01 20:48:48 +00:00
|
|
|
|
2000-12-09 21:58:53 +00:00
|
|
|
char *perl_get_use_list(void);
|
|
|
|
|
|
2000-10-01 20:48:48 +00:00
|
|
|
void perl_common_init(void);
|
|
|
|
|
void perl_common_deinit(void);
|
|
|
|
|
|
|
|
|
|
#endif
|