coder.dictionary.Entry class
Package: coder.dictionary
Description
An object of the coder.dictionary.Entry
class represents one definition
of an Embedded Coder Dictionary. In this API, the object is called an
entry. The information that the object represents is a
definition. In this documentation, definition
refers to the definition of the entry object.
A coder.Dictionary
object contains
three coder.dictionary.Section
objects, which represent the sections of an Embedded Coder
Dictionary: Storage Classes, Memory Sections, and Function Customization Templates. A
coder.dictionary.Section
object contains
coder.dictionary.Entry
objects, which represent the definitions stored in
that section of the Embedded Coder Dictionary. The name of the section identifies the type of
code definitions that the section contains. To access the sections of an Embedded Coder
Dictionary, use a coder.Dictionary
object. To access the dictionary entries
within the section, use a coder.dictionary.Section
object.
Creation
The functions addEntry
,
getEntry
,
copyEntry
, and
find
create
coder.dictionary.Entry
objects.
Properties
A coder.dictionary.Entry
object has these properties.
Name
— Name of code definition
character vector
Name of the coder dictionary definition that the entry represents. The name must be unique among the definitions in the section of the dictionary.
DataSource
— Location of code definition
character vector
The location of the code definition. This property is read-only.
Built-in
— Provided by Simulink®.Model name — Defined in a Simulink model.
Dictionary name — Defined in a Simulink data dictionary.
Package name — Defined in the Simulink package or in a custom package.
To access the properties of the code definition that an entry represents, use the getAvailableProperties
, get
, and
set
methods. Each
type of code definition has available properties listed.
Name
— Name of storage class
StorageClass1
(default) | character vector | string scalar
Name of the storage class. The name must be unique among the storage classes in the dictionary.
For lists of built-in and example storage classes that Simulink provides, see Choose Storage Class for Controlling Data Representation in Generated Code.
Description
— Purpose and functionality of storage class
character vector | string scalar
Custom text that you can use to describe the purpose and functionality of the storage class.
DataSource
— Location of code definition
character vector
The location of the code definition. This property is read-only.
Built-in
— Provided by Simulink.Model name — Defined in a Simulink model.
Dictionary name — Defined in a Simulink data dictionary.
Package name — Defined in the Simulink package or in a custom package.
DataAccess
— Specification to access the data
Direct
(default) | Function
Specification to access data associated with the model. Access the data directly
(Direct
), through customizable get
and
set
functions (Function
), or by using a pointer
(Pointer
). For more information, see Access Data Through Functions by Using Storage Classes in Embedded Coder Dictionary.
Dependencies
Setting this property to
Function
orPointer
:Sets
DataScope
toImported
.Means that you cannot specify multi-instance properties.
Sets the
PreserveDimensions
property tofalse
. To preserve dimensions of multidimensional arrays in the generated code, setDataAccess
toDirect
.
In addition, setting this property to Function
enables these properties:
AccessMode
AllowedAccess
GetFunctionName
SetFunctionName
DataScope
— Specification to generate data definition
Exported
(default) | Imported
Specification that the generated code defines the data (Exported
)
or import (Imported
) the data definition from external code. Built-in
storage classes and storage classes in packages such as Simulink can use other scope options, such as File
.
Dependencies
Setting this property to
Imported
:Disables
DefinitionFile
. To include your external source code file in the build process, use model configuration parameters. For an example, see Configure Data Interface.Means that you cannot set
HeaderFile
to$N.h
, though you can use the$N
token.
To set this property to
Exported
, you must use one of the tokens$N
or$R
in the value ofHeaderFile
.
Header File
— Name of header file that declares data
$N.h
(default) | character vector | string scalar
Name of the header file that declares the data, specified as a name or naming rule. A naming rule includes a combination of text and tokens. Valid tokens are listed in this table.
Token | Description |
---|---|
$R | Name of root model |
$N | Name of associated data element |
$G | Name of storage class |
$U | User token text, which you specify for a model as described in Identifier Format Control |
Dependencies
If you set
DataScope
toExported
, you must use one of the tokens$R
or$N
in the value of this property.If you set
DataScope
toImported
, you cannot set the value of this property to$N.h
, but you can use the$N
token.
Definition File
— Name of source file that defines data
$N.c
(default) | character vector | string scalar
Name of the source file that defines the data, specified as a name or naming rule. A naming rule includes a combination of text and tokens. Valid tokens are listed in this table.
Token | Description |
---|---|
$R | Name of root model |
$N | Name of associated data element |
$G | Name of storage class |
$U | User token text, which you specify for a model as described in Identifier Format Control |
Dependencies
Setting DataScope
to Imported
disables
DefinitionFile
. To include your external source code file in
the build process, use model configuration parameters. For an example, see Configure Data Interface.
AccessMode
— Specification to access data through functions
Value
(default) | Pointer
Specification for the storage class to access data associated with the model through
functions by using Value
or Pointer
. For more
information, see Access Data Through Functions by Using Storage Classes in Embedded Coder Dictionary.
Dependencies
This property is enabled only when you set DataAccess
to
Function
.
AllowedAccess
— Specification to allow access to data through functions
ReadWrite
(default) | ReadOnly
| WriteOnly
Specification for the storage class to allow read and write
(ReadWrite
), read-only (ReadOnly
), or write-only
(WriteOnly
) access to the data.
Dependencies
This property is enabled only when you set DataAccess
to
Function
.
GetFunctionName
— Name of the get
function that fetches the associated data
get_$N$M
(default) | character vector | string scalar
Name of the get
function that fetches the associated data,
specified as a name or naming rule. A naming rule includes a combination of text and
tokens. Valid tokens are listed in this table.
Token | Description |
---|---|
$N | Name of associated data element (required) |
$R | Name of root model |
$M | Mangle text that ensures uniqueness |
$U | User token text. See Identifier Format Control. |
Dependencies
This property is enabled only when you set DataAccess
to
Function
and AllowedAccess
to
ReadWrite
or ReadOnly
.
SetFunctionName
— Name of the set
function that modifies the associated data
set_$N$M
(default) | character vector | string scalar
Name of the set
function that fetches the modified data,
specified as a name or naming rule. A naming rule includes a combination of text and
tokens. Valid tokens are listed in this table.
Token | Description |
---|---|
$N | Name of associated data element (required) |
$R | Name of root model |
$M | Mangle text that ensures uniqueness |
$U | User token text. See Identifier Format Control. |
Dependencies
This property is enabled only when you set DataAccess
to
Function
and AllowedAccess
to
ReadWrite
or WriteOnly
.
DifferentInstanceDataSettings
— Specification to assign separate storage settings for single-instance data and multi-instance data
false
(default) | true
Specification for the storage class to use either the storage settings that you specify for single-instance data or the settings that you specify for multi-instance data. When you apply the storage class to a data item, the Embedded Coder Dictionary determines if it is a single-instance storage class or a multi-instance storage class by the type of data and by the context of the model within the model reference hierarchy.
Dependencies
Selecting this property enables the properties
SingleInstanceStorageType
,
MultiInstanceStorageType
, and
MultiInstanceStructureTypeName
,
MultiInstanceStructureInstanceName
.
StorageType
— Specification to aggregate data into a structure
Unstructured
(default) | Structured
Specification to aggregate the data that uses the storage class into a structure in
the generated code. Each data element appears in the code as a field of the structure.
To create a structure, use Structured
.
Dependencies
Setting this property to Structured
enables
StructureTypeName
and
StructureInstanceName
.
StructureTypeName
— Name of structure type
$R$N$G$M
(default) | character vector | string scalar
Name of the structure type in the generated code, specified as a name or a naming rule. A naming rule includes a combination of text and tokens. Valid tokens are listed in this table.
Token | Description |
---|---|
$R | Name of root model |
$N | Base name of associated function, such as step |
$G | Name of storage class |
$U | User token text, which you specify for a model as described in Identifier Format Control |
$M | Name-mangling text inserted, if necessary, to avoid name collisions |
Dependencies
Setting StorageType
to Structured
enables
this property.
StructureInstanceName
— Name of structure variable
$G$N$M
(default) | character vector | string scalar
Name of the structure variable in the generated code, specified as a name or a naming rule. A naming rule includes a combination of text and tokens. Valid tokens are listed in this table.
Token | Description |
---|---|
$R | Name of root model |
$N | Base name of associated function, such as step |
$G | Name of storage class |
$U | User token text, which you specify for a model as described in Identifier Format Control |
$M | Name-mangling text inserted, if necessary, to avoid name collisions |
Dependencies
Setting StorageType
to Structured
enables
this property.
SingleInstanceStorageType
— Specification to aggregate single-instance data into a structure
Structured
(default) | Unstructured
Specification to aggregate the single-instance data that uses the storage class into
a structure in the generated code. Each data element appears in the code as a field of
the structure. To create a structure, use Structured
.
Dependencies
Setting the property
UseDifferentPropSettingsForInstanceData
totrue
enables this property.Setting this property to
Structured
enables the propertiesSingleInstanceStructureTypeName
andSingleInstanceStructureInstanceName
.
SingleInstanceStructureTypeName
— Name of structure type for single-instance data
$R$N$G$M
(default) | character vector | string scalar
Name of the structure type in the generated code, specified as a name or a naming rule. A naming rule includes a combination of text and tokens. Valid tokens are listed in this table.
Token | Description |
---|---|
$R | Name of root model |
$N | Base name of associated function, such as step |
$G | Name of storage class |
$U | User token text, which you specify for a model as described in Identifier Format Control |
$M | Name-mangling text inserted, if necessary, to avoid name collisions |
Dependencies
Setting SingleInstanceStorageType
to
Structured
enables this property.
SingleInstanceStructureInstanceName
— Name of structure variable for single-instance data
$G$N$M
(default) | character vector | string scalar
Name of the structure variable in the generated code, specified as a name or a naming rule. A naming rule includes a combination of text and tokens. Valid tokens are listed in this table.
Token | Description |
---|---|
$R | Name of root model |
$N | Base name of associated function, such as step |
$G | Name of storage class |
$U | User token text, which you specify for a model as described in Identifier Format Control |
$M | Name-mangling text inserted, if necessary, to avoid name collisions |
Dependencies
Setting SingleInstanceStorageType
to
Structured
enables this property.
MultiInstanceStorageType
— Specification to aggregate multi-instance data into a structure
Structured
(default)
Specification to aggregate the single-instance data that uses the storage class into a structure in the generated code. Each data element appears in the code as a field of the structure. You cannot change the value of this property.
Dependencies
Setting the property UseDifferentPropSettingsForInstanceData
to true
enables this property.
MultiInstanceStructureTypeName
— Name of structure type for multi-instance data
$R$N$G$M
(default) | character vector | string scalar
Name of the structure type in the generated code, specified as a name or a naming rule. A naming rule includes a combination of text and tokens. Valid tokens are listed in this table.
Token | Description |
---|---|
$R | Name of root model |
$N | Base name of associated function, such as step |
$G | Name of storage class |
$U | User token text, which you specify for a model as described in Identifier Format Control |
$M | Name-mangling text inserted, if necessary, to avoid name collisions |
Dependencies
Setting the property
UseDifferentPropSettingsForInstanceData
totrue
enables this property.If you set the property
DataAccess
toFunction
, you cannot set this property.
MultiInstanceStructureInstanceName
— Name of structure variable for multi-instance data
$G$N$M
(default) | character vector | string scalar
Name of the structure variable in the generated code, specified as a name or a naming rule. A naming rule includes a combination of text and tokens. Valid tokens are listed in this table.
Token | Description |
---|---|
$R | Name of root model |
$N | Base name of associated function, such as step |
$G | Name of storage class |
$U | User token text, which you specify for a model as described in Identifier Format Control |
$M | Name-mangling text inserted, if necessary, to avoid name collisions |
Dependencies
Setting the property
UseDifferentPropSettingsForInstanceData
totrue
enables this property.If you set the property
DataAccess
toFunction
, you cannot set this property.
DataInit
— How to initialize data
Dynamic
(default) | Static
|
None
Specification that the generated codes initialize the data.
Dynamic
— The generated code initializes the data as part of the model initialization entry-point function.Static
— The generated code initializes the data in the same statement that defines and allocates memory for the data. The assignment statement appears at the top of a.c
or.cpp
source file, outside of a function.None
— The generated code does not initialize the data.
Dependencies
If you set
Const
totrue
, you cannot set this property toDynamic
.Setting this property to
Dynamic
sets the propertyConst
tofalse
.
MemorySection
— Location in memory to allocate data
None
(default) | coder.dictionary.Entry
object
Location in memory to allocate data, specified as a
coder.dictionary.Entry
object that represents a memory section that
exists in the Embedded Coder Dictionary. For information about memory sections, see
Control Data and Function Placement in Memory by Inserting Pragmas.
PreserveDimensions
— Specification to preserve dimensions of multidimensional arrays
false
(default) | true
Specification for the storage class to preserve dimensions of multidimensional arrays in the generated code. For more information, see Preserve Dimensions of Multidimensional Arrays in Generated Code.
Const
— Specification to apply const
qualifier
false
(default) | true
Specification to apply the const
qualifier to the data.
Dependencies
If you select this property, you cannot set
DataInit
toDynamic
.Setting
DataInit
toDynamic
\sets this property tofalse
.
Volatile
— Specification to apply volatile
qualifier
false
(default) | true
Specification to apply the volatile
qualifier to the data.
OtherQualifier
— Specification to apply a custom qualifier
character vector | string scalar
Specification to apply a custom qualifier to the data. For example, some memory
architectures support qualifiers far
and
huge
.
Do not use this property to apply the keyword static
. Instead,
use the built-in storage class FileScope
, which you cannot apply with
the Code Mappings editor. See Choose Storage Class for Controlling Data Representation in Generated Code.
AccessibleByParameters
— Whether to allow usage with model parameters
false
(default) | true
Specification indicating whether to allow usage of the storage class with model parameters.
Dependencies
Setting
DataInit
toStatic
sets this property totrue
.Setting
DataInit
toDynamic
sets this property tofalse
.To set the value of this property, set
DataInit
toNone
.
AccessibleBySignals
— Whether to allow usage with model signals
true
(default) | false
Specification indicating whether to allow usage of the storage class with model signals.
Dependencies
Setting
DataInit
toDynamic
sets this property totrue
.Setting
DataInit
toStatic
sets this property tofalse
.To set the value of this property, set
DataInit
toNone
.
Name
— Name of function template
FunctionTemplate1
(default) | character vector | string scalar
Name of the template. The name must be unique among the function templates in the dictionary. Embedded Coder® provides the built-in templates listed in this table.
Template | Description |
---|---|
ModelFunction | In the Code Mappings editor, use for entry-point functions for initialization, execution, termination, and reset (see Configure Default Code Generation for Functions) |
UtilityFunction | In the Code Mappings editor, use for shared utility functions (see Configure Default Code Generation for Functions) |
Description
— Purpose and functionality of function template
character vector | string scalar
Custom text that you can use to describe the purpose and functionality of the function template.
FunctionName
— Names of generated functions
$R$N
(default) | character vector | string scalar
Names of the functions in the generated code, specified as a naming rule. A naming rule includes a combination of text and tokens. Valid tokens are listed in this table.
Token | Description |
---|---|
$R | Name of root model |
$N | Base name of associated function, such as step |
$U | User token text, which you specify for a model as described in Identifier Format Control |
$C | For shared utility functions, a checksum inserted to avoid name collisions |
$M | Name-mangling text inserted, if necessary, to avoid name collisions |
MemorySection
— Location in memory to allocate function
None
(default) | coder.dictionary.Entry
object
Location in memory to allocate function, specified as a
coder.dictionary.Entry
object that represents a memory section that
exists in the Embedded Coder Dictionary. For information about memory sections, see
Control Data and Function Placement in Memory by Inserting Pragmas.
Name
— Name of memory section
character vector | string scalar
Name of the memory section. The name must be unique among the memory sections in the dictionary. Embedded Coder provides the built-in memory sections listed in this table.
Memory Section | Description |
---|---|
MemConst | Apply the storage type qualifier const to the
data. |
MemVolatile | Apply the storage type qualifier volatile to the
data. |
MemConstVolatile | Apply the storage type qualifiers const and
volatile to the data. |
Description
— Purpose and functionality of memory section
character vector | string scalar
Custom text that you can use to describe the purpose and functionality of the memory section.
Comment
— Comment to insert in the generated code
character vector | string scalar
Code comment that the code generator includes with the pragmas or other decorations
that you specify with PreStatement
and
PostStatement
.
PreStatement
— Code to insert before data or function code
character vector | string scalar
Code, such as pragmas, to insert before the definitions and declarations of the data or functions that are in the memory section.
You can use the token $R
to represent the name of the model that
uses the memory section.
When you set StatementsSurround
to
EachVariable
, you can use the token $N
to
represent the name of each variable or function that uses the memory section.
PostStatement
— Code to insert after data or function code
character vector | string scalar
Code, such as pragmas, to insert after the definitions and declarations of the data or functions that are in the memory section.
You can use the token $R
to represent the name of the model that
uses the memory section.
When you set StatementsSurround
to
EachVariable
, you can use the token $N
to
represent the name of each variable or function that uses the memory section.
StatementsSurround
— Specification to wrap data and functions separately or in a group
EachVariable
(default) | AllVariables
Specification to insert code statements (PreStatement
and
PostStatement
):
Around each variable and function that uses the memory section. Select
EachVariable
.Once, around the entire memory section. The generated code aggregates the variable and function definitions into a contiguous code block and surrounds the block with the statements. Select
AllVariables
.
Methods
Public Methods
get | Get value of code definition property |
set | Set value of code definition property |
getAvailableProperties | Return properties for code definition |
deleteEntry | Delete Embedded Coder Dictionary entry |
valid | Determine if coder.dictionary.Entry object represents a valid
code definition |
Examples
Create Definition in Embedded Coder Dictionary
Open the model RollAxisAutopilot
and represent the Embedded Coder
Dictionary by using the coder.Dictionary
object
coderDictionary
. Use this object to access the Storage Classes
section of the dictionary, which contains the storage class definitions.
openExample('RollAxisAutopilot') coderDictionary = coder.dictionary.open('RollAxisAutopilot');
Create a coder.dictionary.Section
object that represents the
Storage Classes section of the Embedded Coder Dictionary.
storageClassesSect = getSection(coderDictionary, 'StorageClasses');
Add a definition named MyStorageClass
to the Storage Classes
section. The storage class definition uses the default property settings. You can change
these settings by using the set
function.
newEntry = addEntry(storageClassesSect,'MyStorageClass')
newEntry = Entry with properties: Name: 'MyStorageClass' DataSource: 'RollAxisAutopilot'
Version History
Introduced in R2019b
Commande MATLAB
Vous avez cliqué sur un lien qui correspond à cette commande MATLAB :
Pour exécuter la commande, saisissez-la dans la fenêtre de commande de MATLAB. Les navigateurs web ne supportent pas les commandes MATLAB.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list:
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)