diff options
author | Felipe Gasper <felipe@felipegasper.com> | 2021-01-08 11:25:14 -0500 |
---|---|---|
committer | Karl Williamson <khw@cpan.org> | 2021-05-20 21:57:41 -0600 |
commit | 3d71223710bb414352f7c1d2c8941e72db5cc9de (patch) | |
tree | 99406b7e1fcc2e0be5286e67f27c776c25456dc0 /lib | |
parent | 0763c25341992ca8860342c57282ce7f1f5d62a3 (diff) | |
download | perl-3d71223710bb414352f7c1d2c8941e72db5cc9de.tar.gz |
Give SV information in default typemap
Issue #18461
Diffstat (limited to 'lib')
-rw-r--r-- | lib/ExtUtils/typemap | 55 |
1 files changed, 40 insertions, 15 deletions
diff --git a/lib/ExtUtils/typemap b/lib/ExtUtils/typemap index db700b75bf..4417c2091b 100644 --- a/lib/ExtUtils/typemap +++ b/lib/ExtUtils/typemap @@ -217,38 +217,58 @@ T_REF_IV_REF IV tmp = SvIV((SV*)SvRV($arg)); $var = *INT2PTR($type *, tmp); } - else - Perl_croak_nocontext(\"%s: %s is not of type %s\", + else { + const char* typestr = SvROK($arg) ? \"ref: \" : SvOK($arg) ? \"scalar: \" : \"undef\"; + const char* valstr = SvROK($arg) ? sv_2pvbyte_nolen($arg) : SvPV_nolen($arg); + Perl_croak_nocontext(\"%s: %s (%s%s) is not of type %s\", ${$ALIAS?\q[GvNAME(CvGV(cv))]:\qq[\"$pname\"]}, - \"$var\", \"$ntype\") + \"$var\", + typestr, valstr, + \"$ntype\"); + } T_REF_IV_PTR if (sv_isa($arg, \"${ntype}\")) { IV tmp = SvIV((SV*)SvRV($arg)); $var = INT2PTR($type, tmp); } - else - Perl_croak_nocontext(\"%s: %s is not of type %s\", + else { + const char* typestr = SvROK($arg) ? \"ref: \" : SvOK($arg) ? \"scalar: \" : \"undef\"; + const char* valstr = SvROK($arg) ? sv_2pvbyte_nolen($arg) : SvPV_nolen($arg); + Perl_croak_nocontext(\"%s: %s (%s%s) is not of type %s\", ${$ALIAS?\q[GvNAME(CvGV(cv))]:\qq[\"$pname\"]}, - \"$var\", \"$ntype\") + \"$var\", + typestr, valstr, + \"$ntype\"); + } T_PTROBJ if (SvROK($arg) && sv_derived_from($arg, \"${ntype}\")) { IV tmp = SvIV((SV*)SvRV($arg)); $var = INT2PTR($type,tmp); } - else - Perl_croak_nocontext(\"%s: %s is not of type %s\", + else { + const char* typestr = SvROK($arg) ? \"ref: \" : SvOK($arg) ? \"scalar: \" : \"undef\"; + const char* valstr = SvROK($arg) ? sv_2pvbyte_nolen($arg) : SvPV_nolen($arg); + Perl_croak_nocontext(\"%s: %s (%s%s) is not of type %s\", ${$ALIAS?\q[GvNAME(CvGV(cv))]:\qq[\"$pname\"]}, - \"$var\", \"$ntype\") + \"$var\", + typestr, valstr, + \"$ntype\"); + } T_PTRDESC if (sv_isa($arg, \"${ntype}\")) { IV tmp = SvIV((SV*)SvRV($arg)); ${type}_desc = (\U${type}_DESC\E*) tmp; $var = ${type}_desc->ptr; } - else - Perl_croak_nocontext(\"%s: %s is not of type %s\", + else { + const char* typestr = SvROK($arg) ? \"ref: \" : SvOK($arg) ? \"scalar: \" : \"undef\"; + const char* valstr = SvROK($arg) ? sv_2pvbyte_nolen($arg) : SvPV_nolen($arg); + Perl_croak_nocontext(\"%s: %s (%s%s) is not of type %s\", ${$ALIAS?\q[GvNAME(CvGV(cv))]:\qq[\"$pname\"]}, - \"$var\", \"$ntype\") + \"$var\", + typestr, valstr, + \"$ntype\"); + } T_REFREF if (SvROK($arg)) { IV tmp = SvIV((SV*)SvRV($arg)); @@ -263,10 +283,15 @@ T_REFOBJ IV tmp = SvIV((SV*)SvRV($arg)); $var = *INT2PTR($type,tmp); } - else - Perl_croak_nocontext(\"%s: %s is not of type %s\", + else { + const char* typestr = SvROK($arg) ? \"ref: \" : SvOK($arg) ? \"scalar: \" : \"undef\"; + const char* valstr = SvROK($arg) ? sv_2pvbyte_nolen($arg) : SvPV_nolen($arg); + Perl_croak_nocontext(\"%s: %s (%s%s) is not of type %s\", ${$ALIAS?\q[GvNAME(CvGV(cv))]:\qq[\"$pname\"]}, - \"$var\", \"$ntype\") + \"$var\", + typestr, valstr, + \"$ntype\"); + } T_OPAQUE $var = *($type *)SvPV_nolen($arg) T_OPAQUEPTR |