User`s guide

Internal Interface Functions
5-15
mlfVF Interface Function
The Compiler produces this interface function only when the M-function uses
the variable
nargout and has at least one output. This void interface function
specifies zero output arguments to the implementation version of the function,
and in the event that the implementation version still returns an output
(which, in MATLAB, would be assigned to the
ans variable), it deallocates the
output.
This is the corresponding
mlfVF interface function (mlfVFoo) for the foo.m
example described at the beginning of this section. This function calls the C
Mfoo implementation function that appears in foo.c:
/*
* The function "mlfVFoo" contains the void interface for
* the "foo" M-function from file
* "<matlab>\extern\examples\compiler\foo.m" (lines 1-8). The
* void interface is only produced if the M-function uses
* the special variable "nargout", and has at least one
* output. The void interface function specifies zero
* output arguments to the implementation version of the
* function, and in the event that the implementation
* version still returns an output (which, in MATLAB, would
* be assigned to the "ans" variable), it deallocates the
* output. This function processes any input arguments and
* passes them to the implementation version of the
* function, appearing above.
*/
void mlfVFoo(mxArray * x, mxArray * y) {
/* ------------- Input Argument Processing ------------ */
mxArray * a = NULL;
mxArray * b = NULL;
mlfEnterNewContext(0, 2, x, y);
/* ----------------- Call M-Function ------------------ */
a = Mfoo(&b, 0, x, y);
/* ------------- Output Argument Processing ----------- */
mlfRestorePreviousContext(0, 2, x, y);
mxDestroyArray(a);
mxDestroyArray(b);
}