in reply to sv_derived_from gives a confsing result

Additionally, is there a perlapi that will say what it thinks the type of THIS is?

You can find out what ST(0) is with:
warn("ST(0) is of type %s\n", HvNAME(SvSTASH(SvRV(ST(0)))));
A demo:
use Inline C => Config => BUILD_NOISY => 1; use Inline C => <<'EOC'; void foo(SV * x) { dXSARGS; if (sv_isobject(ST(0))) warn("ST(0) is of type %s\n", HvNAME(SvSTASH(SvRV(ST(0))))); else warn("Not an object\n"); XSRETURN(0); } EOC use Math::BigInt; my $obj = Math::BigInt->new(17); foo($obj);
Cheers,
Rob

Replies are listed 'Best First'.
Re^2: sv_derived_from gives a confsing result
by geoffleach (Scribe) on Mar 29, 2011 at 05:08 UTC
    Thanks, Rob. Your code, plus this:
    warn("not an object %s\n",(char *)SvPV_nolen(ST(0)));
    Revealed that ST(0) was '1', leading to the discovery that despite coding that looked like C++, Perl was not treating it as such. Seems to be related to the fact that there was no new() method.

    Sigh!

      Audio::TagLib::ID3v2::Frame::size(1) would be just as wrong in C++. The C++ equivalent of the correct code would be «frame->size()».
      Seems to be related to the fact that there was no new() method

      Sounds feasible. The method doesn't need to be called "new" (with C, at least), but if sv_isobject(sv) is to return true, then the reference (sv) does need to have been blessed into some package ... which is what "new" normally does, of course.

      Cheers,
      Rob