clibgen.MethodDefinition.defineOutput - Add output argument definition for C++ method - MATLAB (original) (raw)
Class: clibgen.MethodDefinition
Namespace: clibgen
Add output argument definition for C++ method
Syntax
defineOutput(methodDef,argName,mltype) defineOutput(methodDef,argName,mltype,shape) defineOutput(___,argDesc) defineOutput(___,'DeleteFcn',deleteFcn)
Description
defineOutput([methodDef](#d126e226685),[argName](#d126e226707),[mltype](#mw%5F4b7712ca-9e25-47f6-9471-e66d360d3000))
adds an output argument definition for a C++ method.
defineOutput([methodDef](#d126e226685),[argName](#d126e226707),[mltype](#mw%5F4b7712ca-9e25-47f6-9471-e66d360d3000),[shape](#d126e226753))
provides information about data dimensions.
defineOutput(___,[argDesc](#mw%5F8c659985-017d-48f7-a29e-290f997398a1))
adds an argument description, and can include any of the input parameters in previous syntaxes.
defineOutput(___,'DeleteFcn',[deleteFcn](#mw%5F8672d44a-1c54-41f3-af96-3d3042810051))
specifies a C++ library deleter function to manage the memory of the argument.
Input Arguments
methodDef
— Method definition
clibgen.MethodDefinition
Method definition, specified as a clibgen.MethodDefinition object.
argName
— C++ output argument name
"RetVal"
(default) | string scalar | character vector
C++ output argument name, specified as a string scalar or a character vector.
mltype
— MATLAB type
string scalar | character vector
MATLAB® type, specified as a string scalar or a character vector. For more information, see Define Missing MLTYPE Parameter.
shape
— Dimension definition
string vector | scalar text | positive integer vector | "nullTerminated"
| cell array
Dimension definition used by MATLAB to define data dimensions, specified as a string vector, scalar text, positive integer vector, "nullTerminated"
, or a cell array. For a cell array, the elements are a combination of scalar text and scalar positive integers. For more information, see Define Missing SHAPE Parameter.
If you can define the argument dimension as a fixed scalar value, then enter a number, such as 5
.
If the dimension is defined by another argument, then enter the argument name as a string. For example, consider the following C++ signature. If argument len
defines the length of data
, then the value of Shape
is "len"
.
myFunc(const int *data, int len)
If the size of an argument is defined by an array, then the value ofShape
is one of the following:
1
- Fixed dimensions: Enter a numerical array, such as
[5,2]
. - Variable dimensions: Enter a string array of parameter names, such as
["row","col"]
.
If the C++ type for the argument is a string, then use these options to choose values for theMATLABType
and Shape
arguments.
C++ Type | MATLABType | DIRECTION | Options for SHAPE |
---|---|---|---|
char*a | "int8" | "input" | Scalar valueArray of scalar values |
char** char*[] | "string" | "input" | cell |
const char* | "char" | Scalar valueArray of scalar values | |
"string" | "input" | "nullTerminated" | |
const char** const char*[] | "char" | "input" | Scalar valueArray of scalar values |
"string" | "input" | "nullTerminated" | |
a These types are equivalent to MATLABchar: wchar_tchar16_tchar32_t |
For more information, see C++ to MATLAB Data Type Mapping.
argDesc
— C++ argument description
string scalar | character vector
C++ argument description, specified as a string scalar or a character vector.
deleteFcn
— Deleter function
string scalar | character vector
Deleter function, specified as a string scalar or character vector. The deleter can be the C++ standard delete
operator or a user-defined function. If the C++ return type is void*
, then deleteFcn
must be a user-defined function. If the function returns a pointer, then MATLAB takes ownership and manages the life cycle of the memory represented by the argument. If deleteFcn
is not specified, then the library is responsible for managing the memory.
If you specify a library function for the deleter function, then that function is not included in the interface and users cannot call the function from MATLAB. The MATLAB user calls the MATLABdelete
function, which calls the function specified bydeleteFcn
.
Example: 'DeleteFcn','objFree'
Version History
Introduced in R2019a