Macros | |
| #define | REPY_FN_EXEC(code_handle) |
| Executes Python code object within the current inline execution scope. | |
| #define | REPY_FN_EXEC_CSTR(code_str) |
| Executes Python code string string within the current inline execution scope. | |
| #define | REPY_FN_EXEC_CACHE(identifier, code_str) |
| Executes a Python code string string within the current inline execution scope, compiling it the first time it's run and caching the bytecode for subsequent uses. | |
Parse and execute Python code strings within this scope. An extremely flexable way of interweaving mod code and Python code.
| #define REPY_FN_EXEC | ( | code_handle | ) |
Executes Python code object within the current inline execution scope.
The code to execute should already be a Python object. A precompiled bytecode object is recommended for performance reasons, but a Python str object will also work.
| code_handle | The Python code to execute. Should be a REPY_Handle to a valid code object. |
| #define REPY_FN_EXEC_CACHE | ( | identifier, | |
| code_str ) |
Executes a Python code string string within the current inline execution scope, compiling it the first time it's run and caching the bytecode for subsequent uses.
This is the recommended method of inlining executable blocks of Python code inside of functions. The performance difference made by not having to recompile the code strings into bytecode for every run is substantial.
Because this macro expands to a block of code, rather than a single funtion call, the success of the execution is stored in a variable named [identifier]_success. This variable will be 1 if execution was successful, 0 if there was an error.
| identifier | The name for a static variable that will hold the Python bytecode handle once created. |
| code_str | The Python code to execute. Should be a NULL-terminated C-string such as a string literal. This code string will only be parsed and compiled once. |
| #define REPY_FN_EXEC_CSTR | ( | code_str | ) |
Executes Python code string string within the current inline execution scope.
Not generally recommended, since this will require recompiling the Python code string every time it's run. It is technically faster than REPY_FN_EXEC_CACHE for code that is only used once (since one fewer handle lookup is involved), but the difference is so marginal that it really doesn't matter.
| code_str | The Python code to execute. Should be a NULL-terminated C-string such as a string literal or a const char*. |