[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index][Thread Index][Top&Search][Original]
Newer xsubpp
The copy of xsubpp which I have on my disk allows for ANSI-style
declarations, and in/inout/out modifiers. Say, XSUB
int
foo( in int a, out double b, inout IV c);
can be used from Perl as
($res, $b, $c_out) = foo($a, $c_in);
Basically, 'in' is ignored, 'out' variables are not in the Perl
parameter list, 'inout' variables are in the parameter list and in the
output list.
Please tell me what you think.
Ilya
P.S. Here is the C code:
XS(XS_re_foo)
{
dXSARGS;
if (items != 2)
Perl_croak(aTHX_ "Usage: re::foo(a, c)");
{
int RETVAL;
dXSTARG;
int a = (int)SvIV(ST(0));
double b;
IV c = (IV)SvIV(ST(1));
RETVAL = foo(a, &b, &c);
XSprePUSH; PUSHi((IV)RETVAL);
EXTEND(SP,2);
PUSHs(sv_newmortal());
sv_setnv(ST(1), (double)b);
PUSHs(sv_newmortal());
sv_setiv(ST(2), (IV)c);
}
XSRETURN(3);
}
[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index][Thread Index][Top&Search][Original]