typedef int (*check_fptr_t)(pTHX_ SV* const data, SV* const sv);
+/*
+ NOTE: mouse_tc_check() handles GETMAGIC
+*/
int
mouse_tc_check(pTHX_ SV* const tc_code, SV* const sv) {
CV* const cv = (CV*)SvRV(tc_code);
assert(CvXSUBANY(cv).any_ptr != NULL);
assert(mg->mg_ptr != NULL);
+ SvGETMAGIC(sv);
/* call the check function directly, skipping call_sv() */
return CALL_FPTR((check_fptr_t)mg->mg_ptr)(aTHX_ mg->mg_obj, sv);
}
call_sv(tc_code, G_SCALAR);
SPAGAIN;
- ok = SvTRUEx(POPs);
+ ok = sv_true(POPs);
PUTBACK;
FREETMPS;
mouse_tc_Bool(pTHX_ SV* const data PERL_UNUSED_DECL, SV* const sv) {
assert(sv);
- if(SvTRUE(sv)){
+ if(sv_true(sv)){
if(SvIOKp(sv)){
return SvIVX(sv) == 1;
}
I32 i;
for(i = 0; i < len; i++){
SV* const value = *av_fetch(av, i, TRUE);
- SvGETMAGIC(value);
if(!mouse_tc_check(aTHX_ param, value)){
return FALSE;
}
hv_iterinit(hv);
while((he = hv_iternext(hv))){
SV* const value = hv_iterval(hv, he);
- SvGETMAGIC(value);
if(!mouse_tc_check(aTHX_ param, value)){
hv_iterinit(hv); /* reset */
return FALSE;
if(IsObject(instance)){
dMY_CXT;
HV* const instance_stash = SvSTASH(SvRV(instance));
- GV* const instance_isa = find_method_pvs(instance_stash, "isa");
+ GV* const myisa = find_method_pvs(instance_stash, "isa");
/* the instance has no own isa method */
- if(instance_isa == NULL || GvCV(instance_isa) == GvCV(MY_CXT.universal_isa)){
+ if(myisa == NULL || GvCV(myisa) == GvCV(MY_CXT.universal_isa)){
return stash == instance_stash
|| mouse_lookup_isa(aTHX_ instance_stash, HvNAME_get(stash));
}
/* the instance has its own isa method */
else {
- int retval;
- dSP;
+ SV* package;
+ int ok;
ENTER;
SAVETMPS;
- PUSHMARK(SP);
- EXTEND(SP, 2);
- PUSHs(instance);
- mPUSHp(HvNAME_get(stash), HvNAMELEN_get(stash));
- PUTBACK;
-
- call_sv((SV*)instance_isa, G_SCALAR);
-
- SPAGAIN;
-
- retval = SvTRUEx(POPs);
-
- PUTBACK;
+ package = newSVpvn_share(HvNAME_get(stash), HvNAMELEN_get(stash), 0U);
+ ok = sv_true(mcall1s(instance, "isa", sv_2mortal(package)));
FREETMPS;
LEAVE;
- return retval;
+ return ok;
}
}
return FALSE;
}
else{
bool ok;
- dSP;
ENTER;
SAVETMPS;
- PUSHMARK(SP);
- EXTEND(SP, 2);
- PUSHs(instance);
- PUSHs(sv_mortalcopy(name));
- PUTBACK;
-
- call_method("can", G_SCALAR);
-
- SPAGAIN;
- ok = SvTRUE(TOPs);
- (void)POPs;
- PUTBACK;
+ ok = sv_true(mcall1s(instance, "can", sv_mortalcopy(name)));
FREETMPS;
LEAVE;
I32 len;
I32 i;
- SvGETMAGIC(methods);
- if(!IsArrayRef(methods)){
- croak("You must pass an ARRAY ref method names");
- }
+ must_ref(methods, "an ARRAY ref for method names", SVt_PVAV);
av = (AV*)SvRV(methods);
len = av_len(av) + 1;
INSTALL_SIMPLE_READER(TypeConstraint, parent);
INSTALL_SIMPLE_READER(TypeConstraint, message);
+ INSTALL_SIMPLE_READER(TypeConstraint, type_parameter);
+
INSTALL_SIMPLE_READER_WITH_KEY(TypeConstraint, _compiled_type_constraint, compiled_type_constraint);
INSTALL_SIMPLE_READER(TypeConstraint, _compiled_type_coercion); /* Mouse specific */
INSTALL_SIMPLE_PREDICATE_WITH_KEY(TypeConstraint, has_coercion, _compiled_type_coercion);
+ INSTALL_SIMPLE_PREDICATE_WITH_KEY(TypeConstraint, __is_parameterized, type_parameter); /* Mouse specific */
void
compile_type_constraint(SV* self)
else{
check = newRV_inc((SV*)mouse_tc_generate(aTHX_ NULL, (check_fptr_t)mouse_types_check, (SV*)checks));
}
- set_slots(self, "compiled_type_constraint", check);
+ (void)set_slots(self, "compiled_type_constraint", check);
}