Code generation pragmas#
Code generation#
The CGPragma class stores pragmas used by the code generator.
Please refer to the code generation documentation for more details on how to use these pragmas.
The recognized pragmas are defined in the CGPragmaKind enumeration.
Use the method CGPragma.kind() to determine the kind of the pragma, and use
the appropriate method to retrieve the pragma content is any.
- class ansys.scadeone.core.swan.CGPragma(data: str)#
Bases:
PragmaPragma for Swan code generator.
- static filter(pragmas: List[Pragma], key: str, with_key: bool = True) List[Pragma]#
Filters a list of pragmas with/without a given key.
- get_full_path() str#
Full path of the Swan construct.
This method is implemented by derived classes that correspond to a declaration at the module level (such as sensor, type, group, const, operator), or a module itself.
- Returns:
strPath within the owner and name of the Swan construct.
- Raises:
ScadeOneExceptionIf the method is not implemented for the current SwanItem type.
- static set_owner(owner: SwanItem | IModel | None, children: SwanItem | Iterable[SwanItem] | None) None#
Helper to set owner as the owner of each item in the Iterable items.
- property is_protected: bool#
Tell if a construct item is syntactically protected with some markup and is stored as a string (without the markup).
- property kind: CGPragmaKind#
Return the pragma kind.
According to the kind call the appropriate method to get the value if any.
- property model: IModel#
Return model containing the Swan item.
- property module: ModuleBase | None#
Module containing the item.
- Returns:
ModuleBase: module container, see
ModuleBodyandModuleInterfaceor None if the object is itself a module.
- class ansys.scadeone.core.swan.CGPragmaKind(value)#
Bases:
EnumKind of pragma for Swan CG.
- classmethod from_string(kind_str: str) CGPragmaKind | None#
Return the CGPragmaKind from a string.
- Parameters:
- kind_str
str The string given.
- kind_str
- Returns:
Optional[CGPragmaKind]The corresponding CGPragmaKind if found, otherwise None.
- classmethod to_string(kind: CGPragmaKind) str | None#
Return the string representation of a CGPragmaKind.
- Parameters:
- kind
CGPragmaKind The CGPragmaKind to convert.
- kind
- Returns:
Optional[str]The string representation of the CGPragmaKind if found, otherwise None.
- CONST = 4#
C pragma for constants (“C:const”)
- DEFAULT = 3#
Default state pragma (“default”)
- ENUM_VALUE = 7#
C pragma for enum values (“C:enum_val value”)
- INITIALIZER = 8#
C pragma for type initializers (“C:initializer ID”)
- KEEP = 2#
Keep pragma (“keep”)
- NAME = 6#
C pragma for names (“C:name ID”)
- PROBE = 1#
Probe pragma for local variables (“probe”)
- SCALAR = 5#
C: pragma for scalar values (“C:scalar”)
- UNKNOWN = 9#
Unknown pragma.