We have learned enough (and more) to implement the convenience API introduced in
Chapter 19
. They are
perl_call_va
,
perl_eval_va
, and the set of functions for accessing or modifying scalar values:
get_int
,
set_int
, and so on. We'll implement only
perl_call_va
in this section.
perl_eval_va
is a shorter form of this procedure since it doesn't expect any input parameters (the string to be
eval
'd contains all the information). The API functions to modify scalars are simple wrappers over
sv_set*
,
av_store
, and
hv_store
, and are left as an exercise to the reader.[
12
]

[12]
I've always wanted to say that! (See the Preface for the FTP site where you can download this code and other examples in this book.)

Recall that
perl_call_va
takes a NULL-terminated list of typed arguments. This list contains both input and output parameters. The following implementation processes the entire list by
XPUSH
'ing the input parameters and storing the output parameters in an array of
Out_Param
structures. Knowing the number of output parameters expected by the caller allows us to specify
G_SCALAR
,
G_ARRAY
, or
G_DISCARD
. The full code is shown in
Example 20.3
.