Mouse

 view release on metacpan or  search on metacpan

xs-src/Mouse.xs  view on Meta::CPAN


    xsub = newXS("Mouse::Meta::Method::Destructor::XS::_generate_destructor",
        XS_Mouse_value_holder, file);
    CvXSUBANY(xsub).any_ptr
        = newRV_inc((SV*)get_cvs("Mouse::Object::DESTROY", GV_ADD));
}


void
linearized_isa(SV* self)
PPCODE:
{
    /* MOUSE_xc_stash() is not available because the xc system depends on
       linearized_isa() */
    HV* const stash          = mouse_get_namespace(aTHX_ self);
    AV* const linearized_isa = mro_get_linear_isa(stash);
    I32 const            len = AvFILLp(linearized_isa) + 1;
    I32 i;
    EXTEND(SP, len);
    for(i = 0; i < len; i++){
        PUSHs(AvARRAY(linearized_isa)[i]);
    }
}

void
get_all_attributes(SV* self)
PPCODE:
{
    AV* const xc        = mouse_get_xc(aTHX_ self);
    AV* const all_attrs = MOUSE_xc_attrall(xc);
    I32 const len       = AvFILLp(all_attrs) + 1;
    I32 i;

    EXTEND(SP, len);
    for(i = 0; i < len; i++){
        PUSHs( MOUSE_av_at(all_attrs, i) );
    }

xs-src/Mouse.xs  view on Meta::CPAN

    add_before_method_modifier = MOUSE_M_BEFORE
    add_around_method_modifier = MOUSE_M_AROUND
    add_after_method_modifier  = MOUSE_M_AFTER

void
get_before_modifiers(SV* self, SV* name)
ALIAS:
    get_before_method_modifiers = MOUSE_M_BEFORE
    get_around_method_modifiers = MOUSE_M_AROUND
    get_after_method_modifiers  = MOUSE_M_AFTER
PPCODE:
{
    AV* const storage = mouse_get_modifier_storage(aTHX_ self,
                            (enum mouse_modifier_t)ix, name);
    I32 const len     = av_len(storage) + 1;
    if(GIMME_V == G_ARRAY) {
        I32 i;
        EXTEND(SP, len);
        for(i = 0; i < len; i++){
            PUSHs(*av_fetch(storage, i, TRUE));
        }

xs-src/MouseAccessor.xs  view on Meta::CPAN


    mouse_push_value(aTHX_ value, flags);
}

XS(XS_Mouse_accessor)
{
    dVAR; dXSARGS;
    dMOUSE_self;
    MAGIC* const mg = MOUSE_get_magic(aTHX_ cv, &mouse_accessor_vtbl);

    SP -= items; /* PPCODE */
    PUTBACK;

    if(items == 1){ /* reader */
        mouse_attr_get(aTHX_ self, mg);
    }
    else if (items == 2){ /* writer */
        mouse_attr_set(aTHX_ self, mg, ST(1));
    }
    else{
        mouse_throw_error(MOUSE_mg_attribute(mg), NULL,

xs-src/MouseAccessor.xs  view on Meta::CPAN

    dVAR; dXSARGS;
    dMOUSE_self;
    MAGIC* const mg = MOUSE_get_magic(aTHX_ cv, &mouse_accessor_vtbl);

    if (items != 1) {
        mouse_throw_error(MOUSE_mg_attribute(mg), NULL,
            "Cannot assign a value to a read-only accessor of %"SVf,
            MOUSE_mg_slot(mg));
    }

    SP -= items; /* PPCODE */
    PUTBACK;

    mouse_attr_get(aTHX_ self, mg);
}

XS(XS_Mouse_writer)
{
    dVAR; dXSARGS;
    dMOUSE_self;
    MAGIC* const mg = MOUSE_get_magic(aTHX_ cv, &mouse_accessor_vtbl);

    if (items != 2) {
        mouse_throw_error(MOUSE_mg_attribute(mg), NULL,
            "Too few arguments for a write-only accessor of %"SVf,
            MOUSE_mg_slot(mg));
    }

    SP -= items; /* PPCODE */
    PUTBACK;

    mouse_attr_set(aTHX_ self, mg, ST(1));
}

/* simple accessors */

/*
static MAGIC*
mouse_accessor_get_mg(pTHX_ CV* const xsub){

xs-src/MouseAttribute.xs  view on Meta::CPAN

        if(!(has_default || has_builder)){
            mouse_throw_error(klass, NULL,
                "You cannot have a lazy attribute (%"SVf") without specifying "
                "a default value for it", name);
        }
    }
}

void
default(SV* self, SV* instance = NULL)
PPCODE:
{
    SV* value = get_slot(self, sv_2mortal(newSVpvs_share("default")));
    if(! value) {
        value = &PL_sv_undef;
    }
    else if (instance != NULL && IsCodeRef(value)) {
        PUSHMARK(SP);
        XPUSHs(instance);
        PUTBACK;
        call_sv_safe(value, G_SCALAR);

xs-src/MouseUtil.xs  view on Meta::CPAN

    RETVAL

bool
is_class_loaded(SV* sv)

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;

xs-src/MouseUtil.xs  view on Meta::CPAN

    }
}
OUTPUT:
    RETVAL

void
generate_isa_predicate_for(SV* arg, SV* predicate_name = NULL)
ALIAS:
    generate_isa_predicate_for = 0
    generate_can_predicate_for = 1
PPCODE:
{
    const char* name_pv = NULL;
    CV* xsub;

    must_defined(arg, ix == 0 ? "a class_name" : "method names");

    if(predicate_name){
        must_defined(predicate_name, "a predicate name");
        name_pv = SvPV_nolen_const(predicate_name);
    }



( run in 2.417 seconds using v1.01-cache-2.11-cpan-5511b514fd6 )