User`s guide
5 Controlling Code Generation
5-14
* outputs based on the number of non-NULL inputs it
* receives. This function processes any input arguments
* and passes them to the implementation version of the
* function, appearing above.
*/
mlfV
F
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,
andintheeventthattheimplementationversionstillreturnsanoutput
(which, in MATLAB, would be assigned to the
ans variable), it deallocates the
output.
This is the corresponding
mlfVF interface function (mlfVFoo)forthefoo.m
example described at the beginning of this section. This function calls the C
Mfoo implementation function that appears i n 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
mxArray * mlfNFoo(int nargout,
mxArray * * b,
mxArray * x,
mxArray * y) {
mxArray * a = mclGetUninitializedArray();
mxArray * b__ = mclGetUninitializedArray();
mlfEnterNewContext(1, 2, b, x, y);
a = Mfoo(&b__, nargout, x, y);
mlfRestorePreviousContext(1, 2, b, x, y);
if (b != NULL) {
mclCopyOutputArg(b, b__);
} else {
mxDestroyArray(b__);
}
return mlfReturnValue(a);
}
Input argument
processing
Output argument
processing
Call M-function