43#ifdef USE_PYRNA_INVALIDATE_WEAKREF
50#include "RNA_prototypes.hh"
77#define USE_PEDANTIC_WRITE
79#define USE_STRING_COERCE
88#define USE_POSTPONED_ANNOTATIONS
138#define BPY_DOC_ID_PROP_TYPE_NOTE \
141 " Limited to: :ref:`bpy_types-custom_properties`.\n"
145 if (pysrna->
ptr->type) {
154 PyExc_ReferenceError,
"StructRNA of type %.200s has been removed", Py_TYPE(pysrna)->tp_name);
159 if (pysrna->
ptr->type) {
168 if (
self->ptr->type) {
171 PyErr_Format(PyExc_ReferenceError,
172 "PropertyRNA of type %.200s.%.200s has been removed",
173 Py_TYPE(
self)->tp_name,
180 self->ptr->invalidate();
187 PyErr_WarnFormat(PyExc_DeprecationWarning,
189 "'%s.%s' is expected to be removed in Blender %d.%d",
197#ifdef USE_PYRNA_INVALIDATE_GC
198# define FROM_GC(g) ((PyObject *)(((PyGC_Head *)g) + 1))
201struct gc_generation {
207static void id_release_gc(
struct ID *
id)
211 for (j = 0; j < 3; j++) {
213 PyGC_Head *gen = (PyGC_Head *)(((
char *)_PyGC_generation0) + (
sizeof(gc_generation) * j));
214 PyGC_Head *g = gen->gc.gc_next;
215 while ((g = g->gc.gc_next) != gen) {
216 PyObject *ob = FROM_GC(g);
221 if (ob_ptr->
ptr->owner_id ==
id) {
233#ifdef USE_PYRNA_INVALIDATE_WEAKREF
236struct GHash *id_weakref_pool =
nullptr;
237static PyObject *id_free_weakref_cb(PyObject *weakinfo_pair, PyObject *weakref);
238static PyMethodDef id_free_weakref_cb_def = {
239 "id_free_weakref_cb", (PyCFunction)id_free_weakref_cb, METH_O,
nullptr};
244static void id_weakref_pool_free_value_fn(
void *p)
246 GHash *weakinfo_hash =
static_cast<GHash *
>(p);
251static GHash *id_weakref_pool_get(
ID *
id)
254 if (weakinfo_hash ==
nullptr) {
260 return weakinfo_hash;
267 PyObject *weakref_capsule;
268 PyObject *weakref_cb_py;
272 GHash *weakinfo_hash = id_weakref_pool_get(
id);
274 weakref_capsule = PyCapsule_New(weakinfo_hash,
nullptr,
nullptr);
275 weakref_cb_py = PyCFunction_New(&id_free_weakref_cb_def, weakref_capsule);
279 weakref = PyWeakref_NewRef((PyObject *)pyrna, weakref_cb_py);
291static ID *_id_tmp_ptr;
292static void value_id_set(
void *
id)
294 _id_tmp_ptr = (
ID *)
id;
297static void id_release_weakref_list(
struct ID *
id,
GHash *weakinfo_hash);
298static PyObject *id_free_weakref_cb(PyObject *weakinfo_pair, PyObject *weakref)
301 GHash *weakinfo_hash =
static_cast<GHash *
>(PyCapsule_GetPointer(weakinfo_pair,
nullptr));
308 id_release_weakref_list(_id_tmp_ptr, weakinfo_hash);
316static void id_release_weakref_list(
struct ID *
id,
GHash *weakinfo_hash)
322# ifdef DEBUG_RNA_WEAKREF
323 fprintf(stdout,
"id_release_weakref: '%s', %d items\n", id->
name,
BLI_ghash_len(weakinfo_hash));
328 PyObject *item = PyWeakref_GET_OBJECT(weakref);
329 if (item != Py_None) {
331# ifdef DEBUG_RNA_WEAKREF
347static void id_release_weakref(
struct ID *
id)
351 id_release_weakref_list(
id, weakinfo_hash);
358 PyObject *(*nameprop_as_py_object_fn)(
const char *, Py_ssize_t);
372 ptr, fixedbuf,
sizeof(fixedbuf), &name_len, &nameprop);
389 if (name_ptr != fixedbuf) {
399#ifdef USE_PYRNA_INVALIDATE_GC
403#ifdef USE_PYRNA_INVALIDATE_WEAKREF
405 if (id_weakref_pool !=
nullptr) {
406 PyGILState_STATE gilstate = PyGILState_Ensure();
408 id_release_weakref(
id);
410 PyGILState_Release(gilstate);
417#ifdef USE_PEDANTIC_WRITE
422 ID *
id =
ptr->owner_id;
424 const short idcode =
GS(id->
name);
429 if (key && PyUnicode_Check(key)) {
430 pyname = PyUnicode_AsUTF8(key);
433 pyname =
"<UNKNOWN>";
438 PyErr_Format(PyExc_AttributeError,
439 "Writing to ID classes in this context is not allowed: "
440 "%.200s, %.200s data-block, error setting %.200s.%.200s",
453#ifdef USE_PEDANTIC_WRITE
501 const short order_fallback,
508# define MATHUTILS_CB_SUBTYPE_EUL 0
509# define MATHUTILS_CB_SUBTYPE_VEC 1
510# define MATHUTILS_CB_SUBTYPE_QUAT 2
511# define MATHUTILS_CB_SUBTYPE_COLOR 3
519 return self->prop ? 0 : -1;
528 if (
self->prop ==
nullptr) {
551 if (
self->prop ==
nullptr) {
555# ifdef USE_PEDANTIC_WRITE
562 PyErr_Format(PyExc_AttributeError,
563 "bpy_prop \"%.200s.%.200s\" is read-only",
573 for (
i = 0;
i <
len;
i++) {
588 &
self->ptr.value(), eul->
order, &prop_eul_order);
589 if (order != eul->
order) {
605 if (
self->prop ==
nullptr) {
619 if (
self->prop ==
nullptr) {
623# ifdef USE_PEDANTIC_WRITE
630 PyErr_Format(PyExc_AttributeError,
631 "bpy_prop \"%.200s.%.200s\" is read-only",
664 if (
self->prop ==
nullptr) {
678 if (
self->prop ==
nullptr) {
682# ifdef USE_PEDANTIC_WRITE
689 PyErr_Format(PyExc_AttributeError,
690 "bpy_prop \"%.200s.%.200s\" is read-only",
714 const short order_fallback,
718 if (*r_prop_eul_order ==
nullptr) {
722 if (*r_prop_eul_order) {
730 return order_fallback;
739#define PROP_ALL_VECTOR_SUBTYPES \
741 case PROP_TRANSLATION: \
742 case PROP_DIRECTION: \
743 case PROP_VELOCITY: \
744 case PROP_ACCELERATION: \
750 PyObject *
ret =
nullptr;
771 goto thick_wrap_slice;
784 if (totdim == 1 || (totdim == 2 && subtype ==
PROP_MATRIX)) {
792 if (
len >= 2 &&
len <= 4) {
886 if (
ret ==
nullptr) {
917 return (((a->
ptr->data ==
b->ptr->data) && (a->
ptr->type ==
b->ptr->type)) ? 0 : -1);
923 ((a->
prop ==
b->prop) && (a->
ptr->data ==
b->ptr->data) && (a->
ptr->type ==
b->ptr->type)) ?
942 res = ok ? Py_False : Py_True;
949 res = Py_NotImplemented;
956 return Py_NewRef(res);
973 res = ok ? Py_False : Py_True;
980 res = Py_NotImplemented;
987 return Py_NewRef(res);
995 const char *extra_info =
"";
998 return PyUnicode_FromFormat(
"<bpy_struct, %.200s invalid>", Py_TYPE(
self)->tp_name);
1001 ID *
id =
self->ptr->owner_id;
1003 extra_info =
", evaluated";
1012 ret = PyUnicode_FromFormat(
"<bpy_struct, %.200s(\"%.200s\") at %p%s>",
1021 return PyUnicode_FromFormat(
"<bpy_struct, %.200s at %p%s>",
1029 ID *
id =
self->ptr->owner_id;
1038 tmp_str = PyUnicode_FromString(id->
name + 2);
1041 ret = PyUnicode_FromFormat(
1045 ID *real_id =
nullptr;
1054 if (real_id !=
nullptr) {
1056 tmp_str = PyUnicode_FromString(real_id->
name + 2);
1057 ret = PyUnicode_FromFormat(
"bpy.data.%s[%R].%s",
1064 ret = PyUnicode_FromFormat(
"bpy.data.%s[%R]...%s",
1072 ret = PyUnicode_FromFormat(
"bpy.data.%s[%R]...%s",
1089 const char *type_id =
nullptr;
1090 char type_lower[64];
1091 char type_count[16];
1100 PyErr_SetString(PyExc_RuntimeError,
"could not use property type, internal error");
1119 type_count[0] =
'\0';
1128 ret = PyUnicode_FromFormat(
"<bpy_%.200s%.200s, %.200s.%.200s(\"%.200s\")>",
1141 return PyUnicode_FromFormat(
1146 return PyUnicode_FromFormat(
"<bpy_%.200s%.200s, %.200s.%.200s>",
1155 ID *
id =
self->ptr->owner_id;
1161 if (
id ==
nullptr) {
1166 tmp_str = PyUnicode_FromString(id->
name + 2);
1170 ID *real_id =
nullptr;
1172 G_MAIN, &
self->ptr.value(),
self->prop, index_dim, index, &real_id);
1175 if (real_id !=
id) {
1177 tmp_str = PyUnicode_FromString(real_id->
name + 2);
1179 const char *data_delim = ((*path)[0] ==
'[') ?
"" :
".";
1180 ret = PyUnicode_FromFormat(
"bpy.data.%s[%R]%s%s",
1188 ret = PyUnicode_FromFormat(
"bpy.data.%s[%R]...%s",
1211 return PyUnicode_FromFormat(
"<%.200s %.200s.%.200s()>",
1212 Py_TYPE(
self)->tp_name,
1226 if (
self->ptr->data ==
nullptr) {
1246#ifdef USE_PYRNA_STRUCT_REFERENCE
1247static int pyrna_struct_traverse(
BPy_StructRNA *
self, visitproc visit,
void *arg)
1249 Py_VISIT(
self->reference);
1255 Py_CLEAR(
self->reference);
1260#ifdef USE_PYRNA_STRUCT_REFERENCE
1263 if (
self->reference) {
1264 PyObject_GC_UnTrack(
self);
1265 Py_CLEAR(
self->reference);
1270 self->reference = reference;
1271 Py_INCREF(reference);
1273 PyObject_GC_Track(
self);
1302 const char *param = PyUnicode_AsUTF8(item);
1304 if (param ==
nullptr) {
1305 PyErr_Format(PyExc_TypeError,
1306 "%.200s expected a string enum, not %.200s",
1308 Py_TYPE(item)->tp_name);
1314 PyErr_Format(PyExc_TypeError,
1315 "%.200s enum \"%.200s\" not found in (%s)",
1335 if (!PyAnySet_Check(value)) {
1336 PyErr_Format(PyExc_TypeError,
1337 "%.200s, %.200s.%.200s expected a set, not a %.200s",
1341 Py_TYPE(value)->tp_name);
1351 if (PySet_GET_SIZE(value)) {
1352 PyErr_Format(PyExc_TypeError,
1353 "%.200s: empty enum \"%.200s\" could not have any values assigned",
1372 PyObject *item, *
ret =
nullptr;
1377 ret = PySet_New(
nullptr);
1382 for (index = 0; identifier[index]; index++) {
1383 item = PyUnicode_FromString(identifier[index]);
1384 PySet_Add(
ret, item);
1390 const char *identifier;
1392 ret = PyUnicode_FromString(identifier);
1408 "current value '%d' "
1409 "matches no enum in '%s', '%s', '%s'",
1416 char error_str[256];
1419 "RNA Warning: Current value \"%d\" "
1420 "matches no enum in '%s', '%s', '%s'",
1426 PyErr_Warn(PyExc_RuntimeWarning, error_str);
1434 ret = PyUnicode_FromString(
"");
1436 PyErr_Format(PyExc_AttributeError,
"RNA Error: Current value \"%d\" matches no enum", val);
1476#ifdef USE_STRING_COERCE
1479 ret = PyBytes_FromStringAndSize(buf, buf_len);
1485 ret = PyUnicode_FromStringAndSize(buf, buf_len);
1489 ret = PyBytes_FromStringAndSize(buf, buf_len);
1492 ret = PyUnicode_FromStringAndSize(buf, buf_len);
1495 if (buf_fixed != buf) {
1520 PyErr_Format(PyExc_TypeError,
1521 "bpy_struct internal error: unknown type '%d' (pyrna_prop_to_py)",
1532 const bool all_args,
1533 const char *error_prefix)
1537 const char *arg_name =
nullptr;
1540 totkw = kw ? PyDict_Size(kw) : 0;
1545 if (
STREQ(arg_name,
"rna_type")) {
1549 if (kw ==
nullptr) {
1551 PyExc_TypeError,
"%.200s: no keywords, expected \"%.200s\"", error_prefix, arg_name);
1556 item = PyDict_GetItemString(kw, arg_name);
1558 if (item ==
nullptr) {
1560 PyErr_Format(PyExc_TypeError,
1561 "%.200s: keyword \"%.200s\" missing",
1563 arg_name ? arg_name :
"<UNKNOWN>");
1578 if (error_val == 0 && totkw > 0) {
1579 PyObject *key, *value;
1582 while (PyDict_Next(kw, &
pos, &key, &value)) {
1583 arg_name = PyUnicode_AsUTF8(key);
1590 PyErr_Format(PyExc_TypeError,
1591 "%.200s: keyword \"%.200s\" unrecognized",
1593 arg_name ? arg_name :
"<UNKNOWN>");
1627 param = PyObject_IsTrue(value);
1630 param = PyC_Long_AsI32(value);
1638 PyErr_Format(PyExc_TypeError,
1639 "%.200s %.200s.%.200s expected True/False or 0/1, not %.200s",
1643 Py_TYPE(value)->tp_name);
1648 *((
bool *)
data) = param;
1658 const long param = PyLong_AsLongAndOverflow(value, &overflow);
1659 if (overflow || (param > INT_MAX) || (param < INT_MIN)) {
1660 PyErr_Format(PyExc_ValueError,
1661 "%.200s %.200s.%.200s value not in 'int' range "
1668 if (param == -1 && PyErr_Occurred()) {
1669 PyErr_Format(PyExc_TypeError,
1670 "%.200s %.200s.%.200s expected an int type, not %.200s",
1674 Py_TYPE(value)->tp_name);
1678 int param_i = int(param);
1681 *((
int *)
data) = param_i;
1690 const float param = PyFloat_AsDouble(value);
1691 if (PyErr_Occurred()) {
1692 PyErr_Format(PyExc_TypeError,
1693 "%.200s %.200s.%.200s expected a float type, not %.200s",
1697 Py_TYPE(value)->tp_name);
1703 *((
float *)
data) = param;
1716 if (value == Py_None) {
1723 *((
char **)
data) = (
char *)
nullptr;
1731 PyErr_Format(PyExc_TypeError,
1732 "%.200s %.200s.%.200s doesn't support None from string types",
1743 param = PyBytes_AsString(value);
1745 if (param ==
nullptr) {
1746 if (PyBytes_Check(value)) {
1751 "%.200s %.200s.%.200s error assigning bytes",
1757 PyErr_Format(PyExc_TypeError,
1758 "%.200s %.200s.%.200s expected a bytes type, not %.200s",
1762 Py_TYPE(value)->tp_name);
1773 *((
char **)
data) = (
char *)param;
1782#ifdef USE_STRING_COERCE
1783 PyObject *value_coerce =
nullptr;
1789 param = PyUnicode_AsUTF8(value);
1792 param = PyUnicode_AsUTF8(value);
1795 if (param ==
nullptr) {
1796 if (PyUnicode_Check(value)) {
1801 "%.200s %.200s.%.200s error assigning string",
1807 PyErr_Format(PyExc_TypeError,
1808 "%.200s %.200s.%.200s expected a string type, not %.200s",
1812 Py_TYPE(value)->tp_name);
1821 char warning_buf[256];
1823 "%.200s.%.200s: does not support blend relative \"//\" prefix",
1826 PyErr_WarnEx(PyExc_RuntimeWarning, warning_buf, 1);
1839 *((
char **)
data) = (
char *)param;
1846#ifdef USE_STRING_COERCE
1847 Py_XDECREF(value_coerce);
1870 *((
int *)
data) = val;
1879 PyObject *value_new =
nullptr;
1901 if (
ELEM(base_type, &RNA_Operator, &RNA_Gizmo)) {
1909 if (PyDict_Check(value)) {
1911 if (
ELEM(base_type, &RNA_OperatorProperties, &RNA_GizmoProperties)) {
1923 if (
ptr->type != &RNA_Function) {
1924 PyErr_Format(PyExc_TypeError,
1925 "%.200s %.200s.%.200s internal error coercing a dict for %.200s type",
1945 PyErr_Format(PyExc_TypeError,
1946 "%.200s %.200s.%.200s collection has no type, "
1947 "cannot be used as a %.200s type",
1957 if (value == Py_None) {
1959 PyErr_Format(PyExc_TypeError,
1960 "%.200s %.200s.%.200s does not support a 'None' assignment %.200s type",
1965 Py_XDECREF(value_new);
1972 PyErr_Format(PyExc_TypeError,
1973 "%.200s %.200s.%.200s expected a %.200s type, not %.200s",
1978 Py_TYPE(value)->tp_name);
1979 Py_XDECREF(value_new);
1985 if (value_owner_id !=
nullptr) {
1987 PyErr_Format(PyExc_TypeError,
1988 "%.200s %.200s.%.200s ID type does not support assignment to itself",
1992 Py_XDECREF(value_new);
1998 if (
ptr->type != &RNA_Function) {
1999 PyErr_Format(PyExc_TypeError,
2000 "%.200s %.200s.%.200s ID type assignment is temporary, cannot assign",
2004 Py_XDECREF(value_new);
2011 bool raise_error =
false;
2016 if (param ==
nullptr) {
2031 if (param ==
nullptr) {
2032 *((
void **)
data) =
nullptr;
2042 else if (param ==
nullptr) {
2043 *((
void **)
data) =
nullptr;
2046 *((
void **)
data) = param->
ptr->data;
2061 Py_XDECREF(value_new);
2076 PyErr_Format(PyExc_TypeError,
2077 "%.200s %.200s.%.200s expected a %.200s type, not %.200s",
2084 Py_XDECREF(value_new);
2088 Py_XDECREF(value_new);
2093 Py_ssize_t seq_len,
i;
2101 if (!PySequence_Check(value)) {
2104 "%.200s %.200s.%.200s expected a sequence for an RNA collection, not %.200s",
2108 Py_TYPE(value)->tp_name);
2112 seq_len = PySequence_Size(value);
2113 for (
i = 0;
i < seq_len;
i++) {
2114 item = PySequence_GetItem(value,
i);
2116 if (item ==
nullptr) {
2119 "%.200s %.200s.%.200s failed to get sequence index '%d' for an RNA collection",
2128 if (PyDict_Check(item) == 0) {
2129 PyErr_Format(PyExc_TypeError,
2130 "%.200s %.200s.%.200s expected a each sequence "
2131 "member to be a dict for an RNA collection, not %.200s",
2135 Py_TYPE(item)->tp_name);
2148 &itemptr, item,
true,
"Converting a Python list to an RNA collection") == -1)
2151 const char *msg_char = PyUnicode_AsUTF8(msg);
2154 PyErr_Format(PyExc_TypeError,
2155 "%.200s %.200s.%.200s error converting a member of a collection "
2156 "from a dicts into an RNA collection, failed with: %s",
2172 PyErr_Format(PyExc_AttributeError,
2173 "%.200s %.200s.%.200s unknown property type (pyrna_py_to_prop)",
2206 &
self->ptr.value(),
self->prop,
self->arraydim,
self->arrayoffset, index, value,
"") ==
2229 int param = PyC_Long_AsI32(value);
2230 if (param == -1 && PyErr_Occurred()) {
2231 PyErr_SetString(PyExc_TypeError,
"expected an int type");
2241 float param = PyFloat_AsDouble(value);
2242 if (PyErr_Occurred()) {
2243 PyErr_SetString(PyExc_TypeError,
"expected a float type");
2253 PyErr_SetString(PyExc_AttributeError,
"not an array type");
2305#define PYRNA_PROP_COLLECTION_ABS_INDEX(ret_err) \
2307 keynum_abs += RNA_property_collection_length(&self->ptr.value(), self->prop); \
2308 if (keynum_abs < 0) { \
2309 PyErr_Format(PyExc_IndexError, "bpy_prop_collection[%d]: out of range.", keynum); \
2320 if (value != Py_None) {
2323 if (
UNLIKELY(value_pyrna->
ptr->type ==
nullptr)) {
2326 PyErr_Format(PyExc_TypeError,
2327 "'%.200s' object is not subscriptable (only iteration is supported)",
2328 Py_TYPE(value)->tp_name);
2336 const char *error_prefix)
2338 PyErr_Format(PyExc_TypeError,
2339 "%.200s: %.200s.%.200s does not support string lookups",
2346 const char *error_prefix)
2360 Py_ssize_t keynum_abs = keynum;
2373 const int key = int(keynum_abs);
2374 PyObject *
result =
nullptr;
2398 if (keynum_abs >=
len) {
2399 PyErr_Format(PyExc_IndexError,
2400 "bpy_prop_collection[index]: "
2401 "index %d out of range, size %d",
2406 PyErr_Format(PyExc_RuntimeError,
2407 "bpy_prop_collection[index]: internal error, "
2408 "valid index %d given in %d sized collection, but value not found",
2421 Py_ssize_t keynum_abs = keynum;
2432 if (keynum_abs >=
len) {
2433 PyErr_Format(PyExc_IndexError,
2434 "bpy_prop_collection[index] = value: "
2435 "index %d out of range, size %d",
2440 PyErr_Format(PyExc_IndexError,
2441 "bpy_prop_collection[index] = value: "
2442 "index %d failed assignment (unknown reason)",
2463 if (keynum >= 0 && keynum <
len) {
2467 PyErr_Format(PyExc_IndexError,
"bpy_prop_array[index]: index %d out of range", keynum);
2484 const int key_len = strlen(keyname);
2487 PyObject *
result =
nullptr;
2498 &iter.
ptr, nameprop,
name,
sizeof(
name), &name_len);
2499 if ((key_len == name_len) &&
STREQ(name_ptr, keyname)) {
2502 if (
name != name_ptr) {
2526 PyErr_Format(PyExc_KeyError,
"bpy_prop_collection[key]: key \"%.200s\" not found", keyname);
2544 const char *err_prefix,
2545 const short err_not_found,
2548 const char *keyname;
2551 if (PyTuple_GET_SIZE(key) != 2) {
2552 PyErr_Format(PyExc_KeyError,
2553 "%s: tuple key must be a pair, not size %d",
2555 PyTuple_GET_SIZE(key));
2558 if (
self->ptr->type != &RNA_BlendData) {
2559 PyErr_Format(PyExc_KeyError,
2560 "%s: is only valid for bpy.data collections, not %.200s",
2565 if ((keyname = PyUnicode_AsUTF8(PyTuple_GET_ITEM(key, 0))) ==
nullptr) {
2566 PyErr_Format(PyExc_KeyError,
2567 "%s: id must be a string, not %.200s",
2569 Py_TYPE(PyTuple_GET_ITEM(key, 0))->tp_name);
2573 PyObject *keylib = PyTuple_GET_ITEM(key, 1);
2577 if (keylib == Py_None) {
2580 else if (PyUnicode_Check(keylib)) {
2582 const char *keylib_str = PyUnicode_AsUTF8(keylib);
2585 if (
lib ==
nullptr) {
2586 if (err_not_found) {
2587 PyErr_Format(PyExc_KeyError,
2588 "%s: lib filepath '%.1024s' "
2589 "does not reference a valid library",
2599 PyErr_Format(PyExc_KeyError,
2600 "%s: lib must be a string or None, not %.200s",
2602 Py_TYPE(keylib)->tp_name);
2610 ID *
id =
static_cast<ID *
>(itemptr.data);
2622 if ((found ==
false) && err_not_found) {
2624 PyErr_SetString(PyExc_KeyError,
"bpy_prop_collection[key, lib]: not found");
2633 const char *err_prefix,
2634 const bool err_not_found)
2638 self, key, err_prefix, err_not_found, &
ptr);
2640 if (contains == 1) {
2659 list = PyList_New(0);
2668 PyList_APPEND(list, item);
2671 if (
count == stop) {
2699 tuple = PyTuple_New(stop - start);
2714 values =
static_cast<float *
>(PyMem_MALLOC(
sizeof(
float) *
length));
2717 values = values_stack;
2722 PyTuple_SET_ITEM(tuple,
count - start, PyFloat_FromDouble(values[
count]));
2725 if (values != values_stack) {
2734 values =
static_cast<bool *
>(PyMem_MALLOC(
sizeof(
bool) *
length));
2737 values = values_stack;
2742 PyTuple_SET_ITEM(tuple,
count - start, PyBool_FromLong(values[
count]));
2745 if (values != values_stack) {
2754 values =
static_cast<int *
>(PyMem_MALLOC(
sizeof(
int) *
length));
2757 values = values_stack;
2762 PyTuple_SET_ITEM(tuple,
count - start, PyLong_FromLong(values[
count]));
2765 if (values != values_stack) {
2773 PyErr_SetString(PyExc_TypeError,
"not an array type");
2786 if (PyUnicode_Check(key)) {
2789 if (PyIndex_Check(key)) {
2790 const Py_ssize_t
i = PyNumber_AsSsize_t(key, PyExc_IndexError);
2791 if (
i == -1 && PyErr_Occurred()) {
2797 if (PySlice_Check(key)) {
2798 PySliceObject *key_slice = (PySliceObject *)key;
2799 Py_ssize_t
step = 1;
2801 if (key_slice->step != Py_None && !_PyEval_SliceIndex(key, &
step)) {
2805 PyErr_SetString(PyExc_TypeError,
"bpy_prop_collection[slice]: slice steps not supported");
2808 if (key_slice->start == Py_None && key_slice->stop == Py_None) {
2812 Py_ssize_t start = 0, stop = PY_SSIZE_T_MAX;
2815 if (key_slice->start != Py_None && !_PyEval_SliceIndex(key_slice->start, &start)) {
2818 if (key_slice->stop != Py_None && !_PyEval_SliceIndex(key_slice->stop, &stop)) {
2822 if (start < 0 || stop < 0) {
2836 if (stop - start <= 0) {
2837 return PyList_New(0);
2842 if (PyTuple_Check(key)) {
2845 self, key,
"bpy_prop_collection[id, lib]",
true);
2848 PyErr_Format(PyExc_TypeError,
2849 "bpy_prop_collection[key]: invalid key, "
2850 "must be a string or an int, not %.200s",
2851 Py_TYPE(key)->tp_name);
2861 if (value == Py_None) {
2863 PyErr_SetString(PyExc_TypeError,
2864 "bpy_prop_collection[key] = value: invalid, "
2865 "this collection doesn't support None assignment");
2872 PyErr_Format(PyExc_TypeError,
2873 "bpy_prop_collection[key] = value: invalid, "
2874 "expected a StructRNA type or None, not a %.200s",
2875 Py_TYPE(value)->tp_name);
2881 PyErr_Format(PyExc_TypeError,
2882 "bpy_prop_collection[key] = value: invalid, "
2883 "expected a '%.200s' type or None, not a '%.200s'",
2892 PyErr_SetString(PyExc_TypeError,
2893 "bpy_prop_collection[key] = value: internal error, "
2894 "failed to get the collection type");
2907 if (value ==
nullptr) {
2908 PyErr_SetString(PyExc_TypeError,
"del bpy_prop_collection[key]: not supported");
2916 if (PyUnicode_Check(key)) {
2921 if (PyIndex_Check(key)) {
2922 const Py_ssize_t
i = PyNumber_AsSsize_t(key, PyExc_IndexError);
2923 if (
i == -1 && PyErr_Occurred()) {
2930 else if (PySlice_Check(key)) {
2931 PySliceObject *key_slice = (PySliceObject *)key;
2932 Py_ssize_t
step = 1;
2934 if (key_slice->step != Py_None && !_PyEval_SliceIndex(key, &
step)) {
2937 else if (
step != 1) {
2938 PyErr_SetString(PyExc_TypeError,
"bpy_prop_collection[slice]: slice steps not supported");
2941 else if (key_slice->start == Py_None && key_slice->stop == Py_None) {
2945 Py_ssize_t start = 0, stop = PY_SSIZE_T_MAX;
2948 if (key_slice->start != Py_None && !_PyEval_SliceIndex(key_slice->start, &start)) {
2951 if (key_slice->stop != Py_None && !_PyEval_SliceIndex(key_slice->stop, &stop)) {
2955 if (start < 0 || stop < 0) {
2968 if (stop - start <= 0) {
2969 return PyList_New(0);
2978 PyErr_Format(PyExc_TypeError,
2979 "bpy_prop_collection[key]: invalid key, "
2980 "must be an int, not %.200s",
2981 Py_TYPE(key)->tp_name);
2990 if (PyUnicode_Check(key)) {
2991 return pyrna_prop_array_subscript_str(
self, PyUnicode_AsUTF8(key));
2995 if (PyIndex_Check(key)) {
2996 const Py_ssize_t
i = PyNumber_AsSsize_t(key, PyExc_IndexError);
2997 if (
i == -1 && PyErr_Occurred()) {
3002 if (PySlice_Check(key)) {
3003 Py_ssize_t
step = 1;
3004 PySliceObject *key_slice = (PySliceObject *)key;
3006 if (key_slice->step != Py_None && !_PyEval_SliceIndex(key, &
step)) {
3010 PyErr_SetString(PyExc_TypeError,
"bpy_prop_array[slice]: slice steps not supported");
3013 if (key_slice->start == Py_None && key_slice->stop == Py_None) {
3021 Py_ssize_t start, stop, slicelength;
3023 if (PySlice_GetIndicesEx(key,
len, &start, &stop, &
step, &slicelength) < 0) {
3027 if (slicelength <= 0) {
3028 return PyTuple_New(0);
3035 PyErr_SetString(PyExc_AttributeError,
"bpy_prop_array[key]: invalid key, key must be an int");
3045 PyObject *value_fast;
3046 if (!(value_fast = PySequence_Fast(value,
3047 "bpy_prop_array[slice] = value: "
3048 "element in assignment is not a sequence type")))
3052 if (PySequence_Fast_GET_SIZE(value_fast) !=
length) {
3054 PyErr_SetString(PyExc_ValueError,
3055 "bpy_prop_array[slice] = value: "
3056 "re-sizing bpy_struct element in arrays isn't supported");
3064 PyObject **value_items,
float *value,
int totdim,
const int dimsize[],
const float range[2])
3066 const int length = dimsize[0];
3072 if (
UNLIKELY(subvalue ==
nullptr)) {
3077 PySequence_Fast_ITEMS(subvalue), &value[index], totdim - 1, &dimsize[1], range);
3085 const float min = range[0],
max = range[1];
3088 float v = PyFloat_AsDouble(value_items[
i]);
3096 PyObject **value_items,
int *value,
int totdim,
const int dimsize[],
const int range[2])
3098 const int length = dimsize[0];
3104 if (
UNLIKELY(subvalue ==
nullptr)) {
3109 PySequence_Fast_ITEMS(subvalue), &value[index], totdim - 1, &dimsize[1], range);
3117 const int min = range[0],
max = range[1];
3120 int v = PyLong_AsLong(value_items[
i]);
3130 const int dimsize[])
3132 const int length = dimsize[0];
3138 if (
UNLIKELY(subvalue ==
nullptr)) {
3143 PySequence_Fast_ITEMS(subvalue), &value[index], totdim - 1, &dimsize[1]);
3153 const int v = PyLong_AsLong(value_items[
i]);
3167 PyObject *value_orig)
3171 void *values_alloc =
nullptr;
3174 if (value_orig ==
nullptr) {
3177 "bpy_prop_array[slice] = value: deleting with list types is not supported by bpy_struct");
3181 if (!(value = PySequence_Fast(
3182 value_orig,
"bpy_prop_array[slice] = value: assignment is not a sequence type")))
3187 if (PySequence_Fast_GET_SIZE(value) != stop - start) {
3189 PyErr_SetString(PyExc_TypeError,
3190 "bpy_prop_array[slice] = value: re-sizing bpy_struct arrays isn't supported");
3202 for (
int i = arraydim + 1;
i < totdim;
i++) {
3211 const bool is_subset = start != 0 || stop !=
length || arrayoffset != 0 || arraydim != 0;
3213 PyObject **value_items = PySequence_Fast_ITEMS(value);
3217 float *values =
static_cast<float *
>(
3219 (values_alloc = PyMem_MALLOC(
sizeof(*values) * length_flat)) :
3228 dimsize[arraydim] = stop - start;
3230 &values[arrayoffset + (start * span)],
3235 if (PyErr_Occurred()) {
3245 int *values =
static_cast<int *
>(
3247 (values_alloc = PyMem_MALLOC(
sizeof(*values) * length_flat)) :
3256 dimsize[arraydim] = stop - start;
3258 &values[arrayoffset + (start * span)],
3263 if (PyErr_Occurred()) {
3273 bool *values =
static_cast<bool *
>(
3275 (values_alloc = PyMem_MALLOC(
sizeof(
bool) * length_flat)) :
3282 dimsize[arraydim] = stop - start;
3284 &values[arrayoffset + (start * span)],
3286 &dimsize[arraydim]);
3288 if (PyErr_Occurred()) {
3297 PyErr_SetString(PyExc_TypeError,
"not an array type");
3305 PyMem_FREE(values_alloc);
3323 if (keynum >= 0 && keynum <
len) {
3327 PyErr_SetString(PyExc_IndexError,
"bpy_prop_array[index] = value: index out of range");
3341 PyErr_Format(PyExc_AttributeError,
3342 "bpy_prop_collection: attribute \"%.200s\" from \"%.200s\" is read-only",
3348 else if (PyIndex_Check(key)) {
3349 const Py_ssize_t
i = PyNumber_AsSsize_t(key, PyExc_IndexError);
3350 if (
i == -1 && PyErr_Occurred()) {
3357 else if (PySlice_Check(key)) {
3359 Py_ssize_t start, stop,
step, slicelength;
3361 if (PySlice_GetIndicesEx(key,
len, &start, &stop, &
step, &slicelength) < 0) {
3364 else if (slicelength <= 0) {
3367 else if (
step == 1) {
3378 PyErr_SetString(PyExc_TypeError,
"slice steps not supported with RNA");
3383 PyErr_SetString(PyExc_AttributeError,
"invalid key, key must be an int");
3470 if (PyTuple_Check(key)) {
3473 self, key,
"(id, lib) in bpy_prop_collection",
false,
nullptr);
3477 const char *keyname = PyUnicode_AsUTF8(key);
3479 if (keyname ==
nullptr) {
3480 PyErr_SetString(PyExc_TypeError,
3481 "bpy_prop_collection.__contains__: expected a string or a tuple of strings");
3489 self,
"bpy_prop_collection.__contains__") == -1)
3499 const char *
name = PyUnicode_AsUTF8(value);
3504 PyErr_SetString(PyExc_TypeError,
"bpy_struct.__contains__: expected a string");
3509 PyErr_SetString(PyExc_TypeError,
"bpy_struct: this type doesn't support IDProperties");
3568 const char *
name = PyUnicode_AsUTF8(key);
3573 PyErr_SetString(PyExc_TypeError,
"this type doesn't support IDProperties");
3577 if (
name ==
nullptr) {
3578 PyErr_SetString(PyExc_TypeError,
3579 "bpy_struct[key]: only strings are allowed as keys of ID properties");
3585 if (group ==
nullptr) {
3586 PyErr_Format(PyExc_KeyError,
"bpy_struct[key]: key \"%s\" not found",
name);
3592 if (idprop ==
nullptr) {
3593 PyErr_Format(PyExc_KeyError,
"bpy_struct[key]: key \"%s\" not found",
name);
3606#ifdef USE_PEDANTIC_WRITE
3612 if (group ==
nullptr) {
3613 PyErr_SetString(PyExc_TypeError,
3614 "bpy_struct[key] = val: id properties not supported for this type");
3620 if (val &&
self->ptr->type && val->
ptr->type) {
3626 "bpy_struct[key] = val: data-block id properties not supported for this type");
3643 pyrna_struct_keys_doc,
3644 ".. method:: keys()\n"
3646 " Returns the keys of this objects custom properties (matches Python's\n"
3647 " dictionary function of the same name).\n"
3649 " :return: custom property keys.\n"
3650 " :rtype: :class:`idprop.types.IDPropertyGroupViewKeys`\n"
3657 PyErr_SetString(PyExc_TypeError,
"bpy_struct.keys(): this type doesn't support IDProperties");
3668 pyrna_struct_items_doc,
3669 ".. method:: items()\n"
3671 " Returns the items of this objects custom properties (matches Python's\n"
3672 " dictionary function of the same name).\n"
3674 " :return: custom property key, value pairs.\n"
3675 " :rtype: :class:`idprop.types.IDPropertyGroupViewItems`\n"
3682 PyErr_SetString(PyExc_TypeError,
"bpy_struct.items(): this type doesn't support IDProperties");
3693 pyrna_struct_values_doc,
3694 ".. method:: values()\n"
3696 " Returns the values of this objects custom properties (matches Python's\n"
3697 " dictionary function of the same name).\n"
3699 " :return: custom property values.\n"
3700 " :rtype: :class:`idprop.types.IDPropertyGroupViewValues`\n"
3707 PyErr_SetString(PyExc_TypeError,
3708 "bpy_struct.values(): this type doesn't support IDProperties");
3719 pyrna_struct_is_property_set_doc,
3720 ".. method:: is_property_set(property, /, *, ghost=True)\n"
3722 " Check if a property is set, use for testing operator properties.\n"
3724 " :arg property: Property name.\n"
3725 " :type property: str\n"
3726 " :arg ghost: Used for operators that re-run with previous settings.\n"
3727 " In this case the property is not marked as set,\n"
3728 " yet the value from the previous execution is used.\n"
3730 " In rare cases you may want to set this option to false.\n"
3732 " :type ghost: bool\n"
3733 " :return: True when the property has been set.\n"
3739 bool use_ghost =
true;
3743 static const char *_keywords[] = {
"",
"ghost",
nullptr};
3744 static _PyArg_Parser _parser = {
3753 if (!_PyArg_ParseTupleAndKeywordsFast(args, kw, &_parser, &
name,
PyC_ParseBool, &use_ghost)) {
3758 PyErr_Format(PyExc_TypeError,
3759 "%.200s.is_property_set(\"%.200s\") not found",
3770 pyrna_struct_property_unset_doc,
3771 ".. method:: property_unset(property, /)\n"
3773 " Unset a property, will use default value afterward.\n"
3775 " :arg property: Property name.\n"
3776 " :type property: str\n");
3784 if (!PyArg_ParseTuple(args,
"s:property_unset", &
name)) {
3789 PyErr_Format(PyExc_TypeError,
3790 "%.200s.property_unset(\"%.200s\") not found",
3803 pyrna_struct_is_property_hidden_doc,
3804 ".. method:: is_property_hidden(property, /)\n"
3806 " Check if a property is hidden.\n"
3808 " :arg property: Property name.\n"
3809 " :type property: str\n"
3810 " :return: True when the property is hidden.\n"
3819 if (!PyArg_ParseTuple(args,
"s:is_property_hidden", &
name)) {
3824 PyErr_Format(PyExc_TypeError,
3825 "%.200s.is_property_hidden(\"%.200s\") not found",
3836 pyrna_struct_is_property_readonly_doc,
3837 ".. method:: is_property_readonly(property, /)\n"
3839 " Check if a property is readonly.\n"
3841 " :arg property: Property name.\n"
3842 " :type property: str\n"
3843 " :return: True when the property is readonly (not writable).\n"
3852 if (!PyArg_ParseTuple(args,
"s:is_property_readonly", &
name)) {
3857 PyErr_Format(PyExc_TypeError,
3858 "%.200s.is_property_readonly(\"%.200s\") not found",
3869 pyrna_struct_is_property_overridable_library_doc,
3870 ".. method:: is_property_overridable_library(property, /)\n"
3872 " Check if a property is overridable.\n"
3874 " :arg property: Property name.\n"
3875 " :type property: str\n"
3876 " :return: True when the property is overridable.\n"
3885 if (!PyArg_ParseTuple(args,
"s:is_property_overridable_library", &
name)) {
3890 PyErr_Format(PyExc_TypeError,
3891 "%.200s.is_property_overridable_library(\"%.200s\") not found",
3902 pyrna_struct_property_overridable_library_set_doc,
3903 ".. method:: property_overridable_library_set(property, overridable, /)\n"
3905 " Define a property as overridable or not (only for custom properties!).\n"
3907 " :arg property: Property name.\n"
3908 " :type property: str\n"
3909 " :arg overridable: Overridable status to set.\n"
3910 " :type overridable: bool\n"
3911 " :return: True when the overridable status of the property was successfully set.\n"
3921 if (!PyArg_ParseTuple(args,
"sp:property_overridable_library_set", &
name, &is_overridable)) {
3926 PyErr_Format(PyExc_TypeError,
3927 "%.200s.property_overridable_library_set(\"%.200s\") not found",
3933 return PyBool_FromLong(
3939 pyrna_struct_path_resolve_doc,
3940 ".. method:: path_resolve(path, coerce=True, /)\n"
3942 " Returns the property from the path, raise an exception when not found.\n"
3944 " :arg path: path which this property resolves.\n"
3945 " :type path: str\n"
3946 " :arg coerce: optional argument, when True, the property will be converted\n"
3947 " into its Python representation.\n"
3948 " :type coerce: bool\n"
3949 " :return: Property value or property object.\n"
3950 " :rtype: Any | :class:`bpy.types.bpy_prop`\n");
3954 PyObject *coerce = Py_True;
3961 if (!PyArg_ParseTuple(args,
"s|O!:path_resolve", &path, &PyBool_Type, &coerce)) {
3969 PyErr_Format(PyExc_IndexError,
3970 "%.200s.path_resolve(\"%.200s\") index out of range",
3979 if (coerce == Py_False) {
3989 PyErr_Format(PyExc_ValueError,
3990 "%.200s.path_resolve(\"%.200s\") could not be resolved",
3998 pyrna_struct_path_from_module_doc,
3999 ".. method:: path_from_module(property=\"\", index=-1, /)\n"
4001 " Returns the full data path to this struct (as a string) from the bpy module.\n"
4003 " :arg property: Optional property name to get the full path from\n"
4004 " :type property: str\n"
4005 " :arg index: Optional index of the property.\n"
4006 " \"-1\" means that the property has no indices.\n"
4007 " :type index: int\n"
4008 " :return: The full path to the data.\n"
4011 " :raises ValueError:\n"
4012 " if the input data cannot be converted into a full data path.\n"
4014 " .. note:: Even if all input data is correct, this function might\n"
4015 " error out because Blender cannot derive a valid path.\n"
4016 " The incomplete path will be printed in the error message.\n");
4019 const char *error_prefix =
"path_from_module(...)";
4020 const char *
name =
nullptr;
4026 if (!PyArg_ParseTuple(args,
"|si:path_from_module", &
name, &index)) {
4030 PyErr_Format(PyExc_ValueError,
"%s: indices below -1 are not supported", error_prefix);
4034 std::optional<std::string> path;
4037 if (prop ==
nullptr) {
4038 PyErr_Format(PyExc_AttributeError,
4039 "%.200s.path_from_module(\"%.200s\") not found",
4057 PyErr_Format(PyExc_ValueError,
4058 "%.200s.path_from_module(\"%s\", %d) found, but does not support path creation",
4064 PyErr_Format(PyExc_ValueError,
4065 "%.200s.path_from_module() does not support path creation for this type",
4071 if (path.value().back() ==
'.') {
4072 PyErr_Format(PyExc_ValueError,
4073 "%.200s.path_from_module() could not derive a complete path for this type.\n"
4074 "Only got \"%.200s\" as an incomplete path",
4076 path.value().c_str());
4085 pyrna_prop_path_from_module_doc,
4086 ".. method:: path_from_module()\n"
4088 " Returns the full data path to this struct (as a string) from the bpy module.\n"
4090 " :return: The full path to the data.\n"
4093 " :raises ValueError:\n"
4094 " if the input data cannot be converted into a full data path.\n"
4096 " .. note:: Even if all input data is correct, this function might\n"
4097 " error out because Blender cannot derive a valid path.\n"
4098 " The incomplete path will be printed in the error message.\n");
4104 &
self->ptr.value(), prop, -1,
true);
4107 PyErr_Format(PyExc_ValueError,
4108 "%.200s.%.200s.path_from_module() does not support path creation for this type",
4114 if (path.value().back() ==
'.') {
4117 "%.200s.%.200s.path_from_module() could not derive a complete path for this type.\n"
4118 "Only got \"%.200s\" as an incomplete path",
4121 path.value().c_str());
4130 pyrna_struct_path_from_id_doc,
4131 ".. method:: path_from_id(property=\"\", /)\n"
4133 " Returns the data path from the ID to this object (string).\n"
4135 " :arg property: Optional property name which can be used if the path is\n"
4136 " to a property of this object.\n"
4137 " :type property: str\n"
4138 " :return: The path from :class:`bpy.types.bpy_struct.id_data`\n"
4139 " to this struct and property (when given).\n"
4143 const char *
name =
nullptr;
4148 if (!PyArg_ParseTuple(args,
"|s:path_from_id", &
name)) {
4152 std::optional<std::string> path;
4155 if (prop ==
nullptr) {
4156 PyErr_Format(PyExc_AttributeError,
4157 "%.200s.path_from_id(\"%.200s\") not found",
4171 PyErr_Format(PyExc_ValueError,
4172 "%.200s.path_from_id(\"%s\") found, but does not support path creation",
4177 PyErr_Format(PyExc_ValueError,
4178 "%.200s.path_from_id() does not support path creation for this type",
4189 pyrna_prop_path_from_id_doc,
4190 ".. method:: path_from_id()\n"
4192 " Returns the data path from the ID to this property (string).\n"
4194 " :return: The path from :class:`bpy.types.bpy_struct.id_data` to this property.\n"
4204 PyErr_Format(PyExc_ValueError,
4205 "%.200s.%.200s.path_from_id() does not support path creation for this type",
4216 pyrna_prop_as_bytes_doc,
4217 ".. method:: as_bytes()\n"
4219 " Returns this string property as a byte rather than a Python string.\n"
4221 " :return: The string as bytes.\n"
4222 " :rtype: bytes\n");
4227 PyErr_Format(PyExc_TypeError,
4228 "%.200s.%.200s.as_bytes() must be a string",
4235 char buf_fixed[256], *buf;
4239 &
self->ptr.value(),
self->prop, buf_fixed,
sizeof(buf_fixed), &buf_len);
4241 ret = PyBytes_FromStringAndSize(buf, buf_len);
4243 if (buf_fixed != buf) {
4252 pyrna_prop_update_doc,
4253 ".. method:: update()\n"
4255 " Execute the properties update callback.\n"
4258 " This is called when assigning a property,\n"
4259 " however in rare cases it's useful to call explicitly.\n");
4268 pyrna_struct_type_recast_doc,
4269 ".. method:: type_recast()\n"
4271 " Return a new instance, this is needed because types\n"
4272 " such as textures can be changed at runtime.\n"
4274 " :return: a new instance of this object with the type initialized again.\n"
4275 " :rtype: :class:`bpy.types.bpy_struct`\n");
4290 PyObject *ret_test =
nullptr;
4291 PyObject *subclasses = (PyObject *)((PyTypeObject *)cls)->tp_subclasses;
4296 PyObject *key =
nullptr;
4298 PyObject *value =
nullptr;
4299 while (PyDict_Next(subclasses, &
pos, &key, &value)) {
4301 PyObject *subcls = PyWeakref_GET_OBJECT(value);
4302 if (subcls != Py_None) {
4324 pyrna_struct_bl_rna_get_subclass_py_doc,
4325 ".. classmethod:: bl_rna_get_subclass_py(id, default=None, /)\n"
4327 " :arg id: The RNA type identifier.\n"
4329 " :return: The class or default when not found.\n"
4334 PyObject *ret_default = Py_None;
4336 if (!PyArg_ParseTuple(args,
"s|O:bl_rna_get_subclass_py", &
id, &ret_default)) {
4340 if (
ret ==
nullptr) {
4343 return Py_NewRef(
ret);
4348 pyrna_struct_bl_rna_get_subclass_doc,
4349 ".. classmethod:: bl_rna_get_subclass(id, default=None, /)\n"
4351 " :arg id: The RNA type identifier.\n"
4353 " :return: The RNA type or default when not found.\n"
4354 " :rtype: :class:`bpy.types.Struct` subclass\n");
4358 PyObject *ret_default = Py_None;
4360 if (!PyArg_ParseTuple(args,
"s|O:bl_rna_get_subclass", &
id, &ret_default)) {
4366 if (py_srna ==
nullptr) {
4367 PyErr_SetString(PyExc_ValueError,
"Not a registered class");
4372 if (srna_base == &RNA_Node) {
4389 return Py_NewRef(ret_default);
4394 pyrna_struct_get_ancestors_doc,
4395 ".. method:: rna_ancestors()\n"
4397 " Return the chain of data containing this struct, if known.\n"
4398 " The first item is the root (typically an ID), the last one is the immediate parent.\n"
4401 " :return: a list of this object's ancestors.\n"
4402 " :rtype: list[:class:`bpy.types.bpy_struct`]\n");
4408 const int ancestors_num(
self->ptr->ancestors.size());
4410 ret = PyList_New(ancestors_num);
4412 for (
int i = 0;
i < ancestors_num;
i++) {
4415 PyList_SET_ITEM(
ret,
i, ancestor);
4425 list_tmp = PyDict_Keys(dict);
4426 PyList_SetSlice(list, INT_MAX, INT_MAX, list_tmp);
4433 PyObject **dict_ptr;
4435 dict_ptr = _PyObject_GetDictPtr(
self);
4437 if (dict_ptr && (dict = *dict_ptr)) {
4441 dict = ((PyTypeObject *)Py_TYPE(
self))->tp_dict;
4454 dict = ((PyTypeObject *)cls)->tp_dict;
4477 PyList_APPEND(list, PyUnicode_FromString(idname));
4496 PyList_APPEND(list, name_py);
4511 ret = PyList_New(0);
4519 if (
self->ptr->type == &RNA_Context) {
4523 PyList_APPEND(
ret, PyUnicode_FromString(
static_cast<const char *
>(link->data)));
4533 PyObject *set = PySet_New(
ret);
4536 ret = PySequence_List(set);
4545 pyrna_struct_id_properties_ensure_doc,
4546 ".. method:: id_properties_ensure()\n"
4548 " :return: the parent group for an RNA struct's custom IDProperties.\n"
4549 " :rtype: :class:`idprop.types.IDPropertyGroup`\n");
4555 PyErr_SetString(PyExc_TypeError,
"This type doesn't support IDProperties");
4563 if (idprops ==
nullptr) {
4569 group->
prop = idprops;
4571 return (PyObject *)group;
4576 pyrna_struct_id_properties_ui_doc,
4577 ".. method:: id_properties_ui(key, /)\n"
4579 " :return: Return an object used to manage an IDProperty's UI data.\n"
4580 " :arg key: String name of the property.\n"
4581 " :type key: str.\n"
4582 " :rtype: :class:`bpy.types.IDPropertyUIManager`\n");
4588 PyErr_SetString(PyExc_TypeError,
"This type doesn't support IDProperties");
4593 if (!PyArg_ParseTuple(args,
"s:ui_data", &key)) {
4601 if (parent_group ==
nullptr) {
4606 if (property ==
nullptr) {
4607 PyErr_SetString(PyExc_KeyError,
"Property not found in IDProperty group");
4612 PyErr_Format(PyExc_TypeError,
"IDProperty \"%s\" does not support UI data", property->name);
4619 return (PyObject *)ui_manager;
4624 pyrna_struct_id_properties_clear_doc,
4625 ".. method:: id_properties_clear()\n"
4627 " :return: Remove the parent group for an RNA struct's custom IDProperties.\n");
4633 PyErr_SetString(PyExc_TypeError,
"This type doesn't support IDProperties");
4650 const char *
name = PyUnicode_AsUTF8(pyname);
4658 if (
name ==
nullptr) {
4659 PyErr_SetString(PyExc_AttributeError,
"bpy_struct: __getattr__ must be a string");
4669 PyErr_SetString(PyExc_AttributeError,
"bpy_struct: no __getitem__ support for this type");
4673 ret = PyObject_GenericGetAttr((PyObject *)
self, pyname);
4684 else if (
self->ptr->type == &RNA_Context) {
4687 PyErr_Format(PyExc_AttributeError,
4688 "bpy_struct: Context is 'null', cannot get \"%.200s\" from context",
4698 std::optional<int64_t> newint;
4706 C,
name, &newptr, &newlb, &newprop, &newindex, &newstr, &newint, &newtype));
4716 if (newptr.
data ==
nullptr) {
4730 ret = PyUnicode_FromStringAndSize(newstr.
data(), newstr.
size());
4735 if (!newint.has_value()) {
4740 ret = PyLong_FromLong(*newint);
4745 ret = PyList_New(0);
4752 if (newprop !=
nullptr) {
4757 std::optional<std::string> path_str;
4770 ret = PyTuple_New(3);
4774 PyLong_FromLong(newindex));
4791 PyErr_Format(PyExc_AttributeError,
4792 "bpy_struct: Context type invalid %d, cannot get \"%.200s\" from context",
4805 ret = PyObject_GenericGetAttr((PyObject *)
self, pyname);
4811 PyErr_Format(PyExc_AttributeError,
"bpy_struct: attribute \"%.200s\" not found",
name);
4821 ret = PyObject_GenericGetAttr((PyObject *)
self, pyname);
4828static int pyrna_struct_pydict_contains(PyObject *
self, PyObject *pyname)
4830 PyObject *dict = *(_PyObject_GetDictPtr((PyObject *)
self));
4835 return PyDict_Contains(dict, pyname);
4842static PyObject *pyrna_struct_meta_idprop_getattro(PyObject *cls, PyObject *attr)
4844 PyObject *
ret = PyType_Type.tp_getattro(cls, attr);
4856 if ((
ret ==
nullptr) ) {
4866 if (
ret ==
nullptr) {
4867 PyErr_Format(PyExc_AttributeError,
4868 "StructRNA.__getattr__: attribute \"%.200s\" not found",
4869 PyUnicode_AsUTF8(attr));
4882 const char *attr_str = PyUnicode_AsUTF8(attr);
4887 PyErr_Format(PyExc_AttributeError,
4888 "pyrna_struct_meta_idprop_setattro() "
4889 "cannot set in readonly state '%.200s.%S'",
4890 ((PyTypeObject *)cls)->tp_name,
4895 if (srna ==
nullptr) {
4898 if (value && is_deferred_prop) {
4899 PyErr_Format(PyExc_AttributeError,
4900 "pyrna_struct_meta_idprop_setattro() unable to get srna from class '%.200s'",
4901 ((PyTypeObject *)cls)->tp_name);
4907 return PyType_Type.tp_setattro(cls, attr, value);
4912 if (is_deferred_prop) {
4933 PyExc_TypeError,
"struct_meta_idprop.detattr(): '%s' not a dynamic property", attr_str);
4939 return PyType_Type.tp_setattro(cls, attr, value);
4944 const char *
name = PyUnicode_AsUTF8(pyname);
4949#ifdef USE_PEDANTIC_WRITE
4955 if (
name ==
nullptr) {
4956 PyErr_SetString(PyExc_AttributeError,
"bpy_struct: __setattr__ must be a string");
4961 PyErr_Format(PyExc_AttributeError,
4962 "bpy_struct: attribute \"%.200s\" from \"%.200s\" is read-only",
4968 else if (
self->ptr->type == &RNA_Context) {
4973 PyErr_Format(PyExc_AttributeError,
4974 "bpy_struct: Context is 'null', cannot set \"%.200s\" from context",
4984 std::optional<int64_t> newint;
4988 CTX_data_get(
C,
name, &newptr, &newlb, &newprop, &newindex, &newstr, &newint, &newtype));
4992 PyExc_AttributeError,
"bpy_struct: Context property \"%.200s\" is read-only",
name);
4999 if (value ==
nullptr) {
5000 PyErr_SetString(PyExc_AttributeError,
"bpy_struct: del not supported");
5004 &
self->ptr.value(), prop,
nullptr, value,
"bpy_struct: item.attr = val:");
5007 return PyObject_GenericSetAttr((PyObject *)
self, pyname, value);
5017 ret = PyList_New(0);
5034 return PyObject_GenericGetAttr((PyObject *)
self, pyname);
5039 const char *
name = PyUnicode_AsUTF8(pyname);
5041 if (
name ==
nullptr) {
5042 PyErr_SetString(PyExc_AttributeError,
"bpy_prop_collection: __getattr__ must be a string");
5045 if (
name[0] !=
'_') {
5069 return PyObject_GenericGetAttr((PyObject *)
self, pyname);
5076 PyObject *
ret = _PyObject_GenericGetAttrWithDict((PyObject *)
self, pyname,
nullptr, 1);
5079 if ((
ret ==
nullptr) && (
name[0] !=
'_')) {
5084 ret = _PyObject_GenericGetAttrWithDict(cls, pyname,
nullptr, 1);
5087 if (
ret !=
nullptr) {
5088 if (Py_TYPE(
ret) == &PyMethodDescr_Type) {
5089 PyMethodDef *m = ((PyMethodDescrObject *)
ret)->d_method;
5091 if (m->ml_flags & METH_STATIC) {
5096 ret = PyCMethod_New(m, (PyObject *)
self,
nullptr,
nullptr);
5103 if (
ret ==
nullptr) {
5105 PyExc_AttributeError,
"bpy_prop_collection: attribute \"%.200s\" not found",
name);
5116 const char *
name = PyUnicode_AsUTF8(pyname);
5120#ifdef USE_PEDANTIC_WRITE
5126 if (
name ==
nullptr) {
5127 PyErr_SetString(PyExc_AttributeError,
"bpy_prop: __setattr__ must be a string");
5130 if (value ==
nullptr) {
5131 PyErr_SetString(PyExc_AttributeError,
"bpy_prop: del not supported");
5138 &r_ptr, prop,
nullptr, value,
"BPy_PropertyRNA - Attribute (setattr):");
5142 PyErr_Format(PyExc_AttributeError,
"bpy_prop_collection: attribute \"%.200s\" not found",
name);
5151 pyrna_prop_collection_idprop_add_doc,
5152 ".. method:: add()\n"
5154 " This is a function to add a new item to a collection.\n"
5156 " :return: A newly created item.\n"
5162#ifdef USE_PEDANTIC_WRITE
5170 PyErr_SetString(PyExc_TypeError,
5171 "bpy_prop_collection.add(): not supported for this collection");
5180 pyrna_prop_collection_idprop_remove_doc,
5181 ".. method:: remove(index)\n"
5183 " This is a function to remove an item from a collection.\n"
5185 " :arg index: Index of the item to be removed.\n"
5186 " :type index: int\n");
5189 const int key = PyLong_AsLong(value);
5191#ifdef USE_PEDANTIC_WRITE
5197 if (key == -1 && PyErr_Occurred()) {
5198 PyErr_SetString(PyExc_TypeError,
"bpy_prop_collection.remove(): expected one int argument");
5203 PyErr_SetString(PyExc_TypeError,
5204 "bpy_prop_collection.remove() not supported for this collection");
5213 pyrna_prop_collection_idprop_clear_doc,
5214 ".. method:: clear()\n"
5216 " This is a function to remove all items from a collection.\n");
5219#ifdef USE_PEDANTIC_WRITE
5232 pyrna_prop_collection_idprop_move_doc,
5233 ".. method:: move(src_index, dst_index)\n"
5235 " This is a function to move an item in a collection.\n"
5237 " :arg src_index: Source item index.\n"
5238 " :type src_index: int\n"
5239 " :arg dst_index: Destination item index.\n"
5240 " :type dst_index: int\n");
5243 int key = 0,
pos = 0;
5245#ifdef USE_PEDANTIC_WRITE
5251 if (!PyArg_ParseTuple(args,
"ii", &key, &
pos)) {
5252 PyErr_SetString(PyExc_TypeError,
"bpy_prop_collection.move(): expected two ints as arguments");
5257 PyErr_SetString(PyExc_TypeError,
5258 "bpy_prop_collection.move() not supported for this collection");
5267 pyrna_struct_get_id_data_doc,
5268 "The :class:`bpy.types.ID` object this data-block is from or None, "
5269 "(not available for all data types)\n"
5271 ":type: :class:`bpy.types.ID`, (readonly)\n");
5275 if (
self->ptr->owner_id) {
5285 pyrna_struct_get_data_doc,
5286 "The data this property is using, *type* :class:`bpy.types.bpy_struct`");
5294 pyrna_struct_get_rna_type_doc,
5295 "The property type for introspection.");
5310 pyrna_struct_get_id_data_doc,
5316 pyrna_struct_get_rna_type_doc,
5318 {
nullptr,
nullptr,
nullptr,
nullptr,
nullptr}
5325 pyrna_struct_get_id_data_doc,
5327 {
nullptr,
nullptr,
nullptr,
nullptr,
nullptr}
5334 {
nullptr,
nullptr,
nullptr,
nullptr,
nullptr}
5339 pyrna_prop_collection_keys_doc,
5340 ".. method:: keys()\n"
5342 " Return the identifiers of collection members\n"
5343 " (matching Python's dict.keys() functionality).\n"
5345 " :return: the identifiers for each member of this collection.\n"
5346 " :rtype: list[str]\n");
5349 PyObject *
ret = PyList_New(0);
5354 PyList_APPEND(
ret, name_py);
5364 pyrna_prop_collection_items_doc,
5365 ".. method:: items()\n"
5367 " Return the identifiers of collection members\n"
5368 " (matching Python's dict.items() functionality).\n"
5370 " :return: (key, value) pairs for each member of this collection.\n"
5371 " :rtype: list[tuple[str, :class:`bpy.types.bpy_struct`]]\n");
5374 PyObject *
ret = PyList_New(0);
5379 if (
UNLIKELY(itemptr.data ==
nullptr)) {
5383 PyObject *item = PyTuple_New(2);
5387 PyTuple_SET_ITEM(item, 0, name_py ? name_py : PyLong_FromLong(
i));
5390 PyList_APPEND(
ret, item);
5401 pyrna_prop_collection_values_doc,
5402 ".. method:: values()\n"
5404 " Return the values of collection\n"
5405 " (matching Python's dict.values() functionality).\n"
5407 " :return: The members of this collection.\n"
5408 " :rtype: list[:class:`bpy.types.bpy_struct` | None]\n");
5417 pyrna_struct_get_doc,
5418 ".. method:: get(key, default=None, /)\n"
5420 " Returns the value of the custom property assigned to key or default\n"
5421 " when not found (matches Python's dictionary function of the same name).\n"
5423 " :arg key: The key associated with the custom property.\n"
5425 " :arg default: Optional argument for the value to return if\n"
5426 " *key* is not found.\n"
5427 " :type default: Any\n"
5428 " :return: Custom property value or default.\n"
5436 PyObject *def = Py_None;
5440 if (!PyArg_ParseTuple(args,
"s|O:get", &key, &def)) {
5446 PyErr_SetString(PyExc_TypeError,
"this type doesn't support IDProperties");
5459 return Py_NewRef(def);
5464 pyrna_struct_pop_doc,
5465 ".. method:: pop(key, default=None, /)\n"
5467 " Remove and return the value of the custom property assigned to key or default\n"
5468 " when not found (matches Python's dictionary function of the same name).\n"
5470 " :arg key: The key associated with the custom property.\n"
5472 " :arg default: Optional argument for the value to return if\n"
5473 " *key* is not found.\n"
5474 " :type default: Any\n"
5475 " :return: Custom property value or default.\n"
5483 PyObject *def =
nullptr;
5487 if (!PyArg_ParseTuple(args,
"s|O:get", &key, &def)) {
5493 PyErr_SetString(PyExc_TypeError,
"this type doesn't support IDProperties");
5513 if (def ==
nullptr) {
5514 PyErr_SetString(PyExc_KeyError,
"key not found");
5517 return Py_NewRef(def);
5522 pyrna_struct_as_pointer_doc,
5523 ".. method:: as_pointer()\n"
5525 " Returns the memory address which holds a pointer to Blender's internal data\n"
5527 " :return: int (memory address).\n"
5530 " .. note:: This is intended only for advanced script writers who need to\n"
5531 " pass blender data to their own C/Python modules.\n");
5534 return PyLong_FromVoidPtr(
self->ptr->data);
5539 pyrna_prop_collection_get_doc,
5540 ".. method:: get(key, default=None)\n"
5542 " Returns the value of the item assigned to key or default when not found\n"
5543 " (matches Python's dictionary function of the same name).\n"
5545 " :arg key: The identifier for the collection member.\n"
5547 " :arg default: Optional argument for the value to return if\n"
5548 " *key* is not found.\n"
5549 " :type default: Any\n");
5555 PyObject *def = Py_None;
5559 if (!PyArg_ParseTuple(args,
"O|O:get", &key_ob, &def)) {
5563 if (PyUnicode_Check(key_ob)) {
5564 const char *key = PyUnicode_AsUTF8(key_ob);
5570 "bpy_prop_collection.get") == -1)
5575 else if (PyTuple_Check(key_ob)) {
5577 self, key_ob,
"bpy_prop_collection.get((id, lib))",
false);
5583 PyErr_Format(PyExc_KeyError,
5584 "bpy_prop_collection.get(key, ...): key must be a string or tuple, not %.200s",
5585 Py_TYPE(key_ob)->tp_name);
5588 return Py_NewRef(def);
5593 pyrna_prop_collection_find_doc,
5594 ".. method:: find(key)\n"
5596 " Returns the index of a key in a collection or -1 when not found\n"
5597 " (matches Python's string find function of the same name).\n"
5599 " :arg key: The identifier for the collection member.\n"
5601 " :return: index of the key.\n"
5605 Py_ssize_t key_len_ssize;
5606 const char *key = PyUnicode_AsUTF8AndSize(key_ob, &key_len_ssize);
5607 const int key_len = int(key_len_ssize);
5609 char name[256], *name_ptr;
5620 if ((key_len == name_len) && memcmp(name_ptr, key, key_len) == 0) {
5625 if (
name != name_ptr) {
5634 return PyLong_FromLong(index);
5642 bool *r_attr_signed,
5646 bool attr_ok =
true;
5649 *r_attr_signed =
false;
5663 *r_is_empty =
false;
5674 const char *function_name,
5677 const char **r_attr,
5683 bool *r_attr_signed)
5685 *r_size = *r_attr_tot = 0;
5686 *r_attr_signed =
false;
5689 if (!PyArg_ParseTuple(args,
"sO:foreach_get/set", r_attr, r_seq)) {
5693 if (!PySequence_Check(*r_seq) && PyObject_CheckBuffer(*r_seq)) {
5694 PyErr_Format(PyExc_TypeError,
5695 "%s(..) expected second argument to be a sequence or buffer, not a %.200s",
5697 Py_TYPE(*r_seq)->tp_name);
5702 *r_tot = PySequence_Size(*r_seq);
5715 if (array_tot == 0) {
5716 PyErr_Format(PyExc_TypeError,
5717 "%s(..) sequence length mismatch given %d, needed 0",
5724 bool is_empty =
false;
5726 PyErr_Format(PyExc_AttributeError,
5727 "%s(..) '%.200s.%200s[...]' elements have no attribute '%.200s'",
5736 PyErr_Format(PyExc_TypeError,
5737 "%s(..) sequence length mismatch given %d, needed 0",
5750 if ((*r_attr_tot) < 1) {
5754 const int target_tot = array_tot * (*r_attr_tot);
5757 if (target_tot != (*r_tot)) {
5758 PyErr_Format(PyExc_TypeError,
5759 "%s(..) sequence length mismatch given %d, needed %d",
5771 if (*r_size == 0 && *r_attr_tot != 0) {
5773 PyExc_AttributeError,
"%s(..): attribute does not support foreach method", function_name);
5786 return (f ==
'b') ?
true :
false;
5789 return (f ==
'B') ?
true :
false;
5793 return (f ==
'B') ?
true :
false;
5796 return (f ==
'h') ?
true :
false;
5799 return (f ==
'H') ?
true :
false;
5802 return (f ==
'H') ?
true :
false;
5805 return (f ==
'i') ?
true :
false;
5808 return (f ==
'I') ?
true :
false;
5811 return (f ==
'?') ?
true :
false;
5813 return (f ==
'f') ?
true :
false;
5815 return (f ==
'd') ?
true :
false;
5818 return (f ==
'q') ?
true :
false;
5821 return (f ==
'Q') ?
true :
false;
5824 return (f ==
'Q') ?
true :
false;
5834 PyObject *item =
nullptr;
5836 bool buffer_is_compat;
5837 void *
array =
nullptr;
5849 set ?
"foreach_set" :
"foreach_get",
5856 &attr_signed) == -1)
5866 buffer_is_compat =
false;
5867 if (PyObject_CheckBuffer(seq)) {
5869 if (PyObject_GetBuffer(seq, &buf, PyBUF_ND | PyBUF_FORMAT) == -1) {
5879 if (buffer_is_compat) {
5881 nullptr, &
self->ptr.value(),
self->prop, attr, buf.buf, raw_type, tot);
5884 PyBuffer_Release(&buf);
5889 if (!buffer_is_compat) {
5892 for (;
i < tot;
i++) {
5893 item = PySequence_GetItem(seq,
i);
5911 ((
int *)
array)[
i] = int(PyC_Long_AsI32(item));
5917 ((
float *)
array)[
i] =
float(PyFloat_AsDouble(item));
5920 ((
double *)
array)[
i] = PyFloat_AsDouble(item);
5938 nullptr, &
self->ptr.value(),
self->prop, attr,
array, raw_type, tot);
5942 buffer_is_compat =
false;
5943 if (PyObject_CheckBuffer(seq)) {
5945 if (PyObject_GetBuffer(seq, &buf, PyBUF_ND | PyBUF_FORMAT) == -1) {
5955 if (buffer_is_compat) {
5957 nullptr, &
self->ptr.value(),
self->prop, attr, buf.buf, raw_type, tot);
5960 PyBuffer_Release(&buf);
5965 if (!buffer_is_compat) {
5969 nullptr, &
self->ptr.value(),
self->prop, attr,
array, raw_type, tot);
5976 for (;
i < tot;
i++) {
5980 item = PyLong_FromLong(
long(((
char *)
array)[
i]));
5983 item = PyLong_FromLong(
long(((int8_t *)
array)[
i]));
5986 item = PyLong_FromLong(
long(((uint8_t *)
array)[
i]));
5989 item = PyLong_FromLong(
long(((
short *)
array)[
i]));
5992 item = PyLong_FromLong(
long(((uint16_t *)
array)[
i]));
5995 item = PyLong_FromLong(
long(((
int *)
array)[
i]));
5998 item = PyFloat_FromDouble(
double(((
float *)
array)[
i]));
6001 item = PyFloat_FromDouble(((
double *)
array)[
i]);
6004 item = PyBool_FromLong(
long(((
bool *)
array)[
i]));
6020 PySequence_SetItem(seq,
i, item);
6030 if (PyErr_Occurred()) {
6033 PyErr_SetString(PyExc_TypeError,
"couldn't access the py sequence");
6037 PyErr_SetString(PyExc_RuntimeError,
"internal error setting the array");
6049 pyrna_prop_collection_foreach_get_doc,
6050 ".. method:: foreach_get(attr, seq)\n"
6052 " This is a function to give fast access to attributes within a collection.\n");
6062 pyrna_prop_collection_foreach_set_doc,
6063 ".. method:: foreach_set(attr, seq)\n"
6065 " This is a function to give fast access to attributes within a collection.\n");
6077 PyObject *item =
nullptr;
6078 Py_ssize_t
i, seq_size,
size;
6079 void *
array =
nullptr;
6086 PyErr_SetString(PyExc_TypeError,
"foreach_get/set available only for int and float");
6090 if (!PyArg_ParseTuple(args,
"O:foreach_get/set", &seq)) {
6094 if (!PySequence_Check(seq) && PyObject_CheckBuffer(seq)) {
6097 "foreach_get/set expected second argument to be a sequence or buffer, not a %.200s",
6098 Py_TYPE(seq)->tp_name);
6105 seq_size = PySequence_Size(seq);
6107 if (
size != seq_size) {
6108 PyErr_Format(PyExc_TypeError,
"expected sequence size %d, got %d",
size, seq_size);
6113 if (PyObject_GetBuffer(seq, &buf, PyBUF_ND | PyBUF_FORMAT) == -1) {
6116 switch (prop_type) {
6118 array = PyMem_Malloc(
sizeof(
int) *
size);
6121 item = PySequence_GetItem(seq,
i);
6122 ((
int *)
array)[
i] = int(PyLong_AsLong(item));
6127 &
self->ptr.value(),
self->prop,
static_cast<const int *
>(
array));
6133 item = PyLong_FromLong(
long(((
int *)
array)[
i]));
6134 PySequence_SetItem(seq,
i, item);
6141 array = PyMem_Malloc(
sizeof(
float) *
size);
6144 item = PySequence_GetItem(seq,
i);
6145 ((
float *)
array)[
i] =
float(PyFloat_AsDouble(item));
6150 &
self->ptr.value(),
self->prop,
static_cast<const float *
>(
array));
6154 &
self->ptr.value(),
self->prop,
static_cast<float *
>(
array));
6157 item = PyFloat_FromDouble(
double(((
float *)
array)[
i]));
6158 PySequence_SetItem(seq,
i, item);
6175 if (PyErr_Occurred()) {
6178 PyErr_SetString(PyExc_TypeError,
"couldn't access the py sequence");
6183 const char f = buf.format ? buf.format[0] : 0;
6184 if ((prop_type ==
PROP_INT && (buf.itemsize !=
sizeof(
int) || !
ELEM(f,
'l',
'i'))) ||
6185 (prop_type ==
PROP_FLOAT && (buf.itemsize !=
sizeof(
float) || f !=
'f')))
6187 PyBuffer_Release(&buf);
6188 PyErr_Format(PyExc_TypeError,
"incorrect sequence item type: %s", buf.format);
6192 switch (prop_type) {
6196 &
self->ptr.value(),
self->prop,
static_cast<const int *
>(buf.buf));
6205 &
self->ptr.value(),
self->prop,
static_cast<const float *
>(buf.buf));
6209 &
self->ptr.value(),
self->prop,
static_cast<float *
>(buf.buf));
6222 PyBuffer_Release(&buf);
6230 pyrna_prop_array_foreach_get_doc,
6231 ".. method:: foreach_get(seq)\n"
6233 " This is a function to give fast access to array data.\n");
6243 pyrna_prop_array_foreach_set_doc,
6244 ".. method:: foreach_set(seq)\n"
6246 " This is a function to give fast access to array data.\n");
6260 PyObject *iter =
nullptr;
6271 iter = PyObject_GetIter(
ret);
6280#ifndef USE_PYRNA_ITER
6287 PyObject *iter =
nullptr;
6293 iter = PyObject_GetIter(
ret);
6303# pragma clang diagnostic push
6304# pragma clang diagnostic ignored "-Wcast-function-type"
6306# pragma GCC diagnostic push
6307# pragma GCC diagnostic ignored "-Wcast-function-type"
6318 {
"get", (PyCFunction)
pyrna_struct_get, METH_VARARGS, pyrna_struct_get_doc},
6319 {
"pop", (PyCFunction)
pyrna_struct_pop, METH_VARARGS, pyrna_struct_pop_doc},
6326 METH_VARARGS | METH_KEYWORDS,
6330 METH_VARARGS | METH_KEYWORDS,
6343 METH_VARARGS | METH_KEYWORDS,
6344 pyrna_struct_is_property_set_doc},
6348 pyrna_struct_property_unset_doc},
6349 {
"is_property_hidden",
6352 pyrna_struct_is_property_hidden_doc},
6353 {
"is_property_readonly",
6356 pyrna_struct_is_property_readonly_doc},
6357 {
"is_property_overridable_library",
6360 pyrna_struct_is_property_overridable_library_doc},
6361 {
"property_overridable_library_set",
6364 pyrna_struct_property_overridable_library_set_doc},
6368 pyrna_struct_path_resolve_doc},
6372 pyrna_struct_path_from_id_doc},
6373 {
"path_from_module",
6376 pyrna_struct_path_from_module_doc},
6380 pyrna_struct_type_recast_doc},
6381 {
"bl_rna_get_subclass_py",
6383 METH_VARARGS | METH_CLASS,
6384 pyrna_struct_bl_rna_get_subclass_py_doc},
6385 {
"bl_rna_get_subclass",
6387 METH_VARARGS | METH_CLASS,
6388 pyrna_struct_bl_rna_get_subclass_doc},
6392 pyrna_struct_get_ancestors_doc},
6394 {
"id_properties_ensure",
6397 pyrna_struct_id_properties_ensure_doc},
6398 {
"id_properties_clear",
6401 pyrna_struct_id_properties_clear_doc},
6402 {
"id_properties_ui",
6405 pyrna_struct_id_properties_ui_doc},
6410 {
"callback_add", (PyCFunction)pyrna_callback_add, METH_VARARGS,
nullptr},
6411 {
"callback_remove", (PyCFunction)pyrna_callback_remove, METH_VARARGS,
nullptr},
6415 METH_VARARGS | METH_CLASS,
6419 METH_VARARGS | METH_CLASS,
6422 {
nullptr,
nullptr, 0,
nullptr},
6429 pyrna_prop_path_from_id_doc},
6430 {
"path_from_module",
6433 pyrna_prop_path_from_module_doc},
6437 {
nullptr,
nullptr, 0,
nullptr},
6444 pyrna_prop_array_foreach_get_doc},
6448 pyrna_prop_array_foreach_set_doc},
6450 {
nullptr,
nullptr, 0,
nullptr},
6457 pyrna_prop_collection_foreach_get_doc},
6461 pyrna_prop_collection_foreach_set_doc},
6467 pyrna_prop_collection_items_doc},
6471 pyrna_prop_collection_values_doc},
6475 {
nullptr,
nullptr, 0,
nullptr},
6482 pyrna_prop_collection_idprop_add_doc},
6486 pyrna_prop_collection_idprop_remove_doc},
6490 pyrna_prop_collection_idprop_clear_doc},
6494 pyrna_prop_collection_idprop_move_doc},
6495 {
nullptr,
nullptr, 0,
nullptr},
6500# pragma clang diagnostic pop
6502# pragma GCC diagnostic pop
6532 for (a = 0; a <
len; a++) {
6533 PyTuple_SET_ITEM(
ret, a, PyBool_FromLong(((
bool *)
data)[a]));
6538 for (a = 0; a <
len; a++) {
6539 PyTuple_SET_ITEM(
ret, a, PyLong_FromLong(((
int *)
data)[a]));
6553 else if (
len == 9) {
6561 for (a = 0; a <
len; a++) {
6562 PyTuple_SET_ITEM(
ret, a, PyFloat_FromDouble(((
float *)
data)[a]));
6569 PyExc_TypeError,
"RNA Error: unknown array type \"%d\" (pyrna_param_to_py)", type);
6578 ret = PyBool_FromLong(*(
bool *)
data);
6581 ret = PyLong_FromLong(*(
int *)
data);
6584 ret = PyFloat_FromDouble(*(
float *)
data);
6587 const char *data_ch;
6593 data_ch =
static_cast<const char *
>(data_alloc->
array);
6595 BLI_assert((data_ch ==
nullptr) || strlen(data_ch) == data_ch_len);
6599 data_ch_len = data_ch ? strlen(data_ch) : 0;
6602 if (
UNLIKELY(data_ch ==
nullptr)) {
6607#ifdef USE_STRING_COERCE
6609 ret = PyBytes_FromStringAndSize(data_ch, data_ch_len);
6615 ret = PyUnicode_FromStringAndSize(data_ch, data_ch_len);
6619 ret = PyBytes_FromString(buf);
6622 ret = PyUnicode_FromString(data_ch);
6661 if (newptr_p->
data) {
6672 ret = PyList_New(0);
6679 PyErr_Format(PyExc_TypeError,
"RNA Error: unknown type \"%d\" (pyrna_param_to_py)", type);
6692 const char *parm_name)
6694 const Py_ssize_t parm_name_len = strlen(parm_name);
6696 for (Py_ssize_t
i = 0;
i < nkw;
i++) {
6697 PyObject *key = PyTuple_GET_ITEM(kwnames,
i);
6698 if (PyUnicode_Check(key)) {
6699 Py_ssize_t key_buf_len;
6700 const char *key_buf = PyUnicode_AsUTF8AndSize(key, &key_buf_len);
6701 if ((parm_name_len == key_buf_len) && (memcmp(parm_name, key_buf, parm_name_len) == 0)) {
6702 return args[nargs +
i];
6715 const int parm_index,
6717 const size_t error_size)
6721 if (parm_index == -1) {
6724 "%.200s.%.200s(): error with keyword argument \"%.200s\" - ",
6732 "%.200s.%.200s(): error with argument %d, \"%.200s\" - ",
6746 PyObject *
const *args,
6758 PyObject *
ret, *item;
6759 int i, parms_len, ret_len, flag_parameter, err = 0, kw_tot = 0;
6763 void *retdata_single =
nullptr;
6769#ifdef DEBUG_STRING_FREE
6770 PyObject *string_free_ls = PyList_New(0);
6776 if (self_ptr ==
nullptr) {
6777 PyErr_SetString(PyExc_RuntimeError,
6778 "RNA functions internal RNA pointer is null, this is a bug. aborting");
6782 if (self_func ==
nullptr) {
6785 "%.200s.<unknown>(): RNA function internal function is null, this is a bug. aborting",
6796 printf(
"pyrna_func_call > %.200s.%.200s : %.200s:%d\n",
6809 const Py_ssize_t pyargs_len = PyVectorcall_NARGS(nargsf);
6810 const Py_ssize_t pykw_len = kwnames ? PyTuple_GET_SIZE(kwnames) : 0;
6817 if (pyargs_len + pykw_len > parms_len) {
6819 PyErr_Format(PyExc_TypeError,
6820 "%.200s.%.200s(): takes at most %d arguments, got %d",
6824 pyargs_len + pykw_len);
6835 if (pret_single ==
nullptr) {
6837 retdata_single = iter.
data;
6845 if (
i < pyargs_len) {
6848 PyErr_Format(PyExc_TypeError,
6849 "%.200s.%.200s(): required parameter \"%.200s\" to be a keyword argument!",
6860 else if (kwnames !=
nullptr) {
6874 if (item ==
nullptr) {
6876 PyErr_Format(PyExc_TypeError,
6877 "%.200s.%.200s(): required parameter \"%.200s\" not specified",
6888#ifdef DEBUG_STRING_FREE
6890 if (PyUnicode_Check(item)) {
6891 PyList_APPEND(string_free_ls, PyUnicode_FromString(PyUnicode_AsUTF8(item)));
6898 char error_prefix[512];
6922 if (
UNLIKELY(err == 0 && kwnames && (pykw_len > kw_tot))) {
6926 const char *arg_name, *bad_args_str, *good_args_str;
6927 bool found =
false, first =
true;
6929 for (Py_ssize_t
i = 0;
i < pykw_len;
i++) {
6930 PyObject *key = PyTuple_GET_ITEM(kwnames,
i);
6932 arg_name = PyUnicode_AsUTF8(key);
6935 if (arg_name ==
nullptr)
6952 if (found ==
false) {
6979 "%.200s.%.200s(): was called with invalid keyword argument(s) (%s), expected (%s)",
7010 ret = PyTuple_New(ret_len);
7030 if (
ret ==
nullptr) {
7037#ifdef DEBUG_STRING_FREE
7039 if (PyList_GET_SIZE(string_free_ls)) {
7040 printf(
"%.200s.%.200s(): has %d strings\n",
7043 int(PyList_GET_SIZE(string_free_ls)));
7047# undef DEBUG_STRING_FREE
7071 ret = PyUnicode_FromFormat(
"%.200s.%.200s(%.200s)\n%s",
7081 PyVarObject_HEAD_INIT(
nullptr, 0)
7082 "bpy_struct_meta_idprop",
7085 sizeof(PyHeapTypeObject),
7102 Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
7113#if defined(_MSC_VER)
7168static PyObject *
pyrna_struct_new(PyTypeObject *type, PyObject *args, PyObject * );
7173 PyVarObject_HEAD_INIT(
nullptr, 0)
7192 Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE
7193#ifdef USE_PYRNA_STRUCT_REFERENCE
7194 | Py_TPFLAGS_HAVE_GC
7198#ifdef USE_PYRNA_STRUCT_REFERENCE
7199 (traverseproc)pyrna_struct_traverse,
7200 (inquiry)pyrna_struct_clear,
7239 if (PyTuple_GET_SIZE(args) != 1) {
7240 PyErr_Format(PyExc_TypeError,
"bpy_struct.__new__(struct): expected a single argument");
7244 PyObject *arg_1 = PyTuple_GET_ITEM(args, 0);
7247 if (!PyCapsule_CheckExact(arg_1)) {
7253 "bpy_struct.__new__(struct): struct type '%.200s' is not a subtype of bpy_struct",
7254 Py_TYPE(base)->tp_name);
7258 if (Py_TYPE(base) == type) {
7261 return reinterpret_cast<PyObject *
>(base);
7268 PyObject *
self = type->tp_alloc(type, 0);
7271#ifdef USE_PYRNA_STRUCT_REFERENCE
7274 PyObject_GC_UnTrack(
self);
7276 self_struct->
ptr = std::nullopt;
7286 size_t args_num = PyTuple_GET_SIZE(args);
7287 if (args_num != 1) {
7288 PyErr_Format(PyExc_TypeError,
"bpy_struct.__init__(self, struct): expected a single argument");
7292 PyObject *arg_1 = PyTuple_GET_ITEM(args, 0);
7294 if (PyCapsule_CheckExact(arg_1)) {
7305 PyErr_Format(PyExc_TypeError,
7306 "bpy_struct.__init__(self, struct): struct type '%.200s' is not a subtype of "
7308 Py_TYPE(base_struct)->tp_name);
7312 if (base_struct == self_struct) {
7318 ptr = &base_struct->
ptr.value();
7321 if (
ptr ==
nullptr) {
7322 PyErr_Format(PyExc_TypeError,
7323 "bpy_struct.__init__(self, struct): failed to get a valid PointerRNA data "
7324 "from the given `struct` argument");
7328 self_struct->
ptr.reset();
7342 PyObject *error_type, *error_value, *error_traceback;
7343 PyErr_Fetch(&error_type, &error_value, &error_traceback);
7347#ifdef PYRNA_FREE_SUPPORT
7348 if (self_struct->freeptr && self_struct->
ptr->data) {
7350 self_struct->
ptr->data =
nullptr;
7355 if (self_struct->in_weakreflist !=
nullptr) {
7356 PyObject_ClearWeakRefs(
self);
7360#ifdef USE_PYRNA_STRUCT_REFERENCE
7361 if (self_struct->reference) {
7362 PyObject_GC_UnTrack(
self);
7363 pyrna_struct_clear(self_struct);
7366 PyTypeObject *base = Py_TYPE(
self)->tp_base;
7368 if (base && PyType_IS_GC(base)) {
7369 PyObject_GC_UnTrack(
self);
7375 self_struct->
ptr.~optional();
7380 PyErr_Restore(error_type, error_value, error_traceback);
7412 PyVarObject_HEAD_INIT(
nullptr, 0)
7431 Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
7468 PyVarObject_HEAD_INIT(
nullptr, 0)
7487 Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
7524 PyVarObject_HEAD_INIT(
nullptr, 0)
7525 "bpy_prop_collection",
7543 Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
7581 PyVarObject_HEAD_INIT(
nullptr, 0)
7582 "bpy_prop_collection_idprop",
7600 Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
7638 if (PyTuple_GET_SIZE(args) != 1) {
7639 PyErr_Format(PyExc_TypeError,
"bpy_prop.__new__(property): expected a single argument");
7643 PyObject *arg_1 = PyTuple_GET_ITEM(args, 0);
7646 if (!PyCapsule_CheckExact(arg_1)) {
7652 "bpy_prop.__new__(property): property type '%.200s' is not a subtype of bpy_prop",
7653 Py_TYPE(base)->tp_name);
7657 if (Py_TYPE(base) == type) {
7660 return reinterpret_cast<PyObject *
>(base);
7667 PyObject *
self = type->tp_alloc(type, 0);
7670 self_property->
ptr = std::nullopt;
7680 size_t args_num = PyTuple_GET_SIZE(args);
7681 if (args_num != 1) {
7682 PyErr_Format(PyExc_TypeError,
"bpy_prop.__init__(self, property): expected a single argument");
7686 PyObject *arg_1 = PyTuple_GET_ITEM(args, 0);
7689 if (PyCapsule_CheckExact(arg_1)) {
7695 if (pypropptr_rna) {
7696 ptr = pypropptr_rna->
ptr;
7697 prop = pypropptr_rna->
prop;
7707 "bpy_prop.__init__(self, property): property type '%.200s' is not a subtype of bpy_prop",
7708 Py_TYPE(base_property)->tp_name);
7712 if (base_property == self_property) {
7716 ptr = &base_property->
ptr.value();
7717 prop = base_property->
prop;
7720 self_property->
ptr = *
ptr;
7721 self_property->
prop = prop;
7729 PyObject *error_type, *error_value, *error_traceback;
7730 PyErr_Fetch(&error_type, &error_value, &error_traceback);
7734 if (self_property->in_weakreflist !=
nullptr) {
7735 PyObject_ClearWeakRefs(
self);
7739 self_property->
ptr.~optional();
7744 PyErr_Restore(error_type, error_value, error_traceback);
7751 size_t args_num = PyTuple_GET_SIZE(args);
7752 if (args_num != 1) {
7753 PyErr_Format(PyExc_TypeError,
7754 "bpy_prop_array.__init__(self, property): expected a single argument");
7758 PyObject *arg_1 = PyTuple_GET_ITEM(args, 0);
7761 if (PyCapsule_CheckExact(arg_1)) {
7767 if (pypropptr_rna) {
7768 ptr = pypropptr_rna->
ptr;
7769 prop = pypropptr_rna->
prop;
7777 PyErr_Format(PyExc_TypeError,
7778 "bpy_prop_array.__init__(self, property): property type '%.200s' is not a "
7779 "subtype of bpy_prop_array",
7780 Py_TYPE(base_property)->tp_name);
7784 if (base_property == self_property) {
7788 ptr = &base_property->
ptr.value();
7789 prop = base_property->
prop;
7792 self_property->
prop = prop;
7795 self_property->
ptr = *
ptr;
7800#ifdef USE_PYRNA_ITER
7819 PyVarObject_HEAD_INIT(
nullptr, 0)
7820 "bpy_prop_collection_iter",
7835 PyObject_GenericGetAttr,
7878 if (PyTuple_GET_SIZE(args) != 1) {
7879 PyErr_Format(PyExc_TypeError,
7880 "bpy_prop_collection_iter.__new__(arg): expected a single argument");
7884 PyObject *arg_1 = PyTuple_GET_ITEM(args, 0);
7886 if (!PyCapsule_CheckExact(arg_1)) {
7887 PyErr_Format(PyExc_TypeError,
7888 "bpy_prop_collection_iter.__new__(arg): arg type '%.200s' is not a PyCapsule",
7889 Py_TYPE(arg_1)->tp_name);
7894 PyObject *
self = type->tp_alloc(type, 0);
7897 if (self_prop_iter) {
7898 self_prop_iter->
iter = std::nullopt;
7909 size_t args_num = PyTuple_GET_SIZE(args);
7910 if (args_num != 1) {
7913 "bpy_prop_collection_iter.__init__(self, arg): expected at most a single argument");
7917 PyObject *arg_1 = PyTuple_GET_ITEM(args, 0);
7920 if (PyCapsule_CheckExact(arg_1)) {
7926 if (pypropptr_rna) {
7927 ptr = pypropptr_rna->
ptr;
7928 prop = pypropptr_rna->
prop;
7934 "bpy_prop_collection_iter.__init__(self, arg): arg type '%.200s' is not a PyCapsule",
7935 Py_TYPE(arg_1)->tp_name);
7938 if (self_prop_iter->
iter.has_value()) {
7940 self_prop_iter->
iter.reset();
7952 PyObject *error_type, *error_value, *error_traceback;
7953 PyErr_Fetch(&error_type, &error_value, &error_traceback);
7958 if (self_property->in_weakreflist !=
nullptr) {
7959 PyObject_ClearWeakRefs(
self);
7963 if (self_property->
iter.has_value()) {
7965 self_property->
iter.reset();
7971 PyErr_Restore(error_type, error_value, error_traceback);
7979 PyObject *pypropptr_rna = PyCapsule_New(
7982 PyObject *
self = PyObject_CallOneArg(
7991 self_property->in_weakreflist =
nullptr;
8003 self_property->
prop);
8010 if (self_property->
iter->valid ==
false) {
8011 PyErr_SetNone(PyExc_StopIteration);
8017# ifdef USE_PYRNA_STRUCT_REFERENCE
8020 if (iter_data != Py_None) {
8025 pyrna_struct_reference_set(iter_data_struct,
self);
8049 PyVarObject_HEAD_INIT(
nullptr, 0)
8068 Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_VECTORCALL,
8109 pyfunc->
func = func;
8115 PyErr_SetString(PyExc_MemoryError,
"couldn't create bpy_func object");
8121 return reinterpret_cast<PyObject *
>(pyfunc);
8127 PyObject *error_type, *error_value, *error_traceback;
8128 PyErr_Fetch(&error_type, &error_value, &error_traceback);
8133 if (self_func->in_weakreflist !=
nullptr) {
8134 PyObject_ClearWeakRefs(
self);
8138 self_func->
ptr.~optional();
8143 PyErr_Restore(error_type, error_value, error_traceback);
8150 Py_INCREF(newclass);
8185 const PointerRNA func_ptr = {
nullptr, srna,
nullptr};
8214 PyObject *py_base =
nullptr;
8219 if (base && base != srna) {
8225 if (py_base ==
nullptr) {
8252 PyObject *newclass = PyDict_GetItemString(
bpy_types_dict, idname);
8261 PyObject *tp_bases = ((PyTypeObject *)newclass)->tp_bases;
8262 PyObject *tp_slots = PyDict_GetItem(((PyTypeObject *)newclass)->tp_dict,
8265 if (tp_slots ==
nullptr) {
8267 BPY_LOG_RNA,
"expected class '%s' to have __slots__ defined, see _bpy_types.py", idname);
8270 else if (PyTuple_GET_SIZE(tp_bases)) {
8271 PyObject *base = PyTuple_GET_ITEM(tp_bases, 0);
8273 if (base_compare != base) {
8274 char pyob_info[256];
8277 "incorrect subclassing of SRNA '%s', expected '%s', see _bpy_types.py",
8298 PyObject *newclass =
nullptr;
8301 if (srna ==
nullptr) {
8306 Py_INCREF(newclass);
8311 Py_INCREF(newclass);
8326 PyObject *metaclass;
8333 descr =
"(no docs)";
8343 metaclass = (PyObject *)&PyType_Type;
8348 newclass = PyObject_CallFunction(
8349 metaclass,
"s(O) {sss()}", idname, py_base,
"__module__",
"bpy.types",
"__slots__");
8353 PyObject *args, *item, *value;
8356 args = PyTuple_New(3);
8359 PyTuple_SET_ITEM(args, 0, PyUnicode_FromString(idname));
8362 PyTuple_SET_ITEM(args, 1, item = PyTuple_New(1));
8363 PyTuple_SET_ITEM(item, 0, Py_NewRef(py_base));
8366 PyTuple_SET_ITEM(args, 2, item = PyDict_New());
8373 newclass = PyObject_CallObject(metaclass, args);
8404 if (
ptr->type == &RNA_Struct) {
8432 PyObject *pyptr_rna = PyCapsule_New(
8438 PyObject_CallOneArg(
reinterpret_cast<PyObject *
>(tp), pyptr_rna));
8444 PyObject_CallOneArg(
reinterpret_cast<PyObject *
>(&
pyrna_struct_Type), pyptr_rna));
8447#ifdef USE_PYRNA_STRUCT_REFERENCE
8450 if (pyrna !=
nullptr) {
8451 PyObject_GC_UnTrack(pyrna);
8456 if (pyrna !=
nullptr) {
8457 pyrna->in_weakreflist =
nullptr;
8461 if (pyrna ==
nullptr) {
8462 if (!PyErr_Occurred()) {
8463 PyErr_SetString(PyExc_MemoryError,
"couldn't create bpy_struct object");
8477#ifdef PYRNA_FREE_SUPPORT
8478 pyrna->freeptr =
false;
8481#ifdef USE_PYRNA_STRUCT_REFERENCE
8482 pyrna->reference =
nullptr;
8487#ifdef USE_PYRNA_INVALIDATE_WEAKREF
8488 if (
ptr->owner_id) {
8493 return reinterpret_cast<PyObject *
>(pyrna);
8500 if (
ptr->data ==
nullptr &&
ptr->type ==
nullptr) {
8509 if (instance && *instance) {
8513 if (
ptr->type == pyrna->
ptr->type) {
8515 return reinterpret_cast<PyObject *
>(pyrna);
8520 *instance =
nullptr;
8529 return reinterpret_cast<PyObject *
>(pyrna);
8534 if (
ptr->type == &RNA_PrimitiveString) {
8538 if (
ptr->type == &RNA_PrimitiveInt) {
8540 return PyLong_FromLong(
data->value);
8542 if (
ptr->type == &RNA_PrimitiveFloat) {
8544 return PyFloat_FromDouble(
data->value);
8546 if (
ptr->type == &RNA_PrimitiveBoolean) {
8548 return PyBool_FromLong(
data->value);
8574 PyObject *pypropptr_rna = PyCapsule_New(
8578 PyObject_CallOneArg(
reinterpret_cast<PyObject *
>(type), pypropptr_rna));
8580 if (pyrna ==
nullptr) {
8581 PyErr_SetString(PyExc_MemoryError,
"couldn't create BPy_rna object");
8589 pyrna->in_weakreflist =
nullptr;
8592#ifdef USE_PYRNA_INVALIDATE_WEAKREF
8593 if (
ptr->owner_id) {
8598 return (PyObject *)pyrna;
8635#if defined(_MSC_VER)
8668#ifdef USE_PYRNA_ITER
8674#ifdef USE_PYRNA_INVALIDATE_WEAKREF
8682#ifdef USE_PYRNA_INVALIDATE_WEAKREF
8687 const int id_weakref_pool_len =
BLI_ghash_len(id_weakref_pool);
8688 if (id_weakref_pool_len != 0) {
8689 printf(
"Found %d unreleased ID's\n", id_weakref_pool_len);
8696 BLI_ghash_free(id_weakref_pool,
nullptr, id_weakref_pool_free_value_fn);
8697 id_weakref_pool =
nullptr;
8712 return (PyObject *)pyrna;
8729PyObject *BPY_rna_doc()
8751 std::optional<PointerRNA>
ptr;
8763 const char *
name = PyUnicode_AsUTF8(pyname);
8765 if (
name ==
nullptr) {
8766 PyErr_SetString(PyExc_AttributeError,
"bpy.types: __getattr__ must be a string");
8772 if (
ret ==
nullptr) {
8773 PyErr_Format(PyExc_RuntimeError,
8774 "bpy.types.%.200s subtype could not be generated, this is a bug!",
8775 PyUnicode_AsUTF8(pyname));
8780 PyErr_Format(PyExc_AttributeError,
8781 "bpy.types.%.200s RNA_Struct does not exist",
8782 PyUnicode_AsUTF8(pyname));
8786 ret = PyObject_GenericGetAttr(
self, pyname);
8797 PyObject *
ret = PyList_New(0);
8806 PyObject *submodule_dict = PyModule_GetDict(
self);
8807 PyObject *key, *value;
8809 while (PyDict_Next(submodule_dict, &
pos, &key, &value)) {
8810 PyList_Append(
ret, key);
8817# pragma clang diagnostic push
8818# pragma clang diagnostic ignored "-Wcast-function-type"
8820# pragma GCC diagnostic push
8821# pragma GCC diagnostic ignored "-Wcast-function-type"
8828 {
nullptr,
nullptr, 0,
nullptr},
8833# pragma clang diagnostic pop
8835# pragma GCC diagnostic pop
8845 PyObject *submodule =
static_cast<PyObject *
>(
self);
8847 PyModule_GetState(submodule));
8849 state->ptr.~optional();
8854 bpy_types_module_doc,
8855 "Access to internal Blender types.");
8859 bpy_types_module_doc,
8872 PyModule_GetState(submodule));
8879 static PyTypeObject *pyrna_types[] = {
8889 PyObject *submodule_dict = PyModule_GetDict(submodule);
8891 PyDict_SetItemString(submodule_dict, pyrna_types[
i]->tp_name, (PyObject *)pyrna_types[
i]);
8911 PyModule_GetState(submodule));
8914 PyObject *arg_key, *arg_value;
8915 Py_ssize_t arg_pos = 0;
8916 while (PyDict_Next(
bpy_types_dict, &arg_pos, &arg_key, &arg_value)) {
8917 const char *key_str = PyUnicode_AsUTF8(arg_key);
8918 if (key_str[0] ==
'_') {
8924 "Members of _bpy_types.py which are not StructRNA sub-classes must use a \"_\" prefix!");
8940 if (
STREQ(key_str,
"USDHook")) {
8945 BPY_LOG_RNA,
"_bpy_types.py defines \"%.200s\" which is not a known RNA type!", key_str);
8965 if (PyType_Check(
self)) {
8968 Py_XINCREF(py_srna);
8974 if (py_srna ==
nullptr) {
8979 if (py_srna ==
nullptr) {
8980 PyErr_Format(PyExc_RuntimeError,
8981 "%.200s, missing bl_rna attribute from '%.200s' instance (may not be registered)",
8983 Py_TYPE(
self)->tp_name);
8988 PyErr_Format(PyExc_TypeError,
8989 "%.200s, bl_rna attribute wrong type '%.200s' on '%.200s'' instance",
8991 Py_TYPE(py_srna)->tp_name,
8992 Py_TYPE(
self)->tp_name);
8997 if (py_srna->
ptr->type != &RNA_Struct) {
8998 PyErr_Format(PyExc_TypeError,
8999 "%.200s, bl_rna attribute not a RNA_Struct, on '%.200s'' instance",
9001 Py_TYPE(
self)->tp_name);
9016 PyErr_Format(PyExc_TypeError,
9017 "Expected a \"bpy.types.%.200s\" not a \"%.200s\"",
9019 Py_TYPE(py_obj)->tp_name);
9023 return &bpy_srna->
ptr.value();
9028 if (py_obj == Py_None) {
9039 if (srna_parse->
ptr ==
nullptr) {
9050 if (srna_parse->
ptr ==
nullptr) {
9060 if (
self ==
nullptr) {
9063 if (PyCapsule_CheckExact(
self)) {
9064 return static_cast<StructRNA *
>(PyCapsule_GetPointer(
self,
nullptr));
9066 if (PyType_Check(
self) == 0) {
9090 PyObject *py_func =
static_cast<PyObject *
>(((
BPy_PropDeferred *)item)->fn);
9095 PyMethodDef *py_func_method_def = ((PyCFunctionObject *)py_func)->m_ml;
9096 const char *func_name = py_func_method_def->ml_name;
9098 const char *key_str = PyUnicode_AsUTF8(key);
9100 if (*key_str ==
'_') {
9101 PyErr_Format(PyExc_ValueError,
9102 "bpy_struct \"%.200s\" registration error: "
9103 "'%.200s' %.200s could not register because it starts with an '_'",
9110 PyObject *type = PyDict_GetItemString(py_kw,
"type");
9114 PyCFunctionWithKeywords py_func_ref = *(
9115 PyCFunctionWithKeywords)(
void *)PyCFunction_GET_FUNCTION(py_func);
9119 PyErr_Format(PyExc_ValueError,
9120 "bpy_struct \"%.200s\" registration error: "
9121 "'%.200s' %.200s could not register because "
9122 "this type doesn't support data-block properties",
9132 PyObject *py_srna_cobject = PyCapsule_New(srna,
nullptr,
nullptr);
9137 PyObject *args_fake = PyTuple_New(1);
9138 PyTuple_SET_ITEM(args_fake, 0, py_srna_cobject);
9140 PyObject *py_ret = PyObject_Call(py_func, args_fake, py_kw);
9152 PyErr_Format(PyExc_ValueError,
9153 "bpy_struct \"%.200s\" registration error: "
9154 "'%.200s' %.200s could not register (see previous error)",
9169 PyObject *annotations_dict =
nullptr;
9173 PyObject *typing_mod = PyImport_ImportModuleLevel(
"typing",
nullptr,
nullptr,
nullptr, 0);
9174 if (typing_mod !=
nullptr) {
9175 PyObject *get_type_hints_fn = PyObject_GetAttrString(typing_mod,
"get_type_hints");
9176 if (get_type_hints_fn !=
nullptr) {
9177 PyObject *args = PyTuple_New(1);
9179 PyTuple_SET_ITEM(args, 0, (PyObject *)py_class);
9180 Py_INCREF(py_class);
9182 annotations_dict = PyObject_CallObject(get_type_hints_fn, args);
9192 if (annotations_dict !=
nullptr) {
9193 if (PyDict_CheckExact(annotations_dict)) {
9194 PyObject *item, *key;
9197 while (PyDict_Next(annotations_dict, &
pos, &key, &item)) {
9206 PyErr_Format(PyExc_TypeError,
9207 "typing.get_type_hints returned: %.200s, expected dict\n",
9208 Py_TYPE(annotations_dict)->tp_name);
9216 fprintf(stderr,
"typing.get_type_hints failed with: %.200s\n", py_class->tp_name);
9225 PyObject *annotations_dict;
9226 PyObject *item, *key;
9233 PyDict_CheckExact(annotations_dict))
9235 while (PyDict_Next(annotations_dict, &
pos, &key, &item)) {
9249 const int len = PyTuple_GET_SIZE(py_class->tp_bases);
9253 for (
i = 0;
i <
len;
i++) {
9254 PyTypeObject *py_superclass = (PyTypeObject *)PyTuple_GET_ITEM(py_class->tp_bases,
i);
9265 if (py_superclass != &PyBaseObject_Type &&
9266 !PyObject_IsSubclass((PyObject *)py_superclass, (PyObject *)&
pyrna_struct_Type))
9289#ifdef USE_POSTPONED_ANNOTATIONS
9290 const bool use_postponed_annotations =
true;
9292 const bool use_postponed_annotations =
false;
9295 if (use_postponed_annotations) {
9307 int count = is_staticmethod ? 0 : 1;
9308 bool done_min_count =
false;
9318 done_min_count =
true;
9324 if (!done_min_count && min_count) {
9341 bool *have_function)
9346 PyObject *py_class = (PyObject *)py_data;
9348 int i, arg_count, func_arg_count, func_arg_min_count = 0;
9349 const char *py_class_name = ((PyTypeObject *)py_class)->tp_name;
9358 if (!PyObject_IsSubclass(py_class, base_class)) {
9359 PyErr_Format(PyExc_TypeError,
9360 "expected %.200s subclass of class \"%.200s\"",
9384 PyErr_Format(PyExc_AttributeError,
9385 "expected %.200s, %.200s class to have an \"%.200s\" attribute",
9398 have_function[
i] = (item !=
nullptr);
9401 if (item ==
nullptr) {
9412 PyObject *item_orig = item;
9414 if (is_staticmethod) {
9415 if (PyMethod_Check(item) == 0) {
9416 PyErr_Format(PyExc_TypeError,
9417 "expected %.200s, %.200s class \"%.200s\" "
9418 "attribute to be a static/class method, not a %.200s",
9422 Py_TYPE(item)->tp_name);
9426 item = ((PyMethodObject *)item)->im_func;
9429 if (PyFunction_Check(item) == 0) {
9430 PyErr_Format(PyExc_TypeError,
9431 "expected %.200s, %.200s class \"%.200s\" "
9432 "attribute to be a function, not a %.200s",
9436 Py_TYPE(item)->tp_name);
9444 if (func_arg_count >= 0) {
9445 arg_count = ((PyCodeObject *)PyFunction_GET_CODE(item))->co_argcount;
9450 if (is_staticmethod) {
9452 func_arg_min_count++;
9455 if (arg_count < func_arg_min_count || arg_count > func_arg_count) {
9456 if (func_arg_min_count != func_arg_count) {
9459 "expected %.200s, %.200s class \"%.200s\" function to have between %d and %d "
9471 "expected %.200s, %.200s class \"%.200s\" function to have %d args, found %d",
9487 const char *rna_attr;
9489 } bpy_property_substitutions[] = {
9505 PyObject *item =
nullptr;
9506 switch (PyObject_GetOptionalAttrString(py_class, identifier, &item)) {
9508 if (
pyrna_py_to_prop(dummy_ptr, prop,
nullptr, item,
"validating class:") != 0) {
9525 for (
i = 0;
i <
ARRAY_SIZE(bpy_property_substitutions);
i += 1) {
9526 if (
STREQ(identifier, bpy_property_substitutions[
i].rna_attr)) {
9532 PyObject *py_attr = bpy_property_substitutions[
i].py_attr;
9540 if (
pyrna_py_to_prop(dummy_ptr, prop,
nullptr, item,
"validating class:") != 0) {
9556 PyErr_Format(PyExc_AttributeError,
9557 "expected %.200s, %.200s class to have an \"%.200s\" attribute",
9580 PyObject *
ret =
nullptr, *py_srna =
nullptr, *py_class_instance =
nullptr, *parmitem;
9581 PyTypeObject *py_class;
9585 int err = 0,
i, ret_len = 0;
9591 void *retdata_single =
nullptr;
9593 PyGILState_STATE gilstate;
9595#ifdef USE_PEDANTIC_WRITE
9605 if (py_class ==
nullptr) {
9607 "unable to get Python class for RNA struct '%.200s'",
9624 if (!(is_staticmethod || is_classmethod)) {
9631 py_class_instance =
static_cast<PyObject *
>(*instance);
9632 Py_INCREF(py_class_instance);
9638 if (py_class_instance ==
nullptr) {
9642 if (py_class_instance) {
9645 else if (py_srna ==
nullptr) {
9646 py_class_instance =
nullptr;
9647 if (PyErr_Occurred()) {
9651 else if (py_srna == Py_None) {
9653 py_class_instance =
nullptr;
9654 if (PyErr_Occurred()) {
9665 if (py_class->tp_init) {
9666# ifdef USE_PEDANTIC_WRITE
9673 args = PyTuple_New(0);
9674 if (py_class->tp_init(py_srna, args,
nullptr) < 0) {
9680# ifdef USE_PEDANTIC_WRITE
9684 py_class_instance = py_srna;
9687# ifdef USE_PEDANTIC_WRITE
9696 py_class_instance = py_srna;
9697 Py_INCREF(py_class_instance);
9704 py_class_instance = PyObject_CallOneArg(
reinterpret_cast<PyObject *
>(py_class), py_srna);
9706# ifdef USE_PEDANTIC_WRITE
9712 if (py_class_instance ==
nullptr) {
9713 if (PyErr_Occurred()) {
9723 if (err != -1 && (is_staticmethod || is_classmethod || py_class_instance)) {
9726 const bool item_type_valid = (item !=
nullptr) &&
9727 (is_staticmethod ? PyMethod_Check(item) : PyFunction_Check(item));
9728 if (item_type_valid) {
9735 if (is_staticmethod) {
9737 ((PyCodeObject *)PyFunction_GET_CODE(((PyMethodObject *)item)->im_func))->co_argcount -
9741 arg_count = ((PyCodeObject *)PyFunction_GET_CODE(item))->co_argcount;
9743 args = PyTuple_New(arg_count);
9745 if (is_staticmethod) {
9748 else if (is_classmethod) {
9749 PyTuple_SET_ITEM(args, 0, (PyObject *)py_class);
9753 PyTuple_SET_ITEM(args, 0, py_class_instance);
9766 if (pret_single ==
nullptr) {
9768 retdata_single = iter.
data;
9774 if (
i < arg_count) {
9776 PyTuple_SET_ITEM(args,
i, parmitem);
9781#ifdef USE_PEDANTIC_WRITE
9788 ret = PyObject_Call(item, args,
nullptr);
9792#ifdef USE_PEDANTIC_WRITE
9802 PyErr_Format(PyExc_TypeError,
9803 "could not find function %.200s in %.200s to execute callback",
9812 PyErr_Format(PyExc_RuntimeError,
9813 "could not create instance of %.200s to call callback function '%.200s'",
9820 if (
ret ==
nullptr) {
9824 if (ret_len == 0 &&
ret != Py_None) {
9825 PyErr_Format(PyExc_RuntimeError,
9826 "expected class %.200s, function %.200s to return None, not %.200s",
9829 Py_TYPE(
ret)->tp_name);
9832 else if (ret_len == 1) {
9841 "class %.200s, function %.200s: incompatible return value ",
9846 else if (ret_len > 1) {
9848 if (PyTuple_Check(
ret) == 0) {
9851 "expected class %.200s, function %.200s to return a tuple of size %d, not %.200s",
9855 Py_TYPE(
ret)->tp_name);
9858 else if (PyTuple_GET_SIZE(
ret) != ret_len) {
9859 PyErr_Format(PyExc_RuntimeError,
9860 "class %.200s, function %.200s to returned %d items, expected %d",
9863 PyTuple_GET_SIZE(
ret),
9878 &funcptr, parm, iter.
data, PyTuple_GET_ITEM(
ret,
i++),
"calling class function:");
9894 if ((!is_staticmethod) && (!is_classmethod) && (
ptr->data) &&
9916 "Python script error in %.200s.%.200s",
9931#ifdef WITH_PYTHON_MODULE
9941 if (!Py_IsInitialized()) {
9946 PyGILState_STATE gilstate = PyGILState_Ensure();
9961 if (
self->ob_refcnt > 1) {
9971 PyGILState_Release(gilstate);
9979 bool decref =
false;
9988 if (PyObject *bases = cls->tp_bases) {
9989 const int bases_num = PyTuple_GET_SIZE(bases);
9990 for (
int i = 0;
i < bases_num;
i++) {
9991 PyTypeObject *base_cls = (PyTypeObject *)PyTuple_GET_ITEM(bases,
i);
9993 if (base_cls->tp_dict) {
10006 return base_cls_test;
10018 PyObject *subclasses =
static_cast<PyObject *
>(cls->tp_subclasses);
10021 PyObject *key =
nullptr;
10022 Py_ssize_t
pos = 0;
10023 PyObject *value =
nullptr;
10024 while (PyDict_Next(subclasses, &
pos, &key, &value)) {
10026 PyObject *value_ref = PyWeakref_GET_OBJECT(value);
10027 if (value_ref == Py_None) {
10031 PyTypeObject *sub_cls =
reinterpret_cast<PyTypeObject *
>(value_ref);
10032 if (sub_cls->tp_dict) {
10045 return sub_cls_test;
10059 PyGILState_STATE gilstate = PyGILState_Ensure();
10069 if (item ==
nullptr) {
10070 if (PyErr_Occurred()) {
10080 PyGILState_Release(gilstate);
10090 bool decref =
true;
10100#define BPY_TYPEDEF_REGISTERABLE_DOC \
10102 ":class:`bpy.types.Panel` | " \
10103 ":class:`bpy.types.UIList` | " \
10104 ":class:`bpy.types.Menu` | " \
10105 ":class:`bpy.types.Header` | " \
10106 ":class:`bpy.types.Operator` | " \
10107 ":class:`bpy.types.KeyingSetInfo` | " \
10108 ":class:`bpy.types.RenderEngine` | " \
10109 ":class:`bpy.types.AssetShelf` | " \
10110 ":class:`bpy.types.FileHandler` | " \
10111 ":class:`bpy.types.PropertyGroup` | " \
10112 ":class:`bpy.types.AddonPreferences` | " \
10113 ":class:`bpy.types.NodeTree` | " \
10114 ":class:`bpy.types.Node` | " \
10115 ":class:`bpy.types.NodeSocket`" \
10131 pyrna_register_class_doc,
10132 ".. function:: register_class(cls)\n"
10134 " Register a subclass of a Blender type class.\n"
10136 " :arg cls: Registerable Blender class type.\n"
10140 " :raises ValueError:\n"
10141 " if the class is not a subclass of a registerable blender class.\n"
10145 " If the class has a *register* class method it will be called\n"
10146 " before registration.\n");
10156 const char *identifier;
10157 PyObject *py_cls_meth;
10158 const char *error_prefix =
"register_class(...):";
10160 if (!PyType_Check(py_class)) {
10161 PyErr_Format(PyExc_ValueError,
10162 "%s expected a class argument, not '%.200s'",
10164 Py_TYPE(py_class)->tp_name);
10169 PyErr_Format(PyExc_ValueError,
10170 "%s already registered as a subclass '%.200s'",
10172 ((PyTypeObject *)py_class)->tp_name);
10177 PyErr_Format(PyExc_RuntimeError,
10178 "%s cannot run in readonly state '%.200s'",
10180 ((PyTypeObject *)py_class)->tp_name);
10186 if (srna ==
nullptr) {
10199 (PyTypeObject *)py_class))
10202 "%s warning, %.200s: references and already registered base-class %.200s\n",
10204 ((PyTypeObject *)py_class)->tp_name,
10205 base_cls_test->tp_name);
10208 (PyTypeObject *)py_class))
10211 "%s warning, %.200s: references and already registered sub-class %.200s\n",
10213 ((PyTypeObject *)py_class)->tp_name,
10214 sub_cls_test->tp_name);
10225 "%s warning, %.200s: is expected to contain a \"__slots__\" member "
10226 "to prevent arbitrary assignments.\n",
10228 ((PyTypeObject *)py_class)->tp_name);
10236 PyErr_Format(PyExc_ValueError,
10237 "%s %.200s's parent class %.200s is already registered, this is not allowed",
10239 ((PyTypeObject *)py_class)->tp_name,
10249 PyErr_Format(PyExc_ValueError,
10250 "%s expected a subclass of a registerable "
10251 "RNA type (%.200s does not support registration)",
10263 identifier = ((PyTypeObject *)py_class)->tp_name;
10288 if (srna_new ==
nullptr) {
10313 PyObject *
ret = PyObject_CallObject(py_cls_meth,
nullptr);
10333 const char **r_prop_identifier)
10363 pyrna_unregister_class_doc,
10364 ".. function:: unregister_class(cls)\n"
10366 " Unload the Python class from blender.\n"
10368 " :arg cls: Blender type class, \n"
10369 " see :mod:`bpy.utils.register_class` for classes which can \n"
10370 " be registered.\n"
10376 " If the class has an *unregister* class method it will be called\n"
10377 " before unregistering.\n");
10379 "unregister_class",
10382 pyrna_unregister_class_doc,
10389 PyObject *py_cls_meth;
10390 const char *error_prefix =
"unregister_class(...):";
10392 if (!PyType_Check(py_class)) {
10393 PyErr_Format(PyExc_ValueError,
10394 "%s expected a class argument, not '%.200s'",
10396 Py_TYPE(py_class)->tp_name);
10402 PyErr_Format(PyExc_ValueError,
"%s not a registered as a subclass", error_prefix);
10408 PyErr_Format(PyExc_RuntimeError,
10409 "%s cannot run in readonly state '%.200s'",
10411 ((PyTypeObject *)py_class)->tp_name);
10416 if (srna ==
nullptr) {
10421 PyErr_Format(PyExc_RuntimeError,
10422 "%s can't unregister a built-in class '%.200s'",
10424 ((PyTypeObject *)py_class)->tp_name);
10432 PyErr_Format(PyExc_ValueError,
10433 "%s expected type '%.200s' subclassed from a registerable RNA type "
10434 "(unregister not supported)",
10436 ((PyTypeObject *)py_class)->tp_name);
10444 PyObject *
ret = PyObject_CallObject(py_cls_meth,
nullptr);
10464 const char *prop_identifier =
nullptr;
10471 srna_iter =
static_cast<StructRNA *
>(itemptr.data);
10478 if (prop_identifier) {
10479 PyErr_Format(PyExc_RuntimeError,
10480 "%s cannot unregister %s because %s.%s pointer property is using this",
10515 PyObject *dict = type->tp_dict;
10516 if (method !=
nullptr) {
10517 for (; method->ml_name !=
nullptr; method++) {
10518 PyObject *py_method;
10520 if (method->ml_flags & METH_CLASS) {
10521 PyObject *cfunc = PyCFunction_New(method, (PyObject *)type);
10522 py_method = PyClassMethod_New(cfunc);
10525 else if (method->ml_flags & METH_STATIC) {
10526 py_method = PyCFunction_New(method,
nullptr);
10529 py_method = PyDescr_NewMethod(type, method);
10532 const int err = PyDict_SetItemString(dict, method->ml_name, py_method);
10539 if (getset !=
nullptr) {
10540 for (; getset->name !=
nullptr; getset++) {
10541 PyObject *descr = PyDescr_NewGetSet(type, getset);
10543 BLI_assert(PyDict_GetItem(dict, PyDescr_NAME(descr)) ==
nullptr);
10544 PyDict_SetItem(dict, PyDescr_NAME(descr), descr);
10563 return PyUnicode_FromString(
name);
10571 if (value == Py_None) {
10574 else if (PyUnicode_Check(value)) {
10575 name = PyUnicode_AsUTF8(value);
10578 PyErr_Format(PyExc_ValueError,
10580 "expected None or a string, not '%.200s'",
10581 Py_TYPE(value)->tp_name);
10590# pragma clang diagnostic push
10591# pragma clang diagnostic ignored "-Wcast-function-type"
10593# pragma GCC diagnostic push
10594# pragma GCC diagnostic ignored "-Wcast-function-type"
10599 "_bl_owner_id_get",
10605 "_bl_owner_id_set",
10613# pragma clang diagnostic pop
10615# pragma GCC diagnostic pop
ReportList * CTX_wm_reports(const bContext *C)
int CTX_data_get(const bContext *C, const char *member, PointerRNA *r_ptr, blender::Vector< PointerRNA > *r_lb, PropertyRNA **r_prop, int *r_index, blender::StringRef *r_str, std::optional< int64_t > *r_int_value, ContextDataType *r_type)
ListBase CTX_data_dir_get(const bContext *C)
@ CTX_RESULT_MEMBER_NOT_FOUND
Main * CTX_data_main(const bContext *C)
wmWindowManager * CTX_wm_manager(const bContext *C)
IDProperty * IDP_GetPropertyFromGroup(const IDProperty *prop, blender::StringRef name) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL()
void IDP_FreeFromGroup(IDProperty *group, IDProperty *prop) ATTR_NONNULL()
bool IDP_ui_data_supported(const IDProperty *prop)
void IDP_FreeProperty(IDProperty *prop)
const char * BKE_idtype_idcode_to_name(short idcode)
const char * BKE_idtype_idcode_to_name_plural(short idcode)
@ RPT_PRINT_HANDLED_BY_OWNER
void BKE_reports_free(ReportList *reports)
void BKE_report_print_level_set(ReportList *reports, eReportType level)
void BKE_reports_init(ReportList *reports, int flag)
#define BLI_assert_unreachable()
#define BLI_assert_msg(a, msg)
A dynamically sized string ADT.
char * BLI_dynstr_get_cstring(const DynStr *ds) ATTR_MALLOC ATTR_WARN_UNUSED_RESULT ATTR_NONNULL()
DynStr * BLI_dynstr_new(void) ATTR_MALLOC ATTR_WARN_UNUSED_RESULT
void BLI_dynstr_free(DynStr *ds) ATTR_NONNULL()
void BLI_dynstr_appendf(DynStr *__restrict ds, const char *__restrict format,...) ATTR_PRINTF_FORMAT(2
BLI_INLINE void * BLI_ghashIterator_getKey(GHashIterator *ghi) ATTR_WARN_UNUSED_RESULT
void BLI_ghashIterator_step(GHashIterator *ghi)
#define GHASH_ITER(gh_iter_, ghash_)
GHash * BLI_ghash_ptr_new(const char *info) ATTR_MALLOC ATTR_WARN_UNUSED_RESULT
unsigned int BLI_ghash_len(const GHash *gh) ATTR_WARN_UNUSED_RESULT
bool BLI_ghash_remove(GHash *gh, const void *key, GHashKeyFreeFP keyfreefp, GHashValFreeFP valfreefp)
void * BLI_ghash_lookup(const GHash *gh, const void *key) ATTR_WARN_UNUSED_RESULT
void BLI_ghash_insert(GHash *gh, void *key, void *val)
void BLI_ghash_free(GHash *gh, GHashKeyFreeFP keyfreefp, GHashValFreeFP valfreefp)
void BLI_ghashIterator_init(GHashIterator *ghi, GHash *gh)
BLI_INLINE bool BLI_ghashIterator_done(const GHashIterator *ghi) ATTR_WARN_UNUSED_RESULT
void BLI_kdtree_nd_ free(KDTree *tree)
#define LISTBASE_FOREACH(type, var, list)
void * BLI_findstring(const ListBase *listbase, const char *id, int offset) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
BLI_INLINE bool BLI_listbase_is_empty(const ListBase *lb)
void void BLI_freelistN(ListBase *listbase) ATTR_NONNULL(1)
bool BLI_path_is_rel(const char *path) ATTR_NONNULL(1) ATTR_WARN_UNUSED_RESULT
void BLI_str_tolower_ascii(char *str, size_t len) ATTR_NONNULL(1)
char * BLI_strncpy(char *__restrict dst, const char *__restrict src, size_t dst_maxncpy) ATTR_NONNULL(1
size_t size_t size_t BLI_snprintf_utf8(char *__restrict dst, size_t dst_maxncpy, const char *__restrict format,...) ATTR_NONNULL(1
#define SNPRINTF_UTF8(dst, format,...)
char * BLI_strncpy_utf8(char *__restrict dst, const char *__restrict src, size_t dst_maxncpy) ATTR_NONNULL(1
#define STRNCPY_UTF8(dst, src)
#define STREQLEN(a, b, n)
#define UNUSED_VARS_NDEBUG(...)
struct CLG_LogRef * BPY_LOG_RNA
#define CLOG_ERROR(clg_ref,...)
#define CLOG_WARN(clg_ref,...)
#define CLOG_TRACE(clg_ref,...)
T * DEG_get_original(T *id)
Read Guarded memory(de)allocation.
#define RNA_STRUCT_BEGIN(sptr, prop)
#define RNA_PROP_BEGIN(sptr, itemptr, prop)
int RNA_def_property_free_identifier(StructOrFunctionRNA *cont_, const char *identifier)
@ PARM_PYFUNC_REGISTER_OPTIONAL
#define RNA_ENUM_BITFLAG_SIZE
StructRNA *(*)(Main *bmain, ReportList *reports, void *data, const char *identifier, StructValidateFunc validate, StructCallbackFunc call, StructFreeFunc free) StructRegisterFunc
bool(*)(Main *bmain, StructRNA *type) StructUnregisterFunc
@ PROP_PATH_SUPPORTS_BLEND_RELATIVE
BMesh const char void * data
ATTR_WARN_UNUSED_RESULT const BMVert * v
void BPy_reports_write_stdout(const ReportList *reports, const char *header)
short BPy_reports_to_error(ReportList *reports, PyObject *exception, const bool clear)
bool BPy_errors_to_report(ReportList *reports)
void bpy_context_clear(struct bContext *C, const PyGILState_STATE *gilstate)
void bpy_context_set(struct bContext *C, PyGILState_STATE *gilstate)
struct bContext * BPY_context_get()
PyObject * bpy_intern_str_bpy_types
PyObject * bpy_intern_str___name__
PyObject * bpy_intern_str_register
PyObject * bpy_intern_str_bl_rna
PyObject * bpy_intern_str___module__
PyObject * bpy_intern_str___doc__
PyObject * bpy_intern_str_attr
PyObject * bpy_intern_str___annotations__
PyObject * bpy_intern_str_unregister
PyObject * bpy_intern_str___slots__
PyObject * bpy_intern_str_properties
PyObject * BPy_CollectionProperty(PyObject *self, PyObject *args, PyObject *kw)
PyObject * BPy_PointerProperty(PyObject *self, PyObject *args, PyObject *kw)
#define BPy_PropDeferred_CheckTypeExact(v)
#define PYRNA_STACK_ARRAY
static PyModuleDef bpy_types_module_def
static PyTypeObject pyrna_prop_collection_iter_Type
static PyObject * pyrna_struct_is_property_overridable_library(BPy_StructRNA *self, PyObject *args)
const PointerRNA * pyrna_struct_as_ptr(PyObject *py_obj, const StructRNA *srna)
static PyObject * pyrna_prop_collection_subscript_slice(BPy_PropertyRNA *self, Py_ssize_t start, Py_ssize_t stop)
static int mathutils_rna_vector_set(BaseMathObject *bmo, int subtype)
static PyObject * pyrna_prop_collection_get(BPy_PropertyRNA *self, PyObject *args)
PyDoc_STRVAR(pyrna_struct_keys_doc, ".. method:: keys()\n" "\n" " Returns the keys of this objects custom properties (matches Python's\n" " dictionary function of the same name).\n" "\n" " :return: custom property keys.\n" " :rtype: :class:`idprop.types.IDPropertyGroupViewKeys`\n" "\n" BPY_DOC_ID_PROP_TYPE_NOTE)
static int pyrna_property_init(PyObject *self, PyObject *args, PyObject *)
PyTypeObject pyrna_struct_meta_idprop_Type
PyTypeObject pyrna_prop_Type
static PyObject * pyrna_register_class(PyObject *self, PyObject *py_class)
static PyObject * pyrna_bl_owner_id_get(PyObject *)
void pyrna_invalidate(BPy_DummyPointerRNA *self)
static PyObject * pyrna_struct_dir(BPy_StructRNA *self)
StructRNA * pyrna_struct_as_srna(PyObject *self, const bool parent, const char *error_prefix)
static PyTypeObject * bpy_class_check_any_bases_registered(PyTypeObject *cls)
static int pyrna_struct_compare(BPy_StructRNA *a, BPy_StructRNA *b)
static PyObject * pyrna_prop_array_repr(BPy_PropertyArrayRNA *self)
static int pyrna_prop_array_contains(BPy_PropertyRNA *self, PyObject *value)
static int pyrna_py_to_prop_array_index(BPy_PropertyArrayRNA *self, int index, PyObject *value)
static Py_ssize_t pyrna_prop_array_length(BPy_PropertyArrayRNA *self)
static PointerRNA * rna_module_ptr
static int pyrna_prop_array_ass_subscript(BPy_PropertyArrayRNA *self, PyObject *key, PyObject *value)
static PyObject * pyrna_prop_array_subscript(BPy_PropertyArrayRNA *self, PyObject *key)
static PyObject * pyrna_prop_collection_subscript(BPy_PropertyRNA *self, PyObject *key)
static PyObject * pyrna_struct_type_recast(BPy_StructRNA *self)
PyMethodDef meth_bpy_owner_id_set
bool pyrna_id_CheckPyObject(PyObject *obj)
static int pyrna_deferred_register_class_recursive(StructRNA *srna, PyTypeObject *py_class)
static Py_ssize_t pyrna_prop_collection_length(BPy_PropertyRNA *self)
static void bpy_class_free_ex(PyObject *self, bool decref)
static PyObject * pyrna_srna_Subtype(StructRNA *srna)
static PyObject * pyrna_prop_array_foreach_set(BPy_PropertyArrayRNA *self, PyObject *args)
static PyObject * pyrna_struct_get_id_data(BPy_DummyPointerRNA *self, void *)
static PyObject * pyrna_struct_path_from_id(BPy_StructRNA *self, PyObject *args)
PyObject * BPY_rna_module()
static int pyrna_prop_compare(BPy_PropertyRNA *a, BPy_PropertyRNA *b)
#define MATHUTILS_CB_SUBTYPE_COLOR
static int prop_subscript_ass_array_slice__int_recursive(PyObject **value_items, int *value, int totdim, const int dimsize[], const int range[2])
static PyObject * pyrna_struct_property_unset(BPy_StructRNA *self, PyObject *args)
static bool rna_disallow_writes
#define PROP_ALL_VECTOR_SUBTYPES
static PyObject * pyrna_struct_id_properties_ensure(BPy_StructRNA *self)
static PyObject * pyrna_struct_get_ancestors(BPy_StructRNA *self)
static const char * pyrna_enum_as_string(PointerRNA *ptr, PropertyRNA *prop)
static PyObject * pyrna_srna_PyBase(StructRNA *srna)
static long pyrna_prop_hash(BPy_PropertyRNA *self)
static PyObject * pyrna_struct_get_data(BPy_DummyPointerRNA *self, void *)
static void pyrna_prop_collection_iter_dealloc(PyObject *self)
static PyMethodDef pyrna_struct_methods[]
static PyObject * pyrna_struct_as_pointer(BPy_StructRNA *self)
void BPY_id_release(ID *id)
static PyMethodDef pyrna_prop_collection_idprop_methods[]
static PyObject * pyrna_prop_collection_getattro(BPy_PropertyRNA *self, PyObject *pyname)
static PyObject * pyrna_func_CreatePyObject(const PointerRNA *ptr, FunctionRNA *func)
PyObject * pyrna_math_object_from_array(PointerRNA *ptr, PropertyRNA *prop)
static PyObject * pyrna_prop_array_to_py_index(BPy_PropertyArrayRNA *self, int index)
void BPY_free_srna_pytype(StructRNA *srna)
static PyObject * pyrna_struct_id_properties_clear(BPy_StructRNA *self)
static int pyrna_prop_collection_ass_subscript_int(BPy_PropertyRNA *self, Py_ssize_t keynum, PyObject *value)
static PyObject * pyrna_struct_items(BPy_StructRNA *self)
static PyObject * pyrna_bl_owner_id_set(PyObject *, PyObject *value)
void pyrna_struct_type_extend_capi(StructRNA *srna, PyMethodDef *method, PyGetSetDef *getset)
static PyObject * pyrna_struct_richcmp(PyObject *a, PyObject *b, int op)
static PyMappingMethods pyrna_struct_as_mapping
static int deferred_register_prop(StructRNA *srna, PyObject *key, PyObject *item)
static PyObject * pyrna_prop_dir(BPy_PropertyRNA *self)
static void pyrna_dir_members_py__add_keys(PyObject *list, PyObject *dict)
static PyTypeObject pyrna_prop_collection_idprop_Type
static int pyrna_prop_collection_contains(BPy_PropertyRNA *self, PyObject *key)
static PyObject * pyrna_struct_property_overridable_library_set(BPy_StructRNA *self, PyObject *args)
#define BPY_DOC_ID_PROP_TYPE_NOTE
static PyObject * pyrna_prop_array_subscript_slice(BPy_PropertyArrayRNA *self, PointerRNA *ptr, PropertyRNA *prop, Py_ssize_t start, Py_ssize_t stop, Py_ssize_t length)
static PyMappingMethods pyrna_prop_array_as_mapping
static void pyrna_dir_members_py(PyObject *list, PyObject *self)
PyMethodDef meth_bpy_owner_id_get
static PyObject * pyrna_prop_collection_subscript_str(BPy_PropertyRNA *self, const char *keyname)
static int pyrna_prop_collection_ass_subscript(BPy_PropertyRNA *self, PyObject *key, PyObject *value)
static int pyrna_prop_collection_iter_init(PyObject *self, PyObject *, PyObject *)
static PyObject * pyrna_prop_collection_foreach_get(BPy_PropertyRNA *self, PyObject *args)
static int pyrna_string_to_enum(PyObject *item, PointerRNA *ptr, PropertyRNA *prop, int *r_value, const char *error_prefix)
static PyObject * pyrna_prop_richcmp(PyObject *a, PyObject *b, int op)
static PyObject * pyrna_prop_as_bytes(BPy_PropertyRNA *self)
static PyObject * pyrna_struct_id_properties_ui(BPy_StructRNA *self, PyObject *args)
static int pyrna_prop_collection_string_subscript_supported_or_error(BPy_PropertyRNA *self, const char *error_prefix)
static PyObject * pyrna_enum_to_py(PointerRNA *ptr, PropertyRNA *prop, int val)
static int bpy_class_validate_recursive(PointerRNA *dummy_ptr, StructRNA *srna, void *py_data, bool *have_function)
static void pyrna_property_dealloc(PyObject *self)
static PyObject * pyrna_prop_collection_foreach_set(BPy_PropertyRNA *self, PyObject *args)
static PyObject * pyrna_prop_array_subscript_int(BPy_PropertyArrayRNA *self, Py_ssize_t keynum)
static PyObject * pyrna_prop_update(BPy_PropertyRNA *self)
static PyObject * pyrna_prop_path_from_id(BPy_PropertyRNA *self)
void pyrna_struct_validity_exception_only(const BPy_StructRNA *pysrna)
static PyObject * pyrna_prop_path_from_module(BPy_PropertyRNA *self)
static PyNumberMethods pyrna_prop_collection_as_number
static PyObject * pyrna_struct_get_rna_type(BPy_PropertyRNA *self, void *)
static const char * BPy_PropertyPointerRNA_capsule_identifier
static int prop_subscript_ass_array_slice(PointerRNA *ptr, PropertyRNA *prop, int arraydim, int arrayoffset, int start, int stop, int length, PyObject *value_orig)
static int pyrna_deferred_register_props(StructRNA *srna, PyObject *class_dict)
static PyObject * pyrna_prop_collection_values(BPy_PropertyRNA *self)
static PyObject * pyrna_srna_ExternalType(StructRNA *srna)
void BPY_rna_types_finalize_external_types(PyObject *submodule)
static int pyrna_prop_collection_type_check(BPy_PropertyRNA *self, PyObject *value)
static int pyrna_struct_meta_idprop_setattro(PyObject *cls, PyObject *attr, PyObject *value)
int pyrna_struct_as_ptr_or_null_parse(PyObject *o, void *p)
int pyrna_struct_as_ptr_parse(PyObject *o, void *p)
static PyObject * pyrna_unregister_class(PyObject *self, PyObject *py_class)
static int pyrna_struct_setattro(BPy_StructRNA *self, PyObject *pyname, PyObject *value)
static uchar mathutils_rna_array_cb_index
static int bpy_class_call(bContext *C, PointerRNA *ptr, FunctionRNA *func, ParameterList *parms)
static int mathutils_rna_vector_get_index(BaseMathObject *bmo, int, int index)
static PyObject * pyrna_property_new(PyTypeObject *type, PyObject *args, PyObject *)
StructRNA * srna_from_self(PyObject *self, const char *error_prefix)
static PySequenceMethods pyrna_struct_as_sequence
static PyObject * pyrna_func_doc_get(BPy_FunctionRNA *self, void *closure)
static int pyrna_prop_array_bool(BPy_PropertyRNA *self)
#define PYRNA_PROP_COLLECTION_ABS_INDEX(ret_err)
PyObject * pyrna_id_CreatePyObject(ID *id)
static void pyrna_subtype_set_rna(PyObject *newclass, StructRNA *srna)
int pyrna_struct_validity_check(const BPy_StructRNA *pysrna)
static PyObject * pyrna_prop_collection_iter_next(PyObject *self)
static int pyrna_prop_collection_subscript_is_valid_or_error(const PyObject *value)
static PyObject * pyrna_prop_collection_iter(PyObject *self)
static PyObject * pyrna_prop_array_foreach_get(BPy_PropertyArrayRNA *self, PyObject *args)
int pyrna_prop_validity_check(const BPy_PropertyRNA *self)
static int mathutils_rna_generic_check(BaseMathObject *bmo)
static PyObject * pyrna_struct_path_resolve(BPy_StructRNA *self, PyObject *args)
int pyrna_struct_validity_check_only(const BPy_StructRNA *pysrna)
static PyObject * pyrna_struct_is_property_hidden(BPy_StructRNA *self, PyObject *args)
static PyObject * pyrna_struct_is_property_readonly(BPy_StructRNA *self, PyObject *args)
static PyObject * pyrna_prop_collection_subscript_str_lib_pair(BPy_PropertyRNA *self, PyObject *key, const char *err_prefix, const bool err_not_found)
const PointerRNA * pyrna_struct_as_ptr_or_null(PyObject *py_obj, const StructRNA *srna)
static void pyrna_dir_members_rna(PyObject *list, PointerRNA *ptr)
static PyObject * pyrna_prop_array_getattro(BPy_PropertyRNA *self, PyObject *pyname)
PyTypeObject pyrna_prop_array_Type
static void pyrna_func_error_prefix(BPy_FunctionRNA *self, PropertyRNA *parm, const int parm_index, char *error, const size_t error_size)
static int prop_subscript_ass_array_slice__bool_recursive(PyObject **value_items, bool *value, int totdim, const int dimsize[])
static PyNumberMethods pyrna_prop_array_as_number
static int prop_subscript_ass_array_int(BPy_PropertyArrayRNA *self, Py_ssize_t keynum, PyObject *value)
static PyObject * foreach_getset(BPy_PropertyRNA *self, PyObject *args, int set)
static PySequenceMethods pyrna_prop_collection_as_sequence
static PyObject * pyrna_struct_get(BPy_StructRNA *self, PyObject *args)
static Py_hash_t pyrna_struct_hash(BPy_StructRNA *self)
static PyObject * pyrna_struct_bl_rna_find_subclass_recursive(PyObject *cls, const char *id)
static PyGetSetDef pyrna_prop_getseters[]
PyTypeObject pyrna_struct_Type
static PyObject * pyrna_prop_collection_idprop_clear(BPy_PropertyRNA *self)
static int mathutils_rna_vector_get(BaseMathObject *bmo, int subtype)
static PyObject * pyrna_struct_pop(BPy_StructRNA *self, PyObject *args)
static PyObject * prop_subscript_ass_array_slice__as_seq_fast(PyObject *value, int length)
static void bpy_class_free(void *pyob_ptr)
static uchar mathutils_rna_matrix_cb_index
static PySequenceMethods pyrna_prop_array_as_sequence
static PyObject * pyrna_struct_Subtype(PointerRNA *ptr)
static bool foreach_compat_buffer(RawPropertyType raw_type, int attr_signed, const char *format)
static PyMethodDef pyrna_prop_methods[]
static int pyrna_srna_contains_pointer_prop_srna(StructRNA *srna_props, StructRNA *srna, const char **r_prop_identifier)
static int pyrna_struct_contains(BPy_StructRNA *self, PyObject *value)
PyObject * pyrna_prop_to_py(PointerRNA *ptr, PropertyRNA *prop)
PyTypeObject pyrna_func_Type
static PyObject * pyrna_struct_str(BPy_StructRNA *self)
static PyObject * kwnames_get_item_string(PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames, Py_ssize_t nkw, const char *parm_name)
int pyrna_deferred_register_class(StructRNA *srna, PyTypeObject *py_class)
static PyGetSetDef pyrna_struct_getseters[]
int pyrna_pydict_to_props(PointerRNA *ptr, PyObject *kw, const bool all_args, const char *error_prefix)
static void pyrna_struct_dealloc(PyObject *self)
static PyObject * pyrna_struct_getattro(BPy_StructRNA *self, PyObject *pyname)
static PyMethodDef pyrna_prop_collection_methods[]
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)
void BPY_rna_types_dict_set(PyObject *dict)
static PyObject * pyrna_struct_CreatePyObject_from_type(const PointerRNA *ptr, PyTypeObject *tp, void **instance)
static Mathutils_Callback mathutils_rna_array_cb
static void pyrna_prop_collection_string_subscript_unsupported_error(BPy_PropertyRNA *self, const char *error_prefix)
static PyObject * pyrna_struct_values(BPy_StructRNA *self)
static PyObject * pyrna_param_to_py(PointerRNA *ptr, PropertyRNA *prop, void *data)
static int pyrna_prop_collection_bool(BPy_PropertyRNA *self)
static PyObject * pyrna_struct_bl_rna_get_subclass_py(PyObject *cls, PyObject *args)
PyObject * BPY_rna_types()
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)
PyMethodDef meth_bpy_unregister_class
static short pyrna_rotation_euler_order_get(PointerRNA *ptr, const short order_fallback, PropertyRNA **r_prop_eul_order)
static PyObject * bpy_types_dict
static int prop_subscript_ass_array_slice__float_recursive(PyObject **value_items, float *value, int totdim, const int dimsize[], const float range[2])
static const char * BPy_capsule_PointerRNA_identifier
static void pyrna_prop_warn_deprecated(const PointerRNA *ptr, const PropertyRNA *prop, const DeprecatedRNA *deprecated)
PyObject * pyrna_prop_CreatePyObject(PointerRNA *ptr, PropertyRNA *prop)
static int pyrna_struct_init(PyObject *self, PyObject *args, PyObject *)
static void bpy_types_module_free(void *self)
void pyrna_write_set(bool val)
static PyObject * pyrna_prop_repr_ex(BPy_PropertyRNA *self, const int index_dim, const int index)
static PyObject * pyrna_prop_collection_idprop_add(BPy_PropertyRNA *self)
PyMethodDef meth_bpy_register_class
static int bpy_class_validate(PointerRNA *dummy_ptr, void *py_data, bool *have_function)
static PyObject * pyrna_struct_repr(BPy_StructRNA *self)
#define MATHUTILS_CB_SUBTYPE_VEC
static int pyrna_deferred_register_class_from_type_hints(StructRNA *srna, PyTypeObject *py_class)
static PyObject * pyrna_prop_collection_find(BPy_PropertyRNA *self, PyObject *key_ob)
static int mathutils_rna_matrix_set(BaseMathObject *bmo, int)
static PyObject * pyrna_prop_collection_keys(BPy_PropertyRNA *self)
static int pyrna_property_array_init(PyObject *self, PyObject *args, PyObject *)
#define MATHUTILS_CB_SUBTYPE_EUL
static PyObject * pyrna_prop_repr(BPy_PropertyRNA *self)
static PyGetSetDef pyrna_func_getseters[]
void BPY_update_rna_module()
static PyTypeObject * bpy_class_check_any_subclasses_registered(PyTypeObject *cls)
static int pyrna_prop_collection_setattro(BPy_PropertyRNA *self, PyObject *pyname, PyObject *value)
static PyObject * pyrna_struct_bl_rna_get_subclass(PyObject *cls, PyObject *args)
static int pyrna_prop_to_enum_bitfield(PointerRNA *ptr, PropertyRNA *prop, PyObject *value, int *r_value, const char *error_prefix)
static PyObject * pyrna_func_repr(BPy_FunctionRNA *self)
static PyMappingMethods pyrna_prop_collection_as_mapping
bool pyrna_id_FromPyObject(PyObject *obj, ID **id)
static PyObject * pyrna_struct_get_nameprop_as_pyobject(PointerRNA *ptr, BPy_NamePropAsPyObject_Cache &nameprop_cache)
#define BPY_TYPEDEF_REGISTERABLE_DOC
PyObject * pyrna_struct_CreatePyObject(PointerRNA *ptr)
static PyMethodDef bpy_types_module_methods[]
static PyObject * bpy_types_module_getattro(PyObject *self, PyObject *pyname)
static PyObject * pyrna_prop_str(BPy_PropertyRNA *self)
static PyObject * pyrna_prop_collection_items(BPy_PropertyRNA *self)
static PyObject * pyprop_array_foreach_getset(BPy_PropertyArrayRNA *self, PyObject *args, const bool do_set)
static int mathutils_rna_matrix_get(BaseMathObject *bmo, int)
static PyObject * bpy_types_module_dir(PyObject *self)
static int mathutils_rna_vector_set_index(BaseMathObject *bmo, int, int index)
static PyObject * pyrna_prop_collection_iter_new(PyTypeObject *type, PyObject *, PyObject *)
static PyObject * pyrna_struct_new(PyTypeObject *type, PyObject *args, PyObject *)
static PyObject * pyrna_struct_keys(BPy_StructRNA *self)
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)
static PyObject * pyrna_prop_array_iter(BPy_PropertyArrayRNA *self)
#define MATHUTILS_CB_SUBTYPE_QUAT
static PyObject * pyrna_prop_collection_subscript_int(BPy_PropertyRNA *self, Py_ssize_t keynum)
static PyObject * pyrna_prop_collection_idprop_move(BPy_PropertyRNA *self, PyObject *args)
static PyMethodDef pyrna_prop_array_methods[]
BPy_StructRNA * bpy_context_module
PyObject * pyrna_struct_CreatePyObject_with_primitive_support(PointerRNA *ptr)
static void pyrna_func_dealloc(PyObject *self)
static PyObject * pyrna_prop_collection_idprop_remove(BPy_PropertyRNA *self, PyObject *value)
static PyObject * pyrna_struct_subscript(BPy_StructRNA *self, PyObject *key)
static int pyrna_struct_ass_subscript(BPy_StructRNA *self, PyObject *key, PyObject *value)
static PyObject * pyrna_prop_collection_iter_CreatePyObject(PointerRNA *ptr, PropertyRNA *prop)
static StructRNA * srna_from_ptr(PointerRNA *ptr)
static PyObject * pyrna_struct_path_from_module(BPy_StructRNA *self, PyObject *args)
static bool rna_id_write_error(PointerRNA *ptr, PyObject *key)
static int pyrna_py_to_prop(PointerRNA *ptr, PropertyRNA *prop, void *data, PyObject *value, const char *error_prefix)
static int rna_function_register_arg_count(FunctionRNA *func, int *min_count)
PyTypeObject pyrna_prop_collection_Type
static PyObject * pyrna_func_vectorcall(PyObject *callable, PyObject *const *args, size_t nargsf, PyObject *kwnames)
static PyObject * pyrna_struct_is_property_set(BPy_StructRNA *self, PyObject *args, PyObject *kw)
static Mathutils_Callback mathutils_rna_matrix_cb
int pyrna_py_to_array(PointerRNA *ptr, PropertyRNA *prop, char *param_data, PyObject *py, const char *error_prefix)
PyObject * pyrna_array_index(PointerRNA *ptr, PropertyRNA *prop, int index)
#define PYRNA_STRUCT_IS_VALID(pysrna)
int pyrna_array_contains_py(PointerRNA *ptr, PropertyRNA *prop, PyObject *value)
#define BPy_StructRNA_CheckExact(v)
#define PYRNA_STRUCT_CHECK_OBJ(obj)
int pyrna_py_to_array_index(PointerRNA *ptr, PropertyRNA *prop, int arraydim, int arrayoffset, int index, PyObject *py, const char *error_prefix)
#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)
PyObject * pyrna_py_from_array_index(BPy_PropertyArrayRNA *self, PointerRNA *ptr, PropertyRNA *prop, int index)
PyObject * pyrna_py_from_array(PointerRNA *ptr, PropertyRNA *prop)
char pyrna_struct_driver_add_doc[]
char pyrna_struct_keyframe_insert_doc[]
PyObject * pyrna_struct_keyframe_delete(BPy_StructRNA *self, PyObject *args, PyObject *kw)
PyObject * pyrna_struct_driver_remove(BPy_StructRNA *self, PyObject *args)
PyObject * pyrna_struct_driver_add(BPy_StructRNA *self, PyObject *args)
char pyrna_struct_driver_remove_doc[]
char pyrna_struct_keyframe_delete_doc[]
PyObject * pyrna_struct_keyframe_insert(BPy_StructRNA *self, PyObject *args, PyObject *kw)
PyObject * pyrna_callback_classmethod_remove(PyObject *, PyObject *args)
PyObject * pyrna_callback_classmethod_add(PyObject *, PyObject *args)
unsigned long long int uint64_t
static DBVT_INLINE btScalar size(const btDbvtVolume &a)
void append(const T &value)
constexpr bool is_empty() const
constexpr int64_t size() const
constexpr const char * data() const
constexpr const char * c_str() const
VecBase< float, D > step(VecOp< float, D >, VecOp< float, D >) RET
float length(VecOp< float, D >) RET
PyObject * BPy_Wrap_GetKeys_View_WithID(ID *id, IDProperty *prop)
int BPy_Wrap_SetMapItem(IDProperty *prop, PyObject *key, PyObject *val)
PyObject * BPy_Wrap_GetItems_View_WithID(ID *id, IDProperty *prop)
PyTypeObject BPy_IDGroup_Type
PyObject * BPy_IDGroup_MapDataToPy(IDProperty *prop)
PyObject * BPy_IDGroup_WrapData(ID *id, IDProperty *prop, IDProperty *parent)
PyObject * BPy_Wrap_GetValues_View_WithID(ID *id, IDProperty *prop)
PyTypeObject BPy_IDPropertyUIManager_Type
void MEM_freeN(void *vmemh)
uchar Mathutils_RegisterCallback(Mathutils_Callback *cb)
int(*)(BaseMathObject *, int) BaseMathGetFunc
int(*)(BaseMathObject *, int) BaseMathSetFunc
int(*)(BaseMathObject *, int, int) BaseMathSetIndexFunc
int(*)(BaseMathObject *) BaseMathCheckFunc
int(*)(BaseMathObject *, int, int) BaseMathGetIndexFunc
PyObject * Color_CreatePyObject(const float col[3], PyTypeObject *base_type)
PyObject * Color_CreatePyObject_cb(PyObject *cb_user, uchar cb_type, uchar cb_subtype)
PyObject * Euler_CreatePyObject(const float eul[3], const short order, PyTypeObject *base_type)
PyObject * Euler_CreatePyObject_cb(PyObject *cb_user, const short order, uchar cb_type, uchar cb_subtype)
PyObject * Matrix_CreatePyObject_cb(PyObject *cb_user, const ushort col_num, const ushort row_num, uchar cb_type, uchar cb_subtype)
PyObject * Matrix_CreatePyObject(const float *mat, const ushort col_num, const ushort row_num, PyTypeObject *base_type)
PyObject * Quaternion_CreatePyObject_cb(PyObject *cb_user, uchar cb_type, uchar cb_subtype)
PyObject * Quaternion_CreatePyObject(const float quat[4], PyTypeObject *base_type)
PyObject * Vector_CreatePyObject(const float *vec, const int vec_num, PyTypeObject *base_type)
PyObject * Vector_CreatePyObject_cb(PyObject *cb_user, int vec_num, uchar cb_type, uchar cb_subtype)
static void error(const char *str)
StringRefNull node_type_find_alias(StringRefNull alias)
bNodeType * node_type_find(StringRef idname)
int pyrna_enum_bitfield_from_set(const EnumPropertyItem *items, PyObject *value, int *r_value, const char *error_prefix)
char * pyrna_enum_repr(const EnumPropertyItem *item)
int16_t PyC_Long_AsI16(PyObject *value)
uint8_t PyC_Long_AsU8(PyObject *value)
PyObject * PyC_Err_Format_Prefix(PyObject *exception_type_prefix, const char *format,...)
void PyC_ObSpit(const char *name, PyObject *var)
int8_t PyC_Long_AsI8(PyObject *value)
PyObject * PyC_UnicodeFromBytesAndSize(const char *str, Py_ssize_t size)
PyObject * PyC_UnicodeFromBytes(const char *str)
uint64_t PyC_Long_AsU64(PyObject *value)
void PyC_ObSpitStr(char *result, size_t result_maxncpy, PyObject *var)
PyObject * PyC_ExceptionBuffer()
int PyC_Long_AsBool(PyObject *value)
void PyC_FileAndNum(const char **r_filename, int *r_lineno)
uint16_t PyC_Long_AsU16(PyObject *value)
PyObject * PyC_UnicodeFromStdStr(const std::string &str)
int PyC_ParseBool(PyObject *o, void *p)
const char * PyC_UnicodeAsBytes(PyObject *py_str, PyObject **r_coerce)
header-only compatibility defines.
#define PyObject_GetOptionalAttr
#define PY_ARG_PARSER_HEAD_COMPAT()
#define PyTuple_SET_ITEMS(op_arg,...)
StructUnregisterFunc RNA_struct_unregister(StructRNA *type)
float RNA_property_float_get(PointerRNA *ptr, PropertyRNA *prop)
bool RNA_property_collection_lookup_int_has_fn(PropertyRNA *prop)
bool RNA_property_enum_value(bContext *C, PointerRNA *ptr, PropertyRNA *prop, const char *identifier, int *r_value)
StructRegisterFunc RNA_struct_register(StructRNA *type)
bool RNA_property_enum_identifier(bContext *C, PointerRNA *ptr, PropertyRNA *prop, const int value, const char **r_identifier)
void RNA_property_boolean_set_index(PointerRNA *ptr, PropertyRNA *prop, int index, bool value)
void RNA_property_int_set(PointerRNA *ptr, PropertyRNA *prop, int value)
const StructRNA * RNA_struct_base_child_of(const StructRNA *type, const StructRNA *parent_type)
bool RNA_property_update_check(PropertyRNA *prop)
bool RNA_property_array_check(PropertyRNA *prop)
bool RNA_struct_is_a(const StructRNA *type, const StructRNA *srna)
void RNA_property_float_get_array(PointerRNA *ptr, PropertyRNA *prop, float *values)
const char * RNA_function_identifier(FunctionRNA *func)
void RNA_parameter_list_end(ParameterIterator *)
void RNA_struct_state_owner_set(const char *name)
void RNA_struct_py_type_set(StructRNA *srna, void *py_type)
IDProperty ** RNA_struct_idprops_p(PointerRNA *ptr)
int RNA_property_int_clamp(PointerRNA *ptr, PropertyRNA *prop, int *value)
int RNA_property_float_clamp(PointerRNA *ptr, PropertyRNA *prop, float *value)
int RNA_property_enum_bitflag_identifiers(bContext *C, PointerRNA *ptr, PropertyRNA *prop, const int value, const char **r_identifier)
bool RNA_struct_is_ID(const StructRNA *type)
const ListBase * RNA_struct_type_properties(StructRNA *srna)
void RNA_property_float_set_index(PointerRNA *ptr, PropertyRNA *prop, int index, float value)
const ListBase * RNA_struct_type_functions(StructRNA *srna)
bool RNA_struct_idprops_check(const StructRNA *srna)
bool RNA_property_collection_assign_int(PointerRNA *ptr, PropertyRNA *prop, const int key, const PointerRNA *assign_ptr)
bool RNA_property_collection_is_empty(PointerRNA *ptr, PropertyRNA *prop)
int RNA_function_defined(FunctionRNA *func)
StructRNA * RNA_property_pointer_type(PointerRNA *ptr, PropertyRNA *prop)
PropertyRNA * RNA_struct_find_property(PointerRNA *ptr, const char *identifier)
float RNA_property_float_get_index(PointerRNA *ptr, PropertyRNA *prop, int index)
void RNA_property_pointer_set(PointerRNA *ptr, PropertyRNA *prop, PointerRNA ptr_value, ReportList *reports)
char * RNA_struct_name_get_alloc(PointerRNA *ptr, char *fixedbuf, int fixedlen, int *r_len)
void RNA_property_collection_skip(CollectionPropertyIterator *iter, int num)
bool RNA_property_collection_lookup_string_has_nameprop(PropertyRNA *prop)
int RNA_property_collection_raw_get(ReportList *reports, PointerRNA *ptr, PropertyRNA *prop, const char *propname, void *array, RawPropertyType type, int len)
int RNA_property_multi_array_length(PointerRNA *ptr, PropertyRNA *prop, int dimension)
bool RNA_property_is_set_ex(PointerRNA *ptr, PropertyRNA *prop, bool use_ghost)
bool RNA_property_collection_lookup_string_supported(PropertyRNA *prop)
void RNA_property_collection_begin(PointerRNA *ptr, PropertyRNA *prop, CollectionPropertyIterator *iter)
void RNA_property_float_range(PointerRNA *ptr, PropertyRNA *prop, float *hardmin, float *hardmax)
void RNA_property_boolean_get_array(PointerRNA *ptr, PropertyRNA *prop, bool *values)
PropertyType RNA_property_type(PropertyRNA *prop)
const PointerRNA PointerRNA_NULL
char * RNA_property_string_get_alloc(PointerRNA *ptr, PropertyRNA *prop, char *fixedbuf, int fixedlen, int *r_len)
void RNA_property_enum_set(PointerRNA *ptr, PropertyRNA *prop, int value)
PointerRNA RNA_property_pointer_get(PointerRNA *ptr, PropertyRNA *prop)
void ** RNA_struct_instance(PointerRNA *ptr)
void RNA_parameter_list_free(ParameterList *parms)
IDProperty * RNA_struct_idprops(PointerRNA *ptr, bool create)
void RNA_property_update(bContext *C, PointerRNA *ptr, PropertyRNA *prop)
size_t RNA_raw_type_sizeof(RawPropertyType type)
bool RNA_property_boolean_get(PointerRNA *ptr, PropertyRNA *prop)
const char * RNA_struct_identifier(const StructRNA *type)
bool RNA_struct_idprops_contains_datablock(const StructRNA *type)
void RNA_property_int_set_index(PointerRNA *ptr, PropertyRNA *prop, int index, int value)
bool RNA_enum_id_from_value(const EnumPropertyItem *item, int value, const char **r_identifier)
int RNA_property_int_get(PointerRNA *ptr, PropertyRNA *prop)
void RNA_property_collection_next(CollectionPropertyIterator *iter)
char * RNA_struct_name_get_alloc_ex(PointerRNA *ptr, char *fixedbuf, int fixedlen, int *r_len, PropertyRNA **r_nameprop)
void RNA_parameter_list_next(ParameterIterator *iter)
const char * RNA_function_ui_description(FunctionRNA *func)
int RNA_property_array_dimension(const PointerRNA *ptr, PropertyRNA *prop, int length[])
PropertyRNA * RNA_struct_type_find_property_no_base(StructRNA *srna, const char *identifier)
int RNA_function_flag(FunctionRNA *func)
std::string RNA_function_as_string_keywords(bContext *C, FunctionRNA *func, const bool as_function, const bool all_args, const int max_prop_length)
PointerRNA RNA_pointer_create_from_ancestor(const PointerRNA &ptr, const int ancestor_idx)
const DeprecatedRNA * RNA_property_deprecated(const PropertyRNA *prop)
int RNA_property_flag(PropertyRNA *prop)
RawPropertyType RNA_property_raw_type(PropertyRNA *prop)
void RNA_property_boolean_set(PointerRNA *ptr, PropertyRNA *prop, bool value)
bool RNA_property_builtin(PropertyRNA *prop)
bool RNA_struct_system_idprops_register_check(const StructRNA *type)
const char * RNA_struct_ui_description(const StructRNA *type)
int RNA_parameter_list_arg_count(const ParameterList *parms)
bool RNA_property_collection_lookup_int(PointerRNA *ptr, PropertyRNA *prop, int key, PointerRNA *r_ptr)
void RNA_property_string_set_bytes(PointerRNA *ptr, PropertyRNA *prop, const char *value, int len)
bool RNA_struct_system_idprops_check(StructRNA *srna)
void RNA_property_collection_add(PointerRNA *ptr, PropertyRNA *prop, PointerRNA *r_ptr)
int RNA_property_array_length(PointerRNA *ptr, PropertyRNA *prop)
StructRNA * RNA_struct_base(StructRNA *type)
FunctionRNA * RNA_struct_find_function(StructRNA *srna, const char *identifier)
bool RNA_property_is_idprop(const PropertyRNA *prop)
int RNA_property_string_maxlength(PropertyRNA *prop)
const char * RNA_struct_state_owner_get()
bool RNA_struct_idprops_datablock_allowed(const StructRNA *type)
bool RNA_property_editable(const PointerRNA *ptr, PropertyRNA *prop)
void RNA_property_float_set_array(PointerRNA *ptr, PropertyRNA *prop, const float *values)
void RNA_property_int_set_array(PointerRNA *ptr, PropertyRNA *prop, const int *values)
int RNA_property_enum_get(PointerRNA *ptr, PropertyRNA *prop)
PointerRNA RNA_pointer_recast(PointerRNA *ptr)
void RNA_property_float_set(PointerRNA *ptr, PropertyRNA *prop, float value)
PropertyRNA * RNA_struct_name_property(const StructRNA *type)
void RNA_property_int_get_array(PointerRNA *ptr, PropertyRNA *prop, int *values)
bool RNA_property_collection_move(PointerRNA *ptr, PropertyRNA *prop, int key, int pos)
PropertySubType RNA_property_subtype(PropertyRNA *prop)
PointerRNA RNA_main_pointer_create(Main *main)
void RNA_property_int_range(PointerRNA *ptr, PropertyRNA *prop, int *hardmin, int *hardmax)
int RNA_function_call(bContext *C, ReportList *reports, PointerRNA *ptr, FunctionRNA *func, ParameterList *parms)
bool RNA_property_collection_lookup_string(PointerRNA *ptr, PropertyRNA *prop, const char *key, PointerRNA *r_ptr)
ParameterList * RNA_parameter_list_create(ParameterList *parms, PointerRNA *, FunctionRNA *func)
void RNA_property_enum_items(bContext *C, PointerRNA *ptr, PropertyRNA *prop, const EnumPropertyItem **r_item, int *r_totitem, bool *r_free)
void RNA_property_collection_clear(PointerRNA *ptr, PropertyRNA *prop)
bool RNA_property_collection_type_get(PointerRNA *ptr, PropertyRNA *prop, PointerRNA *r_ptr)
void RNA_property_collection_end(CollectionPropertyIterator *iter)
bool RNA_property_collection_lookup_string_has_fn(PropertyRNA *prop)
PointerRNA RNA_blender_rna_pointer_create()
PointerRNA RNA_pointer_create_discrete(ID *id, StructRNA *type, void *data)
bool RNA_property_collection_remove(PointerRNA *ptr, PropertyRNA *prop, int key)
void RNA_property_unset(PointerRNA *ptr, PropertyRNA *prop)
void RNA_parameter_list_begin(ParameterList *parms, ParameterIterator *iter)
PropertyRNA * RNA_struct_iterator_property(StructRNA *type)
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)
int RNA_parameter_flag(PropertyRNA *prop)
void * RNA_struct_py_type_get(StructRNA *srna)
bool RNA_property_editable_flag(const PointerRNA *ptr, PropertyRNA *prop)
int RNA_property_collection_raw_set(ReportList *reports, PointerRNA *ptr, PropertyRNA *prop, const char *propname, void *array, RawPropertyType type, int len)
const char * RNA_property_identifier(const PropertyRNA *prop)
const ListBase * RNA_function_defined_parameters(FunctionRNA *func)
int RNA_property_collection_length(PointerRNA *ptr, PropertyRNA *prop)
void RNA_property_boolean_set_array(PointerRNA *ptr, PropertyRNA *prop, const bool *values)
PointerRNA RNA_id_pointer_create(ID *id)
void RNA_property_string_set(PointerRNA *ptr, PropertyRNA *prop, const char *value)
bool RNA_property_overridable_library_set(PointerRNA *, PropertyRNA *prop, const bool is_overridable)
bool RNA_property_overridable_get(const PointerRNA *ptr, PropertyRNA *prop)
StructRNA RNA_PropertyGroup
std::optional< std::string > RNA_path_from_ID_to_struct(const PointerRNA *ptr)
std::optional< std::string > RNA_path_from_real_ID_to_struct(Main *bmain, const PointerRNA *ptr, ID **r_real)
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)
std::optional< std::string > RNA_path_full_property_py_ex(const PointerRNA *ptr, PropertyRNA *prop, int index, bool use_fallback)
bool RNA_path_resolve_full_maybe_null(const PointerRNA *ptr, const char *path, PointerRNA *r_ptr, PropertyRNA **r_prop, int *r_index)
std::optional< std::string > RNA_path_full_struct_py(const PointerRNA *ptr)
std::string RNA_path_full_ID_py(ID *id)
std::optional< std::string > RNA_path_from_ID_to_property(const PointerRNA *ptr, PropertyRNA *prop)
std::string RNA_path_from_ptr_to_property_index(const PointerRNA *ptr, PropertyRNA *prop, int index_dim, int index)
const EnumPropertyItem rna_enum_property_type_items[]
const EnumPropertyItem rna_enum_dummy_NULL_items[]
PyObject_HEAD std::optional< PointerRNA > ptr
vectorcallfunc vectorcall
PyObject_HEAD std::optional< PointerRNA > ptr
PyObject_VAR_HEAD IDProperty * property
PyObject_VAR_HEAD struct ID * owner_id
struct IDProperty * parent
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
blender::Vector< PointerRNA > items
struct ReportList * reports
static DynamicLibrary lib