Skip to content

Commit

Permalink
Simplify global typemap
Browse files Browse the repository at this point in the history
  • Loading branch information
Leont committed Jun 24, 2024
1 parent 2f4409b commit 42cf752
Showing 1 changed file with 59 additions and 59 deletions.
118 changes: 59 additions & 59 deletions lib/ExtUtils/typemap
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,9 @@ T_SVREF
$var = SvRV(xsub_tmp_sv);
}
else{
Perl_croak_nocontext(\"%s: %s is not a reference\",
${$ALIAS?\q[GvNAME(CvGV(cv))]:\qq[\"$pname\"]},
\"$var\");
Perl_croak_nocontext("%s: %s is not a reference",
${$ALIAS?\q[GvNAME(CvGV(cv))]:\qq["$pname"]},
"$var");
}
} STMT_END
T_SVREF_REFCOUNT_FIXED
Expand All @@ -84,9 +84,9 @@ T_SVREF_REFCOUNT_FIXED
$var = SvRV(xsub_tmp_sv);
}
else{
Perl_croak_nocontext(\"%s: %s is not a reference\",
${$ALIAS?\q[GvNAME(CvGV(cv))]:\qq[\"$pname\"]},
\"$var\");
Perl_croak_nocontext("%s: %s is not a reference",
${$ALIAS?\q[GvNAME(CvGV(cv))]:\qq["$pname"]},
"$var");
}
} STMT_END
T_AVREF
Expand All @@ -97,9 +97,9 @@ T_AVREF
$var = (AV*)SvRV(xsub_tmp_sv);
}
else{
Perl_croak_nocontext(\"%s: %s is not an ARRAY reference\",
${$ALIAS?\q[GvNAME(CvGV(cv))]:\qq[\"$pname\"]},
\"$var\");
Perl_croak_nocontext("%s: %s is not an ARRAY reference",
${$ALIAS?\q[GvNAME(CvGV(cv))]:\qq["$pname"]},
"$var");
}
} STMT_END
T_AVREF_REFCOUNT_FIXED
Expand All @@ -110,9 +110,9 @@ T_AVREF_REFCOUNT_FIXED
$var = (AV*)SvRV(xsub_tmp_sv);
}
else{
Perl_croak_nocontext(\"%s: %s is not an ARRAY reference\",
${$ALIAS?\q[GvNAME(CvGV(cv))]:\qq[\"$pname\"]},
\"$var\");
Perl_croak_nocontext("%s: %s is not an ARRAY reference",
${$ALIAS?\q[GvNAME(CvGV(cv))]:\qq["$pname"]},
"$var");
}
} STMT_END
T_HVREF
Expand All @@ -123,9 +123,9 @@ T_HVREF
$var = (HV*)SvRV(xsub_tmp_sv);
}
else{
Perl_croak_nocontext(\"%s: %s is not a HASH reference\",
${$ALIAS?\q[GvNAME(CvGV(cv))]:\qq[\"$pname\"]},
\"$var\");
Perl_croak_nocontext("%s: %s is not a HASH reference",
${$ALIAS?\q[GvNAME(CvGV(cv))]:\qq["$pname"]},
"$var");
}
} STMT_END
T_HVREF_REFCOUNT_FIXED
Expand All @@ -136,9 +136,9 @@ T_HVREF_REFCOUNT_FIXED
$var = (HV*)SvRV(xsub_tmp_sv);
}
else{
Perl_croak_nocontext(\"%s: %s is not a HASH reference\",
${$ALIAS?\q[GvNAME(CvGV(cv))]:\qq[\"$pname\"]},
\"$var\");
Perl_croak_nocontext("%s: %s is not a HASH reference",
${$ALIAS?\q[GvNAME(CvGV(cv))]:\qq["$pname"]},
"$var");
}
} STMT_END
T_CVREF
Expand All @@ -149,9 +149,9 @@ T_CVREF
SvGETMAGIC(xsub_tmp_sv);
$var = sv_2cv(xsub_tmp_sv, &st, &gvp, 0);
if (!$var) {
Perl_croak_nocontext(\"%s: %s is not a CODE reference\",
${$ALIAS?\q[GvNAME(CvGV(cv))]:\qq[\"$pname\"]},
\"$var\");
Perl_croak_nocontext("%s: %s is not a CODE reference",
${$ALIAS?\q[GvNAME(CvGV(cv))]:\qq["$pname"]},
"$var");
}
} STMT_END
T_CVREF_REFCOUNT_FIXED
Expand All @@ -162,9 +162,9 @@ T_CVREF_REFCOUNT_FIXED
SvGETMAGIC(xsub_tmp_sv);
$var = sv_2cv(xsub_tmp_sv, &st, &gvp, 0);
if (!$var) {
Perl_croak_nocontext(\"%s: %s is not a CODE reference\",
${$ALIAS?\q[GvNAME(CvGV(cv))]:\qq[\"$pname\"]},
\"$var\");
Perl_croak_nocontext("%s: %s is not a CODE reference",
${$ALIAS?\q[GvNAME(CvGV(cv))]:\qq["$pname"]},
"$var");
}
} STMT_END
T_SYSRET
Expand Down Expand Up @@ -209,59 +209,59 @@ T_PTRREF
$var = INT2PTR($type,tmp);
}
else
Perl_croak_nocontext(\"%s: %s is not a reference\",
${$ALIAS?\q[GvNAME(CvGV(cv))]:\qq[\"$pname\"]},
\"$var\")
Perl_croak_nocontext("%s: %s is not a reference",
${$ALIAS?\q[GvNAME(CvGV(cv))]:\qq["$pname"]},
"$var")
T_REF_IV_REF
if (sv_isa($arg, \"${ntype}\")) {
if (sv_isa($arg, "$ntype")) {
IV tmp = SvIV((SV*)SvRV($arg));
$var = *INT2PTR($type *, tmp);
}
else {
const char* refstr = SvROK($arg) ? \"\" : SvOK($arg) ? \"scalar \" : \"undef\";
Perl_croak_nocontext(\"%s: Expected %s to be of type %s; got %s%\" SVf \" instead\",
${$ALIAS?\q[GvNAME(CvGV(cv))]:\qq[\"$pname\"]},
\"$var\", \"$ntype\",
const char* refstr = SvROK($arg) ? "" : SvOK($arg) ? "scalar " : "undef";
Perl_croak_nocontext("%s: Expected %s to be of type %s; got %s%" SVf " instead",
${$ALIAS?\q[GvNAME(CvGV(cv))]:\qq["$pname"]},
"$var", "$ntype",
refstr, $arg
);
}
T_REF_IV_PTR
if (sv_isa($arg, \"${ntype}\")) {
if (sv_isa($arg, "$ntype")) {
IV tmp = SvIV((SV*)SvRV($arg));
$var = INT2PTR($type, tmp);
}
else {
const char* refstr = SvROK($arg) ? \"\" : SvOK($arg) ? \"scalar \" : \"undef\";
Perl_croak_nocontext(\"%s: Expected %s to be of type %s; got %s%\" SVf \" instead\",
${$ALIAS?\q[GvNAME(CvGV(cv))]:\qq[\"$pname\"]},
\"$var\", \"$ntype\",
const char* refstr = SvROK($arg) ? "" : SvOK($arg) ? "scalar " : "undef";
Perl_croak_nocontext("%s: Expected %s to be of type %s; got %s%" SVf " instead",
${$ALIAS?\q[GvNAME(CvGV(cv))]:\qq["$pname"]},
"$var", "$ntype",
refstr, $arg
);
}
T_PTROBJ
if (SvROK($arg) && sv_derived_from($arg, \"${ntype}\")) {
if (SvROK($arg) && sv_derived_from($arg, "$ntype")) {
IV tmp = SvIV((SV*)SvRV($arg));
$var = INT2PTR($type,tmp);
}
else {
const char* refstr = SvROK($arg) ? \"\" : SvOK($arg) ? \"scalar \" : \"undef\";
Perl_croak_nocontext(\"%s: Expected %s to be of type %s; got %s%\" SVf \" instead\",
${$ALIAS?\q[GvNAME(CvGV(cv))]:\qq[\"$pname\"]},
\"$var\", \"$ntype\",
const char* refstr = SvROK($arg) ? "" : SvOK($arg) ? "scalar " : "undef";
Perl_croak_nocontext("%s: Expected %s to be of type %s; got %s%" SVf " instead",
${$ALIAS?\q[GvNAME(CvGV(cv))]:\qq["$pname"]},
"$var", "$ntype",
refstr, $arg
);
}
T_PTRDESC
if (sv_isa($arg, \"${ntype}\")) {
if (sv_isa($arg, "$ntype")) {
IV tmp = SvIV((SV*)SvRV($arg));
${type}_desc = (\U${type}_DESC\E*) tmp;
$var = ${type}_desc->ptr;
}
else {
const char* refstr = SvROK($arg) ? \"\" : SvOK($arg) ? \"scalar \" : \"undef\";
Perl_croak_nocontext(\"%s: Expected %s to be of type %s; got %s%\" SVf \" instead\",
${$ALIAS?\q[GvNAME(CvGV(cv))]:\qq[\"$pname\"]},
\"$var\", \"$ntype\",
const char* refstr = SvROK($arg) ? "" : SvOK($arg) ? "scalar " : "undef";
Perl_croak_nocontext("%s: Expected %s to be of type %s; got %s%" SVf " instead",
${$ALIAS?\q[GvNAME(CvGV(cv))]:\qq["$pname"]},
"$var", "$ntype",
refstr, $arg
);
}
Expand All @@ -271,19 +271,19 @@ T_REFREF
$var = *INT2PTR($type,tmp);
}
else
Perl_croak_nocontext(\"%s: %s is not a reference\",
${$ALIAS?\q[GvNAME(CvGV(cv))]:\qq[\"$pname\"]},
\"$var\")
Perl_croak_nocontext("%s: %s is not a reference",
${$ALIAS?\q[GvNAME(CvGV(cv))]:\qq["$pname"]},
"$var")
T_REFOBJ
if (sv_isa($arg, \"${ntype}\")) {
if (sv_isa($arg, "$ntype")) {
IV tmp = SvIV((SV*)SvRV($arg));
$var = *INT2PTR($type,tmp);
}
else {
const char* refstr = SvROK($arg) ? \"\" : SvOK($arg) ? \"scalar \" : \"undef\";
Perl_croak_nocontext(\"%s: Expected %s to be of type %s; got %s%\" SVf \" instead\",
${$ALIAS?\q[GvNAME(CvGV(cv))]:\qq[\"$pname\"]},
\"$var\", \"$ntype\",
const char* refstr = SvROK($arg) ? "" : SvOK($arg) ? "scalar " : "undef";
Perl_croak_nocontext("%s: Expected %s to be of type %s; got %s%" SVf " instead",
${$ALIAS?\q[GvNAME(CvGV(cv))]:\qq["$pname"]},
"$var", "$ntype",
refstr, $arg
);
}
Expand Down Expand Up @@ -376,13 +376,13 @@ T_PTR
T_PTRREF
sv_setref_pv($arg, Nullch, (void*)$var);
T_REF_IV_REF
sv_setref_pv($arg, \"${ntype}\", (void*)new $ntype($var));
sv_setref_pv($arg, "$ntype", (void*)new $ntype($var));
T_REF_IV_PTR
sv_setref_pv($arg, \"${ntype}\", (void*)$var);
sv_setref_pv($arg, "$ntype", (void*)$var);
T_PTROBJ
sv_setref_pv($arg, \"${ntype}\", (void*)$var);
sv_setref_pv($arg, "$ntype", (void*)$var);
T_PTRDESC
sv_setref_pv($arg, \"${ntype}\", (void*)new\U${type}_DESC\E($var));
sv_setref_pv($arg, "$ntype", (void*)new\U${type}_DESC\E($var));
T_REFREF
NOT_IMPLEMENTED
T_REFOBJ
Expand Down

0 comments on commit 42cf752

Please sign in to comment.