Contenu principal

coder.mapping.api.CoderDictionary

R2026b

Get and set data and function defaults of Embedded Coder dictionary configured with data interface configuration

    Description

    Use a coder.mapping.api.CoderDictionary object and its functions to view and modify the default C code generation settings in an Embedded Coder® dictionary configured with data interface configuration.

    Creation

    The object coder.mapping.api.CoderDictionary is created automatically with the Embedded Coder dictionary it is associated with. Use one of these syntaxes to get a handle to the object:

    Description

    mapDictObj = coder.mapping.api.get(dictFilePath) returns the active code mapping object of the Embedded Coder dictionary in the specified .sldd file dictFilePath.

    example

    mapDictObj = coder.mapping.api.get(simDictObj) returns the active code mapping object associated with the Simulink.data.Dictionary object, simDictObj.

    example

    Input Arguments

    expand all

    Path to the Embedded Coder dictionary file to return the coder dictionary mapping object for, specified as a string scalar or character vector.

    Example: dictFilePath = "exCodeDefs.sldd";

    Data Types: string | char

    Handle to the Simulink® data dictionary object that is associated with the dictionary to return the coder dictionary mapping object for, specified as a Simulink.data.Dictionary object.

    Example: simDictObj = Simulink.data.dictionary.open("exCodeDefs.sldd");

    Output Arguments

    expand all

    Code mapping object associated with the Embedded Coder dictionary, returned as a coder.mapping.api.CoderDictionary object.

    Usage

    Each Embedded Coder dictionary configured with data interface configuration is associated with a coder.mapping.api.CoderDictionary object. The object provides access to the default dictionary values for data and functions categories. Use the object functions getDataDefault and setDataDefault to view and modify the default storage class and memory section for these data categories:

    • Inports

    • Outports

    • ModelParameters

    • ExternalParameters

    • SharedLocalDataStores

    • GlobalDataStores

    • InternalData

    Use the object functions getFunctionDefault and setFunctionDefault to view and modify the default function customization template and memory section for these function categories:

    • InitializeTerminate

    • Execution

    • SharedUtility

    Object Functions

    getDataDefaultGet default code settings for data category
    setDataDefaultSet default code settings for data category
    getFunctionDefaultGet default function customization template or memory section for model functions category
    setFunctionDefaultSet default function customization template and memory section for model functions category

    Examples

    collapse all

    View and modify data defaults of an Embedded Coder dictionary configured with data interface configuration.

    Use the function Simulink.data.dictionary.create to create the dictionary file dataDict.sldd and the associated Simulink.data.Dictionary object. Then use the function coder.dictionary.create to create the data interface Embedded Coder dictionary object, and store handles to the objects in variables.

    dictFile = "dataDict.sldd";
    simDictObj = Simulink.data.dictionary.create(dictFile);
    ecoderDataDictObj = coder.dictionary.create(dictFile,"DataInterface");

    Use the function coder.mapping.api.get() with the dictionary file name to get a handle to the mapping object of the dictionary mapping object and store it in the variable dictMapObj.

    dictMapObj = coder.mapping.api.get(dictFile);

    Use the function setDataDefault to set the default dictionary value for the storage class of outports, then use the function getDataDefault to verify that the default has been updated.

    setDataDefault(dictMapObj,"Outports",StorageClass="ExportedGlobal")
    getDataDefault(dictMapObj,"Outports","StorageClass")
    ans = 'ExportedGlobal'

    View and modify function defaults of an Embedded Coder dictionary configured with data interface configuration.

    Use the function Simulink.data.dictionary.create to create the dictionary file dataDict.sldd and the associated Simulink.data.Dictionary object. Then use the function coder.dictionary.create to create the data interface Embedded Coder dictionary object, and store handles to the objects in variables.

    dictFile = "dataDict.sldd";
    simDictObj = Simulink.data.dictionary.create(dictFile);
    ecoderDataDictObj = coder.dictionary.create(dictFile,"DataInterface");

    Use the function coder.mapping.api.get() with the Simulink.data.Dictionary object to get a handle to the mapping object of the dictionary mapping object and store it in the variable dictMapObj.

    dictMapObj = coder.mapping.api.get(simDictObj);

    Use the function setFunctionDefault to set the default dictionary value for the memory section of the execution function category. Then use the function getFunctionDefault to verify that the default has been updated.

    setFunctionDefault(dictMapObj,"Execution",MemorySection="MemConst")
    getFunctionDefault(dictMapObj,"Execution","MemorySection")
    ans = 'MemConst

    Version History

    Introduced in R2021a