Modules and Interfaces#
This section describes the classes that represent a module body or a module interface. It also describes the class representing a use directive which is used to reference a module/interface in an other module/interface.
See also Operator declaration and Global declarations.
- class ansys.scadeone.core.swan.ModuleBody(name: PathIdentifier, use_directives: List[UseDirective] | None = None, declarations: List[GlobalDeclaration] | None = None)#
Bases:
Module
Module body definition.
- body() ModuleBody #
Return the module body for a module interface if it exists.
- filter_declarations(filter_fn) Generator[GlobalDeclaration, None, None] #
Return declarations matched by a filter.
- Parameters:
- filter_fn
function
A function of one argument of type GlobalDeclaration, returning True or False.
- filter_fn
- Yields:
Generator
[GlobalDeclaration
,None
,None
]Generator on matching declarations.
- get_declaration(name: str) GlobalDeclaration #
Return the type, global, or operator declaration searching by namespace.
- get_use_directive(name: str) UseDirective #
Return a dictionary of use directives by their name or given alias. The name is the last part of the path ID.
Returns Dict[str, UseDirective]
- interface() ModuleInterface #
Return the module interface for a module body if it exists.
- static set_owner(owner: Self, children: Self | Iterable[Self])#
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 module: ModuleBase#
Module containing the item.
- Returns:
ModuleBase: module container, see
ModuleBody
andModuleInterface
- property name: PathIdentifier#
Module or Interface name.
- property owner: Self#
Owner of current Swan construct.
- property sensors: Generator[SensorDecl, None, None]#
Return a generator on sensor declarations.
- property use_directive_list: List[UseDirective]#
Module’s use directives as a list. Can be modified.
- property use_directives: Generator[UseDirective, None, None]#
Module’s use directives as a generator.
- class ansys.scadeone.core.swan.ModuleInterface(name: PathIdentifier, use_directives: List[UseDirective] | None = None, declarations: List[ModuleItem] | None = None)#
Bases:
Module
Module interface definition.
- body() ModuleBody #
Return the module body for a module interface if it exists.
- filter_declarations(filter_fn) Generator[GlobalDeclaration, None, None] #
Return declarations matched by a filter.
- Parameters:
- filter_fn
function
A function of one argument of type GlobalDeclaration, returning True or False.
- filter_fn
- Yields:
Generator
[GlobalDeclaration
,None
,None
]Generator on matching declarations.
- get_declaration(name: str) GlobalDeclaration #
Return the type, global, or operator declaration searching by namespace.
- get_use_directive(name: str) UseDirective #
Return a dictionary of use directives by their name or given alias. The name is the last part of the path ID.
Returns Dict[str, UseDirective]
- interface() ModuleInterface #
Return the module interface for a module body if it exists.
- static set_owner(owner: Self, children: Self | Iterable[Self])#
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 module: ModuleBase#
Module containing the item.
- Returns:
ModuleBase: module container, see
ModuleBody
andModuleInterface
- property name: PathIdentifier#
Module or Interface name.
- property owner: Self#
Owner of current Swan construct.
- property sensors: Generator[SensorDecl, None, None]#
Return a generator on sensor declarations.
- property use_directive_list: List[UseDirective]#
Module’s use directives as a list. Can be modified.
- property use_directives: Generator[UseDirective, None, None]#
Module’s use directives as a generator.
- class ansys.scadeone.core.swan.UseDirective(path: PathIdentifier, alias: Identifier | None = None)#
Bases:
ModuleItem
Class for use directive.
- static set_owner(owner: Self, children: Self | Iterable[Self])#
Helper to set owner as the owner of each item in the Iterable items.
- property alias: Identifier | None#
Renaming of module.
- 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 module: ModuleBase#
Module containing the item.
- Returns:
ModuleBase: module container, see
ModuleBody
andModuleInterface
- property owner: Self#
Owner of current Swan construct.
- property path: PathIdentifier#
Used module path.