RecompExternalPython for N64Recompiled 2.0.0
Loading...
Searching...
No Matches
REPY_FN_SETUP/CLEANUP - Initialization and cleanup of Python scopes.

Macros

#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.

Detailed Description

Macro Definition Documentation

◆ REPY_FN_CLEANUP

#define REPY_FN_CLEANUP
Value:
REPY_Release(REPY_FN_LOCAL_SCOPE); \
REPY_PopInterpreter() \
void REPY_DeferredCleanupHelper_Destroy(REPY_DeferredCleanupHelper *cleanup)
Destroy a REPY_DeferredCleanupHelper instance and clean up all of the resources registered to it.
#define REPY_FN_LOCAL_SCOPE
The variable name for inline execution local scopes.
Definition repy_api.h:756
#define REPY_FN_AUTO_CLEANUP
The variable name for helper auto-cleanup object.
Definition repy_api.h:762

Clean up a inline execution scope by releasing the local scope and popping the last interpreter index.

The REPY_DeferredCleanupHelper will perform all queued cleanup tasks at this time.

The global scope is only released if the global and local scopes are the same.

◆ REPY_FN_DEFER_RECOMP_FREE

#define REPY_FN_DEFER_RECOMP_FREE ( pointer)
Value:
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_DeferredCleanup...

Registers a void* to be deallocated by the REPY_DeferredCleanupHelper for this REPY_FN scope.

This pointer will now be deallocated when the scope is cleaned up. Do not deallocate manually before that point.

Deallocation is handled by calling recomp_free. If this is inapproproate for whatever you want to deallocate, do not use this mechanism.

Parameters
pointera void* to be released on scope cleanup.

◆ REPY_FN_DEFER_RELEASE

#define REPY_FN_DEFER_RELEASE ( handle)
Value:
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.

Registers a REPY_Handle to be released by the REPY_DeferredCleanupHelper for this REPY_FN scope.

This handle will now be released when the scope is cleaned up. Do not make the handle Single-Use or otherwise release the handle manually before that point.

Parameters
handlea REPY_Handle to be released on scope cleanup.

◆ REPY_FN_RETURN

#define REPY_FN_RETURN ( retType,
retVal )
Value:
retType __repy_retVal = retVal; \
REPY_DeferredCleanupHelper_Destroy(REPY_FN_AUTO_CLEANUP, 1); \
REPY_Release(REPY_FN_LOCAL_SCOPE); \
REPY_PopInterpreter(); \
return retVal

Clean up a inline scope by releasing the local scope and popping the last interpreter index, then returns.

The REPY_DeferredCleanupHelper will perform all queued cleanup tasks at this time.

Supports returning a value, which is captured before cleanup starts.

The global scope is only released if the global and local scopes are the same.

◆ REPY_FN_SETUP

#define REPY_FN_SETUP   REPY_FN_SETUP_INTERP(REPY_MAIN_INTERPRETER)

Create an inline execution scope for your function without any globals.

The global and local scope dict objects will the same. Python's built-ins will be added whenever Python code is first executed.

REPY_FN scopes also create a REPY_DeferredCleanupHandler instance, which is used to automatically destroy any helper objects created by other REPY_FN macros. The cleanup handler is also capable of releasing REPY_Handle instances and freeing memory using recomp_free for you as well, but those cases must be declared manually using REPY_FN_DEFER_RELEASE and REPY_FN_DEFER_RECOMP_FREE.

This execution scope will use the main Python interpreter.

◆ REPY_FN_SETUP_INTERP

#define REPY_FN_SETUP_INTERP ( interp_index)
Value:
REPY_PushInterpreter(interp_index); \
REPY_DeferredCleanupHelper * REPY_DeferredCleanupHelper_Create()
Create a new REPY_DeferredCleanupHelper object.
REPY_Handle REPY_CreateDict(REPY_u32 size,...)
Create a Python dict and return a REPY_Handle for it.
#define REPY_FN_GLOBAL_SCOPE
The variable name for inline execution global scopes.
Definition repy_api.h:750
unsigned int REPY_Handle
Represents a Python object in REPY API functions.
Definition repy_api.h:201
void REPY_PushInterpreter(REPY_InterpreterIndex interpreter_handle)
Pushes an interpreter index to the interpreter stack, and switching the active interpreter if necessa...
void REPY_DeferredCleanupHelper
Helper object used to deallocate REPY_IfStmtHelper and REPY_IteratorHelper objects when a REPY_FN sco...
Definition repy_api.h:303

Create an inline execution scope for your function without any globals.

The global and local scope dict objects will the same. Python's built-ins will be added whenever Python code is first executed.

REPY_FN scopes also create a REPY_DeferredCleanupHandler instance, which is used to automatically destroy any helper objects created by other REPY_FN macros. The cleanup handler is also capable of releasing REPY_Handle instances and freeing memory using recomp_free for you as well, but those cases must be declared manually using REPY_FN_DEFER_RELEASE and REPY_FN_DEFER_RECOMP_FREE.

The Python interpreter to use is defined by the interp_index argument.

Parameters
interp_indexa valid interpreter index. Should be of the type REPY_InterpreterIndex.

◆ REPY_FN_SETUP_INTERP_WITH_GLOBALS

#define REPY_FN_SETUP_INTERP_WITH_GLOBALS ( interp_index,
globals )
Value:

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.

If the global scope dict doesn't have Python's builtins predefined, they will be added to the dict whenever Python code is first executed.

REPY_FN scopes also create a REPY_DeferredCleanupHandler instance, which is used to automatically destroy any helper objects created by other REPY_FN macros. The cleanup handler is also capable of releasing REPY_Handle instances and freeing memory using recomp_free for you as well, but those cases must be declared manually using REPY_FN_DEFER_RELEASE and REPY_FN_DEFER_RECOMP_FREE.

The Python interpreter to use is defined by the interp_index argument.

Parameters
interp_indexa valid interpreter index. Should be of the type REPY_InterpreterIndex.
globalsThe Python dict to use as a global scope.

◆ REPY_FN_SETUP_WITH_GLOBALS

#define REPY_FN_SETUP_WITH_GLOBALS ( globals)
Value:
#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 sc...
Definition repy_api.h:804
#define REPY_MAIN_INTERPRETER
Represents the index of the main Python interpreter. Goes with REPY_InterpreterIndex.
Definition repy_api.h:233

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.

If the global scope dict doesn't have Python's builtins predefined, they will be added to the dict whenever Python code is first executed.

REPY_FN scopes also create a REPY_DeferredCleanupHandler instance, which is used to automatically destroy any helper objects created by other REPY_FN macros. The cleanup handler is also capable of releasing REPY_Handle instances and freeing memory using recomp_free for you as well, but those cases must be declared manually using REPY_FN_DEFER_RELEASE and REPY_FN_DEFER_RECOMP_FREE. This execution scope will use the main Python interpreter.

Parameters
globalsThe Python dict to use as a global scope.