develooper Front page | perl.perl5.porters | Postings from October 2016

Nullable XS types

Thread Next
Paul "LeoNerd" Evans
October 22, 2016 23:06
Nullable XS types
Message ID:
Currently I have to do somewhat awkward steps to make a type that XS is
happy to let turn perl-level undef into C-level NULL on input:

This is somewhat awkward as, in this typemap file, I've had to decide
what entire types are always nullable, or which ones never are. I can't
make a decision on a per-function basis what will happen.

I would like to be able to decide this at the level of individual
functions. Does anyone have any suggestions?

Ideeeeally what I'd love is to be able to simply type:

    SV *self
    Tickit::Rect? rect

or some other suitable abuse of notation, to say "Hey, XS, allow a
perl-level undef to come in here, and that means the C-level value
should be NULL". Perhaps similar for OUTPUT types

    SV *self

to mean that if I set RETVAL = NULL then that means it should return an
undef to perl.

Short of that somewhat-pipedream, is there anything practical I can do
now, with existing technology, to make this a little less awkward?

Paul "LeoNerd" Evans      |  |

Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About