X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=gitmo%2FMouse.git;a=blobdiff_plain;f=xs-src%2FMouse.xs;h=8d0f3a815d7e27af035c6e13264f504087d84259;hp=ccbf65fd592cca53c90d511bbb2e765fde5b323f;hb=646c0371bdfda5817f842c54577c4d5605a4c3c0;hpb=b330ee2d30c887a6485c7e8b711be2d7bdcd98a3 diff --git a/xs-src/Mouse.xs b/xs-src/Mouse.xs index ccbf65f..8d0f3a8 100644 --- a/xs-src/Mouse.xs +++ b/xs-src/Mouse.xs @@ -3,8 +3,9 @@ SV* mouse_package; SV* mouse_namespace; SV* mouse_methods; +SV* mouse_name; -MODULE = Mouse PACKAGE = Mouse::Util +MODULE = Mouse PACKAGE = Mouse PROTOTYPES: DISABLE @@ -12,77 +13,11 @@ BOOT: mouse_package = newSVpvs_share("package"); mouse_namespace = newSVpvs_share("namespace"); mouse_methods = newSVpvs_share("methods"); + mouse_name = newSVpvs_share("name"); + MOUSE_CALL_BOOT(Mouse__Util); MOUSE_CALL_BOOT(Mouse__Util__TypeConstraints); - - -bool -is_class_loaded(SV* sv = &PL_sv_undef) - -void -get_code_info(CV* code) -PREINIT: - GV* gv; - HV* stash; -PPCODE: - if((gv = CvGV(code)) && isGV(gv) && (stash = GvSTASH(gv))){ - EXTEND(SP, 2); - mPUSHs(newSVpvn_share(HvNAME_get(stash), HvNAMELEN_get(stash), 0U)); - mPUSHs(newSVpvn_share(GvNAME_get(gv), GvNAMELEN_get(gv), 0U)); - } - -SV* -get_code_package(CV* code) -PREINIT: - HV* stash; -CODE: - if(CvGV(code) && isGV(CvGV(code)) && (stash = GvSTASH(CvGV(code)))){ - RETVAL = newSVpvn_share(HvNAME_get(stash), HvNAMELEN_get(stash), 0U); - } - else{ - RETVAL = &PL_sv_no; - } -OUTPUT: - RETVAL - -CV* -get_code_ref(SV* package, SV* name) -CODE: -{ - HV* stash; - HE* he; - - if(!SvOK(package)){ - croak("You must define a package name"); - } - if(!SvOK(name)){ - croak("You must define a subroutine name"); - } - - stash = gv_stashsv(package, FALSE); - if(!stash){ - XSRETURN_UNDEF; - } - he = hv_fetch_ent(stash, name, FALSE, 0U); - if(he){ - GV* const gv = (GV*)hv_iterval(stash, he); - if(!isGV(gv)){ /* special constant or stub */ - STRLEN len; - const char* const pv = SvPV_const(name, len); - gv_init(gv, stash, pv, len, GV_ADDMULTI); - } - RETVAL = GvCVu(gv); - } - else{ - RETVAL = NULL; - } - - if(!RETVAL){ - XSRETURN_UNDEF; - } -} -OUTPUT: - RETVAL + MOUSE_CALL_BOOT(Mouse__Meta__Method__Accessor__XS); MODULE = Mouse PACKAGE = Mouse::Meta::Module @@ -248,56 +183,3 @@ BOOT: INSTALL_SIMPLE_PREDICATE_WITH_KEY(TypeConstraint, has_coercion, _compiled_type_coercion); -MODULE = Mouse PACKAGE = Mouse::Meta::Method::Accessor::XS - -CV* -_generate_accessor(klass, SV* attr, metaclass) -CODE: -{ - RETVAL = mouse_instantiate_xs_accessor(aTHX_ attr, mouse_xs_accessor); -} -OUTPUT: - RETVAL - -CV* -_generate_reader(klass, SV* attr, metaclass) -CODE: -{ - RETVAL = mouse_instantiate_xs_accessor(aTHX_ attr, mouse_xs_reader); -} -OUTPUT: - RETVAL - -CV* -_generate_writer(klass, SV* attr, metaclass) -CODE: -{ - RETVAL = mouse_instantiate_xs_accessor(aTHX_ attr, mouse_xs_writer); -} -OUTPUT: - RETVAL - -CV* -_generate_clearer(klass, SV* attr, metaclass) -CODE: -{ - SV* const slot = mcall0s(attr, "name"); - STRLEN len; - const char* const pv = SvPV_const(slot, len); - RETVAL = mouse_install_simple_accessor(aTHX_ NULL, pv, len, mouse_xs_simple_clearer); -} -OUTPUT: - RETVAL - -CV* -_generate_predicate(klass, SV* attr, metaclass) -CODE: -{ - SV* const slot = mcall0s(attr, "name"); - STRLEN len; - const char* const pv = SvPV_const(slot, len); - RETVAL = mouse_install_simple_accessor(aTHX_ NULL, pv, len, mouse_xs_simple_predicate); -} -OUTPUT: - RETVAL -