%if EXISTS("_CIINFOLIB_") == 0
%assign _CIINFOLIB_ = 1
%include "dtypelib.tlc"
%selectfile NULL_FILE
%function SLibResetCodeInfoLib() void
%createrecord CodeInfoMapEmpty { /
TypeMap {} /
VariableMap {} /
StructExprMap {} /
InternalDataTypeMap {} /
InternalDataMap {} /
ConstDataMap {} /
TimingInterfaceMap {} /
LookupMap {} /
ExportFunctionMap {} /
}
%assign ::CodeInfoMap = CodeInfoMapEmpty
%endfunction
%function SLibGetConstTypeObject(typeIdx) Output
%if LibCGTypeIsPointer(typeIdx)
%assign baseTypeObj = SLibGetCoderTypeObject(LibCGTypeBaseIndex(typeIdx), 1, 0)
%return FcnGetPointerTypeObj(baseTypeObj, 0, 0)
%elseif LibCGTypeWidth(typeIdx) != 1
%return SLibGetCoderTypeObject(typeIdx, 1, 0)
%else
%return SLibGetCoderTypeObject(typeIdx, 0, 0)
%endif
%endfunction
%function SLibGetCoderTypeObject(typeIdx, const, volatile) Output
%return SLibGetCoderTypeObjectInternal(typeIdx, const, volatile, TLC_FALSE)
%endfunction
%function SLibGetCoderTypeObjectInternal(typeIdx, const, volatile, useStdContainerType) Output
%assign typeObj = "Type_%<typeIdx>_R%<const>_V%<volatile>_C%<useStdContainerType>"
%if ISFIELD(CodeInfoMap.TypeMap, typeObj)
%else
%assign cgType = ::CompiledModel.CGTypes.CGType[typeIdx]
%if (SLibCGTypeIsStructStrict(typeIdx))
%<FcnCreateStructTypeObj(typeObj, typeIdx, const, volatile)>/
%elseif useStdContainerType && (LibCGTypeIsStdContainer(typeIdx) || LibCGTypeIsStdContainerClass(typeIdx))
%<FcnCreateStdContainerClassTypeObj(typeObj, typeIdx, const, volatile)>/
%elseif (SLibCGTypeIsMatrixStrict(typeIdx))
%assign dummyWidth = LibCGTypeSymbolicWidth(typeIdx)
%assign dummyDims = LibCGTypeSymbolicDimensions(typeIdx)
%<FcnCreateMatrixTypeObj(typeObj, typeIdx, const, volatile)>/
%elseif (SLibCGTypeIsComplexStrict(typeIdx))
%<FcnCreateComplexTypeObj(typeObj, typeIdx, const, volatile)>/
%elseif (LibCGTypeIsPointer(typeIdx))
%<FcnCreatePointerTypeObjNew(typeObj, typeIdx, const, volatile)>/
%elseif (LibCGTypeIsRenamed(typeIdx))
%assign typeName = cgType.Name
%<FcnCreateAliasTypeObj(typeObj, typeIdx, const, volatile)>/
%elseif (LibCGTypeIsVoid(typeIdx))
%<FcnCreateOpaqueTypeObj(typeObj, cgType, 0, 0)>/
%elseif (SLibCGTypeIsEnumStrict(typeIdx))
%<FcnCreateEnumTypeObj(typeObj, cgType, const, volatile)>/
%elseif (cgType.SLTypeIdx != -1)
%assign dTypeIdx = cgType.SLTypeIdx
%assign dTypeRec = ::CompiledModel.DataTypes.DataType[dTypeIdx]
%if (LibIsFundamentalBuiltInDataType(dTypeIdx))
%<FcnCreateBuiltInTypeObj(typeObj, cgType, const, volatile)>/
%elseif (LibIsHalfDataType(dTypeIdx))
%<FcnCreateHalfTypeObj(typeObj, cgType, const, volatile)>/
%elseif (dTypeRec.IsFixedPoint)
%<FcnCreateFixPtTypeObj(typeObj, typeIdx, const, volatile)>/
%elseif (LibIsStringDataType(dTypeIdx))
%if ISFIELD(dTypeRec, "ContainerCGTypeIdx") && ( LibCGTypeIsPointer(dTypeRec.ContainerCGTypeIdx) )
%assign typeObj = SLibGetCoderTypeObject(dTypeRec.ContainerCGTypeIdx, const, volatile)
%return typeObj
%elseif ISFIELD(dTypeRec, "ContainerCGTypeIdx") && ( LibCGTypeIsClass(dTypeRec.ContainerCGTypeIdx) )
%assign containerTypeRec =::CompiledModel.CGTypes.CGType[dTypeRec.ContainerCGTypeIdx]
%<FcnCreateStringClassTypeObj(typeObj, containerTypeRec, dTypeRec.ContainerCGTypeIdx, const, volatile)>/
%else
%if (cgType.Name == "SLStringType")
%assign containerTypeIdx = dTypeRec.ContainerCGTypeIdx
%assign dummyWidth = LibCGTypeSymbolicWidth(containerTypeIdx)
%assign dummyDims = LibCGTypeSymbolicDimensions(containerTypeIdx)
%<FcnCreateMatrixTypeObj(typeObj, containerTypeIdx, const, volatile)>/
%else
%<FcnCreateCharTypeObj(typeObj, cgType, const, volatile)>/
%endif
%endif
%else
%<FcnCreateOpaqueTypeObj(typeObj, cgType, 0, 0)>/
%endif
%else
%<LibReportFatalError("CodeInfo: Unhandled Data Type")>
%endif
%<LibAddIdentifier(CodeInfoMap.TypeMap, typeObj, typeIdx)>/
%endif
%return typeObj
%endfunction
%function SLibGetCodeInfoCGTypeIdx(aRecord) void
%assign cgTypeIdx = LibGetRecordCGTypeIdx(aRecord)
%if ISFIELD(aRecord, "ContainerCGTypeIdx") && LibCGTypeContainsStdContainer(aRecord.ContainerCGTypeIdx)
%return aRecord.ContainerCGTypeIdx
%elseif LibCGTypeIsMatrix(cgTypeIdx) && LibCGTypeWidth(cgTypeIdx) == 1
%return LibCGTypeBaseIndex(cgTypeIdx)
%endif
%return cgTypeIdx
%endfunction
%function SLibGetRTWVariableObject(varKey, typeObj, identifier, ...
owner, defnFile, declFile) Output
%assign varObj = "Var_%<varKey>"
%if ISFIELD(CodeInfoMap.VariableMap, varObj)
%else
%assign comment = "% Variable: %<varObj>"
%<comment>
%<varObj> = RTW.Variable(%<typeObj>, '%<identifier>');
%<varObj>.Owner = '%<owner>';
%<varObj>.DeclarationFile = '%<declFile>';
%if !ISEMPTY(owner)
%<varObj>.DefinitionFile = '%<defnFile>';
%endif
%<LibAddIdentifier(CodeInfoMap.VariableMap, varObj, identifier)>
%endif
%return varObj
%endfunction
%function SLibGetRTWPointerVariableObject(varKey, typeObj, identifier, tgtVar) Output
%assign varObj = "PtrVar_%<varKey>"
%if ISFIELD(CodeInfoMap.VariableMap, varObj)
%else
%assign comment = "% Pointer Variable: %<varObj>"
%<comment>
%<varObj> = RTW.PointerVariable(%<typeObj>, '%<identifier>', %<tgtVar>);
%<LibAddIdentifier(CodeInfoMap.VariableMap, varObj, identifier)>
%endif
%return varObj
%endfunction
%function SLibGetRTWArrayExprObject(typeObj, baseRegion, offset) Output
%assign varObj = "AExp_%<baseRegion>_%<offset>"
%if ISFIELD(CodeInfoMap.VariableMap, varObj)
%else
%assign comment = "% Array Expression: "
%<comment>
%<varObj> = RTW.ArrayExpression(%<baseRegion>, %<offset>, %<typeObj>);
%<LibAddIdentifier(CodeInfoMap.VariableMap, varObj, 0)>
%endif
%return varObj
%endfunction
%function SLibGetRTWCustomVariableObject(varKey, typeObj, identifier, ...
owner, defnFile, declFile) Output
%assign varObj = "Var_%<varKey>"
%if ISFIELD(CodeInfoMap.VariableMap, varObj)
%else
%assign comment = "% Variable: %<varObj>"
%<comment>
%<varObj> = RTW.CustomVariable(%<typeObj>);
%<varObj>.Owner = '%<owner>';
%<varObj>.DeclarationFile = '%<declFile>';
%if !ISEMPTY(owner)
%<varObj>.DefinitionFile = '%<defnFile>';
%endif
%<LibAddIdentifier(CodeInfoMap.VariableMap, varObj, identifier)>
%endif
%return varObj
%endfunction
%function SLibGetRTWLiteralObject(typeObj, value) Output
%assign varObj = "Lit_%<value>"
%if ISFIELD(CodeInfoMap.VariableMap, varObj)
%else
%assign comment = "% Literal: %<varObj>"
%<comment>
%<varObj> = RTW.Literal(%<typeObj>, %<value>);
%<LibAddIdentifier(CodeInfoMap.VariableMap, varObj, value)>
%endif
%return varObj
%endfunction
%function FcnCreateRTMMemberObject(varKey, identifier, typeObj, baseObj, tgtObj) Output
%assign varObj = "PointerExpr_%<varKey>"
%assign elemObj = "StructElem_%<varObj>"
%if ISFIELD(CodeInfoMap.StructExprMap, varObj)
%else
%assign comment = "% Structure Element: %<elemObj>"
%<comment>
%<elemObj> = coder.types.AggregateElement;
%<elemObj>.Identifier = '%<identifier>';
%<elemObj>.Type = %<typeObj>;
%assign comment = "% Pointer Expression: %<varObj>"
%<comment>
%<varObj> = RTW.PointerExpression(%<elemObj>, %<baseObj>, %<tgtObj>);
%<LibAddIdentifier(CodeInfoMap.StructExprMap, varObj, baseObj)>
%endif
%return varObj
%endfunction
%function SLibGetRTWCalibrationObject(varKey, typeObj, identifier, customAttribs, coderTypeObj) Output
%assign varObj = "Cal_%<varKey>"
%if ISFIELD(CodeInfoMap.VariableMap, varObj)
%else
%assign comment = "% Calibration: %<varObj>"
%assign csAttribs = customAttribs.ObjectProperties
%<comment>
%if ISEQUAL(customAttribs.Class, "AttribClass_AUTOSAR_CalPrm")
%<varObj> = RTW.AutosarCalibration('Calibration');
%<varObj>.Type = %<typeObj>;
%<varObj>.CodeType = %<coderTypeObj>;
%<varObj>.ElementName = '%<csAttribs.ElementName>';
%<varObj>.InterfacePath = '%<csAttribs.InterfacePath>';
%<varObj>.Port = '%<csAttribs.PortName>';
%<varObj>.CalibrationComponent = '%<csAttribs.CalibrationComponent>';
%<varObj>.ProviderPortName = '%<csAttribs.ProviderPortName>';
%elseif ISEQUAL(customAttribs.Class, "AttribClass_AUTOSAR_InternalCalPrm")
%<varObj> = RTW.AutosarCalibration('InternalCalPrm');
%<varObj>.Type = %<typeObj>;
%<varObj>.CodeType = %<coderTypeObj>;
switch '%<csAttribs.PerInstanceBehavior>'
case 'Parameter shared by all instances of the Software Component'
%<varObj>.Shared = 'true';
case 'Each instance of the Software Component has its own copy of the parameter'
%<varObj>.Shared = 'false';
otherwise
assert(false, 'Should not be here');
end
%assign mappedName = FcnGetLookupMapping(identifier)
%if ISEMPTY(mappedName)
%assign port = identifier
%else
%assign port = mappedName
%endif
%<varObj>.Port = '%<port>';
%elseif ISEQUAL(customAttribs.Class, "AttribClass_AUTOSAR_SystemConstant")
%<varObj> = RTW.AutosarCalibration('InternalCalPrm');
%else
%<LibReportFatalError("CodeInfo: Incorrect Calibration Parameter")>
%endif
%<LibAddIdentifier(CodeInfoMap.VariableMap, varObj, identifier)>
%endif
%return varObj
%endfunction
%function SLibMapDSMToRunnables(componentObj, runnableName) Output
dsmAccessS = [];
%if ISFIELD(::CompiledModel.RTWAutosar, "DSMAccessInfo")
%with ::CompiledModel.RTWAutosar
%if ISFIELD(DSMAccessInfo, runnableName)
%assign dws = DSMAccessInfo.%<runnableName>
%foreach dwIdx = SIZE(dws)[1]
temp_dsm = %<componentObj>.DataStores(%);
dsmAccessS = [dsmAccessS, temp_dsm];
%endforeach
%endif
%endwith
%endif
%return "dsmAccessS"
%endfunction
%function SLibMapCalPrmToRunnables(componentObj, runnableName) Output
calPrmReads = [];
%if ISFIELD(::CompiledModel.RTWAutosar, "ParamAccessInfo")
%with ::CompiledModel.RTWAutosar
%if ISFIELD(ParamAccessInfo, runnableName)
%assign calPrms = ParamAccessInfo.%<runnableName>
%foreach prmIdx = SIZE(calPrms)[1]
temp_par = %<componentObj>.Parameters(%);
calPrmReads = [calPrmReads, temp_par];
%endforeach
%endif
%endwith
%endif
%return "uniquifyDataAccess(calPrmReads)"
%endfunction
%function SLibGetRTWTimingObject(tid) Output
%if (TYPE(tid) == "Number")
%if SLibModelWideEventTID(tid)
%assign tid = tid
%assign tidKey = tid
%elseif (FcnGetIsInheritedSampleTime() == 1)
%assign tid = "inherited"
%assign tidKey = -3
%elseif ( ISEQUAL(SolverType, "FixedStep") && (FixedStepOpts.TID01EQ) && (tid == 0) && !IsModelReferenceSimTarget() )
%assign tid = 1
%assign tidKey = tid
%else
%assign tid = tid
%assign tidKey = tid
%endif
%elseif ISEQUAL(tid, "constant")
%assign tidKey = -1
%elseif ISEQUAL(tid, "continuous")
%assign tidKey = -2
%elseif ISEQUAL(tid, "inherited")
%assign tidKey = -3
%else
%<LibReportFatalError("CodeInfo TID: Incorrect TID specified")>
%endif
%assign timeObj = "time_%<tid>"
%<timeObj> = codeInfo.TimingProperties(getIndexFromTimingInternalId(codeInfo.TimingInternalIds, %<tidKey>));
%return timeObj
%endfunction
%function SLibGetRTWTimingObjectFromPeriod(samplePeriod) Output
%if (TYPE(samplePeriod) != "Real")
%<LibReportFatalError("CodeInfo Period: Incorrect Period specified")>
%endif
%if ISEQUAL(samplePeriod, 0)
%assign timeObj = "time_val_0"
%elseif samplePeriod < 0
%assign str = SPRINTF("%g",-samplePeriod)
%if samplePeriod > -1
%assign timeObj = "time_val_N" + FEVAL("regexprep", str, "[.-]", "n")
%else
%assign timeObj = "time_val_N" + FEVAL("regexprep", str, "[.+]", "p")
%endif
%else
%assign str = SPRINTF("%g",samplePeriod)
%if samplePeriod < 1
%assign timeObj = "time_val_P" + FEVAL("regexprep", str, "[.-]", "n")
%else
%assign timeObj = "time_val_P" + FEVAL("regexprep", str, "[.+]", "p")
%endif
%endif
%if ISFIELD(CodeInfoMap.TimingInterfaceMap, timeObj)
%else
%assign comment = "% Timing Information: %<timeObj>"
%<comment>
%<timeObj> = RTW.TimingInterface;
%<timeObj>.SamplePeriod = %<samplePeriod>;
%<LibAddIdentifier(CodeInfoMap.TimingInterfaceMap, timeObj, samplePeriod)>
%endif
%return timeObj
%endfunction
%function FcnCreateBuiltInTypeObj(typeObj, cgTypeRec, const, volatile) Output
%assign cgTypeName = cgTypeRec.Name
%assign slTypeIdx = cgTypeRec.SLTypeIdx
%assign comment = "% Built-In Type: %<slTypeIdx>"
%<comment>
%switch (slTypeIdx)
%case 0
%<typeObj> = coder.types.Double;
%<typeObj>.Name = 'double';
%break
%case 1
%<typeObj> = coder.types.Single;
%<typeObj>.Name = 'single';
%break
%case 2
%<typeObj> = coder.types.Int(8,1);
%<typeObj>.Name = 'int8';
%break
%case 3
%<typeObj> = coder.types.Int(8,0);
%<typeObj>.Name = 'uint8';
%break
%case 4
%<typeObj> = coder.types.Int(16,1);
%<typeObj>.Name = 'int16';
%break
%case 5
%<typeObj> = coder.types.Int(16,0);
%<typeObj>.Name = 'uint16';
%break
%case 6
%<typeObj> = coder.types.Int(32,1);
%<typeObj>.Name = 'int32';
%break
%case 7
%<typeObj> = coder.types.Int(32,0);
%<typeObj>.Name = 'uint32';
%break
%case 8
%<typeObj> = coder.types.Bool;
%<typeObj>.Name = 'boolean';
%break
%default
%<LibReportFatalError("coder.types.Type: Unhandled Data Type")>
%break
%endswitch
%<typeObj>.Identifier = '%<cgTypeName>';
%<typeObj>.ReadOnly = %<const>;
%<typeObj>.Volatile = %<volatile>;
%endfunction
%function FcnCreateHalfTypeObj(typeObj, cgTypeRec, const, volatile) Output
%assign cgTypeName = cgTypeRec.Name
%assign slTypeIdx = cgTypeRec.SLTypeIdx
%assign comment = "% Half Precision Type: %<slTypeIdx>"
%<typeObj> = coder.types.Half;
%<typeObj>.Name = 'half';
%<typeObj>.Identifier = '%<cgTypeName>';
%<typeObj>.ReadOnly = %<const>;
%<typeObj>.Volatile = %<volatile>;
%endfunction
%function FcnCreateFixPtTypeObj(typeObj, cgTypeIdx, const, volatile) Output
%assign cgTypeRec = ::CompiledModel.CGTypes.CGType[cgTypeIdx]
%assign cgTypeName = ::CompiledModel.CGTypes.CGType[LibCGTypeBaseIndex(cgTypeIdx)].Name
%assign dTypeRec = ::CompiledModel.DataTypes.DataType[cgTypeRec.SLTypeIdx]
%assign comment = "% Fixed-Point Type"
%<comment>
%<typeObj> = coder.types.Fixed;
%<typeObj>.Signedness = %<dTypeRec.IsSigned>;
%<typeObj>.WordLength = %<dTypeRec.RequiredBits>;
%if (dTypeRec.Bias != 0.0) || (dTypeRec.FracSlope != 1.0)
%if (fxpIsDataTypeScaledDouble(dTypeRec))
%<typeObj>.DataTypeMode = 'Scaled double: slope and bias scaling';
%else
%<typeObj>.DataTypeMode = 'Fixed-point: slope and bias scaling';
%endif
%<typeObj>.Bias = %<dTypeRec.Bias>;
%<typeObj>.SlopeAdjustmentFactor = %<dTypeRec.FracSlope>;
%<typeObj>.FixedExponent = %<dTypeRec.FixedExp>;
%else
%if (fxpIsDataTypeScaledDouble(dTypeRec))
%<typeObj>.DataTypeMode = 'Scaled double: binary point scaling';
%else
%<typeObj>.DataTypeMode = 'Fixed-point: binary point scaling';
%endif
%<typeObj>.FixedExponent = %<dTypeRec.FixedExp>;
%endif
%<typeObj>.Identifier = '%<cgTypeName>';
%<typeObj>.Name = '%<cgTypeRec.Name>';
%<typeObj>.ReadOnly = %<const>;
%<typeObj>.Volatile = %<volatile>;
%<FcnSetTypeChecksum(typeObj, dTypeRec)>
%endfunction
%function FcnCreateAliasTypeObj(typeObj, cgTypeIdx, const, volatile) Output
%assign cgTypeRec = ::CompiledModel.CGTypes.CGType[cgTypeIdx]
%assign cgTypeName = cgTypeRec.Name
%assign dTypeIdx = cgTypeRec.SLTypeIdx
%if dTypeIdx < 0
%assign baseTypeObj = ...
SLibGetCoderTypeObject(LibCGTypeBaseIndex(cgTypeIdx), const, volatile)
%assign comment = "% Alias Data Type"
%<comment>
%<typeObj> = %<baseTypeObj>.clone;
%<typeObj>.Identifier = '%<cgTypeName>';
%else
%assign dTypeRec = ::CompiledModel.DataTypes.DataType[dTypeIdx]
%assign aliasIdx = LibGetDataTypeIdAliasedToFromId(dTypeIdx)
%assign aliasThruIdx= LibGetDataTypeIdAliasedThruToFromId(dTypeIdx)
%if (LibIsFundamentalBuiltInDataType(aliasIdx))
%assign baseTypeObj = SLibGetCoderTypeObject(aliasIdx, const, volatile)
%assign comment = "% Alias Data Type"
%<comment>
%<typeObj> = %<baseTypeObj>.clone;
%<typeObj>.Identifier = '%<cgTypeName>';
%elseif LibIsFundamentalBuiltInDataType(aliasThruIdx)
%assign baseTypeObj = ...
SLibGetCoderTypeObject(aliasThruIdx, const, volatile)
%assign comment = "% Alias Data Type"
%<comment>
%<typeObj> = %<baseTypeObj>.clone;
%<typeObj>.Identifier = '%<cgTypeName>';
%elseif LibIsEnumDataType(aliasThruIdx)
%assign baseTypeObj = ...
SLibGetCoderTypeObject(LibCGTypeBaseIndex(cgTypeIdx), const, volatile)
%assign comment = "% Alias to Enum Type"
%<comment>
%<typeObj> = %<baseTypeObj>.clone;
%<typeObj>.Identifier = '%<cgTypeName>';
%else
%assign dTypeRec = ::CompiledModel.DataTypes.DataType[dTypeIdx]
%if (dTypeRec.IsFixedPoint)
%assign comment = "% Alias to Fixed-Point Type"
%<comment>
%<typeObj> = coder.types.Fixed;
%<typeObj>.Signedness = %<dTypeRec.IsSigned>;
%<typeObj>.WordLength = %<dTypeRec.RequiredBits>;
%if (dTypeRec.Bias != 0.0) || (dTypeRec.FracSlope != 1.0)
%if (fxpIsDataTypeScaledDouble(dTypeRec))
%<typeObj>.DataTypeMode = 'Scaled double: slope and bias scaling';
%else
%<typeObj>.DataTypeMode = 'Fixed-point: slope and bias scaling';
%endif
%<typeObj>.Bias = %<dTypeRec.Bias>;
%<typeObj>.SlopeAdjustmentFactor = %<dTypeRec.FracSlope>;
%<typeObj>.FixedExponent = %<dTypeRec.FixedExp>;
%else
%if (fxpIsDataTypeScaledDouble(dTypeRec))
%<typeObj>.DataTypeMode = 'Scaled double: binary point scaling';
%else
%<typeObj>.DataTypeMode = 'Fixed-point: binary point scaling';
%endif
%<typeObj>.FixedExponent = %<dTypeRec.FixedExp>;
%endif
%<typeObj>.Identifier = '%<cgTypeName>';
%<typeObj>.ReadOnly = %<const>;
%<typeObj>.Volatile = %<volatile>;
%else
%<FcnCreateOpaqueTypeObj(typeObj, cgTypeRec, 0, 0)>/
%endif
%endif
%<FcnSetTypeChecksum(typeObj, dTypeRec)>
%endif
%<typeObj>.Name = %<typeObj>.Identifier;
%endfunction
%function FcnCreateEnumTypeObj(typeObj, cgTypeRec, const, volatile) Output
%assign cgTypeName = cgTypeRec.Name
%assign dTypeId = cgTypeRec.SLTypeIdx
%if !LibIsEnumDataType(dTypeId)
%<LibReportFatalError("CodeInfo: Unhandled Enumerated Data Type")>
%endif
%assign numEnums = FcnGetEnumTypeNumEnums(dTypeId)
%assert (numEnums > 0)
tmpEnumStr%<dTypeId> = cell(%<numEnums>, 1);
tmpEnumVal%<dTypeId> = zeros(%<numEnums>, 1);
%foreach enIdx = numEnums
tmpEnumStr%<dTypeId>{%<enIdx>+1} = '%<SLibGetEnumTypeCodeGenStringFromIndex(dTypeId, enIdx)>';
tmpEnumVal%<dTypeId>(%<enIdx>+1) = %<SLibGetEnumTypeValueFromIndex(dTypeId, enIdx)>;
%endforeach
%assign comment = "% Enum Data Type"
%<comment>
%<typeObj> = coder.types.Enum;
%<typeObj>.Identifier = '%<cgTypeName>';
%<typeObj>.Name = '%<cgTypeName>';
%<typeObj>.ReadOnly = %<const>;
%<typeObj>.Volatile = %<volatile>;
%<typeObj>.Strings = tmpEnumStr%<dTypeId>;
%<typeObj>.Values = int32(tmpEnumVal%<dTypeId>);
%<typeObj>.DefaultMember = %<FcnGetEnumTypeIndexOfDefaultValue(dTypeId)+1>;
%if (!LibIsEnumTypeStoredAsInt(dTypeId))
%assign baseDTypeId = LibGetEnumTypeStorageType(dTypeId)
%assign baseDTypeRec = ::CompiledModel.DataTypes.DataType[baseDTypeId]
%assign baseTypeObj = SLibGetCoderTypeObject(baseDTypeRec.CGTypeIdx, 0, 0)
%<typeObj>.StorageType = %<baseTypeObj>;
%endif
%assign dTypeRec = ::CompiledModel.DataTypes.DataType[dTypeId]
%<FcnSetTypeChecksum(typeObj, dTypeRec)>
%endfunction
%function FcnCreateCharTypeObj(typeObj, cgTypeRec, const, volatile) Output
%assign cgTypeName = cgTypeRec.Name
%assign comment = "% Char Data Type"
%<comment>
%<typeObj> = coder.types.Char;
%<typeObj>.Identifier = '%<cgTypeName>';
%<typeObj>.ReadOnly = %<const>;
%<typeObj>.Volatile = %<volatile>;
%endfunction
%function FcnCreateOpaqueTypeObj(typeObj, cgTypeRec, const, volatile) Output
%assign cgTypeName = cgTypeRec.Name
%assign comment = "% Opaque Data Type"
%<comment>
%<typeObj> = coder.types.Opaque;
%<typeObj>.Identifier = '%<cgTypeName>';
%<typeObj>.Name = '%<cgTypeName>';
%endfunction
%function FcnCreateStringClassTypeObj(typeObj, cgTypeRec, cgTypeIdx, const, volatile) Output
%assign cgTypeName = cgTypeRec.Name
%assign comment = "% Class Elements"
%<comment>
%<typeObj>_EL = [];
%foreach mIdx = LibCGTypeNumMembers(cgTypeIdx)
%assign mtypeIdx = LibCGTypeMemberCGTypeIdx(cgTypeIdx, mIdx)
%assign mTypeObj = SLibGetCoderTypeObject(mtypeIdx, 0, 0)
%assign comment = "% Element # %"
%<comment>
%<typeObj>_M%<mIdx> = coder.types.AggregateElement;
%<typeObj>_M%<mIdx>.Identifier = '%<LibCGTypeMemberName(cgTypeIdx, mIdx)>';
%<typeObj>_M%<mIdx>.Type = %<mTypeObj>;
%<typeObj>_EL = [%<typeObj>_EL, %<typeObj>_M%<mIdx>];
%endforeach
%assign comment = "% Class Type"
%<comment>
%<typeObj> = coder.types.Class;
%<typeObj>.Identifier = '%<cgTypeName>';
%<typeObj>.Name = '%<cgTypeName>';
%<typeObj>.Elements = %<typeObj>_EL;
%<typeObj>.ReadOnly = %<const>;
%<typeObj>.Volatile = %<volatile>;
%endfunction
%function FcnCreateStdContainerClassTypeObj(typeObj, cgTypeIdx, const, volatile) Output
%assign cgTypeName = LibCGTypeStdContainerName(cgTypeIdx)
%assign comment = "% Class Elements"
%<comment>
%<typeObj>_EL = [];
%assign mTypeObj = FcnGetCharTypeObj(0, 0)
%assign comment = "% Element # 1"
%<comment>
%<typeObj>_M0 = coder.types.AggregateElement;
%<typeObj>_M0.Identifier = "rt_unused";
%<typeObj>_M0.Type = %<mTypeObj>;
%<typeObj>_EL = [%<typeObj>_EL, %<typeObj>_M0];
%assign referenceTypeObj = ...
SLibGetCoderTypeObject(LibCGTypeStdContainerReferenceIndex(cgTypeIdx), const, volatile)
%assign comment = "% Class Type"
%<comment>
%<typeObj> = coder.types.ContainerClass;
%<typeObj>.Identifier = '%<cgTypeName>';
%<typeObj>.Name = '%<cgTypeName>';
%<typeObj>.Elements = %<typeObj>_EL;
%<typeObj>.ReadOnly = %<const>;
%<typeObj>.Volatile = %<volatile>;
%<typeObj>.ReferenceType = %<referenceTypeObj>;
%endfunction
%function FcnCreateStructTypeObj(typeObj, cgTypeIdx, const, volatile) Output
%assign cgTypeRec = ::CompiledModel.CGTypes.CGType[cgTypeIdx]
%assign cgTypeName = cgTypeRec.Name
%if FcnTypeIsMultiWord(cgTypeIdx)
%<FcnCreateFixPtTypeObj(typeObj, cgTypeIdx, const, volatile)>
%else
%assign comment = "% Structure Elements"
%<comment>
%<typeObj>_EL = [];
%foreach mIdx = LibCGTypeNumMembers(cgTypeIdx)
%assign mtypeIdx = LibCGTypeMemberCGTypeIdx(cgTypeIdx, mIdx)
%assign mTypeObj = SLibGetCoderTypeObjectInternal(mtypeIdx, 0, 0, TLC_TRUE)
%assign comment = "% Element # %"
%<comment>
%<typeObj>_M%<mIdx> = coder.types.AggregateElement;
%<typeObj>_M%<mIdx>.Identifier = '%<LibCGTypeMemberName(cgTypeIdx, mIdx)>';
%<typeObj>_M%<mIdx>.Type = %<mTypeObj>;
%<typeObj>_EL = [%<typeObj>_EL, %<typeObj>_M%<mIdx>];
%endforeach
%assign comment = "% Structure Type"
%<comment>
%<typeObj> = coder.types.Struct;
%<typeObj>.Identifier = '%<cgTypeName>';
%<typeObj>.Name = '%<cgTypeName>';
%<typeObj>.Elements = %<typeObj>_EL;
%<typeObj>.ReadOnly = %<const>;
%<typeObj>.Volatile = %<volatile>;
%assign dTypeIdx = cgTypeRec.SLTypeIdx
%if (dTypeIdx > -1)
%assign dTypeRec = ::CompiledModel.DataTypes.DataType[dTypeIdx]
%if ISFIELD(dTypeRec, "StructDtChecksum")
%<typeObj>.Checksum = uint32([%<CAST("Real", dTypeRec.StructDtChecksum[0])>; ...
%<CAST("Real", dTypeRec.StructDtChecksum[1])>; ...
%<CAST("Real", dTypeRec.StructDtChecksum[2])>; ...
%<CAST("Real", dTypeRec.StructDtChecksum[3])>]);
%endif
%<FcnSetTypeChecksum(typeObj, dTypeRec)>
%endif
%endif
%endfunction
%function FcnTypeIsMultiWord(cgTypeIdx) void
%assign isMultiWord = 0
%if (LibCGTypeIsStruct(cgTypeIdx))
%assign isMultiWord = LibCGTypeIsLoweredMultiword(cgTypeIdx)
%endif
%return isMultiWord
%endfunction
%function FcnCreateMatrixTypeObj(typeObj, cgTypeIdx, const, volatile) Output
%assign cgTypeRec = ::CompiledModel.CGTypes.CGType[cgTypeIdx]
%assign baseTypeObj = SLibGetCoderTypeObject(LibCGTypeBaseIndex(cgTypeIdx), const, volatile)
%assign comment = "% Matrix Type"
%<comment>
%<typeObj> = coder.types.Matrix;
%<typeObj>.BaseType = %<baseTypeObj>;
%if ISFIELD(cgTypeRec, "SymbolicWidth")
%if ISFIELD(cgTypeRec, "SLSymbolicDimensions")
%assign symDims = cgTypeRec.SLSymbolicDimensions
%else
%assign symDims = cgTypeRec.SymbolicDimensions
%endif
%assign symDimsStr = "{"
%assign numDimsStr = "["
%assign compileDimsStr = "["
%assign sep = ""
%assign hasNumDims = TLC_FALSE
%foreach dimsIdx = SIZE(symDims, 1)
%assign numDimStr = "%"
%assign compileDimsStr = compileDimsStr + sep + numDimStr
%if numDimStr == symDims[dimsIdx]
%assign hasNumDims = TLC_TRUE
%else
%assign numDimStr = "inf"
%endif
%assign numDimsStr = numDimsStr + sep + numDimStr
%assign symDimsStr = symDimsStr + sep + "'" + symDims[dimsIdx] + "'"
%assign sep = ", "
%endforeach
%assign symDimsStr = symDimsStr + "}"
%assign numDimsStr = numDimsStr + "]"
%assign compileDimsStr = compileDimsStr + "]"
%<typeObj>.SymbolicDimensions = %<symDimsStr>;
%if ISFIELD(cgTypeRec, "SLSymbolicWidth")
%<typeObj>.SymbolicWidth = '%<cgTypeRec.SLSymbolicWidth>';
%else
%<typeObj>.SymbolicWidth = '%<cgTypeRec.SymbolicWidth>';
%endif
%if hasNumDims
%<typeObj>.Dimensions = %<numDimsStr>;
%endif
%<typeObj>.CompileTimeDimensions = %<compileDimsStr>;
%else
%<typeObj>.Dimensions = %<cgTypeRec.Dimensions>;
%endif
%endfunction
%function FcnCreateMatrixTypeWithBaseTypeObj(baseCgTypeIdx, const, volatile) Output
%assign baseTypeObj = SLibGetCoderTypeObject(baseCgTypeIdx, const, volatile)
%if (LibCGTypeIsMatrix(baseCgTypeIdx))
%return baseTypeObj
%else
%assign comment = "% Matrix Type"
%<comment>
%assign matTypeObj = "Mat%<baseTypeObj>_%<const>_%<volatile>"
%<matTypeObj> = coder.types.Matrix;
%<matTypeObj>.BaseType = %<baseTypeObj>;
%<matTypeObj>.Dimensions = [1,1];
%return matTypeObj
%endif
%endfunction
%function FcnCreateComplexTypeObj(typeObj, cgTypeIdx, const, volatile) Output
%assign baseTypeObj = SLibGetCoderTypeObject(LibCGTypeBaseIndex(cgTypeIdx), 0, 0)
%assign baseCGRec = ::CompiledModel.CGTypes.CGType[LibCGTypeBaseIndex(cgTypeIdx)]
%assign typeName = LibGetDataTypeComplexNameFromId(baseCGRec.SLTypeIdx)
%assign comment = "% Complex Type"
%<comment>
%<typeObj> = coder.types.Complex;
%<typeObj>.Identifier = '%<typeName>';
%<typeObj>.BaseType = %<baseTypeObj>;
%<typeObj>.ReadOnly = %<const>;
%<typeObj>.Volatile = %<volatile>;
%endfunction
%function FcnCreatePointerTypeObjNew(typeObj, cgTypeIdx, const, volatile) Output
%assign baseTypeObj = SLibGetCoderTypeObject(LibCGTypeBaseIndex(cgTypeIdx), const, volatile)
%assign comment = "% Pointer Type: Pointer to '%<baseTypeObj>'"
%<comment>
%<typeObj> = coder.types.Pointer;
%<typeObj>.BaseType = %<baseTypeObj>;
%<typeObj>.ReadOnly = 0;
%<typeObj>.Volatile = 0;
%endfunction
%function FcnCreatePointerTypeObj(cgTypeIdx, const, volatile) Output
%if (LibCGTypeWidth(cgTypeIdx) != 1)
%assign baseTypeObj = ...
SLibGetCoderTypeObject(LibCGTypeBaseIndex(cgTypeIdx), const, volatile)
%else
%assign baseTypeObj = SLibGetCoderTypeObject(cgTypeIdx, const, volatile)
%endif
%return FcnGetPointerTypeObj(baseTypeObj, 0, 0)
%endfunction
%function FcnGetPointerTypeObj(baseTypeName, const, volatile) Output
%assign ptrtypeObj = "Ptr%<baseTypeName>_%<const>_%<volatile>"
%if ISFIELD(CodeInfoMap.TypeMap, ptrtypeObj)
%else
%assign comment = "% Pointer Type: Pointer to %<baseTypeName>"
%<comment>
%<ptrtypeObj> = coder.types.Pointer;
%if !ISEQUAL(baseTypeName, "void")
%<ptrtypeObj>.BaseType = %<baseTypeName>;
%endif
%<ptrtypeObj>.ReadOnly = %<const>;
%<ptrtypeObj>.Volatile = %<volatile>;
%<LibAddIdentifier(CodeInfoMap.TypeMap, ptrtypeObj, 1)>
%endif
%return ptrtypeObj
%endfunction
%function FcnGetMatrixFrameTypeObj(typeName) Output
%assign frameTypeObj = "Frame_%<typeName>"
%if ISFIELD(CodeInfoMap.TypeMap, frameTypeObj)
%else
%assign comment = "% Matrix Type: Frame to %<typeName>"
%<comment>
if ~%<typeName>.isMatrix
%<frameTypeObj> = coder.types.Matrix;
%<frameTypeObj>.BaseType = %<typeName>;
%<frameTypeObj>.Dimensions = [1, 1];
%<frameTypeObj>.FrameData = true;
else
%<frameTypeObj> = %<typeName>.clone;
%<frameTypeObj>.FrameData = true;
end
%<LibAddIdentifier(CodeInfoMap.TypeMap, frameTypeObj, 1)>
%endif
%return frameTypeObj
%endfunction
%function FcnGetIntegerTypeObj(const, volatile) Output
%assign inttypeObj = "Type_int_R%<const>_V%<volatile>"
%if ISFIELD(CodeInfoMap.TypeMap, inttypeObj)
%else
%assign comment = "% Unsized integer type"
%<comment>
%<inttypeObj> = coder.types.Int(32,1);
%<inttypeObj>.Identifier = 'int_T';
%<inttypeObj>.Name = 'int';
%<inttypeObj>.ReadOnly = %<const>;
%<inttypeObj>.Volatile = %<volatile>;
%<LibAddIdentifier(CodeInfoMap.TypeMap, inttypeObj, 1)>
%endif
%return inttypeObj
%endfunction
%function FcnGetCharTypeObj(const, volatile) Output
%assign chartypeObj = "Type_char_R%<const>_V%<volatile>"
%if ISFIELD(CodeInfoMap.TypeMap, chartypeObj)
%else
%assign comment = "% Char type"
%<comment>
%<chartypeObj> = coder.types.Char;
%<chartypeObj>.Identifier = 'char_T';
%<chartypeObj>.ReadOnly = %<const>;
%<chartypeObj>.Volatile = %<volatile>;
%<LibAddIdentifier(CodeInfoMap.TypeMap, chartypeObj, 1)>
%endif
%return chartypeObj
%endfunction
%function FcnGetOpaqueTypeObj(typeName, const, volatile) Output
%assign opaquetypeObj = "Type_opaque_%<typeName>_R%<const>_V%<volatile>"
%if ISFIELD(CodeInfoMap.TypeMap, opaquetypeObj)
%else
%assign comment = "% Opaque type"
%<comment>
%<opaquetypeObj> = coder.types.Opaque;
%<opaquetypeObj>.Identifier = '%<typeName>';
%<opaquetypeObj>.ReadOnly = %<const>;
%<opaquetypeObj>.Volatile = %<volatile>;
%<LibAddIdentifier(CodeInfoMap.TypeMap, opaquetypeObj, 1)>
%endif
%return opaquetypeObj
%endfunction
%function FcnGetInternalTypeObj(key, typeName, typeObj) Output
%assign keyName = "Type_%<key>"
%if ISEMPTY(typeObj)
%if !ISFIELD(CodeInfoMap.InternalDataTypeMap, keyName)
%assign typeObj = "type_%<key>"
%assign comment = "% Opaque Data Type"
%<comment>
%<typeObj> = coder.types.Opaque;
%<typeObj>.Identifier = '%<typeName>';
%<LibAddIdentifier(CodeInfoMap.InternalDataTypeMap, keyName, typeObj)>
%endif
%else
%if !ISFIELD(CodeInfoMap.InternalDataTypeMap, keyName)
%<LibAddIdentifier(CodeInfoMap.InternalDataTypeMap, keyName, typeObj)>
%endif
%endif
%return GETFIELD(CodeInfoMap.InternalDataTypeMap, keyName)
%endfunction
%function FcnGetInternalDataObject(key, path, name, region, time) Output
%assign dataObj = "idata_%<key>"
%if ISFIELD(CodeInfoMap.InternalDataMap, dataObj)
%else
%assign comment = "% Data Interface: %<dataObj>"
%<comment>
%if ISEMPTY(time)
%assign time = "empty_timing"
%<time> = RTW.TimingInterface.empty;
%endif
%<dataObj> = RTW.DataInterface('%<path>', '%<name>', %<region>, %<time>);
%<LibAddIdentifier(CodeInfoMap.InternalDataMap, dataObj, key)>
%endif
%return dataObj
%endfunction
%function FcnGetInternalDataByName(iDataName) Output
%assign dataObj = "idata_%<iDataName>"
%assign comment = "% Data Interface: %<iDataName>"
%<comment>
%<dataObj> = getInternalDataByName(codeInfo.InternalData, '%<iDataName>');
%return dataObj
%endfunction
%function FcnGetInternalDataByVariableName(iDataName) Output
%assign dataObj = "idata_%<iDataName>"
%assign comment = "% Data Interface: %<iDataName>"
%<comment>
%<dataObj> = getInternalDataByVariableName(codeInfo.InternalData, '%<iDataName>');
%return dataObj
%endfunction
%function FcnGetDataInterfaceType(dataInterface) Output
%assign typeObj = "type_%<dataInterface>"
%assign comment = "% Type of : %<dataInterface>"
%<comment>
if isa(%<dataInterface>.Implementation,'RTW.PointerExpression')
%<typeObj> = %<dataInterface>.Implementation.TargetRegion.Type;
else
%<typeObj> = %<dataInterface>.Implementation.Type;
end
%return typeObj
%endfunction
%function FcnGetInternalConstant(value, region) Output
%assign dataObj = "Const_%<value>"
%if ISFIELD(CodeInfoMap.ConstDataMap, dataObj)
%else
%assign comment = "% Data Interface: %<dataObj>"
%<comment>
%assign time = "empty_timing"
%<time> = RTW.TimingInterface.empty;
%<dataObj> = RTW.DataInterface('', '%<value>', %<region>, %<time>);
%<LibAddIdentifier(CodeInfoMap.ConstDataMap, dataObj, value)>
%endif
%return dataObj
%endfunction
%function FcnGetCIIdxFromEIIdx(eiIdx) void
%assign ciIdx = -1
%assign rootInPairs = FcnGetRootInportsMapFromIRInfo()
%foreach idx = SIZE(rootInPairs, 0)
%assign rootInPair = rootInPairs[idx]
%if (eiIdx == rootInPair[0])
%assign ciIdx = rootInPair[1]
%break
%endif
%endforeach
%return ciIdx+1
%endfunction
%function AddSimulinkFunctionInfo(componentObj) Output
%with ::CompiledModel
%foreach fcnIdx = NumSimulinkFunctions
%assign fcnRec = SimulinkFunction[fcnIdx]
%assign isDefinedInThisModel = (fcnRec.IsDefinedInThisModel == "yes")
%assign isDeclaredInThisModel = SLibSimulinkFunctionNeedsDeclaration(fcnRec)
%assign isDefinedInChildExportFunctionModel = ...
(fcnRec.IsDefined == "yes") && SLibIsExportFcnDiagram() && !(fcnRec.IsMultiInstance == "yes")
%if !( isDefinedInThisModel || isDeclaredInThisModel || isDefinedInChildExportFunctionModel )
%continue
%endif
%if (SLibAutosarActive() && fcnRec.IsSupportedForAUTOSAR=="no")
%continue
%endif
cimpl = coder.types.Prototype;
cimpl.Name = '%<fcnRec.CGFunctionName>';
%assign isClassMethod = (GenerateClassInterface && fcnRec.FullPathToFunction != "G")
%if isClassMethod && fcnRec.SystemIdx >= 0
%assign sys = System[fcnRec.SystemIdx]
%if !SLibIsPublicClassMemberSLFcn(sys) && ISEMPTY(SLibGetStepMethodDecl(TLC_TRUE,fcnRec.TID))
%continue
%endif
%endif
%if !(SLibAutosarActive() && fcnRec.IsDefinedInThisModel == "no" && ...
!IsModelReferenceTarget())
%if fcnRec.WriteHeaderFile == "no" || isClassMethod
%if !SLibAutosarActive()
cimpl.HeaderFile = '%<::CompiledModel.Name>.h';
%endif
%else
cimpl.HeaderFile = '%<fcnRec.CGFunctionName>.h';
%endif
%endif
%if SLibIsCompactFileFormat() || fcnRec.IsMultiInstance == "yes" || isClassMethod || ...
(RateGroupedSimulinkFunctions && fcnRec.IsScoped == "no")
cimpl.SourceFile = ['%<::CompiledModel.Name>', '.%<::LangFileExt>'];
%else
cimpl.SourceFile = '%<fcnRec.CGFunctionName>.c';
%endif
%assign numInOutArgs = SIZE(fcnRec.InoutArgs)[1]
%createrecord inoutArgPairFirst {}
%createrecord inoutArgPairSecond {}
%foreach argIdx = numInOutArgs/2
%assign inArgNum = fcnRec.InoutArgs[2*argIdx]
%assign outArgNum = fcnRec.InoutArgs[2*argIdx + 1]
%addtorecord inoutArgPairFirst I%<inArgNum> 1
%addtorecord inoutArgPairSecond O%<outArgNum> %<inArgNum>
%endforeach
argvec = [];
%if (SLibAutosarActive() && MultiInstanceERTCode)
%assign rteTypeName = "Rte_Instance"
%assign rteName = FcnGetInstanceHandleName()
%assign rteType = FcnGetOpaqueTypeObj(rteTypeName, 0, 0)
%assign rteArg = "%<fcnName>_RTEArg"
%<rteArg> = coder.types.Argument;
%<rteArg>.Type = %<rteType>;
%<rteArg>.Name = '%<rteName>';
%<rteArg>.IOType = 'INPUT';
argvec = [argvec %<rteArg>];
%elseif fcnRec.IsMultiInstance == "yes" && !GenerateClassInterface
%assign slfType = FcnGetInternalTypeObj("RTModel", ::tSimStructType, "")
%assign slfPtrType = FcnGetPointerTypeObj(slfType, 1, 0)
%assign slfArg = "%<fcnName>_SlfArg"
%assign slfArgName = ::tSimStruct
%<slfArg> = coder.types.Argument;
%<slfArg>.Type = %<slfPtrType>;
%<slfArg>.Name = '%<slfArgName>';
%<slfArg>.IOType = 'INPUT';
argvec = [argvec; %<slfArg>];
%endif
%foreach argIdx = SIZE(fcnRec.ArgIndices)[1]
%assign argKey = fcnRec.ArgIndices[argIdx]
%assign argDir = IDNUM(argKey)[0]
%assign argIndex = IDNUM(argKey)[1]
arg = coder.types.Argument;
%assign argName = fcnRec.ArgNames[argIdx]
arg.Name = '%<argName>';
%if argDir == "I"
%assign cgTypeIdx = fcnRec.ArginCGTypeIdx[argIndex]
%if (LibCGTypeWidth(cgTypeIdx) == 1) && (fcnRec.ArginPassByType[argIndex] >= eSLFARG_PASSBYTYPE.POINTER)
%assign typeObj = FcnCreatePointerToScalarTypeObj(cgTypeIdx, 0,0)
%else
%if LibCGTypeIsMatrix(cgTypeIdx) && LibCGTypeWidth(cgTypeIdx) != 1
%assign typeObj = SLibGetCoderTypeObject (cgTypeIdx,1,0)
%elseif LibCGTypeIsStruct(cgTypeIdx) && ...
!LibIsDataTypeMultiWordFixpt(LibCGTypeToSLType(cgTypeIdx)) && ...
!LibCGTypeIsComplex(cgTypeIdx)
%assign typeObj = FcnCreatePointerTypeObj(cgTypeIdx,1,0)
%else
%assign typeObj = SLibGetCoderTypeObject(cgTypeIdx,0,0)
%endif
%endif
%assign typeObj = FcnSetTypeObjPropsForNonAutoPassByType(typeObj,fcnRec.ArginPassByType[argIndex])
arg.Type = %<typeObj>;
arg.IOType = 'INPUT';
arg.GraphicalIndex = int32(%<argIndex>);
%elseif argDir == "O"
%assign cgTypeIdx = fcnRec.ArgoutCGTypeIdx[argIndex]
%if (LibCGTypeWidth(cgTypeIdx) == 1)
%if (fcnRec.ArgoutPassByType[argIndex] >= eSLFARG_PASSBYTYPE.POINTER)
%assign typeObj = FcnCreatePointerToScalarTypeObj(cgTypeIdx, 0,0)
%else
%assign typeObj = FcnCreatePointerTypeObj(cgTypeIdx, 0,0)
%endif
%else
%assign typeObj = SLibGetCoderTypeObject(cgTypeIdx,0,0)
%endif
%assign typeObj = FcnSetTypeObjPropsForNonAutoPassByType(typeObj,fcnRec.ArgoutPassByType[argIndex])
arg.Type = %<typeObj>;
%if ISFIELD(inoutArgPairSecond, argKey)
arg.IOType = 'INPUT_OUTPUT';
arg.GraphicalIndex = int32([%<GETFIELD(inoutArgPairSecond, argKey)>, %<argIndex>]);
%else
arg.IOType = 'OUTPUT';
arg.GraphicalIndex = int32(%<argIndex>);
%endif
%endif
argvec = [argvec arg];
%endforeach
%if fcnRec.ReturnArgIndex >= 0
arg = coder.types.Argument;
arg.Name = '';
%assign cgTypeIdx = fcnRec.ArgoutCGTypeIdx[fcnRec.ReturnArgIndex]
%assign typeObj = SLibGetCoderTypeObject(cgTypeIdx,0,0)
arg.Type = %<typeObj>;
arg.IOType = 'OUTPUT';
arg.GraphicalIndex = int32(%<fcnRec.ReturnArgIndex>);
cimpl.Return = arg;
%endif
cimpl.Arguments = argvec;
%if fcnRec.TID == -2
%assign timeObj = SLibGetRTWTimingObject("constant")
%elseif fcnRec.TID >= 0
%assign timeObj = SLibGetRTWTimingObject(fcnRec.TID)
%else
%assign timeObj = "RTW.TimingInterface.empty"
%endif
%if fcnRec.IsDefined == "yes"
fcnRec = RTW.SimulinkFunctionInterface;
fcnRec.Prototype = cimpl;
fcnRec.Timing = %<timeObj>;
%if fcnRec.IsVariantSimulinkFunction == "yes"
vInfoObj = RTW.VariantInfo;
vInfoObj.NetCGVCE = '%<fcnRec.NetCGVCE>';
vInfoObj.NetCGVCEPoundIf = '%<fcnRec.NetCGVCEPoundIf>';
vInfoObj.NetSVCE = %<fcnRec.NetSVCE>;
vInfoObj.EMVCE = '%<fcnRec.EMVCE>';
fcnRec.VariantInfo = vInfoObj;
%endif
fcnRec.SimulinkFunctionName = '%<fcnRec.Name>';
fcnRec.FullPathToSimulinkFunction = {'%<fcnRec.FullPathToFunction>'};
%if !(SLibAutosarActive()) && ISFIELD(fcnRec, "ServerFcnCallPortGroupIdx")
%assign pgIdx = fcnRec.ServerFcnCallPortGroupIdx
%assign fcnCallPortGroup = ExternalPortGroups.FcnCallPortGroup[pgIdx]
tmpDirectReads = [];
tmpDirectWrites = [];
%assign dataInputPorts = fcnCallPortGroup.DataInputPorts
%foreach idx = SIZE(dataInputPorts, 1)
%assign portIdx = dataInputPorts[idx]
%assign inportIdx = FcnGetCIIdxFromEIIdx(portIdx)
%if inportIdx > 0
tmpDirectReads = [tmpDirectReads; %<componentObj>.Inports(%<inportIdx>)];
%endif
%endforeach
%assign dataOutputPorts = fcnCallPortGroup.DataOutputPorts
%foreach idx = SIZE(dataOutputPorts, 1)
%assign portIdx = dataOutputPorts[idx]
tmpDirectWrites = [tmpDirectWrites; %<componentObj>.Outports(%<portIdx>+1)];
%endforeach
fcnRec.DirectReads = tmpDirectReads;
fcnRec.DirectWrites = tmpDirectWrites;
%if ISFIELD(CodeInfoMap.ExportFunctionMap, "%<fcnRec.Name>")
%assign mapEntry = GETFIELD(CodeInfoMap.ExportFunctionMap, "%<fcnRec.Name>")
%foreach i = SIZE(mapEntry, 1)
%assign outputFcnInterfaceName = mapEntry[i].FunctionInterfaceName
%<outputFcnInterfaceName>.DirectReads = uniquifyDataAccess([%<outputFcnInterfaceName>.DirectReads fcnRec.DirectReads]);
%<outputFcnInterfaceName>.DirectWrites = uniquifyDataAccess([%<outputFcnInterfaceName>.DirectWrites fcnRec.DirectWrites]);
%endforeach
%endif
%elseif SLibAutosarActive()
%with ::CompiledModel.RTWAutosar.AutosarRunnables
%assign numRunnables = SIZE(Runnable)[1]
%foreach runIdx = numRunnables
%if Runnable[runIdx].IsService == "yes" && fcnRec.Name == Runnable[runIdx].Symbol
%assign tmpRunnable = Runnable[runIdx]
%<SLibAutosarWriteDirectReadWrite(tmpRunnable, "fcnRec")>
%break
%endif
%endforeach
%endwith
%endif
if isempty( %<componentObj>.OutputFunctions)
%<componentObj>.OutputFunctions = fcnRec;
else
%<componentObj>.OutputFunctions(end+1) = fcnRec;
end
%endif
%if fcnRec.CGIsCalled == "yes"
%if ISEQUAL(fcnRec.CallerOperationName, fcnRec.Name)
callerImpl = cimpl;
%else
callerImpl = coder.types.Prototype;
callerImpl.Name = '%<fcnRec.CallerOperationName>';
callerImpl.Arguments = cimpl.Arguments;
callerImpl.Return = cimpl.Return;
%endif
%foreach callerIdx = SIZE(fcnRec.ServerCallPoints)[1]
%assign callerTID = fcnRec.ServerCallPoints[callerIdx]
%if callerTID == -2
%assign callerTimeObj = SLibGetRTWTimingObject("constant")
%elseif callerTID >= 0
%assign callerTimeObj = SLibGetRTWTimingObject(callerTID)
%else
%<LibReportFatalError("CodeInfo: Unhandled Function Caller TID")>
%endif
fcnRec = RTW.AutosarClientCall;
fcnRec.Prototype = callerImpl;
fcnRec.Timing = %<callerTimeObj>;
fcnRec.PortName = '%<fcnRec.CallerPortName>';
%if fcnRec.IsVariantSimulinkFunction == "yes"
vInfoObj = RTW.VariantInfo;
vInfoObj.NetCGVCE = '%<fcnRec.NetCGVCE>';
vInfoObj.NetCGVCEPoundIf = '%<fcnRec.NetCGVCEPoundIf>';
vInfoObj.NetSVCE = %<fcnRec.NetSVCE>;
vInfoObj.EMVCE = '%<fcnRec.EMVCE>';
fcnRec.VariantInfo = vInfoObj;
%endif
fcnRec.SimulinkFunctionName = '%<fcnRec.Name>';
fcnRec.FullPathToSimulinkFunction = {'%<fcnRec.FullPathToFunction>'};
if isempty(%<componentObj>.ServerCallPoints)
%<componentObj>.ServerCallPoints = fcnRec;
else
%<componentObj>.ServerCallPoints(end+1) = fcnRec;
end
%endforeach
%endif
%undef inArgNames
%undef outArgNames
%undef inoutArgPairFirst
%undef inoutArgPairSecond
%endforeach
%endwith
%endfunction
%function FcnCreatePointerToScalarTypeObj(cgTypeIdx, const, volatile) Output
%if LibCGTypeIsMatrix(cgTypeIdx) && "1"==LibCGTypeSymbolicWidth(cgTypeIdx)
%assign cgTypeIdx = LibCGTypeBaseIndex(cgTypeIdx)
%endif
%return FcnCreatePointerTypeObj(cgTypeIdx,const,volatile)
%endfunction
%function FcnSetTypeObjPropsForNonAutoPassByType(typeObj, passByType) Output
%assign newTypeObj = "%<typeObj>_PassByT%<passByType>"
%<newTypeObj> = %<typeObj>.clone();
%switch passByType
%case eSLFARG_PASSBYTYPE.CONST_DATA
%<newTypeObj>.ReadOnly = 1;
%break
%case eSLFARG_PASSBYTYPE.ARR_SIZEONE
%case eSLFARG_PASSBYTYPE.CONST_ARR_SIZEONE
%<newTypeObj>_ARR_SIZEONE = coder.types.Matrix;
%<newTypeObj>_ARR_SIZEONE.Dimensions = 1;
%<newTypeObj>_ARR_SIZEONE.ArrSizeOne = true;
%<newTypeObj>_ARR_SIZEONE_base = %<newTypeObj>;
if(isa(%<newTypeObj>,'coder.types.Pointer'))
%<newTypeObj>_ARR_SIZEONE_base = %<newTypeObj>.BaseType;
end
if isa(%<newTypeObj>_ARR_SIZEONE_base,'coder.types.Matrix')
assert(prod(%<newTypeObj>_ARR_SIZEONE_base.Dimensions)==1);
%<newTypeObj>_ARR_SIZEONE_base = %<newTypeObj>_ARR_SIZEONE_base.BaseType;
end
%<newTypeObj>_ARR_SIZEONE.BaseType = %<newTypeObj>_ARR_SIZEONE_base;
%assign arrSizeOneBaseT = "%<newTypeObj>_ARR_SIZEONE.BaseType"
%if (passByType==eSLFARG_PASSBYTYPE.CONST_ARR_SIZEONE)
%<FcnSetPropertyOnCopy(arrSizeOneBaseT,"ReadOnly",1)>
%else
%<FcnSetPropertyOnCopy(arrSizeOneBaseT,"ReadOnly",0)>
%endif
%<newTypeObj> = %<newTypeObj>_ARR_SIZEONE;
%break
%case eSLFARG_PASSBYTYPE.POINTER
%<newTypeObj>.ReadOnly = 0;
%assign baseT = "%<newTypeObj>.BaseType"
%<FcnSetPropertyOnCopy(baseT,"ReadOnly",0)>
%break
%case eSLFARG_PASSBYTYPE.POINTER_VOID
%<newTypeObj>_VOIDPTR = coder.types.Pointer;
%<newTypeObj>_VOIDPTR.ReadOnly = 0;
%<newTypeObj>_VOIDPTR.BaseType = coder.types.Void;
%<newTypeObj>_VOIDPTR.BaseType.ReadOnly = 0;
if isa(%<newTypeObj>,'coder.types.Pointer')
%<newTypeObj>_VOIDPTR.BaseType.BaseType = %<newTypeObj>.BaseType.clone();
else
%<newTypeObj>_VOIDPTR.BaseType.BaseType = %<newTypeObj>;
end
%<newTypeObj>_VOIDPTR.BaseType.BaseType.ReadOnly = 0;
%<newTypeObj> = %<newTypeObj>_VOIDPTR;
%break
%case eSLFARG_PASSBYTYPE.POINTER_CONST_DATA
%<newTypeObj>.ReadOnly = 0;
%assign baseT = "%<newTypeObj>.BaseType"
%<FcnSetPropertyOnCopy(baseT,"ReadOnly",1)>
%break
%case eSLFARG_PASSBYTYPE.POINTER_CONST_VOID
%<newTypeObj>_VOIDPTR = coder.types.Pointer;
%<newTypeObj>_VOIDPTR.ReadOnly = 0;
%<newTypeObj>_VOIDPTR.BaseType = coder.types.Void;
%<newTypeObj>_VOIDPTR.BaseType.ReadOnly = 1;
%<newTypeObj>_VOIDPTR.BaseType.BaseType = %<newTypeObj>;
if isa(%<newTypeObj>,'coder.types.Pointer')
%<newTypeObj>_VOIDPTR.BaseType.BaseType = %<newTypeObj>.BaseType.clone();
else
%<newTypeObj>_VOIDPTR.BaseType.BaseType = %<newTypeObj>;
end
%<newTypeObj>_VOIDPTR.BaseType.BaseType.ReadOnly = 1;
%<newTypeObj> = %<newTypeObj>_VOIDPTR;
%break
%case eSLFARG_PASSBYTYPE.CONST_POINTER_CONST_DATA
%<newTypeObj>.ReadOnly = 1;
%assign baseT = "%<newTypeObj>.BaseType"
%<FcnSetPropertyOnCopy(baseT,"ReadOnly",1)>
%break
%endswitch
%return newTypeObj
%endfunction
/% Abstract :
This function is intended to for setting an EmbeddedTypeSystem property
without changing the original object in case it is referenced by other
objects.
<> Ex1: (set ReadOnly flag to true):
type1 = numerictype(1,16,0);
type2 = type1;
setting ReadOnly flag of type2 will also set the ReadOnly flag of type1
so this function emits:
tmp_copy = type2.copy;
type2 = numerictype(); % this is needed (see Ex2)
type2 = tmp_copy;
type2.ReadOnly = true;
<> Ex2: not clearing BaseType first does not work as in the example below
t3 = embedded.matrixtype;
t3.BaseType = numerictype(1,16,0);
t4 = t3.copy;
base = t4.BaseType.copy;
%j4.BaseType = numerictype();
t4.BaseType = base;
t4.BaseType.ReadOnly = true;
t3.BaseType.ReadOnly
t4.BaseType.ReadOnly
The above code produced the following INCORRECT result:
1
1
%/
%function FcnSetPropertyOnCopy(obj,prop,value) Output
tmp_copy = [];
tmp_copy = %<obj>.clone;
tmp_copy.%<prop> = %<value>;
%<obj> = tmp_copy;
%endfunction
%function FcnGetLookupMapping(slParam)
%if ISFIELD(CodeInfoMap.LookupMap, slParam)
%assign output = CodeInfoMap.LookupMap.%<slParam>
%else
%assign output = FEVAL("autosar.api.Utils.getLookupMapping", ...
::CompiledModel.Name, ...
slParam)
%if ISEMPTY(output) || (TYPE(output) != "Scope")
%exit Failed to call getLookupMapping function
%endif
%if output.success != 1
%exit Failed during call to getLookupMapping: %<output.message>
%endif
%<LibAddIdentifier(CodeInfoMap.LookupMap, slParam, output)>
%endif
%return output.ARParameterData
%endfunction
%function FcnSetTypeChecksum(typeObj, dTypeRec) Output
%if ISFIELD(dTypeRec, "Checksum")
%<typeObj>.TypeChecksum = uint32([%<CAST("Real", dTypeRec.Checksum[0])>; ...
%<CAST("Real", dTypeRec.Checksum[1])>; ...
%<CAST("Real", dTypeRec.Checksum[2])>; ...
%<CAST("Real", dTypeRec.Checksum[3])>]);
%endif
%endfunction
%endif