Skip to content
Find file
Fetching contributors…
Cannot retrieve contributors at this time
52 lines (43 sloc) 1.84 KB
TYPEMAP
mop_attribute * T_MOP_OBJECT
mop_class * T_MOP_OBJECT
mop_method * T_MOP_OBJECT
OUTPUT
T_MOP_OBJECT
/* T_MOP_OBJECT */
if (! $var)
SvOK_off($arg); /* return as undef */
else {
mop_state *st;
HV *hv = newHV();
char *classname = \"${my $ntt = $ntype; $ntt =~ s/Ptr//; $ntt =~ s/_/::/g; \$ntt}\";
/* take (sub)class name to use from class_sv if appropriate */
/*if (class_sv && SvOK(class_sv) && sv_derived_from(class_sv, classname))
classname = (SvROK(class_sv)) ? sv_reftype(class_sv, 0) : SvPV_nolen(class_sv);*/
sv_setsv($arg, sv_2mortal(newRV_noinc((SV*)hv)));
(void)sv_bless($arg, gv_stashpv(classname, TRUE));
/* allocate mop_state struct */
st = mop_state_create($var, $arg);
/* now attach $var to the HV */
/* done as two steps to avoid sv_magic SvREFCNT_inc and MGf_REFCOUNTED */
sv_magic((SV*)hv, NULL, '~', NULL, 0);
MOP_STATE_FROM_SV($arg) = (void *) st;
if (MOP_TRACE_LEVEL_FROM_SV($arg) >= 2)
warn(\"\t<= %s(%s %s = %p)\", \"${func_name}\", \"${ntype}\", \"${var}\", (void*)$var);
}
INPUT
T_MOP_OBJECT
/* T_MOP_OBJECT */
if (!SvOK($arg)) { /* undef */
$var = NULL; /* treat as null */
}
else if (sv_derived_from($arg, \"${my $ntt = $type; $ntt =~ s/\s+\*\s*$//; $ntt =~ s/_/::/g; \$ntt}\")) {
if (SvROK($arg)) {
$var = ($type)MOP_PTR_FROM_SV($arg);
}
else { /* mop ptr already freed or is a class name */
$var = NULL;
}
}
else
croak(\"$var is not of type ${my $ntt = $type; $ntt =~ s/\s+\*\s*$//; $ntt =~ s/_/::/g; \$ntt}\");
Jump to Line
Something went wrong with that request. Please try again.