Tassilo Parseval <[EMAIL PROTECTED]> writes: >Hi, > >two little questions this time. > >1) When I return multiple values from an XSUB by doing a > > ST(0) = sv_newmortal(...); > ST(1) = sv_newmortal(...); > XSRETURN(2); > >do I have to do a prior EXTEND(SP, 2)? Currently I am not doing it and >it seems to work fine.
It depends how many args you are passed. If you have at least two args then at least two slots exist. But as EXTEND is a macro and cheep if it doesn't need to do anything you may as well put it in. > >2) For some parameter parsing, I'd like to get rid of a few warnings >that happen when I do a 'SvIV(ST(n))' and ST(n) is not SvIOK but rather >a string or so. SvIV() will upgrade a string that looks like a number (and indeed there is a function looks_like_a_number() you can use.) >I didn't find an interface to the warnings and so poked >around a little in warnings.h. Right now I'm doing it this way: > > CODE: > { > SV *oldwarn = PL_curcops->cop_warnings; > PL_curcops->cop_warnings = pWARN_NONE; > ... > PL_curcops->cop_warnings = oldwarn; > XSRETURN_YES; > } > >Is there a clean and commonly accepted way of doing it? I don't know - the above is exactly what Tk does in the one spot it bothers to do anything. I tend to code defensively so warnings go away. >And if not, is >the above reliable? The risk is if what you show as '...' can croak() - then perhaps something to restore the SV would be appropriate. As this is an SV there is an save_item() to do the job (I think - I always have to read scope.c for the save_xxx() stuff). > >TIA, >Tassilo