print
uses call_method
to call PRINT
when
io && (mg = SvTIED_mg((const SV *)io, PERL_MAGIC_tiedscalar)))
is true. The blessed object to place on the stack is
SvTIED_obj(MUTABLE_SV(io), mg)
By the way, the XS compiler can place non-declaration code before the content of CODE
, so the content of CODE
cannot start with declarations.
CODE:
STRLEN len
char* buf = SvPV(str, len);
PerlIO* io = IoIFP(sv_2io(fh));
if (io) {
...
should be
CODE:
{
STRLEN len
char* buf = SvPV(str, len);
PerlIO* io = IoIFP(sv_2io(fh));
if (io) {
...
}
or
PREINIT:
STRLEN len
char* buf = SvPV(str, len);
PerlIO* io = IoIFP(sv_2io(fh));
CODE:
if (io) {
...