Functions Used for Python module operations. More...
Functions | |
| void | REPY_AddCStrToSysPath (const char *filepath) |
| Casts a null-terminated C-string to a Python str and appends it to the current interpreter's sys.path. | |
| void | REPY_AddNrmToSysPath () |
| Adds this NRM to the current interpreter's sys.path. | |
| REPY_Handle | REPY_ConstructModuleFromCStr (const char *identifier, const char *code, REPY_bool add_to_sys) |
| Construct a new Python module from a NULL-terminated code string, optionally importable by name. | |
| REPY_Handle | REPY_ConstructModuleFromCStrN (const char *identifier, const char *code, REPY_u32 len, REPY_bool add_to_sys) |
| Construct a new Python module from a char array, optionally importable by name. | |
| REPY_Handle | REPY_ImportModule (const char *identifier) |
| Imports a Python module by name and returns a handle to it. | |
Functions Used for Python module operations.
| void REPY_AddCStrToSysPath | ( | const char * | filepath | ) |
Casts a null-terminated C-string to a Python str and appends it to the current interpreter's sys.path.
Unlike REPY_PreInitAddToSysPath, this will only add a path to the current interpreter. The sys.path values of any other interpreters defined before this point will be unaffected.
This function primarily exists to support for REPY_AddCStrToSysPath, since that needs to be inline in order to work.
| filepath | a null-terminated path string to be added to sys.path |
|
inline |
Adds this NRM to the current interpreter's sys.path.
Unlike REPY_PreInitAddToSysPath, this will only add a path to the current interpreter. The sys.path values of any other interpreters defined before this point will be unaffected.
This function is defined as inline in the repy_api.h header in order to be able to grab this mod's nrm path, and is primarily a wrapper for REPY_AddCStrToSysPath.
| REPY_Handle REPY_ConstructModuleFromCStr | ( | const char * | identifier, |
| const char * | code, | ||
| REPY_bool | add_to_sys ) |
Construct a new Python module from a NULL-terminated code string, optionally importable by name.
The Python code of the module is run immediately, rather than on first import.
| identifier | The name of the new module. Should be NULL-terminated. |
| code | The Python code for the module. Should be NULL-terminated. |
| add_to_sys | If true, the module is added to Python's sys.modules, allowing it to be brought into scope via an import statement. If false, the module will only be available through the returned REPY_Handle. |
| REPY_Handle REPY_ConstructModuleFromCStrN | ( | const char * | identifier, |
| const char * | code, | ||
| REPY_u32 | len, | ||
| REPY_bool | add_to_sys ) |
Construct a new Python module from a char array, optionally importable by name.
The Python code of the module is run immediately, rather than on first import.
| identifier | The name of the new module. Should be NULL-terminated. |
| code | The Python code for the module. Does not need to be null terminated. |
| len | The length of the Python code, in bytes. |
| add_to_sys | If true, the module is added to Python's sys.modules, allowing it to be brought into scope via an import statement. If false, the module will only be available through the returned REPY_Handle. |
| REPY_Handle REPY_ImportModule | ( | const char * | identifier | ) |
Imports a Python module by name and returns a handle to it.
Members of the module can be accessed with the various attribute access functions.
| identifier | The name of the Python module. Should be NULL-terminated. |