Thanks - I appreciate the effort. But that isn't the approach I need here.

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.

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
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...

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

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.