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

Functions that operate on Python dict objects. More...

Functions

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.

Detailed Description

Functions that operate on Python dict objects.

Function Documentation

◆ REPY_CreateDict()

REPY_Handle REPY_CreateDict ( REPY_u32 size,
... )

Create a Python dict and return a REPY_Handle for it.

Because the REPY_Handle created by this function requires manual release, it's not recommended to use this function nested inside REPY_Call (or any of it's sister functions) to pass keyword arguments. Use REPY_CreateDict_SUH instead.

Parameters
sizeThe number of entries in the dict. Use 0 for an empty dict.
...REPY_Handle arguments for each entry in the dict. Each argument should be a two-entry tuple representing a key/value pair (using REPY_CreatePair or REPY_CreatePair_SUH makes this easy). Leave out if size is 0.
Returns
A REPY_Handle for the new dict. Will be REPY_NO_HANDLE if an error occured.

◆ REPY_CreateDict_SUH()

REPY_Handle REPY_CreateDict_SUH ( REPY_u32 size,
... )

Create a Python dict and return a REPY_Handle for it.

This is the recommended function for constructing a keyword arguments tuple nested inside a call to REPY_Call (or any of it's sister functions).

At this time, this function is just shorthand for REPY_MakeSUH(REPY_CreateDict(size, ...)), and thus will perform similarly. However, internal performance improvements may make this function more performant in the future.

Parameters
sizeThe number of entries in the dict. Use 0 for an empty dict.
...REPY_Handle arguments for each entry in the dict. Each argument should be a two-entry tuple representing a key/value pair (using REPY_CreatePair or REPY_CreatePair_SUH makes this easy). Leave out if size is 0.
Returns
A REPY_Handle for the new dict. Will be REPY_NO_HANDLE if an error occured.

◆ REPY_DictDel()

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.

Note that any hashable Python type can be used as a dict key, not just str objects.

Parameters
dictThe dict to remove an entry from.
keyThe key for the entry. Should be a hashable Python type.

◆ REPY_DictDelCStr()

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.

The key variable will treated as a str object, as that is the most common use-case, as well as the use-case for code execution scopes.

Parameters
dictThe dict to remove an entry from.
keyThe key for the entry. Should be a NULL-terminated C string.

◆ REPY_DictGet()

REPY_Handle REPY_DictGet ( REPY_Handle dict,
REPY_Handle key )

Get an entry from a Python dict, using a REPY handle for the key.

Note that any hashable Python type can be used as a dict key, not just str objects.

Parameters
dictThe dict to get an entry from.
keyThe key for the entry. Should be a hashable Python type.
Returns
The retrieved object. Will be REPY_NO_HANDLE if an error occured.

◆ REPY_DictGetCStr()

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.

The key variable will treated as a str object, as that is the most common use-case, as well as the use-case for code execution scopes.

Parameters
dictThe dict to get an entry from.
keyThe key for the entry. Should be a NULL-terminated C string.
Returns
The retrieved object. Will be REPY_NO_HANDLE if an error occured.

◆ REPY_DictHas()

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.

Note that any hashable Python type can be used as a dict key, not just str objects.

Parameters
dictThe dict to check for a key in.
keyThe key for the entry. Should be a hashable Python type.
Returns
true if the entry exists, false otherwise.

◆ REPY_DictHasCStr()

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.

The key variable will treated as a str object, as that is the most common use-case, as well as the use-case for code execution scopes.

Parameters
dictThe dict to check for a key in.
keyThe key for the entry. Should be a NULL-terminated C string.
Returns
true if the entry exists, false otherwise.

◆ REPY_DictSet()

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.

Note that any hashable Python type can be used as a dict key, not just str objects.

Parameters
dictThe dict to insert into.
keyThe key for the entry. Should be a hashable Python type.
valueThe object to add.

◆ REPY_DictSetCStr()

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.

The key variable will treated as a str object, as that is the most common use-case, as well as the use-case for code execution scopes.

Parameters
dictThe dict to insert into.
keyThe key for the entry. Should be a NULL-terminated C string.
valueThe object to add.