From: Vincent Pit Date: Sat, 2 Jan 2010 00:20:30 +0000 (+0100) Subject: Rename sub_op_keyword to sub_op_config_t X-Git-Tag: v0.01~10 X-Git-Url: http://git.vpit.fr/?a=commitdiff_plain;h=6a7b5fad65453cfc8742554cef515b1d7c84443a;p=perl%2Fmodules%2FSub-Op.git Rename sub_op_keyword to sub_op_config_t For accuracy and consistency. --- diff --git a/Op.xs b/Op.xs index 44c283e..bc85f7f 100644 --- a/Op.xs +++ b/Op.xs @@ -113,26 +113,26 @@ typedef struct { #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); } } diff --git a/lib/Sub/Op.pm b/lib/Sub/Op.pm index 6459b04..877cf31 100644 --- a/lib/Sub/Op.pm +++ b/lib/Sub/Op.pm @@ -49,13 +49,13 @@ In your XS file : 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 : diff --git a/sub_op.h b/sub_op.h index c7fc83f..20733c1 100644 --- a/sub_op.h +++ b/sub_op.h @@ -12,8 +12,8 @@ typedef struct { Perl_ppaddr_t pp; sub_op_check_t check; void *ud; -} sub_op_keyword; +} sub_op_config_t; -void sub_op_register(pTHX_ const sub_op_keyword *k); +void sub_op_register(pTHX_ const sub_op_config_t *c); #endif /* SUB_OP_H */ diff --git a/t/Sub-Op-Test/Test.xs b/t/Sub-Op-Test/Test.xs index b317969..4a7b970 100644 --- a/t/Sub-Op-Test/Test.xs +++ b/t/Sub-Op-Test/Test.xs @@ -70,16 +70,16 @@ void _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);