#include "sub_op.h"
-void sub_op_register(pTHX_ const sub_op_keyword *k) {
- SV *key = newSViv(PTR2IV(k->pp));
+void sub_op_register(pTHX_ const sub_op_config_t *c) {
+ SV *key = newSViv(PTR2IV(c->pp));
if (!PL_custom_op_names)
PL_custom_op_names = newHV();
- (void) hv_store_ent(PL_custom_op_names, key, newSVpv(k->name, k->len), 0);
+ (void) hv_store_ent(PL_custom_op_names, key, newSVpv(c->name, c->len), 0);
if (!PL_custom_op_descs)
PL_custom_op_descs = newHV();
- (void) hv_store_ent(PL_custom_op_descs, key, newSVpv(k->name, k->len), 0);
+ (void) hv_store_ent(PL_custom_op_descs, key, newSVpv(c->name, c->len), 0);
- if (k->check) {
- SV *check = newSViv(PTR2IV(k->check));
- sv_magicext(key, check, PERL_MAGIC_ext, NULL, k->ud, 0);
+ if (c->check) {
+ SV *check = newSViv(PTR2IV(c->check));
+ sv_magicext(key, check, PERL_MAGIC_ext, NULL, c->ud, 0);
SvREFCNT_dec(check);
}
{
dMY_CXT;
- (void) hv_store(MY_CXT.map, k->name, k->len, key, 0);
+ (void) hv_store(MY_CXT.map, c->name, c->len, key, 0);
}
}
BOOT:
{
- sub_op_keyword k;
- k.name = "reftype";
- k.len = sizeof("reftype")-1;
- k.pp = scalar_util_reftype;
- k.check = 0;
- k.ud = NULL;
- sub_op_register(aTHX_ &k);
+ sub_op_config_t c;
+ c.name = "reftype";
+ c.len = sizeof("reftype")-1;
+ c.pp = scalar_util_reftype;
+ c.check = 0;
+ c.ud = NULL;
+ sub_op_register(aTHX_ &c);
}
In your Perl module file :
_init(SV *name, SV *cb)
PROTOTYPE: $$
PREINIT:
- sub_op_keyword k;
+ sub_op_config_t c;
PPCODE:
if (SvROK(cb)) {
cb = SvRV(cb);
if (SvTYPE(cb) >= SVt_PVCV) {
- k.name = SvPV_const(name, k.len);
- k.check = sub_op_test_check;
- k.ud = SvREFCNT_inc(cb);
- k.pp = sub_op_test_pp;
- sub_op_register(aTHX_ &k);
+ c.name = SvPV_const(name, c.len);
+ c.check = sub_op_test_check;
+ c.ud = SvREFCNT_inc(cb);
+ c.pp = sub_op_test_pp;
+ sub_op_register(aTHX_ &c);
}
}
XSRETURN(0);