Define Missing SHAPE
Parameter
In C++, pointer arguments are used for both scalar data and array data. To use a pointer
as an array, MATLAB® needs dimension information to safely convert the array between C++ and
MATLAB. The SHAPE
parameter helps you specify the dimensions for the
pointer.
Note
Pointers representing arrays of C++ class objects can only be used as scalars. Define
SHAPE as 1
in the library definition file.
The following example C++ signatures show you how to specify the shape of an argument. In these tables, the descriptions for the functions in the C++ Signature and Role of Pointer column are based on assumed knowledge of the arguments. The signature itself does not provide this information.
Define Pointer Argument to Fixed Scalar
C++ Signature and Role of Pointer | defineArgument Values |
---|---|
The input to this function is a scalar pointer
| For argument defineArgument(readScalarPtrDefinition, "in", ... "int32", "input", 1); |
The input to this function is a scalar pointer to class
| For argument defineArgument(readScalarPtrDefinition, "in", ... "clib.cppUseCases.ns.MyClass2", "input", 1); |
Define Pointer Argument
C++ Signature | defineArgument Values |
---|---|
The input to this function is a pointer to an integer array of length
| For argument defineArgument(readMatrix1DPtrDefinition, "mat", ... "int32", "input", "m"); |
The input to this function is a pointer to a fixed-length array
| For argument defineArgument(readMatrix1DPtrFixedSizeDefinition, ... "mat", "int32", "input", 5); |
The input to this function is a pointer to a two-dimensional integer
matrix
| For argument defineArgument(readMatrix2DPtrDefinition, "mat", ... "int32", "input", ["m","n"]); |
The input to this function is a pointer to a two-dimensional matrix
| For argument defineArgument(readMatrix2DPtrFixedSizeDefinition, ... "mat", "int32", "input", 6); |
The input to this function is a pointer to a three-dimensional matrix
| For argument defineArgument(readMatrix3DPtrDefinition, "mat", ... "int32", "input", ["m","n","p"]); |
Define Array Argument
C++ Signature | defineArgument Values |
---|---|
The input to this function is a one-dimensional array
| For argument defineArgument(readMatrix1DArrDefinition, "mat", ... "int32", "input", "len"); |
The input to this function is a two-dimensional array
| For argument defineArgument(readMatrix2DArrDefinition, "mat", ... "int32", "input", ["len","typeSz"]); |
Define Output Pointer Argument
C++ Signature | defineArgument Values |
---|---|
The input to this function is a pointer to an array of length
| For the return value defineOutput(getRandomValuesDefinition, "RetVal", ... "int32", "len"); |
The input to this function is a pointer to an array of length
| For the return value defineOutput(getRandomValuesDefinition, "RetVal", ... "int32", "len", "DeleteFcn", "CustomDeleteFcn"); |
The output argument of this function is a pointer to a fixed-length array.
| For the return value defineOutput(getRandomValuesFixedSizeDefinition, ... "RetVal", "int32", 5); |
The output argument of this function is a pointer to a 2-by-2 array.
| For the return value defineOutput(getRandomValuesArrayDefinition, ... "RetVal", "double", [2,2]); |
The output argument of this function is a pointer to a 1-by-2 vector of
type double. The library provides a function named
| For the return value defineOutput(getRandomValuesDoubleDefinition, ... "RetVal", "double", 2, "DeleteFcn", "CustomDeleteFcn"); |
The output argument of this function is a pointer to a 1-by-2 vector of
type
| For the return value defineOutput(getRandomConstDoubleDefinition, ... "RetVal", "double", 2, "DeleteFcn", "CustomDeleteFcn"); |
Define Additional Output Arguments
C++ Signature | defineArgument Values |
---|---|
This function returns an integer value and the value to which input
argument
| For argument defineArgument(getValuesDefinition, "arg", "int32", "output", 1); |
To call the function built into interface
[out1, out2] = clib.A.getValues |
Define Scalar Object Argument
C++ Signature | defineArgument Values |
---|---|
The input to this function is a pointer to class
| For the defineArgument(addClassByPtrDefinition, "myc2", ... "clib.cppUseCases.ns.MyClass2", "input", 1); |
The input to this function is a pointer to class
| For argument defineArgument(updateClassByPtrDefinition, "myc2", ... "clib.cppUseCases.ns.MyClass2", "input", 1); |
The input to this function is a pointer to class
| For argument defineArgument(readClassByPtrDefinition, "myc2", ... "clib.cppUseCases.ns.MyClass2", "input", 1); |
The input to this function is a pointer to class
| For argument defineArgument(fillClassByPtrDefinition, "myc2", ... "clib.cppUseCases.ns.MyClass2", "input", 1); |
Define Matrix Argument
C++ Signature | defineArgument Values |
---|---|
The input to this function is a pointer to an integer vector of length
| For argument defineArgument(updateMatrix1DPtrByXDefinition, ... "mat", "int32", "inputoutput", "len"); |
The input to this function is a reference to an integer array of length
| For argument defineArgument(updateMatrix1DArrByXDefinition, ... "mat", "int32", "inputoutput", "len"); |
The input to this function is a pointer to an integer vector of length
| For argument defineArgument(addValuesByPtrDefinition, "mat", ... "int32", "input", "len"); |
The input to this function is a reference to an integer array of length
| For argument defineArgument(addValuesByArrDefinition, ... "mat", "int32", "input", "len"); |
This function creates an integer vector of length
| For argument defineArgument(fillRandomValuesToPtrDefinition, ... "mat", "int32", "output", "len"); |
This function creates an integer vector of length
| For argument defineArgument(fillRandomValuesToArrDefinition, ... "mat", "int32", "output", "len"); |
Define String Argument
C++ Signature | defineArgument Values |
---|---|
The input to this function is a C-style string.
| For argument defineArgument(getStringCopyDefinition, "str", ... "string", "input", "nullTerminated"); |
The return value for this function is a string.
| For return value defineOutput(getStringCopyDefinition, ... "RetVal", "string", "nullTerminated"); |
The return value for this function is a string of length
| MATLAB defines argument %defineArgument(getMessageDefinition, "pmsg", ... "clib.array.libname.Char", "input", <SHAPE>); To
define
defineArgument(getMessageDefinition, "pmsg", ... "string, "output", "nullTerminated", ... "NumElementsInBuffer", "buf"); |
The input to this function is a string specified by length
| For argument defineArgument(readCharArrayDefinition, ... "chArray", "char", "input", "len"); |
The input to this function is an array of type
| For argument defineArgument(readInt8ArrayDefinition, ... "int8Array", "int8", "input", "len"); |
The return value for this function is a scalar of characters.
| For return value defineOutput(getRandomCharScalarDefinition, ... "RetVal", "char", 1); |
The return value for this function is a 2 element character vector.
| For return value defineOutput(getRandomCharsDefinition, ... "RetVal", "char", 2); |
The return value for this function is a 2 element character vector. The
library provides a function named
| For return value defineOutput(getRandomCharsDefinition, ... "RetVal", "char", 2 "DeleteFcn", "CustomDeleteFcn"); |
The type of the return value for this function is
| For return value defineOutput(getRandomInt8ScalarDefinition, ... "RetVal", "int8", 1); |
This function updates the input argument
| For argument defineArgument(updateCharArrayDefinition, ... "chArray", "int8", "inputoutput", "len"); |
The input to these functions is an array of C-string of size
| For argument defineArgument(readCStrArrayDefinition, ... "strs", "string", "input", ["numStrs", "nullTerminated"]) |
The input to these functions is a
| Call defineArgument(readConstCStrArrayDefinition, ... "strs", "string", "input", ["numStrs", "nullTerminated"]) |
The input to this function is a fixed-size array of C-string.
| For argument defineArgument(readFixedCStrArrayDefinition, ... "strs", "string", "input", [5, "nullTerminated"]) |
The input to this function is a fixed-size
| Call defineArgument(readConstFixedCStrArrayDefinition, ... "strs", "string", "input", [5, "nullTerminated"]) |
Define Typed Pointer Argument
C++ Signature | defineArgument Values |
---|---|
The input to this function is a pointer to typedef
| For argument defineArgument(useTypedefPtrDefinition, "input1", ... "int16", "input", 1); |
Use Property or Method as SHAPE
You can use a public nonstatic C++ data member (property) as the
SHAPE
for the return type of a nonstatic method or another nonstatic
data member (property) in the same class. The property must be defined as an integer (C++
type int
). Similarly, you can use a static C++ data members as a
SHAPE
parameter for a return type of a static method or another static
data member in the same class.
You can use a public, nonstatic C++ method as the SHAPE
parameter for
a nonstatic property or for the return type of a nonstatic method in the same class. The
method must be fully implemented, without input arguments, and the return type must be
defined as a C++ type int
.
You can use a combination of parameters, properties and methods as the
SHAPE
parameter for a method return type. If the specified
SHAPE
exists as both a parameter and a method or property, then
parameters take precedence. In this case SHAPE
is treated as a
parameter.
C++ Signature | SHAPE Values |
---|---|
The size of data member
| For property addProperty(ADefinition, "rowdata", ["rows","cols","channels"]... "Description", "clib.array.libname.Int Data member of C++ class A."); |
The size of the array returned by
| For the return value of method defineOutput(getDataDefinition, "RetVal", "clib.array.libname.Int", ... ["rows","cols","channels"]); |
The size of the array returned by
| For the return value of method defineOutput(getDataDefinition, "RetVal", "clib.array.C.Int", ["rows","channels"]); |