Declaration base classes#
The Declaration class serves as the base class for all declarations of constructs with an identifier.
Declarations of the same kind (e.g., constant, type, sensor, group) are grouped into a list of declarations,
contained within classes derived from GlobalDeclaration.
Fig. 3 Declaration classes hierarchy#
Note
In Swan, a global declaration can contain multiple declarations. For example, one can write:
const C1: int32; C2: int32; or const C1: int32; const C2: int32;.
While the Swan editor produces the second form, having a list of declarations
in the first form is also valid.
- class ansys.scadeone.core.swan.Declaration(id: Identifier, pragmas: List[Pragma] | None = None)#
Bases:
HasPragmaBase class for declarations.
- 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 id: Identifier#
Language item identifier.
- 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 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.GlobalDeclaration#
Bases:
ModuleItemAbstract class for global declarations:
type declaration list
constant declaration list
sensor declaration list
group declarations
- 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 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.ProtectedDecl(markup: str, data: str, pragmas: List[Pragma] | None = None)#
Bases:
ProtectedItem,GlobalDeclaration,HasPragmaProtected declaration.
- 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_operator: bool#
Protected operator declaration.
Note: operator declaration within {text% … %text} is parsed.
- 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.