RecompExternalPython for N64Recompiled 2.0.0
Loading...
Searching...
No Matches
repy_api.h File Reference

The main header for Recomp External Python. Header version 2. . More...

#include "modding.h"
#include "recomputils.h"
#include "recompconfig.h"

Go to the source code of this file.

Macros

#define REPY_MOD_ID_STR   "RecompExternalPython_API"
 The mod id string for REPY.
#define REPY_IMPORT(func)
#define REPY_NO_OBJECT   0
 Represents the absence of a Python object in REPY API functions. Goes with REPY_Handle.
#define REPY_MAIN_INTERPRETER   0
 Represents the index of the main Python interpreter. Goes with REPY_InterpreterIndex.
#define REPY_INTERPRETER_STACK_EMPTY   -1
 A value indicating that the interpreter stack is empty. Goes with REPY_InterpreterIndex.
#define REPY_ON_PRE_INIT   RECOMP_CALLBACK(REPY_MOD_ID_STR, REPY_OnPreInit)
 Runs before the Python interpreter is initialized.
#define REPY_ON_CONFIG_INTERPRETERS   RECOMP_CALLBACK(REPY_MOD_ID_STR, REPY_OnConfigInterpreters)
 Event that runs immediately after the Python interpreter is initialized. Used by the REPY_REGISTER_SUBINTERPRETER macro.
#define REPY_ON_INIT_CODE_CACHE   RECOMP_CALLBACK(REPY_MOD_ID_STR, REPY_OnInitCodeCache)
 Event that runs immediately after REPY_ON_INIT_SUBINTERPRETERS. Used by the various global and static code caching macros.
#define REPY_ON_POST_INIT   RECOMP_CALLBACK(REPY_MOD_ID_STR, REPY_OnPostInit)
 Event that runs immediately after the REPY_ON_INIT is called. Since many REPY macros use REPY_ON_INIT, use this event to ensure your code runs after.
#define REPY_PREINIT_ADD_NRM_TO_ALL_INTERPRETERS
 Adds this .nrm file to Python's module search path.
#define REPY_ADD_NRM_TO_MAIN_INTERPRETER
 Adds this .nrm file to the main Python interpreter's module search path.
#define REPY_REGISTER_SUBINTERPRETER(subinterp_identifier)
 Use this macro at the global level of a C file to initialize a subinterpreter on startup.
#define REPY_EXTERN_SUBINTERPRETER(subinterp_identifier)
 Macro used to extern in a subinterpreter index variable.
#define REPY_EXTERN_INCBIN(identifier)
 Macro that creates extern statements for data included by REPY_INCBIN and REPY_INCBIN_TEXT.
#define REPY_INCBIN(identifier, filename)
 General INCBIN macro used by several other initialization macros to include external Python code.
#define REPY_INCBIN_TEXT(identifier, filename)
 General INCBIN macro used by several other initialization macros to include external Python code.
#define REPY_GLOBAL_COMPILE_CACHE(interpreter_index, bytecode_identifier, code_mode, code_str)
 On startup, compiles a Python code string into bytecode with a global handle. Use outside of any functions.
#define REPY_STATIC_COMPILE_CACHE(interpreter_index, bytecode_identifier, code_mode, code_str)
 On startup, compiles a Python code string into bytecode with a static handle. Use outside of any functions.
#define REPY_GLOBAL_COMPILE_INCBIN_CACHE(interpreter_index, bytecode_identifier, filename)
 On startup, compiles a INCBINed Python code file into bytecode with a global handle.
#define REPY_STATIC_COMPILE_INCBIN_CACHE(interpreter_index, bytecode_identifier, filename)
 On startup, compiles a INCBINed Python code file into bytecode with a global handle. Use outside of any functions.
#define REPY_INLINE_COMPILE_CACHE_BLOCK(category, bytecode_identifier, code_mode, code_str)
 Inside a function, construct a code block that compiles to bytecode a Python code string the first time it's run, storing the handle for that bytecode in a static variable. Allows setting a category name.
#define REPY_INLINE_COMPILE_CACHE(bytecode_identifier, code_mode, code_str)
 Inside a function, construct a code block that compiles to bytecode a Python code string the first time it's run, storing the handle for that bytecode in a static variable.
#define REPY_FOREACH_FNAC(iter_identifier, py_object)
 Iterate through a Python object, the way Python's for loops do.
#define REPY_FOREACH(iter_identifier, py_object, auto_self_destuct)
 Iterate through a Python object, the way Python's for loops do.
#define REPY_FOREACH_CLEANUP_NOW(iter_identifier)
 Manually clean up the REPY_IteratorHelper for a REPY_FOREACH loop.
#define REPY_FOREACH_BREAK(iter_identifier)
 Manually clean up the REPY_IteratorHelper for a REPY_FOREACH loop, and immediately break.
#define REPY_FOREACH_RETURN(iter_identifier, retType, retVal)
 Manually clean up the REPY_IteratorHelper for a REPY_FOREACH loop, and immediately return.
#define REPY_FN_GLOBAL_SCOPE   __repy_globals
 The variable name for inline execution global scopes.
#define REPY_FN_LOCAL_SCOPE   __repy_locals
 The variable name for inline execution local scopes.
#define REPY_FN_AUTO_CLEANUP   __repy_auto_cleanup
 The variable name for helper auto-cleanup object.
#define REPY_FN_SETUP_INTERP(interp_index)
 Create an inline execution scope for your function without any globals.
#define REPY_FN_SETUP_INTERP_WITH_GLOBALS(interp_index, globals)
 Create an inline execution scope for your function, using a pre-defined Python dict as your global scope object, and creating a new Python dict for the local scope. Note that, unless otherwise specified, executing Python code stores variables on the local scope.
#define REPY_FN_SETUP   REPY_FN_SETUP_INTERP(REPY_MAIN_INTERPRETER)
 Create an inline execution scope for your function without any globals.
#define REPY_FN_SETUP_WITH_GLOBALS(globals)
 Create an inline execution scope for your function, using a pre-defined Python dict as your global scope object, and creating a new Python dict for the local scope. Note that, unless otherwise specified, executing Python code stores variables on the local scope.
#define REPY_FN_CLEANUP
 Clean up a inline execution scope by releasing the local scope and popping the last interpreter index.
#define REPY_FN_RETURN(retType, retVal)
 Clean up a inline scope by releasing the local scope and popping the last interpreter index, then returns.
#define REPY_FN_DEFER_RELEASE(handle)
 Registers a REPY_Handle to be released by the REPY_DeferredCleanupHelper for this REPY_FN scope.
#define REPY_FN_DEFER_RECOMP_FREE(pointer)
 Registers a void* to be deallocated by the REPY_DeferredCleanupHelper for this REPY_FN scope.
#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.
#define REPY_FN_EVAL(code_handle)
 Evaluates a Python expression code object within the current inline execution scope, and returns the result.
#define REPY_FN_EVAL_BOOL(code_handle)
 Evaluates a Python expression code object within the current inline execution scope, and returns the result as a bool.
#define REPY_FN_EVAL_U8(code_handle)
 Evaluates a Python expression code object within the current inline execution scope, and returns the result as a u8.
#define REPY_FN_EVAL_S8(code_handle)
 Evaluates a Python expression code object within the current inline execution scope, and returns the result as a s8.
#define REPY_FN_EVAL_U16(code_handle)
 Evaluates a Python expression code object within the current inline execution scope, and returns the result as a u16.
#define REPY_FN_EVAL_S16(code_handle)
 Evaluates a Python expression code object within the current inline execution scope, and returns the result as a s16.
#define REPY_FN_EVAL_U32(code_handle)
 Evaluates a Python expression code object within the current inline execution scope, and returns the result as a u32.
#define REPY_FN_EVAL_S32(code_handle)
 Evaluates a Python expression code object within the current inline execution scope, and returns the result as a s32.
#define REPY_FN_EVAL_F32(code_handle)
 Evaluates a Python expression code object within the current inline execution scope, and returns the result as a f32.
#define REPY_FN_EVAL_U64(code_handle)
 Evaluates a Python expression code object within the current inline execution scope, and returns the result as a u64.
#define REPY_FN_EVAL_S64(code_handle)
 Evaluates a Python expression code object within the current inline execution scope, and returns the result as a s64.
#define REPY_FN_EVAL_F64(code_handle)
 Evaluates a Python expression code object within the current inline execution scope, and returns the result as a f64.
#define REPY_FN_EVAL_STR(code_handle)
 Evaluates a Python expression code object within the current inline execution scope, and returns the result as a char* C string.
#define REPY_FN_EVAL_BYTESTR(code_handle)
 Evaluates a Python expression code object within the current inline execution scope, and returns the result as a char* C string.
#define REPY_FN_EVAL_CSTR(code_str)
 Evaluates a Python expression code string within the current inline execution scope, and returns the result.
#define REPY_FN_EVAL_CSTR_BOOL(code_str)
 Evaluates a Python expression code string within the current inline execution scope, and returns the result as a bool.
#define REPY_FN_EVAL_CSTR_U8(code_str)
 Evaluates a Python expression code string within the current inline execution scope, and returns the result as a u8.
#define REPY_FN_EVAL_CSTR_S8(code_str)
 Evaluates a Python expression code string within the current inline execution scope, and returns the result as a s8.
#define REPY_FN_EVAL_CSTR_U16(code_str)
 Evaluates a Python expression code string within the current inline execution scope, and returns the result as a u16.
#define REPY_FN_EVAL_CSTR_S16(code_str)
 Evaluates a Python expression code string within the current inline execution scope, and returns the result as a s16.
#define REPY_FN_EVAL_CSTR_U32(code_str)
 Evaluates a Python expression code string within the current inline execution scope, and returns the result as a u32.
#define REPY_FN_EVAL_CSTR_S32(code_str)
 Evaluates a Python expression code string within the current inline execution scope, and returns the result as a s32.
#define REPY_FN_EVAL_CSTR_F32(code_str)
 Evaluates a Python expression code string within the current inline execution scope, and returns the result as a f32.
#define REPY_FN_EVAL_CSTR_U64(code_str)
 Evaluates a Python expression code string within the current inline execution scope, and returns the result as a u64.
#define REPY_FN_EVAL_CSTR_S64(code_str)
 Evaluates a Python expression code string within the current inline execution scope, and returns the result as a s64.
#define REPY_FN_EVAL_CSTR_F64(code_str)
 Evaluates a Python expression code string within the current inline execution scope, and returns the result as a f64.
#define REPY_FN_EVAL_CSTR_STR(code_str)
 Evaluates a Python expression code string within the current inline execution scope, and returns the result as a char*.
#define REPY_FN_EVAL_CSTR_BYTESTR(code_str)
 Evaluates a Python expression code string within the current inline execution scope, and returns the result as a char*.
#define REPY_FN_EVAL_CACHE(bytecode_identifier, code_str, out_var)
 Evaluate a Python expression code string within the current inline execution scope, compiling it the first time it's run and caching the bytecode for subsequent uses, and storing its result as a REPY_Handle.
#define REPY_FN_EVAL_CACHE_BOOL(bytecode_identifier, code_str, out_var)
 Evaluate a Python expression code string within the current inline execution scope, compiling it the first time it's run and caching the bytecode for subsequent uses, and storing its result as a bool.
#define REPY_FN_EVAL_CACHE_U8(bytecode_identifier, code_str, out_var)
 Evaluate a Python expression code string within the current inline execution scope, compiling it the first time it's run and caching the bytecode for subsequent uses, and storing its result as a u8.
#define REPY_FN_EVAL_CACHE_S8(bytecode_identifier, code_str, out_var)
 Evaluate a Python expression code string within the current inline execution scope, compiling it the first time it's run and caching the bytecode for subsequent uses, and storing its result as a s8.
#define REPY_FN_EVAL_CACHE_U16(bytecode_identifier, code_str, out_var)
 Evaluate a Python expression code string within the current inline execution scope, compiling it the first time it's run and caching the bytecode for subsequent uses, and storing its result as a u16.
#define REPY_FN_EVAL_CACHE_S16(bytecode_identifier, code_str, out_var)
 Evaluate a Python expression code string within the current inline execution scope, compiling it the first time it's run and caching the bytecode for subsequent uses, and storing its result as a s16.
#define REPY_FN_EVAL_CACHE_U32(bytecode_identifier, code_str, out_var)
 Evaluate a Python expression code string within the current inline execution scope, compiling it the first time it's run and caching the bytecode for subsequent uses, and storing its result as a u32.
#define REPY_FN_EVAL_CACHE_S32(bytecode_identifier, code_str, out_var)
 Evaluate a Python expression code string within the current inline execution scope, compiling it the first time it's run and caching the bytecode for subsequent uses, and storing its result as a s32.
#define REPY_FN_EVAL_CACHE_F32(bytecode_identifier, code_str, out_var)
 Evaluate a Python expression code string within the current inline execution scope, compiling it the first time it's run and caching the bytecode for subsequent uses, and storing its result as a f32.
#define REPY_FN_EVAL_CACHE_U64(bytecode_identifier, code_str, out_var)
 Evaluate a Python expression code string within the current inline execution scope, compiling it the first time it's run and caching the bytecode for subsequent uses, and storing its result as a u64.
#define REPY_FN_EVAL_CACHE_S64(bytecode_identifier, code_str, out_var)
 Evaluate a Python expression code string within the current inline execution scope, compiling it the first time it's run and caching the bytecode for subsequent uses, and storing its result as a s64.
#define REPY_FN_EVAL_CACHE_F64(bytecode_identifier, code_str, out_var)
 Evaluate a Python expression code string within the current inline execution scope, compiling it the first time it's run and caching the bytecode for subsequent uses, and storing its result as a f64.
#define REPY_FN_EVAL_CACHE_STR(bytecode_identifier, code_str, out_var)
 Evaluate a Python expression code string within the current inline execution scope, compiling it the first time it's run and caching the bytecode for subsequent uses, and storing its result as a char*.
#define REPY_FN_EVAL_CACHE_BYTESTR(bytecode_identifier, code_str, out_var)
 Evaluate a Python expression code string within the current inline execution scope, compiling it the first time it's run and caching the bytecode for subsequent uses, and storing its result as a char*.
#define REPY_FN_IMPORT(module_name)
 Inserts a Python module into the local scope.
#define REPY_FN_GET(var_name)
 Gets a variable from the local scope.
#define REPY_FN_SET(var_name, py_object)
 Sets a variable in the the local scope, using a REPY_Handle for the value.
#define REPY_FN_GET_BOOL(var_name)
 Gets a variable from the local scope and casts it to a bool.
#define REPY_FN_SET_BOOL(var_name, value)
 Sets a variable of the Python type bool in the the local scope, using a bool for the value.
#define REPY_FN_GET_U8(var_name)
 Gets a variable from the local scope and casts it to a u8.
#define REPY_FN_SET_U8(var_name, value)
 Sets a variable of the Python type int in the the local scope, using a u8 for the value.
#define REPY_FN_GET_S8(var_name)
 Gets a variable from the local scope and casts it to a s8.
#define REPY_FN_SET_S8(var_name, value)
 Sets a variable of the Python type int in the the local scope, using a s8 for the value.
#define REPY_FN_GET_U16(var_name)
 Gets a variable from the local scope and casts it to a u16.
#define REPY_FN_SET_U16(var_name, value)
 Sets a variable of the Python type int in the the local scope, using a u16 for the value.
#define REPY_FN_GET_S16(var_name)
 Gets a variable from the local scope and casts it to a s16.
#define REPY_FN_SET_S16(var_name, value)
 Sets a variable of the Python type int in the the local scope, using a s16 for the value.
#define REPY_FN_GET_U32(var_name)
 Gets a variable from the local scope and casts it to a u32.
#define REPY_FN_SET_U32(var_name, value)
 Sets a variable of the Python type int in the the local scope, using a u32 for the value.
#define REPY_FN_GET_S32(var_name)
 Gets a variable from the local scope and casts it to a s32.
#define REPY_FN_SET_S32(var_name, value)
 Sets a variable of the Python type int in the the local scope, using a s32 for the value.
#define REPY_FN_GET_F32(var_name)
 Gets a variable from the local scope and casts it to a f32.
#define REPY_FN_SET_F32(var_name, value)
 Sets a variable of the Python type float in the the local scope, using a f32 for the value.
#define REPY_FN_GET_U64(var_name)
 Gets a variable from the local scope and casts it to a u64.
#define REPY_FN_SET_U64(var_name, value)
 Sets a variable of the Python type int in the the local scope, using a u64 for the value.
#define REPY_FN_GET_S64(var_name)
 Gets a variable from the local scope and casts it to a s64.
#define REPY_FN_SET_S64(var_name, value)
 Sets a variable of the Python type int in the the local scope, using a s64 for the value.
#define REPY_FN_GET_F64(var_name)
 Gets a variable from the local scope and casts it to a f64.
#define REPY_FN_SET_F64(var_name, value)
 Sets a variable of the Python type float in the the local scope, using a f64 for the value.
#define REPY_FN_GET_STR(var_name)
 Gets a variable from the local scope and casts it to a char*. Intended to be used when the variable object is a Python str.
#define REPY_FN_SET_STR(var_name, value)
 Sets a variable of the Python type str in the the local scope, using a NULL-terminated C string.
#define REPY_FN_SET_STR_N(var_name, value, len)
 Sets a variable of the Python type str in the the local scope, using char array of N length for the value.
#define REPY_FN_GET_BYTESTR(var_name)
 Gets a variable from the local scope and casts it to a char*. Intended to be used when the variable object is a Python bytes.
#define REPY_FN_SET_BYTESTR(var_name, value)
 Sets a variable of the Python type str in the the local scope, using a NULL-terminated C string.
#define REPY_FN_SET_BYTESTR_N(var_name, value, len)
 Sets a variable of the Python type bytes in the the local scope, using char array of N length for the value.
#define REPY_FN_IF_CACHE_INIT(helper_identifier)
 Initializes the helpers for cached Pythonic if statements in the current scope.
#define REPY_FN_IF_CACHE_STMT(helper_identifier, py_expression)
 Constructs a if statement that uses a cached Python expression executed in the current scope.
#define REPY_FN_IF_CACHE(helper_identifier, py_expression)
 Initializes the helpers for a cached Pythonic if/else block, and constructs the first if statement, using a cached Python expression executed in the local scope.
#define REPY_FN_ELIF_CACHE(helper_identifier, py_expression)
 Constructs a else if statement that uses a cached Python expression executed in the current scope.
#define REPY_FN_WHILE_CACHE(bytecode_identifier, py_expression)
 Constructs a while loop that uses a cached Python expression executed in the current scope.
#define REPY_FN_FOREACH_CACHE(bytecode_identifier, var_name, py_expression)
 Constructs a for loop that iterates through a Python object in the current scope, similar to how a Pythonic for loop works.
#define REPY_FN_FOR_CACHE(bytecode_identifier, py_init_statement, py_eval_expression, py_update_statement)
 Constructs a C style for loop, using cached Python code.
#define REPY_VL   REPY_VariadicLocals
 Shorthand for REPY_VariadicLocals.
#define REPY_VL_SUH   REPY_VariadicLocals_SUH
 Shorthand for REPY_VariadicLocals_SUH.

Typedefs

typedef signed char REPY_s8
 A signed, 8-bit integer compatible with libultra's s8.
typedef unsigned char REPY_u8
 An unsigned, 8-bit integer compatible with libultra's u8.
typedef signed short int REPY_s16
 A signed, 16-bit integer compatible with libultra's s16.
typedef unsigned short int REPY_u16
 An unsigned, 16-bit integer compatible with libultra's u16.
typedef signed long REPY_s32
 A signed, 32-bit integer compatible with libultra's s32.
typedef unsigned long REPY_u32
 An unsigned, 13-bit integer compatible with libultra's u32.
typedef signed long long int REPY_s64
 A signed, 64-bit integer compatible with libultra's s64.
typedef unsigned long long int REPY_u64
 An unsigned, 64-bit integer compatible with libultra's u64.
typedef float REPY_f32
 A 32-bit floating point value compatible with libultra's f32.
typedef double REPY_f64
 A 64-bit floating point value compatible with libultra's f64.
typedef _Bool REPY_bool
 A boolean type compatible with libultra's bool type.
typedef enum REPY_CodeModeEnum REPY_CodeMode
 Used to set the type of code-string being compiled, in line with how Python's built-in compile function operates.
typedef unsigned int REPY_Handle
 Represents a Python object in REPY API functions.
typedef signed int REPY_InterpreterIndex
 Index value for a specific Python interpreter, either the main interpreter or a registered subinterpreter.
typedef void REPY_IteratorHelper
 Helper object used to when iterating through Python objects in loops in C code.
typedef void REPY_IfStmtChain
 Helper object used to cache Python expressions as bytecode, so that they don't need to be re-parsed and compiled every time they're run.
typedef void REPY_IfStmtHelper
 Helper object used to step through a REPY_IfStmtChain while it's being evaluated, generating new links as necessary.
typedef void REPY_DeferredCleanupHelper
 Helper object used to deallocate REPY_IfStmtHelper and REPY_IteratorHelper objects when a REPY_FN scope exits.

Enumerations

enum  REPY_CodeModeEnum { REPY_CODE_EXEC = 0 , REPY_CODE_EVAL = 1 , REPY_CODE_SINGLE = 2 }
 Used to set the type of code-string being compiled, in line with how Python's built-in compile function operates. More...

Functions

void REPY_PreInitAddSysPath (const unsigned char *nrm_file_path)
 Instruct REPY to add a path to Python's module search path during initialization.
REPY_InterpreterIndex REPY_PreInitRegisterSubinterpreter ()
 Registers a new Python subinterpreter to be created on initialization, and return a REPY_InterpreterIndex corresponding to it.
void REPY_Release (REPY_Handle py_handle)
 Releases a REPY_Handle, removing the reference to the Python object and rendering this handle invalid.
REPY_Handle REPY_MakeSUH (REPY_Handle py_handle_no_release)
 Convienience function that marks a REPY_Handle as Single-Use and then returns the value of the provided handle.
REPY_bool REPY_IsValidHandle (REPY_Handle py_handle_no_release)
 Returns whether the a handle value is mapped to a Python object.
REPY_bool REPY_GetSUH (REPY_Handle py_handle_no_release)
 Gets whether or not a REPY_Handle is Single-Use.
void REPY_SetSUH (REPY_Handle py_handle_no_release, REPY_bool value)
 Sets whether or not a REPY_Handle is Single-Use.
REPY_Handle REPY_CopyHandle (REPY_Handle handle_no_release)
 Creates a new handle to the same Python object as another handle.
void REPY_PushInterpreter (REPY_InterpreterIndex interpreter_handle)
 Pushes an interpreter index to the interpreter stack, and switching the active interpreter if necessary.
void REPY_PopInterpreter ()
 Pops an interpreter index from the interpreter stack, switching active interpreters if necessary.
REPY_InterpreterIndex REPY_GetCurrentInterpreter ()
 Gets the interpreter index at the top of the interpreter stack.
REPY_bool REPY_GetInterpreterAutoDisarm (REPY_InterpreterIndex index)
 Gets whether or not this subinterpreter should be 'disarmed' when shutting down.
void REPY_SetInterpreterAutoDisarm (REPY_InterpreterIndex index, REPY_bool value)
 Sets whether or not this subinterpreter should be 'disarmed' when shutting down.
REPY_InterpreterIndex REPY_GetHandleInterpreter (REPY_Handle handle_no_release)
 Gets the index of the interpreter a specific REPY_Handle object is associated with.
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.
REPY_Handle REPY_CreateBool (REPY_bool value)
 Returns a REPY_Handle for a Python bool object, based on a C bool.
REPY_Handle REPY_CreateBool_SUH (REPY_bool value)
 Returns a Single-Use REPY_Handle for a Python bool object, based on a C bool.
REPY_bool REPY_CastBool (REPY_Handle object)
 Casts a Python object to a C bool.
REPY_Handle REPY_CreateU8 (REPY_u8 value)
 Returns a REPY_Handle for a Python int object, based on a C u8.
REPY_Handle REPY_CreateU8_SUH (REPY_u8 value)
 Returns a Single-Use REPY_Handle for a Python int object, based on a C u8.
REPY_u8 REPY_CastU8 (REPY_Handle object)
 Casts a Python object to a C u8.
REPY_Handle REPY_CreateS8 (REPY_s8 value)
 Returns a REPY_Handle for a Python int object, based on a C s8.
REPY_Handle REPY_CreateS8_SUH (REPY_s8 value)
 Returns a Single-Use REPY_Handle for a Python int object, based on a C s8.
REPY_s8 REPY_CastS8 (REPY_Handle object)
 Casts a Python object to a C s8.
REPY_Handle REPY_CreateU16 (REPY_u16 value)
 Returns a REPY_Handle for a Python int object, based on a C u16.
REPY_Handle REPY_CreateU16_SUH (REPY_u16 value)
 Returns a Single-Use REPY_Handle for a Python u16 object, based on a C int.
REPY_u16 REPY_CastU16 (REPY_Handle object)
 Casts a Python object to a C u16.
REPY_Handle REPY_CreateS16 (REPY_s16 value)
 Returns a REPY_Handle for a Python int object, based on a C s16.
REPY_Handle REPY_CreateS16_SUH (REPY_s16 value)
 Returns a Single-Use REPY_Handle for a Python int object, based on a C s16.
REPY_s16 REPY_CastS16 (REPY_Handle object)
 Casts a Python object to a C s16.
REPY_Handle REPY_CreateU32 (REPY_u32 value)
 Returns a REPY_Handle for a Python int object, based on a C u32.
REPY_Handle REPY_CreateU32_SUH (REPY_u32 value)
 Returns a Single-Use REPY_Handle for a Python int object, based on a C u32.
REPY_u32 REPY_CastU32 (REPY_Handle object)
 Casts a Python object to a C u32.
REPY_Handle REPY_CreateS32 (REPY_s32 value)
 Returns a REPY_Handle for a Python int object, based on a C s32.
REPY_Handle REPY_CreateS32_SUH (REPY_s32 value)
 Returns a Single-Use REPY_Handle for a Python int object, based on a C s32.
REPY_s32 REPY_CastS32 (REPY_Handle object)
 Casts a Python object to a C s32.
REPY_Handle REPY_CreateF32 (REPY_f32 value)
 Returns a REPY_Handle for a Python float object, based on a C f32.
REPY_Handle REPY_CreateF32_SUH (REPY_f32 value)
 Returns a Single-Use REPY_Handle for a Python float object, based on a C f32.
REPY_f32 REPY_CastF32 (REPY_Handle object)
 Casts a Python object to a C f32.
REPY_Handle REPY_CreatePtr (void *value)
 Returns a REPY_Handle for a Python int object, based on a C void*.
REPY_Handle REPY_CreatePtr_SUH (void *value)
 Returns a Single-Use REPY_Handle for a Python int object, based on a C void*.
void * REPY_CastPtr (REPY_Handle object)
 Casts a Python object to a C void*.
REPY_Handle REPY_CreateU64 (REPY_u64 value)
 Returns a REPY_Handle for a Python int object, based on a C u64.
REPY_Handle REPY_CreateU64_SUH (REPY_u64 value)
 Returns a Single-Use REPY_Handle for a Python int object, based on a C u64.
REPY_u64 REPY_CastU64 (REPY_Handle object)
 Casts a Python object to a C u64.
REPY_Handle REPY_CreateS64 (REPY_s64 value)
 Returns a REPY_Handle for a Python int object, based on a C s64.
REPY_Handle REPY_CreateS64_SUH (REPY_s64 value)
 Returns a Single-Use REPY_Handle for a Python int object, based on a C s64.
REPY_s64 REPY_CastS64 (REPY_Handle object)
 Casts a Python object to a C s64.
REPY_Handle REPY_CreateF64 (REPY_f64 value)
 Returns a REPY_Handle for a Python int object, based on a C u8.
REPY_Handle REPY_CreateF64_SUH (REPY_f64 value)
 Returns a Single-Use REPY_Handle for a Python int object, based on a C bool.
REPY_f64 REPY_CastF64 (REPY_Handle object)
 Casts a Python object to a C u8.
REPY_Handle REPY_CreateStr (const char *string)
 Returns a REPY_Handle for a Python str object, based on a NULL-terminated C string.
REPY_Handle REPY_CreateStr_SUH (const char *string)
 Returns a Single-Use REPY_Handle for a Python str object, based on a NULL-terminated C string.
REPY_Handle REPY_CreateStrN (const char *string, REPY_u32 len)
 Returns a REPY_Handle for a Python str object, based on char array.
REPY_Handle REPY_CreateStrN_SUH (const char *string, REPY_u32 len)
 Returns a Single-Use REPY_Handle for a Python str object, based on char array.
char * REPY_CastStr (REPY_Handle object)
 Casts a Python object to NULL-terminated C string. Intended to be used with a Python str.
REPY_Handle REPY_CreateByteStr (const char *string)
 Returns a REPY_Handle for a Python bytes object, based on a NULL-terminated C string.
REPY_Handle REPY_CreateByteStr_SUH (const char *string)
 Returns a Single-Use REPY_Handle for a Python bytes object, based on a NULL-terminated C string.
REPY_Handle REPY_CreateByteStrN (const char *string, REPY_u32 len)
 Returns a REPY_Handle for a Python bytes object, based on a char array.
REPY_Handle REPY_CreateByteStrN_SUH (const char *string, REPY_u32 len)
 Returns a Single-Use REPY_Handle for a Python bytes object, based on a char array.
char * REPY_CastByteStr (REPY_Handle object)
 Casts a Python object to a NULL-terminated C string. Intended to be used with a Python bytes.
REPY_Handle REPY_MemcpyToBytes (void *src, REPY_u32 len, REPY_bool reverse)
 Create a Python bytes object from a chunk of mod memory.
REPY_Handle REPY_MemcpyToByteArray (void *src, REPY_u32 len, REPY_bool reverse)
 Create a Python bytearray object from a chunk of mod memory.
REPY_u32 REPY_MemcpyFromBuffer (void *dst, REPY_u32 len, REPY_bool reverse, REPY_Handle buffer)
 Copy the content of a Python object supporting buffer protocol (such as bytes and bytearray) into mod memory.
void * REPY_AllocAndCopyBuffer (REPY_bool reverse, REPY_Handle buffer, REPY_u32 *write_size)
 Copy the content of a Python object supporting buffer protocol into mod memory, automatically allocating the space for it with recomp_alloc.
REPY_u32 REPY_Len (REPY_Handle object)
 Gets the length of an appropriate Python object as a u32.
REPY_Handle REPY_GetAttr (REPY_Handle object, REPY_Handle key, REPY_Handle default_value_nullable)
 Returns a REPY_Handle for a named attribute of a Python object, using a REPY_Handle for the attribute name.
REPY_Handle REPY_GetAttrCStr (REPY_Handle object, char *key, REPY_Handle default_value_nullable)
 Returns a REPY_Handle for a named attribute of a Python object, using a NULL-terminated C string for the name.
void REPY_SetAttr (REPY_Handle object, REPY_Handle key, REPY_Handle value)
 Assigned a named attribute of a Python object, using a REPY_Handle for the attribute name.
void REPY_SetAttrCStr (REPY_Handle object, char *key, REPY_Handle value)
 Assigned a named attribute of a Python object, using a NULL-terminated C string for the name.
REPY_bool REPY_HasAttr (REPY_Handle object, REPY_Handle key)
 Checks if a Python object has an attribute with a specific name, using a REPY_Handle for the attribute name.
REPY_bool REPY_HasAttrCStr (REPY_Handle object, char *key)
 Checks if a Python object has an attribute with a specific name, using a NULL-terminated C string for the name.
void REPY_DelAttr (REPY_Handle object, REPY_Handle key)
 Deletes an attribute from a Python object by name, using a REPY_Handle for the attribute name.
void REPY_DelAttrCStr (REPY_Handle object, char *key)
 Deletes an attribute from a Python object by name, using a NULL-terminated C string for the name.
REPY_Handle REPY_Iter (REPY_Handle object)
 Gets an iterator for a given Python object.
REPY_Handle REPY_Next (REPY_Handle iterator, REPY_Handle default_obj_nullable, REPY_bool process_stop_iteration)
 Gets the next Python object from a Python iterator.
REPY_Handle REPY_CreateTuple (REPY_u32 size,...)
 Create a Python tuple and return a REPY_Handle for it.
REPY_Handle REPY_CreateTuple_SUH (REPY_u32 size,...)
 Create a Python tuple and return a Single-Use REPY_Handle for it.
REPY_Handle REPY_CreatePair (REPY_Handle key, REPY_Handle value)
 Create a Python tuple with exactly 2 entries and return a REPY_Handle for it.
REPY_Handle REPY_CreatePair_SUH (REPY_Handle key, REPY_Handle value)
 Create a Python tuple with exactly 2 entries and return a Single-Use REPY_Handle for it.
REPY_Handle REPY_CreatePairCStr (char *key, REPY_Handle value)
 Create a Python tuple with exactly 2 entries and return a REPY_Handle for it. The first entry is automatically cast to str.
REPY_Handle REPY_CreatePairCStr_SUH (char *key, REPY_Handle value)
 Create a Python tuple with exactly 2 entries and return a Single-Use REPY_Handle for it. The first entry is automatically cast to str.
REPY_Handle REPY_TupleGetIndexS32 (REPY_Handle tuple, int index)
 Returns the Python object at a specific index from a tuple.
REPY_Handle REPY_CreateDict (REPY_u32 size,...)
 Create a Python dict and return a REPY_Handle for it.
REPY_Handle REPY_CreateDict_SUH (REPY_u32 size,...)
 Create a Python dict and return a REPY_Handle for it.
REPY_Handle REPY_DictGet (REPY_Handle dict, REPY_Handle key)
 Get an entry from a Python dict, using a REPY handle for the key.
REPY_Handle REPY_DictGetCStr (REPY_Handle dict, char *key)
 Get an entry from a Python dict, using a NULL-terminated C string for the key.
void REPY_DictSet (REPY_Handle dict, REPY_Handle key, REPY_Handle value)
 Sets/adds a Python object to a Python dict, using a REPY handle for the key.
void REPY_DictSetCStr (REPY_Handle dict, char *key, REPY_Handle value)
 Sets/adds a Python object to a Python dict, using a NULL-terminated C string for the key.
REPY_bool REPY_DictHas (REPY_Handle dict, REPY_Handle key)
 Checks if a Python dict has an entry with a specific key, using a REPY handle for the key.
REPY_bool REPY_DictHasCStr (REPY_Handle dict, char *key)
 Checks if a Python dict has an entry with a specific key, using a NULL-terminated C string for the key.
void REPY_DictDel (REPY_Handle dict, REPY_Handle key)
 Remove an entry from a dict via it's key, using a REPY handle for the key.
void REPY_DictDelCStr (REPY_Handle dict, char *key)
 Remove an entry from a dict via it's key, using a NULL-terminated C string for the key.
REPY_Handle REPY_Compile (REPY_Handle code, REPY_Handle identifier, REPY_Handle mode)
 Compile a Python code string into Python bytecode, using a REPY_Handle for the text.
REPY_Handle REPY_CompileCStr (const char *code, const char *identifier, REPY_CodeMode mode)
 Compile a Python code string into Python bytecode, using a NULL-terminated C string for the code.
REPY_Handle REPY_CompileCStrN (const char *code, REPY_u32 len, const char *identifier, REPY_CodeMode mode)
 Compile a Python code string into Python bytecode, using a C char array for the code.
REPY_bool REPY_Exec (REPY_Handle code, REPY_Handle global_scope_nullable, REPY_Handle local_scope_nullable)
 Execute Python code statements from a REPY_Handle. Optionally provide dict objects to serve as a scope.
REPY_bool REPY_ExecCStr (const char *code, REPY_Handle global_scope_nullable, REPY_Handle local_scope_nullable)
 Execute Python code from a NULL-terminated C string. Optionally provide dict objects to serve as a scope.
REPY_bool REPY_ExecCStrN (const char *code, REPY_u32 len, REPY_Handle global_scope_nullable, REPY_Handle local_scope_nullable)
 Execute Python code from a C char array. Optionally provide dict objects to serve as a scope.
REPY_Handle REPY_Eval (REPY_Handle code, REPY_Handle global_scope_nullable, REPY_Handle local_scope_nullable)
 Evaluate a Python code expression from a REPY_Handle. Optionally provide dict objects to serve as a scope.
REPY_Handle REPY_EvalCStr (const char *code, REPY_Handle global_scope_nullable, REPY_Handle local_scope_nullable)
 Evaluate a Python code expression from a NULL-terminated C string. Optionally provide dict objects to serve as a scope.
REPY_Handle REPY_EvalCStrN (const char *code, REPY_u32 len, REPY_Handle global_scope_nullable, REPY_Handle local_scope_nullable)
 Evaluate a Python code expression from a C char array. Optionally provide dict objects to serve as a scope.
REPY_Handle REPY_VariadicLocals (REPY_Handle dict_nullable_no_release, REPY_u32 size,...)
 Adds the Python object represented by a set of REPY_Handle handles to a dict, using the keys following the scheme _0, _1, _2, etc. These keys serve as valid Python variable names to be used in code strings.
REPY_Handle REPY_VariadicLocals_SUH (REPY_Handle dict_nullable_no_release, REPY_u32 size,...)
 Adds the Python object represented by a set of REPY_handles to a dict, using the keys following the scheme _0, _1, _2, etc. These keys serve as valid Python variable names to be used in code strings. This function also marks the resulting handle as Single-Use.
REPY_bool REPY_Call (REPY_Handle func, REPY_Handle args_nullable, REPY_Handle kwargs_nullable)
 Call a Python function (or another callable object) by handle, and discard the return value.
REPY_Handle REPY_CallReturn (REPY_Handle func, REPY_Handle args_nullable, REPY_Handle kwargs_nullable)
 Call a Python function (or another callable object) by handle, and get the return value as a REPY_Handle.
REPY_bool REPY_CallAttr (REPY_Handle object, REPY_Handle name, REPY_Handle args_nullable, REPY_Handle kwargs_nullable)
 Call a Python object member (such as a module function, object method, or another callable) by parent object and attribute name, and discard the return value. The attribute name should be a Python str.
REPY_bool REPY_CallAttrCStr (REPY_Handle object, char *name, REPY_Handle args_nullable, REPY_Handle kwargs_nullable)
 Call a Python object member (such as a module function, object method, or another callable) by parent object and attribute name, and discard the return value. The attribute name should be a NULL-terminated C string.
REPY_Handle REPY_CallAttrReturn (REPY_Handle object, REPY_Handle name, REPY_Handle args_nullable, REPY_Handle kwargs_nullable)
 Call a Python object member (such as a module function, object method, or another callable) by parent object and attribute name, and discard the return value. The attribute name should be a NULL-terminated C string.
REPY_Handle REPY_CallAttrCStrReturn (REPY_Handle object, char *name, REPY_Handle args_nullable, REPY_Handle kwargs_nullable)
 Call a Python object member (such as a module function, object method, or another callable) by parent object and attribute name, and discard the return value. The attribute name should be a NULL-terminated C string.
REPY_bool REPY_IsErrorSet ()
 Checks if a Python exception was raised and caught by the REPY API.
REPY_Handle REPY_GetErrorType ()
 Get the type of a captured Python exception for the current interpreter and thread.
REPY_Handle REPY_GetErrorTrace ()
 Get the trace object for the Python exception for the current interpreter and thread.
REPY_Handle REPY_GetErrorValue ()
 Get the captured Python exception object for the current interpreter and thread.
void REPY_ClearError ()
 Releases the captured exception for the current interpreter and thread.
REPY_Handle REPY_GetZipFileFromPath (const char *filepath)
 Opens a read-only instance of zipfile.ZipFile as indicated by filepath.
REPY_Handle REPY_GetNrmZipFile ()
 Opens a read-only instance of zipfile.ZipFile for this .nrm file. Provides an easy way to access additional files inside the mod.
char * REPY_InlineCodeSourceStrHelper (char *category, char *filename, char *function_name, REPY_u32 line_number, char *identifier)
 Constructs the filename strings used by most macros that enable inlining Python code into C files.
REPY_IteratorHelperREPY_IteratorHelper_Create (REPY_Handle py_object, REPY_Handle py_scope_nullable, const char *var_name, REPY_bool auto_destroy)
 Create a REPY_IteratorHelper object on the heap.
void REPY_IteratorHelper_Destroy (REPY_IteratorHelper *helper)
 Destructs a REPY_IteratorHelper object from the heap.
REPY_bool REPY_IteratorHelper_Update (REPY_IteratorHelper *helper)
 Makes the REPY_IteratorHelper move on to the next object in the iteration.
REPY_u32 REPY_IteratorHelper_GetIndex (REPY_IteratorHelper *helper)
 Gets the current index of a REPY_IteratorHelper object.
REPY_Handle REPY_IteratorHelper_BorrowCurrent (REPY_IteratorHelper *helper)
 Gets the REPY_Handle for a REPY_IteratorHelper object's current Python object.
REPY_IfStmtChainREPY_IfStmtChain_Create (char *expr_string, char *filename, char *function_name, REPY_u32 line_number, char *identifier)
 Creates a new link in a REPY_IfStmtChain if statement chain.
void REPY_IfStmtChain_Destroy (REPY_IfStmtChain *chain)
 Destructs a REPY_IfStmtChain object from the heap, recursively destructs and all additional links down the chain.
REPY_IfStmtChainREPY_IfStmtChain_BorrowNext (REPY_IfStmtChain *chain)
 Returns a pointer to the next IfStmtChain in the series.
void REPY_IfStmtChain_StealNext (REPY_IfStmtChain *chain, REPY_IfStmtChain *next)
 Sets the next REPY_IfStmtChain in a series.
REPY_Handle REPY_IfStmtChain_BorrowEvalBytecode (REPY_IfStmtChain *chain)
 Retrieves the evaluated bytecode expression for this REPY_IfStmtChain as a REPY_Handle.
void REPY_IfStmtChain_StealEvalBytecode (REPY_IfStmtChain *chain, REPY_Handle eval_bytecode)
 Sets.
REPY_IfStmtHelperREPY_IfStmtHelper_Create (REPY_IfStmtChain **chain_root)
 Initializes a REPY_IfStmtHelper for controlling managing a Pythonic if/else block.
void REPY_IfStmtHelper_Destroy (REPY_IfStmtHelper *helper)
 Destroys and deallocates a REPY_IfStmtHelper.
REPY_bool REPY_IfStmtHelper_Step (REPY_IfStmtHelper *helper, REPY_Handle global_scope, REPY_Handle local_scope, char *expr_string, char *filename, char *function_name, REPY_u32 line_number, char *identifier)
 Steps through and evaluate the next link in the REPY_IfStmtChain chain provided to the REPY_IfStmtHelper, or creates a new link if one doesn't exist.
REPY_DeferredCleanupHelperREPY_DeferredCleanupHelper_Create ()
 Create a new REPY_DeferredCleanupHelper object.
REPY_Handle REPY_DeferredCleanupHelper_AddHandle (REPY_DeferredCleanupHelper *cleanup, REPY_Handle handle_no_release)
 Adds a REPY_Handle to be release by a REPY_DeferredCleanupHelper instance.
void * REPY_DeferredCleanupHelper_AddRecompFree (REPY_DeferredCleanupHelper *cleanup, void *pointer)
 Adds a region of memory (specified by a void*) to be freed with recomp_free by a REPY_DeferredCleanupHelper instance.
REPY_IteratorHelperREPY_DeferredCleanupHelper_AddIteratorHelper (REPY_DeferredCleanupHelper *cleanup, REPY_IteratorHelper *iterator_helper)
 Adds a REPY_IteratorHelper to be destroyed by a REPY_DeferredCleanupHelper instance.
REPY_IfStmtHelperREPY_DeferredCleanupHelper_AddIfStmtHelper (REPY_DeferredCleanupHelper *cleanup, REPY_IfStmtHelper *if_stmt_helper)
 Adds a REPY_IfStmtHelper to be destroyed by a REPY_DeferredCleanupHelper instance.
void REPY_DeferredCleanupHelper_CleanNow (REPY_DeferredCleanupHelper *cleanup)
 Clean up all of the resources registered to a REPY_DeferredCleanupHelper without destroying the instance itself.
void REPY_DeferredCleanupHelper_Destroy (REPY_DeferredCleanupHelper *cleanup)
 Destroy a REPY_DeferredCleanupHelper instance and clean up all of the resources registered to it.

Detailed Description

The main header for Recomp External Python. Header version 2. .

Version
2.0.0

Macro Definition Documentation

◆ REPY_IMPORT

#define REPY_IMPORT ( func)
Value:
func

◆ REPY_MOD_ID_STR

#define REPY_MOD_ID_STR   "RecompExternalPython_API"

The mod id string for REPY.

The recomp_py.h imports all the functions and events needed for REPY, so you probably won't need to use this directly.