45#ifdef USE_PYRNA_INVALIDATE_WEAKREF
52#include "RNA_prototypes.hh"
81#define USE_PEDANTIC_WRITE
83#define USE_STRING_COERCE
92#define USE_POSTPONED_ANNOTATIONS
155 PyObject *
result =
nullptr;
156 if (PyWeakref_GetRef(ref, &
result) == -1) [[unlikely]] {
171#define BPY_DOC_ID_PROP_TYPE_NOTE \
174 " Limited to: :ref:`bpy_types-custom_properties`.\n"
178 if (pysrna->
ptr->has_type()) {
187 PyExc_ReferenceError,
"StructRNA of type %.200s has been removed", Py_TYPE(pysrna)->tp_name);
192 if (pysrna->
ptr->has_type()) {
201 if (self->
ptr->has_type()) {
204 PyErr_Format(PyExc_ReferenceError,
205 "PropertyRNA of type %.200s.%.200s has been removed",
206 Py_TYPE(self)->tp_name,
213 self->
ptr->invalidate();
220 PyErr_WarnFormat(PyExc_DeprecationWarning,
222 "'%s.%s' is expected to be removed in Blender %d.%d",
237 PyErr_Format(PyExc_IndexError,
"%.200s: index out of range", error_prefix);
241 PyErr_Format(PyExc_TypeError,
"%.200s: is not editable", error_prefix);
245 PyErr_Format(PyExc_TypeError,
"%.200s: not supported for this collection", error_prefix);
254#ifdef USE_PYRNA_INVALIDATE_GC
255# define FROM_GC(g) ((PyObject *)(((PyGC_Head *)g) + 1))
258struct gc_generation {
264static void id_release_gc(
struct ID *
id)
268 for (j = 0; j < 3; j++) {
270 PyGC_Head *gen = (PyGC_Head *)(((
char *)_PyGC_generation0) + (
sizeof(gc_generation) * j));
271 PyGC_Head *g = gen->gc.gc_next;
272 while ((g = g->gc.gc_next) != gen) {
273 PyObject *ob = FROM_GC(g);
278 if (ob_ptr->ptr->owner_id ==
id) {
290#ifdef USE_PYRNA_INVALIDATE_WEAKREF
293struct GHash *id_weakref_pool =
nullptr;
294static PyObject *id_free_weakref_cb(PyObject *weakinfo_pair, PyObject *weakref);
295static PyMethodDef id_free_weakref_cb_def = {
296 "id_free_weakref_cb", (PyCFunction)id_free_weakref_cb, METH_O,
nullptr};
301static void id_weakref_pool_free_value_fn(
void *p)
303 GHash *weakinfo_hash =
static_cast<GHash *
>(p);
308static GHash *id_weakref_pool_get(
ID *
id)
311 if (weakinfo_hash ==
nullptr) {
317 return weakinfo_hash;
324 PyObject *weakref_capsule;
325 PyObject *weakref_cb_py;
329 GHash *weakinfo_hash = id_weakref_pool_get(
id);
331 weakref_capsule = PyCapsule_New(weakinfo_hash,
nullptr,
nullptr);
332 weakref_cb_py = PyCFunction_New(&id_free_weakref_cb_def, weakref_capsule);
333 Py_DECREF(weakref_capsule);
336 weakref = PyWeakref_NewRef((PyObject *)pyrna, weakref_cb_py);
338 Py_DECREF(weakref_cb_py);
348static ID *_id_tmp_ptr;
349static void value_id_set(
void *
id)
351 _id_tmp_ptr = (
ID *)
id;
354static void id_release_weakref_list(
struct ID *
id,
GHash *weakinfo_hash);
355static PyObject *id_free_weakref_cb(PyObject *weakinfo_pair, PyObject *weakref)
358 GHash *weakinfo_hash =
static_cast<GHash *
>(PyCapsule_GetPointer(weakinfo_pair,
nullptr));
365 id_release_weakref_list(_id_tmp_ptr, weakinfo_hash);
373static void id_release_weakref_list(
struct ID *
id,
GHash *weakinfo_hash)
379# ifdef DEBUG_RNA_WEAKREF
380 fprintf(stdout,
"id_release_weakref: '%s', %d items\n",
id->name,
BLI_ghash_len(weakinfo_hash));
387# ifdef DEBUG_RNA_WEAKREF
403static void id_release_weakref(
struct ID *
id)
407 id_release_weakref_list(
id, weakinfo_hash);
414 PyObject *(*nameprop_as_py_object_fn)(
const char *, Py_ssize_t);
428 ptr, fixedbuf,
sizeof(fixedbuf), &name_len, &nameprop);
429 if (name_ptr) [[likely]] {
431 if (nameprop != nameprop_cache.
nameprop) [[unlikely]] {
445 if (name_ptr != fixedbuf) {
446 MEM_delete(name_ptr);
455#ifdef USE_PYRNA_INVALIDATE_GC
459#ifdef USE_PYRNA_INVALIDATE_WEAKREF
461 if (id_weakref_pool !=
nullptr) {
462 PyGILState_STATE gilstate = PyGILState_Ensure();
464 id_release_weakref(
id);
466 PyGILState_Release(gilstate);
473#ifdef USE_PEDANTIC_WRITE
482 const short idcode =
id->id_type();
487 if (key && PyUnicode_Check(key)) {
488 pyname = PyUnicode_AsUTF8(key);
491 pyname =
"<UNKNOWN>";
496 PyErr_Format(PyExc_AttributeError,
497 "Writing to ID classes in this context is not allowed: "
498 "%.200s, %.200s data-block, error setting %.200s.%.200s",
511#ifdef USE_PEDANTIC_WRITE
561 const char *error_prefix,
562 PyObject **r_value_coerce);
577 Py_ssize_t slice_length,
578 Py_ssize_t array_length);
580 const short order_fallback,
587# define MATHUTILS_CB_SUBTYPE_EUL 0
588# define MATHUTILS_CB_SUBTYPE_VEC 1
589# define MATHUTILS_CB_SUBTYPE_QUAT 2
590# define MATHUTILS_CB_SUBTYPE_COLOR 3
598 return self->
prop ? 0 : -1;
607 if (self->
prop ==
nullptr) {
630 if (self->
prop ==
nullptr) {
634# ifdef USE_PEDANTIC_WRITE
641 PyErr_Format(PyExc_AttributeError,
642 "bpy_prop \"%.200s.%.200s\" is read-only",
652 for (i = 0; i <
len; i++) {
667 &self->
ptr.value(), eul->
order, &prop_eul_order);
668 if (order != eul->
order) {
684 if (self->
prop ==
nullptr) {
698 if (self->
prop ==
nullptr) {
702# ifdef USE_PEDANTIC_WRITE
709 PyErr_Format(PyExc_AttributeError,
710 "bpy_prop \"%.200s.%.200s\" is read-only",
743 if (self->
prop ==
nullptr) {
757 if (self->
prop ==
nullptr) {
761# ifdef USE_PEDANTIC_WRITE
768 PyErr_Format(PyExc_AttributeError,
769 "bpy_prop \"%.200s.%.200s\" is read-only",
793 const short order_fallback,
797 if (*r_prop_eul_order ==
nullptr) {
801 if (*r_prop_eul_order) {
809 return order_fallback;
818#define PROP_ALL_VECTOR_SUBTYPES \
820 case PROP_TRANSLATION: \
821 case PROP_DIRECTION: \
822 case PROP_VELOCITY: \
823 case PROP_ACCELERATION: \
829 PyObject *
ret =
nullptr;
850 goto thick_wrap_slice;
863 if (totdim == 1 || (totdim == 2 && subtype ==
PROP_MATRIX)) {
871 if (
len >= 2 &&
len <= 4) {
968 if (
ret ==
nullptr) {
999 return (((a->
ptr->data ==
b->ptr->data) && (a->
ptr->type ==
b->ptr->type)) ? 0 : -1);
1005 ((a->
prop ==
b->prop) && (a->
ptr->data ==
b->ptr->data) && (a->
ptr->type ==
b->ptr->type)) ?
1025 res = ok ? Py_False : Py_True;
1032 res = Py_NotImplemented;
1035 PyErr_BadArgument();
1039 return Py_NewRef(res);
1057 res = ok ? Py_False : Py_True;
1064 res = Py_NotImplemented;
1067 PyErr_BadArgument();
1071 return Py_NewRef(res);
1079 const char *extra_info =
"";
1082 return PyUnicode_FromFormat(
"<bpy_struct, %.200s invalid>", Py_TYPE(self)->tp_name);
1085 ID *
id = self->
ptr->owner_id;
1087 extra_info =
", evaluated";
1096 ret = PyUnicode_FromFormat(
"<bpy_struct, %.200s(\"%.200s\") at %p%s>",
1105 return PyUnicode_FromFormat(
"<bpy_struct, %.200s at %p%s>",
1113 ID *
id = self->
ptr->owner_id;
1122 tmp_str = PyUnicode_FromString(
id->name + 2);
1125 ret = PyUnicode_FromFormat(
1129 ID *real_id =
nullptr;
1138 if (real_id !=
nullptr) {
1140 tmp_str = PyUnicode_FromString(real_id->
name + 2);
1141 ret = PyUnicode_FromFormat(
"bpy.data.%s[%R].%s",
1148 ret = PyUnicode_FromFormat(
"bpy.data.%s[%R]...%s",
1156 ret = PyUnicode_FromFormat(
"bpy.data.%s[%R]...%s",
1173 const char *type_id =
nullptr;
1174 char type_lower[64];
1175 char type_count[16];
1184 PyErr_SetString(PyExc_RuntimeError,
"could not use property type, internal error");
1203 type_count[0] =
'\0';
1212 ret = PyUnicode_FromFormat(
"<bpy_%.200s%.200s, %.200s.%.200s(\"%.200s\")>",
1226 return PyUnicode_FromFormat(
"<bpy_%.200s%.200s, %.200s>",
1233 return PyUnicode_FromFormat(
"<bpy_%.200s%.200s, %.200s.%.200s>",
1242 ID *
id = self->
ptr->owner_id;
1248 if (
id ==
nullptr) {
1253 tmp_str = PyUnicode_FromString(
id->name + 2);
1257 ID *real_id =
nullptr;
1262 if (real_id !=
id) {
1264 tmp_str = PyUnicode_FromString(real_id->
name + 2);
1266 const char *data_delim = ((*path)[0] ==
'[') ?
"" :
".";
1267 ret = PyUnicode_FromFormat(
"bpy.data.%s[%R]%s%s",
1275 ret = PyUnicode_FromFormat(
"bpy.data.%s[%R]...%s",
1299 return PyUnicode_FromFormat(
"<%.200s %.200s.%.200s()>",
1300 Py_TYPE(self)->tp_name,
1334#ifdef USE_PYRNA_STRUCT_REFERENCE
1335static int pyrna_struct_traverse(BPy_StructRNA *self, visitproc visit,
void *arg)
1337 Py_VISIT(self->reference);
1343 Py_CLEAR(self->reference);
1348#ifdef USE_PYRNA_STRUCT_REFERENCE
1349static void pyrna_struct_reference_set(
BPy_StructRNA *self, PyObject *reference)
1351 if (self->reference) {
1352 PyObject_GC_UnTrack(self);
1353 Py_CLEAR(self->reference);
1358 self->reference = reference;
1359 Py_INCREF(reference);
1360 BLI_assert(!PyObject_GC_IsTracked((PyObject *)self));
1361 PyObject_GC_Track(self);
1390 const char *param = PyUnicode_AsUTF8(item);
1392 if (param ==
nullptr) {
1393 PyErr_Format(PyExc_TypeError,
1394 "%.200s expected a string enum, not %.200s",
1396 Py_TYPE(item)->tp_name);
1402 PyErr_Format(PyExc_TypeError,
1403 "%.200s enum \"%.200s\" not found in (%s)",
1407 MEM_delete(enum_str);
1423 if (!PyAnySet_Check(value)) {
1424 PyErr_Format(PyExc_TypeError,
1425 "%.200s, %.200s.%.200s expected a set, not a %.200s",
1429 Py_TYPE(value)->tp_name);
1439 if (PySet_GET_SIZE(value)) {
1440 PyErr_Format(PyExc_TypeError,
1441 "%.200s: empty enum \"%.200s\" could not have any values assigned",
1460 PyObject *item, *
ret =
nullptr;
1465 ret = PySet_New(
nullptr);
1471 item = PyUnicode_FromString(identifier[
index]);
1472 PySet_Add(
ret, item);
1478 const char *identifier;
1480 ret = PyUnicode_FromString(identifier);
1496 "current value '%d' "
1497 "matches no enum in '%s', '%s', '%s'",
1504 char error_str[256];
1507 "RNA Warning: Current value \"%d\" "
1508 "matches no enum in '%s', '%s', '%s'",
1514 PyErr_Warn(PyExc_RuntimeWarning, error_str);
1518 MEM_delete(ptr_name);
1522 ret = PyUnicode_FromString(
"");
1524 PyErr_Format(PyExc_AttributeError,
"RNA Error: Current value \"%d\" matches no enum", val);
1564#ifdef USE_STRING_COERCE
1567 ret = PyBytes_FromStringAndSize(buf, buf_len);
1573 ret = PyUnicode_FromStringAndSize(buf, buf_len);
1577 ret = PyBytes_FromStringAndSize(buf, buf_len);
1580 ret = PyUnicode_FromStringAndSize(buf, buf_len);
1583 if (buf_fixed != buf) {
1608 PyErr_Format(PyExc_TypeError,
1609 "bpy_struct internal error: unknown type '%d' (pyrna_prop_to_py)",
1620 const bool all_args,
1621 const char *error_prefix)
1625 const char *arg_name =
nullptr;
1628 totkw = kw ? PyDict_Size(kw) : 0;
1633 if (
STREQ(arg_name,
"rna_type")) {
1637 if (kw ==
nullptr) {
1639 PyExc_TypeError,
"%.200s: no keywords, expected \"%.200s\"", error_prefix, arg_name);
1644 item = PyDict_GetItemString(kw, arg_name);
1646 if (item ==
nullptr) {
1648 PyErr_Format(PyExc_TypeError,
1649 "%.200s: keyword \"%.200s\" missing",
1651 arg_name ? arg_name :
"<UNKNOWN>");
1666 if (error_val == 0 && totkw > 0) {
1667 PyObject *key, *value;
1670 while (PyDict_Next(kw, &pos, &key, &value)) {
1671 arg_name = PyUnicode_AsUTF8(key);
1678 PyErr_Format(PyExc_TypeError,
1679 "%.200s: keyword \"%.200s\" unrecognized",
1681 arg_name ? arg_name :
"<UNKNOWN>");
1692 const char *error_prefix,
1693 PyObject **r_value_coerce)
1719 param = PyObject_IsTrue(value);
1722 param = PyC_Long_AsI32(value);
1724 if (param & ~1) [[unlikely]] {
1730 PyErr_Format(PyExc_TypeError,
1731 "%.200s %.200s.%.200s expected True/False or 0/1, not %.200s",
1735 Py_TYPE(value)->tp_name);
1740 *(
static_cast<bool *
>(
data)) = param;
1750 const long param = PyLong_AsLongAndOverflow(value, &overflow);
1751 if (overflow || (param >
INT_MAX) || (param < INT_MIN)) {
1752 PyErr_Format(PyExc_ValueError,
1753 "%.200s %.200s.%.200s value not in 'int' range "
1760 if (param == -1 && PyErr_Occurred()) {
1761 PyErr_Format(PyExc_TypeError,
1762 "%.200s %.200s.%.200s expected an int type, not %.200s",
1766 Py_TYPE(value)->tp_name);
1770 int param_i = int(param);
1773 *(
static_cast<int *
>(
data)) = param_i;
1782 const float param = PyFloat_AsDouble(value);
1783 if (PyErr_Occurred()) {
1784 PyErr_Format(PyExc_TypeError,
1785 "%.200s %.200s.%.200s expected a float type, not %.200s",
1789 Py_TYPE(value)->tp_name);
1795 *(
static_cast<float *
>(
data)) = param;
1808 if (value == Py_None) {
1812 *
static_cast<char *
>(
data) = 0;
1815 *(
static_cast<char **
>(
data)) =
static_cast<char *
>(
nullptr);
1823 PyErr_Format(PyExc_TypeError,
1824 "%.200s %.200s.%.200s doesn't support None from string types",
1835 param = PyBytes_AsString(value);
1837 if (param ==
nullptr) {
1838 if (PyBytes_Check(value)) {
1843 "%.200s %.200s.%.200s error assigning bytes",
1849 PyErr_Format(PyExc_TypeError,
1850 "%.200s %.200s.%.200s expected a bytes type, not %.200s",
1854 Py_TYPE(value)->tp_name);
1865 *(
static_cast<char **
>(
data)) =
const_cast<char *
>(param);
1874#ifdef USE_STRING_COERCE
1875 PyObject *value_coerce =
nullptr;
1881 param = PyUnicode_AsUTF8(value);
1884 param = PyUnicode_AsUTF8(value);
1887 if (param ==
nullptr) {
1888 if (PyUnicode_Check(value)) {
1893 "%.200s %.200s.%.200s error assigning string",
1899 PyErr_Format(PyExc_TypeError,
1900 "%.200s %.200s.%.200s expected a string type, not %.200s",
1904 Py_TYPE(value)->tp_name);
1913 char warning_buf[256];
1915 "%.200s.%.200s: does not support blend relative \"//\" prefix",
1918 PyErr_WarnEx(PyExc_RuntimeWarning, warning_buf, 1);
1926 bool param_is_ref =
false;
1933 *(
static_cast<char **
>(
data)) =
const_cast<char *
>(param);
1934 param_is_ref =
true;
1941#ifdef USE_STRING_COERCE
1942 if (value_coerce) [[unlikely]] {
1943 if (param_is_ref && r_value_coerce) [[unlikely]] {
1945 *r_value_coerce = value_coerce;
1951 Py_DECREF(value_coerce);
1978 *(
static_cast<int *
>(
data)) = val;
1987 PyObject *value_new =
nullptr;
2009 if (
ELEM(base_type, RNA_Operator, RNA_Gizmo)) {
2017 if (PyDict_Check(value)) {
2031 if (ptr->
type != RNA_Function) {
2032 PyErr_Format(PyExc_TypeError,
2033 "%.200s %.200s.%.200s internal error coercing a dict for %.200s type",
2047 &value_prop->
ptr.value(), value_prop->
prop))
2053 PyErr_Format(PyExc_TypeError,
2054 "%.200s %.200s.%.200s collection has no type, "
2055 "cannot be used as a %.200s type",
2065 if (value == Py_None) {
2067 PyErr_Format(PyExc_TypeError,
2068 "%.200s %.200s.%.200s does not support a 'None' assignment %.200s type",
2073 Py_XDECREF(value_new);
2080 PyErr_Format(PyExc_TypeError,
2081 "%.200s %.200s.%.200s expected a %.200s type, not %.200s",
2086 Py_TYPE(value)->tp_name);
2087 Py_XDECREF(value_new);
2093 if (value_owner_id !=
nullptr) {
2095 PyErr_Format(PyExc_TypeError,
2096 "%.200s %.200s.%.200s ID type does not support assignment to itself",
2100 Py_XDECREF(value_new);
2106 if (ptr->
type != RNA_Function) {
2107 PyErr_Format(PyExc_TypeError,
2108 "%.200s %.200s.%.200s ID type assignment is temporary, cannot assign",
2112 Py_XDECREF(value_new);
2119 bool raise_error =
false;
2124 if (param ==
nullptr) {
2139 if (param ==
nullptr) {
2140 *(
static_cast<void **
>(
data)) =
nullptr;
2150 else if (param ==
nullptr) {
2151 *(
static_cast<void **
>(
data)) =
nullptr;
2154 *(
static_cast<void **
>(
data)) = param->
ptr->data;
2166 ptr, prop, (param ==
nullptr) ?
PointerRNA() : *param->
ptr, &reports);
2169 Py_XDECREF(value_new);
2184 PyErr_Format(PyExc_TypeError,
2185 "%.200s %.200s.%.200s expected a %.200s type, not %.200s",
2192 Py_XDECREF(value_new);
2196 Py_XDECREF(value_new);
2201 Py_ssize_t seq_len, i;
2209 if (!PySequence_Check(value)) {
2212 "%.200s %.200s.%.200s expected a sequence for an RNA collection, not %.200s",
2216 Py_TYPE(value)->tp_name);
2220 seq_len = PySequence_Size(value);
2221 for (i = 0; i < seq_len; i++) {
2222 item = PySequence_GetItem(value, i);
2224 if (item ==
nullptr) {
2227 "%.200s %.200s.%.200s failed to get sequence index '%d' for an RNA collection",
2236 if (PyDict_Check(item) == 0) {
2237 PyErr_Format(PyExc_TypeError,
2238 "%.200s %.200s.%.200s expected a each sequence "
2239 "member to be a dict for an RNA collection, not %.200s",
2243 Py_TYPE(item)->tp_name);
2249 lb->
items.append(itemptr);
2256 &itemptr, item,
true,
"Converting a Python list to an RNA collection") == -1)
2259 const char *msg_char = PyUnicode_AsUTF8(msg);
2262 PyErr_Format(PyExc_TypeError,
2263 "%.200s %.200s.%.200s error converting a member of a collection "
2264 "from a dicts into an RNA collection, failed with: %s",
2280 PyErr_Format(PyExc_AttributeError,
2281 "%.200s %.200s.%.200s unknown property type (pyrna_py_to_prop)",
2337 int param = PyC_Long_AsI32(value);
2338 if (param == -1 && PyErr_Occurred()) {
2339 PyErr_SetString(PyExc_TypeError,
"expected an int type");
2349 float param = PyFloat_AsDouble(value);
2350 if (PyErr_Occurred()) {
2351 PyErr_SetString(PyExc_TypeError,
"expected a float type");
2361 PyErr_SetString(PyExc_AttributeError,
"not an array type");
2413#define PYRNA_PROP_COLLECTION_ABS_INDEX(ret_err) \
2415 keynum_abs += RNA_property_collection_length(&self->ptr.value(), self->prop); \
2416 if (keynum_abs < 0) { \
2417 PyErr_Format(PyExc_IndexError, "bpy_prop_collection[%d]: out of range.", keynum); \
2428 if (value != Py_None) {
2431 if (!value_pyrna->
ptr->has_type()) [[unlikely]] {
2434 PyErr_Format(PyExc_TypeError,
2435 "'%.200s' object is not subscriptable (only iteration is supported)",
2436 Py_TYPE(value)->tp_name);
2444 const char *error_prefix)
2446 PyErr_Format(PyExc_TypeError,
2447 "%.200s: %.200s.%.200s does not support string lookups",
2454 const char *error_prefix)
2468 Py_ssize_t keynum_abs = keynum;
2481 const int key = int(keynum_abs);
2482 PyObject *
result =
nullptr;
2506 if (keynum_abs >=
len) {
2507 PyErr_Format(PyExc_IndexError,
2508 "bpy_prop_collection[index]: "
2509 "index %d out of range, size %d",
2514 PyErr_Format(PyExc_RuntimeError,
2515 "bpy_prop_collection[index]: internal error, "
2516 "valid index %d given in %d sized collection, but value not found",
2529 Py_ssize_t keynum_abs = keynum;
2541 if (keynum_abs >=
len) {
2542 PyErr_Format(PyExc_IndexError,
2543 "bpy_prop_collection[index] = value: "
2544 "index %d out of range, size %d",
2549 PyErr_Format(PyExc_IndexError,
2550 "bpy_prop_collection[index] = value: "
2551 "index %d failed assignment (unknown reason)",
2572 if (keynum >= 0 && keynum <
len) {
2576 PyErr_Format(PyExc_IndexError,
"bpy_prop_array[index]: index %d out of range", keynum);
2593 const int key_len = strlen(keyname);
2596 PyObject *
result =
nullptr;
2607 &iter.
ptr, nameprop, name,
sizeof(name), &name_len);
2608 if ((key_len == name_len) &&
STREQ(name_ptr, keyname)) {
2611 if (name != name_ptr) {
2612 MEM_delete(name_ptr);
2635 PyErr_Format(PyExc_KeyError,
"bpy_prop_collection[key]: key \"%.200s\" not found", keyname);
2653 const char *err_prefix,
2654 const short err_not_found,
2657 const char *keyname;
2660 if (PyTuple_GET_SIZE(key) != 2) {
2661 PyErr_Format(PyExc_KeyError,
2662 "%s: tuple key must be a pair, not size %d",
2664 PyTuple_GET_SIZE(key));
2667 if (self->
ptr->type != RNA_BlendData) {
2668 PyErr_Format(PyExc_KeyError,
2669 "%s: is only valid for bpy.data collections, not %.200s",
2674 if ((keyname = PyUnicode_AsUTF8(PyTuple_GET_ITEM(key, 0))) ==
nullptr) {
2675 PyErr_Format(PyExc_KeyError,
2676 "%s: id must be a string, not %.200s",
2678 Py_TYPE(PyTuple_GET_ITEM(key, 0))->tp_name);
2682 PyObject *keylib = PyTuple_GET_ITEM(key, 1);
2686 if (keylib == Py_None) {
2689 else if (PyUnicode_Check(keylib)) {
2690 Main *bmain =
static_cast<Main *
>(self->
ptr->data);
2691 const char *keylib_str = PyUnicode_AsUTF8(keylib);
2694 if (lib ==
nullptr) {
2695 if (err_not_found) {
2696 PyErr_Format(PyExc_KeyError,
2697 "%s: lib filepath '%.1024s' "
2698 "does not reference a valid library",
2708 PyErr_Format(PyExc_KeyError,
2709 "%s: lib must be a string or None, not %.200s",
2711 Py_TYPE(keylib)->tp_name);
2719 ID *
id =
static_cast<ID *
>(itemptr.data);
2720 if (
id->lib == lib &&
STREQLEN(keyname,
id->name + 2,
sizeof(
id->name) - 2)) {
2731 if ((found ==
false) && err_not_found) {
2733 PyErr_SetString(PyExc_KeyError,
"bpy_prop_collection[key, lib]: not found");
2742 const char *err_prefix,
2743 const bool err_not_found)
2747 self, key, err_prefix, err_not_found, &ptr);
2749 if (contains == 1) {
2768 list = PyList_New(0);
2777 PyList_APPEND(
list, item);
2780 if (count == stop) {
2800 Py_ssize_t slice_length,
2801 Py_ssize_t array_length)
2803 Py_ssize_t count,
index;
2810 tuple = PyTuple_New(slice_length);
2815 for (count = 0,
index = start; count < slice_length; count++,
index +=
step) {
2825 values =
static_cast<float *
>(PyMem_MALLOC(
sizeof(
float) * array_length));
2828 values = values_stack;
2832 for (count = 0,
index = start; count < slice_length; count++,
index +=
step) {
2833 PyTuple_SET_ITEM(tuple, count, PyFloat_FromDouble(values[
index]));
2836 if (values != values_stack) {
2845 values =
static_cast<bool *
>(PyMem_MALLOC(
sizeof(
bool) * array_length));
2848 values = values_stack;
2852 for (count = 0,
index = start; count < slice_length; count++,
index +=
step) {
2853 PyTuple_SET_ITEM(tuple, count, PyBool_FromLong(values[
index]));
2856 if (values != values_stack) {
2865 values =
static_cast<int *
>(PyMem_MALLOC(
sizeof(
int) * array_length));
2868 values = values_stack;
2872 for (count = 0,
index = start; count < slice_length; count++,
index +=
step) {
2873 PyTuple_SET_ITEM(tuple, count, PyLong_FromLong(values[
index]));
2876 if (values != values_stack) {
2884 PyErr_SetString(PyExc_TypeError,
"not an array type");
2897 if (PyUnicode_Check(key)) {
2900 if (PyIndex_Check(key)) {
2901 const Py_ssize_t i = PyNumber_AsSsize_t(key, PyExc_IndexError);
2902 if (i == -1 && PyErr_Occurred()) {
2908 if (PySlice_Check(key)) {
2909 PySliceObject *key_slice =
reinterpret_cast<PySliceObject *
>(key);
2910 Py_ssize_t
step = 1;
2912 if (key_slice->step != Py_None && !_PyEval_SliceIndex(key_slice->step, &
step)) {
2916 PyErr_SetString(PyExc_TypeError,
"bpy_prop_collection[slice]: slice steps not supported");
2919 if (key_slice->start == Py_None && key_slice->stop == Py_None) {
2923 Py_ssize_t start = 0, stop = PY_SSIZE_T_MAX;
2926 if (key_slice->start != Py_None && !_PyEval_SliceIndex(key_slice->start, &start)) {
2929 if (key_slice->stop != Py_None && !_PyEval_SliceIndex(key_slice->stop, &stop)) {
2933 if (start < 0 || stop < 0) {
2935 const Py_ssize_t
len = Py_ssize_t(
2947 if (stop - start <= 0) {
2948 return PyList_New(0);
2953 if (PyTuple_Check(key)) {
2956 self, key,
"bpy_prop_collection[id, lib]",
true);
2959 PyErr_Format(PyExc_TypeError,
2960 "bpy_prop_collection[key]: invalid key, "
2961 "must be a string or an int, not %.200s",
2962 Py_TYPE(key)->tp_name);
2972 if (value == Py_None) {
2974 PyErr_SetString(PyExc_TypeError,
2975 "bpy_prop_collection[key] = value: invalid, "
2976 "this collection doesn't support None assignment");
2983 PyErr_Format(PyExc_TypeError,
2984 "bpy_prop_collection[key] = value: invalid, "
2985 "expected a StructRNA type or None, not a %.200s",
2986 Py_TYPE(value)->tp_name);
2992 PyErr_Format(PyExc_TypeError,
2993 "bpy_prop_collection[key] = value: invalid, "
2994 "expected a '%.200s' type or None, not a '%.200s'",
3003 PyErr_SetString(PyExc_TypeError,
3004 "bpy_prop_collection[key] = value: internal error, "
3005 "failed to get the collection type");
3018 if (value ==
nullptr) {
3019 PyErr_SetString(PyExc_TypeError,
"del bpy_prop_collection[key]: not supported");
3027 if (PyUnicode_Check(key)) {
3032 if (PyIndex_Check(key)) {
3033 const Py_ssize_t i = PyNumber_AsSsize_t(key, PyExc_IndexError);
3034 if (i == -1 && PyErr_Occurred()) {
3041 else if (PySlice_Check(key)) {
3042 PySliceObject *key_slice = (PySliceObject *)key;
3043 Py_ssize_t
step = 1;
3045 if (key_slice->step != Py_None && !_PyEval_SliceIndex(key_slice->step, &
step)) {
3048 else if (
step != 1) {
3049 PyErr_SetString(PyExc_TypeError,
"bpy_prop_collection[slice]: slice steps not supported");
3052 else if (key_slice->start == Py_None && key_slice->stop == Py_None) {
3056 Py_ssize_t start = 0, stop = PY_SSIZE_T_MAX;
3059 if (key_slice->start != Py_None && !_PyEval_SliceIndex(key_slice->start, &start)) {
3062 if (key_slice->stop != Py_None && !_PyEval_SliceIndex(key_slice->stop, &stop)) {
3066 if (start < 0 || stop < 0) {
3079 if (stop - start <= 0) {
3080 return PyList_New(0);
3089 PyErr_Format(PyExc_TypeError,
3090 "bpy_prop_collection[key]: invalid key, "
3091 "must be an int, not %.200s",
3092 Py_TYPE(key)->tp_name);
3101 if (PyUnicode_Check(key)) {
3102 return pyrna_prop_array_subscript_str(self, PyUnicode_AsUTF8(key));
3106 if (PyIndex_Check(key)) {
3107 const Py_ssize_t i = PyNumber_AsSsize_t(key, PyExc_IndexError);
3108 if (i == -1 && PyErr_Occurred()) {
3113 if (PySlice_Check(key)) {
3115 Py_ssize_t start, stop,
step, slice_length;
3117 if (PySlice_GetIndicesEx(key,
len, &start, &stop, &
step, &slice_length) < 0) {
3121 if (slice_length <= 0) {
3122 return PyTuple_New(0);
3126 self, &self->
ptr.value(), self->
prop, start,
step, slice_length,
len);
3129 PyErr_SetString(PyExc_AttributeError,
"bpy_prop_array[key]: invalid key, key must be an int");
3139 PyObject *value_fast;
3140 if (!(value_fast = PySequence_Fast(value,
3141 "bpy_prop_array[slice] = value: "
3142 "element in assignment is not a sequence type")))
3146 if (PySequence_Fast_GET_SIZE(value_fast) !=
length) {
3147 Py_DECREF(value_fast);
3148 PyErr_SetString(PyExc_ValueError,
3149 "bpy_prop_array[slice] = value: "
3150 "re-sizing bpy_struct element in arrays isn't supported");
3158 PyObject **value_items,
float *value,
int totdim,
const int dimsize[],
const float range[2])
3160 const int length = dimsize[0];
3164 for (i = 0; i !=
length; i++) {
3166 if (subvalue ==
nullptr) [[unlikely]] {
3171 PySequence_Fast_ITEMS(subvalue), &value[
index], totdim - 1, &dimsize[1], range);
3173 Py_DECREF(subvalue);
3179 const float min = range[0],
max = range[1];
3181 for (i = 0; i !=
length; i++) {
3182 float v = PyFloat_AsDouble(value_items[i]);
3190 PyObject **value_items,
int *value,
int totdim,
const int dimsize[],
const int range[2])
3192 const int length = dimsize[0];
3196 for (i = 0; i !=
length; i++) {
3198 if (subvalue ==
nullptr) [[unlikely]] {
3203 PySequence_Fast_ITEMS(subvalue), &value[
index], totdim - 1, &dimsize[1], range);
3205 Py_DECREF(subvalue);
3211 const int min = range[0],
max = range[1];
3213 for (i = 0; i !=
length; i++) {
3214 int v = PyLong_AsLong(value_items[i]);
3224 const int dimsize[])
3226 const int length = dimsize[0];
3230 for (i = 0; i !=
length; i++) {
3232 if (subvalue ==
nullptr) [[unlikely]] {
3237 PySequence_Fast_ITEMS(subvalue), &value[
index], totdim - 1, &dimsize[1]);
3239 Py_DECREF(subvalue);
3246 for (i = 0; i !=
length; i++) {
3247 const int v = PyLong_AsLong(value_items[i]);
3262 PyObject *value_orig)
3275 void *values_alloc =
nullptr;
3278 if (value_orig ==
nullptr) {
3281 "bpy_prop_array[slice] = value: deleting with list types is not supported by bpy_struct");
3285 if (!(value = PySequence_Fast(
3286 value_orig,
"bpy_prop_array[slice] = value: assignment is not a sequence type")))
3291 if (PySequence_Fast_GET_SIZE(value) != slice_length) {
3293 PyErr_SetString(PyExc_TypeError,
3294 "bpy_prop_array[slice] = value: re-sizing bpy_struct arrays isn't supported");
3301 BLI_assert(dimsize[arraydim] == array_length);
3306 for (
int i = arraydim + 1; i < totdim; i++) {
3323 const bool is_subset = (slice_length != array_length) || (arrayoffset != 0) || (arraydim != 0);
3325 PyObject **value_items = PySequence_Fast_ITEMS(value);
3329 float *values =
static_cast<float *
>(
3331 (values_alloc = PyMem_MALLOC(
sizeof(*values) * length_flat)) :
3341 dimsize[arraydim] = slice_length;
3343 &values[arrayoffset + (start * span)],
3349 dimsize[arraydim] = 1;
3350 for (
int i = 0; i < slice_length; i++) {
3353 &values[arrayoffset + ((start + (i *
step)) * span)],
3357 if (PyErr_Occurred()) {
3363 if (PyErr_Occurred()) {
3373 int *values =
static_cast<int *
>(
3375 (values_alloc = PyMem_MALLOC(
sizeof(*values) * length_flat)) :
3385 dimsize[arraydim] = slice_length;
3387 &values[arrayoffset + (start * span)],
3393 dimsize[arraydim] = 1;
3394 for (
int i = 0; i < slice_length; i++) {
3397 &values[arrayoffset + ((start + (i *
step)) * span)],
3401 if (PyErr_Occurred()) {
3407 if (PyErr_Occurred()) {
3417 bool *values =
static_cast<bool *
>(
3419 (values_alloc = PyMem_MALLOC(
sizeof(
bool) * length_flat)) :
3427 dimsize[arraydim] = slice_length;
3429 &values[arrayoffset + (start * span)],
3431 &dimsize[arraydim]);
3434 dimsize[arraydim] = 1;
3435 for (
int i = 0; i < slice_length; i++) {
3438 &values[arrayoffset + ((start + (i *
step)) * span)],
3440 &dimsize[arraydim]);
3441 if (PyErr_Occurred()) {
3447 if (PyErr_Occurred()) {
3456 PyErr_SetString(PyExc_TypeError,
"not an array type");
3464 PyMem_FREE(values_alloc);
3482 if (keynum >= 0 && keynum <
len) {
3486 PyErr_SetString(PyExc_IndexError,
"bpy_prop_array[index] = value: index out of range");
3500 PyErr_Format(PyExc_AttributeError,
3501 "bpy_prop_collection: attribute \"%.200s\" from \"%.200s\" is read-only",
3507 else if (PyIndex_Check(key)) {
3508 const Py_ssize_t i = PyNumber_AsSsize_t(key, PyExc_IndexError);
3509 if (i == -1 && PyErr_Occurred()) {
3516 else if (PySlice_Check(key)) {
3518 Py_ssize_t start, stop,
step, slice_length;
3520 if (PySlice_GetIndicesEx(key,
len, &start, &stop, &
step, &slice_length) < 0) {
3523 else if (slice_length <= 0) {
3539 PyErr_SetString(PyExc_AttributeError,
"invalid key, key must be an int");
3626 if (PyTuple_Check(key)) {
3629 self, key,
"(id, lib) in bpy_prop_collection",
false,
nullptr);
3633 const char *keyname = PyUnicode_AsUTF8(key);
3635 if (keyname ==
nullptr) {
3636 PyErr_SetString(PyExc_TypeError,
3637 "bpy_prop_collection.__contains__: expected a string or a tuple of strings");
3645 self,
"bpy_prop_collection.__contains__") == -1)
3655 const char *name = PyUnicode_AsUTF8(value);
3660 PyErr_SetString(PyExc_TypeError,
"bpy_struct.__contains__: expected a string");
3665 PyErr_SetString(PyExc_TypeError,
"bpy_struct: this type doesn't support IDProperties");
3724 const char *name = PyUnicode_AsUTF8(key);
3729 PyErr_SetString(PyExc_TypeError,
"this type doesn't support IDProperties");
3733 if (name ==
nullptr) {
3734 PyErr_SetString(PyExc_TypeError,
3735 "bpy_struct[key]: only strings are allowed as keys of ID properties");
3741 if (group ==
nullptr) {
3742 PyErr_Format(PyExc_KeyError,
"bpy_struct[key]: key \"%s\" not found", name);
3749 PyErr_Format(PyExc_KeyError,
"bpy_struct[key]: key \"%s\" not found", name);
3762#ifdef USE_PEDANTIC_WRITE
3768 if (group ==
nullptr) {
3769 PyErr_SetString(PyExc_TypeError,
3770 "bpy_struct[key] = val: id properties not supported for this type");
3776 if (val && self->
ptr->type && val->
ptr->type) {
3782 "bpy_struct[key] = val: data-block id properties not supported for this type");
3792 static_cast<lenfunc
>(
nullptr),
3799 pyrna_struct_keys_doc,
3800 ".. method:: keys()\n"
3802 " Returns the keys of this objects custom properties (matches Python's\n"
3803 " dictionary function of the same name).\n"
3805 " :return: custom property keys.\n"
3806 " :rtype: :class:`idprop.types.IDPropertyGroupViewKeys`\n"
3813 PyErr_SetString(PyExc_TypeError,
"bpy_struct.keys(): this type doesn't support IDProperties");
3824 pyrna_struct_items_doc,
3825 ".. method:: items()\n"
3827 " Returns the items of this objects custom properties (matches Python's\n"
3828 " dictionary function of the same name).\n"
3830 " :return: custom property key, value pairs.\n"
3831 " :rtype: :class:`idprop.types.IDPropertyGroupViewItems`\n"
3838 PyErr_SetString(PyExc_TypeError,
"bpy_struct.items(): this type doesn't support IDProperties");
3849 pyrna_struct_values_doc,
3850 ".. method:: values()\n"
3852 " Returns the values of this objects custom properties (matches Python's\n"
3853 " dictionary function of the same name).\n"
3855 " :return: custom property values.\n"
3856 " :rtype: :class:`idprop.types.IDPropertyGroupViewValues`\n"
3863 PyErr_SetString(PyExc_TypeError,
3864 "bpy_struct.values(): this type doesn't support IDProperties");
3875 pyrna_struct_is_property_set_doc,
3876 ".. method:: is_property_set(property, /, *, ghost=True)\n"
3878 " Check if a property is set, use for testing operator properties.\n"
3880 " :param property: Property name.\n"
3881 " :type property: str\n"
3882 " :param ghost: Used for operators that re-run with previous settings.\n"
3883 " In this case the property is not marked as set,\n"
3884 " yet the value from the previous execution is used.\n"
3886 " In rare cases you may want to set this option to false.\n"
3888 " :type ghost: bool\n"
3889 " :return: True when the property has been set.\n"
3895 bool use_ghost =
true;
3899 static const char *_keywords[] = {
"",
"ghost",
nullptr};
3900 static _PyArg_Parser _parser = {
3908 if (!_PyArg_ParseTupleAndKeywordsFast(args, kw, &_parser, &name,
PyC_ParseBool, &use_ghost)) {
3913 PyErr_Format(PyExc_TypeError,
3914 "%.200s.is_property_set(\"%.200s\") not found",
3925 pyrna_struct_property_unset_doc,
3926 ".. method:: property_unset(property, /)\n"
3928 " Unset a property, will use default value afterward.\n"
3930 " :param property: Property name.\n"
3931 " :type property: str\n");
3939 if (!PyArg_ParseTuple(args,
3948 PyErr_Format(PyExc_TypeError,
3949 "%.200s.property_unset(\"%.200s\") not found",
3962 pyrna_struct_is_property_hidden_doc,
3963 ".. method:: is_property_hidden(property, /)\n"
3965 " Check if a property is hidden.\n"
3967 " :param property: Property name.\n"
3968 " :type property: str\n"
3969 " :return: True when the property is hidden.\n"
3978 if (!PyArg_ParseTuple(args,
3980 ":is_property_hidden",
3987 PyErr_Format(PyExc_TypeError,
3988 "%.200s.is_property_hidden(\"%.200s\") not found",
3999 pyrna_struct_is_property_readonly_doc,
4000 ".. method:: is_property_readonly(property, /)\n"
4002 " Check if a property is readonly.\n"
4004 " :param property: Property name.\n"
4005 " :type property: str\n"
4006 " :return: True when the property is readonly (not writable).\n"
4015 if (!PyArg_ParseTuple(args,
4017 ":is_property_readonly",
4024 PyErr_Format(PyExc_TypeError,
4025 "%.200s.is_property_readonly(\"%.200s\") not found",
4036 pyrna_struct_is_property_overridable_library_doc,
4037 ".. method:: is_property_overridable_library(property, /)\n"
4039 " Check if a property is overridable.\n"
4041 " :param property: Property name.\n"
4042 " :type property: str\n"
4043 " :return: True when the property is overridable.\n"
4052 if (!PyArg_ParseTuple(args,
4054 ":is_property_overridable_library",
4061 PyErr_Format(PyExc_TypeError,
4062 "%.200s.is_property_overridable_library(\"%.200s\") not found",
4073 pyrna_struct_property_overridable_library_set_doc,
4074 ".. method:: property_overridable_library_set(property, overridable, /)\n"
4076 " Define a property as overridable or not (only for custom properties!).\n"
4078 " :param property: Property name.\n"
4079 " :type property: str\n"
4080 " :param overridable: Overridable status to set.\n"
4081 " :type overridable: bool\n"
4082 " :return: True when the overridable status of the property was successfully set.\n"
4092 if (!PyArg_ParseTuple(args,
4095 ":property_overridable_library_set",
4103 PyErr_Format(PyExc_TypeError,
4104 "%.200s.property_overridable_library_set(\"%.200s\") not found",
4110 return PyBool_FromLong(
4116 pyrna_struct_path_resolve_doc,
4117 ".. method:: path_resolve(path, coerce=True, /)\n"
4119 " Returns the property from the path, raise an exception when not found.\n"
4121 " :param path: path which this property resolves.\n"
4122 " :type path: str\n"
4123 " :param coerce: optional argument, when True, the property will be converted\n"
4124 " into its Python representation.\n"
4125 " :type coerce: bool\n"
4126 " :return: Property value or property object.\n"
4127 " :rtype: Any | :class:`bpy.types.bpy_prop`\n");
4131 PyObject *coerce = Py_True;
4138 if (!PyArg_ParseTuple(args,
4154 PyErr_Format(PyExc_IndexError,
4155 "%.200s.path_resolve(\"%.200s\") index out of range",
4164 if (coerce == Py_False) {
4174 PyErr_Format(PyExc_ValueError,
4175 "%.200s.path_resolve(\"%.200s\") could not be resolved",
4183 pyrna_struct_path_from_module_doc,
4184 ".. method:: path_from_module(property=\"\", index=-1, /)\n"
4186 " Returns the full data path to this struct (as a string) from the bpy module.\n"
4188 " :param property: Optional property name to get the full path from\n"
4189 " :type property: str\n"
4190 " :param index: Optional index of the property.\n"
4191 " \"-1\" means that the property has no indices.\n"
4192 " :type index: int\n"
4193 " :return: The full path to the data.\n"
4196 " :raises ValueError:\n"
4197 " if the input data cannot be converted into a full data path.\n"
4199 " .. note:: Even if all input data is correct, this function might\n"
4200 " error out because Blender cannot derive a valid path.\n"
4201 " The incomplete path will be printed in the error message.\n");
4204 const char *error_prefix =
"path_from_module(...)";
4205 const char *name =
nullptr;
4211 if (!PyArg_ParseTuple(args,
4215 ":path_from_module",
4222 PyErr_Format(PyExc_ValueError,
"%s: indices below -1 are not supported", error_prefix);
4226 std::optional<std::string> path;
4229 if (prop ==
nullptr) {
4230 PyErr_Format(PyExc_AttributeError,
4231 "%.200s.path_from_module(\"%.200s\") not found",
4249 PyErr_Format(PyExc_ValueError,
4250 "%.200s.path_from_module(\"%s\", %d) found, but does not support path creation",
4256 PyErr_Format(PyExc_ValueError,
4257 "%.200s.path_from_module() does not support path creation for this type",
4263 if (path.value().back() ==
'.') {
4264 PyErr_Format(PyExc_ValueError,
4265 "%.200s.path_from_module() could not derive a complete path for this type.\n"
4266 "Only got \"%.200s\" as an incomplete path",
4268 path.value().c_str());
4277 pyrna_prop_path_from_module_doc,
4278 ".. method:: path_from_module()\n"
4280 " Returns the full data path to this struct (as a string) from the bpy module.\n"
4282 " :return: The full path to the data.\n"
4285 " :raises ValueError:\n"
4286 " if the input data cannot be converted into a full data path.\n"
4288 " .. note:: Even if all input data is correct, this function might\n"
4289 " error out because Blender cannot derive a valid path.\n"
4290 " The incomplete path will be printed in the error message.\n");
4296 &self->
ptr.value(), prop, -1,
true);
4299 PyErr_Format(PyExc_ValueError,
4300 "%.200s.%.200s.path_from_module() does not support path creation for this type",
4306 if (path.value().back() ==
'.') {
4309 "%.200s.%.200s.path_from_module() could not derive a complete path for this type.\n"
4310 "Only got \"%.200s\" as an incomplete path",
4313 path.value().c_str());
4322 pyrna_struct_path_from_id_doc,
4323 ".. method:: path_from_id(property=\"\", /)\n"
4325 " Returns the data path from the ID to this object (string).\n"
4327 " :param property: Optional property name which can be used if the path is\n"
4328 " to a property of this object.\n"
4329 " :type property: str\n"
4330 " :return: The path from :class:`bpy.types.bpy_struct.id_data`\n"
4331 " to this struct and property (when given).\n"
4335 const char *name =
nullptr;
4340 if (!PyArg_ParseTuple(args,
4349 std::optional<std::string> path;
4352 if (prop ==
nullptr) {
4353 PyErr_Format(PyExc_AttributeError,
4354 "%.200s.path_from_id(\"%.200s\") not found",
4368 PyErr_Format(PyExc_ValueError,
4369 "%.200s.path_from_id(\"%s\") found, but does not support path creation",
4374 PyErr_Format(PyExc_ValueError,
4375 "%.200s.path_from_id() does not support path creation for this type",
4386 pyrna_prop_path_from_id_doc,
4387 ".. method:: path_from_id()\n"
4389 " Returns the data path from the ID to this property (string).\n"
4391 " :return: The path from :class:`bpy.types.bpy_struct.id_data` to this property.\n"
4401 PyErr_Format(PyExc_ValueError,
4402 "%.200s.%.200s.path_from_id() does not support path creation for this type",
4413 pyrna_prop_as_bytes_doc,
4414 ".. method:: as_bytes()\n"
4416 " Returns this string property as a byte rather than a Python string.\n"
4418 " :return: The string as bytes.\n"
4419 " :rtype: bytes\n");
4424 PyErr_Format(PyExc_TypeError,
4425 "%.200s.%.200s.as_bytes() must be a string",
4432 char buf_fixed[256], *buf;
4436 &self->
ptr.value(), self->
prop, buf_fixed,
sizeof(buf_fixed), &buf_len);
4438 ret = PyBytes_FromStringAndSize(buf, buf_len);
4440 if (buf_fixed != buf) {
4449 pyrna_prop_update_doc,
4450 ".. method:: update()\n"
4452 " Execute the properties update callback.\n"
4455 " This is called when assigning a property,\n"
4456 " however in rare cases it's useful to call explicitly.\n");
4465 pyrna_struct_type_recast_doc,
4466 ".. method:: type_recast()\n"
4468 " Return a new instance, this is needed because types\n"
4469 " such as textures can be changed at runtime.\n"
4471 " :return: a new instance of this object with the type initialized again.\n"
4472 " :rtype: :class:`bpy.types.bpy_struct`\n");
4487 PyObject *ret_test =
nullptr;
4488 PyObject *subclasses =
static_cast<PyObject *
>(
4489 (
reinterpret_cast<PyTypeObject *
>(cls))->tp_subclasses);
4494 PyObject *key =
nullptr;
4496 PyObject *value =
nullptr;
4497 while (PyDict_Next(subclasses, &pos, &key, &value)) {
4509 ret_test = value_ref;
4517 Py_DECREF(value_ref);
4529 pyrna_struct_bl_rna_get_subclass_py_doc,
4530 ".. classmethod:: bl_rna_get_subclass_py(id, default=None, /)\n"
4532 " :param id: The RNA type identifier.\n"
4534 " :param default: The value to return when not found.\n"
4535 " :type default: type | None\n"
4536 " :return: The class or default when not found.\n"
4541 PyObject *ret_default = Py_None;
4543 if (!PyArg_ParseTuple(args,
4547 ":bl_rna_get_subclass_py",
4554 if (
ret ==
nullptr) {
4557 return Py_NewRef(
ret);
4562 pyrna_struct_bl_rna_get_subclass_doc,
4563 ".. classmethod:: bl_rna_get_subclass(id, default=None, /)\n"
4565 " :param id: The RNA type identifier.\n"
4567 " :param default: The value to return when not found.\n"
4568 " :type default: :class:`bpy.types.Struct` | None\n"
4569 " :return: The RNA type or default when not found.\n"
4570 " :rtype: :class:`bpy.types.Struct`\n");
4574 PyObject *ret_default = Py_None;
4576 if (!PyArg_ParseTuple(args,
4580 ":bl_rna_get_subclass",
4589 if (py_srna ==
nullptr) {
4590 PyErr_SetString(PyExc_ValueError,
"Not a registered class");
4595 if (srna_base == RNA_Node) {
4612 return Py_NewRef(ret_default);
4617 pyrna_struct_get_ancestors_doc,
4618 ".. method:: rna_ancestors()\n"
4620 " Return the chain of data containing this struct, if known.\n"
4621 " The first item is the root (typically an ID), the last one is the immediate parent.\n"
4624 " :return: a list of this object's ancestors.\n"
4625 " :rtype: list[:class:`bpy.types.bpy_struct`]\n");
4631 const int ancestors_num(self->
ptr->ancestors.size());
4633 ret = PyList_New(ancestors_num);
4635 for (
int i = 0; i < ancestors_num; i++) {
4638 PyList_SET_ITEM(
ret, i, ancestor);
4648 list_tmp = PyDict_Keys(dict);
4650 Py_DECREF(list_tmp);
4656 PyObject **dict_ptr;
4658 dict_ptr = _PyObject_GetDictPtr(self);
4660 if (dict_ptr && (dict = *dict_ptr)) {
4664 dict = (
static_cast<PyTypeObject *
>(Py_TYPE(self)))->tp_dict;
4674 &self_prop->
ptr.value(), self_prop->
prop))
4677 dict = (
reinterpret_cast<PyTypeObject *
>(cls))->tp_dict;
4700 PyList_APPEND(
list, PyUnicode_FromString(idname));
4719 PyList_APPEND(
list, name_py);
4734 ret = PyList_New(0);
4742 if (self->
ptr->type == RNA_Context) {
4746 PyList_APPEND(
ret, PyUnicode_FromString(
static_cast<const char *
>(link.data)));
4749 lb.free_no_destruct();
4756 PyObject *set = PySet_New(
ret);
4759 ret = PySequence_List(set);
4768 pyrna_struct_id_properties_ensure_doc,
4769 ".. method:: id_properties_ensure()\n"
4771 " :return: the parent group for an RNA struct's custom IDProperties.\n"
4772 " :rtype: :class:`idprop.types.IDPropertyGroup`\n");
4778 PyErr_SetString(PyExc_TypeError,
"This type doesn't support IDProperties");
4786 if (idprops ==
nullptr) {
4792 group->
prop = idprops;
4794 return reinterpret_cast<PyObject *
>(group);
4799 pyrna_struct_id_properties_ui_doc,
4800 ".. method:: id_properties_ui(key, /)\n"
4802 " :param key: String name of the property.\n"
4804 " :return: An object used to manage an IDProperty's UI data.\n"
4805 " :rtype: :class:`idprop.types.IDPropertyUIManager` | None\n");
4811 PyErr_SetString(PyExc_TypeError,
"This type doesn't support IDProperties");
4816 if (!PyArg_ParseTuple(args,
4818 ":id_properties_ui",
4828 if (parent_group ==
nullptr) {
4833 if (property ==
nullptr) {
4834 PyErr_SetString(PyExc_KeyError,
"Property not found in IDProperty group");
4839 PyErr_Format(PyExc_TypeError,
"IDProperty \"%s\" does not support UI data", property->name);
4846 return reinterpret_cast<PyObject *
>(ui_manager);
4851 pyrna_struct_id_properties_clear_doc,
4852 ".. method:: id_properties_clear()\n"
4854 " Remove the parent group for an RNA struct's custom IDProperties.\n");
4860 PyErr_SetString(PyExc_TypeError,
"This type doesn't support IDProperties");
4877 const char *name = PyUnicode_AsUTF8(pyname);
4885 if (name ==
nullptr) {
4886 PyErr_SetString(PyExc_AttributeError,
"bpy_struct: __getattr__ must be a string");
4896 PyErr_SetString(PyExc_AttributeError,
"bpy_struct: no __getitem__ support for this type");
4900 ret = PyObject_GenericGetAttr(
reinterpret_cast<PyObject *
>(self), pyname);
4911 else if (self->
ptr->type == RNA_Context) {
4914 PyErr_Format(PyExc_AttributeError,
4915 "bpy_struct: Context is 'null', cannot get \"%.200s\" from context",
4925 std::optional<int64_t> newint;
4933 C, name, &newptr, &newlb, &newprop, &newindex, &newstr, &newint, &newtype));
4957 ret = PyUnicode_FromStringAndSize(newstr.
data(), newstr.
size());
4962 if (!newint.has_value()) {
4967 ret = PyLong_FromLong(*newint);
4972 ret = PyList_New(0);
4979 if (newprop !=
nullptr) {
4984 std::optional<std::string> path_str;
4997 ret = PyTuple_New(3);
5001 PyLong_FromLong(newindex));
5018 PyErr_Format(PyExc_AttributeError,
5019 "bpy_struct: Context type invalid %d, cannot get \"%.200s\" from context",
5032 ret = PyObject_GenericGetAttr(
reinterpret_cast<PyObject *
>(self), pyname);
5038 PyErr_Format(PyExc_AttributeError,
"bpy_struct: attribute \"%.200s\" not found", name);
5048 ret = PyObject_GenericGetAttr(
reinterpret_cast<PyObject *
>(self), pyname);
5055static int pyrna_struct_pydict_contains(PyObject *self, PyObject *pyname)
5057 PyObject *dict = *(_PyObject_GetDictPtr((PyObject *)self));
5058 if (dict ==
nullptr) [[unlikely]] {
5062 return PyDict_Contains(dict, pyname);
5069static PyObject *pyrna_struct_meta_idprop_getattro(PyObject *cls, PyObject *attr)
5071 PyObject *
ret = PyType_Type.tp_getattro(cls, attr);
5083 if ((
ret ==
nullptr) ) {
5093 if (
ret ==
nullptr) {
5094 PyErr_Format(PyExc_AttributeError,
5095 "StructRNA.__getattr__: attribute \"%.200s\" not found",
5096 PyUnicode_AsUTF8(attr));
5109 const char *attr_str = PyUnicode_AsUTF8(attr);
5114 PyErr_Format(PyExc_AttributeError,
5115 "pyrna_struct_meta_idprop_setattro() "
5116 "cannot set in readonly state '%.200s.%S'",
5117 (
reinterpret_cast<PyTypeObject *
>(cls))->tp_name,
5122 if (srna ==
nullptr) {
5125 if (value && is_deferred_prop) {
5126 PyErr_Format(PyExc_AttributeError,
5127 "pyrna_struct_meta_idprop_setattro() unable to get srna from class '%.200s'",
5128 ((PyTypeObject *)cls)->tp_name);
5134 return PyType_Type.tp_setattro(cls, attr, value);
5139 if (is_deferred_prop) {
5160 PyExc_TypeError,
"struct_meta_idprop.detattr(): '%s' not a dynamic property", attr_str);
5166 return PyType_Type.tp_setattro(cls, attr, value);
5171 const char *name = PyUnicode_AsUTF8(pyname);
5177#ifdef USE_PEDANTIC_WRITE
5183 if (name ==
nullptr) {
5184 PyErr_SetString(PyExc_AttributeError,
"bpy_struct: __setattr__ must be a string");
5189 PyErr_Format(PyExc_AttributeError,
5190 "bpy_struct: attribute \"%.200s\" from \"%.200s\" is read-only",
5202 PyErr_Format(PyExc_AttributeError,
5203 "bpy_struct: attribute \"%.200s\" from \"%.200s\" is read-only",
5208 else if (self->
ptr->type == RNA_Context) {
5213 PyErr_Format(PyExc_AttributeError,
5214 "bpy_struct: Context is 'null', cannot set \"%.200s\" from context",
5224 std::optional<int64_t> newint;
5228 CTX_data_get(
C, name, &newptr, &newlb, &newprop, &newindex, &newstr, &newint, &newtype));
5232 PyExc_AttributeError,
"bpy_struct: Context property \"%.200s\" is read-only", name);
5239 if (value ==
nullptr) {
5240 PyErr_SetString(PyExc_AttributeError,
"bpy_struct: del not supported");
5244 &self->
ptr.value(), prop,
nullptr, value,
"bpy_struct: item.attr = val:",
nullptr);
5247 return PyObject_GenericSetAttr(
reinterpret_cast<PyObject *
>(self), pyname, value);
5256 ret = PyList_New(0);
5275 return PyObject_GenericGetAttr(
reinterpret_cast<PyObject *
>(self), pyname);
5280 const char *name = PyUnicode_AsUTF8(pyname);
5282 if (name ==
nullptr) {
5283 PyErr_SetString(PyExc_AttributeError,
"bpy_prop_collection: __getattr__ must be a string");
5286 if (name[0] !=
'_') {
5303 Py_DECREF(self_collection);
5311 return PyObject_GenericGetAttr((PyObject *)self, pyname);
5318 PyObject *
ret = _PyObject_GenericGetAttrWithDict(
5319 reinterpret_cast<PyObject *
>(self), pyname,
nullptr, 1);
5322 if ((
ret ==
nullptr) && (name[0] !=
'_')) {
5328 ret = _PyObject_GenericGetAttrWithDict(cls, pyname,
nullptr, 1);
5331 if (
ret !=
nullptr) {
5332 if (Py_TYPE(
ret) == &PyMethodDescr_Type) {
5333 PyMethodDef *m = (
reinterpret_cast<PyMethodDescrObject *
>(
ret))->d_method;
5335 if (m->ml_flags & METH_STATIC) {
5340 ret = PyCMethod_New(m,
reinterpret_cast<PyObject *
>(self),
nullptr,
nullptr);
5347 if (
ret ==
nullptr) {
5349 PyExc_AttributeError,
"bpy_prop_collection: attribute \"%.200s\" not found", name);
5360 const char *name = PyUnicode_AsUTF8(pyname);
5363#ifdef USE_PEDANTIC_WRITE
5369 if (name ==
nullptr) {
5370 PyErr_SetString(PyExc_AttributeError,
"bpy_prop: __setattr__ must be a string");
5373 if (value ==
nullptr) {
5374 PyErr_SetString(PyExc_AttributeError,
"bpy_prop: del not supported");
5383 &c_ptr.value(), prop,
nullptr, value,
"BPy_PropertyRNA - Attribute (setattr):",
nullptr);
5387 PyErr_Format(PyExc_AttributeError,
"bpy_prop_collection: attribute \"%.200s\" not found", name);
5396 pyrna_prop_collection_idprop_add_doc,
5397 ".. method:: add()\n"
5399 " This is a function to add a new item to a collection.\n"
5401 " :return: A newly created item.\n"
5407#ifdef USE_PEDANTIC_WRITE
5415 PyErr_SetString(PyExc_TypeError,
5416 "bpy_prop_collection.add(): not supported for this collection");
5425 pyrna_prop_collection_idprop_remove_doc,
5426 ".. method:: remove(index)\n"
5428 " This is a function to remove an item from a collection.\n"
5430 " :param index: Index of the item to be removed.\n"
5431 " :type index: int\n");
5434 const int key = PyLong_AsLong(value);
5436#ifdef USE_PEDANTIC_WRITE
5442 if (key == -1 && PyErr_Occurred()) {
5443 PyErr_SetString(PyExc_TypeError,
"bpy_prop_collection.remove(): expected one int argument");
5448 PyErr_SetString(PyExc_TypeError,
5449 "bpy_prop_collection.remove() not supported for this collection");
5458 pyrna_prop_collection_idprop_clear_doc,
5459 ".. method:: clear()\n"
5461 " This is a function to remove all items from a collection.\n");
5464#ifdef USE_PEDANTIC_WRITE
5477 pyrna_prop_collection_idprop_move_doc,
5478 ".. method:: move(src_index, dst_index)\n"
5480 " This is a function to move an item in a collection.\n"
5482 " :param src_index: Source item index.\n"
5483 " :type src_index: int\n"
5484 " :param dst_index: Destination item index.\n"
5485 " :type dst_index: int\n");
5488 int src_index = 0, dst_index = 0;
5490#ifdef USE_PEDANTIC_WRITE
5496 if (!PyArg_ParseTuple(args,
5503 PyErr_SetString(PyExc_TypeError,
"bpy_prop_collection.move(): expected two ints as arguments");
5508 &self->
ptr.value(), self->
prop, src_index, dst_index);
5518 pyrna_struct_get_id_data_doc,
5519 "The :class:`bpy.types.ID` object this data-block is from or None, "
5520 "(not available for all data types) (readonly)\n"
5522 ":type: :class:`bpy.types.ID`\n");
5526 if (self->
ptr->owner_id) {
5536 pyrna_struct_get_data_doc,
5537 "The data this property is using, (readonly)\n"
5539 ":type: :class:`bpy.types.bpy_struct`\n");
5547 pyrna_struct_get_rna_type_doc,
5548 "The property type for introspection.\n"
5550 ":type: :class:`bpy.types.Property`\n");
5564 static_cast<setter
>(
nullptr),
5565 pyrna_struct_get_id_data_doc,
5569 static_cast<setter
>(
nullptr),
5570 pyrna_struct_get_data_doc,
5574 static_cast<setter
>(
nullptr),
5575 pyrna_struct_get_rna_type_doc,
5577 {
nullptr,
nullptr,
nullptr,
nullptr,
nullptr}
5583 static_cast<setter
>(
nullptr),
5584 pyrna_struct_get_id_data_doc,
5586 {
nullptr,
nullptr,
nullptr,
nullptr,
nullptr}
5594 static_cast<setter
>(
nullptr),
5597 {
nullptr,
nullptr,
nullptr,
nullptr,
nullptr}
5602 pyrna_prop_collection_keys_doc,
5603 ".. method:: keys()\n"
5605 " Return the identifiers of collection members\n"
5606 " (matching Python's dict.keys() functionality).\n"
5608 " :return: the identifiers for each member of this collection.\n"
5609 " :rtype: list[str]\n");
5612 PyObject *
ret = PyList_New(0);
5617 PyList_APPEND(
ret, name_py);
5627 pyrna_prop_collection_items_doc,
5628 ".. method:: items()\n"
5630 " Return the identifiers of collection members\n"
5631 " (matching Python's dict.items() functionality).\n"
5633 " :return: (key, value) pairs for each member of this collection.\n"
5634 " :rtype: list[tuple[str, :class:`bpy.types.bpy_struct`]]\n");
5637 PyObject *
ret = PyList_New(0);
5642 if (!itemptr) [[unlikely]] {
5646 PyObject *item = PyTuple_New(2);
5650 PyTuple_SET_ITEM(item, 0, name_py ? name_py : PyLong_FromLong(i));
5653 PyList_APPEND(
ret, item);
5664 pyrna_prop_collection_values_doc,
5665 ".. method:: values()\n"
5667 " Return the values of collection\n"
5668 " (matching Python's dict.values() functionality).\n"
5670 " :return: The members of this collection.\n"
5671 " :rtype: list[:class:`bpy.types.bpy_struct` | None]\n");
5680 pyrna_struct_get_doc,
5681 ".. method:: get(key, default=None, /)\n"
5683 " Returns the value of the custom property assigned to key or default\n"
5684 " when not found (matches Python's dictionary function of the same name).\n"
5686 " :param key: The key associated with the custom property.\n"
5688 " :param default: Optional argument for the value to return if\n"
5689 " *key* is not found.\n"
5690 " :type default: Any\n"
5691 " :return: Custom property value or default.\n"
5699 PyObject *def = Py_None;
5703 if (!PyArg_ParseTuple(args,
5716 PyErr_SetString(PyExc_TypeError,
"this type doesn't support IDProperties");
5729 return Py_NewRef(def);
5734 pyrna_struct_pop_doc,
5735 ".. method:: pop(key, default=None, /)\n"
5737 " Remove and return the value of the custom property assigned to key or default\n"
5738 " when not found (matches Python's dictionary function of the same name).\n"
5740 " :param key: The key associated with the custom property.\n"
5742 " :param default: Optional argument for the value to return if\n"
5743 " *key* is not found.\n"
5744 " :type default: Any\n"
5745 " :return: Custom property value or default.\n"
5753 PyObject *def =
nullptr;
5757 if (!PyArg_ParseTuple(args,
5770 PyErr_SetString(PyExc_TypeError,
"this type doesn't support IDProperties");
5782 if (
ret ==
nullptr) [[unlikely]] {
5790 if (def ==
nullptr) {
5791 PyErr_SetString(PyExc_KeyError,
"key not found");
5794 return Py_NewRef(def);
5799 pyrna_struct_as_pointer_doc,
5800 ".. method:: as_pointer()\n"
5802 " Returns the memory address which holds a pointer to Blender's internal data\n"
5804 " :return: int (memory address).\n"
5807 " .. note:: This is intended only for advanced script writers who need to\n"
5808 " pass blender data to their own C/Python modules.\n");
5811 return PyLong_FromVoidPtr(self->
ptr->data);
5816 pyrna_prop_collection_get_doc,
5817 ".. method:: get(key, default=None)\n"
5819 " Returns the value of the item assigned to key or default when not found\n"
5820 " (matches Python's dictionary function of the same name).\n"
5822 " :param key: The identifier for the collection member.\n"
5824 " For ``bpy.data`` collections a ``(name, library)`` tuple can also be used.\n"
5825 " *library* is the library filepath or ``None`` for data in the current file.\n"
5826 " :type key: str | tuple[str, str | None]\n"
5827 " :param default: Optional argument for the value to return if\n"
5828 " *key* is not found.\n"
5829 " :type default: Any\n"
5830 " :return: The collection member or default.\n"
5831 " :rtype: :class:`bpy_struct`\n");
5837 PyObject *def = Py_None;
5841 if (!PyArg_ParseTuple(args,
5852 if (PyUnicode_Check(key_ob)) {
5853 const char *key = PyUnicode_AsUTF8(key_ob);
5859 "bpy_prop_collection.get") == -1)
5864 else if (PyTuple_Check(key_ob)) {
5866 self, key_ob,
"bpy_prop_collection.get((id, lib))",
false);
5872 PyErr_Format(PyExc_KeyError,
5873 "bpy_prop_collection.get(key, ...): key must be a string or tuple, not %.200s",
5874 Py_TYPE(key_ob)->tp_name);
5877 return Py_NewRef(def);
5882 pyrna_prop_collection_find_doc,
5883 ".. method:: find(key)\n"
5885 " Returns the index of a key in a collection or -1 when not found\n"
5886 " (matches Python's string find function of the same name).\n"
5888 " :param key: The identifier for the collection member.\n"
5890 " :return: index of the key.\n"
5894 Py_ssize_t key_len_ssize;
5895 const char *key = PyUnicode_AsUTF8AndSize(key_ob, &key_len_ssize);
5896 const int key_len = int(key_len_ssize);
5898 char name[256], *name_ptr;
5909 const bool found = (key_len == name_len) && (memcmp(name_ptr, key, key_len) == 0);
5910 if (name != name_ptr) {
5911 MEM_delete(name_ptr);
5923 return PyLong_FromLong(
index);
5931 bool *r_attr_signed,
5935 bool attr_ok =
true;
5938 *r_attr_signed =
false;
5952 *r_is_empty =
false;
5963 const char *function_name,
5966 const char **r_attr,
5972 bool *r_attr_signed)
5974 *r_size = *r_attr_tot = 0;
5975 *r_attr_signed =
false;
5978 if (!PyArg_ParseTuple(args,
5988 if (!PySequence_Check(*r_seq) && PyObject_CheckBuffer(*r_seq)) {
5989 PyErr_Format(PyExc_TypeError,
5990 "%s(..) expected second argument to be a sequence or buffer, not a %.200s",
5992 Py_TYPE(*r_seq)->tp_name);
5997 *r_tot = PySequence_Size(*r_seq);
6010 if (array_tot == 0) {
6011 PyErr_Format(PyExc_TypeError,
6012 "%s(..) sequence length mismatch given %d, needed 0",
6019 bool is_empty =
false;
6020 if (!
foreach_attr_type(self, *r_attr, r_raw_type, r_attr_tot, r_attr_signed, &is_empty)) {
6021 PyErr_Format(PyExc_AttributeError,
6022 "%s(..) '%.200s.%200s[...]' elements have no attribute '%.200s'",
6031 PyErr_Format(PyExc_TypeError,
6032 "%s(..) sequence length mismatch given %d, needed 0",
6045 if ((*r_attr_tot) < 1) {
6049 const int target_tot = array_tot * (*r_attr_tot);
6052 if (target_tot != (*r_tot)) {
6053 PyErr_Format(PyExc_TypeError,
6054 "%s(..) sequence length mismatch given %d, needed %d",
6066 if (*r_size == 0 && *r_attr_tot != 0) {
6068 PyExc_AttributeError,
"%s(..): attribute does not support foreach method", function_name);
6076 const char f = format ? *format :
'B';
6081 return (f ==
'b') ?
true :
false;
6084 return (f ==
'B') ?
true :
false;
6088 return (f ==
'B') ?
true :
false;
6091 return (f ==
'h') ?
true :
false;
6094 return (f ==
'H') ?
true :
false;
6097 return (f ==
'H') ?
true :
false;
6100 return (f ==
'i') ?
true :
false;
6103 return (f ==
'I') ?
true :
false;
6106 return (f ==
'?') ?
true :
false;
6108 return (f ==
'f') ?
true :
false;
6110 return (f ==
'd') ?
true :
false;
6113 return (f ==
'q') ?
true :
false;
6116 return (f ==
'Q') ?
true :
false;
6119 return (f ==
'Q') ?
true :
false;
6129 PyObject *item =
nullptr;
6131 bool buffer_is_compat;
6132 void *
array =
nullptr;
6144 set ?
"foreach_set" :
"foreach_get",
6151 &attr_signed) == -1)
6161 buffer_is_compat =
false;
6162 if (PyObject_CheckBuffer(
seq)) {
6164 if (PyObject_GetBuffer(
seq, &buf, PyBUF_ND | PyBUF_FORMAT) == -1) {
6174 if (buffer_is_compat) {
6176 nullptr, &self->
ptr.value(), self->
prop, attr, buf.buf, raw_type, tot);
6179 PyBuffer_Release(&buf);
6184 if (!buffer_is_compat) {
6185 array = PyMem_Malloc(size * tot);
6187 for (; i < tot; i++) {
6188 item = PySequence_GetItem(
seq, i);
6206 (
static_cast<int *
>(
array))[i] =
int(PyC_Long_AsI32(item));
6212 (
static_cast<float *
>(
array))[i] =
float(PyFloat_AsDouble(item));
6215 (
static_cast<double *
>(
array))[i] = PyFloat_AsDouble(item);
6218 (
static_cast<int64_t *
>(
array))[i] = PyC_Long_AsI64(item);
6233 nullptr, &self->
ptr.value(), self->
prop, attr,
array, raw_type, tot);
6237 buffer_is_compat =
false;
6238 if (PyObject_CheckBuffer(
seq)) {
6241 if (PyObject_GetBuffer(
seq, &buf, PyBUF_ND | PyBUF_FORMAT | PyBUF_WRITABLE) == -1) {
6251 if (buffer_is_compat) {
6253 nullptr, &self->
ptr.value(), self->
prop, attr, buf.buf, raw_type, tot);
6256 PyBuffer_Release(&buf);
6261 if (!buffer_is_compat) {
6262 array = PyMem_Malloc(size * tot);
6265 nullptr, &self->
ptr.value(), self->
prop, attr,
array, raw_type, tot);
6272 for (; i < tot; i++) {
6276 item = PyLong_FromLong(
long((
static_cast<char *
>(
array))[i]));
6279 item = PyLong_FromLong(
long((
static_cast<int8_t *
>(
array))[i]));
6282 item = PyLong_FromLong(
long((
static_cast<uint8_t *
>(
array))[i]));
6285 item = PyLong_FromLong(
long((
static_cast<short *
>(
array))[i]));
6288 item = PyLong_FromLong(
long((
static_cast<uint16_t *
>(
array))[i]));
6291 item = PyLong_FromLong(
long((
static_cast<int *
>(
array))[i]));
6294 item = PyFloat_FromDouble(
double((
static_cast<float *
>(
array))[i]));
6297 item = PyFloat_FromDouble((
static_cast<double *
>(
array))[i]);
6300 item = PyBool_FromLong(
long((
static_cast<bool *
>(
array))[i]));
6303 item = PyLong_FromLongLong((
static_cast<int64_t *
>(
array))[i]);
6306 item = PyLong_FromUnsignedLongLong((
static_cast<uint64_t *
>(
array))[i]);
6316 PySequence_SetItem(
seq, i, item);
6326 if (PyErr_Occurred()) {
6329 PyErr_SetString(PyExc_TypeError,
"couldn't access the py sequence");
6333 PyErr_SetString(PyExc_RuntimeError,
"internal error setting the array");
6345 pyrna_prop_collection_foreach_get_doc,
6346 ".. method:: foreach_get(attr, seq)\n"
6348 " Fast access to a basic-type attribute within a collection.\n"
6350 " :param attr: Name of the item attribute to read (for example ``co``, ``normal`` or\n"
6351 " ``select``). The attribute must be a basic type (bool, int or float).\n"
6353 " For geometry attribute types, see :attr:`Attribute.data_type`.\n"
6354 " :type attr: str\n"
6355 " :param seq: Writable sequence or buffer receiving flattened values.\n"
6356 " For array attributes, the length must be ``len(collection) * array_length``.\n"
6357 " :type seq: MutableSequence[bool | int | float] | Buffer\n");
6367 pyrna_prop_collection_foreach_set_doc,
6368 ".. method:: foreach_set(attr, seq)\n"
6370 " Fast access to a basic-type attribute within a collection.\n"
6372 " :param attr: Name of the item attribute to write (for example ``co`` or\n"
6373 " ``select``). The attribute must be a basic type (bool, int or float).\n"
6375 " For geometry attribute types, see :attr:`Attribute.data_type`.\n"
6376 " :type attr: str\n"
6377 " :param seq: Sequence or buffer containing flattened values.\n"
6378 " For array attributes, the length must be ``len(collection) * array_length``.\n"
6379 " :type seq: Sequence[bool | int | float] | Buffer\n");
6391 PyObject *item =
nullptr;
6392 Py_ssize_t i, seq_size, size;
6393 void *
array =
nullptr;
6400 PyErr_SetString(PyExc_TypeError,
"foreach_get/set available only for int and float");
6404 if (!PyArg_ParseTuple(args,
6412 if (!PySequence_Check(
seq) && PyObject_CheckBuffer(
seq)) {
6415 "foreach_get/set expected second argument to be a sequence or buffer, not a %.200s",
6416 Py_TYPE(
seq)->tp_name);
6423 seq_size = PySequence_Size(
seq);
6425 if (size != seq_size) {
6426 PyErr_Format(PyExc_TypeError,
"expected sequence size %d, got %d", size, seq_size);
6432 if (PyObject_GetBuffer(
seq, &buf, PyBUF_ND | PyBUF_FORMAT | (do_set ? 0 : PyBUF_WRITABLE)) == -1)
6436 switch (prop_type) {
6438 array = PyMem_Malloc(
sizeof(
int) * size);
6440 for (i = 0; i < size; i++) {
6441 item = PySequence_GetItem(
seq, i);
6442 (
static_cast<int *
>(
array))[i] =
int(PyLong_AsLong(item));
6447 &self->
ptr.value(), self->
prop,
static_cast<const int *
>(
array));
6452 for (i = 0; i < size; i++) {
6453 item = PyLong_FromLong(
long((
static_cast<int *
>(
array))[i]));
6454 PySequence_SetItem(
seq, i, item);
6461 array = PyMem_Malloc(
sizeof(
float) * size);
6463 for (i = 0; i < size; i++) {
6464 item = PySequence_GetItem(
seq, i);
6465 (
static_cast<float *
>(
array))[i] =
float(PyFloat_AsDouble(item));
6470 &self->
ptr.value(), self->
prop,
static_cast<const float *
>(
array));
6474 &self->
ptr.value(), self->
prop,
static_cast<float *
>(
array));
6476 for (i = 0; i < size; i++) {
6477 item = PyFloat_FromDouble(
double((
static_cast<float *
>(
array))[i]));
6478 PySequence_SetItem(
seq, i, item);
6495 if (PyErr_Occurred()) {
6498 PyErr_SetString(PyExc_TypeError,
"couldn't access the py sequence");
6503 const char f = buf.format ? buf.format[0] : 0;
6504 if ((prop_type ==
PROP_INT && (buf.itemsize !=
sizeof(
int) || !
ELEM(f,
'l',
'i'))) ||
6505 (prop_type ==
PROP_FLOAT && (buf.itemsize !=
sizeof(
float) || f !=
'f')))
6507 PyBuffer_Release(&buf);
6508 PyErr_Format(PyExc_TypeError,
"incorrect sequence item type: %s", buf.format);
6512 switch (prop_type) {
6516 &self->
ptr.value(), self->
prop,
static_cast<const int *
>(buf.buf));
6525 &self->
ptr.value(), self->
prop,
static_cast<const float *
>(buf.buf));
6529 &self->
ptr.value(), self->
prop,
static_cast<float *
>(buf.buf));
6542 PyBuffer_Release(&buf);
6550 pyrna_prop_array_foreach_get_doc,
6551 ".. method:: foreach_get(seq)\n"
6553 " This is a function to give fast access to array data.\n"
6555 " :param seq: Buffer to read element values into, must match the length of this array.\n"
6556 " :type seq: MutableSequence[Any]\n");
6566 pyrna_prop_array_foreach_set_doc,
6567 ".. method:: foreach_set(seq)\n"
6569 " This is a function to give fast access to array data.\n"
6571 " :param seq: Element values to write, must match the length of this array.\n"
6572 " :type seq: Sequence[Any]\n");
6586 PyObject *iter =
nullptr;
6597 iter = PyObject_GetIter(
ret);
6606#ifndef USE_PYRNA_ITER
6609 BPy_PropertyRNA *self_property =
reinterpret_cast<BPy_PropertyRNA *
>(self);
6613 PyObject *iter =
nullptr;
6619 iter = PyObject_GetIter(
ret);
6629# pragma clang diagnostic push
6630# pragma clang diagnostic ignored "-Wcast-function-type"
6632# pragma GCC diagnostic push
6633# pragma GCC diagnostic ignored "-Wcast-function-type"
6640 {
"keys",
reinterpret_cast<PyCFunction
>(
pyrna_struct_keys), METH_NOARGS, pyrna_struct_keys_doc},
6644 pyrna_struct_values_doc},
6648 pyrna_struct_items_doc},
6650 {
"get",
reinterpret_cast<PyCFunction
>(
pyrna_struct_get), METH_VARARGS, pyrna_struct_get_doc},
6651 {
"pop",
reinterpret_cast<PyCFunction
>(
pyrna_struct_pop), METH_VARARGS, pyrna_struct_pop_doc},
6656 pyrna_struct_as_pointer_doc},
6661 METH_VARARGS | METH_KEYWORDS,
6665 METH_VARARGS | METH_KEYWORDS,
6678 METH_VARARGS | METH_KEYWORDS,
6679 pyrna_struct_is_property_set_doc},
6683 pyrna_struct_property_unset_doc},
6684 {
"is_property_hidden",
6687 pyrna_struct_is_property_hidden_doc},
6688 {
"is_property_readonly",
6691 pyrna_struct_is_property_readonly_doc},
6692 {
"is_property_overridable_library",
6695 pyrna_struct_is_property_overridable_library_doc},
6696 {
"property_overridable_library_set",
6699 pyrna_struct_property_overridable_library_set_doc},
6703 pyrna_struct_path_resolve_doc},
6707 pyrna_struct_path_from_id_doc},
6708 {
"path_from_module",
6711 pyrna_struct_path_from_module_doc},
6715 pyrna_struct_type_recast_doc},
6716 {
"bl_rna_get_subclass_py",
6718 METH_VARARGS | METH_CLASS,
6719 pyrna_struct_bl_rna_get_subclass_py_doc},
6720 {
"bl_rna_get_subclass",
6722 METH_VARARGS | METH_CLASS,
6723 pyrna_struct_bl_rna_get_subclass_doc},
6727 pyrna_struct_get_ancestors_doc},
6728 {
"__dir__",
reinterpret_cast<PyCFunction
>(
pyrna_struct_dir), METH_NOARGS,
nullptr},
6729 {
"id_properties_ensure",
6732 pyrna_struct_id_properties_ensure_doc},
6733 {
"id_properties_clear",
6736 pyrna_struct_id_properties_clear_doc},
6737 {
"id_properties_ui",
6740 pyrna_struct_id_properties_ui_doc},
6745 {
"callback_add", (PyCFunction)pyrna_callback_add, METH_VARARGS,
nullptr},
6746 {
"callback_remove", (PyCFunction)pyrna_callback_remove, METH_VARARGS,
nullptr},
6750 METH_VARARGS | METH_CLASS,
6754 METH_VARARGS | METH_CLASS,
6757 {
nullptr,
nullptr, 0,
nullptr},
6764 pyrna_prop_path_from_id_doc},
6765 {
"path_from_module",
6768 pyrna_prop_path_from_module_doc},
6772 pyrna_prop_as_bytes_doc},
6776 pyrna_prop_update_doc},
6777 {
"__dir__",
reinterpret_cast<PyCFunction
>(
pyrna_prop_dir), METH_NOARGS,
nullptr},
6778 {
nullptr,
nullptr, 0,
nullptr},
6785 pyrna_prop_array_foreach_get_doc},
6789 pyrna_prop_array_foreach_set_doc},
6791 {
nullptr,
nullptr, 0,
nullptr},
6798 pyrna_prop_collection_foreach_get_doc},
6802 pyrna_prop_collection_foreach_set_doc},
6807 pyrna_prop_collection_keys_doc},
6811 pyrna_prop_collection_items_doc},
6815 pyrna_prop_collection_values_doc},
6820 pyrna_prop_collection_get_doc},
6824 pyrna_prop_collection_find_doc},
6825 {
nullptr,
nullptr, 0,
nullptr},
6832 pyrna_prop_collection_idprop_add_doc},
6836 pyrna_prop_collection_idprop_remove_doc},
6840 pyrna_prop_collection_idprop_clear_doc},
6844 pyrna_prop_collection_idprop_move_doc},
6845 {
nullptr,
nullptr, 0,
nullptr},
6850# pragma clang diagnostic pop
6852# pragma GCC diagnostic pop
6882 for (a = 0; a <
len; a++) {
6883 PyTuple_SET_ITEM(
ret, a, PyBool_FromLong(((
bool *)
data)[a]));
6888 for (a = 0; a <
len; a++) {
6889 PyTuple_SET_ITEM(
ret, a, PyLong_FromLong(((
int *)
data)[a]));
6903 else if (
len == 9) {
6911 for (a = 0; a <
len; a++) {
6912 PyTuple_SET_ITEM(
ret, a, PyFloat_FromDouble(((
float *)
data)[a]));
6919 PyExc_TypeError,
"RNA Error: unknown array type \"%d\" (pyrna_param_to_py)", type);
6928 ret = PyBool_FromLong(*
static_cast<bool *
>(
data));
6931 ret = PyLong_FromLong(*
static_cast<int *
>(
data));
6934 ret = PyFloat_FromDouble(*
static_cast<float *
>(
data));
6937 const char *data_ch;
6943 data_ch =
static_cast<const char *
>(data_alloc->
array);
6945 BLI_assert((data_ch ==
nullptr) || strlen(data_ch) == data_ch_len);
6949 *
static_cast<char **
>(
data);
6950 data_ch_len = data_ch ? strlen(data_ch) : 0;
6953 if (data_ch ==
nullptr) [[unlikely]] {
6958#ifdef USE_STRING_COERCE
6960 ret = PyBytes_FromStringAndSize(data_ch, data_ch_len);
6966 ret = PyUnicode_FromStringAndSize(data_ch, data_ch_len);
6970 ret = PyBytes_FromString(buf);
6973 ret = PyUnicode_FromString(data_ch);
7024 ret = PyList_New(0);
7031 PyErr_Format(PyExc_TypeError,
"RNA Error: unknown type \"%d\" (pyrna_param_to_py)", type);
7044 const char *parm_name)
7046 const Py_ssize_t parm_name_len = strlen(parm_name);
7048 for (Py_ssize_t i = 0; i < nkw; i++) {
7049 PyObject *key = PyTuple_GET_ITEM(kwnames, i);
7050 if (PyUnicode_Check(key)) {
7051 Py_ssize_t key_buf_len;
7052 const char *key_buf = PyUnicode_AsUTF8AndSize(key, &key_buf_len);
7053 if ((parm_name_len == key_buf_len) && (memcmp(parm_name, key_buf, parm_name_len) == 0)) {
7054 return args[nargs + i];
7067 const int parm_index,
7069 const size_t error_maxncpy)
7073 if (parm_index == -1) {
7076 "%.200s.%.200s(): error with keyword argument \"%.200s\" - ",
7084 "%.200s.%.200s(): error with argument %d, \"%.200s\" - ",
7098 PyObject *
const *args,
7110 PyObject *
ret, *item;
7111 int i, parms_len, ret_len, flag_parameter, err = 0, kw_tot = 0;
7115 void *retdata_single =
nullptr;
7121#ifdef DEBUG_STRING_FREE
7122 PyObject *string_free_ls = PyList_New(0);
7128 if (self_ptr ==
nullptr) {
7129 PyErr_SetString(PyExc_RuntimeError,
7130 "RNA functions internal RNA pointer is null, this is a bug. aborting");
7134 if (self_func ==
nullptr) {
7137 "%.200s.<unknown>(): RNA function internal function is null, this is a bug. aborting",
7148 printf(
"pyrna_func_call > %.200s.%.200s : %.200s:%d\n",
7161 const Py_ssize_t pyargs_len = PyVectorcall_NARGS(nargsf);
7162 const Py_ssize_t pykw_len = kwnames ? PyTuple_GET_SIZE(kwnames) : 0;
7166 struct PyObjectLink {
7170 PyObjectLink *py_coerce_ls =
nullptr;
7177 if (pyargs_len + pykw_len > parms_len) {
7179 PyErr_Format(PyExc_TypeError,
7180 "%.200s.%.200s(): takes at most %d arguments, got %d",
7184 pyargs_len + pykw_len);
7195 if (pret_single ==
nullptr) {
7197 retdata_single = iter.
data;
7205 if (i < pyargs_len) {
7208 PyErr_Format(PyExc_TypeError,
7209 "%.200s.%.200s(): required parameter \"%.200s\" to be a keyword argument!",
7220 else if (kwnames !=
nullptr) {
7234 if (item ==
nullptr) {
7236 PyErr_Format(PyExc_TypeError,
7237 "%.200s.%.200s(): required parameter \"%.200s\" not specified",
7248#ifdef DEBUG_STRING_FREE
7250 if (PyUnicode_Check(item)) {
7251 PyList_APPEND(string_free_ls, PyUnicode_FromString(PyUnicode_AsUTF8(item)));
7258 char error_prefix[512];
7260 PyObject *value_coerce =
nullptr;
7263 if (value_coerce) [[unlikely]] {
7264 PyObjectLink *link =
static_cast<PyObjectLink *
>(alloca(
sizeof(*link)));
7265 link->next = py_coerce_ls;
7266 link->ob = value_coerce;
7267 py_coerce_ls = link;
7290 if (err == 0 && kwnames && (pykw_len > kw_tot)) [[unlikely]] {
7294 const char *arg_name, *bad_args_str, *good_args_str;
7295 bool found =
false, first =
true;
7297 for (Py_ssize_t i = 0; i < pykw_len; i++) {
7298 PyObject *key = PyTuple_GET_ITEM(kwnames, i);
7300 arg_name = PyUnicode_AsUTF8(key);
7304 if (arg_name ==
nullptr) {
7320 if (found ==
false) {
7347 "%.200s.%.200s(): was called with invalid keyword argument(s) (%s), expected (%s)",
7355 MEM_delete(bad_args_str);
7356 MEM_delete(good_args_str);
7378 ret = PyTuple_New(ret_len);
7398 if (
ret ==
nullptr) {
7405#ifdef DEBUG_STRING_FREE
7407 if (PyList_GET_SIZE(string_free_ls)) {
7408 printf(
"%.200s.%.200s(): has %d strings\n",
7411 int(PyList_GET_SIZE(string_free_ls)));
7414 Py_DECREF(string_free_ls);
7415# undef DEBUG_STRING_FREE
7422 if (py_coerce_ls) [[unlikely]] {
7423 for (PyObjectLink *link = py_coerce_ls; link; link = link->next) {
7424 Py_DECREF(link->ob);
7445 ret = PyUnicode_FromFormat(
"%.200s.%.200s(%.200s)\n%s",
7455 PyVarObject_HEAD_INIT(
nullptr, 0)
7456 "bpy_struct_meta_idprop",
7459 sizeof(PyHeapTypeObject),
7476 Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
7487#if defined(_MSC_VER)
7542static PyObject *
pyrna_struct_new(PyTypeObject *type, PyObject *args, PyObject * );
7547 PyVarObject_HEAD_INIT(
nullptr, 0)
7566 Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE
7567#ifdef USE_PYRNA_STRUCT_REFERENCE
7568 | Py_TPFLAGS_HAVE_GC
7572#ifdef USE_PYRNA_STRUCT_REFERENCE
7573 (traverseproc)pyrna_struct_traverse,
7574 (inquiry)pyrna_struct_clear,
7613 if (PyTuple_GET_SIZE(args) != 1) {
7614 PyErr_Format(PyExc_TypeError,
"bpy_struct.__new__(struct): expected a single argument");
7618 PyObject *arg_1 = PyTuple_GET_ITEM(args, 0);
7621 if (!PyCapsule_CheckExact(arg_1)) {
7627 "bpy_struct.__new__(struct): struct type '%.200s' is not a subtype of bpy_struct",
7628 Py_TYPE(base)->tp_name);
7632 if (Py_TYPE(base) == type) {
7635 return reinterpret_cast<PyObject *
>(base);
7642 PyObject *self = type->tp_alloc(type, 0);
7645#ifdef USE_PYRNA_STRUCT_REFERENCE
7648 PyObject_GC_UnTrack(self);
7650 self_struct->
ptr = std::nullopt;
7660 size_t args_num = PyTuple_GET_SIZE(args);
7661 if (args_num != 1) {
7662 PyErr_Format(PyExc_TypeError,
"bpy_struct.__init__(self, struct): expected a single argument");
7666 PyObject *arg_1 = PyTuple_GET_ITEM(args, 0);
7668 if (PyCapsule_CheckExact(arg_1)) {
7679 PyErr_Format(PyExc_TypeError,
7680 "bpy_struct.__init__(self, struct): struct type '%.200s' is not a subtype of "
7682 Py_TYPE(base_struct)->tp_name);
7686 if (base_struct == self_struct) {
7692 ptr = &base_struct->
ptr.value();
7695 if (ptr ==
nullptr) {
7696 PyErr_Format(PyExc_TypeError,
7697 "bpy_struct.__init__(self, struct): failed to get a valid PointerRNA data "
7698 "from the given `struct` argument");
7702 self_struct->
ptr.reset();
7703 self_struct->
ptr = *ptr;
7716 PyObject *error_type, *error_value, *error_traceback;
7717 PyErr_Fetch(&error_type, &error_value, &error_traceback);
7721#ifdef PYRNA_FREE_SUPPORT
7722 if (self_struct->freeptr && *self_struct->
ptr) {
7724 self_struct->
ptr->data =
nullptr;
7729 if (self_struct->in_weakreflist !=
nullptr) {
7730 PyObject_ClearWeakRefs(self);
7734#ifdef USE_PYRNA_STRUCT_REFERENCE
7735 if (self_struct->reference) {
7736 PyObject_GC_UnTrack(self);
7737 pyrna_struct_clear(self_struct);
7740 PyTypeObject *base = Py_TYPE(self)->tp_base;
7742 if (base && PyType_IS_GC(base)) {
7743 PyObject_GC_UnTrack(self);
7749 self_struct->
ptr.~optional();
7751 Py_TYPE(self)->tp_free(self);
7754 PyErr_Restore(error_type, error_value, error_traceback);
7786 PyVarObject_HEAD_INIT(
nullptr, 0)
7805 Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
7842 PyVarObject_HEAD_INIT(
nullptr, 0)
7861 Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
7898 PyVarObject_HEAD_INIT(
nullptr, 0)
7899 "bpy_prop_collection",
7917 Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
7955 PyVarObject_HEAD_INIT(
nullptr, 0)
7956 "bpy_prop_collection_idprop",
7974 Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
8012 if (PyTuple_GET_SIZE(args) != 1) {
8013 PyErr_Format(PyExc_TypeError,
"bpy_prop.__new__(property): expected a single argument");
8017 PyObject *arg_1 = PyTuple_GET_ITEM(args, 0);
8020 if (!PyCapsule_CheckExact(arg_1)) {
8026 "bpy_prop.__new__(property): property type '%.200s' is not a subtype of bpy_prop",
8027 Py_TYPE(base)->tp_name);
8031 if (Py_TYPE(base) == type) {
8034 return reinterpret_cast<PyObject *
>(base);
8041 PyObject *self = type->tp_alloc(type, 0);
8044 self_property->
ptr = std::nullopt;
8054 size_t args_num = PyTuple_GET_SIZE(args);
8055 if (args_num != 1) {
8056 PyErr_Format(PyExc_TypeError,
"bpy_prop.__init__(self, property): expected a single argument");
8060 PyObject *arg_1 = PyTuple_GET_ITEM(args, 0);
8063 if (PyCapsule_CheckExact(arg_1)) {
8069 if (pypropptr_rna) {
8070 ptr = pypropptr_rna->
ptr;
8071 prop = pypropptr_rna->
prop;
8081 "bpy_prop.__init__(self, property): property type '%.200s' is not a subtype of bpy_prop",
8082 Py_TYPE(base_property)->tp_name);
8086 if (base_property == self_property) {
8090 ptr = &base_property->
ptr.value();
8091 prop = base_property->
prop;
8094 self_property->
ptr = *ptr;
8095 self_property->
prop = prop;
8103 PyObject *error_type, *error_value, *error_traceback;
8104 PyErr_Fetch(&error_type, &error_value, &error_traceback);
8108 if (self_property->in_weakreflist !=
nullptr) {
8109 PyObject_ClearWeakRefs(self);
8113 self_property->
ptr.~optional();
8115 Py_TYPE(self)->tp_free(self);
8118 PyErr_Restore(error_type, error_value, error_traceback);
8125 size_t args_num = PyTuple_GET_SIZE(args);
8126 if (args_num != 1) {
8127 PyErr_Format(PyExc_TypeError,
8128 "bpy_prop_array.__init__(self, property): expected a single argument");
8132 PyObject *arg_1 = PyTuple_GET_ITEM(args, 0);
8135 if (PyCapsule_CheckExact(arg_1)) {
8141 if (pypropptr_rna) {
8142 ptr = pypropptr_rna->
ptr;
8143 prop = pypropptr_rna->
prop;
8151 PyErr_Format(PyExc_TypeError,
8152 "bpy_prop_array.__init__(self, property): property type '%.200s' is not a "
8153 "subtype of bpy_prop_array",
8154 Py_TYPE(base_property)->tp_name);
8158 if (base_property == self_property) {
8162 ptr = &base_property->
ptr.value();
8163 prop = base_property->
prop;
8166 self_property->
prop = prop;
8169 self_property->
ptr = *ptr;
8174#ifdef USE_PYRNA_ITER
8193 PyVarObject_HEAD_INIT(
nullptr, 0)
8194 "bpy_prop_collection_iter",
8209 PyObject_GenericGetAttr,
8252 if (PyTuple_GET_SIZE(args) != 1) {
8253 PyErr_Format(PyExc_TypeError,
8254 "bpy_prop_collection_iter.__new__(arg): expected a single argument");
8258 PyObject *arg_1 = PyTuple_GET_ITEM(args, 0);
8260 if (!PyCapsule_CheckExact(arg_1)) {
8261 PyErr_Format(PyExc_TypeError,
8262 "bpy_prop_collection_iter.__new__(arg): arg type '%.200s' is not a PyCapsule",
8263 Py_TYPE(arg_1)->tp_name);
8268 PyObject *self = type->tp_alloc(type, 0);
8271 if (self_prop_iter) {
8272 self_prop_iter->
iter = std::nullopt;
8283 size_t args_num = PyTuple_GET_SIZE(args);
8284 if (args_num != 1) {
8287 "bpy_prop_collection_iter.__init__(self, arg): expected at most a single argument");
8291 PyObject *arg_1 = PyTuple_GET_ITEM(args, 0);
8294 if (PyCapsule_CheckExact(arg_1)) {
8300 if (pypropptr_rna) {
8301 ptr = pypropptr_rna->
ptr;
8302 prop = pypropptr_rna->
prop;
8308 "bpy_prop_collection_iter.__init__(self, arg): arg type '%.200s' is not a PyCapsule",
8309 Py_TYPE(arg_1)->tp_name);
8312 if (self_prop_iter->
iter.has_value()) {
8314 self_prop_iter->
iter.reset();
8318 const_cast<PointerRNA *
>(ptr), prop, &self_prop_iter->
iter.value());
8326 PyObject *error_type, *error_value, *error_traceback;
8327 PyErr_Fetch(&error_type, &error_value, &error_traceback);
8332 if (self_property->in_weakreflist !=
nullptr) {
8333 PyObject_ClearWeakRefs(self);
8337 if (self_property->
iter.has_value()) {
8339 self_property->
iter.reset();
8342 Py_TYPE(self)->tp_free(self);
8345 PyErr_Restore(error_type, error_value, error_traceback);
8353 PyObject *pypropptr_rna = PyCapsule_New(
8356 PyObject *self = PyObject_CallOneArg(
8362 Py_DECREF(pypropptr_rna);
8365 self_property->in_weakreflist =
nullptr;
8377 self_property->
prop);
8384 if (self_property->
iter->valid ==
false) {
8387 if (self_property->
iter.has_value()) {
8389 self_property->
iter.reset();
8391 PyErr_SetNone(PyExc_StopIteration);
8397# ifdef USE_PYRNA_STRUCT_REFERENCE
8400 if (iter_data != Py_None) {
8405 pyrna_struct_reference_set(iter_data_struct, self);
8429 PyVarObject_HEAD_INIT(
nullptr, 0)
8448 Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_VECTORCALL,
8489 pyfunc->
func = func;
8495 PyErr_SetString(PyExc_MemoryError,
"couldn't create bpy_func object");
8501 return reinterpret_cast<PyObject *
>(pyfunc);
8507 PyObject *error_type, *error_value, *error_traceback;
8508 PyErr_Fetch(&error_type, &error_value, &error_traceback);
8513 if (self_func->in_weakreflist !=
nullptr) {
8514 PyObject_ClearWeakRefs(self);
8518 self_func->
ptr.~optional();
8520 Py_TYPE(self)->tp_free(self);
8523 PyErr_Restore(error_type, error_value, error_traceback);
8530 Py_INCREF(newclass);
8534 Py_DECREF(oldclass);
8565 const PointerRNA func_ptr = {
nullptr, srna,
nullptr};
8567 for (
const std::unique_ptr<FunctionRNA> &link : lb) {
8592 PyObject *py_base =
nullptr;
8597 if (base && base != srna) {
8603 if (py_base ==
nullptr) {
8630 PyObject *newclass = PyDict_GetItemString(
bpy_types_dict, idname);
8639 PyObject *tp_bases = (
reinterpret_cast<PyTypeObject *
>(newclass))->tp_bases;
8640 PyObject *tp_slots = PyDict_GetItem((
reinterpret_cast<PyTypeObject *
>(newclass))->tp_dict,
8643 if (tp_slots ==
nullptr) {
8645 BPY_LOG_RNA,
"expected class '%s' to have __slots__ defined, see _bpy_types.py", idname);
8648 else if (PyTuple_GET_SIZE(tp_bases)) {
8649 PyObject *base = PyTuple_GET_ITEM(tp_bases, 0);
8651 if (base_compare != base) {
8652 char pyob_info[256];
8655 "incorrect subclassing of SRNA '%s', expected '%s', see _bpy_types.py",
8676 PyObject *newclass =
nullptr;
8679 if (srna ==
nullptr) {
8684 Py_INCREF(newclass);
8689 Py_INCREF(newclass);
8704 PyObject *metaclass;
8711 descr =
"(no docs)";
8716 !PyObject_IsSubclass(py_base,
8722 metaclass =
reinterpret_cast<PyObject *
>(&PyType_Type);
8727 newclass = PyObject_CallFunction(
8728 metaclass,
"s(O) {sss()}", idname, py_base,
"__module__",
"bpy.types",
"__slots__");
8732 PyObject *args, *item, *value;
8735 args = PyTuple_New(3);
8738 PyTuple_SET_ITEM(args, 0, PyUnicode_FromString(idname));
8741 PyTuple_SET_ITEM(args, 1, item = PyTuple_New(1));
8742 PyTuple_SET_ITEM(item, 0, Py_NewRef(py_base));
8745 PyTuple_SET_ITEM(args, 2, item = PyDict_New());
8752 newclass = PyObject_CallObject(metaclass, args);
8783 if (ptr->
type == RNA_Struct) {
8811 PyObject *pyptr_rna = PyCapsule_New(
8817 PyObject_CallOneArg(
reinterpret_cast<PyObject *
>(tp), pyptr_rna));
8823 PyObject_CallOneArg(
reinterpret_cast<PyObject *
>(&
pyrna_struct_Type), pyptr_rna));
8826#ifdef USE_PYRNA_STRUCT_REFERENCE
8829 if (pyrna !=
nullptr) {
8830 PyObject_GC_UnTrack(pyrna);
8835 if (pyrna !=
nullptr) {
8836 pyrna->in_weakreflist =
nullptr;
8841 Py_DECREF(pyptr_rna);
8842 if (pyrna ==
nullptr) {
8843 if (!PyErr_Occurred()) {
8844 PyErr_SetString(PyExc_MemoryError,
"couldn't create bpy_struct object");
8855#ifdef PYRNA_FREE_SUPPORT
8856 pyrna->freeptr =
false;
8859#ifdef USE_PYRNA_STRUCT_REFERENCE
8860 pyrna->reference =
nullptr;
8865#ifdef USE_PYRNA_INVALIDATE_WEAKREF
8871 return reinterpret_cast<PyObject *
>(pyrna);
8887 if (instance && *instance) {
8891 if (ptr->
type == pyrna->
ptr->type) {
8893 return reinterpret_cast<PyObject *
>(pyrna);
8898 *instance =
nullptr;
8907 return reinterpret_cast<PyObject *
>(pyrna);
8912 if (ptr->
type == RNA_PrimitiveString) {
8916 if (ptr->
type == RNA_PrimitiveInt) {
8918 return PyLong_FromLong(
data->value);
8920 if (ptr->
type == RNA_PrimitiveFloat) {
8922 return PyFloat_FromDouble(
data->value);
8924 if (ptr->
type == RNA_PrimitiveBoolean) {
8926 return PyBool_FromLong(
data->value);
8952 PyObject *pypropptr_rna = PyCapsule_New(
8956 PyObject_CallOneArg(
reinterpret_cast<PyObject *
>(type), pypropptr_rna));
8959 Py_DECREF(pypropptr_rna);
8960 if (pyrna ==
nullptr) {
8961 PyErr_SetString(PyExc_MemoryError,
"couldn't create BPy_rna object");
8966 pyrna->in_weakreflist =
nullptr;
8969#ifdef USE_PYRNA_INVALIDATE_WEAKREF
8975 return reinterpret_cast<PyObject *
>(pyrna);
8991 *
id = (
reinterpret_cast<BPy_StructRNA *
>(obj))->ptr->owner_id;
9013#if defined(_MSC_VER)
9046#ifdef USE_PYRNA_ITER
9052#ifdef USE_PYRNA_INVALIDATE_WEAKREF
9060#ifdef USE_PYRNA_INVALIDATE_WEAKREF
9065 const int id_weakref_pool_len =
BLI_ghash_len(id_weakref_pool);
9066 if (id_weakref_pool_len != 0) {
9067 printf(
"Found %d unreleased ID's\n", id_weakref_pool_len);
9074 BLI_ghash_free(id_weakref_pool,
nullptr, id_weakref_pool_free_value_fn);
9075 id_weakref_pool =
nullptr;
9090 return reinterpret_cast<PyObject *
>(pyrna);
9107PyObject *BPY_rna_doc()
9129 std::optional<PointerRNA>
ptr;
9141 const char *name = PyUnicode_AsUTF8(pyname);
9143 if (name ==
nullptr) {
9144 PyErr_SetString(PyExc_AttributeError,
"bpy.types: __getattr__ must be a string");
9150 if (
ret ==
nullptr) {
9151 PyErr_Format(PyExc_RuntimeError,
9152 "bpy.types.%.200s subtype could not be generated, this is a bug!",
9153 PyUnicode_AsUTF8(pyname));
9158 PyErr_Format(PyExc_AttributeError,
9159 "bpy.types.%.200s RNA_Struct does not exist",
9160 PyUnicode_AsUTF8(pyname));
9164 ret = PyObject_GenericGetAttr(self, pyname);
9175 PyObject *
ret = PyList_New(0);
9184 PyObject *submodule_dict = PyModule_GetDict(self);
9185 PyObject *key, *value;
9187 while (PyDict_Next(submodule_dict, &pos, &key, &value)) {
9188 PyList_Append(
ret, key);
9195# pragma clang diagnostic push
9196# pragma clang diagnostic ignored "-Wcast-function-type"
9198# pragma GCC diagnostic push
9199# pragma GCC diagnostic ignored "-Wcast-function-type"
9206 {
nullptr,
nullptr, 0,
nullptr},
9211# pragma clang diagnostic pop
9213# pragma GCC diagnostic pop
9223 PyObject *submodule =
static_cast<PyObject *
>(self);
9225 PyModule_GetState(submodule));
9227 state->ptr.~optional();
9232 bpy_types_module_doc,
9233 "Access to internal Blender types.");
9237 bpy_types_module_doc,
9250 PyModule_GetState(submodule));
9257 static PyTypeObject *pyrna_types[] = {
9267 PyObject *submodule_dict = PyModule_GetDict(submodule);
9268 for (
int i = 0; i <
ARRAY_SIZE(pyrna_types); i += 1) {
9269 PyDict_SetItemString(
9270 submodule_dict, pyrna_types[i]->tp_name,
reinterpret_cast<PyObject *
>(pyrna_types[i]));
9290 PyModule_GetState(submodule));
9293 PyObject *arg_key, *arg_value;
9294 Py_ssize_t arg_pos = 0;
9295 while (PyDict_Next(
bpy_types_dict, &arg_pos, &arg_key, &arg_value)) {
9296 const char *key_str = PyUnicode_AsUTF8(arg_key);
9297 if (key_str[0] ==
'_') {
9303 "Members of _bpy_types.py which are not StructRNA sub-classes must use a \"_\" prefix!");
9319 if (
STREQ(key_str,
"USDHook")) {
9324 BPY_LOG_RNA,
"_bpy_types.py defines \"%.200s\" which is not a known RNA type!", key_str);
9344 if (PyType_Check(self)) {
9347 Py_XINCREF(py_srna);
9353 if (py_srna ==
nullptr) {
9358 if (py_srna ==
nullptr) {
9359 PyErr_Format(PyExc_RuntimeError,
9360 "%.200s, missing bl_rna attribute from '%.200s' instance (may not be registered)",
9362 Py_TYPE(self)->tp_name);
9367 PyErr_Format(PyExc_TypeError,
9368 "%.200s, bl_rna attribute wrong type '%.200s' on '%.200s'' instance",
9370 Py_TYPE(py_srna)->tp_name,
9371 Py_TYPE(self)->tp_name);
9376 if (py_srna->
ptr->type != RNA_Struct) {
9377 PyErr_Format(PyExc_TypeError,
9378 "%.200s, bl_rna attribute not a RNA_Struct, on '%.200s'' instance",
9380 Py_TYPE(self)->tp_name);
9395 PyErr_Format(PyExc_TypeError,
9396 "Expected a \"bpy.types.%.200s\" not a \"%.200s\"",
9398 Py_TYPE(py_obj)->tp_name);
9402 return &bpy_srna->
ptr.value();
9407 if (py_obj == Py_None) {
9419 if (srna_parse->
ptr ==
nullptr) {
9430 if (srna_parse->
ptr ==
nullptr) {
9440 if (self ==
nullptr) {
9443 if (PyCapsule_CheckExact(self)) {
9444 return static_cast<StructRNA *
>(PyCapsule_GetPointer(self,
nullptr));
9446 if (PyType_Check(self) == 0) {
9470 PyObject *py_func =
static_cast<PyObject *
>((
reinterpret_cast<BPy_PropDeferred *
>(item))->fn);
9475 PyMethodDef *py_func_method_def = (
reinterpret_cast<PyCFunctionObject *
>(py_func))->m_ml;
9476 const char *func_name = py_func_method_def->ml_name;
9478 const char *key_str = PyUnicode_AsUTF8(key);
9480 if (*key_str ==
'_') {
9481 PyErr_Format(PyExc_ValueError,
9482 "bpy_struct \"%.200s\" registration error: "
9483 "'%.200s' %.200s could not register because it starts with an '_'",
9490 PyObject *type = PyDict_GetItemString(py_kw,
"type");
9494 PyCFunctionWithKeywords py_func_ref = *(
9495 PyCFunctionWithKeywords)(
void *)PyCFunction_GET_FUNCTION(py_func);
9499 PyErr_Format(PyExc_ValueError,
9500 "bpy_struct \"%.200s\" registration error: "
9501 "'%.200s' %.200s could not register because "
9502 "this type doesn't support data-block properties",
9512 PyObject *py_srna_cobject = PyCapsule_New(srna,
nullptr,
nullptr);
9517 PyObject *args_fake = PyTuple_New(1);
9518 PyTuple_SET_ITEM(args_fake, 0, py_srna_cobject);
9520 PyObject *py_ret = PyObject_Call(py_func, args_fake, py_kw);
9524 Py_DECREF(args_fake);
9530 Py_DECREF(args_fake);
9532 PyErr_Format(PyExc_ValueError,
9533 "bpy_struct \"%.200s\" registration error: "
9534 "'%.200s' %.200s could not register (see previous error)",
9549 PyObject *annotations_dict =
nullptr;
9553 PyObject *typing_mod = PyImport_ImportModuleLevel(
"typing",
nullptr,
nullptr,
nullptr, 0);
9554 if (typing_mod !=
nullptr) {
9555 PyObject *get_type_hints_fn = PyObject_GetAttrString(typing_mod,
"get_type_hints");
9556 if (get_type_hints_fn !=
nullptr) {
9557 PyObject *args = PyTuple_New(1);
9559 PyTuple_SET_ITEM(args, 0, (PyObject *)py_class);
9560 Py_INCREF(py_class);
9562 annotations_dict = PyObject_CallObject(get_type_hints_fn, args);
9565 Py_DECREF(get_type_hints_fn);
9567 Py_DECREF(typing_mod);
9572 if (annotations_dict !=
nullptr) {
9573 if (PyDict_CheckExact(annotations_dict)) {
9574 PyObject *item, *key;
9577 while (PyDict_Next(annotations_dict, &pos, &key, &item)) {
9586 PyErr_Format(PyExc_TypeError,
9587 "typing.get_type_hints returned: %.200s, expected dict\n",
9588 Py_TYPE(annotations_dict)->tp_name);
9592 Py_DECREF(annotations_dict);
9596 fprintf(stderr,
"typing.get_type_hints failed with: %.200s\n", py_class->tp_name);
9605 PyObject *annotations_dict;
9606 PyObject *item, *key;
9613 PyDict_CheckExact(annotations_dict))
9615 while (PyDict_Next(annotations_dict, &pos, &key, &item)) {
9629 const int len = PyTuple_GET_SIZE(py_class->tp_bases);
9633 for (i = 0; i <
len; i++) {
9634 PyTypeObject *py_superclass =
reinterpret_cast<PyTypeObject *
> PyTuple_GET_ITEM(
9635 py_class->tp_bases, i);
9646 if (py_superclass != &PyBaseObject_Type &&
9647 !PyObject_IsSubclass(
reinterpret_cast<PyObject *
>(py_superclass),
9671#ifdef USE_POSTPONED_ANNOTATIONS
9672 const bool use_postponed_annotations =
true;
9674 const bool use_postponed_annotations =
false;
9677 if (use_postponed_annotations) {
9688 int count = is_staticmethod ? 0 : 1;
9689 bool done_min_count =
false;
9691 for (
const Link &link : lb->cast<
Link>()) {
9699 done_min_count =
true;
9705 if (!done_min_count && min_count) {
9722 bool *have_function)
9726 PyObject *py_class =
static_cast<PyObject *
>(py_data);
9728 int i, arg_count, func_arg_count, func_arg_min_count = 0;
9729 const char *py_class_name = (
reinterpret_cast<PyTypeObject *
>(py_class))->tp_name;
9738 if (!PyObject_IsSubclass(py_class, base_class)) {
9739 PyErr_Format(PyExc_TypeError,
9740 "expected %.200s subclass of class \"%.200s\"",
9750 for (
const std::unique_ptr<FunctionRNA> &link : lb_func) {
9764 PyErr_Format(PyExc_AttributeError,
9765 "expected %.200s, %.200s class to have an \"%.200s\" attribute",
9778 have_function[i] = (item !=
nullptr);
9781 if (item ==
nullptr) {
9792 PyObject *item_orig = item;
9794 if (is_staticmethod) {
9795 if (PyMethod_Check(item) == 0) {
9796 PyErr_Format(PyExc_TypeError,
9797 "expected %.200s, %.200s class \"%.200s\" "
9798 "attribute to be a static/class method, not a %.200s",
9802 Py_TYPE(item)->tp_name);
9803 Py_DECREF(item_orig);
9806 item = (
reinterpret_cast<PyMethodObject *
>(item))->im_func;
9809 if (PyFunction_Check(item) == 0) {
9810 PyErr_Format(PyExc_TypeError,
9811 "expected %.200s, %.200s class \"%.200s\" "
9812 "attribute to be a function, not a %.200s",
9816 Py_TYPE(item)->tp_name);
9817 Py_DECREF(item_orig);
9824 if (func_arg_count >= 0) {
9825 arg_count = (
reinterpret_cast<PyCodeObject *
>(PyFunction_GET_CODE(item))->co_argcount);
9830 if (is_staticmethod) {
9832 func_arg_min_count++;
9835 if (arg_count < func_arg_min_count || arg_count > func_arg_count) {
9836 if (func_arg_min_count != func_arg_count) {
9839 "expected %.200s, %.200s class \"%.200s\" function to have between %d and %d "
9851 "expected %.200s, %.200s class \"%.200s\" function to have %d args, found %d",
9858 Py_DECREF(item_orig);
9862 Py_DECREF(item_orig);
9867 const char *rna_attr;
9869 } bpy_property_substitutions[] = {
9876 for (
Link &link : *
reinterpret_cast<const ListBaseT<Link> *
>(lb_prop)) {
9885 PyObject *item =
nullptr;
9886 switch (PyObject_GetOptionalAttrString(py_class, identifier, &item)) {
9888 if (
pyrna_py_to_prop(dummy_ptr, prop,
nullptr, item,
"validating class:",
nullptr) != 0) {
9905 for (i = 0; i <
ARRAY_SIZE(bpy_property_substitutions); i += 1) {
9906 if (
STREQ(identifier, bpy_property_substitutions[i].rna_attr)) {
9911 if (i <
ARRAY_SIZE(bpy_property_substitutions)) {
9912 PyObject *py_attr = bpy_property_substitutions[i].py_attr;
9913 switch (PyObject_GetOptionalAttr(py_class, py_attr, &item)) {
9915 if (item == Py_None) [[unlikely]] {
9921 dummy_ptr, prop,
nullptr, item,
"validating class:",
nullptr) != 0)
9938 PyErr_Format(PyExc_AttributeError,
9939 "expected %.200s, %.200s class to have an \"%.200s\" attribute",
9962 PyObject *
ret =
nullptr, *py_srna =
nullptr, *py_class_instance =
nullptr, *parmitem;
9963 PyTypeObject *py_class;
9967 int err = 0, i, ret_len = 0;
9973 void *retdata_single =
nullptr;
9975 PyGILState_STATE gilstate;
9977#ifdef USE_PEDANTIC_WRITE
9987 if (py_class ==
nullptr) {
9989 "unable to get Python class for RNA struct '%.200s'",
10006 if (!(is_staticmethod || is_classmethod)) {
10013 py_class_instance =
static_cast<PyObject *
>(*instance);
10014 Py_INCREF(py_class_instance);
10020 if (py_class_instance ==
nullptr) {
10024 if (py_class_instance) {
10027 else if (py_srna ==
nullptr) {
10028 py_class_instance =
nullptr;
10029 if (PyErr_Occurred()) {
10033 else if (py_srna == Py_None) {
10034 Py_DECREF(py_srna);
10035 py_class_instance =
nullptr;
10036 if (PyErr_Occurred()) {
10047 if (py_class->tp_init) {
10048# ifdef USE_PEDANTIC_WRITE
10055 args = PyTuple_New(0);
10056 if (py_class->tp_init(py_srna, args,
nullptr) < 0) {
10057 Py_DECREF(py_srna);
10062# ifdef USE_PEDANTIC_WRITE
10066 py_class_instance = py_srna;
10069# ifdef USE_PEDANTIC_WRITE
10078 py_class_instance = py_srna;
10079 Py_INCREF(py_class_instance);
10086 py_class_instance = PyObject_CallOneArg(
reinterpret_cast<PyObject *
>(py_class), py_srna);
10088# ifdef USE_PEDANTIC_WRITE
10094 if (py_class_instance ==
nullptr) {
10095 if (PyErr_Occurred()) {
10100 Py_DECREF(py_srna);
10105 if (err != -1 && (is_staticmethod || is_classmethod || py_class_instance)) {
10106 PyObject *item = PyObject_GetAttrString(
reinterpret_cast<PyObject *
>(py_class),
10109 const bool item_type_valid = (item !=
nullptr) &&
10110 (is_staticmethod ? PyMethod_Check(item) : PyFunction_Check(item));
10111 if (item_type_valid) {
10118 if (is_staticmethod) {
10119 arg_count = (
reinterpret_cast<PyCodeObject *
>(
10120 PyFunction_GET_CODE(((PyMethodObject *)item)->im_func)))
10125 arg_count = (
reinterpret_cast<PyCodeObject *
>(PyFunction_GET_CODE(item)))->co_argcount;
10127 args = PyTuple_New(arg_count);
10129 if (is_staticmethod) {
10132 else if (is_classmethod) {
10133 PyTuple_SET_ITEM(args, 0, (PyObject *)py_class);
10137 PyTuple_SET_ITEM(args, 0, py_class_instance);
10150 if (pret_single ==
nullptr) {
10151 pret_single = parm;
10152 retdata_single = iter.
data;
10158 if (i < arg_count) {
10160 PyTuple_SET_ITEM(args, i, parmitem);
10165#ifdef USE_PEDANTIC_WRITE
10172 ret = PyObject_Call(item, args,
nullptr);
10176#ifdef USE_PEDANTIC_WRITE
10186 PyErr_Format(PyExc_TypeError,
10187 "could not find function %.200s in %.200s to execute callback",
10196 PyErr_Format(PyExc_RuntimeError,
10197 "could not create instance of %.200s to call callback function '%.200s'",
10204 if (
ret ==
nullptr) {
10208 if (ret_len == 0 &&
ret != Py_None) {
10209 PyErr_Format(PyExc_RuntimeError,
10210 "expected class %.200s, function %.200s to return None, not %.200s",
10213 Py_TYPE(
ret)->tp_name);
10216 else if (ret_len == 1) {
10225 "class %.200s, function %.200s: incompatible return value ",
10230 else if (ret_len > 1) {
10232 if (PyTuple_Check(
ret) == 0) {
10234 PyExc_RuntimeError,
10235 "expected class %.200s, function %.200s to return a tuple of size %d, not %.200s",
10239 Py_TYPE(
ret)->tp_name);
10242 else if (PyTuple_GET_SIZE(
ret) != ret_len) {
10243 PyErr_Format(PyExc_RuntimeError,
10244 "class %.200s, function %.200s to returned %d items, expected %d",
10247 PyTuple_GET_SIZE(
ret),
10264 PyTuple_GET_ITEM(
ret, i++),
10265 "calling class function:",
10282 if ((!is_staticmethod) && (!is_classmethod) && (*ptr) &&
10304 "Python script error in %.200s.%.200s",
10319#ifdef WITH_PYTHON_MODULE
10329 if (!Py_IsInitialized()) {
10334 PyGILState_STATE gilstate = PyGILState_Ensure();
10349 if (self->ob_refcnt > 1) {
10350 PyC_ObSpit(
"zombie class - reference should be 1", self);
10359 PyGILState_Release(gilstate);
10367 bool decref =
false;
10376 if (PyObject *bases = cls->tp_bases) {
10377 const int bases_num = PyTuple_GET_SIZE(bases);
10378 for (
int i = 0; i < bases_num; i++) {
10379 PyTypeObject *base_cls =
reinterpret_cast<PyTypeObject *
> PyTuple_GET_ITEM(bases, i);
10381 if (base_cls->tp_dict) {
10394 return base_cls_test;
10406 PyTypeObject *
result =
nullptr;
10407 PyObject *subclasses =
static_cast<PyObject *
>(cls->tp_subclasses);
10410 PyObject *key =
nullptr;
10411 Py_ssize_t pos = 0;
10412 PyObject *value =
nullptr;
10413 while (PyDict_Next(subclasses, &pos, &key, &value)) {
10420 PyTypeObject *sub_cls =
reinterpret_cast<PyTypeObject *
>(value_ref);
10421 if (sub_cls->tp_dict) {
10438 Py_DECREF(value_ref);
10455 PyGILState_STATE gilstate = PyGILState_Ensure();
10465 if (item ==
nullptr) {
10466 if (PyErr_Occurred()) {
10476 PyGILState_Release(gilstate);
10486 bool decref =
true;
10498#define BPY_TYPEDEF_REGISTERABLE_DOC \
10500 ":class:`bpy.types.Panel` | " \
10501 ":class:`bpy.types.UIList` | " \
10502 ":class:`bpy.types.Menu` | " \
10503 ":class:`bpy.types.Header` | " \
10504 ":class:`bpy.types.Operator` | " \
10505 ":class:`bpy.types.KeyingSetInfo` | " \
10506 ":class:`bpy.types.RenderEngine` | " \
10507 ":class:`bpy.types.AssetShelf` | " \
10508 ":class:`bpy.types.FileHandler` | " \
10509 ":class:`bpy.types.PropertyGroup` | " \
10510 ":class:`bpy.types.AddonPreferences` | " \
10511 ":class:`bpy.types.NodeTree` | " \
10512 ":class:`bpy.types.Node` | " \
10513 ":class:`bpy.types.NodeSocket` | " \
10514 ":class:`bpy.types.Gizmo` | " \
10515 ":class:`bpy.types.GizmoGroup`" \
10531 pyrna_register_class_doc,
10532 ".. function:: register_class(cls)\n"
10534 " Register a subclass of a Blender type class.\n"
10536 " :param cls: Registerable Blender class type.\n"
10540 " :raises ValueError:\n"
10541 " if the class is not a subclass of a registerable blender class.\n"
10545 " If the class has a *register* class method it will be called\n"
10546 " before registration.\n");
10556 const char *identifier;
10557 PyObject *py_cls_meth;
10558 const char *error_prefix =
"register_class(...):";
10560 if (!PyType_Check(py_class)) {
10561 PyErr_Format(PyExc_ValueError,
10562 "%s expected a class argument, not '%.200s'",
10564 Py_TYPE(py_class)->tp_name);
10570 PyErr_Format(PyExc_ValueError,
10571 "%s already registered as a subclass '%.200s'",
10573 (
reinterpret_cast<PyTypeObject *
>(py_class))->tp_name);
10578 PyErr_Format(PyExc_RuntimeError,
10579 "%s cannot run in readonly state '%.200s'",
10581 (
reinterpret_cast<PyTypeObject *
>(py_class))->tp_name);
10587 if (srna ==
nullptr) {
10600 reinterpret_cast<PyTypeObject *
>(py_class)))
10603 "%s warning, %.200s: references and already registered base-class %.200s\n",
10605 (
reinterpret_cast<PyTypeObject *
>(py_class))->tp_name,
10606 base_cls_test->tp_name);
10609 reinterpret_cast<PyTypeObject *
>(py_class)))
10612 "%s warning, %.200s: references and already registered sub-class %.200s\n",
10614 (
reinterpret_cast<PyTypeObject *
>(py_class))->tp_name,
10615 sub_cls_test->tp_name);
10624 if (!PyDict_GetItem((
reinterpret_cast<PyTypeObject *
>(py_class))->tp_dict,
10628 "%s warning, %.200s: is expected to contain a \"__slots__\" member "
10629 "to prevent arbitrary assignments.\n",
10631 (
reinterpret_cast<PyTypeObject *
>(py_class))->tp_name);
10639 PyErr_Format(PyExc_ValueError,
10640 "%s %.200s's parent class %.200s is already registered, this is not allowed",
10642 ((PyTypeObject *)py_class)->tp_name,
10652 PyErr_Format(PyExc_ValueError,
10653 "%s expected a subclass of a registerable "
10654 "RNA type (%.200s does not support registration)",
10666 identifier = (
reinterpret_cast<PyTypeObject *
>(py_class))->tp_name;
10676 if (!reports.
list.is_empty()) {
10691 if (srna_new ==
nullptr) {
10701 Py_DECREF(old_py_class);
10721 if (parent_name_prop) {
10743 PyObject *
ret = PyObject_CallObject(py_cls_meth,
nullptr);
10744 Py_DECREF(py_cls_meth);
10763 const char **r_prop_identifier)
10770 for (
const Link &link : lb->cast<
Link>()) {
10793 pyrna_unregister_class_doc,
10794 ".. function:: unregister_class(cls)\n"
10796 " Unload the Python class from blender.\n"
10798 " :param cls: Blender type class, \n"
10799 " see :func:`bpy.utils.register_class` for classes which can \n"
10800 " be registered.\n"
10806 " If the class has an *unregister* class method it will be called\n"
10807 " before unregistering.\n");
10809 "unregister_class",
10812 pyrna_unregister_class_doc,
10819 PyObject *py_cls_meth;
10820 const char *error_prefix =
"unregister_class(...):";
10822 if (!PyType_Check(py_class)) {
10823 PyErr_Format(PyExc_ValueError,
10824 "%s expected a class argument, not '%.200s'",
10826 Py_TYPE(py_class)->tp_name);
10832 PyErr_Format(PyExc_ValueError,
"%s not a registered as a subclass", error_prefix);
10838 PyErr_Format(PyExc_RuntimeError,
10839 "%s cannot run in readonly state '%.200s'",
10841 (
reinterpret_cast<PyTypeObject *
>(py_class))->tp_name);
10846 if (srna ==
nullptr) {
10851 PyErr_Format(PyExc_RuntimeError,
10852 "%s can't unregister a built-in class '%.200s'",
10854 (
reinterpret_cast<PyTypeObject *
>(py_class))->tp_name);
10862 PyErr_Format(PyExc_ValueError,
10863 "%s expected type '%.200s' subclassed from a registerable RNA type "
10864 "(unregister not supported)",
10866 (
reinterpret_cast<PyTypeObject *
>(py_class))->tp_name);
10874 PyObject *
ret = PyObject_CallObject(py_cls_meth,
nullptr);
10875 Py_DECREF(py_cls_meth);
10894 const char *prop_identifier =
nullptr;
10901 srna_iter =
static_cast<StructRNA *
>(itemptr.data);
10908 if (prop_identifier) {
10909 PyErr_Format(PyExc_RuntimeError,
10910 "%s cannot unregister %s because %s.%s pointer property is using this",
10927 if (PyDict_DelItem((
reinterpret_cast<PyTypeObject *
>(py_class))->tp_dict,
10947 PyObject *dict = type->tp_dict;
10948 if (method !=
nullptr) {
10949 for (; method->ml_name !=
nullptr; method++) {
10950 PyObject *py_method;
10952 if (method->ml_flags & METH_CLASS) {
10953 PyObject *cfunc = PyCFunction_New(method, (PyObject *)type);
10954 py_method = PyClassMethod_New(cfunc);
10957 else if (method->ml_flags & METH_STATIC) {
10958 py_method = PyCFunction_New(method,
nullptr);
10961 py_method = PyDescr_NewMethod(type, method);
10964 const int err = PyDict_SetItemString(dict, method->ml_name, py_method);
10965 Py_DECREF(py_method);
10971 if (getset !=
nullptr) {
10972 for (; getset->name !=
nullptr; getset++) {
10973 PyObject *descr = PyDescr_NewGetSet(type, getset);
10975 BLI_assert(PyDict_GetItem(dict, PyDescr_NAME(descr)) ==
nullptr);
10976 PyDict_SetItem(dict, PyDescr_NAME(descr), descr);
10995 return PyUnicode_FromString(name);
11003 if (value == Py_None) {
11006 else if (PyUnicode_Check(value)) {
11007 name = PyUnicode_AsUTF8(value);
11010 PyErr_Format(PyExc_ValueError,
11012 "expected None or a string, not '%.200s'",
11013 Py_TYPE(value)->tp_name);
11022# pragma clang diagnostic push
11023# pragma clang diagnostic ignored "-Wcast-function-type"
11025# pragma GCC diagnostic push
11026# pragma GCC diagnostic ignored "-Wcast-function-type"
11031 "_bl_owner_id_get",
11037 "_bl_owner_id_set",
11045# pragma clang diagnostic pop
11047# pragma GCC diagnostic pop
A dynamically sized string ADT.
#define GHASH_ITER(gh_iter_, ghash_)
#define SNPRINTF_UTF8(dst, format,...)
#define STRNCPY_UTF8(dst, src)
#define CLOG_ERROR(clg_ref,...)
#define CLOG_WARN(clg_ref,...)
#define CLOG_TRACE(clg_ref,...)
These structs are the foundation for all linked lists in the library system.
Read Blender memory allocation and freeing.
#define RNA_STRUCT_BEGIN(sptr, prop)
#define RNA_PROP_BEGIN(sptr, itemptr, prop)
#define RNA_ENUM_BITFLAG_SIZE
#define BLI_assert_unreachable()
#define STREQLEN(a, b, n)
#define UNUSED_VARS_NDEBUG(...)
#define BLI_assert_msg(a, msg)
#define BPy_PropDeferred_CheckTypeExact(v)
#define PYRNA_STACK_ARRAY
#define MATHUTILS_CB_SUBTYPE_COLOR
#define PROP_ALL_VECTOR_SUBTYPES
#define BPY_DOC_ID_PROP_TYPE_NOTE
#define PYRNA_PROP_COLLECTION_ABS_INDEX(ret_err)
#define MATHUTILS_CB_SUBTYPE_VEC
#define MATHUTILS_CB_SUBTYPE_EUL
#define BPY_TYPEDEF_REGISTERABLE_DOC
#define MATHUTILS_CB_SUBTYPE_QUAT
#define PYRNA_STRUCT_IS_VALID(pysrna)
#define BPy_StructRNA_CheckExact(v)
#define PYRNA_STRUCT_CHECK_OBJ(obj)
#define PYRNA_STRUCT_CHECK_INT(obj)
#define PYRNA_STRUCT_CHECK_OBJ_UNLESS(obj, unless)
#define PYRNA_PROP_CHECK_OBJ(obj)
#define PYRNA_PROP_CHECK_INT(obj)
#define BPy_PropertyRNA_CheckExact(v)
#define BPy_StructRNA_Check(v)
#define BPy_PropertyRNA_Check(v)
constexpr bool is_empty() const
constexpr int64_t size() const
constexpr const char * data() const
VecBase< float, D > step(VecOp< float, D >, VecOp< float, D >) RET
float length(VecOp< float, D >) RET
ccl_device_inline dual1 len(const ccl_private dual< T > &a)
void free(Subdiv *subdiv)
bNodeType * node_type_find(UString idname)
UString node_type_find_alias(UString alias)
std::string ptr_type(const ResourceString &str)
static PyObject * pyrna_prop_collection_values(BPy_PropertyRNA *self)
static PyMappingMethods pyrna_struct_as_mapping
char * RNA_property_string_get_alloc(PointerRNA *ptr, PropertyRNA *prop, char *fixedbuf, int fixedlen, int *r_len)
const char * BKE_idtype_idcode_to_name(short idcode)
PyTypeObject pyrna_func_Type
int RNA_property_array_length(PointerRNA *ptr, PropertyRNA *prop)
PointerRNA RNA_pointer_create_from_ancestor(const PointerRNA &ptr, const int ancestor_idx)
BLI_assert(slot->slot_subtype.map==BMO_OP_SLOT_SUBTYPE_MAP_FLT)
bool pyrna_id_CheckPyObject(PyObject *obj)
int RNA_property_enum_bitflag_identifiers(bContext *C, PointerRNA *ptr, PropertyRNA *prop, const int value, const char **r_identifier)
bool RNA_property_overridable_library_set(PointerRNA *, PropertyRNA *prop, const bool is_overridable)
void IDP_FreeFromGroup(IDProperty *group, IDProperty *prop) ATTR_NONNULL()
static PyObject * pyrna_struct_property_overridable_library_set(BPy_StructRNA *self, PyObject *args)
size_t size_t size_t BLI_snprintf_utf8(char *__restrict dst, size_t dst_maxncpy, const char *__restrict format,...) ATTR_NONNULL(1
void ** RNA_struct_instance(PointerRNA *ptr)
static void pyrna_struct_dealloc(PyObject *self)
static int prop_subscript_ass_array_slice__float_recursive(PyObject **value_items, float *value, int totdim, const int dimsize[], const float range[2])
static Py_ssize_t pyrna_prop_collection_length(BPy_PropertyRNA *self)
static int mathutils_rna_vector_get_index(BaseMathObject *bmo, int, int index)
static PyObject * pyrna_struct_pop(BPy_StructRNA *self, PyObject *args)
unsigned __int64 uint64_t
static PyObject * pyrna_struct_is_property_hidden(BPy_StructRNA *self, PyObject *args)
static PyObject * pyrna_struct_getattro(BPy_StructRNA *self, PyObject *pyname)
PointerRNA RNA_property_pointer_get(PointerRNA *ptr, PropertyRNA *prop)
PyObject * bpy_intern_str___slots__
PyObject * bpy_intern_str___doc__
static PyMethodDef pyrna_struct_methods[]
void BLI_dynstr_appendf(DynStr *__restrict ds, const char *__restrict format,...) ATTR_PRINTF_FORMAT(2
static int pyrna_struct_contains(BPy_StructRNA *self, PyObject *value)
static int pyrna_struct_compare(BPy_StructRNA *a, BPy_StructRNA *b)
bool RNA_struct_idprops_datablock_allowed(const StructRNA *type)
BLI_INLINE void * BLI_ghashIterator_getKey(GHashIterator *ghi) ATTR_WARN_UNUSED_RESULT
bool RNA_struct_system_idprops_check(StructRNA *srna)
static int pyrna_prop_collection_ass_subscript_int(BPy_PropertyRNA *self, Py_ssize_t keynum, PyObject *value)
static void pyrna_prop_warn_deprecated(const PointerRNA *ptr, const PropertyRNA *prop, const DeprecatedRNA *deprecated)
void RNA_def_property_ui_text(PropertyRNA *prop, const char *name, const char *description)
static int pyrna_prop_collection_bool(BPy_PropertyRNA *self)
PyObject * pyrna_struct_keyframe_delete(BPy_StructRNA *self, PyObject *args, PyObject *kw)
static PyObject * pyrna_struct_path_from_module(BPy_StructRNA *self, PyObject *args)
static PyObject * bpy_types_dict
static int prop_subscript_ass_array_slice(PointerRNA *ptr, PropertyRNA *prop, int arraydim, int arrayoffset, int start, int step, int slice_length, int array_length, PyObject *value_orig)
static PyObject * bpy_types_module_dir(PyObject *self)
char pyrna_struct_keyframe_insert_doc[]
static int bpy_class_validate_recursive(PointerRNA *dummy_ptr, StructRNA *srna, void *py_data, bool *have_function)
void RNA_property_float_get_array(PointerRNA *ptr, PropertyRNA *prop, float *values)
int PyC_ParseBool(PyObject *o, void *p)
PointerRNA RNA_main_pointer_create(Main *main)
static long pyrna_prop_hash(BPy_PropertyRNA *self)
PropertyRNA * RNA_struct_find_property(PointerRNA *ptr, const char *identifier)
int pyrna_enum_bitfield_from_set(const EnumPropertyItem *items, PyObject *value, int *r_value, const char *error_prefix)
bool RNA_struct_idprops_check(const StructRNA *srna)
PointerRNA RNA_pointer_recast(PointerRNA *ptr)
PyObject * BPY_rna_module()
void RNA_property_update(bContext *C, PointerRNA *ptr, PropertyRNA *prop)
static PyObject * pyrna_func_vectorcall(PyObject *callable, PyObject *const *args, size_t nargsf, PyObject *kwnames)
void RNA_property_pointer_set(PointerRNA *ptr, PropertyRNA *prop, PointerRNA ptr_value, ReportList *reports)
bool RNA_struct_is_a(const StructRNA *type, const StructRNA *srna)
static int prop_subscript_ass_array_int(BPy_PropertyArrayRNA *self, Py_ssize_t keynum, PyObject *value)
int pyrna_prop_validity_check(const BPy_PropertyRNA *self)
static int pyrna_prop_collection_type_check(BPy_PropertyRNA *self, PyObject *value)
static PyObject * pyrna_prop_array_subscript_slice(BPy_PropertyArrayRNA *self, PointerRNA *ptr, PropertyRNA *prop, Py_ssize_t start, Py_ssize_t step, Py_ssize_t slice_length, Py_ssize_t array_length)
const char * RNA_function_ui_description(FunctionRNA *func)
static PyObject * pyrna_prop_str(BPy_PropertyRNA *self)
void RNA_property_string_set_bytes(PointerRNA *ptr, PropertyRNA *prop, const char *value, int len)
static PyObject * pyrna_struct_get_rna_type(BPy_PropertyRNA *self, void *)
static PyObject * pyrna_struct_id_properties_ui(BPy_StructRNA *self, PyObject *args)
void BKE_reports_free(ReportList *reports)
PointerRNA RNA_blender_rna_pointer_create()
void BKE_report_print_level_set(ReportList *reports, eReportType level)
PyObject * pyrna_id_CreatePyObject(ID *id)
bool RNA_property_editable_flag(const PointerRNA *ptr, PropertyRNA *prop)
void BPY_id_release(ID *id)
BPy_StructRNA * bpy_context_module
bool RNA_property_enum_identifier(bContext *C, PointerRNA *ptr, PropertyRNA *prop, const int value, const char **r_identifier)
static PyGetSetDef pyrna_prop_getseters[]
PointerRNA RNA_id_pointer_create(ID *id)
void * RNA_struct_py_type_get(StructRNA *srna)
std::optional< std::string > RNA_path_from_ID_to_property(const PointerRNA *ptr, PropertyRNA *prop)
std::optional< std::string > RNA_path_full_struct_py(const PointerRNA *ptr)
PyObject * Quaternion_CreatePyObject_cb(PyObject *cb_user, uchar cb_type, uchar cb_subtype)
void * BLI_ghash_lookup(const GHash *gh, const void *key) ATTR_WARN_UNUSED_RESULT
PropertyRNA * RNA_struct_type_find_property_no_base(StructRNA *srna, const UString identifier)
void RNA_property_float_set(PointerRNA *ptr, PropertyRNA *prop, float value)
void pyrna_context_clear(bContext *C)
static PyNumberMethods pyrna_prop_array_as_number
PyMethodDef meth_bpy_owner_id_set
const char * RNA_property_identifier(const PropertyRNA *prop)
static int pyrna_prop_collection_ass_subscript(BPy_PropertyRNA *self, PyObject *key, PyObject *value)
eRNAStatus RNA_property_collection_move(PointerRNA *ptr, PropertyRNA *prop, int src_index, int dst_index)
static void pyrna_dir_members_py__add_keys(PyObject *list, PyObject *dict)
void RNA_property_boolean_get_array(PointerRNA *ptr, PropertyRNA *prop, bool *values)
static int rna_function_register_arg_count(FunctionRNA *func, int *min_count)
void pyrna_context_init(bContext *C)
void BKE_reports_init(ReportList *reports, int flag)
static bool foreach_compat_buffer(RawPropertyType raw_type, int attr_signed, const char *format)
void BPy_reports_write_stdout(const ReportList *reports, const char *header)
bool RNA_property_builtin(PropertyRNA *prop)
static PyObject * pyrna_func_repr(BPy_FunctionRNA *self)
int RNA_property_enum_get(PointerRNA *ptr, PropertyRNA *prop)
int(*)(BaseMathObject *, int) BaseMathSetFunc
int pyrna_struct_validity_check(const BPy_StructRNA *pysrna)
void RNA_property_enum_items(bContext *C, PointerRNA *ptr, PropertyRNA *prop, const EnumPropertyItem **r_item, int *r_totitem, bool *r_free)
int RNA_property_collection_raw_get(ReportList *reports, PointerRNA *ptr, PropertyRNA *prop, const char *propname, void *array, RawPropertyType type, int len)
float RNA_property_float_get_index(PointerRNA *ptr, PropertyRNA *prop, int index)
IDProperty * IDP_GetPropertyFromGroup(const IDProperty *prop, StringRef name) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL()
int pyrna_pydict_to_props(PointerRNA *ptr, PyObject *kw, const bool all_args, const char *error_prefix)
static PyObject * pyrna_prop_collection_iter_next(PyObject *self)
PyDoc_STRVAR(bpy_bm_new_doc, ".. function:: new(*, use_operators=True)\n" "\n" " :param use_operators: Support calling operators in :mod:`bmesh.ops` (uses some " "extra memory per vert/edge/face).\n" " :type use_operators: bool\n" " :return: Return a new, empty BMesh.\n" " :rtype: :class:`bmesh.types.BMesh`\n")
static Mathutils_Callback mathutils_rna_matrix_cb
static void bpy_class_free(void *pyob_ptr)
static PyGetSetDef pyrna_struct_getseters[]
PyTypeObject pyrna_prop_Type
static PyMethodDef pyrna_prop_array_methods[]
static PyObject * pyrna_enum_to_py(PointerRNA *ptr, PropertyRNA *prop, int val)
std::optional< std::string > RNA_path_from_ID_to_struct(const PointerRNA *ptr)
static PyObject * pyrna_struct_as_pointer(BPy_StructRNA *self)
static PyObject * pyrna_prop_collection_idprop_add(BPy_PropertyRNA *self)
const char * RNA_struct_state_owner_get()
PyObject * Euler_CreatePyObject(const float eul[3], const short order, PyTypeObject *base_type)
char * BLI_strncpy_utf8(char *__restrict dst, const char *__restrict src, size_t dst_maxncpy) ATTR_NONNULL(1
FunctionRNA * RNA_struct_find_function(StructRNA *srna, const char *identifier_c_str)
void RNA_parameter_list_next(ParameterIterator *iter)
void RNA_property_collection_begin(PointerRNA *ptr, PropertyRNA *prop, CollectionPropertyIterator *iter)
bool RNA_struct_idprops_contains_datablock(const StructRNA *type)
PyObject * BPy_IDGroup_MapDataToPy(IDProperty *prop)
void RNA_parameter_list_end(ParameterIterator *)
void * BLI_findstring(const ListBase *listbase, const char *id, int offset) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
static PyObject * pyrna_register_class(PyObject *self, PyObject *py_class)
static PyObject * prop_subscript_ass_array_slice__as_seq_fast(PyObject *value, int length)
int(*)(BaseMathObject *, int) BaseMathGetFunc
bool RNA_property_overridable_get(const PointerRNA *ptr, PropertyRNA *prop)
PyObject * BPy_Wrap_GetItems_View_WithID(ID *id, IDProperty *prop)
StructUnregisterFunc RNA_struct_unregister(StructRNA *type)
bool RNA_property_enum_value(bContext *C, PointerRNA *ptr, PropertyRNA *prop, const char *identifier, int *r_value)
char pyrna_struct_keyframe_delete_doc[]
bool RNA_property_collection_assign_int(PointerRNA *ptr, PropertyRNA *prop, const int key, const PointerRNA *assign_ptr)
static int mathutils_rna_vector_set(BaseMathObject *bmo, int subtype)
static PySequenceMethods pyrna_struct_as_sequence
static PyObject * pyrna_prop_array_iter(BPy_PropertyArrayRNA *self)
char * RNA_struct_name_get_alloc(PointerRNA *ptr, char *fixedbuf, int fixedlen, int *r_len)
static bool rna_id_write_error(PointerRNA *ptr, PyObject *key)
void RNA_property_float_set_array(PointerRNA *ptr, PropertyRNA *prop, const float *values)
static PyObject * pyrna_prop_collection_subscript_str_lib_pair(BPy_PropertyRNA *self, PyObject *key, const char *err_prefix, const bool err_not_found)
static PyObject * pyrna_struct_new(PyTypeObject *type, PyObject *args, PyObject *)
std::optional< std::string > RNA_path_from_real_ID_to_property_index(Main *bmain, const PointerRNA *ptr, PropertyRNA *prop, int index_dim, int index, ID **r_real_id)
static PyObject * pyrna_bl_owner_id_get(PyObject *)
void RNA_property_boolean_set_array(PointerRNA *ptr, PropertyRNA *prop, const bool *values)
ATTR_WARN_UNUSED_RESULT const BMVert * v
PropertyRNA * RNA_struct_iterator_property(StructRNA *type)
int RNA_property_collection_length(PointerRNA *ptr, PropertyRNA *prop)
void BPY_rna_types_dict_set(PyObject *dict)
static PyObject * pyrna_struct_is_property_overridable_library(BPy_StructRNA *self, PyObject *args)
static int mathutils_rna_matrix_get(BaseMathObject *bmo, int)
static Py_ssize_t pyrna_prop_array_length(BPy_PropertyArrayRNA *self)
static int pyrna_property_init(PyObject *self, PyObject *args, PyObject *)
static int pyrna_prop_collection_contains(BPy_PropertyRNA *self, PyObject *key)
static PyMethodDef pyrna_prop_collection_methods[]
PyObject * pyrna_struct_CreatePyObject(PointerRNA *ptr)
static PyObject * pyrna_struct_str(BPy_StructRNA *self)
PyTypeObject pyrna_struct_meta_idprop_Type
static PyObject * pyrna_prop_repr_ex(BPy_PropertyRNA *self, const int index_dim, const int index)
static PyModuleDef bpy_types_module_def
PyMethodDef meth_bpy_unregister_class
PyObject * BPy_Wrap_GetKeys_View_WithID(ID *id, IDProperty *prop)
PyObject * PyC_UnicodeFromBytes(const char *str)
static int deferred_register_prop(StructRNA *srna, PyObject *key, PyObject *item)
static PyObject * pyrna_prop_collection_foreach_set(BPy_PropertyRNA *self, PyObject *args)
static int pyrna_prop_collection_subscript_is_valid_or_error(const PyObject *value)
PyObject * Matrix_CreatePyObject_cb(PyObject *cb_user, const ushort col_num, const ushort row_num, uchar cb_type, uchar cb_subtype)
const ListBaseT< PropertyRNA > * RNA_struct_type_properties(StructRNA *srna)
PyObject * BPy_CollectionProperty(PyObject *self, PyObject *args, PyObject *kw)
void BLI_dynstr_free(DynStr *ds) ATTR_NONNULL()
static PyObject * pyrna_srna_ExternalType(StructRNA *srna)
int(*)(BaseMathObject *, int, int) BaseMathGetIndexFunc
static PyObject * pyrna_prop_collection_getattro(BPy_PropertyRNA *self, PyObject *pyname)
StructRNA RNA_PropertyGroup
PyObject * pyrna_prop_to_py(PointerRNA *ptr, PropertyRNA *prop)
static PyObject * pyrna_prop_collection_iter_new(PyTypeObject *type, PyObject *, PyObject *)
int pyrna_struct_as_ptr_or_null_parse(PyObject *o, void *p)
void RNA_def_property_duplicate_pointers(StructOrFunctionRNA *cont_, PropertyRNA *prop)
static PyMappingMethods pyrna_prop_collection_as_mapping
void BLI_ghash_insert(GHash *gh, void *key, void *val)
static PyMethodDef bpy_types_module_methods[]
PyObject * bpy_intern_str___annotations__
bool RNA_property_collection_remove(PointerRNA *ptr, PropertyRNA *prop, int key)
int RNA_function_flag(FunctionRNA *func)
static Mathutils_Callback mathutils_rna_array_cb
bool BPy_errors_to_report(ReportList *reports)
ParameterList * RNA_parameter_list_create(ParameterList *parms, PointerRNA *, FunctionRNA *func)
PyObject * BPy_PointerProperty(PyObject *self, PyObject *args, PyObject *kw)
static PyTypeObject pyrna_prop_collection_iter_Type
static int mathutils_rna_vector_set_index(BaseMathObject *bmo, int, int index)
bool RNA_property_boolean_get(PointerRNA *ptr, PropertyRNA *prop)
bool RNA_property_array_check(PropertyRNA *prop)
PyObject * pyrna_struct_keyframe_insert(BPy_StructRNA *self, PyObject *args, PyObject *kw)
void RNA_property_collection_add(PointerRNA *ptr, PropertyRNA *prop, PointerRNA *r_ptr)
static PyObject * pyrna_prop_collection_iter(PyObject *self)
void RNA_property_int_set_array(PointerRNA *ptr, PropertyRNA *prop, const int *values)
int(*)(BaseMathObject *) BaseMathCheckFunc
void RNA_property_int_set(PointerRNA *ptr, PropertyRNA *prop, int value)
void BPY_rna_types_finalize_external_types(PyObject *submodule)
static PyObject * pyrna_prop_collection_subscript_str(BPy_PropertyRNA *self, const char *keyname)
PropertyRNA * RNA_def_property(StructOrFunctionRNA *cont_, const char *identifier_c_str, int type, int subtype)
PropertyType RNA_property_type(PropertyRNA *prop)
bool RNA_property_collection_lookup_string_has_fn(PropertyRNA *prop)
static PyObject * pyrna_prop_collection_get(BPy_PropertyRNA *self, PyObject *args)
static PyObject * pyrna_prop_collection_items(BPy_PropertyRNA *self)
const EnumPropertyItem rna_enum_property_type_items[]
static bool rna_disallow_writes
static PyObject * pyrna_prop_array_repr(BPy_PropertyArrayRNA *self)
int(*)(BaseMathObject *, int, int) BaseMathSetIndexFunc
static PyObject * pyrna_prop_collection_idprop_clear(BPy_PropertyRNA *self)
void BLI_ghashIterator_step(GHashIterator *ghi)
static PyNumberMethods pyrna_prop_collection_as_number
static void bpy_types_module_free(void *self)
char * BLI_strncpy(char *__restrict dst, const char *__restrict src, size_t dst_maxncpy) ATTR_NONNULL(1
int RNA_function_defined(FunctionRNA *func)
static int foreach_parse_args(BPy_PropertyRNA *self, PyObject *args, const char *function_name, const char **r_attr, PyObject **r_seq, int *r_tot, size_t *r_size, RawPropertyType *r_raw_type, int *r_attr_tot, bool *r_attr_signed)
PyObject * pyrna_py_from_array_index(BPy_PropertyArrayRNA *self, PointerRNA *ptr, PropertyRNA *prop, int index)
PyObject * Vector_CreatePyObject(const float *vec, const int vec_num, PyTypeObject *base_type)
static void pyrna_func_error_prefix(BPy_FunctionRNA *self, PropertyRNA *parm, const int parm_index, char *error, const size_t error_maxncpy)
PyObject * pyrna_prop_CreatePyObject(PointerRNA *ptr, PropertyRNA *prop)
void RNA_property_string_set(PointerRNA *ptr, PropertyRNA *prop, const char *value)
std::optional< std::string > RNA_path_from_real_ID_to_struct(Main *bmain, const PointerRNA *ptr, ID **r_real)
static PyObject * pyrna_struct_path_resolve(BPy_StructRNA *self, PyObject *args)
StructRNA * RNA_property_pointer_type(PointerRNA *ptr, PropertyRNA *prop)
PyObject * bpy_intern_str_bpy_types
static PyTypeObject * bpy_class_check_any_bases_registered(PyTypeObject *cls)
PyObject * bpy_intern_str___name__
PyObject * Matrix_CreatePyObject(const float *mat, const ushort col_num, const ushort row_num, PyTypeObject *base_type)
void BLI_ghash_free(GHash *gh, GHashKeyFreeFP keyfreefp, GHashValFreeFP valfreefp)
static int pyrna_prop_array_ass_subscript(BPy_PropertyArrayRNA *self, PyObject *key, PyObject *value)
static void pyrna_subtype_set_rna(PyObject *newclass, StructRNA *srna)
PyObject * Quaternion_CreatePyObject(const float quat[4], PyTypeObject *base_type)
int pyrna_struct_as_ptr_parse(PyObject *o, void *p)
struct bContext * BPY_context_get()
static int pyrna_string_to_enum(PyObject *item, PointerRNA *ptr, PropertyRNA *prop, int *r_value, const char *error_prefix)
void RNA_property_int_get_array(PointerRNA *ptr, PropertyRNA *prop, int *values)
std::string RNA_path_from_ptr_to_property_index(const PointerRNA *ptr, PropertyRNA *prop, int index_dim, int index)
BMesh const char void * data
void RNA_property_collection_end(CollectionPropertyIterator *iter)
PyObject * pyrna_callback_classmethod_add(PyObject *, PyObject *args)
int CTX_data_get(const bContext *C, const char *member, PointerRNA *r_ptr, Vector< PointerRNA > *r_lb, PropertyRNA **r_prop, int *r_index, StringRef *r_str, std::optional< int64_t > *r_int_value, ContextDataType *r_type)
bool RNA_property_is_set_ex(PointerRNA *ptr, PropertyRNA *prop, bool use_ghost)
static PyObject * pyrna_prop_path_from_id(BPy_PropertyRNA *self)
void RNA_property_enum_items_ex(bContext *C, PointerRNA *ptr, PropertyRNA *prop, const bool use_static, const EnumPropertyItem **r_item, int *r_totitem, bool *r_free)
IDProperty * RNA_struct_idprops(PointerRNA *ptr, bool create)
PyMethodDef meth_bpy_register_class
static PyObject * pyrna_struct_get_data(BPy_DummyPointerRNA *self, void *)
static int pyrna_prop_compare(BPy_PropertyRNA *a, BPy_PropertyRNA *b)
bool(*)(Main *bmain, StructRNA *type) StructUnregisterFunc
static int prop_subscript_ass_array_slice__bool_recursive(PyObject **value_items, bool *value, int totdim, const int dimsize[])
static PyObject * pyrna_struct_get_id_data(BPy_DummyPointerRNA *self, void *)
std::string RNA_path_full_ID_py(ID *id)
wmWindowManager * CTX_wm_manager(const bContext *C)
static PyObject * pyrna_struct_values(BPy_StructRNA *self)
static int bpy_class_validate(PointerRNA *dummy_ptr, void *py_data, bool *have_function)
static int mathutils_rna_matrix_set(BaseMathObject *bmo, int)
PyTypeObject BPy_IDGroup_Type
std::string RNA_function_as_string_keywords(bContext *C, FunctionRNA *func, const bool as_function, const bool all_args, const int max_prop_length)
static PyObject * pyrna_struct_property_unset(BPy_StructRNA *self, PyObject *args)
static void pyrna_dir_members_rna(PyObject *list, PointerRNA *ptr)
void PyC_ObSpit(const char *name, PyObject *var)
int pyrna_py_to_array_index(PointerRNA *ptr, PropertyRNA *prop, int arraydim, int arrayoffset, int index, PyObject *py, const char *error_prefix)
PyObject * Vector_CreatePyObject_cb(PyObject *cb_user, int vec_num, uchar cb_type, uchar cb_subtype)
static PyObject * pyrna_struct_id_properties_clear(BPy_StructRNA *self)
void pyrna_struct_type_extend_capi(StructRNA *srna, PyMethodDef *method, PyGetSetDef *getset)
static uchar mathutils_rna_array_cb_index
int16_t PyC_Long_AsI16(PyObject *value)
PyObject * bpy_intern_str_attr
void RNA_property_unset(PointerRNA *ptr, PropertyRNA *prop)
static PyMethodDef pyrna_prop_collection_idprop_methods[]
static PyObject * pyrna_prop_collection_foreach_get(BPy_PropertyRNA *self, PyObject *args)
PyObject * pyrna_array_index(PointerRNA *ptr, PropertyRNA *prop, int index)
static int pyrna_struct_setattro(BPy_StructRNA *self, PyObject *pyname, PyObject *value)
bool pyrna_id_FromPyObject(PyObject *obj, ID **id)
int RNA_property_flag(PropertyRNA *prop)
static PySequenceMethods pyrna_prop_collection_as_sequence
int RNA_property_float_clamp(PointerRNA *ptr, PropertyRNA *prop, float *value)
PyObject * pyrna_math_object_from_array(PointerRNA *ptr, PropertyRNA *prop)
bool RNA_property_collection_lookup_string(PointerRNA *ptr, PropertyRNA *prop, const char *key, PointerRNA *r_ptr)
PyObject * bpy_intern_str_unregister
const char * RNA_function_identifier(FunctionRNA *func)
static PyObject * pyrna_struct_richcmp(PyObject *a, PyObject *b, int op)
static PyObject * pyrna_prop_collection_subscript(BPy_PropertyRNA *self, PyObject *key)
static PyObject * pyrna_struct_keys(BPy_StructRNA *self)
PyObject * bpy_intern_str_register
constexpr size_t ARRAY_SIZE(const T(&arg)[N]) noexcept
PyObject * Color_CreatePyObject(const float col[3], PyTypeObject *base_type)
static PySequenceMethods pyrna_prop_array_as_sequence
char pyrna_struct_driver_remove_doc[]
GHash * BLI_ghash_ptr_new(const char *info) ATTR_MALLOC ATTR_WARN_UNUSED_RESULT
PyTypeObject pyrna_prop_collection_Type
uchar Mathutils_RegisterCallback(Mathutils_Callback *cb)
static int prop_subscript_ass_array_slice__int_recursive(PyObject **value_items, int *value, int totdim, const int dimsize[], const int range[2])
PyObject * BPY_rna_types()
RawPropertyType RNA_property_raw_type(PropertyRNA *prop)
bool RNA_property_is_idprop(const PropertyRNA *prop)
void RNA_struct_py_type_set(StructRNA *srna, void *py_type)
PyObject * BPy_IDGroup_WrapData(ID *id, IDProperty *prop, IDProperty *parent)
PointerRNA RNA_pointer_create_discrete(ID *id, StructRNA *type, void *data)
PropertyRNA * RNA_struct_type_find_property(StructRNA *srna, const char *identifier)
static void pyrna_dir_members_py(PyObject *list, PyObject *self)
const char * BKE_idtype_idcode_to_name_plural(short idcode)
static void pyrna_prop_collection_iter_dealloc(PyObject *self)
char * BLI_dynstr_get_cstring(const DynStr *ds) ATTR_MALLOC ATTR_WARN_UNUSED_RESULT ATTR_NONNULL()
static PyObject * pyrna_struct_is_property_readonly(BPy_StructRNA *self, PyObject *args)
static PyObject * pyrna_struct_items(BPy_StructRNA *self)
static int pyrna_prop_collection_iter_init(PyObject *self, PyObject *, PyObject *)
static PyObject * pyrna_struct_bl_rna_get_subclass(PyObject *cls, PyObject *args)
static int pyrna_struct_meta_idprop_setattro(PyObject *cls, PyObject *attr, PyObject *value)
static int pyrna_property_array_init(PyObject *self, PyObject *args, PyObject *)
bool RNA_property_update_check(PropertyRNA *prop)
PyObject * pyrna_py_from_array(PointerRNA *ptr, PropertyRNA *prop)
void pyrna_struct_validity_exception_only(const BPy_StructRNA *pysrna)
static PyObject * pyrna_prop_collection_idprop_remove(BPy_PropertyRNA *self, PyObject *value)
static void pyrna_prop_collection_string_subscript_unsupported_error(BPy_PropertyRNA *self, const char *error_prefix)
unsigned int BLI_ghash_len(const GHash *gh) ATTR_WARN_UNUSED_RESULT
static short pyrna_rotation_euler_order_get(PointerRNA *ptr, const short order_fallback, PropertyRNA **r_prop_eul_order)
static PyObject * pyrna_struct_bl_rna_get_subclass_py(PyObject *cls, PyObject *args)
void RNA_property_collection_skip(CollectionPropertyIterator *iter, int num)
bool RNA_enum_id_from_value(const EnumPropertyItem *item, int value, const char **r_identifier)
uint64_t PyC_Long_AsU64(PyObject *value)
PropertyRNA * RNA_struct_name_property(const StructRNA *type)
const EnumPropertyItem rna_enum_dummy_NULL_items[]
static PyObject * pyrna_srna_Subtype(StructRNA *srna)
void BLI_ghashIterator_init(GHashIterator *ghi, GHash *gh)
bool RNA_property_collection_lookup_int_has_fn(PropertyRNA *prop)
static int mathutils_rna_generic_check(BaseMathObject *bmo)
int RNA_property_array_dimension(const PointerRNA *ptr, PropertyRNA *prop, int length[])
int RNA_parameter_list_arg_count(const ParameterList *parms)
static PyObject * pyrna_prop_array_getattro(BPy_PropertyRNA *self, PyObject *pyname)
static PyObject * pyrna_property_new(PyTypeObject *type, PyObject *args, PyObject *)
static PyObject * pyrna_func_CreatePyObject(const PointerRNA *ptr, FunctionRNA *func)
static PyTypeObject * bpy_class_check_any_subclasses_registered(PyTypeObject *cls)
void BLI_str_tolower_ascii(char *str, size_t len) ATTR_NONNULL(1)
PyObject * pyrna_callback_classmethod_remove(PyObject *, PyObject *args)
static PyObject * foreach_getset(BPy_PropertyRNA *self, PyObject *args, int set)
uint8_t PyC_Long_AsU8(PyObject *value)
void CTX_rna_disallow_write_set_p(bContext *C, const bool *rna_disallow_writes)
bool RNA_struct_is_ID(const StructRNA *type)
static int pyrna_py_to_prop(PointerRNA *ptr, PropertyRNA *prop, void *data, PyObject *value, const char *error_prefix, PyObject **r_value_coerce)
PyObject * PyC_Err_Format_Prefix(PyObject *exception_type_prefix, const char *format,...)
const char * PyC_UnicodeAsBytes(PyObject *py_str, PyObject **r_coerce)
static PyObject * pyrna_bl_owner_id_set(PyObject *, PyObject *value)
const DeprecatedRNA * RNA_property_deprecated(const PropertyRNA *prop)
PyObject * pyrna_struct_driver_remove(BPy_StructRNA *self, PyObject *args)
static int pyrna_prop_collection_string_subscript_supported_or_error(BPy_PropertyRNA *self, const char *error_prefix)
bool RNA_struct_system_idprops_register_check(const StructRNA *type)
const char * RNA_struct_identifier(const StructRNA *type)
static PyObject * pyrna_prop_array_to_py_index(BPy_PropertyArrayRNA *self, int index)
static PyObject * pyrna_prop_collection_idprop_move(BPy_PropertyRNA *self, PyObject *args)
static PyGetSetDef pyrna_func_getseters[]
int PyC_Long_AsBool(PyObject *value)
PyObject * BPy_Wrap_GetValues_View_WithID(ID *id, IDProperty *prop)
int pyrna_deferred_register_class(StructRNA *srna, PyTypeObject *py_class)
void RNA_struct_state_owner_set(const char *name)
void RNA_property_collection_next(CollectionPropertyIterator *iter)
float RNA_property_float_get(PointerRNA *ptr, PropertyRNA *prop)
static PyObject * pyrna_prop_update(BPy_PropertyRNA *self)
PropertySubType RNA_property_subtype(PropertyRNA *prop)
const char * RNA_struct_ui_description(const StructRNA *type)
static void pyrna_property_dealloc(PyObject *self)
bool RNA_property_collection_is_empty(PointerRNA *ptr, PropertyRNA *prop)
const PointerRNA * pyrna_struct_as_ptr(PyObject *py_obj, const StructRNA *srna)
static int pyrna_srna_contains_pointer_prop_srna(StructRNA *srna_props, StructRNA *srna, const char **r_prop_identifier)
void pyrna_write_set(bool val)
static PyObject * pyrna_srna_PyBase(StructRNA *srna)
int RNA_parameter_flag(PropertyRNA *prop)
static PyObject * pyrna_struct_id_properties_ensure(BPy_StructRNA *self)
const StructRNA * RNA_struct_base_child_of(const StructRNA *type, const StructRNA *parent_type)
StructRNA * pyrna_struct_as_srna(PyObject *self, const bool parent, const char *error_prefix)
void pyrna_invalidate(BPy_DummyPointerRNA *self)
static PyObject * pyrna_struct_Subtype(PointerRNA *ptr)
static const char * pyrna_enum_as_string(PointerRNA *ptr, PropertyRNA *prop)
T * DEG_get_original(T *id)
static int mathutils_rna_vector_get(BaseMathObject *bmo, int subtype)
static PyObject * bpy_types_module_getattro(PyObject *self, PyObject *pyname)
PyTypeObject BPy_IDPropertyUIManager_Type
StructRNA *(*)(Main *bmain, ReportList *reports, void *data, const char *identifier, StructValidateFunc validate, StructCallbackFunc call, StructFreeFunc free) StructRegisterFunc
PyObject * pyrna_struct_driver_add(BPy_StructRNA *self, PyObject *args)
static int pyrna_prop_collection_subscript_str_lib_pair_ptr(BPy_PropertyRNA *self, PyObject *key, const char *err_prefix, const short err_not_found, PointerRNA *r_ptr)
uint16_t PyC_Long_AsU16(PyObject *value)
Main * CTX_data_main(const bContext *C)
char pyrna_struct_driver_add_doc[]
static int pyrna_struct_ass_subscript(BPy_StructRNA *self, PyObject *key, PyObject *value)
int RNA_property_collection_raw_set(ReportList *reports, PointerRNA *ptr, PropertyRNA *prop, const char *propname, void *array, RawPropertyType type, int len)
static PyObject * pyprop_array_foreach_getset(BPy_PropertyArrayRNA *self, PyObject *args, const bool do_set)
static PyObject * pyrna_prop_richcmp(PyObject *a, PyObject *b, int op)
bool bpy_context_set(struct bContext *C, PyGILState_STATE *gilstate) ATTR_NONNULL(1)
void IDP_FreeProperty(IDProperty *prop)
static PyMappingMethods pyrna_prop_array_as_mapping
static PyObject * pyrna_prop_as_bytes(BPy_PropertyRNA *self)
StructRNA * RNA_struct_base(StructRNA *type)
static PyObject * pyrna_prop_array_foreach_set(BPy_PropertyArrayRNA *self, PyObject *args)
PyObject * pyrna_struct_CreatePyObject_with_primitive_support(PointerRNA *ptr)
static const char * BPy_PropertyPointerRNA_capsule_identifier
char * RNA_struct_name_get_alloc_ex(PointerRNA *ptr, char *fixedbuf, int fixedlen, int *r_len, PropertyRNA **r_nameprop)
bool BLI_path_is_rel(const char *path) ATTR_NONNULL(1) ATTR_WARN_UNUSED_RESULT
static PyObject * pyrna_struct_repr(BPy_StructRNA *self)
static PyObject * pyrna_struct_get(BPy_StructRNA *self, PyObject *args)
void RNA_property_collection_clear(PointerRNA *ptr, PropertyRNA *prop)
std::optional< PointerRNA > RNA_property_collection_type_get(PointerRNA *ptr, PropertyRNA *prop)
static int pyrna_prop_collection_setattro(BPy_PropertyRNA *self, PyObject *pyname, PyObject *value)
static PyObject * pyrna_prop_repr(BPy_PropertyRNA *self)
static PyObject * pyrna_struct_subscript(BPy_StructRNA *self, PyObject *key)
std::optional< std::string > RNA_path_full_property_py_ex(const PointerRNA *ptr, PropertyRNA *prop, int index, bool use_fallback)
void PyC_FileAndNum(const char **r_filename, int *r_lineno)
static PyObject * pyrna_prop_collection_iter_CreatePyObject(PointerRNA *ptr, PropertyRNA *prop)
int RNA_function_call(bContext *C, ReportList *reports, PointerRNA *ptr, FunctionRNA *func, ParameterList *parms)
bool BLI_ghash_remove(GHash *gh, const void *key, GHashKeyFreeFP keyfreefp, GHashValFreeFP valfreefp)
static PyObject * pyrna_prop_array_foreach_get(BPy_PropertyArrayRNA *self, PyObject *args)
@ PROP_PATH_SUPPORTS_BLEND_RELATIVE
static PointerRNA * rna_module_ptr
static PyObject * pyrna_prop_array_subscript(BPy_PropertyArrayRNA *self, PyObject *key)
static void pyrna_func_dealloc(PyObject *self)
void BPY_free_srna_pytype(StructRNA *srna)
static PyObject * pyrna_func_doc_get(BPy_FunctionRNA *self, void *closure)
bool RNA_property_collection_lookup_string_supported(PropertyRNA *prop)
void RNA_property_enum_set(PointerRNA *ptr, PropertyRNA *prop, int value)
StructRNA * srna_from_self(PyObject *self, const char *error_prefix)
static PyObject * pyrna_struct_CreatePyObject_from_type(const PointerRNA *ptr, PyTypeObject *tp, void **instance)
const PointerRNA * pyrna_struct_as_ptr_or_null(PyObject *py_obj, const StructRNA *srna)
bool RNA_property_collection_lookup_int(PointerRNA *ptr, PropertyRNA *prop, int key, PointerRNA *r_ptr)
static StructRNA * srna_from_ptr(PointerRNA *ptr)
bool RNA_property_collection_lookup_string_has_nameprop(PropertyRNA *prop)
bool RNA_property_editable(const PointerRNA *ptr, PropertyRNA *prop)
static void bpy_class_free_ex(PyObject *self, bool decref)
static PyObject * pyrna_struct_get_ancestors(BPy_StructRNA *self)
Span< std::unique_ptr< FunctionRNA > > RNA_struct_type_functions(StructRNA *srna)
static PyObject * pyrna_prop_path_from_module(BPy_PropertyRNA *self)
int RNA_property_int_clamp(PointerRNA *ptr, PropertyRNA *prop, int *value)
PyObject * PyC_UnicodeFromStdStr(const std::string &str)
static PyObject * pyrna_prop_collection_find(BPy_PropertyRNA *self, PyObject *key_ob)
static int pyrna_deferred_register_class_recursive(StructRNA *srna, PyTypeObject *py_class)
int RNA_property_multi_array_length(PointerRNA *ptr, PropertyRNA *prop, int dimension)
void RNA_property_boolean_set(PointerRNA *ptr, PropertyRNA *prop, bool value)
static PyObject * kwnames_get_item_string(PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames, Py_ssize_t nkw, const char *parm_name)
bool RNA_path_resolve_full_maybe_null(const PointerRNA *ptr, const char *path, PointerRNA *r_ptr, PropertyRNA **r_prop, int *r_index)
int RNA_def_property_free_identifier(StructOrFunctionRNA *cont_, const char *identifier)
static PyObject * pyrna_struct_dir(BPy_StructRNA *self)
PyObject * Color_CreatePyObject_cb(PyObject *cb_user, uchar cb_type, uchar cb_subtype)
static int pyrna_prop_array_bool(BPy_PropertyRNA *self)
PyObject * bpy_intern_str_properties
static int pyrna_deferred_register_props(StructRNA *srna, PyObject *class_dict)
ListBaseT< LinkData > CTX_data_dir_get(const bContext *C)
static PyMethodDef pyrna_prop_methods[]
void RNA_property_int_set_index(PointerRNA *ptr, PropertyRNA *prop, int index, int value)
size_t RNA_raw_type_sizeof(RawPropertyType type)
void RNA_property_float_set_index(PointerRNA *ptr, PropertyRNA *prop, int index, float value)
PyTypeObject pyrna_struct_Type
PyObject * PyC_ExceptionBuffer()
short BPy_reports_to_error(ReportList *reports, PyObject *exception, const bool clear)
PyTypeObject pyrna_prop_array_Type
@ CTX_RESULT_MEMBER_NOT_FOUND
void RNA_parameter_list_begin(ParameterList *parms, ParameterIterator *iter)
static PyObject * pyrna_prop_collection_subscript_slice(BPy_PropertyRNA *self, Py_ssize_t start, Py_ssize_t stop)
PyObject * PyC_UnicodeFromBytesAndSize(const char *str, Py_ssize_t size)
static PyObject * pyrna_unregister_class(PyObject *self, PyObject *py_class)
static int pyrna_py_to_prop_array_index(BPy_PropertyArrayRNA *self, int index, PyObject *value)
static PyObject * pyrna_prop_array_subscript_int(BPy_PropertyArrayRNA *self, Py_ssize_t keynum)
@ RPT_PRINT_HANDLED_BY_OWNER
void RNA_property_boolean_set_index(PointerRNA *ptr, PropertyRNA *prop, int index, bool value)
void PyC_ObSpitStr(char *result, size_t result_maxncpy, PyObject *var)
@ PARM_PYFUNC_REGISTER_OPTIONAL
char * pyrna_enum_repr(const EnumPropertyItem *item)
static int bpy_class_call(bContext *C, PointerRNA *ptr, FunctionRNA *func, ParameterList *parms)
ReportList * CTX_wm_reports(const bContext *C)
static int pyrna_struct_init(PyObject *self, PyObject *args, PyObject *)
int pyrna_py_to_array(PointerRNA *ptr, PropertyRNA *prop, char *param_data, PyObject *py, const char *error_prefix)
static PyObject * pyrna_struct_path_from_id(BPy_StructRNA *self, PyObject *args)
int8_t PyC_Long_AsI8(PyObject *value)
int RNA_property_string_maxlength(PropertyRNA *prop)
int RNA_property_int_get(PointerRNA *ptr, PropertyRNA *prop)
static PyObject * pyrna_struct_is_property_set(BPy_StructRNA *self, PyObject *args, PyObject *kw)
IDProperty ** RNA_struct_idprops_p(PointerRNA *ptr)
void RNA_property_int_range(PointerRNA *ptr, PropertyRNA *prop, int *hardmin, int *hardmax)
void bpy_context_clear(struct bContext *C, const PyGILState_STATE *gilstate)
void RNA_def_struct_name_property(StructRNA *srna, PropertyRNA *prop, const bool allow_replace)
DynStr * BLI_dynstr_new() ATTR_MALLOC ATTR_WARN_UNUSED_RESULT
static PyObject * pyweakref_get_ref(PyObject *ref)
static PyObject * pyrna_struct_get_nameprop_as_pyobject(PointerRNA *ptr, BPy_NamePropAsPyObject_Cache &nameprop_cache)
static PyObject * pyrna_param_to_py(PointerRNA *ptr, PropertyRNA *prop, void *data)
BLI_INLINE bool BLI_ghashIterator_done(const GHashIterator *ghi) ATTR_WARN_UNUSED_RESULT
static bool foreach_attr_type(BPy_PropertyRNA *self, const char *attr, RawPropertyType *r_raw_type, int *r_attr_tot, bool *r_attr_signed, bool *r_is_empty)
bool IDP_ui_data_supported(const IDProperty *prop)
PyMethodDef meth_bpy_owner_id_get
static int pyrna_prop_array_contains(BPy_PropertyRNA *self, PyObject *value)
int pyrna_struct_validity_check_only(const BPy_StructRNA *pysrna)
static bool pyrna_status_ok_or_error(eRNAStatus status, const char *error_prefix)
static Py_hash_t pyrna_struct_hash(BPy_StructRNA *self)
static uchar mathutils_rna_matrix_cb_index
static PyObject * pyrna_prop_collection_subscript_int(BPy_PropertyRNA *self, Py_ssize_t keynum)
int pyrna_array_contains_py(PointerRNA *ptr, PropertyRNA *prop, PyObject *value)
static int pyrna_deferred_register_class_from_type_hints(StructRNA *srna, PyTypeObject *py_class)
static PyObject * pyrna_struct_bl_rna_find_subclass_recursive(PyObject *cls, const char *id)
static PyObject * pyrna_prop_dir(BPy_PropertyRNA *self)
PyObject * Euler_CreatePyObject_cb(PyObject *cb_user, const short order, uchar cb_type, uchar cb_subtype)
const ListBaseT< PropertyRNA > * RNA_function_defined_parameters(FunctionRNA *func)
void RNA_parameter_list_free(ParameterList *parms)
static PyTypeObject pyrna_prop_collection_idprop_Type
PyObject * bpy_intern_str___module__
void RNA_property_float_range(PointerRNA *ptr, PropertyRNA *prop, float *hardmin, float *hardmax)
PyObject * bpy_intern_str_bl_rna
StructRegisterFunc RNA_struct_register(StructRNA *type)
static const char * BPy_capsule_PointerRNA_identifier
static PyObject * pyrna_struct_type_recast(BPy_StructRNA *self)
void BPY_update_rna_module()
int BPy_Wrap_SetMapItem(IDProperty *prop, PyObject *key, PyObject *val)
static PyObject * pyrna_prop_collection_keys(BPy_PropertyRNA *self)
static int pyrna_prop_to_enum_bitfield(PointerRNA *ptr, PropertyRNA *prop, PyObject *value, int *r_value, const char *error_prefix)
header-only compatibility defines.
#define PyTuple_SET_ITEMS(op_arg,...)
PyObject_HEAD std::optional< PointerRNA > ptr
vectorcallfunc vectorcall
PyObject_HEAD std::optional< PointerRNA > ptr
PyObject_HEAD IDProperty * property
struct IDProperty * parent
PyObject_HEAD struct ID * owner_id
PyObject *(*) nameprop_as_py_object_fn(const char *, Py_ssize_t)
PyObject_HEAD std::optional< PointerRNA > ptr
PyObject_HEAD std::optional< CollectionPropertyIterator > iter
PyObject_HEAD std::optional< PointerRNA > ptr
PyObject_HEAD std::optional< PointerRNA > ptr
std::optional< PointerRNA > ptr
Vector< PointerRNA > items
ListBaseT< Library > libraries
struct ReportList * reports