Main Content

createAndSetCImplementationReturn

Create implementation return argument from specified properties and add to implementation for code replacement table entry

Description

arg = createAndSetCImplementationReturn(hEntry,argType,Name=Name,varargin) creates an implementation return argument from specified properties and adds the argument to the implementation for a code replacement table.

Implementation return arguments must describe fundamental numeric data types, such as double, single, int32, int16, int8, uint32, uint16, uint8, or boolean (not fixed-point data types).

example

Examples

collapse all

This example shows how to use the createAndSetCImplementationReturn function with the createAndAddImplementationArg function to specify the output and input arguments for an operator implementation.

op_entry = RTW.TflCOperationEntry;
.
.
.
createAndSetCImplementationReturn(op_entry, 'RTW.TflArgNumeric', ...
    'Name',       'y1', ...
    'IOType',     'RTW_IO_OUTPUT', ...
    'IsSigned',   true, ...
    'WordLength', 32, ...
    'FractionLength', 0);
                                  
createAndAddImplementationArg(op_entry, 'RTW.TflArgNumeric',...
    'Name',       'u1', ...
    'IOType',     'RTW_IO_INPUT',...
    'IsSigned',   true,...
    'WordLength', 32, ...
    'FractionLength', 0 );
                               
createAndAddImplementationArg(op_entry, 'RTW.TflArgNumeric',...
    'Name',       'u2', ...
    'IOType',     'RTW_IO_INPUT',...
    'IsSigned',   true,...
    'WordLength', 32, ...
    'FractionLength', 0 );

These examples show some common type specifications using createAndSetCImplementationReturn.

hEntry = RTW.TflCOperationEntry;
.
.
.
% uint8:
createAndSetCImplementationReturn(hEntry, 'RTW.TflArgNumeric', ...
    'Name',           'y1', ... 
    'IOType',         'RTW_IO_OUTPUT', ...
    'Type',           'uint8' );

% single:
createAndSetCImplementationReturn(hEntry, 'RTW.TflArgNumeric', ...
    'Name',         'y1', ... 
    'IOType',       'RTW_IO_OUTPUT', ...
    'Type',         'single' );

% double:
createAndSetCImplementationReturn(hEntry, 'RTW.TflArgNumeric', ...
    'Name',         'y1', ... 
    'IOType',       'RTW_IO_OUTPUT', ...
    'Type',         'double' );

% boolean:
createAndSetCImplementationReturn(hEntry, 'RTW.TflArgNumeric', ...
    'Name',         'y1', ... 
    'IOType',       'RTW_IO_OUTPUT', ...
    'Type',         'boolean' );

% complex:
createAndSetCImplementationReturn(hEntry, 'RTW.TflArgNumeric', ...
    'Name',         'y1', ... 
    'IOType',       'RTW_IO_OUTPUT', ...
    'Type',         'cint16' );

These examples show how to specify types by using several properties of the data type.

hEntry = RTW.TflCOperationEntry;
.
.
.
% uint8:
createAndSetCImplementationReturn(hEntry, 'RTW.TflArgNumeric', ...
    'Name',           'y1', ... 
    'IOType',         'RTW_IO_OUTPUT', ...
    'IsSigned',       false, ...
    'WordLength',     8, ...
    'FractionLength', 0 );

% single:
createAndSetCImplementationReturn(hEntry, 'RTW.TflArgNumeric', ...
    'Name',         'y1', ... 
    'IOType',       'RTW_IO_OUTPUT', ...
    'DataTypeMode', 'single' );

% double:
createAndSetCImplementationReturn(hEntry, 'RTW.TflArgNumeric', ...
    'Name',         'y1', ... 
    'IOType',       'RTW_IO_OUTPUT', ...
    'DataTypeMode', 'double' );

% boolean:
createAndSetCImplementationReturn(hEntry, 'RTW.TflArgNumeric', ...
    'Name',         'y1', ... 
    'IOType',       'RTW_IO_OUTPUT', ...
    'DataTypeMode', 'boolean' );

This example shows how to create a return argument that is a two-dimensional matrix of size 2-by-1 or larger and has base type uint8.

hEntry = RTW.TflCOperationEntry;
% .
% .
% .
createAndSetCImplementationReturn(hEntry, 'RTW.TflArgMatrix', ... 
    'Name',       'mat_out1', ...
    'IOType',     'RTW_IO_OUTPUT', ...
    'DimRange',   [2 1; Inf Inf], ...
    'BaseType',   'uint8');

Input Arguments

collapse all

The hEntry is a handle to a code replacement table entry previously returned by instantiating a code replacement entry class, such as hEntry = RTW.TflCFunctionEntry or hEntry = RTW.TflCOperationEntry.

Example: op_entry

The argType is a character vector or string scalar that specifies the argument type to create. Use 'RTW.TflArgNumeric' for numeric.

Example: 'RTW.TflArgNumeric'

Name of the argument to create, specified as a character vector or string scalar.

Example: 'Name','y1'

Example: 'Name','argOut'

Example: 'IOType','RTW_IO_OUTPUT'

Name-Value Arguments

Specify optional pairs of arguments as Name1=Value1,...,NameN=ValueN, where Name is the argument name and Value is the corresponding value. Name-value arguments must appear after other arguments, but the order of the pairs does not matter.

Before R2021a, use commas to separate each name and value, and enclose Name in quotes.

Example: 'IOType','RTW_IO_OUTPUT'

Use 'RTW_IO_OUTPUT' for output.

Example: 'IOType','RTW_IO_OUTPUT'

Data type of the argument, specified as a character vector or string scalar. You can specify built-in MATLAB data types such as uint8, boolean, double, and others. You can also specify data types that you create by using the fixdt function, such as fixdt(1,16,2). When you specify the Type, you do not need to specify other properties of the type, such as the signedness or word length.

Example: 'Type','uint8'

Example: 'Type','fixdt(1,16,2)'

Boolean value that, when set to true, indicates that the argument is signed. The default is true.

Example: 'IsSigned',true

Example: 'WordLength',16

You can specify either DataType (with Scaling) or DataTypeMode, but do not specify both.

Example: 'DataTypeMode','Fixed-point: binary point scaling'

Example: 'DataType','Fixed'

Use 'BinaryPoint' for binary-point scaling or 'SlopeBias' for slope and bias scaling.

Example: 'Scaling','BinaryPoint'

You can optionally specify either this parameter or a combination of the SlopeAdjustmentFactor and FixedExponent parameters, but do not specify both.

Example: 'Slope',1.0

You can optionally specify either the Slope parameter or a combination of this parameter and the FixedExponent parameter, but do not specify both.

Example: 'SlopeAdjustmentFactor',1.0

You can optionally specify either the Slope parameter or a combination of this parameter and the SlopeAdjustmentFactor parameter, but do not specify both.

Example: 'FixedExponent',0

Example: 'Bias',0.0

Example: 'FractionLength',0

Output Arguments

collapse all

Specifying the return argument in the createAndSetCImplementationReturn function call is optional.

Version History

Introduced in R2007b

expand all