RecompExternalPython for N64Recompiled 2.0.0
Loading...
Searching...
No Matches

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.

Detailed Description

Functions Used for Python module operations.

Function Documentation

◆ REPY_AddCStrToSysPath()

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.

Parameters
filepatha null-terminated path string to be added to sys.path

◆ REPY_AddNrmToSysPath()

void REPY_AddNrmToSysPath ( )
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_ConstructModuleFromCStr()

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.

Parameters
identifierThe name of the new module. Should be NULL-terminated.
codeThe Python code for the module. Should be NULL-terminated.
add_to_sysIf 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.
Returns
a new REPY_Handle for the module.

◆ REPY_ConstructModuleFromCStrN()

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.

Parameters
identifierThe name of the new module. Should be NULL-terminated.
codeThe Python code for the module. Does not need to be null terminated.
lenThe length of the Python code, in bytes.
add_to_sysIf 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.
Returns
a new REPY_Handle for the module.

◆ REPY_ImportModule()

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.

Parameters
identifierThe name of the Python module. Should be NULL-terminated.