ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/JSON-XS/XS.xs
(Generate patch)

Comparing JSON-XS/XS.xs (file contents):
Revision 1.53 by root, Tue Jul 10 15:45:34 2007 UTC vs.
Revision 1.54 by root, Tue Jul 10 16:22:31 2007 UTC

493 // we re-bless the reference to get overload and other niceties right 493 // we re-bless the reference to get overload and other niceties right
494 GV *to_json = gv_fetchmethod_autoload (SvSTASH (sv), "TO_JSON", 0); 494 GV *to_json = gv_fetchmethod_autoload (SvSTASH (sv), "TO_JSON", 0);
495 495
496 if (to_json) 496 if (to_json)
497 { 497 {
498 int count;
498 dSP; 499 dSP;
499 500
500 ENTER; SAVETMPS; PUSHMARK (SP); 501 ENTER; SAVETMPS; PUSHMARK (SP);
501 XPUSHs (sv_bless (sv_2mortal (newRV_inc (sv)), SvSTASH (sv))); 502 XPUSHs (sv_bless (sv_2mortal (newRV_inc (sv)), SvSTASH (sv)));
502 503
503 // calling with G_SCALAR ensures that we always get a 1 return value 504 // calling with G_SCALAR ensures that we always get a 1 return value
504 // check anyways.
505 PUTBACK; 505 PUTBACK;
506 assert (1 == call_sv ((SV *)GvCV (to_json), G_SCALAR)); 506 call_sv ((SV *)GvCV (to_json), G_SCALAR);
507 SPAGAIN; 507 SPAGAIN;
508 508
509 // catch this surprisingly common error 509 // catch this surprisingly common error
510 if (SvROK (TOPs) && SvRV (TOPs) == sv) 510 if (SvROK (TOPs) && SvRV (TOPs) == sv)
511 croak ("%s::TO_JSON method returned same object as was passed instead of a new one", HvNAME (SvSTASH (sv))); 511 croak ("%s::TO_JSON method returned same object as was passed instead of a new one", HvNAME (SvSTASH (sv)));

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines