Notation used in Ruby API documentation
Module: lay
Description: A macro class
Sub-classes: Format, Interpreter
This class is provided mainly to support generation of template macros in the DSL interpreter framework provided by MacroInterpreter. The implementation may be enhanced in future versions and provide access to macros stored inside KLayout's macro repository. But it can be used to execute macro code in a consistent way:
path = "path-to-macro.lym" RBA::Macro::new(path).run()
Using the Macro class with run for executing code will chose the right interpreter and is able to execute DRC and LVS scripts in the proper environment. This also provides an option to execute Ruby code from Python and vice versa.
In this scenario you can pass values to the script using Interpreter#define_variable. The interpreter to choose for DRC and LVS scripts is Interpreter#ruby_interpreter. For passing values back from the script, wrap the variable value into a Value object which can be modified by the called script and read back by the caller.
new Macro ptr | new | (string path) | Loads the macro from the given file path |
[const] | Macro ptr | _const_cast | Returns a non-const reference to self. | |
void | _create | Ensures the C++ object is created | ||
void | _destroy | Explicitly destroys the object | ||
[const] | bool | _destroyed? | Returns a value indicating whether the object was already destroyed | |
[const] | bool | _is_const_object? | Returns a value indicating whether the reference is a const reference | |
void | _manage | Marks the object as managed by the script side. | ||
void | _unmanage | Marks the object as no longer owned by the script side. | ||
[const] | string | category | Gets the category tags | |
void | category= | (string string) | Sets the category tags string | |
[const] | string | description | Gets the description text | |
void | description= | (string description) | Sets the description text | |
[const] | string | doc | Gets the macro's documentation string | |
void | doc= | (string doc) | Sets the macro's documentation string | |
[const] | string | dsl_interpreter | Gets the macro's DSL interpreter name (if interpreter is DSLInterpreter) | |
void | dsl_interpreter= | (string dsl_interpreter) | Sets the macro's DSL interpreter name (if interpreter is DSLInterpreter) | |
[const] | string | epilog | Gets the epilog code | |
void | epilog= | (string string) | Sets the epilog | |
[const] | Macro::Format | format | Gets the macro's storage format | |
void | format= | (Macro::Format format) | Sets the macro's storage format | |
[const] | string | group_name | Gets the menu group name | |
void | group_name= | (string string) | Sets the menu group name | |
[const] | Macro::Interpreter | interpreter | Gets the macro's interpreter | |
void | interpreter= | (Macro::Interpreter interpreter) | Sets the macro's interpreter | |
[const] | string | interpreter_name | Gets the macro interpreter name | |
void | is_autorun= | (bool flag) | Sets a flag indicating whether the macro is automatically executed on startup | |
[const] | bool | is_autorun? | Gets a flag indicating whether the macro is automatically executed on startup | |
void | is_autorun_early= | (bool flag) | Sets a flag indicating whether the macro is automatically executed early on startup | |
[const] | bool | is_autorun_early? | Gets a flag indicating whether the macro is automatically executed early on startup | |
[const] | string | menu_path | Gets the menu path | |
void | menu_path= | (string string) | Sets the menu path | |
[const] | string | name | Gets the name of the macro | |
[const] | string | path | Gets the path of the macro | |
[const] | string | prolog | Gets the prolog code | |
void | prolog= | (string string) | Sets the prolog | |
[const] | int | run | Executes the macro | |
void | save_to | (string path) | Saves the macro to the given file | |
[const] | string | shortcut | Gets the macro's keyboard shortcut | |
void | shortcut= | (string shortcut) | Sets the macro's keyboard shortcut | |
void | show_in_menu= | (bool flag) | Sets a value indicating whether the macro shall be shown in the menu | |
[const] | bool | show_in_menu? | Gets a value indicating whether the macro shall be shown in the menu | |
void | sync_properties_with_text | Synchronizes the macro properties with the text | ||
void | sync_text_with_properties | Synchronizes the macro text with the properties | ||
[const] | string | text | Gets the macro text | |
void | text= | (string string) | Sets the macro text | |
[const] | string | version | Gets the macro's version | |
void | version= | (string version) | Sets the macro's version |
[static,const] | Macro::Interpreter | DSLInterpreter | A domain-specific interpreter (DSL) | |
[static,const] | Macro::Format | MacroFormat | The macro has macro (XML) format | |
[static,const] | Macro::Interpreter | None | No specific interpreter | |
[static,const] | Macro::Format | PlainTextFormat | The macro has plain text format | |
[static,const] | Macro::Format | PlainTextWithHashAnnotationsFormat | The macro has plain text format with special pseudo-comment annotations | |
[static,const] | Macro::Interpreter | Python | The interpreter is Python | |
[static,const] | Macro::Interpreter | Ruby | The interpreter is Ruby | |
[static,const] | Macro::Interpreter | Text | Plain text | |
Macro ptr | macro_by_path | (string path) | Finds the macro by installation path | |
int | real_line | (string path, int line) | Gets the real line number for an include-encoded path and line number | |
string | real_path | (string path, int line) | Gets the real path for an include-encoded path and line number |
void | create | Use of this method is deprecated. Use _create instead | ||
void | destroy | Use of this method is deprecated. Use _destroy instead | ||
[const] | bool | destroyed? | Use of this method is deprecated. Use _destroyed? instead | |
[const] | bool | is_const_object? | Use of this method is deprecated. Use _is_const_object? instead |
DSLInterpreter | Signature: [static,const] Macro::Interpreter DSLInterpreter Description: A domain-specific interpreter (DSL) Python specific notes: | ||
MacroFormat | Signature: [static,const] Macro::Format MacroFormat Description: The macro has macro (XML) format Python specific notes: | ||
None | Signature: [static,const] Macro::Interpreter None Description: No specific interpreter Python specific notes: | ||
PlainTextFormat | Signature: [static,const] Macro::Format PlainTextFormat Description: The macro has plain text format Python specific notes: | ||
PlainTextWithHashAnnotationsFormat | Signature: [static,const] Macro::Format PlainTextWithHashAnnotationsFormat Description: The macro has plain text format with special pseudo-comment annotations Python specific notes: | ||
Python | Signature: [static,const] Macro::Interpreter Python Description: The interpreter is Python Python specific notes: | ||
Ruby | Signature: [static,const] Macro::Interpreter Ruby Description: The interpreter is Ruby Python specific notes: | ||
Text | Signature: [static,const] Macro::Interpreter Text Description: Plain text Python specific notes: | ||
_const_cast | Signature: [const] Macro ptr _const_cast Description: Returns a non-const reference to self. Basically, this method allows turning a const object reference to a non-const one. This method is provided as last resort to remove the constness from an object. Usually there is a good reason for a const object reference, so using this method may have undesired side effects. This method has been introduced in version 0.29.6. | ||
_create | Signature: void _create Description: Ensures the C++ object is created Use this method to ensure the C++ object is created, for example to ensure that resources are allocated. Usually C++ objects are created on demand and not necessarily when the script object is created. | ||
_destroy | Signature: void _destroy Description: Explicitly destroys the object Explicitly destroys the object on C++ side if it was owned by the script interpreter. Subsequent access to this object will throw an exception. If the object is not owned by the script, this method will do nothing. | ||
_destroyed? | Signature: [const] bool _destroyed? Description: Returns a value indicating whether the object was already destroyed This method returns true, if the object was destroyed, either explicitly or by the C++ side. The latter may happen, if the object is owned by a C++ object which got destroyed itself. | ||
_is_const_object? | Signature: [const] bool _is_const_object? Description: Returns a value indicating whether the reference is a const reference This method returns true, if self is a const reference. In that case, only const methods may be called on self. | ||
_manage | Signature: void _manage Description: Marks the object as managed by the script side. After calling this method on an object, the script side will be responsible for the management of the object. This method may be called if an object is returned from a C++ function and the object is known not to be owned by any C++ instance. If necessary, the script side may delete the object if the script's reference is no longer required. Usually it's not required to call this method. It has been introduced in version 0.24. | ||
_unmanage | Signature: void _unmanage Description: Marks the object as no longer owned by the script side. Calling this method will make this object no longer owned by the script's memory management. Instead, the object must be managed in some other way. Usually this method may be called if it is known that some C++ object holds and manages this object. Technically speaking, this method will turn the script's reference into a weak reference. After the script engine decides to delete the reference, the object itself will still exist. If the object is not managed otherwise, memory leaks will occur. Usually it's not required to call this method. It has been introduced in version 0.24. | ||
category | Signature: [const] string category Description: Gets the category tags The category tags string indicates to which categories a macro will belong to. This string is only used for templates currently and is a comma-separated list of category names. Python specific notes: | ||
category= | Signature: void category= (string string) Description: Sets the category tags string See category for details. Python specific notes: | ||
create | Signature: void create Description: Ensures the C++ object is created Use of this method is deprecated. Use _create instead Use this method to ensure the C++ object is created, for example to ensure that resources are allocated. Usually C++ objects are created on demand and not necessarily when the script object is created. | ||
description | Signature: [const] string description Description: Gets the description text The description text of a macro will appear in the macro list. If used as a macro template, the description text can have the format "Group;;Description". In that case, the macro will appear in a group with title "Group". Python specific notes: | ||
description= | Signature: void description= (string description) Description: Sets the description text
See description for details. Python specific notes: | ||
destroy | Signature: void destroy Description: Explicitly destroys the object Use of this method is deprecated. Use _destroy instead Explicitly destroys the object on C++ side if it was owned by the script interpreter. Subsequent access to this object will throw an exception. If the object is not owned by the script, this method will do nothing. | ||
destroyed? | Signature: [const] bool destroyed? Description: Returns a value indicating whether the object was already destroyed Use of this method is deprecated. Use _destroyed? instead This method returns true, if the object was destroyed, either explicitly or by the C++ side. The latter may happen, if the object is owned by a C++ object which got destroyed itself. | ||
doc | Signature: [const] string doc Description: Gets the macro's documentation string This method has been introduced in version 0.27.5. Python specific notes: | ||
doc= | Signature: void doc= (string doc) Description: Sets the macro's documentation string This method has been introduced in version 0.27.5. Python specific notes: | ||
dsl_interpreter | Signature: [const] string dsl_interpreter Description: Gets the macro's DSL interpreter name (if interpreter is DSLInterpreter) This method has been introduced in version 0.27.5. Python specific notes: | ||
dsl_interpreter= | Signature: void dsl_interpreter= (string dsl_interpreter) Description: Sets the macro's DSL interpreter name (if interpreter is DSLInterpreter) This method has been introduced in version 0.27.5. Python specific notes: | ||
epilog | Signature: [const] string epilog Description: Gets the epilog code The epilog is executed after the actual code is executed. Interpretation depends on the implementation of the DSL interpreter for DSL macros. Python specific notes: | ||
epilog= | Signature: void epilog= (string string) Description: Sets the epilog See epilog for details. Python specific notes: | ||
format | Signature: [const] Macro::Format format Description: Gets the macro's storage format This method has been introduced in version 0.27.5. Python specific notes: | ||
format= | Signature: void format= (Macro::Format format) Description: Sets the macro's storage format This method has been introduced in version 0.27.5. Python specific notes: | ||
group_name | Signature: [const] string group_name Description: Gets the menu group name If a group name is specified and show_in_menu? is true, the macro will appear in a separate group (separated by a separator) together with other macros sharing the same group. Python specific notes: | ||
group_name= | Signature: void group_name= (string string) Description: Sets the menu group name See group_name for details. Python specific notes: | ||
interpreter | Signature: [const] Macro::Interpreter interpreter Description: Gets the macro's interpreter This method has been introduced in version 0.27.5. Python specific notes: | ||
interpreter= | Signature: void interpreter= (Macro::Interpreter interpreter) Description: Sets the macro's interpreter This method has been introduced in version 0.27.5. Python specific notes: | ||
interpreter_name | Signature: [const] string interpreter_name Description: Gets the macro interpreter name This is the string version of interpreter. This method has been introduced in version 0.27.5. | ||
is_autorun= | Signature: void is_autorun= (bool flag) Description: Sets a flag indicating whether the macro is automatically executed on startup This method has been introduced in version 0.27.5. Python specific notes: | ||
is_autorun? | Signature: [const] bool is_autorun? Description: Gets a flag indicating whether the macro is automatically executed on startup This method has been introduced in version 0.27.5. Python specific notes: | ||
is_autorun_early= | Signature: void is_autorun_early= (bool flag) Description: Sets a flag indicating whether the macro is automatically executed early on startup This method has been introduced in version 0.27.5. Python specific notes: | ||
is_autorun_early? | Signature: [const] bool is_autorun_early? Description: Gets a flag indicating whether the macro is automatically executed early on startup This method has been introduced in version 0.27.5. Python specific notes: | ||
is_const_object? | Signature: [const] bool is_const_object? Description: Returns a value indicating whether the reference is a const reference Use of this method is deprecated. Use _is_const_object? instead This method returns true, if self is a const reference. In that case, only const methods may be called on self. | ||
macro_by_path | Signature: [static] Macro ptr macro_by_path (string path) Description: Finds the macro by installation path Returns nil if no macro with this path can be found. This method has been added in version 0.26. | ||
menu_path | Signature: [const] string menu_path Description: Gets the menu path If a menu path is specified and show_in_menu? is true, the macro will appear in the menu at the specified position. Python specific notes: | ||
menu_path= | Signature: void menu_path= (string string) Description: Sets the menu path See menu_path for details. Python specific notes: | ||
name | Signature: [const] string name Description: Gets the name of the macro This attribute has been added in version 0.25. | ||
new | Signature: [static] new Macro ptr new (string path) Description: Loads the macro from the given file path This constructor has been introduced in version 0.27.5. Python specific notes: | ||
path | Signature: [const] string path Description: Gets the path of the macro The path is the path where the macro is stored, starting with an abstract group identifier. The path is used to identify the macro in the debugger for example. | ||
prolog | Signature: [const] string prolog Description: Gets the prolog code The prolog is executed before the actual code is executed. Interpretation depends on the implementation of the DSL interpreter for DSL macros. Python specific notes: | ||
prolog= | Signature: void prolog= (string string) Description: Sets the prolog See prolog for details. Python specific notes: | ||
real_line | Signature: [static] int real_line (string path, int line) Description: Gets the real line number for an include-encoded path and line number When using KLayout's include scheme based on '# %include ...', __FILE__ and __LINE__ (Ruby) will not have the proper values but encoded file names. This method allows retrieving the real line number by using # Ruby real_line = RBA::Macro::real_line(__FILE__, __LINE__) # Python real_line = pya::Macro::real_line(__file__, __line__) This substitution is not required for top-level macros as KLayout's interpreter will automatically use this function instead of __FILE__. Call this function when you need __FILE__ from files included through the languages mechanisms such as 'require' or 'load' where this substitution does not happen. For Python there is no equivalent for __LINE__, so you always have to use: # Pythonimport inspect real_line = pya.Macro.real_line(__file__, inspect.currentframe().f_back.f_lineno) This feature has been introduced in version 0.27. | ||
real_path | Signature: [static] string real_path (string path, int line) Description: Gets the real path for an include-encoded path and line number When using KLayout's include scheme based on '# %include ...', __FILE__ and __LINE__ (Ruby) will not have the proper values but encoded file names. This method allows retrieving the real file by using # Ruby real_file = RBA::Macro::real_path(__FILE__, __LINE__) This substitution is not required for top-level macros as KLayout's interpreter will automatically use this function instead of __FILE__. Call this function when you need __FILE__ from files included through the languages mechanisms such as 'require' or 'load' where this substitution does not happen. For Python there is no equivalent for __LINE__, so you always have to use: # Pythonimport inspect real_file = pya.Macro.real_path(__file__, inspect.currentframe().f_back.f_lineno) This feature has been introduced in version 0.27. | ||
run | Signature: [const] int run Description: Executes the macro This method has been introduced in version 0.27.5. | ||
save_to | Signature: void save_to (string path) Description: Saves the macro to the given file This method has been introduced in version 0.27.5. | ||
shortcut | Signature: [const] string shortcut Description: Gets the macro's keyboard shortcut This method has been introduced in version 0.27.5. Python specific notes: | ||
shortcut= | Signature: void shortcut= (string shortcut) Description: Sets the macro's keyboard shortcut This method has been introduced in version 0.27.5. Python specific notes: | ||
show_in_menu= | Signature: void show_in_menu= (bool flag) Description: Sets a value indicating whether the macro shall be shown in the menu Python specific notes: | ||
show_in_menu? | Signature: [const] bool show_in_menu? Description: Gets a value indicating whether the macro shall be shown in the menu Python specific notes: | ||
sync_properties_with_text | Signature: void sync_properties_with_text Description: Synchronizes the macro properties with the text This method performs the reverse process of sync_text_with_properties. This method has been introduced in version 0.27.5. | ||
sync_text_with_properties | Signature: void sync_text_with_properties Description: Synchronizes the macro text with the properties This method applies to PlainTextWithHashAnnotationsFormat format. The macro text will be enhanced with pseudo-comments reflecting the macro properties. This way, the macro properties can be stored in plain files. This method has been introduced in version 0.27.5. | ||
text | Signature: [const] string text Description: Gets the macro text The text is the code executed by the macro interpreter. Depending on the DSL interpreter, the text can be any kind of code. Python specific notes: | ||
text= | Signature: void text= (string string) Description: Sets the macro text See text for details. Python specific notes: | ||
version | Signature: [const] string version Description: Gets the macro's version This method has been introduced in version 0.27.5. Python specific notes: | ||
version= | Signature: void version= (string version) Description: Sets the macro's version This method has been introduced in version 0.27.5. Python specific notes: |