|
The OUTPUT: keyword indicates that certain function parameters should be updated (new
values made visible to Perl) when the XSUB terminates or that certain values should be
returned to the calling Perl function. For simple functions which have no CODE: or PPCODE:
section, such as the sin() function above, the RETVAL variable is automatically designated as
an output value. For more complex functions the xsubpp compiler will need help to
determine which variables are output variables.
This keyword will normally be used to complement the CODE: keyword. The RETVAL variable is
not recognized as an output variable when the CODE: keyword is present. The OUTPUT: keyword is
used in this situation to tell the compiler that RETVAL really is an output variable.
The OUTPUT: keyword can also be used to indicate that function parameters are output
variables. This may be necessary when a parameter has been modified within the function and
the programmer would like the update to be seen by Perl.
bool_t
rpcb_gettime(host,timep)
char *host
time_t &timep
OUTPUT:
timep
|
|
The OUTPUT: keyword will also allow an output parameter to be mapped to a matching piece of
code rather than to a typemap.
bool_t
rpcb_gettime(host,timep)
char *host
time_t &timep
OUTPUT:
timep sv_setnv(ST(1), (double)timep);
|
|
xsubpp emits an automatic SvSETMAGIC() for all parameters in the OUTPUT
section of the XSUB, except RETVAL. This is the usually desired behavior, as it takes care of
properly invoking 'set' magic on output parameters (needed for hash or array element
parameters that must be created if they didn't exist). If for some reason, this behavior is
not desired, the OUTPUT section may contain a SETMAGIC: DISABLE line to disable
it for the remainder of the parameters in the OUTPUT section. Likewise, SETMAGIC: ENABLE
can be used to reenable it for the remainder of the OUTPUT section. See perlguts for more details about
'set' magic.
|
|