Blender V4.5
py_capi_utils.hh File Reference
#include <Python.h>
#include <string>
#include "BLI_compiler_attrs.h"
#include "BLI_span.hh"
#include "BLI_sys_types.h"

Go to the source code of this file.

Classes

struct  PyC_UnicodeAsBytesAndSize_Data
struct  PyC_FlagSet
struct  PyC_StringEnumItems
struct  PyC_StringEnum

Functions

void PyC_ObSpit (const char *name, PyObject *var)
void PyC_ObSpitStr (char *result, size_t result_maxncpy, PyObject *var)
void PyC_LineSpit ()
void PyC_StackSpit ()
PyObject * PyC_ExceptionBuffer () ATTR_WARN_UNUSED_RESULT ATTR_RETURNS_NONNULL
PyObject * PyC_ExceptionBuffer_Simple () ATTR_WARN_UNUSED_RESULT ATTR_RETURNS_NONNULL
PyObject * PyC_Object_GetAttrStringArgs (PyObject *o, Py_ssize_t n,...)
PyObject * PyC_FrozenSetFromStrings (const char **strings)
PyObject * PyC_Err_Format_Prefix (PyObject *exception_type_prefix, const char *formatformat,...)
PyObject * PyC_Err_SetString_Prefix (PyObject *exception_type_prefix, const char *str)
void PyC_Err_PrintWithFunc (PyObject *py_func)
void PyC_FileAndNum (const char **r_filename, int *r_lineno)
void PyC_FileAndNum_Safe (const char **r_filename, int *r_lineno)
int PyC_AsArray_FAST (void *array, size_t array_item_size, PyObject *value_fast, Py_ssize_t length, const PyTypeObject *type, const char *error_prefix)
int PyC_AsArray (void *array, size_t array_item_size, PyObject *value, Py_ssize_t length, const PyTypeObject *type, const char *error_prefix)
int PyC_AsArray_Multi_FAST (void *array, size_t array_item_size, PyObject *value_fast, const int *dims, int dims_len, const PyTypeObject *type, const char *error_prefix)
int PyC_AsArray_Multi (void *array, size_t array_item_size, PyObject *value, const int *dims, int dims_len, const PyTypeObject *type, const char *error_prefix)
PyObject * PyC_Tuple_PackArray_F32 (const float *array, uint len)
PyObject * PyC_Tuple_PackArray_F64 (const double *array, uint len)
PyObject * PyC_Tuple_PackArray_I32 (const int *array, uint len)
PyObject * PyC_Tuple_PackArray_I32FromBool (const int *array, uint len)
PyObject * PyC_Tuple_PackArray_Bool (const bool *array, uint len)
PyObject * PyC_Tuple_PackArray_String (const char **array, uint len)
PyObject * PyC_Tuple_PackArray_Multi_F32 (const float *array, const int dims[], int dims_len)
PyObject * PyC_Tuple_PackArray_Multi_F64 (const double *array, const int dims[], int dims_len)
PyObject * PyC_Tuple_PackArray_Multi_I32 (const int *array, const int dims[], int dims_len)
PyObject * PyC_Tuple_PackArray_Multi_Bool (const bool *array, const int dims[], int dims_len)
void PyC_Tuple_Fill (PyObject *tuple, PyObject *value)
void PyC_List_Fill (PyObject *list, PyObject *value)
PyObject * PyC_UnicodeFromBytes (const char *str)
PyObject * PyC_UnicodeFromBytesAndSize (const char *str, Py_ssize_t size)
const char * PyC_UnicodeAsBytes (PyObject *py_str, PyObject **r_coerce)
const char * PyC_UnicodeAsBytesAndSize (PyObject *py_str, Py_ssize_t *r_size, PyObject **r_coerce)
int PyC_ParseUnicodeAsBytesAndSize (PyObject *o, void *p)
int PyC_ParseUnicodeAsBytesAndSize_OrNone (PyObject *o, void *p)
PyObject * PyC_DefaultNameSpace (const char *filename) ATTR_NONNULL(1) ATTR_WARN_UNUSED_RESULT
void PyC_RunQuicky (const char *filepath, int n,...) ATTR_NONNULL(1)
bool PyC_NameSpace_ImportArray (PyObject *py_dict, const char *imports[])
PyObject * PyC_MainModule_Backup () ATTR_WARN_UNUSED_RESULT
void PyC_MainModule_Restore (PyObject *main_mod)
bool PyC_IsInterpreterActive ()
void * PyC_RNA_AsPointer (PyObject *value, const char *type_name)
PyObject * PyC_FlagSet_AsString (const PyC_FlagSet *item)
int PyC_FlagSet_ValueFromID_int (const PyC_FlagSet *item, const char *identifier, int *r_value)
int PyC_FlagSet_ValueFromID (const PyC_FlagSet *item, const char *identifier, int *r_value, const char *error_prefix)
int PyC_FlagSet_ToBitfield (const PyC_FlagSet *items, PyObject *value, int *r_value, const char *error_prefix)
PyObject * PyC_FlagSet_FromBitfield (PyC_FlagSet *items, int flag)
bool PyC_RunString_AsNumber (const char **imports, const char *expr, const char *filename, double *r_value) ATTR_NONNULL(2
bool PyC_RunString_AsIntPtr (const char **imports, const char *expr, const char *filename, intptr_t *r_value) ATTR_NONNULL(2
bool PyC_RunString_AsStringAndSize (const char **imports, const char *expr, const char *filename, char **r_value, size_t *r_value_size) ATTR_NONNULL(2
bool PyC_RunString_AsString (const char **imports, const char *expr, const char *filename, char **r_value) ATTR_NONNULL(2
bool PyC_RunString_AsStringAndSizeOrNone (const char **imports, const char *expr, const char *filename, char **r_value, size_t *r_value_size) ATTR_NONNULL(2
bool PyC_RunString_AsStringOrNone (const char **imports, const char *expr, const char *filename, char **r_value) ATTR_NONNULL(2
void PyC_StdFilesFlush ()
int PyC_ParseBool (PyObject *o, void *p)
int PyC_ParseStringEnum (PyObject *o, void *p)
const char * PyC_StringEnum_FindIDFromValue (const struct PyC_StringEnumItems *items, int value)
int PyC_CheckArgs_DeepCopy (PyObject *args)
int PyC_Long_AsBool (PyObject *value)
int8_t PyC_Long_AsI8 (PyObject *value)
int16_t PyC_Long_AsI16 (PyObject *value)
uint8_t PyC_Long_AsU8 (PyObject *value)
uint16_t PyC_Long_AsU16 (PyObject *value)
uint32_t PyC_Long_AsU32 (PyObject *value)
uint64_t PyC_Long_AsU64 (PyObject *value)
 Py_LOCAL_INLINE (int32_t) PyC_Long_AsI32(PyObject *value)
 Py_LOCAL_INLINE (int64_t) PyC_Long_AsI64(PyObject *value)
char PyC_StructFmt_type_from_str (const char *typestr)
bool PyC_StructFmt_type_is_float_any (char formatformat)
bool PyC_StructFmt_type_is_int_any (char formatformat)
bool PyC_StructFmt_type_is_byte (char formatformat)
bool PyC_StructFmt_type_is_bool (char formatformat)
PyObject * PyC_UnicodeFromStdStr (const std::string &str)
PyObject * PyC_Tuple_Pack_F32 (const blender::Span< float > values)
PyObject * PyC_Tuple_Pack_F64 (const blender::Span< double > values)
PyObject * PyC_Tuple_Pack_I32 (const blender::Span< int > values)
PyObject * PyC_Tuple_Pack_I32FromBool (const blender::Span< int > values)
PyObject * PyC_Tuple_Pack_Bool (const blender::Span< bool > values)

Variables

bool ATTR_WARN_UNUSED_RESULT

Function Documentation

◆ Py_LOCAL_INLINE() [1/2]

Py_LOCAL_INLINE ( int32_t )

◆ Py_LOCAL_INLINE() [2/2]

Py_LOCAL_INLINE ( int64_t )

Definition at line 354 of file py_capi_utils.hh.

References Py_LOCAL_INLINE(), and PyC_StringEnumItems::value.

◆ PyC_AsArray()

int PyC_AsArray ( void * array,
size_t array_item_size,
PyObject * value,
Py_ssize_t length,
const PyTypeObject * type,
const char * error_prefix )

◆ PyC_AsArray_FAST()

int PyC_AsArray_FAST ( void * array,
size_t array_item_size,
PyObject * value_fast,
Py_ssize_t length,
const PyTypeObject * type,
const char * error_prefix )

◆ PyC_AsArray_Multi()

int PyC_AsArray_Multi ( void * array,
size_t array_item_size,
PyObject * value,
const int * dims,
int dims_len,
const PyTypeObject * type,
const char * error_prefix )

◆ PyC_AsArray_Multi_FAST()

int PyC_AsArray_Multi_FAST ( void * array,
size_t array_item_size,
PyObject * value_fast,
const int * dims,
int dims_len,
const PyTypeObject * type,
const char * error_prefix )

Definition at line 273 of file py_capi_utils.cc.

References PyC_AsArray_Multi_FAST(), and PyC_AsArray_Multi_FAST_impl().

Referenced by PyC_AsArray_Multi_FAST().

◆ PyC_CheckArgs_DeepCopy()

int PyC_CheckArgs_DeepCopy ( PyObject * args)

Silly function, we don't use arg. just check its compatible with __deepcopy__.

Definition at line 555 of file py_capi_utils.cc.

References PyC_CheckArgs_DeepCopy().

Referenced by Color_deepcopy(), Euler_deepcopy(), Matrix_deepcopy(), py_imbuf_deepcopy(), PyC_CheckArgs_DeepCopy(), PyC_StringEnum_FindIDFromValue(), Quaternion_deepcopy(), and Vector_deepcopy().

◆ PyC_DefaultNameSpace()

PyObject * PyC_DefaultNameSpace ( const char * filename)

Description: This function creates a new Python dictionary object. NOTE: dict is owned by sys.modules["__main__"] module, reference is borrowed NOTE: important we use the dict from main, this is what python expects for 'pickle' to work as well as strings like this...

foo = 10 print(import("__main__").foo)

NOTE: this overwrites main which gives problems with nested calls. be sure to run PyC_MainModule_Backup & PyC_MainModule_Restore if there is any chance that python is in the call stack.

Definition at line 1113 of file py_capi_utils.cc.

References PyC_DefaultNameSpace(), and PyC_UnicodeFromBytes().

Referenced by bpy_rna_uilayout_introspect(), bpy_run_string_impl(), PyC_DefaultNameSpace(), pyc_run_string_as_py_object(), PyC_RunQuicky(), and python_script_exec().

◆ PyC_Err_Format_Prefix()

PyObject * PyC_Err_Format_Prefix ( PyObject * exception_type_prefix,
const char * format,
... )

Similar to #PyErr_Format(),

Implementation - we can't actually prepend the existing exception, because it could have any arguments given to it, so instead we get its __str__ output and raise our own exception including it.

Definition at line 781 of file py_capi_utils.cc.

References PyC_Err_Format_Prefix().

Referenced by bpy_class_call(), PyC_Err_Format_Prefix(), PyC_Err_SetString_Prefix(), and pyrna_py_to_prop().

◆ PyC_Err_PrintWithFunc()

◆ PyC_Err_SetString_Prefix()

PyObject * PyC_Err_SetString_Prefix ( PyObject * exception_type_prefix,
const char * str )

◆ PyC_ExceptionBuffer()

PyObject * PyC_ExceptionBuffer ( )

Return a string containing the full stack trace.

  • Only call when PyErr_Occurred() != 0 .
  • The exception is left in place without being manipulated, although they will be normalized in order to display them (PyErr_Print also does this).
  • SystemExit exceptions will exit (so sys.exit(..) works, matching PyErr_Print behavior).
  • The always returns a Python string (unless exiting where the function doesn't return).

Definition at line 897 of file py_capi_utils.cc.

References BLI_assert, pyc_exception_buffer_handle_system_exit(), PyC_ExceptionBuffer(), result, and UNLIKELY.

Referenced by BPy_errors_to_report_ex(), pointer_type_from_py(), PyC_ExceptionBuffer(), pyrna_py_to_prop(), and run_string_handle_error().

◆ PyC_ExceptionBuffer_Simple()

PyObject * PyC_ExceptionBuffer_Simple ( )

A version of PyC_ExceptionBuffer that returns the last exception only.

Useful for error messages from evaluating numeric expressions for example where a full multi-line stack-trace isn't needed and doesn't format well in the status-bar.

Definition at line 957 of file py_capi_utils.cc.

References BLI_assert, pyc_exception_buffer_handle_system_exit(), PyC_ExceptionBuffer_Simple(), result, and UNLIKELY.

Referenced by BPy_errors_to_report_ex(), PyC_ExceptionBuffer_Simple(), and run_string_handle_error().

◆ PyC_FileAndNum()

void PyC_FileAndNum ( const char ** r_filename,
int * r_lineno )

◆ PyC_FileAndNum_Safe()

void PyC_FileAndNum_Safe ( const char ** r_filename,
int * r_lineno )

Definition at line 709 of file py_capi_utils.cc.

References PyC_FileAndNum(), PyC_FileAndNum_Safe(), and PyC_IsInterpreterActive().

Referenced by PyC_FileAndNum_Safe().

◆ PyC_FlagSet_AsString()

PyObject * PyC_FlagSet_AsString ( const PyC_FlagSet * item)

◆ PyC_FlagSet_FromBitfield()

PyObject * PyC_FlagSet_FromBitfield ( PyC_FlagSet * items,
int flag )

◆ PyC_FlagSet_ToBitfield()

int PyC_FlagSet_ToBitfield ( const PyC_FlagSet * items,
PyObject * value,
int * r_value,
const char * error_prefix )

◆ PyC_FlagSet_ValueFromID()

◆ PyC_FlagSet_ValueFromID_int()

int PyC_FlagSet_ValueFromID_int ( const PyC_FlagSet * item,
const char * identifier,
int * r_value )

◆ PyC_FrozenSetFromStrings()

PyObject * PyC_FrozenSetFromStrings ( const char ** strings)

Definition at line 759 of file py_capi_utils.cc.

References PyC_FrozenSetFromStrings(), ret, and str.

Referenced by BPyInit__bpy_path(), and PyC_FrozenSetFromStrings().

◆ PyC_IsInterpreterActive()

◆ PyC_LineSpit()

void PyC_LineSpit ( )

Definition at line 617 of file py_capi_utils.cc.

References PyC_FileAndNum(), PyC_IsInterpreterActive(), and PyC_LineSpit().

Referenced by _RNA_warning(), and PyC_LineSpit().

◆ PyC_List_Fill()

void PyC_List_Fill ( PyObject * list,
PyObject * value )

Definition at line 487 of file py_capi_utils.cc.

References i, and PyC_List_Fill().

Referenced by PyC_List_Fill().

◆ PyC_Long_AsBool()

int PyC_Long_AsBool ( PyObject * value)

Comparison with #PyObject_IsTrue

Even though Python provides a way to retrieve the boolean value for an object, in many cases it's far too relaxed, with the following examples coercing values.

data.value = "Text" # True.
data.value = "" # False.
data.value = {1, 2} # True
data.value = {} # False.
data.value = None # False.

In practice this is often a mistake by the script author that doesn't behave as they expect. So it's better to be more strict for attribute assignment and function arguments, only accepting True/False 0/1.

If coercing a value is desired, it can be done explicitly: data.value = bool(value)

See also
PyC_ParseBool for use with #PyArg_ParseTuple and related functions.
Note
Don't use bool return type, so -1 can be used as an error value.

Definition at line 1770 of file py_capi_utils.cc.

References PyC_Long_AsBool(), PyLong_AsInt, and UNLIKELY.

Referenced by bpy_bm_elem_hflag_set(), bpy_bm_elem_hide_set(), bpy_bm_elem_select_set(), bpy_bmesh_select_flush(), BPy_BMLayerItem_SetItem(), bpy_bmloopuv_pin_uv_set(), bpy_bmloopuv_select_edge_set(), bpy_bmloopuv_select_set(), bpy_bmvertskin_flag_set(), BPy_IDArray_SetItem(), bpy_prop_boolean_get_fn(), bpy_slot_from_py(), foreach_getset(), idp_from_PyBool(), idp_from_PySequence_Fast(), idprop_ui_data_update_bool_default(), PyC_Long_AsBool(), PyC_StringEnum_FindIDFromValue(), pyrna_array_contains_py(), and pyrna_py_to_prop_array_index().

◆ PyC_Long_AsI16()

int16_t PyC_Long_AsI16 ( PyObject * value)

◆ PyC_Long_AsI8()

int8_t PyC_Long_AsI8 ( PyObject * value)

◆ PyC_Long_AsU16()

uint16_t PyC_Long_AsU16 ( PyObject * value)

◆ PyC_Long_AsU32()

◆ PyC_Long_AsU64()

uint64_t PyC_Long_AsU64 ( PyObject * value)

#PyLong_AsUnsignedLongLong, unlike #PyLong_AsLongLong, does not fall back to calling #PyNumber_Index when its argument is not a PyLongObject instance. To match parsing signed integer types with #PyLong_AsLongLong, this function performs the #PyNumber_Index fallback, if necessary, before calling #PyLong_AsUnsignedLongLong.

Definition at line 1853 of file py_capi_utils.cc.

References PyC_Long_AsU64().

Referenced by foreach_getset(), PyC_Long_AsU64(), and PyC_StringEnum_FindIDFromValue().

◆ PyC_Long_AsU8()

uint8_t PyC_Long_AsU8 ( PyObject * value)

Unlike Python's #PyLong_AsUnsignedLong and #PyLong_AsUnsignedLongLong, these unsigned integer parsing functions fall back to calling #PyNumber_Index when their argument is not a PyLongObject. This matches Python's signed integer parsing functions which also fall back to calling #PyNumber_Index.

Definition at line 1814 of file py_capi_utils.cc.

References PyC_Long_AsU8(), pyc_Long_AsUnsignedLong(), UINT8_MAX, and UNLIKELY.

Referenced by foreach_getset(), PyC_Long_AsU8(), and PyC_StringEnum_FindIDFromValue().

◆ PyC_MainModule_Backup()

◆ PyC_MainModule_Restore()

void PyC_MainModule_Restore ( PyObject * main_mod)

◆ PyC_NameSpace_ImportArray()

bool PyC_NameSpace_ImportArray ( PyObject * py_dict,
const char * imports[] )

Import imports into py_dict.

Parameters
py_dictA Python dictionary, typically used as a name-space for script execution.
importsA NULL terminated array of strings.
Returns
true when all modules import without errors, otherwise return false. The caller is expected to handle the exception.

Definition at line 1131 of file py_capi_utils.cc.

References i, mod, and PyC_NameSpace_ImportArray().

Referenced by bpy_run_string_impl(), PyC_NameSpace_ImportArray(), and pyc_run_string_as_py_object().

◆ PyC_Object_GetAttrStringArgs()

PyObject * PyC_Object_GetAttrStringArgs ( PyObject * o,
Py_ssize_t n,
... )

Definition at line 724 of file py_capi_utils.cc.

References i, and PyC_Object_GetAttrStringArgs().

Referenced by PyC_Object_GetAttrStringArgs().

◆ PyC_ObSpit()

void PyC_ObSpit ( const char * name,
PyObject * var )

Useful to print Python objects while debugging.

Definition at line 571 of file py_capi_utils.cc.

References PyC_ObSpit().

Referenced by bpy_class_free_ex(), PyC_ObSpit(), PyC_RunQuicky(), and pyrna_subtype_set_rna().

◆ PyC_ObSpitStr()

void PyC_ObSpitStr ( char * result,
size_t result_maxncpy,
PyObject * var )

A version of PyC_ObSpit that writes into a string (and doesn't take a name argument). Use for logging.

Definition at line 589 of file py_capi_utils.cc.

References BLI_snprintf(), PyC_ObSpitStr(), and result.

Referenced by PyC_ObSpitStr(), and pyrna_srna_ExternalType().

◆ PyC_ParseBool()

◆ PyC_ParseStringEnum()

◆ PyC_ParseUnicodeAsBytesAndSize()

int PyC_ParseUnicodeAsBytesAndSize ( PyObject * o,
void * p )

Use with PyArg_ParseTuple's "O&" formatting.

Expose PyC_UnicodeAsBytes in a way which is useful to the argument parser.

Parameters
oAn argument parsed to PyC_UnicodeAsBytes.
pPointer to #PyC_UnicodeAsBytes_Data.
Note
The Python API docs reference PyUnicode_FSConverter however this does not support paths which non UTF8 encoding, see: #111033.

Definition at line 1077 of file py_capi_utils.cc.

References BLI_assert, data, PyC_ParseUnicodeAsBytesAndSize(), PyC_UnicodeAsBytesAndSize(), and UNLIKELY.

Referenced by bpy_app_icons_new_triangles_from_file(), bpy_lib_load(), bpy_lib_write(), bpy_system_resource(), bpy_user_resource(), bpy_utils_previews_load(), M_imbuf_load(), py_blf_load(), py_blf_unload(), PyC_ParseUnicodeAsBytesAndSize(), and PyC_ParseUnicodeAsBytesAndSize_OrNone().

◆ PyC_ParseUnicodeAsBytesAndSize_OrNone()

int PyC_ParseUnicodeAsBytesAndSize_OrNone ( PyObject * o,
void * p )

◆ PyC_RNA_AsPointer()

void * PyC_RNA_AsPointer ( PyObject * value,
const char * type_name )

◆ PyC_RunQuicky()

void PyC_RunQuicky ( const char * filepath,
int n,
... )

Definition at line 1187 of file py_capi_utils.cc.

References i, printf, PyC_DefaultNameSpace(), PyC_ObSpit(), PyC_RunQuicky(), and ret.

Referenced by PyC_RunQuicky().

◆ PyC_RunString_AsIntPtr()

bool PyC_RunString_AsIntPtr ( const char ** imports,
const char * expr,
const char * filename,
intptr_t * r_value )

◆ PyC_RunString_AsNumber()

bool PyC_RunString_AsNumber ( const char ** imports,
const char * expr,
const char * filename,
double * r_value )
Returns
success
Note
it is caller's responsibility to acquire & release GIL!

References PyC_RunString_AsNumber().

◆ PyC_RunString_AsString()

bool PyC_RunString_AsString ( const char ** imports,
const char * expr,
const char * filename,
char ** r_value )

◆ PyC_RunString_AsStringAndSize()

bool PyC_RunString_AsStringAndSize ( const char ** imports,
const char * expr,
const char * filename,
char ** r_value,
size_t * r_value_size )
Parameters
r_value_sizeThe length of the string assigned: strlen(*r_value).

References ATTR_NONNULL, ATTR_WARN_UNUSED_RESULT, and PyC_RunString_AsStringAndSize().

◆ PyC_RunString_AsStringAndSizeOrNone()

bool PyC_RunString_AsStringAndSizeOrNone ( const char ** imports,
const char * expr,
const char * filename,
char ** r_value,
size_t * r_value_size )
Parameters
r_value_sizeThe length of the string assigned: strlen(*r_value).

References ATTR_NONNULL, ATTR_WARN_UNUSED_RESULT, and PyC_RunString_AsStringAndSizeOrNone().

◆ PyC_RunString_AsStringOrNone()

bool PyC_RunString_AsStringOrNone ( const char ** imports,
const char * expr,
const char * filename,
char ** r_value )

◆ PyC_StackSpit()

void PyC_StackSpit ( )

Definition at line 635 of file py_capi_utils.cc.

References PyC_IsInterpreterActive(), and PyC_StackSpit().

Referenced by PyC_StackSpit().

◆ PyC_StdFilesFlush()

void PyC_StdFilesFlush ( )

Flush Python's sys.stdout and sys.stderr. Errors are ignored.

Definition at line 1695 of file py_capi_utils.cc.

References BLI_assert, and PyC_StdFilesFlush().

Referenced by PyC_RunString_AsStringOrNone(), PyC_StdFilesFlush(), and python_script_exec().

◆ PyC_StringEnum_FindIDFromValue()

◆ PyC_StructFmt_type_from_str()

char PyC_StructFmt_type_from_str ( const char * typestr)

◆ PyC_StructFmt_type_is_bool()

bool PyC_StructFmt_type_is_bool ( char format)

Definition at line 1946 of file py_capi_utils.cc.

References PyC_StructFmt_type_is_bool().

Referenced by PyC_StructFmt_type_is_bool().

◆ PyC_StructFmt_type_is_byte()

bool PyC_StructFmt_type_is_byte ( char format)

◆ PyC_StructFmt_type_is_float_any()

bool PyC_StructFmt_type_is_float_any ( char format)

◆ PyC_StructFmt_type_is_int_any()

bool PyC_StructFmt_type_is_int_any ( char format)

◆ PyC_Tuple_Fill()

void PyC_Tuple_Fill ( PyObject * tuple,
PyObject * value )

Caller needs to ensure tuple is uninitialized. Handy for filling a tuple with None for eg.

Definition at line 476 of file py_capi_utils.cc.

References i, and PyC_Tuple_Fill().

Referenced by kdtree_nearest_to_py_and_check(), py_bvhtree_nearest_to_py_none(), py_bvhtree_raycast_to_py_none(), and PyC_Tuple_Fill().

◆ PyC_Tuple_Pack_Bool()

PyObject * PyC_Tuple_Pack_Bool ( const blender::Span< bool > values)
inline

◆ PyC_Tuple_Pack_F32()

PyObject * PyC_Tuple_Pack_F32 ( const blender::Span< float > values)
inline

◆ PyC_Tuple_Pack_F64()

PyObject * PyC_Tuple_Pack_F64 ( const blender::Span< double > values)
inline

◆ PyC_Tuple_Pack_I32()

◆ PyC_Tuple_Pack_I32FromBool()

PyObject * PyC_Tuple_Pack_I32FromBool ( const blender::Span< int > values)
inline

◆ PyC_Tuple_PackArray_Bool()

PyObject * PyC_Tuple_PackArray_Bool ( const bool * array,
uint len )

◆ PyC_Tuple_PackArray_F32()

◆ PyC_Tuple_PackArray_F64()

PyObject * PyC_Tuple_PackArray_F64 ( const double * array,
uint len )

◆ PyC_Tuple_PackArray_I32()

PyObject * PyC_Tuple_PackArray_I32 ( const int * array,
uint len )

◆ PyC_Tuple_PackArray_I32FromBool()

PyObject * PyC_Tuple_PackArray_I32FromBool ( const int * array,
uint len )

◆ PyC_Tuple_PackArray_Multi_Bool()

PyObject * PyC_Tuple_PackArray_Multi_Bool ( const bool * array,
const int dims[],
int dims_len )

◆ PyC_Tuple_PackArray_Multi_F32()

PyObject * PyC_Tuple_PackArray_Multi_F32 ( const float * array,
const int dims[],
int dims_len )

◆ PyC_Tuple_PackArray_Multi_F64()

PyObject * PyC_Tuple_PackArray_Multi_F64 ( const double * array,
const int dims[],
int dims_len )

◆ PyC_Tuple_PackArray_Multi_I32()

PyObject * PyC_Tuple_PackArray_Multi_I32 ( const int * array,
const int dims[],
int dims_len )

◆ PyC_Tuple_PackArray_String()

PyObject * PyC_Tuple_PackArray_String ( const char ** array,
uint len )
Note
Any errors converting strings will return null with the error left as-is.

Definition at line 351 of file py_capi_utils.cc.

References i, len(), and PyC_Tuple_PackArray_String().

Referenced by bpy_app_python_args_get(), and PyC_Tuple_PackArray_String().

◆ PyC_UnicodeAsBytes()

const char * PyC_UnicodeAsBytes ( PyObject * py_str,
PyObject ** r_coerce )

◆ PyC_UnicodeAsBytesAndSize()

const char * PyC_UnicodeAsBytesAndSize ( PyObject * py_str,
Py_ssize_t * r_size,
PyObject ** r_coerce )

String conversion, escape non-unicode chars

Parameters
r_sizeThe string length (not including the null terminator).
Note
By convention Blender API's use len/length however Python API's use the term size, as this is an alternative to Python's #PyUnicode_AsUTF8AndSize, follow it's naming.
Parameters
r_coercemust reference a pointer set to NULL.

Definition at line 1000 of file py_capi_utils.cc.

References PyC_UnicodeAsBytesAndSize(), and result.

Referenced by idp_from_PyUnicode(), py_imbuf_filepath_set(), PyC_ParseUnicodeAsBytesAndSize(), and PyC_UnicodeAsBytesAndSize().

◆ PyC_UnicodeFromBytes()

◆ PyC_UnicodeFromBytesAndSize()

PyObject * PyC_UnicodeFromBytesAndSize ( const char * str,
Py_ssize_t size )

◆ PyC_UnicodeFromStdStr()

Variable Documentation

◆ ATTR_WARN_UNUSED_RESULT

bool ATTR_WARN_UNUSED_RESULT

Definition at line 229 of file py_capi_utils.hh.