From: gfx Date: Fri, 4 Sep 2009 11:33:22 +0000 (+0900) Subject: Make MOP_CALL_BOOT a little smart X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=c79ae27afa1591b7876a3990475ab15d673b1e38;p=gitmo%2FClass-MOP.git Make MOP_CALL_BOOT a little smart --- diff --git a/mop.c b/mop.c index 27309ff..f2e9423 100644 --- a/mop.c +++ b/mop.c @@ -4,15 +4,6 @@ #define NEED_newSVpvn_flags_GLOBAL #include "mop.h" -void -mop_call_xs (pTHX_ XSPROTO(subaddr), CV *cv, SV **mark) -{ - dSP; - PUSHMARK(mark); - (*subaddr)(aTHX_ cv); - PUTBACK; -} - #if PERL_BCDVERSION >= 0x5010000 UV mop_check_package_cache_flag (pTHX_ HV *stash) diff --git a/mop.h b/mop.h index 9f6c612..45c50aa 100644 --- a/mop.h +++ b/mop.h @@ -8,9 +8,12 @@ #include "ppport.h" -#define MOP_CALL_BOOT(name) mop_call_xs(aTHX_ name, cv, mark); +#define MOP_CALL_BOOT(name) STMT_START { \ + EXTERN_C XS(CAT2(boot_, name)); \ + PUSHMARK(SP); \ + CALL_FPTR(CAT2(boot_, name))(aTHX_ cv); \ + } STMT_END -void mop_call_xs (pTHX_ XSPROTO(subaddr), CV *cv, SV **mark); #define MAKE_KEYSV(name) newSVpvn_share(#name, sizeof(#name)-1, 0U) diff --git a/xs/MOP.xs b/xs/MOP.xs index 14efa49..3c0200d 100644 --- a/xs/MOP.xs +++ b/xs/MOP.xs @@ -96,14 +96,6 @@ mop_is_class_loaded(pTHX_ SV * const klass){ } } -EXTERN_C XS(boot_Class__MOP__Package); -EXTERN_C XS(boot_Class__MOP__Class); -EXTERN_C XS(boot_Class__MOP__Attribute); -EXTERN_C XS(boot_Class__MOP__Instance); -EXTERN_C XS(boot_Class__MOP__Method); -EXTERN_C XS(boot_Class__MOP__Method__Accessor); -EXTERN_C XS(boot_Class__MOP__Method__Constructor); - MODULE = Class::MOP PACKAGE = Class::MOP PROTOTYPES: DISABLE @@ -126,13 +118,13 @@ BOOT: mop_isa = MAKE_KEYSV(isa); mop_can = MAKE_KEYSV(can); - MOP_CALL_BOOT (boot_Class__MOP__Package); - MOP_CALL_BOOT (boot_Class__MOP__Class); - MOP_CALL_BOOT (boot_Class__MOP__Attribute); - MOP_CALL_BOOT (boot_Class__MOP__Instance); - MOP_CALL_BOOT (boot_Class__MOP__Method); - MOP_CALL_BOOT (boot_Class__MOP__Method__Accessor); - MOP_CALL_BOOT (boot_Class__MOP__Method__Constructor); + MOP_CALL_BOOT( Class__MOP__Package ); + MOP_CALL_BOOT( Class__MOP__Class ); + MOP_CALL_BOOT( Class__MOP__Attribute ); + MOP_CALL_BOOT( Class__MOP__Instance ); + MOP_CALL_BOOT( Class__MOP__Method ); + MOP_CALL_BOOT( Class__MOP__Method__Accessor ); + MOP_CALL_BOOT( Class__MOP__Method__Constructor ); # use prototype here to be compatible with get_code_info from Sub::Identify void