Main Content

createAndSetCImplementationReturn

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

Description

example

arg = createAndSetCImplementationReturn(hEntry,argType,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).

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', ...
    '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' );

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'

Example: 'Name','y1'

Name-Value Pair Arguments

Specify optional comma-separated pairs of Name,Value arguments. Name is the argument name and Value is the corresponding value. Name must appear inside quotes. You can specify several name and value pair arguments in any order as Name1,Value1,...,NameN,ValueN.

Example: 'Name','y1'

Example: 'Name','y1'

Use 'RTW_IO_OUTPUT' for output.

Example: 'IOType','RTW_IO_OUTPUT'

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.

Introduced in R2007b