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

Functins used to directly transfer data between mod memory and the Python interpreter, using appropriate Python types. More...

Functions

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.

Detailed Description

Functins used to directly transfer data between mod memory and the Python interpreter, using appropriate Python types.

Function Documentation

◆ REPY_AllocAndCopyBuffer()

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.

The binary data from the buffer will be copied exactly as is, NULL bytes and all. No additional NULL bytes will be added to the end of the data.

Failure to free the void* returned by this function with recomp_free will result in a memory leak.

Behavior with Python types other than bytearray is undefined, and may change between versions.

Parameters
reverseSet to false to copy normally, or true to reverse the byte order of the data being copied.
bufferThe Python buffer object to copy from.
write_sizeA pointer to a u32, where the number of bytes copied can be written to. Can be NULL.
Returns
A void* to the data copied into mod memory.

◆ REPY_MemcpyFromBuffer()

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.

The binary data from the buffer will be copied exactly as is, NULL bytes and all. No additional NULL bytes will be added to the end of the data.

If the Python buffer object is smaller than len, then the remainder of destination will be untouched. If the bytearray object is larger than len, then copying will terminate when len is reached. Use the return value to get how many bytes were actually copied.

Parameters
dstThe beginning of the memory region to write to.
lenThe size of the destination region to copy, in bytes.
reverseSet to false to copy normally, or true to reverse the byte order of the data being copied.
bufferThe Python buffer object to copy from.
Returns
The number of bytes actually copied.

◆ REPY_MemcpyToByteArray()

REPY_Handle REPY_MemcpyToByteArray ( void * src,
REPY_u32 len,
REPY_bool reverse )

Create a Python bytearray object from a chunk of mod memory.

This function copies the entire src region exactly as is, NULL-terminators and all.

Parameters
srcThe beginning of the memory region to copy.
lenThe size of the region to copy, in bytes.
reverseSet to false to copy normally, or true to reverse the byte order of the memory being copied.
Returns
A REPY_Handle to the bytearray obect created.

◆ REPY_MemcpyToBytes()

REPY_Handle REPY_MemcpyToBytes ( void * src,
REPY_u32 len,
REPY_bool reverse )

Create a Python bytes object from a chunk of mod memory.

This function copies the entire src region exactly as is, NULL-terminators and all.

Parameters
srcThe beginning of the memory region to copy.
lenThe size of the region to copy, in bytes.
reverseSet to false to copy normally, or true to reverse the byte order of the memory being copied.
Returns
A REPY_Handle to the bytes obect created.