I have made this work by making the declaration variadic, which gives me the unfettered ability to process the third argument. But it also required me to copy all the ugly casts that the xs compiler did to convert to the structure pointer.
There must be some typemap magic that would have the same effect with less mumbling. But the documentation is sparse and the crystal is cloudy...routine(a, b=4,...) char * a; int b PREINIT: foo_t * c = NULL; CODE: if (items > 2 ) { if (SvOK(ST(2))) { /* defined */ if (SvROK(ST(2))) { /* reference */ IV tmp = SvIV((SV*)SvRV(ST(2))); c = INT2PTR(foo_t *,tmp); } else Perl_croak(aTHX_ "c is not a reference"); } } ... continuing as before
This communication may not represent my employer's views, if any, on the matters discussed.
In reply to Re^2: XS: How to enable passing ref or undef?
by tlhackque
in thread XS: How to enable passing ref or undef?
by tlhackque
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |