Blender V5.0
bpy_rna.hh File Reference
#include <Python.h>
#include <optional>
#include "intern/rna_internal_types.hh"

Go to the source code of this file.

Classes

struct  BPy_DummyPointerRNA
struct  BPy_StructRNA
struct  BPy_PropertyRNA
struct  BPy_PropertyArrayRNA
struct  BPy_PropertyCollectionIterRNA
struct  BPy_FunctionRNA
struct  BPy_StructRNA_Parse

Macros

#define USE_PYRNA_ITER
#define BPy_StructRNA_Check(v)
#define BPy_StructRNA_CheckExact(v)
#define BPy_PropertyRNA_Check(v)
#define BPy_PropertyRNA_CheckExact(v)
#define PYRNA_STRUCT_CHECK_OBJ(obj)
#define PYRNA_STRUCT_CHECK_INT(obj)
#define PYRNA_PROP_CHECK_OBJ(obj)
#define PYRNA_PROP_CHECK_INT(obj)
#define PYRNA_STRUCT_CHECK_OBJ_UNLESS(obj, unless)
#define PYRNA_STRUCT_IS_VALID(pysrna)
#define PYRNA_PROP_IS_VALID(pysrna)

Functions

StructRNAsrna_from_self (PyObject *self, const char *error_prefix)
StructRNApyrna_struct_as_srna (PyObject *self, bool parent, const char *error_prefix)
void BPY_rna_init ()
void BPY_rna_exit ()
PyObject * BPY_rna_module ()
void BPY_update_rna_module ()
PyObject * BPY_rna_types ()
void BPY_rna_types_dict_set (PyObject *dict)
void BPY_rna_types_finalize_external_types (PyObject *submodule)
PyObject * pyrna_struct_CreatePyObject_with_primitive_support (PointerRNA *ptr)
PyObject * pyrna_struct_CreatePyObject (PointerRNA *ptr)
PyObject * pyrna_prop_CreatePyObject (PointerRNA *ptr, PropertyRNA *prop)
PyObject * pyrna_id_CreatePyObject (ID *id)
bool pyrna_id_FromPyObject (PyObject *obj, ID **id)
bool pyrna_id_CheckPyObject (PyObject *obj)
int pyrna_pydict_to_props (PointerRNA *ptr, PyObject *kw, bool all_args, const char *error_prefix)
PyObject * pyrna_prop_to_py (PointerRNA *ptr, PropertyRNA *prop)
int pyrna_deferred_register_class (StructRNA *srna, PyTypeObject *py_class)
const PointerRNApyrna_struct_as_ptr (PyObject *py_obj, const StructRNA *srna)
const PointerRNApyrna_struct_as_ptr_or_null (PyObject *py_obj, const StructRNA *srna)
int pyrna_struct_as_ptr_parse (PyObject *o, void *p)
int pyrna_struct_as_ptr_or_null_parse (PyObject *o, void *p)
void pyrna_struct_type_extend_capi (StructRNA *srna, PyMethodDef *method, PyGetSetDef *getset)
void pyrna_alloc_types ()
int pyrna_py_to_array (PointerRNA *ptr, PropertyRNA *prop, char *param_data, PyObject *py, const char *error_prefix)
int pyrna_py_to_array_index (PointerRNA *ptr, PropertyRNA *prop, int arraydim, int arrayoffset, int index, PyObject *py, const char *error_prefix)
PyObject * pyrna_array_index (PointerRNA *ptr, PropertyRNA *prop, int index)
PyObject * pyrna_py_from_array (PointerRNA *ptr, PropertyRNA *prop)
PyObject * pyrna_py_from_array_index (BPy_PropertyArrayRNA *self, PointerRNA *ptr, PropertyRNA *prop, int index)
PyObject * pyrna_math_object_from_array (PointerRNA *ptr, PropertyRNA *prop)
int pyrna_array_contains_py (PointerRNA *ptr, PropertyRNA *prop, PyObject *value)
bool pyrna_write_check ()
void pyrna_write_set (bool val)
void pyrna_invalidate (BPy_DummyPointerRNA *self)
int pyrna_struct_validity_check_only (const BPy_StructRNA *pysrna)
void pyrna_struct_validity_exception_only (const BPy_StructRNA *pysrna)
int pyrna_struct_validity_check (const BPy_StructRNA *pysrna)
int pyrna_prop_validity_check (const BPy_PropertyRNA *self)

Variables

PyTypeObject pyrna_struct_meta_idprop_Type
PyTypeObject pyrna_struct_Type
PyTypeObject pyrna_prop_Type
PyTypeObject pyrna_prop_array_Type
PyTypeObject pyrna_prop_collection_Type
PyTypeObject pyrna_func_Type
PyMethodDef meth_bpy_register_class
PyMethodDef meth_bpy_unregister_class
PyMethodDef meth_bpy_owner_id_set
PyMethodDef meth_bpy_owner_id_get
BPy_StructRNAbpy_context_module

Macro Definition Documentation

◆ BPy_PropertyRNA_Check

#define BPy_PropertyRNA_Check ( v)
Value:
(PyObject_TypeCheck(v, &pyrna_prop_Type))
ATTR_WARN_UNUSED_RESULT const BMVert * v
PyTypeObject pyrna_prop_Type
Definition bpy_rna.cc:7411

Definition at line 75 of file bpy_rna.hh.

Referenced by py_msgbus_rna_key_from_py(), pyrna_dir_members_py(), pyrna_prop_collection_string_subscript_supported_or_error(), and pyrna_prop_richcmp().

◆ BPy_PropertyRNA_CheckExact

#define BPy_PropertyRNA_CheckExact ( v)
Value:
(Py_TYPE(v) == &pyrna_prop_Type)

Definition at line 76 of file bpy_rna.hh.

Referenced by pyrna_prop_dir().

◆ BPy_StructRNA_Check

◆ BPy_StructRNA_CheckExact

#define BPy_StructRNA_CheckExact ( v)
Value:
(Py_TYPE(v) == &pyrna_struct_Type)

Definition at line 74 of file bpy_rna.hh.

Referenced by pyrna_struct_dir().

◆ PYRNA_PROP_CHECK_INT

◆ PYRNA_PROP_CHECK_OBJ

◆ PYRNA_PROP_IS_VALID

#define PYRNA_PROP_IS_VALID ( pysrna)
Value:
(LIKELY(((BPy_PropertyRNA *)(pysrna))->ptr->type != NULL))
#define LIKELY(x)
PointerRNA * ptr
Definition wm_files.cc:4238

Definition at line 111 of file bpy_rna.hh.

◆ PYRNA_STRUCT_CHECK_INT

#define PYRNA_STRUCT_CHECK_INT ( obj)
Value:
return -1; \
} \
(void)0
int pyrna_struct_validity_check(const BPy_StructRNA *pysrna)
Definition bpy_rna.cc:157

Definition at line 83 of file bpy_rna.hh.

Referenced by py_msgbus_rna_key_from_py(), pyrna_struct_ass_subscript(), pyrna_struct_contains(), and pyrna_struct_setattro().

◆ PYRNA_STRUCT_CHECK_OBJ

◆ PYRNA_STRUCT_CHECK_OBJ_UNLESS

#define PYRNA_STRUCT_CHECK_OBJ_UNLESS ( obj,
unless )
Value:
{ \
const BPy_StructRNA *_obj = obj; \
if (UNLIKELY(pyrna_struct_validity_check_only(_obj) == -1) && !(unless)) { \
pyrna_struct_validity_exception_only(_obj); \
return NULL; \
} \
} \
(void)0
int pyrna_struct_validity_check_only(const BPy_StructRNA *pysrna)
Definition bpy_rna.cc:143

Definition at line 100 of file bpy_rna.hh.

Referenced by pyrna_struct_getattro().

◆ PYRNA_STRUCT_IS_VALID

#define PYRNA_STRUCT_IS_VALID ( pysrna)
Value:
(LIKELY(((BPy_StructRNA *)(pysrna))->ptr->type != NULL))

Definition at line 110 of file bpy_rna.hh.

Referenced by pyrna_struct_repr(), and pyrna_struct_str().

◆ USE_PYRNA_ITER

#define USE_PYRNA_ITER

Definition at line 56 of file bpy_rna.hh.

Function Documentation

◆ BPY_rna_exit()

void BPY_rna_exit ( )

Definition at line 8680 of file bpy_rna.cc.

References BLI_ghash_free(), BLI_ghash_len(), BLI_ghashIterator_getKey(), GHASH_ITER, ID::name, and printf.

Referenced by BPY_python_end().

◆ BPY_rna_init()

◆ BPY_rna_module()

PyObject * BPY_rna_module ( )
nodiscard

◆ BPY_rna_types()

◆ BPY_rna_types_dict_set()

void BPY_rna_types_dict_set ( PyObject * dict)

Set the _bpy_types.py modules __dict__, needed for instancing RNA types.

Definition at line 8237 of file bpy_rna.cc.

References bpy_types_dict.

Referenced by BPy_init_modules().

◆ BPY_rna_types_finalize_external_types()

void BPY_rna_types_finalize_external_types ( PyObject * submodule)

◆ BPY_update_rna_module()

void BPY_update_rna_module ( )

Definition at line 8715 of file bpy_rna.cc.

References G_MAIN, RNA_main_pointer_create(), and rna_module_ptr.

Referenced by BPY_driver_exec(), and BPY_modules_update().

◆ pyrna_alloc_types()

void pyrna_alloc_types ( )

◆ pyrna_array_contains_py()

◆ pyrna_array_index()

◆ pyrna_deferred_register_class()

◆ pyrna_id_CheckPyObject()

bool pyrna_id_CheckPyObject ( PyObject * obj)
nodiscard

Definition at line 8622 of file bpy_rna.cc.

Referenced by pyrna_id_FromPyObject().

◆ pyrna_id_CreatePyObject()

PyObject * pyrna_id_CreatePyObject ( ID * id)
nodiscard

Definition at line 8601 of file bpy_rna.cc.

◆ pyrna_id_FromPyObject()

bool pyrna_id_FromPyObject ( PyObject * obj,
ID ** id )
nodiscard

Definition at line 8611 of file bpy_rna.cc.

◆ pyrna_invalidate()

void pyrna_invalidate ( BPy_DummyPointerRNA * self)

Definition at line 178 of file bpy_rna.cc.

References self.

Referenced by BPY_DECREF_RNA_INVALIDATE().

◆ pyrna_math_object_from_array()

◆ pyrna_prop_CreatePyObject()

◆ pyrna_prop_to_py()

◆ pyrna_prop_validity_check()

int pyrna_prop_validity_check ( const BPy_PropertyRNA * self)
nodiscard

Definition at line 166 of file bpy_rna.cc.

References RNA_property_identifier(), and self.

◆ pyrna_py_from_array()

PyObject * pyrna_py_from_array ( PointerRNA * ptr,
PropertyRNA * prop )
nodiscard

Definition at line 978 of file bpy_rna_array.cc.

References ptr, pyrna_math_object_from_array(), pyrna_prop_CreatePyObject(), and ret.

Referenced by pyrna_prop_to_py().

◆ pyrna_py_from_array_index()

PyObject * pyrna_py_from_array_index ( BPy_PropertyArrayRNA * self,
PointerRNA * ptr,
PropertyRNA * prop,
int index )
nodiscard

◆ pyrna_py_to_array()

◆ pyrna_py_to_array_index()

int pyrna_py_to_array_index ( PointerRNA * ptr,
PropertyRNA * prop,
int arraydim,
int arrayoffset,
int index,
PyObject * py,
const char * error_prefix )
nodiscard

◆ pyrna_pydict_to_props()

int pyrna_pydict_to_props ( PointerRNA * ptr,
PyObject * kw,
bool all_args,
const char * error_prefix )
nodiscard

◆ pyrna_struct_as_ptr()

const PointerRNA * pyrna_struct_as_ptr ( PyObject * py_obj,
const StructRNA * srna )

◆ pyrna_struct_as_ptr_or_null()

const PointerRNA * pyrna_struct_as_ptr_or_null ( PyObject * py_obj,
const StructRNA * srna )

◆ pyrna_struct_as_ptr_or_null_parse()

int pyrna_struct_as_ptr_or_null_parse ( PyObject * o,
void * p )
nodiscard

A version of pyrna_struct_as_ptr_parse that maps Python's None to PointerRNA_NULL.

Definition at line 9045 of file bpy_rna.cc.

References BLI_assert, BPy_StructRNA_Parse::ptr, pyrna_struct_as_ptr_or_null(), and BPy_StructRNA_Parse::type.

Referenced by bpy_context_temp_override().

◆ pyrna_struct_as_ptr_parse()

int pyrna_struct_as_ptr_parse ( PyObject * o,
void * p )
nodiscard

Sets BPy_StructRNA_Parse.ptr to the value in the BPy_StructRNA.ptr (from o) or raise an error if the type isn't a BPy_StructRNA.

Use with #PyArg_ParseTuple's O& formatting.

Definition at line 9034 of file bpy_rna.cc.

References BLI_assert, BPy_StructRNA_Parse::ptr, pyrna_struct_as_ptr(), and BPy_StructRNA_Parse::type.

◆ pyrna_struct_as_srna()

◆ pyrna_struct_CreatePyObject()

◆ pyrna_struct_CreatePyObject_with_primitive_support()

PyObject * pyrna_struct_CreatePyObject_with_primitive_support ( PointerRNA * ptr)
nodiscard

Definition at line 8532 of file bpy_rna.cc.

References data, ptr, PyC_UnicodeFromBytes(), and pyrna_struct_CreatePyObject().

Referenced by bpy_app_generic_callback().

◆ pyrna_struct_type_extend_capi()

void pyrna_struct_type_extend_capi ( StructRNA * srna,
PyMethodDef * method,
PyGetSetDef * getset )

Definition at line 10511 of file bpy_rna.cc.

References BLI_assert, Py_DECREF(), pyrna_srna_Subtype(), and UNUSED_VARS_NDEBUG.

Referenced by BPY_rna_types_extend_capi().

◆ pyrna_struct_validity_check()

int pyrna_struct_validity_check ( const BPy_StructRNA * pysrna)
nodiscard

Definition at line 157 of file bpy_rna.cc.

References BPy_StructRNA::ptr, and pyrna_struct_validity_exception_only().

Referenced by pyrna_py_to_prop().

◆ pyrna_struct_validity_check_only()

int pyrna_struct_validity_check_only ( const BPy_StructRNA * pysrna)
nodiscard

Definition at line 143 of file bpy_rna.cc.

References BPy_StructRNA::ptr.

◆ pyrna_struct_validity_exception_only()

void pyrna_struct_validity_exception_only ( const BPy_StructRNA * pysrna)

Definition at line 151 of file bpy_rna.cc.

Referenced by pyrna_struct_validity_check().

◆ pyrna_write_check()

◆ pyrna_write_set()

void pyrna_write_set ( bool val)

◆ srna_from_self()

StructRNA * srna_from_self ( PyObject * self,
const char * error_prefix )
nodiscard

Variable Documentation

◆ bpy_context_module

◆ meth_bpy_owner_id_get

PyMethodDef meth_bpy_owner_id_get
extern

Definition at line 10598 of file bpy_rna.cc.

Referenced by BPy_init_modules().

◆ meth_bpy_owner_id_set

PyMethodDef meth_bpy_owner_id_set
extern

Definition at line 10604 of file bpy_rna.cc.

Referenced by BPy_init_modules().

◆ meth_bpy_register_class

PyMethodDef meth_bpy_register_class
extern

Definition at line 10147 of file bpy_rna.cc.

Referenced by BPy_init_modules().

◆ meth_bpy_unregister_class

PyMethodDef meth_bpy_unregister_class
extern

Definition at line 10378 of file bpy_rna.cc.

Referenced by BPy_init_modules().

◆ pyrna_func_Type

PyTypeObject pyrna_func_Type
extern

Definition at line 8048 of file bpy_rna.cc.

Referenced by BPY_rna_init(), BPY_rna_types(), and pyrna_func_CreatePyObject().

◆ pyrna_prop_array_Type

PyTypeObject pyrna_prop_array_Type
extern

◆ pyrna_prop_collection_Type

PyTypeObject pyrna_prop_collection_Type
extern

◆ pyrna_prop_Type

PyTypeObject pyrna_prop_Type
extern

◆ pyrna_struct_meta_idprop_Type

PyTypeObject pyrna_struct_meta_idprop_Type
extern

Sub-classes of pyrna_struct_Type which support idprop definitions use this as a meta-class.

Note
tp_base member is set to &PyType_Type on initialization.

Definition at line 7080 of file bpy_rna.cc.

Referenced by BPY_rna_init(), BPY_rna_types(), and pyrna_srna_Subtype().

◆ pyrna_struct_Type