43#ifdef USE_PYRNA_INVALIDATE_WEAKREF
50#include "RNA_prototypes.hh"
75#define USE_PEDANTIC_WRITE
77#define USE_STRING_COERCE
86#define USE_POSTPONED_ANNOTATIONS
138#define BPY_DOC_ID_PROP_TYPE_NOTE \
141 " Only the :class:`bpy.types.ID`, :class:`bpy.types.Bone` and\n" \
142 " :class:`bpy.types.PoseBone` classes support custom properties.\n"
146 if (pysrna->
ptr->type) {
155 PyExc_ReferenceError,
"StructRNA of type %.200s has been removed", Py_TYPE(pysrna)->tp_name);
160 if (pysrna->
ptr->type) {
169 if (
self->ptr->type) {
172 PyErr_Format(PyExc_ReferenceError,
173 "PropertyRNA of type %.200s.%.200s has been removed",
174 Py_TYPE(
self)->tp_name,
181 self->ptr->invalidate();
184#ifdef USE_PYRNA_INVALIDATE_GC
185# define FROM_GC(g) ((PyObject *)(((PyGC_Head *)g) + 1))
188struct gc_generation {
194static void id_release_gc(
struct ID *
id)
198 for (j = 0; j < 3; j++) {
200 PyGC_Head *gen = (PyGC_Head *)(((
char *)_PyGC_generation0) + (
sizeof(gc_generation) * j));
201 PyGC_Head *g = gen->gc.gc_next;
202 while ((g = g->gc.gc_next) != gen) {
203 PyObject *ob = FROM_GC(g);
208 if (ob_ptr->
ptr->owner_id ==
id) {
220#ifdef USE_PYRNA_INVALIDATE_WEAKREF
223struct GHash *id_weakref_pool =
nullptr;
224static PyObject *id_free_weakref_cb(PyObject *weakinfo_pair, PyObject *weakref);
225static PyMethodDef id_free_weakref_cb_def = {
226 "id_free_weakref_cb", (PyCFunction)id_free_weakref_cb, METH_O,
nullptr};
231static void id_weakref_pool_free_value_fn(
void *p)
233 GHash *weakinfo_hash =
static_cast<GHash *
>(p);
238static GHash *id_weakref_pool_get(
ID *
id)
241 if (weakinfo_hash ==
nullptr) {
247 return weakinfo_hash;
254 PyObject *weakref_capsule;
255 PyObject *weakref_cb_py;
259 GHash *weakinfo_hash = id_weakref_pool_get(
id);
261 weakref_capsule = PyCapsule_New(weakinfo_hash,
nullptr,
nullptr);
262 weakref_cb_py = PyCFunction_New(&id_free_weakref_cb_def, weakref_capsule);
263 Py_DECREF(weakref_capsule);
266 weakref = PyWeakref_NewRef((PyObject *)pyrna, weakref_cb_py);
268 Py_DECREF(weakref_cb_py);
278static ID *_id_tmp_ptr;
279static void value_id_set(
void *
id)
281 _id_tmp_ptr = (
ID *)
id;
284static void id_release_weakref_list(
struct ID *
id,
GHash *weakinfo_hash);
285static PyObject *id_free_weakref_cb(PyObject *weakinfo_pair, PyObject *weakref)
288 GHash *weakinfo_hash =
static_cast<GHash *
>(PyCapsule_GetPointer(weakinfo_pair,
nullptr));
295 id_release_weakref_list(_id_tmp_ptr, weakinfo_hash);
303static void id_release_weakref_list(
struct ID *
id,
GHash *weakinfo_hash)
309# ifdef DEBUG_RNA_WEAKREF
310 fprintf(stdout,
"id_release_weakref: '%s', %d items\n", id->
name,
BLI_ghash_len(weakinfo_hash));
315 PyObject *item = PyWeakref_GET_OBJECT(weakref);
316 if (item != Py_None) {
318# ifdef DEBUG_RNA_WEAKREF
334static void id_release_weakref(
struct ID *
id)
338 id_release_weakref_list(
id, weakinfo_hash);
346#ifdef USE_PYRNA_INVALIDATE_GC
350#ifdef USE_PYRNA_INVALIDATE_WEAKREF
352 if (id_weakref_pool !=
nullptr) {
353 PyGILState_STATE gilstate = PyGILState_Ensure();
355 id_release_weakref(
id);
357 PyGILState_Release(gilstate);
364#ifdef USE_PEDANTIC_WRITE
369 ID *
id =
ptr->owner_id;
371 const short idcode =
GS(id->
name);
376 if (key && PyUnicode_Check(key)) {
377 pyname = PyUnicode_AsUTF8(key);
380 pyname =
"<UNKNOWN>";
385 PyErr_Format(PyExc_AttributeError,
386 "Writing to ID classes in this context is not allowed: "
387 "%.200s, %.200s datablock, error setting %.200s.%.200s",
400#ifdef USE_PEDANTIC_WRITE
448 const short order_fallback,
455# define MATHUTILS_CB_SUBTYPE_EUL 0
456# define MATHUTILS_CB_SUBTYPE_VEC 1
457# define MATHUTILS_CB_SUBTYPE_QUAT 2
458# define MATHUTILS_CB_SUBTYPE_COLOR 3
466 return self->prop ? 0 : -1;
475 if (
self->prop ==
nullptr) {
498 if (
self->prop ==
nullptr) {
502# ifdef USE_PEDANTIC_WRITE
509 PyErr_Format(PyExc_AttributeError,
510 "bpy_prop \"%.200s.%.200s\" is read-only",
520 for (
i = 0;
i <
len;
i++) {
535 &
self->ptr.value(), eul->
order, &prop_eul_order);
536 if (order != eul->
order) {
552 if (
self->prop ==
nullptr) {
566 if (
self->prop ==
nullptr) {
570# ifdef USE_PEDANTIC_WRITE
577 PyErr_Format(PyExc_AttributeError,
578 "bpy_prop \"%.200s.%.200s\" is read-only",
611 if (
self->prop ==
nullptr) {
625 if (
self->prop ==
nullptr) {
629# ifdef USE_PEDANTIC_WRITE
636 PyErr_Format(PyExc_AttributeError,
637 "bpy_prop \"%.200s.%.200s\" is read-only",
661 const short order_fallback,
665 if (*r_prop_eul_order ==
nullptr) {
669 if (*r_prop_eul_order) {
677 return order_fallback;
686#define PROP_ALL_VECTOR_SUBTYPES \
688 case PROP_TRANSLATION: \
689 case PROP_DIRECTION: \
690 case PROP_VELOCITY: \
691 case PROP_ACCELERATION: \
697 PyObject *
ret =
nullptr;
718 goto thick_wrap_slice;
731 if (totdim == 1 || (totdim == 2 && subtype ==
PROP_MATRIX)) {
739 if (
len >= 2 &&
len <= 4) {
833 if (
ret ==
nullptr) {
864 return (((a->
ptr->data ==
b->ptr->data) && (a->
ptr->type ==
b->ptr->type)) ? 0 : -1);
870 ((a->
prop ==
b->prop) && (a->
ptr->data ==
b->ptr->data) && (a->
ptr->type ==
b->ptr->type)) ?
889 res = ok ? Py_False : Py_True;
896 res = Py_NotImplemented;
903 return Py_NewRef(res);
920 res = ok ? Py_False : Py_True;
927 res = Py_NotImplemented;
934 return Py_NewRef(res);
942 const char *extra_info =
"";
945 return PyUnicode_FromFormat(
"<bpy_struct, %.200s invalid>", Py_TYPE(
self)->tp_name);
948 ID *
id =
self->ptr->owner_id;
950 extra_info =
", evaluated";
959 ret = PyUnicode_FromFormat(
"<bpy_struct, %.200s(\"%.200s\") at %p%s>",
968 return PyUnicode_FromFormat(
"<bpy_struct, %.200s at %p%s>",
976 ID *
id =
self->ptr->owner_id;
985 tmp_str = PyUnicode_FromString(id->
name + 2);
988 ret = PyUnicode_FromFormat(
992 ID *real_id =
nullptr;
1001 if (real_id !=
nullptr) {
1003 tmp_str = PyUnicode_FromString(real_id->
name + 2);
1004 ret = PyUnicode_FromFormat(
"bpy.data.%s[%R].%s",
1011 ret = PyUnicode_FromFormat(
"bpy.data.%s[%R]...%s",
1019 ret = PyUnicode_FromFormat(
"bpy.data.%s[%R]...%s",
1036 const char *type_id =
nullptr;
1037 char type_lower[64];
1038 char type_count[16];
1047 PyErr_SetString(PyExc_RuntimeError,
"could not use property type, internal error");
1066 type_count[0] =
'\0';
1075 ret = PyUnicode_FromFormat(
"<bpy_%.200s%.200s, %.200s.%.200s(\"%.200s\")>",
1088 return PyUnicode_FromFormat(
1093 return PyUnicode_FromFormat(
"<bpy_%.200s%.200s, %.200s.%.200s>",
1102 ID *
id =
self->ptr->owner_id;
1108 if (
id ==
nullptr) {
1113 tmp_str = PyUnicode_FromString(id->
name + 2);
1117 ID *real_id =
nullptr;
1119 G_MAIN, &
self->ptr.value(),
self->prop, index_dim, index, &real_id);
1122 if (real_id !=
id) {
1124 tmp_str = PyUnicode_FromString(real_id->
name + 2);
1126 const char *data_delim = ((*path)[0] ==
'[') ?
"" :
".";
1127 ret = PyUnicode_FromFormat(
"bpy.data.%s[%R]%s%s",
1135 ret = PyUnicode_FromFormat(
"bpy.data.%s[%R]...%s",
1158 return PyUnicode_FromFormat(
"<%.200s %.200s.%.200s()>",
1159 Py_TYPE(
self)->tp_name,
1173 if (
self->ptr->data ==
nullptr) {
1193#ifdef USE_PYRNA_STRUCT_REFERENCE
1194static int pyrna_struct_traverse(
BPy_StructRNA *
self, visitproc visit,
void *arg)
1196 Py_VISIT(
self->reference);
1202 Py_CLEAR(
self->reference);
1207#ifdef USE_PYRNA_STRUCT_REFERENCE
1210 if (
self->reference) {
1211 PyObject_GC_UnTrack(
self);
1212 Py_CLEAR(
self->reference);
1217 self->reference = reference;
1218 Py_INCREF(reference);
1220 PyObject_GC_Track(
self);
1249 const char *param = PyUnicode_AsUTF8(item);
1251 if (param ==
nullptr) {
1252 PyErr_Format(PyExc_TypeError,
1253 "%.200s expected a string enum, not %.200s",
1255 Py_TYPE(item)->tp_name);
1261 PyErr_Format(PyExc_TypeError,
1262 "%.200s enum \"%.200s\" not found in (%s)",
1282 if (!PyAnySet_Check(value)) {
1283 PyErr_Format(PyExc_TypeError,
1284 "%.200s, %.200s.%.200s expected a set, not a %.200s",
1288 Py_TYPE(value)->tp_name);
1298 if (PySet_GET_SIZE(value)) {
1299 PyErr_Format(PyExc_TypeError,
1300 "%.200s: empty enum \"%.200s\" could not have any values assigned",
1319 PyObject *item, *
ret =
nullptr;
1324 ret = PySet_New(
nullptr);
1329 for (index = 0; identifier[index]; index++) {
1330 item = PyUnicode_FromString(identifier[index]);
1331 PySet_Add(
ret, item);
1337 const char *identifier;
1339 ret = PyUnicode_FromString(identifier);
1355 "current value '%d' "
1356 "matches no enum in '%s', '%s', '%s'",
1363 char error_str[256];
1366 "RNA Warning: Current value \"%d\" "
1367 "matches no enum in '%s', '%s', '%s'",
1373 PyErr_Warn(PyExc_RuntimeWarning, error_str);
1381 ret = PyUnicode_FromString(
"");
1383 PyErr_Format(PyExc_AttributeError,
"RNA Error: Current value \"%d\" matches no enum", val);
1419#ifdef USE_STRING_COERCE
1422 ret = PyBytes_FromStringAndSize(buf, buf_len);
1428 ret = PyUnicode_FromStringAndSize(buf, buf_len);
1432 ret = PyBytes_FromStringAndSize(buf, buf_len);
1435 ret = PyUnicode_FromStringAndSize(buf, buf_len);
1438 if (buf_fixed != buf) {
1463 PyErr_Format(PyExc_TypeError,
1464 "bpy_struct internal error: unknown type '%d' (pyrna_prop_to_py)",
1475 const bool all_args,
1476 const char *error_prefix)
1480 const char *arg_name =
nullptr;
1483 totkw = kw ? PyDict_Size(kw) : 0;
1488 if (
STREQ(arg_name,
"rna_type")) {
1492 if (kw ==
nullptr) {
1494 PyExc_TypeError,
"%.200s: no keywords, expected \"%.200s\"", error_prefix, arg_name);
1499 item = PyDict_GetItemString(kw, arg_name);
1501 if (item ==
nullptr) {
1503 PyErr_Format(PyExc_TypeError,
1504 "%.200s: keyword \"%.200s\" missing",
1506 arg_name ? arg_name :
"<UNKNOWN>");
1521 if (error_val == 0 && totkw > 0) {
1522 PyObject *key, *value;
1525 while (PyDict_Next(kw, &
pos, &key, &value)) {
1526 arg_name = PyUnicode_AsUTF8(key);
1533 PyErr_Format(PyExc_TypeError,
1534 "%.200s: keyword \"%.200s\" unrecognized",
1536 arg_name ? arg_name :
"<UNKNOWN>");
1546 PyObject *pyfuncrna_ptr = PyCapsule_New(
1549 PyObject_CallOneArg(
reinterpret_cast<PyObject *
>(&
pyrna_func_Type), pyfuncrna_ptr));
1552 PyErr_SetString(PyExc_MemoryError,
"couldn't create bpy_func object");
1557 Py_DECREF(pyfuncrna_ptr);
1559 return reinterpret_cast<PyObject *
>(pyfunc);
1585 param = PyObject_IsTrue(value);
1588 param = PyC_Long_AsI32(value);
1596 PyErr_Format(PyExc_TypeError,
1597 "%.200s %.200s.%.200s expected True/False or 0/1, not %.200s",
1601 Py_TYPE(value)->tp_name);
1606 *((
bool *)
data) = param;
1616 const long param = PyLong_AsLongAndOverflow(value, &overflow);
1617 if (overflow || (param > INT_MAX) || (param < INT_MIN)) {
1618 PyErr_Format(PyExc_ValueError,
1619 "%.200s %.200s.%.200s value not in 'int' range "
1626 if (param == -1 && PyErr_Occurred()) {
1627 PyErr_Format(PyExc_TypeError,
1628 "%.200s %.200s.%.200s expected an int type, not %.200s",
1632 Py_TYPE(value)->tp_name);
1636 int param_i = int(param);
1639 *((
int *)
data) = param_i;
1648 const float param = PyFloat_AsDouble(value);
1649 if (PyErr_Occurred()) {
1650 PyErr_Format(PyExc_TypeError,
1651 "%.200s %.200s.%.200s expected a float type, not %.200s",
1655 Py_TYPE(value)->tp_name);
1661 *((
float *)
data) = param;
1674 if (value == Py_None) {
1681 *((
char **)
data) = (
char *)
nullptr;
1689 PyErr_Format(PyExc_TypeError,
1690 "%.200s %.200s.%.200s doesn't support None from string types",
1701 param = PyBytes_AsString(value);
1703 if (param ==
nullptr) {
1704 if (PyBytes_Check(value)) {
1709 "%.200s %.200s.%.200s error assigning bytes",
1715 PyErr_Format(PyExc_TypeError,
1716 "%.200s %.200s.%.200s expected a bytes type, not %.200s",
1720 Py_TYPE(value)->tp_name);
1731 *((
char **)
data) = (
char *)param;
1740#ifdef USE_STRING_COERCE
1741 PyObject *value_coerce =
nullptr;
1747 param = PyUnicode_AsUTF8(value);
1750 param = PyUnicode_AsUTF8(value);
1753 if (param ==
nullptr) {
1754 if (PyUnicode_Check(value)) {
1759 "%.200s %.200s.%.200s error assigning string",
1765 PyErr_Format(PyExc_TypeError,
1766 "%.200s %.200s.%.200s expected a string type, not %.200s",
1770 Py_TYPE(value)->tp_name);
1779 char warning_buf[256];
1781 "%.200s.%.200s: does not support blend relative \"//\" prefix",
1784 PyErr_WarnEx(PyExc_RuntimeWarning, warning_buf, 1);
1797 *((
char **)
data) = (
char *)param;
1804#ifdef USE_STRING_COERCE
1805 Py_XDECREF(value_coerce);
1828 *((
int *)
data) = val;
1837 PyObject *value_new =
nullptr;
1859 if (
ELEM(base_type, &RNA_Operator, &RNA_Gizmo)) {
1867 if (PyDict_Check(value)) {
1869 if (
ELEM(base_type, &RNA_OperatorProperties, &RNA_GizmoProperties)) {
1881 if (
ptr->type != &RNA_Function) {
1882 PyErr_Format(PyExc_TypeError,
1883 "%.200s %.200s.%.200s internal error coercing a dict for %.200s type",
1903 PyErr_Format(PyExc_TypeError,
1904 "%.200s %.200s.%.200s collection has no type, "
1905 "can't be used as a %.200s type",
1915 if (value == Py_None) {
1917 PyErr_Format(PyExc_TypeError,
1918 "%.200s %.200s.%.200s does not support a 'None' assignment %.200s type",
1923 Py_XDECREF(value_new);
1930 PyErr_Format(PyExc_TypeError,
1931 "%.200s %.200s.%.200s expected a %.200s type, not %.200s",
1936 Py_TYPE(value)->tp_name);
1937 Py_XDECREF(value_new);
1943 if (value_owner_id !=
nullptr) {
1945 PyErr_Format(PyExc_TypeError,
1946 "%.200s %.200s.%.200s ID type does not support assignment to itself",
1950 Py_XDECREF(value_new);
1956 if (
ptr->type != &RNA_Function) {
1957 PyErr_Format(PyExc_TypeError,
1958 "%.200s %.200s.%.200s ID type assignment is temporary, can't assign",
1962 Py_XDECREF(value_new);
1969 bool raise_error =
false;
1974 if (param ==
nullptr) {
1989 if (param ==
nullptr) {
1990 *((
void **)
data) =
nullptr;
2000 else if (param ==
nullptr) {
2001 *((
void **)
data) =
nullptr;
2004 *((
void **)
data) = param->
ptr->data;
2019 Py_XDECREF(value_new);
2034 PyErr_Format(PyExc_TypeError,
2035 "%.200s %.200s.%.200s expected a %.200s type, not %.200s",
2042 Py_XDECREF(value_new);
2046 Py_XDECREF(value_new);
2051 Py_ssize_t seq_len,
i;
2059 if (!PySequence_Check(value)) {
2062 "%.200s %.200s.%.200s expected a sequence for an RNA collection, not %.200s",
2066 Py_TYPE(value)->tp_name);
2070 seq_len = PySequence_Size(value);
2071 for (
i = 0;
i < seq_len;
i++) {
2072 item = PySequence_GetItem(value,
i);
2074 if (item ==
nullptr) {
2077 "%.200s %.200s.%.200s failed to get sequence index '%d' for an RNA collection",
2086 if (PyDict_Check(item) == 0) {
2087 PyErr_Format(PyExc_TypeError,
2088 "%.200s %.200s.%.200s expected a each sequence "
2089 "member to be a dict for an RNA collection, not %.200s",
2093 Py_TYPE(item)->tp_name);
2106 &itemptr, item,
true,
"Converting a Python list to an RNA collection") == -1)
2109 const char *msg_char = PyUnicode_AsUTF8(msg);
2112 PyErr_Format(PyExc_TypeError,
2113 "%.200s %.200s.%.200s error converting a member of a collection "
2114 "from a dicts into an RNA collection, failed with: %s",
2130 PyErr_Format(PyExc_AttributeError,
2131 "%.200s %.200s.%.200s unknown property type (pyrna_py_to_prop)",
2164 &
self->ptr.value(),
self->prop,
self->arraydim,
self->arrayoffset, index, value,
"") ==
2187 int param = PyC_Long_AsI32(value);
2188 if (param == -1 && PyErr_Occurred()) {
2189 PyErr_SetString(PyExc_TypeError,
"expected an int type");
2199 float param = PyFloat_AsDouble(value);
2200 if (PyErr_Occurred()) {
2201 PyErr_SetString(PyExc_TypeError,
"expected a float type");
2211 PyErr_SetString(PyExc_AttributeError,
"not an array type");
2263#define PYRNA_PROP_COLLECTION_ABS_INDEX(ret_err) \
2265 keynum_abs += RNA_property_collection_length(&self->ptr.value(), self->prop); \
2266 if (keynum_abs < 0) { \
2267 PyErr_Format(PyExc_IndexError, "bpy_prop_collection[%d]: out of range.", keynum); \
2278 if (value != Py_None) {
2281 if (
UNLIKELY(value_pyrna->
ptr->type ==
nullptr)) {
2284 PyErr_Format(PyExc_TypeError,
2285 "'%.200s' object is not subscriptable (only iteration is supported)",
2286 Py_TYPE(value)->tp_name);
2294 const char *error_prefix)
2296 PyErr_Format(PyExc_TypeError,
2297 "%.200s: %.200s.%.200s does not support string lookups",
2304 const char *error_prefix)
2318 Py_ssize_t keynum_abs = keynum;
2331 const int key = int(keynum_abs);
2332 PyObject *
result =
nullptr;
2356 if (keynum_abs >=
len) {
2357 PyErr_Format(PyExc_IndexError,
2358 "bpy_prop_collection[index]: "
2359 "index %d out of range, size %d",
2364 PyErr_Format(PyExc_RuntimeError,
2365 "bpy_prop_collection[index]: internal error, "
2366 "valid index %d given in %d sized collection, but value not found",
2379 Py_ssize_t keynum_abs = keynum;
2390 if (keynum_abs >=
len) {
2391 PyErr_Format(PyExc_IndexError,
2392 "bpy_prop_collection[index] = value: "
2393 "index %d out of range, size %d",
2398 PyErr_Format(PyExc_IndexError,
2399 "bpy_prop_collection[index] = value: "
2400 "index %d failed assignment (unknown reason)",
2421 if (keynum >= 0 && keynum <
len) {
2425 PyErr_Format(PyExc_IndexError,
"bpy_prop_array[index]: index %d out of range", keynum);
2442 const int key_len = strlen(keyname);
2445 PyObject *
result =
nullptr;
2456 &iter.
ptr, nameprop, name,
sizeof(name), &name_len);
2457 if ((key_len == name_len) &&
STREQ(name_ptr, keyname)) {
2460 if (name != name_ptr) {
2484 PyErr_Format(PyExc_KeyError,
"bpy_prop_collection[key]: key \"%.200s\" not found", keyname);
2502 const char *err_prefix,
2503 const short err_not_found,
2506 const char *keyname;
2509 if (PyTuple_GET_SIZE(key) != 2) {
2510 PyErr_Format(PyExc_KeyError,
2511 "%s: tuple key must be a pair, not size %d",
2513 PyTuple_GET_SIZE(key));
2516 if (
self->ptr->type != &RNA_BlendData) {
2517 PyErr_Format(PyExc_KeyError,
2518 "%s: is only valid for bpy.data collections, not %.200s",
2523 if ((keyname = PyUnicode_AsUTF8(PyTuple_GET_ITEM(key, 0))) ==
nullptr) {
2524 PyErr_Format(PyExc_KeyError,
2525 "%s: id must be a string, not %.200s",
2527 Py_TYPE(PyTuple_GET_ITEM(key, 0))->tp_name);
2531 PyObject *keylib = PyTuple_GET_ITEM(key, 1);
2535 if (keylib == Py_None) {
2538 else if (PyUnicode_Check(keylib)) {
2540 const char *keylib_str = PyUnicode_AsUTF8(keylib);
2543 if (
lib ==
nullptr) {
2544 if (err_not_found) {
2545 PyErr_Format(PyExc_KeyError,
2546 "%s: lib filepath '%.1024s' "
2547 "does not reference a valid library",
2557 PyErr_Format(PyExc_KeyError,
2558 "%s: lib must be a string or None, not %.200s",
2560 Py_TYPE(keylib)->tp_name);
2568 ID *
id =
static_cast<ID *
>(itemptr.data);
2580 if ((found ==
false) && err_not_found) {
2582 PyErr_SetString(PyExc_KeyError,
"bpy_prop_collection[key, lib]: not found");
2591 const char *err_prefix,
2592 const bool err_not_found)
2596 self, key, err_prefix, err_not_found, &
ptr);
2598 if (contains == 1) {
2617 list = PyList_New(0);
2626 PyList_APPEND(list, item);
2657 tuple = PyTuple_New(
stop - start);
2672 values =
static_cast<float *
>(PyMem_MALLOC(
sizeof(
float) *
length));
2675 values = values_stack;
2680 PyTuple_SET_ITEM(tuple,
count - start, PyFloat_FromDouble(values[
count]));
2683 if (values != values_stack) {
2692 values =
static_cast<bool *
>(PyMem_MALLOC(
sizeof(
bool) *
length));
2695 values = values_stack;
2700 PyTuple_SET_ITEM(tuple,
count - start, PyBool_FromLong(values[
count]));
2703 if (values != values_stack) {
2712 values =
static_cast<int *
>(PyMem_MALLOC(
sizeof(
int) *
length));
2715 values = values_stack;
2720 PyTuple_SET_ITEM(tuple,
count - start, PyLong_FromLong(values[
count]));
2723 if (values != values_stack) {
2731 PyErr_SetString(PyExc_TypeError,
"not an array type");
2744 if (PyUnicode_Check(key)) {
2747 if (PyIndex_Check(key)) {
2748 const Py_ssize_t
i = PyNumber_AsSsize_t(key, PyExc_IndexError);
2749 if (
i == -1 && PyErr_Occurred()) {
2755 if (PySlice_Check(key)) {
2756 PySliceObject *key_slice = (PySliceObject *)key;
2757 Py_ssize_t
step = 1;
2759 if (key_slice->step != Py_None && !_PyEval_SliceIndex(key, &
step)) {
2763 PyErr_SetString(PyExc_TypeError,
"bpy_prop_collection[slice]: slice steps not supported");
2766 if (key_slice->start == Py_None && key_slice->stop == Py_None) {
2770 Py_ssize_t start = 0,
stop = PY_SSIZE_T_MAX;
2773 if (key_slice->start != Py_None && !_PyEval_SliceIndex(key_slice->start, &start)) {
2776 if (key_slice->stop != Py_None && !_PyEval_SliceIndex(key_slice->stop, &
stop)) {
2780 if (start < 0 ||
stop < 0) {
2794 if (
stop - start <= 0) {
2795 return PyList_New(0);
2800 if (PyTuple_Check(key)) {
2803 self, key,
"bpy_prop_collection[id, lib]",
true);
2806 PyErr_Format(PyExc_TypeError,
2807 "bpy_prop_collection[key]: invalid key, "
2808 "must be a string or an int, not %.200s",
2809 Py_TYPE(key)->tp_name);
2819 if (value == Py_None) {
2821 PyErr_Format(PyExc_TypeError,
2822 "bpy_prop_collection[key] = value: invalid, "
2823 "this collection doesn't support None assignment");
2830 PyErr_Format(PyExc_TypeError,
2831 "bpy_prop_collection[key] = value: invalid, "
2832 "expected a StructRNA type or None, not a %.200s",
2833 Py_TYPE(value)->tp_name);
2839 PyErr_Format(PyExc_TypeError,
2840 "bpy_prop_collection[key] = value: invalid, "
2841 "expected a '%.200s' type or None, not a '%.200s'",
2850 PyErr_Format(PyExc_TypeError,
2851 "bpy_prop_collection[key] = value: internal error, "
2852 "failed to get the collection type");
2865 if (value ==
nullptr) {
2866 PyErr_SetString(PyExc_TypeError,
"del bpy_prop_collection[key]: not supported");
2874 if (PyUnicode_Check(key)) {
2879 if (PyIndex_Check(key)) {
2880 const Py_ssize_t
i = PyNumber_AsSsize_t(key, PyExc_IndexError);
2881 if (
i == -1 && PyErr_Occurred()) {
2888 else if (PySlice_Check(key)) {
2889 PySliceObject *key_slice = (PySliceObject *)key;
2890 Py_ssize_t
step = 1;
2892 if (key_slice->step != Py_None && !_PyEval_SliceIndex(key, &
step)) {
2895 else if (
step != 1) {
2896 PyErr_SetString(PyExc_TypeError,
"bpy_prop_collection[slice]: slice steps not supported");
2899 else if (key_slice->start == Py_None && key_slice->stop == Py_None) {
2903 Py_ssize_t start = 0,
stop = PY_SSIZE_T_MAX;
2906 if (key_slice->start != Py_None && !_PyEval_SliceIndex(key_slice->start, &start)) {
2909 if (key_slice->stop != Py_None && !_PyEval_SliceIndex(key_slice->stop, &
stop)) {
2913 if (start < 0 ||
stop < 0) {
2926 if (
stop - start <= 0) {
2927 return PyList_New(0);
2936 PyErr_Format(PyExc_TypeError,
2937 "bpy_prop_collection[key]: invalid key, "
2938 "must be an int, not %.200s",
2939 Py_TYPE(key)->tp_name);
2948 if (PyUnicode_Check(key)) {
2949 return pyrna_prop_array_subscript_str(
self, PyUnicode_AsUTF8(key));
2953 if (PyIndex_Check(key)) {
2954 const Py_ssize_t
i = PyNumber_AsSsize_t(key, PyExc_IndexError);
2955 if (
i == -1 && PyErr_Occurred()) {
2960 if (PySlice_Check(key)) {
2961 Py_ssize_t
step = 1;
2962 PySliceObject *key_slice = (PySliceObject *)key;
2964 if (key_slice->step != Py_None && !_PyEval_SliceIndex(key, &
step)) {
2968 PyErr_SetString(PyExc_TypeError,
"bpy_prop_array[slice]: slice steps not supported");
2971 if (key_slice->start == Py_None && key_slice->stop == Py_None) {
2979 Py_ssize_t start,
stop, slicelength;
2981 if (PySlice_GetIndicesEx(key,
len, &start, &
stop, &
step, &slicelength) < 0) {
2985 if (slicelength <= 0) {
2986 return PyTuple_New(0);
2993 PyErr_SetString(PyExc_AttributeError,
"bpy_prop_array[key]: invalid key, key must be an int");
3003 PyObject *value_fast;
3004 if (!(value_fast = PySequence_Fast(value,
3005 "bpy_prop_array[slice] = value: "
3006 "element in assignment is not a sequence type")))
3010 if (PySequence_Fast_GET_SIZE(value_fast) !=
length) {
3011 Py_DECREF(value_fast);
3012 PyErr_SetString(PyExc_ValueError,
3013 "bpy_prop_array[slice] = value: "
3014 "re-sizing bpy_struct element in arrays isn't supported");
3023 PyObject **value_items,
float *value,
int totdim,
const int dimsize[],
const float range[2])
3025 const int length = dimsize[0];
3031 if (
UNLIKELY(subvalue ==
nullptr)) {
3036 PySequence_Fast_ITEMS(subvalue), &value[index], totdim - 1, &dimsize[1], range);
3038 Py_DECREF(subvalue);
3044 const float min = range[0],
max = range[1];
3047 float v = PyFloat_AsDouble(value_items[
i]);
3055 PyObject **value_items,
int *value,
int totdim,
const int dimsize[],
const int range[2])
3057 const int length = dimsize[0];
3063 if (
UNLIKELY(subvalue ==
nullptr)) {
3068 PySequence_Fast_ITEMS(subvalue), &value[index], totdim - 1, &dimsize[1], range);
3070 Py_DECREF(subvalue);
3076 const int min = range[0],
max = range[1];
3079 int v = PyLong_AsLong(value_items[
i]);
3089 const int dimsize[])
3091 const int length = dimsize[0];
3097 if (
UNLIKELY(subvalue ==
nullptr)) {
3102 PySequence_Fast_ITEMS(subvalue), &value[index], totdim - 1, &dimsize[1]);
3104 Py_DECREF(subvalue);
3112 const int v = PyLong_AsLong(value_items[
i]);
3126 PyObject *value_orig)
3130 void *values_alloc =
nullptr;
3133 if (value_orig ==
nullptr) {
3136 "bpy_prop_array[slice] = value: deleting with list types is not supported by bpy_struct");
3140 if (!(value = PySequence_Fast(
3141 value_orig,
"bpy_prop_array[slice] = value: assignment is not a sequence type")))
3146 if (PySequence_Fast_GET_SIZE(value) !=
stop - start) {
3148 PyErr_SetString(PyExc_TypeError,
3149 "bpy_prop_array[slice] = value: re-sizing bpy_struct arrays isn't supported");
3161 for (
int i = arraydim + 1;
i < totdim;
i++) {
3166 PyObject **value_items = PySequence_Fast_ITEMS(value);
3170 float *values =
static_cast<float *
>(
3172 (values_alloc = PyMem_MALLOC(
sizeof(*values) * length_flat)) :
3182 dimsize[arraydim] =
stop - start;
3184 &values[arrayoffset + (start * span)],
3189 if (PyErr_Occurred()) {
3199 int *values =
static_cast<int *
>(
3201 (values_alloc = PyMem_MALLOC(
sizeof(*values) * length_flat)) :
3211 dimsize[arraydim] =
stop - start;
3213 &values[arrayoffset + (start * span)],
3218 if (PyErr_Occurred()) {
3228 bool *values =
static_cast<bool *
>(
3230 (values_alloc = PyMem_MALLOC(
sizeof(
bool) * length_flat)) :
3238 dimsize[arraydim] =
stop - start;
3240 &values[arrayoffset + (start * span)],
3242 &dimsize[arraydim]);
3244 if (PyErr_Occurred()) {
3253 PyErr_SetString(PyExc_TypeError,
"not an array type");
3261 PyMem_FREE(values_alloc);
3279 if (keynum >= 0 && keynum <
len) {
3283 PyErr_SetString(PyExc_IndexError,
"bpy_prop_array[index] = value: index out of range");
3297 PyErr_Format(PyExc_AttributeError,
3298 "bpy_prop_collection: attribute \"%.200s\" from \"%.200s\" is read-only",
3304 else if (PyIndex_Check(key)) {
3305 const Py_ssize_t
i = PyNumber_AsSsize_t(key, PyExc_IndexError);
3306 if (
i == -1 && PyErr_Occurred()) {
3313 else if (PySlice_Check(key)) {
3315 Py_ssize_t start,
stop,
step, slicelength;
3317 if (PySlice_GetIndicesEx(key,
len, &start, &
stop, &
step, &slicelength) < 0) {
3320 else if (slicelength <= 0) {
3323 else if (
step == 1) {
3334 PyErr_SetString(PyExc_TypeError,
"slice steps not supported with RNA");
3339 PyErr_SetString(PyExc_AttributeError,
"invalid key, key must be an int");
3426 if (PyTuple_Check(key)) {
3429 self, key,
"(id, lib) in bpy_prop_collection",
false,
nullptr);
3433 const char *keyname = PyUnicode_AsUTF8(key);
3435 if (keyname ==
nullptr) {
3436 PyErr_SetString(PyExc_TypeError,
3437 "bpy_prop_collection.__contains__: expected a string or a tuple of strings");
3445 self,
"bpy_prop_collection.__contains__") == -1)
3455 const char *name = PyUnicode_AsUTF8(value);
3460 PyErr_SetString(PyExc_TypeError,
"bpy_struct.__contains__: expected a string");
3465 PyErr_SetString(PyExc_TypeError,
"bpy_struct: this type doesn't support IDProperties");
3524 const char *name = PyUnicode_AsUTF8(key);
3529 PyErr_SetString(PyExc_TypeError,
"this type doesn't support IDProperties");
3533 if (name ==
nullptr) {
3534 PyErr_SetString(PyExc_TypeError,
3535 "bpy_struct[key]: only strings are allowed as keys of ID properties");
3541 if (group ==
nullptr) {
3542 PyErr_Format(PyExc_KeyError,
"bpy_struct[key]: key \"%s\" not found", name);
3548 if (idprop ==
nullptr) {
3549 PyErr_Format(PyExc_KeyError,
"bpy_struct[key]: key \"%s\" not found", name);
3562#ifdef USE_PEDANTIC_WRITE
3568 if (group ==
nullptr) {
3569 PyErr_SetString(PyExc_TypeError,
3570 "bpy_struct[key] = val: id properties not supported for this type");
3576 if (val &&
self->ptr->type && val->
ptr->type) {
3582 "bpy_struct[key] = val: datablock id properties not supported for this type");
3599 pyrna_struct_keys_doc,
3600 ".. method:: keys()\n"
3602 " Returns the keys of this objects custom properties (matches Python's\n"
3603 " dictionary function of the same name).\n"
3605 " :return: custom property keys.\n"
3606 " :rtype: :class:`idprop.types.IDPropertyGroupViewKeys`\n"
3613 PyErr_SetString(PyExc_TypeError,
"bpy_struct.keys(): this type doesn't support IDProperties");
3624 pyrna_struct_items_doc,
3625 ".. method:: items()\n"
3627 " Returns the items of this objects custom properties (matches Python's\n"
3628 " dictionary function of the same name).\n"
3630 " :return: custom property key, value pairs.\n"
3631 " :rtype: :class:`idprop.types.IDPropertyGroupViewItems`\n"
3638 PyErr_SetString(PyExc_TypeError,
"bpy_struct.items(): this type doesn't support IDProperties");
3649 pyrna_struct_values_doc,
3650 ".. method:: values()\n"
3652 " Returns the values of this objects custom properties (matches Python's\n"
3653 " dictionary function of the same name).\n"
3655 " :return: custom property values.\n"
3656 " :rtype: :class:`idprop.types.IDPropertyGroupViewValues`\n"
3663 PyErr_SetString(PyExc_TypeError,
3664 "bpy_struct.values(): this type doesn't support IDProperties");
3675 pyrna_struct_is_property_set_doc,
3676 ".. method:: is_property_set(property, /, *, ghost=True)\n"
3678 " Check if a property is set, use for testing operator properties.\n"
3680 " :arg property: Property name.\n"
3681 " :type property: str\n"
3682 " :arg ghost: Used for operators that re-run with previous settings.\n"
3683 " In this case the property is not marked as set,\n"
3684 " yet the value from the previous execution is used.\n"
3686 " In rare cases you may want to set this option to false.\n"
3688 " :type ghost: bool\n"
3689 " :return: True when the property has been set.\n"
3695 bool use_ghost =
true;
3699 static const char *_keywords[] = {
"",
"ghost",
nullptr};
3700 static _PyArg_Parser _parser = {
3709 if (!_PyArg_ParseTupleAndKeywordsFast(args, kw, &_parser, &name,
PyC_ParseBool, &use_ghost)) {
3714 PyErr_Format(PyExc_TypeError,
3715 "%.200s.is_property_set(\"%.200s\") not found",
3726 pyrna_struct_property_unset_doc,
3727 ".. method:: property_unset(property, /)\n"
3729 " Unset a property, will use default value afterward.\n"
3731 " :arg property: Property name.\n"
3732 " :type property: str\n");
3740 if (!PyArg_ParseTuple(args,
"s:property_unset", &name)) {
3745 PyErr_Format(PyExc_TypeError,
3746 "%.200s.property_unset(\"%.200s\") not found",
3759 pyrna_struct_is_property_hidden_doc,
3760 ".. method:: is_property_hidden(property, /)\n"
3762 " Check if a property is hidden.\n"
3764 " :arg property: Property name.\n"
3765 " :type property: str\n"
3766 " :return: True when the property is hidden.\n"
3775 if (!PyArg_ParseTuple(args,
"s:is_property_hidden", &name)) {
3780 PyErr_Format(PyExc_TypeError,
3781 "%.200s.is_property_hidden(\"%.200s\") not found",
3792 pyrna_struct_is_property_readonly_doc,
3793 ".. method:: is_property_readonly(property, /)\n"
3795 " Check if a property is readonly.\n"
3797 " :arg property: Property name.\n"
3798 " :type property: str\n"
3799 " :return: True when the property is readonly (not writable).\n"
3808 if (!PyArg_ParseTuple(args,
"s:is_property_readonly", &name)) {
3813 PyErr_Format(PyExc_TypeError,
3814 "%.200s.is_property_readonly(\"%.200s\") not found",
3825 pyrna_struct_is_property_overridable_library_doc,
3826 ".. method:: is_property_overridable_library(property, /)\n"
3828 " Check if a property is overridable.\n"
3830 " :arg property: Property name.\n"
3831 " :type property: str\n"
3832 " :return: True when the property is overridable.\n"
3841 if (!PyArg_ParseTuple(args,
"s:is_property_overridable_library", &name)) {
3846 PyErr_Format(PyExc_TypeError,
3847 "%.200s.is_property_overridable_library(\"%.200s\") not found",
3858 pyrna_struct_property_overridable_library_set_doc,
3859 ".. method:: property_overridable_library_set(property, overridable, /)\n"
3861 " Define a property as overridable or not (only for custom properties!).\n"
3863 " :arg property: Property name.\n"
3864 " :type property: str\n"
3865 " :arg overridable: Overridable status to set.\n"
3866 " :type overridable: bool\n"
3867 " :return: True when the overridable status of the property was successfully set.\n"
3877 if (!PyArg_ParseTuple(args,
"sp:property_overridable_library_set", &name, &is_overridable)) {
3882 PyErr_Format(PyExc_TypeError,
3883 "%.200s.property_overridable_library_set(\"%.200s\") not found",
3889 return PyBool_FromLong(
3895 pyrna_struct_path_resolve_doc,
3896 ".. method:: path_resolve(path, coerce=True, /)\n"
3898 " Returns the property from the path, raise an exception when not found.\n"
3900 " :arg path: path which this property resolves.\n"
3901 " :type path: str\n"
3902 " :arg coerce: optional argument, when True, the property will be converted\n"
3903 " into its Python representation.\n"
3904 " :type coerce: bool\n"
3905 " :return: Property value or property object.\n"
3906 " :rtype: Any | :class:`bpy.types.bpy_prop`\n");
3910 PyObject *coerce = Py_True;
3917 if (!PyArg_ParseTuple(args,
"s|O!:path_resolve", &path, &PyBool_Type, &coerce)) {
3925 PyErr_Format(PyExc_IndexError,
3926 "%.200s.path_resolve(\"%.200s\") index out of range",
3935 if (coerce == Py_False) {
3945 PyErr_Format(PyExc_ValueError,
3946 "%.200s.path_resolve(\"%.200s\") could not be resolved",
3954 pyrna_struct_path_from_id_doc,
3955 ".. method:: path_from_id(property=\"\", /)\n"
3957 " Returns the data path from the ID to this object (string).\n"
3959 " :arg property: Optional property name which can be used if the path is\n"
3960 " to a property of this object.\n"
3961 " :type property: str\n"
3962 " :return: The path from :class:`bpy.types.bpy_struct.id_data`\n"
3963 " to this struct and property (when given).\n"
3967 const char *name =
nullptr;
3972 if (!PyArg_ParseTuple(args,
"|s:path_from_id", &name)) {
3976 std::optional<std::string> path;
3979 if (prop ==
nullptr) {
3980 PyErr_Format(PyExc_AttributeError,
3981 "%.200s.path_from_id(\"%.200s\") not found",
3995 PyErr_Format(PyExc_ValueError,
3996 "%.200s.path_from_id(\"%s\") found, but does not support path creation",
4001 PyErr_Format(PyExc_ValueError,
4002 "%.200s.path_from_id() does not support path creation for this type",
4013 pyrna_prop_path_from_id_doc,
4014 ".. method:: path_from_id()\n"
4016 " Returns the data path from the ID to this property (string).\n"
4018 " :return: The path from :class:`bpy.types.bpy_struct.id_data` to this property.\n"
4028 PyErr_Format(PyExc_ValueError,
4029 "%.200s.%.200s.path_from_id() does not support path creation for this type",
4040 pyrna_prop_as_bytes_doc,
4041 ".. method:: as_bytes()\n"
4043 " Returns this string property as a byte rather than a Python string.\n"
4045 " :return: The string as bytes.\n"
4046 " :rtype: bytes\n");
4051 PyErr_Format(PyExc_TypeError,
4052 "%.200s.%.200s.as_bytes() must be a string",
4059 char buf_fixed[256], *buf;
4063 &
self->ptr.value(),
self->prop, buf_fixed,
sizeof(buf_fixed), &buf_len);
4065 ret = PyBytes_FromStringAndSize(buf, buf_len);
4067 if (buf_fixed != buf) {
4076 pyrna_prop_update_doc,
4077 ".. method:: update()\n"
4079 " Execute the properties update callback.\n"
4082 " This is called when assigning a property,\n"
4083 " however in rare cases it's useful to call explicitly.\n");
4092 pyrna_struct_type_recast_doc,
4093 ".. method:: type_recast()\n"
4095 " Return a new instance, this is needed because types\n"
4096 " such as textures can be changed at runtime.\n"
4098 " :return: a new instance of this object with the type initialized again.\n"
4099 " :rtype: :class:`bpy.types.bpy_struct`\n");
4114 PyObject *ret_test =
nullptr;
4115 PyObject *subclasses = (PyObject *)((PyTypeObject *)cls)->tp_subclasses;
4120 PyObject *key =
nullptr;
4122 PyObject *value =
nullptr;
4123 while (PyDict_Next(subclasses, &
pos, &key, &value)) {
4125 PyObject *subcls = PyWeakref_GET_OBJECT(value);
4126 if (subcls != Py_None) {
4148 pyrna_struct_bl_rna_get_subclass_py_doc,
4149 ".. classmethod:: bl_rna_get_subclass_py(id, default=None, /)\n"
4151 " :arg id: The RNA type identifier.\n"
4153 " :return: The class or default when not found.\n"
4158 PyObject *ret_default = Py_None;
4160 if (!PyArg_ParseTuple(args,
"s|O:bl_rna_get_subclass_py", &
id, &ret_default)) {
4164 if (
ret ==
nullptr) {
4167 return Py_NewRef(
ret);
4172 pyrna_struct_bl_rna_get_subclass_doc,
4173 ".. classmethod:: bl_rna_get_subclass(id, default=None, /)\n"
4175 " :arg id: The RNA type identifier.\n"
4177 " :return: The RNA type or default when not found.\n"
4178 " :rtype: :class:`bpy.types.Struct` subclass\n");
4182 PyObject *ret_default = Py_None;
4184 if (!PyArg_ParseTuple(args,
"s|O:bl_rna_get_subclass", &
id, &ret_default)) {
4190 if (py_srna ==
nullptr) {
4191 PyErr_SetString(PyExc_ValueError,
"Not a registered class");
4196 if (srna_base == &RNA_Node) {
4213 return Py_NewRef(ret_default);
4218 pyrna_struct_get_ancestors_doc,
4219 ".. method:: rna_ancestors()\n"
4221 " Return the chain of data containing this struct, if known.\n"
4222 " The first item is the root (typically an ID), the last one is the immediate parent.\n"
4225 " :return: a list of this object's ancestors.\n"
4226 " :rtype: list[:class:`bpy.types.bpy_struct`]\n");
4232 const int ancestors_num(
self->ptr->ancestors.size());
4234 ret = PyList_New(ancestors_num);
4236 for (
int i = 0;
i < ancestors_num;
i++) {
4239 PyList_SET_ITEM(
ret,
i, ancestor);
4249 list_tmp = PyDict_Keys(dict);
4250 PyList_SetSlice(list, INT_MAX, INT_MAX, list_tmp);
4251 Py_DECREF(list_tmp);
4257 PyObject **dict_ptr;
4259 dict_ptr = _PyObject_GetDictPtr(
self);
4261 if (dict_ptr && (dict = *dict_ptr)) {
4265 dict = ((PyTypeObject *)Py_TYPE(
self))->tp_dict;
4278 dict = ((PyTypeObject *)cls)->tp_dict;
4301 PyList_APPEND(list, PyUnicode_FromString(idname));
4311 char name[256], *name_ptr;
4324 PyList_APPEND(list, PyUnicode_FromStringAndSize(name_ptr, name_len));
4326 if (name != name_ptr) {
4343 ret = PyList_New(0);
4351 if (
self->ptr->type == &RNA_Context) {
4355 PyList_APPEND(
ret, PyUnicode_FromString(
static_cast<const char *
>(link->data)));
4365 PyObject *set = PySet_New(
ret);
4368 ret = PySequence_List(set);
4377 pyrna_struct_id_properties_ensure_doc,
4378 ".. method:: id_properties_ensure()\n"
4380 " :return: the parent group for an RNA struct's custom IDProperties.\n"
4381 " :rtype: :class:`idprop.types.IDPropertyGroup`\n");
4387 PyErr_SetString(PyExc_TypeError,
"This type doesn't support IDProperties");
4395 if (idprops ==
nullptr) {
4401 group->
prop = idprops;
4403 return (PyObject *)group;
4408 pyrna_struct_id_properties_ui_doc,
4409 ".. method:: id_properties_ui(key, /)\n"
4411 " :return: Return an object used to manage an IDProperty's UI data.\n"
4412 " :arg key: String name of the property.\n"
4413 " :type key: str.\n"
4414 " :rtype: :class:`bpy.types.IDPropertyUIManager`\n");
4420 PyErr_SetString(PyExc_TypeError,
"This type doesn't support IDProperties");
4425 if (!PyArg_ParseTuple(args,
"s:ui_data", &key)) {
4433 if (parent_group ==
nullptr) {
4438 if (property ==
nullptr) {
4439 PyErr_SetString(PyExc_KeyError,
"Property not found in IDProperty group");
4444 PyErr_Format(PyExc_TypeError,
"IDProperty \"%s\" does not support UI data", property->name);
4451 return (PyObject *)ui_manager;
4456 pyrna_struct_id_properties_clear_doc,
4457 ".. method:: id_properties_clear()\n"
4459 " :return: Remove the parent group for an RNA struct's custom IDProperties.\n");
4465 PyErr_SetString(PyExc_TypeError,
"This type doesn't support IDProperties");
4482 const char *name = PyUnicode_AsUTF8(pyname);
4490 if (name ==
nullptr) {
4491 PyErr_SetString(PyExc_AttributeError,
"bpy_struct: __getattr__ must be a string");
4501 PyErr_SetString(PyExc_AttributeError,
"bpy_struct: no __getitem__ support for this type");
4505 ret = PyObject_GenericGetAttr((PyObject *)
self, pyname);
4516 else if (
self->ptr->type == &RNA_Context) {
4519 PyErr_Format(PyExc_AttributeError,
4520 "bpy_struct: Context is 'nullptr', can't get \"%.200s\" from context",
4530 std::optional<int64_t> newint;
4538 C, name, &newptr, &newlb, &newprop, &newindex, &newstr, &newint, &newtype));
4548 if (newptr.
data ==
nullptr) {
4562 ret = PyUnicode_FromStringAndSize(newstr.
data(), newstr.
size());
4567 if (!newint.has_value()) {
4572 ret = PyLong_FromLong(*newint);
4577 ret = PyList_New(0);
4584 if (newprop !=
nullptr) {
4589 std::optional<std::string> path_str;
4602 ret = PyTuple_New(3);
4606 PyLong_FromLong(newindex));
4623 PyErr_Format(PyExc_AttributeError,
4624 "bpy_struct: Context type invalid %d, can't get \"%.200s\" from context",
4637 ret = PyObject_GenericGetAttr((PyObject *)
self, pyname);
4643 PyErr_Format(PyExc_AttributeError,
"bpy_struct: attribute \"%.200s\" not found", name);
4653 ret = PyObject_GenericGetAttr((PyObject *)
self, pyname);
4660static int pyrna_struct_pydict_contains(PyObject *
self, PyObject *pyname)
4662 PyObject *dict = *(_PyObject_GetDictPtr((PyObject *)
self));
4667 return PyDict_Contains(dict, pyname);
4674static PyObject *pyrna_struct_meta_idprop_getattro(PyObject *cls, PyObject *attr)
4676 PyObject *
ret = PyType_Type.tp_getattro(cls, attr);
4688 if ((
ret ==
nullptr) ) {
4698 if (
ret ==
nullptr) {
4699 PyErr_Format(PyExc_AttributeError,
4700 "StructRNA.__getattr__: attribute \"%.200s\" not found",
4701 PyUnicode_AsUTF8(attr));
4714 const char *attr_str = PyUnicode_AsUTF8(attr);
4719 PyErr_Format(PyExc_AttributeError,
4720 "pyrna_struct_meta_idprop_setattro() "
4721 "can't set in readonly state '%.200s.%S'",
4722 ((PyTypeObject *)cls)->tp_name,
4727 if (srna ==
nullptr) {
4730 if (value && is_deferred_prop) {
4731 PyErr_Format(PyExc_AttributeError,
4732 "pyrna_struct_meta_idprop_setattro() unable to get srna from class '%.200s'",
4733 ((PyTypeObject *)cls)->tp_name);
4739 return PyType_Type.tp_setattro(cls, attr, value);
4744 if (is_deferred_prop) {
4765 PyExc_TypeError,
"struct_meta_idprop.detattr(): '%s' not a dynamic property", attr_str);
4771 return PyType_Type.tp_setattro(cls, attr, value);
4776 const char *name = PyUnicode_AsUTF8(pyname);
4781#ifdef USE_PEDANTIC_WRITE
4787 if (name ==
nullptr) {
4788 PyErr_SetString(PyExc_AttributeError,
"bpy_struct: __setattr__ must be a string");
4793 PyErr_Format(PyExc_AttributeError,
4794 "bpy_struct: attribute \"%.200s\" from \"%.200s\" is read-only",
4800 else if (
self->ptr->type == &RNA_Context) {
4805 PyErr_Format(PyExc_AttributeError,
4806 "bpy_struct: Context is 'nullptr', can't set \"%.200s\" from context",
4816 std::optional<int64_t> newint;
4820 CTX_data_get(
C, name, &newptr, &newlb, &newprop, &newindex, &newstr, &newint, &newtype));
4824 PyExc_AttributeError,
"bpy_struct: Context property \"%.200s\" is read-only", name);
4831 if (value ==
nullptr) {
4832 PyErr_SetString(PyExc_AttributeError,
"bpy_struct: del not supported");
4836 &
self->ptr.value(), prop,
nullptr, value,
"bpy_struct: item.attr = val:");
4839 return PyObject_GenericSetAttr((PyObject *)
self, pyname, value);
4849 ret = PyList_New(0);
4866 return PyObject_GenericGetAttr((PyObject *)
self, pyname);
4871 const char *name = PyUnicode_AsUTF8(pyname);
4873 if (name ==
nullptr) {
4874 PyErr_SetString(PyExc_AttributeError,
"bpy_prop_collection: __getattr__ must be a string");
4877 if (name[0] !=
'_') {
4893 Py_DECREF(self_collection);
4901 return PyObject_GenericGetAttr((PyObject *)
self, pyname);
4908 PyObject *
ret = _PyObject_GenericGetAttrWithDict((PyObject *)
self, pyname,
nullptr, 1);
4911 if ((
ret ==
nullptr) && (name[0] !=
'_')) {
4916 ret = _PyObject_GenericGetAttrWithDict(cls, pyname,
nullptr, 1);
4919 if (
ret !=
nullptr) {
4920 if (Py_TYPE(
ret) == &PyMethodDescr_Type) {
4921 PyMethodDef *m = ((PyMethodDescrObject *)
ret)->d_method;
4923 if (m->ml_flags & METH_STATIC) {
4928 ret = PyCMethod_New(m, (PyObject *)
self,
nullptr,
nullptr);
4935 if (
ret ==
nullptr) {
4937 PyExc_AttributeError,
"bpy_prop_collection: attribute \"%.200s\" not found", name);
4948 const char *name = PyUnicode_AsUTF8(pyname);
4952#ifdef USE_PEDANTIC_WRITE
4958 if (name ==
nullptr) {
4959 PyErr_SetString(PyExc_AttributeError,
"bpy_prop: __setattr__ must be a string");
4962 if (value ==
nullptr) {
4963 PyErr_SetString(PyExc_AttributeError,
"bpy_prop: del not supported");
4970 &r_ptr, prop,
nullptr, value,
"BPy_PropertyRNA - Attribute (setattr):");
4974 PyErr_Format(PyExc_AttributeError,
"bpy_prop_collection: attribute \"%.200s\" not found", name);
4983 pyrna_prop_collection_idprop_add_doc,
4984 ".. method:: add()\n"
4986 " This is a function to add a new item to a collection.\n"
4988 " :return: A newly created item.\n"
4994#ifdef USE_PEDANTIC_WRITE
5002 PyErr_SetString(PyExc_TypeError,
5003 "bpy_prop_collection.add(): not supported for this collection");
5012 pyrna_prop_collection_idprop_remove_doc,
5013 ".. method:: remove(index)\n"
5015 " This is a function to remove an item from a collection.\n"
5017 " :arg index: Index of the item to be removed.\n"
5018 " :type index: int\n");
5021 const int key = PyLong_AsLong(value);
5023#ifdef USE_PEDANTIC_WRITE
5029 if (key == -1 && PyErr_Occurred()) {
5030 PyErr_SetString(PyExc_TypeError,
"bpy_prop_collection.remove(): expected one int argument");
5035 PyErr_SetString(PyExc_TypeError,
5036 "bpy_prop_collection.remove() not supported for this collection");
5045 pyrna_prop_collection_idprop_clear_doc,
5046 ".. method:: clear()\n"
5048 " This is a function to remove all items from a collection.\n");
5051#ifdef USE_PEDANTIC_WRITE
5064 pyrna_prop_collection_idprop_move_doc,
5065 ".. method:: move(src_index, dst_index)\n"
5067 " This is a function to move an item in a collection.\n"
5069 " :arg src_index: Source item index.\n"
5070 " :type src_index: int\n"
5071 " :arg dst_index: Destination item index.\n"
5072 " :type dst_index: int\n");
5075 int key = 0,
pos = 0;
5077#ifdef USE_PEDANTIC_WRITE
5083 if (!PyArg_ParseTuple(args,
"ii", &key, &
pos)) {
5084 PyErr_SetString(PyExc_TypeError,
"bpy_prop_collection.move(): expected two ints as arguments");
5089 PyErr_SetString(PyExc_TypeError,
5090 "bpy_prop_collection.move() not supported for this collection");
5099 pyrna_struct_get_id_data_doc,
5100 "The :class:`bpy.types.ID` object this datablock is from or None, (not available for "
5103 ":type: :class:`bpy.types.ID`, (readonly)\n");
5107 if (
self->ptr->owner_id) {
5117 pyrna_struct_get_data_doc,
5118 "The data this property is using, *type* :class:`bpy.types.bpy_struct`");
5126 pyrna_struct_get_rna_type_doc,
5127 "The property type for introspection");
5142 pyrna_struct_get_id_data_doc,
5148 pyrna_struct_get_rna_type_doc,
5150 {
nullptr,
nullptr,
nullptr,
nullptr,
nullptr}
5157 pyrna_struct_get_id_data_doc,
5159 {
nullptr,
nullptr,
nullptr,
nullptr,
nullptr}
5166 {
nullptr,
nullptr,
nullptr,
nullptr,
nullptr}
5171 pyrna_prop_collection_keys_doc,
5172 ".. method:: keys()\n"
5174 " Return the identifiers of collection members\n"
5175 " (matching Python's dict.keys() functionality).\n"
5177 " :return: the identifiers for each member of this collection.\n"
5178 " :rtype: list[str]\n");
5181 PyObject *
ret = PyList_New(0);
5182 char name[256], *name_ptr;
5189 PyList_APPEND(
ret, PyUnicode_FromStringAndSize(name_ptr, name_len));
5191 if (name != name_ptr) {
5203 pyrna_prop_collection_items_doc,
5204 ".. method:: items()\n"
5206 " Return the identifiers of collection members\n"
5207 " (matching Python's dict.items() functionality).\n"
5209 " :return: (key, value) pairs for each member of this collection.\n"
5210 " :rtype: list[tuple[str, :class:`bpy.types.bpy_struct`]]\n");
5213 PyObject *
ret = PyList_New(0);
5215 char name[256], *name_ptr;
5222 item = PyTuple_New(2);
5225 PyTuple_SET_ITEM(item, 0, PyUnicode_FromStringAndSize(name_ptr, name_len));
5226 if (name != name_ptr) {
5232 PyTuple_SET_ITEM(item, 0, PyLong_FromLong(
i));
5236 PyList_APPEND(
ret, item);
5248 pyrna_prop_collection_values_doc,
5249 ".. method:: values()\n"
5251 " Return the values of collection\n"
5252 " (matching Python's dict.values() functionality).\n"
5254 " :return: The members of this collection.\n"
5255 " :rtype: list[:class:`bpy.types.bpy_struct` | None]\n");
5264 pyrna_struct_get_doc,
5265 ".. method:: get(key, default=None, /)\n"
5267 " Returns the value of the custom property assigned to key or default\n"
5268 " when not found (matches Python's dictionary function of the same name).\n"
5270 " :arg key: The key associated with the custom property.\n"
5272 " :arg default: Optional argument for the value to return if\n"
5273 " *key* is not found.\n"
5274 " :type default: Any\n"
5275 " :return: Custom property value or default.\n"
5283 PyObject *def = Py_None;
5287 if (!PyArg_ParseTuple(args,
"s|O:get", &key, &def)) {
5293 PyErr_SetString(PyExc_TypeError,
"this type doesn't support IDProperties");
5306 return Py_NewRef(def);
5311 pyrna_struct_pop_doc,
5312 ".. method:: pop(key, default=None, /)\n"
5314 " Remove and return the value of the custom property assigned to key or default\n"
5315 " when not found (matches Python's dictionary function of the same name).\n"
5317 " :arg key: The key associated with the custom property.\n"
5319 " :arg default: Optional argument for the value to return if\n"
5320 " *key* is not found.\n"
5321 " :type default: Any\n"
5322 " :return: Custom property value or default.\n"
5330 PyObject *def =
nullptr;
5334 if (!PyArg_ParseTuple(args,
"s|O:get", &key, &def)) {
5340 PyErr_SetString(PyExc_TypeError,
"this type doesn't support IDProperties");
5360 if (def ==
nullptr) {
5361 PyErr_SetString(PyExc_KeyError,
"key not found");
5364 return Py_NewRef(def);
5369 pyrna_struct_as_pointer_doc,
5370 ".. method:: as_pointer()\n"
5372 " Returns the memory address which holds a pointer to Blender's internal data\n"
5374 " :return: int (memory address).\n"
5377 " .. note:: This is intended only for advanced script writers who need to\n"
5378 " pass blender data to their own C/Python modules.\n");
5381 return PyLong_FromVoidPtr(
self->ptr->data);
5386 pyrna_prop_collection_get_doc,
5387 ".. method:: get(key, default=None)\n"
5389 " Returns the value of the item assigned to key or default when not found\n"
5390 " (matches Python's dictionary function of the same name).\n"
5392 " :arg key: The identifier for the collection member.\n"
5394 " :arg default: Optional argument for the value to return if\n"
5395 " *key* is not found.\n"
5396 " :type default: Any\n");
5402 PyObject *def = Py_None;
5406 if (!PyArg_ParseTuple(args,
"O|O:get", &key_ob, &def)) {
5410 if (PyUnicode_Check(key_ob)) {
5411 const char *key = PyUnicode_AsUTF8(key_ob);
5417 "bpy_prop_collection.get") == -1)
5422 else if (PyTuple_Check(key_ob)) {
5424 self, key_ob,
"bpy_prop_collection.get((id, lib))",
false);
5430 PyErr_Format(PyExc_KeyError,
5431 "bpy_prop_collection.get(key, ...): key must be a string or tuple, not %.200s",
5432 Py_TYPE(key_ob)->tp_name);
5435 return Py_NewRef(def);
5440 pyrna_prop_collection_find_doc,
5441 ".. method:: find(key)\n"
5443 " Returns the index of a key in a collection or -1 when not found\n"
5444 " (matches Python's string find function of the same name).\n"
5446 " :arg key: The identifier for the collection member.\n"
5448 " :return: index of the key.\n"
5452 Py_ssize_t key_len_ssize;
5453 const char *key = PyUnicode_AsUTF8AndSize(key_ob, &key_len_ssize);
5454 const int key_len = int(key_len_ssize);
5456 char name[256], *name_ptr;
5467 if ((key_len == name_len) && memcmp(name_ptr, key, key_len) == 0) {
5472 if (name != name_ptr) {
5481 return PyLong_FromLong(index);
5489 bool *r_attr_signed,
5493 bool attr_ok =
true;
5496 *r_attr_signed =
false;
5510 *r_is_empty =
false;
5521 const char *function_name,
5524 const char **r_attr,
5530 bool *r_attr_signed)
5532 *r_size = *r_attr_tot = 0;
5533 *r_attr_signed =
false;
5536 if (!PyArg_ParseTuple(args,
"sO:foreach_get/set", r_attr, r_seq)) {
5540 if (!PySequence_Check(*r_seq) && PyObject_CheckBuffer(*r_seq)) {
5541 PyErr_Format(PyExc_TypeError,
5542 "%s(..) expected second argument to be a sequence or buffer, not a %.200s",
5544 Py_TYPE(*r_seq)->tp_name);
5549 *r_tot = PySequence_Size(*r_seq);
5562 if (array_tot == 0) {
5563 PyErr_Format(PyExc_TypeError,
5564 "%s(..) sequence length mismatch given %d, needed 0",
5571 bool is_empty =
false;
5573 PyErr_Format(PyExc_AttributeError,
5574 "%s(..) '%.200s.%200s[...]' elements have no attribute '%.200s'",
5583 PyErr_Format(PyExc_TypeError,
5584 "%s(..) sequence length mismatch given %d, needed 0",
5597 if ((*r_attr_tot) < 1) {
5601 const int target_tot = array_tot * (*r_attr_tot);
5604 if (target_tot != (*r_tot)) {
5605 PyErr_Format(PyExc_TypeError,
5606 "%s(..) sequence length mismatch given %d, needed %d",
5618 if (*r_size == 0 && *r_attr_tot != 0) {
5620 PyExc_AttributeError,
"%s(..): attribute does not support foreach method", function_name);
5633 return (f ==
'b') ?
true :
false;
5636 return (f ==
'B') ?
true :
false;
5640 return (f ==
'B') ?
true :
false;
5643 return (f ==
'h') ?
true :
false;
5646 return (f ==
'H') ?
true :
false;
5649 return (f ==
'H') ?
true :
false;
5652 return (f ==
'i') ?
true :
false;
5655 return (f ==
'I') ?
true :
false;
5658 return (f ==
'?') ?
true :
false;
5660 return (f ==
'f') ?
true :
false;
5662 return (f ==
'd') ?
true :
false;
5665 return (f ==
'q') ?
true :
false;
5668 return (f ==
'Q') ?
true :
false;
5671 return (f ==
'Q') ?
true :
false;
5681 PyObject *item =
nullptr;
5683 bool buffer_is_compat;
5684 void *
array =
nullptr;
5696 set ?
"foreach_set" :
"foreach_get",
5703 &attr_signed) == -1)
5713 buffer_is_compat =
false;
5714 if (PyObject_CheckBuffer(seq)) {
5716 if (PyObject_GetBuffer(seq, &buf, PyBUF_ND | PyBUF_FORMAT) == -1) {
5726 if (buffer_is_compat) {
5728 nullptr, &
self->ptr.value(),
self->prop, attr, buf.buf, raw_type, tot);
5731 PyBuffer_Release(&buf);
5736 if (!buffer_is_compat) {
5739 for (;
i < tot;
i++) {
5740 item = PySequence_GetItem(seq,
i);
5758 ((
int *)
array)[
i] = int(PyC_Long_AsI32(item));
5764 ((
float *)
array)[
i] = float(PyFloat_AsDouble(item));
5767 ((
double *)
array)[
i] = PyFloat_AsDouble(item);
5785 nullptr, &
self->ptr.value(),
self->prop, attr,
array, raw_type, tot);
5789 buffer_is_compat =
false;
5790 if (PyObject_CheckBuffer(seq)) {
5792 if (PyObject_GetBuffer(seq, &buf, PyBUF_ND | PyBUF_FORMAT) == -1) {
5802 if (buffer_is_compat) {
5804 nullptr, &
self->ptr.value(),
self->prop, attr, buf.buf, raw_type, tot);
5807 PyBuffer_Release(&buf);
5812 if (!buffer_is_compat) {
5816 nullptr, &
self->ptr.value(),
self->prop, attr,
array, raw_type, tot);
5823 for (;
i < tot;
i++) {
5827 item = PyLong_FromLong(
long(((
char *)
array)[
i]));
5830 item = PyLong_FromLong(
long(((int8_t *)
array)[
i]));
5833 item = PyLong_FromLong(
long(((uint8_t *)
array)[
i]));
5836 item = PyLong_FromLong(
long(((
short *)
array)[
i]));
5839 item = PyLong_FromLong(
long(((uint16_t *)
array)[
i]));
5842 item = PyLong_FromLong(
long(((
int *)
array)[
i]));
5845 item = PyFloat_FromDouble(
double(((
float *)
array)[
i]));
5848 item = PyFloat_FromDouble(((
double *)
array)[
i]);
5851 item = PyBool_FromLong(
long(((
bool *)
array)[
i]));
5867 PySequence_SetItem(seq,
i, item);
5877 if (PyErr_Occurred()) {
5880 PyErr_SetString(PyExc_TypeError,
"couldn't access the py sequence");
5884 PyErr_SetString(PyExc_RuntimeError,
"internal error setting the array");
5896 pyrna_prop_collection_foreach_get_doc,
5897 ".. method:: foreach_get(attr, seq)\n"
5899 " This is a function to give fast access to attributes within a collection.\n");
5909 pyrna_prop_collection_foreach_set_doc,
5910 ".. method:: foreach_set(attr, seq)\n"
5912 " This is a function to give fast access to attributes within a collection.\n");
5924 PyObject *item =
nullptr;
5925 Py_ssize_t
i, seq_size,
size;
5926 void *
array =
nullptr;
5933 PyErr_Format(PyExc_TypeError,
"foreach_get/set available only for int and float");
5937 if (!PyArg_ParseTuple(args,
"O:foreach_get/set", &seq)) {
5941 if (!PySequence_Check(seq) && PyObject_CheckBuffer(seq)) {
5944 "foreach_get/set expected second argument to be a sequence or buffer, not a %.200s",
5945 Py_TYPE(seq)->tp_name);
5952 seq_size = PySequence_Size(seq);
5954 if (
size != seq_size) {
5955 PyErr_Format(PyExc_TypeError,
"expected sequence size %d, got %d",
size, seq_size);
5960 if (PyObject_GetBuffer(seq, &buf, PyBUF_ND | PyBUF_FORMAT) == -1) {
5963 switch (prop_type) {
5965 array = PyMem_Malloc(
sizeof(
int) *
size);
5968 item = PySequence_GetItem(seq,
i);
5969 ((
int *)
array)[
i] = int(PyLong_AsLong(item));
5974 &
self->ptr.value(),
self->prop,
static_cast<const int *
>(
array));
5980 item = PyLong_FromLong(
long(((
int *)
array)[
i]));
5981 PySequence_SetItem(seq,
i, item);
5988 array = PyMem_Malloc(
sizeof(
float) *
size);
5991 item = PySequence_GetItem(seq,
i);
5992 ((
float *)
array)[
i] = float(PyFloat_AsDouble(item));
5997 &
self->ptr.value(),
self->prop,
static_cast<const float *
>(
array));
6001 &
self->ptr.value(),
self->prop,
static_cast<float *
>(
array));
6004 item = PyFloat_FromDouble(
double(((
float *)
array)[
i]));
6005 PySequence_SetItem(seq,
i, item);
6022 if (PyErr_Occurred()) {
6025 PyErr_SetString(PyExc_TypeError,
"couldn't access the py sequence");
6030 const char f = buf.format ? buf.format[0] : 0;
6031 if ((prop_type ==
PROP_INT && (buf.itemsize !=
sizeof(
int) || !
ELEM(f,
'l',
'i'))) ||
6032 (prop_type ==
PROP_FLOAT && (buf.itemsize !=
sizeof(
float) || f !=
'f')))
6034 PyBuffer_Release(&buf);
6035 PyErr_Format(PyExc_TypeError,
"incorrect sequence item type: %s", buf.format);
6039 switch (prop_type) {
6043 &
self->ptr.value(),
self->prop,
static_cast<const int *
>(buf.buf));
6052 &
self->ptr.value(),
self->prop,
static_cast<const float *
>(buf.buf));
6056 &
self->ptr.value(),
self->prop,
static_cast<float *
>(buf.buf));
6069 PyBuffer_Release(&buf);
6077 pyrna_prop_array_foreach_get_doc,
6078 ".. method:: foreach_get(seq)\n"
6080 " This is a function to give fast access to array data.\n");
6090 pyrna_prop_array_foreach_set_doc,
6091 ".. method:: foreach_set(seq)\n"
6093 " This is a function to give fast access to array data.\n");
6107 PyObject *iter =
nullptr;
6118 iter = PyObject_GetIter(
ret);
6127#ifndef USE_PYRNA_ITER
6134 PyObject *iter =
nullptr;
6140 iter = PyObject_GetIter(
ret);
6150# pragma clang diagnostic push
6151# pragma clang diagnostic ignored "-Wcast-function-type"
6153# pragma GCC diagnostic push
6154# pragma GCC diagnostic ignored "-Wcast-function-type"
6165 {
"get", (PyCFunction)
pyrna_struct_get, METH_VARARGS, pyrna_struct_get_doc},
6166 {
"pop", (PyCFunction)
pyrna_struct_pop, METH_VARARGS, pyrna_struct_pop_doc},
6173 METH_VARARGS | METH_KEYWORDS,
6177 METH_VARARGS | METH_KEYWORDS,
6190 METH_VARARGS | METH_KEYWORDS,
6191 pyrna_struct_is_property_set_doc},
6195 pyrna_struct_property_unset_doc},
6196 {
"is_property_hidden",
6199 pyrna_struct_is_property_hidden_doc},
6200 {
"is_property_readonly",
6203 pyrna_struct_is_property_readonly_doc},
6204 {
"is_property_overridable_library",
6207 pyrna_struct_is_property_overridable_library_doc},
6208 {
"property_overridable_library_set",
6211 pyrna_struct_property_overridable_library_set_doc},
6215 pyrna_struct_path_resolve_doc},
6219 pyrna_struct_path_from_id_doc},
6223 pyrna_struct_type_recast_doc},
6224 {
"bl_rna_get_subclass_py",
6226 METH_VARARGS | METH_CLASS,
6227 pyrna_struct_bl_rna_get_subclass_py_doc},
6228 {
"bl_rna_get_subclass",
6230 METH_VARARGS | METH_CLASS,
6231 pyrna_struct_bl_rna_get_subclass_doc},
6235 pyrna_struct_get_ancestors_doc},
6237 {
"id_properties_ensure",
6240 pyrna_struct_id_properties_ensure_doc},
6241 {
"id_properties_clear",
6244 pyrna_struct_id_properties_clear_doc},
6245 {
"id_properties_ui",
6248 pyrna_struct_id_properties_ui_doc},
6253 {
"callback_add", (PyCFunction)pyrna_callback_add, METH_VARARGS,
nullptr},
6254 {
"callback_remove", (PyCFunction)pyrna_callback_remove, METH_VARARGS,
nullptr},
6258 METH_VARARGS | METH_CLASS,
6262 METH_VARARGS | METH_CLASS,
6265 {
nullptr,
nullptr, 0,
nullptr},
6272 pyrna_prop_path_from_id_doc},
6276 {
nullptr,
nullptr, 0,
nullptr},
6283 pyrna_prop_array_foreach_get_doc},
6287 pyrna_prop_array_foreach_set_doc},
6289 {
nullptr,
nullptr, 0,
nullptr},
6296 pyrna_prop_collection_foreach_get_doc},
6300 pyrna_prop_collection_foreach_set_doc},
6306 pyrna_prop_collection_items_doc},
6310 pyrna_prop_collection_values_doc},
6314 {
nullptr,
nullptr, 0,
nullptr},
6321 pyrna_prop_collection_idprop_add_doc},
6325 pyrna_prop_collection_idprop_remove_doc},
6329 pyrna_prop_collection_idprop_clear_doc},
6333 pyrna_prop_collection_idprop_move_doc},
6334 {
nullptr,
nullptr, 0,
nullptr},
6339# pragma clang diagnostic pop
6341# pragma GCC diagnostic pop
6371 for (a = 0; a <
len; a++) {
6372 PyTuple_SET_ITEM(
ret, a, PyBool_FromLong(((
bool *)
data)[a]));
6377 for (a = 0; a <
len; a++) {
6378 PyTuple_SET_ITEM(
ret, a, PyLong_FromLong(((
int *)
data)[a]));
6392 else if (
len == 9) {
6400 for (a = 0; a <
len; a++) {
6401 PyTuple_SET_ITEM(
ret, a, PyFloat_FromDouble(((
float *)
data)[a]));
6408 PyExc_TypeError,
"RNA Error: unknown array type \"%d\" (pyrna_param_to_py)", type);
6417 ret = PyBool_FromLong(*(
bool *)
data);
6420 ret = PyLong_FromLong(*(
int *)
data);
6423 ret = PyFloat_FromDouble(*(
float *)
data);
6426 const char *data_ch;
6432 data_ch =
static_cast<const char *
>(data_alloc->
array);
6434 BLI_assert((data_ch ==
nullptr) || strlen(data_ch) == data_ch_len);
6438 data_ch_len = data_ch ? strlen(data_ch) : 0;
6441 if (
UNLIKELY(data_ch ==
nullptr)) {
6446#ifdef USE_STRING_COERCE
6448 ret = PyBytes_FromStringAndSize(data_ch, data_ch_len);
6454 ret = PyUnicode_FromStringAndSize(data_ch, data_ch_len);
6458 ret = PyBytes_FromString(buf);
6461 ret = PyUnicode_FromString(data_ch);
6500 if (newptr_p->
data) {
6511 ret = PyList_New(0);
6518 PyErr_Format(PyExc_TypeError,
"RNA Error: unknown type \"%d\" (pyrna_param_to_py)", type);
6535 const Py_ssize_t key_lookup_len = strlen(key_lookup);
6536 PyObject *key =
nullptr;
6538 PyObject *value =
nullptr;
6540 while (PyDict_Next(dict, &
pos, &key, &value)) {
6541 if (PyUnicode_Check(key)) {
6542 Py_ssize_t key_buf_len;
6543 const char *key_buf = PyUnicode_AsUTF8AndSize(key, &key_buf_len);
6544 if ((key_lookup_len == key_buf_len) && (memcmp(key_lookup, key_buf, key_lookup_len) == 0)) {
6558 const int parm_index,
6560 const size_t error_size)
6564 if (parm_index == -1) {
6567 "%.200s.%.200s(): error with keyword argument \"%.200s\" - ",
6575 "%.200s.%.200s(): error with argument %d, \"%.200s\" - ",
6592 PyObject *
ret, *item;
6593 int i, pyargs_len, pykw_len, parms_len, ret_len, flag_parameter, err = 0, kw_tot = 0;
6597 void *retdata_single =
nullptr;
6603#ifdef DEBUG_STRING_FREE
6604 PyObject *string_free_ls = PyList_New(0);
6610 if (self_ptr ==
nullptr) {
6611 PyErr_SetString(PyExc_RuntimeError,
6612 "RNA functions internal RNA pointer is nullptr, this is a bug. aborting");
6616 if (self_func ==
nullptr) {
6619 "%.200s.<unknown>(): RNA function internal function is nullptr, this is a bug. aborting",
6630 printf(
"pyrna_func_call > %.200s.%.200s : %.200s:%d\n",
6643 pyargs_len = PyTuple_GET_SIZE(args);
6644 pykw_len = kw ? PyDict_Size(kw) : 0;
6651 if (pyargs_len + pykw_len > parms_len) {
6653 PyErr_Format(PyExc_TypeError,
6654 "%.200s.%.200s(): takes at most %d arguments, got %d",
6658 pyargs_len + pykw_len);
6670 if (pret_single ==
nullptr) {
6672 retdata_single = iter.
data;
6680 if (
i < pyargs_len) {
6683 PyErr_Format(PyExc_TypeError,
6684 "%.200s.%.200s(): required parameter \"%.200s\" to be a keyword argument!",
6692 item = PyTuple_GET_ITEM(args,
i);
6695 else if (kw !=
nullptr) {
6708 if (item ==
nullptr) {
6710 PyErr_Format(PyExc_TypeError,
6711 "%.200s.%.200s(): required parameter \"%.200s\" not specified",
6722#ifdef DEBUG_STRING_FREE
6724 if (PyUnicode_Check(item)) {
6725 PyList_APPEND(string_free_ls, PyUnicode_FromString(PyUnicode_AsUTF8(item)));
6732 char error_prefix[512];
6756 if (err == 0 && kw && (pykw_len > kw_tot)) {
6757 PyObject *key, *value;
6763 const char *arg_name, *bad_args_str, *good_args_str;
6764 bool found =
false, first =
true;
6766 while (PyDict_Next(kw, &
pos, &key, &value)) {
6768 arg_name = PyUnicode_AsUTF8(key);
6771 if (arg_name ==
nullptr)
6788 if (found ==
false) {
6815 "%.200s.%.200s(): was called with invalid keyword argument(s) (%s), expected (%s)",
6844 ret = PyTuple_New(ret_len);
6864 if (
ret ==
nullptr) {
6871#ifdef DEBUG_STRING_FREE
6873 if (PyList_GET_SIZE(string_free_ls)) {
6874 printf(
"%.200s.%.200s(): has %d strings\n",
6877 int(PyList_GET_SIZE(string_free_ls)));
6880 Py_DECREF(string_free_ls);
6881# undef DEBUG_STRING_FREE
6905 ret = PyUnicode_FromFormat(
"%.200s.%.200s(%.200s)\n%s",
6915 PyVarObject_HEAD_INIT(
nullptr, 0)
6916 "bpy_struct_meta_idprop",
6919 sizeof(PyHeapTypeObject),
6936 Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
6947#if defined(_MSC_VER)
7002static PyObject *
pyrna_struct_new(PyTypeObject *type, PyObject *args, PyObject * );
7007 PyVarObject_HEAD_INIT(
nullptr, 0)
7026 Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE
7027#ifdef USE_PYRNA_STRUCT_REFERENCE
7028 | Py_TPFLAGS_HAVE_GC
7032#ifdef USE_PYRNA_STRUCT_REFERENCE
7033 (traverseproc)pyrna_struct_traverse,
7034 (inquiry)pyrna_struct_clear,
7073 if (PyTuple_GET_SIZE(args) != 1) {
7074 PyErr_Format(PyExc_TypeError,
"bpy_struct.__new__(struct): expected a single argument");
7078 PyObject *arg_1 = PyTuple_GET_ITEM(args, 0);
7081 if (!PyCapsule_CheckExact(arg_1)) {
7087 "bpy_struct.__new__(struct): struct type '%.200s' is not a subtype of bpy_struct",
7088 Py_TYPE(base)->tp_name);
7092 if (Py_TYPE(base) == type) {
7095 return reinterpret_cast<PyObject *
>(base);
7102 PyObject *
self = type->tp_alloc(type, 0);
7105#ifdef USE_PYRNA_STRUCT_REFERENCE
7108 PyObject_GC_UnTrack(
self);
7110 self_struct->
ptr = std::nullopt;
7120 size_t args_num = PyTuple_GET_SIZE(args);
7121 if (args_num != 1) {
7122 PyErr_Format(PyExc_TypeError,
"bpy_struct.__init__(self, struct): expected a single argument");
7126 PyObject *arg_1 = PyTuple_GET_ITEM(args, 0);
7128 if (PyCapsule_CheckExact(arg_1)) {
7139 PyErr_Format(PyExc_TypeError,
7140 "bpy_struct.__init__(self, struct): struct type '%.200s' is not a subtype of "
7142 Py_TYPE(base_struct)->tp_name);
7146 if (base_struct == self_struct) {
7152 ptr = &base_struct->
ptr.value();
7155 if (
ptr ==
nullptr) {
7156 PyErr_Format(PyExc_TypeError,
7157 "bpy_struct.__init__(self, struct): failed to get a valid PointerRNA data "
7158 "from the given `struct` argument");
7162 self_struct->
ptr.reset();
7176 PyObject *error_type, *error_value, *error_traceback;
7177 PyErr_Fetch(&error_type, &error_value, &error_traceback);
7181#ifdef PYRNA_FREE_SUPPORT
7182 if (self_struct->freeptr && self_struct->
ptr->data) {
7184 self_struct->
ptr->data =
nullptr;
7189 if (self_struct->in_weakreflist !=
nullptr) {
7190 PyObject_ClearWeakRefs(
self);
7194#ifdef USE_PYRNA_STRUCT_REFERENCE
7195 if (self_struct->reference) {
7196 PyObject_GC_UnTrack(
self);
7197 pyrna_struct_clear(self_struct);
7200 PyTypeObject *base = Py_TYPE(
self)->tp_base;
7202 if (base && PyType_IS_GC(base)) {
7203 PyObject_GC_UnTrack(
self);
7209 self_struct->
ptr.~optional();
7214 PyErr_Restore(error_type, error_value, error_traceback);
7246 PyVarObject_HEAD_INIT(
nullptr, 0)
7265 Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
7302 PyVarObject_HEAD_INIT(
nullptr, 0)
7321 Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
7358 PyVarObject_HEAD_INIT(
nullptr, 0)
7359 "bpy_prop_collection",
7377 Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
7415 PyVarObject_HEAD_INIT(
nullptr, 0)
7416 "bpy_prop_collection_idprop",
7434 Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
7472 if (PyTuple_GET_SIZE(args) != 1) {
7473 PyErr_Format(PyExc_TypeError,
"bpy_prop.__new__(property): expected a single argument");
7477 PyObject *arg_1 = PyTuple_GET_ITEM(args, 0);
7480 if (!PyCapsule_CheckExact(arg_1)) {
7486 "bpy_prop.__new__(property): property type '%.200s' is not a subtype of bpy_prop",
7487 Py_TYPE(base)->tp_name);
7491 if (Py_TYPE(base) == type) {
7494 return reinterpret_cast<PyObject *
>(base);
7501 PyObject *
self = type->tp_alloc(type, 0);
7504 self_property->
ptr = std::nullopt;
7514 size_t args_num = PyTuple_GET_SIZE(args);
7515 if (args_num != 1) {
7516 PyErr_Format(PyExc_TypeError,
"bpy_prop.__init__(self, property): expected a single argument");
7520 PyObject *arg_1 = PyTuple_GET_ITEM(args, 0);
7523 if (PyCapsule_CheckExact(arg_1)) {
7529 if (pypropptr_rna) {
7530 ptr = pypropptr_rna->
ptr;
7531 prop = pypropptr_rna->
prop;
7541 "bpy_prop.__init__(self, property): property type '%.200s' is not a subtype of bpy_prop",
7542 Py_TYPE(base_property)->tp_name);
7546 if (base_property == self_property) {
7550 ptr = &base_property->
ptr.value();
7551 prop = base_property->
prop;
7554 self_property->
ptr = *
ptr;
7555 self_property->
prop = prop;
7563 PyObject *error_type, *error_value, *error_traceback;
7564 PyErr_Fetch(&error_type, &error_value, &error_traceback);
7568 if (self_property->in_weakreflist !=
nullptr) {
7569 PyObject_ClearWeakRefs(
self);
7573 self_property->
ptr.~optional();
7578 PyErr_Restore(error_type, error_value, error_traceback);
7585 size_t args_num = PyTuple_GET_SIZE(args);
7586 if (args_num != 1) {
7587 PyErr_Format(PyExc_TypeError,
7588 "bpy_prop_array.__init__(self, property): expected a single argument");
7592 PyObject *arg_1 = PyTuple_GET_ITEM(args, 0);
7595 if (PyCapsule_CheckExact(arg_1)) {
7601 if (pypropptr_rna) {
7602 ptr = pypropptr_rna->
ptr;
7603 prop = pypropptr_rna->
prop;
7611 PyErr_Format(PyExc_TypeError,
7612 "bpy_prop_array.__init__(self, property): property type '%.200s' is not a "
7613 "subtype of bpy_prop_array",
7614 Py_TYPE(base_property)->tp_name);
7618 if (base_property == self_property) {
7622 ptr = &base_property->
ptr.value();
7623 prop = base_property->
prop;
7626 self_property->
prop = prop;
7629 self_property->
ptr = *
ptr;
7634#ifdef USE_PYRNA_ITER
7653 PyVarObject_HEAD_INIT(
nullptr, 0)
7654 "bpy_prop_collection_iter",
7669 PyObject_GenericGetAttr,
7712 if (PyTuple_GET_SIZE(args) != 1) {
7713 PyErr_Format(PyExc_TypeError,
7714 "bpy_prop_collection_iter.__new__(arg): expected a single argument");
7718 PyObject *arg_1 = PyTuple_GET_ITEM(args, 0);
7720 if (!PyCapsule_CheckExact(arg_1)) {
7721 PyErr_Format(PyExc_TypeError,
7722 "bpy_prop_collection_iter.__new__(arg): arg type '%.200s' is not a PyCapsule",
7723 Py_TYPE(arg_1)->tp_name);
7728 PyObject *
self = type->tp_alloc(type, 0);
7731 if (self_prop_iter) {
7732 self_prop_iter->
iter = std::nullopt;
7743 size_t args_num = PyTuple_GET_SIZE(args);
7744 if (args_num != 1) {
7747 "bpy_prop_collection_iter.__init__(self, arg): expected at most a single argument");
7751 PyObject *arg_1 = PyTuple_GET_ITEM(args, 0);
7754 if (PyCapsule_CheckExact(arg_1)) {
7760 if (pypropptr_rna) {
7761 ptr = pypropptr_rna->
ptr;
7762 prop = pypropptr_rna->
prop;
7768 "bpy_prop_collection_iter.__init__(self, arg): arg type '%.200s' is not a PyCapsule",
7769 Py_TYPE(arg_1)->tp_name);
7772 if (self_prop_iter->
iter.has_value()) {
7774 self_prop_iter->
iter.reset();
7786 PyObject *error_type, *error_value, *error_traceback;
7787 PyErr_Fetch(&error_type, &error_value, &error_traceback);
7792 if (self_property->in_weakreflist !=
nullptr) {
7793 PyObject_ClearWeakRefs(
self);
7797 if (self_property->
iter.has_value()) {
7799 self_property->
iter.reset();
7805 PyErr_Restore(error_type, error_value, error_traceback);
7813 PyObject *pypropptr_rna = PyCapsule_New(
7816 PyObject *
self = PyObject_CallOneArg(
7822 Py_DECREF(pypropptr_rna);
7825 self_property->in_weakreflist =
nullptr;
7837 self_property->
prop);
7844 if (self_property->
iter->valid ==
false) {
7845 PyErr_SetNone(PyExc_StopIteration);
7851# ifdef USE_PYRNA_STRUCT_REFERENCE
7854 if (iter_data != Py_None) {
7859 pyrna_struct_reference_set(iter_data_struct,
self);
7885 PyVarObject_HEAD_INIT(
nullptr, 0)
7942 if (PyTuple_GET_SIZE(args) != 1) {
7943 PyErr_Format(PyExc_TypeError,
"bpy_func.__new__(arg): expected a single argument");
7947 PyObject *arg_1 = PyTuple_GET_ITEM(args, 0);
7950 if (!PyCapsule_CheckExact(arg_1)) {
7951 PyErr_Format(PyExc_TypeError,
7952 "bpy_func.__new__(arg): arg type '%.200s' is not a PyCapsule",
7953 Py_TYPE(arg_1)->tp_name);
7958 PyObject *
self = type->tp_alloc(type, 0);
7960 if (self_function) {
7961 self_function->
ptr = std::nullopt;
7971 size_t args_num = PyTuple_GET_SIZE(args);
7972 if (args_num != 1) {
7973 PyErr_Format(PyExc_TypeError,
7974 "bpy_func.__init__(self, arg): expected at most a single argument");
7978 PyObject *arg_1 = PyTuple_GET_ITEM(args, 0);
7981 if (PyCapsule_CheckExact(arg_1)) {
7987 if (pyfuncptr_rna) {
7988 ptr = pyfuncptr_rna->
ptr;
7989 func = pyfuncptr_rna->
func;
7993 PyErr_Format(PyExc_TypeError,
7994 "bpy_func.__init__(self, arg): arg type '%.200s' is not a PyCapsule",
7995 Py_TYPE(arg_1)->tp_name);
7998 self_function->
func = func;
7999 self_function->
ptr = *
ptr;
8007 PyObject *error_type, *error_value, *error_traceback;
8008 PyErr_Fetch(&error_type, &error_value, &error_traceback);
8013 if (self_func->in_weakreflist !=
nullptr) {
8014 PyObject_ClearWeakRefs(
self);
8018 self_func->
ptr.~optional();
8023 PyErr_Restore(error_type, error_value, error_traceback);
8030 Py_INCREF(newclass);
8034 Py_DECREF(oldclass);
8065 const PointerRNA func_ptr = {
nullptr, srna,
nullptr};
8094 PyObject *py_base =
nullptr;
8099 if (base && base != srna) {
8105 if (py_base ==
nullptr) {
8127 PyObject *bpy_types = PyImport_ImportModuleLevel(
"bpy_types",
nullptr,
nullptr,
nullptr, 0);
8129 if (bpy_types ==
nullptr) {
8136 Py_DECREF(bpy_types);
8148 PyObject *tp_bases = ((PyTypeObject *)newclass)->tp_bases;
8149 PyObject *tp_slots = PyDict_GetItem(((PyTypeObject *)newclass)->tp_dict,
8152 if (tp_slots ==
nullptr) {
8154 BPY_LOG_RNA,
"expected class '%s' to have __slots__ defined, see bpy_types.py", idname);
8157 else if (PyTuple_GET_SIZE(tp_bases)) {
8158 PyObject *base = PyTuple_GET_ITEM(tp_bases, 0);
8160 if (base_compare != base) {
8161 char pyob_info[256];
8164 "incorrect subclassing of SRNA '%s', expected '%s', see bpy_types.py",
8185 PyObject *newclass =
nullptr;
8188 if (srna ==
nullptr) {
8193 Py_INCREF(newclass);
8198 Py_INCREF(newclass);
8213 PyObject *metaclass;
8220 descr =
"(no docs)";
8230 metaclass = (PyObject *)&PyType_Type;
8235 newclass = PyObject_CallFunction(
8236 metaclass,
"s(O) {sss()}", idname, py_base,
"__module__",
"bpy.types",
"__slots__");
8240 PyObject *args, *item, *value;
8243 args = PyTuple_New(3);
8246 PyTuple_SET_ITEM(args, 0, PyUnicode_FromString(idname));
8249 PyTuple_SET_ITEM(args, 1, item = PyTuple_New(1));
8250 PyTuple_SET_ITEM(item, 0, Py_NewRef(py_base));
8253 PyTuple_SET_ITEM(args, 2, item = PyDict_New());
8260 newclass = PyObject_CallObject(metaclass, args);
8292 if (
ptr->type == &RNA_Struct) {
8320 PyObject *pyptr_rna = PyCapsule_New(
8326 PyObject_CallOneArg(
reinterpret_cast<PyObject *
>(tp), pyptr_rna));
8332 PyObject_CallOneArg(
reinterpret_cast<PyObject *
>(&
pyrna_struct_Type), pyptr_rna));
8335#ifdef USE_PYRNA_STRUCT_REFERENCE
8338 if (pyrna !=
nullptr) {
8339 PyObject_GC_UnTrack(pyrna);
8344 if (pyrna !=
nullptr) {
8345 pyrna->in_weakreflist =
nullptr;
8349 if (pyrna ==
nullptr) {
8350 if (!PyErr_Occurred()) {
8351 PyErr_SetString(PyExc_MemoryError,
"couldn't create bpy_struct object");
8357 Py_DECREF(pyptr_rna);
8365#ifdef PYRNA_FREE_SUPPORT
8366 pyrna->freeptr =
false;
8369#ifdef USE_PYRNA_STRUCT_REFERENCE
8370 pyrna->reference =
nullptr;
8375#ifdef USE_PYRNA_INVALIDATE_WEAKREF
8376 if (
ptr->owner_id) {
8381 return reinterpret_cast<PyObject *
>(pyrna);
8388 if (
ptr->data ==
nullptr &&
ptr->type ==
nullptr) {
8397 if (instance && *instance) {
8401 if (
ptr->type == pyrna->
ptr->type) {
8403 return reinterpret_cast<PyObject *
>(pyrna);
8408 *instance =
nullptr;
8417 return reinterpret_cast<PyObject *
>(pyrna);
8422 if (
ptr->type == &RNA_PrimitiveString) {
8426 if (
ptr->type == &RNA_PrimitiveInt) {
8428 return PyLong_FromLong(
data->value);
8430 if (
ptr->type == &RNA_PrimitiveFloat) {
8432 return PyFloat_FromDouble(
data->value);
8434 if (
ptr->type == &RNA_PrimitiveBoolean) {
8436 return PyBool_FromLong(
data->value);
8462 PyObject *pypropptr_rna = PyCapsule_New(
8466 PyObject_CallOneArg(
reinterpret_cast<PyObject *
>(type), pypropptr_rna));
8468 if (pyrna ==
nullptr) {
8469 PyErr_SetString(PyExc_MemoryError,
"couldn't create BPy_rna object");
8474 Py_DECREF(pypropptr_rna);
8477 pyrna->in_weakreflist =
nullptr;
8480#ifdef USE_PYRNA_INVALIDATE_WEAKREF
8481 if (
ptr->owner_id) {
8486 return (PyObject *)pyrna;
8523#if defined(_MSC_VER)
8556#ifdef USE_PYRNA_ITER
8562#ifdef USE_PYRNA_INVALIDATE_WEAKREF
8570#ifdef USE_PYRNA_INVALIDATE_WEAKREF
8575 const int id_weakref_pool_len =
BLI_ghash_len(id_weakref_pool);
8576 if (id_weakref_pool_len != 0) {
8577 printf(
"Found %d unreleased ID's\n", id_weakref_pool_len);
8584 BLI_ghash_free(id_weakref_pool,
nullptr, id_weakref_pool_free_value_fn);
8585 id_weakref_pool =
nullptr;
8600 return (PyObject *)pyrna;
8617PyObject *BPY_rna_doc()
8639 std::optional<PointerRNA>
ptr;
8651 const char *name = PyUnicode_AsUTF8(pyname);
8653 if (name ==
nullptr) {
8654 PyErr_SetString(PyExc_AttributeError,
"bpy.types: __getattr__ must be a string");
8660 if (
ret ==
nullptr) {
8661 PyErr_Format(PyExc_RuntimeError,
8662 "bpy.types.%.200s subtype could not be generated, this is a bug!",
8663 PyUnicode_AsUTF8(pyname));
8668 PyErr_Format(PyExc_AttributeError,
8669 "bpy.types.%.200s RNA_Struct does not exist",
8670 PyUnicode_AsUTF8(pyname));
8674 ret = PyObject_GenericGetAttr(
self, pyname);
8685 PyObject *
ret = PyList_New(0);
8694 PyObject *submodule_dict = PyModule_GetDict(
self);
8695 PyObject *key, *value;
8697 while (PyDict_Next(submodule_dict, &
pos, &key, &value)) {
8698 PyList_Append(
ret, key);
8705# pragma clang diagnostic push
8706# pragma clang diagnostic ignored "-Wcast-function-type"
8708# pragma GCC diagnostic push
8709# pragma GCC diagnostic ignored "-Wcast-function-type"
8716 {
nullptr,
nullptr, 0,
nullptr},
8721# pragma clang diagnostic pop
8723# pragma GCC diagnostic pop
8733 PyObject *submodule =
static_cast<PyObject *
>(
self);
8735 PyModule_GetState(submodule));
8737 state->ptr.~optional();
8742 bpy_types_module_doc,
8743 "Access to internal Blender types");
8747 bpy_types_module_doc,
8760 PyModule_GetState(submodule));
8767 static PyTypeObject *pyrna_types[] = {
8777 PyObject *submodule_dict = PyModule_GetDict(submodule);
8779 PyDict_SetItemString(submodule_dict, pyrna_types[
i]->tp_name, (PyObject *)pyrna_types[
i]);
8799 PyModule_GetState(submodule));
8802 PyObject *arg_key, *arg_value;
8803 Py_ssize_t arg_pos = 0;
8804 while (PyDict_Next(
bpy_types_dict, &arg_pos, &arg_key, &arg_value)) {
8805 const char *key_str = PyUnicode_AsUTF8(arg_key);
8806 if (key_str[0] ==
'_') {
8812 "Members of bpy_types.py which are not StructRNA sub-classes must use a \"_\" prefix!");
8828 if (
STREQ(key_str,
"USDHook")) {
8833 BPY_LOG_RNA,
"bpy_types.py defines \"%.200s\" which is not a known RNA type!", key_str);
8853 if (PyType_Check(
self)) {
8856 Py_XINCREF(py_srna);
8862 if (py_srna ==
nullptr) {
8867 if (py_srna ==
nullptr) {
8868 PyErr_Format(PyExc_RuntimeError,
8869 "%.200s, missing bl_rna attribute from '%.200s' instance (may not be registered)",
8871 Py_TYPE(
self)->tp_name);
8876 PyErr_Format(PyExc_TypeError,
8877 "%.200s, bl_rna attribute wrong type '%.200s' on '%.200s'' instance",
8879 Py_TYPE(py_srna)->tp_name,
8880 Py_TYPE(
self)->tp_name);
8885 if (py_srna->
ptr->type != &RNA_Struct) {
8886 PyErr_Format(PyExc_TypeError,
8887 "%.200s, bl_rna attribute not a RNA_Struct, on '%.200s'' instance",
8889 Py_TYPE(
self)->tp_name);
8904 PyErr_Format(PyExc_TypeError,
8905 "Expected a \"bpy.types.%.200s\" not a \"%.200s\"",
8907 Py_TYPE(py_obj)->tp_name);
8911 return &bpy_srna->
ptr.value();
8916 if (py_obj == Py_None) {
8927 if (srna_parse->
ptr ==
nullptr) {
8938 if (srna_parse->
ptr ==
nullptr) {
8948 if (
self ==
nullptr) {
8951 if (PyCapsule_CheckExact(
self)) {
8952 return static_cast<StructRNA *
>(PyCapsule_GetPointer(
self,
nullptr));
8954 if (PyType_Check(
self) == 0) {
8978 PyObject *py_func =
static_cast<PyObject *
>(((
BPy_PropDeferred *)item)->fn);
8980 PyObject *py_srna_cobject, *py_ret;
8984 PyMethodDef *py_func_method_def = ((PyCFunctionObject *)py_func)->m_ml;
8985 const char *func_name = py_func_method_def->ml_name;
8987 PyObject *args_fake;
8988 const char *key_str = PyUnicode_AsUTF8(key);
8990 if (*key_str ==
'_') {
8991 PyErr_Format(PyExc_ValueError,
8992 "bpy_struct \"%.200s\" registration error: "
8993 "'%.200s' %.200s could not register because it starts with an '_'",
8999 py_srna_cobject = PyCapsule_New(srna,
nullptr,
nullptr);
9004 args_fake = PyTuple_New(1);
9005 PyTuple_SET_ITEM(args_fake, 0, py_srna_cobject);
9007 PyObject *type = PyDict_GetItemString(py_kw,
"type");
9011 PyCFunctionWithKeywords py_func_ref = *(
9012 PyCFunctionWithKeywords)(
void *)PyCFunction_GET_FUNCTION(py_func);
9016 PyErr_Format(PyExc_ValueError,
9017 "bpy_struct \"%.200s\" registration error: "
9018 "'%.200s' %.200s could not register because "
9019 "this type doesn't support data-block properties",
9029 py_ret = PyObject_Call(py_func, args_fake, py_kw);
9033 Py_DECREF(args_fake);
9040 Py_DECREF(args_fake);
9042 PyErr_Format(PyExc_ValueError,
9043 "bpy_struct \"%.200s\" registration error: "
9044 "'%.200s' %.200s could not register (see previous error)",
9059 PyObject *annotations_dict =
nullptr;
9063 PyObject *typing_mod = PyImport_ImportModuleLevel(
"typing",
nullptr,
nullptr,
nullptr, 0);
9064 if (typing_mod !=
nullptr) {
9065 PyObject *get_type_hints_fn = PyObject_GetAttrString(typing_mod,
"get_type_hints");
9066 if (get_type_hints_fn !=
nullptr) {
9067 PyObject *args = PyTuple_New(1);
9069 PyTuple_SET_ITEM(args, 0, (PyObject *)py_class);
9070 Py_INCREF(py_class);
9072 annotations_dict = PyObject_CallObject(get_type_hints_fn, args);
9075 Py_DECREF(get_type_hints_fn);
9077 Py_DECREF(typing_mod);
9082 if (annotations_dict !=
nullptr) {
9083 if (PyDict_CheckExact(annotations_dict)) {
9084 PyObject *item, *key;
9087 while (PyDict_Next(annotations_dict, &
pos, &key, &item)) {
9096 PyErr_Format(PyExc_TypeError,
9097 "typing.get_type_hints returned: %.200s, expected dict\n",
9098 Py_TYPE(annotations_dict)->tp_name);
9102 Py_DECREF(annotations_dict);
9106 fprintf(stderr,
"typing.get_type_hints failed with: %.200s\n", py_class->tp_name);
9115 PyObject *annotations_dict;
9116 PyObject *item, *key;
9123 PyDict_CheckExact(annotations_dict))
9125 while (PyDict_Next(annotations_dict, &
pos, &key, &item)) {
9139 const int len = PyTuple_GET_SIZE(py_class->tp_bases);
9143 for (
i = 0;
i <
len;
i++) {
9144 PyTypeObject *py_superclass = (PyTypeObject *)PyTuple_GET_ITEM(py_class->tp_bases,
i);
9155 if (py_superclass != &PyBaseObject_Type &&
9156 !PyObject_IsSubclass((PyObject *)py_superclass, (PyObject *)&
pyrna_struct_Type))
9179#ifdef USE_POSTPONED_ANNOTATIONS
9180 const bool use_postponed_annotations =
true;
9182 const bool use_postponed_annotations =
false;
9185 if (use_postponed_annotations) {
9197 int count = is_staticmethod ? 0 : 1;
9198 bool done_min_count =
false;
9208 done_min_count =
true;
9214 if (!done_min_count && min_count) {
9231 bool *have_function)
9236 PyObject *py_class = (PyObject *)py_data;
9239 int i, arg_count, func_arg_count, func_arg_min_count = 0;
9240 const char *py_class_name = ((PyTypeObject *)py_class)->tp_name;
9249 if (!PyObject_IsSubclass(py_class, base_class)) {
9250 PyErr_Format(PyExc_TypeError,
9251 "expected %.200s subclass of class \"%.200s\"",
9269 have_function[
i] = (item !=
nullptr);
9272 if (item ==
nullptr) {
9274 PyErr_Format(PyExc_AttributeError,
9275 "expected %.200s, %.200s class to have an \"%.200s\" attribute",
9293 PyObject *item_orig = item;
9295 if (is_staticmethod) {
9296 if (PyMethod_Check(item) == 0) {
9297 PyErr_Format(PyExc_TypeError,
9298 "expected %.200s, %.200s class \"%.200s\" "
9299 "attribute to be a static/class method, not a %.200s",
9303 Py_TYPE(item)->tp_name);
9304 Py_DECREF(item_orig);
9307 item = ((PyMethodObject *)item)->im_func;
9310 if (PyFunction_Check(item) == 0) {
9311 PyErr_Format(PyExc_TypeError,
9312 "expected %.200s, %.200s class \"%.200s\" "
9313 "attribute to be a function, not a %.200s",
9317 Py_TYPE(item)->tp_name);
9318 Py_DECREF(item_orig);
9325 if (func_arg_count >= 0) {
9326 arg_count = ((PyCodeObject *)PyFunction_GET_CODE(item))->co_argcount;
9331 if (is_staticmethod) {
9333 func_arg_min_count++;
9336 if (arg_count < func_arg_min_count || arg_count > func_arg_count) {
9337 if (func_arg_min_count != func_arg_count) {
9340 "expected %.200s, %.200s class \"%.200s\" function to have between %d and %d "
9352 "expected %.200s, %.200s class \"%.200s\" function to have %d args, found %d",
9359 Py_DECREF(item_orig);
9363 Py_DECREF(item_orig);
9369 const char *identifier;
9379 item = PyObject_GetAttrString(py_class, identifier);
9381 if (item ==
nullptr) {
9385#define BPY_REPLACEMENT_STRING(rna_attr, py_attr) \
9386 else if (STREQ(identifier, rna_attr)) { \
9387 if ((item = PyObject_GetAttr(py_class, py_attr))) { \
9388 if (item != Py_None) { \
9389 if (pyrna_py_to_prop(dummy_ptr, prop, nullptr, item, "validating class:") != 0) { \
9406#undef BPY_REPLACEMENT_STRING
9409 PyErr_Format(PyExc_AttributeError,
9410 "expected %.200s, %.200s class to have an \"%.200s\" attribute",
9420 if (
pyrna_py_to_prop(dummy_ptr, prop,
nullptr, item,
"validating class:") != 0) {
9440 PyObject *
ret =
nullptr, *py_srna =
nullptr, *py_class_instance =
nullptr, *parmitem;
9441 PyTypeObject *py_class;
9445 int err = 0,
i, ret_len = 0;
9451 void *retdata_single =
nullptr;
9453 PyGILState_STATE gilstate;
9455#ifdef USE_PEDANTIC_WRITE
9465 if (py_class ==
nullptr) {
9467 "unable to get Python class for RNA struct '%.200s'",
9484 if (!(is_staticmethod || is_classmethod)) {
9491 py_class_instance =
static_cast<PyObject *
>(*instance);
9492 Py_INCREF(py_class_instance);
9498 if (py_class_instance ==
nullptr) {
9502 if (py_class_instance) {
9505 else if (py_srna ==
nullptr) {
9506 py_class_instance =
nullptr;
9507 if (PyErr_Occurred()) {
9511 else if (py_srna == Py_None) {
9513 py_class_instance =
nullptr;
9514 if (PyErr_Occurred()) {
9525 if (py_class->tp_init) {
9526# ifdef USE_PEDANTIC_WRITE
9533 args = PyTuple_New(0);
9534 if (py_class->tp_init(py_srna, args,
nullptr) < 0) {
9540# ifdef USE_PEDANTIC_WRITE
9544 py_class_instance = py_srna;
9547# ifdef USE_PEDANTIC_WRITE
9556 py_class_instance = py_srna;
9557 Py_INCREF(py_class_instance);
9564 py_class_instance = PyObject_CallOneArg(
reinterpret_cast<PyObject *
>(py_class), py_srna);
9566# ifdef USE_PEDANTIC_WRITE
9572 if (py_class_instance ==
nullptr) {
9573 if (PyErr_Occurred()) {
9583 if (err != -1 && (is_staticmethod || is_classmethod || py_class_instance)) {
9586 const bool item_type_valid = (item !=
nullptr) &&
9587 (is_staticmethod ? PyMethod_Check(item) : PyFunction_Check(item));
9588 if (item_type_valid) {
9595 if (is_staticmethod) {
9597 ((PyCodeObject *)PyFunction_GET_CODE(((PyMethodObject *)item)->im_func))->co_argcount -
9601 arg_count = ((PyCodeObject *)PyFunction_GET_CODE(item))->co_argcount;
9603 args = PyTuple_New(arg_count);
9605 if (is_staticmethod) {
9608 else if (is_classmethod) {
9609 PyTuple_SET_ITEM(args, 0, (PyObject *)py_class);
9613 PyTuple_SET_ITEM(args, 0, py_class_instance);
9626 if (pret_single ==
nullptr) {
9628 retdata_single = iter.
data;
9634 if (
i < arg_count) {
9636 PyTuple_SET_ITEM(args,
i, parmitem);
9641#ifdef USE_PEDANTIC_WRITE
9648 ret = PyObject_Call(item, args,
nullptr);
9652#ifdef USE_PEDANTIC_WRITE
9663 PyErr_Format(PyExc_TypeError,
9664 "could not find function %.200s in %.200s to execute callback",
9673 PyErr_Format(PyExc_RuntimeError,
9674 "could not create instance of %.200s to call callback function '%.200s'",
9681 if (
ret ==
nullptr) {
9685 if (ret_len == 0 &&
ret != Py_None) {
9686 PyErr_Format(PyExc_RuntimeError,
9687 "expected class %.200s, function %.200s to return None, not %.200s",
9690 Py_TYPE(
ret)->tp_name);
9693 else if (ret_len == 1) {
9702 "class %.200s, function %.200s: incompatible return value ",
9707 else if (ret_len > 1) {
9709 if (PyTuple_Check(
ret) == 0) {
9712 "expected class %.200s, function %.200s to return a tuple of size %d, not %.200s",
9716 Py_TYPE(
ret)->tp_name);
9719 else if (PyTuple_GET_SIZE(
ret) != ret_len) {
9720 PyErr_Format(PyExc_RuntimeError,
9721 "class %.200s, function %.200s to returned %d items, expected %d",
9724 PyTuple_GET_SIZE(
ret),
9739 &funcptr, parm, iter.
data, PyTuple_GET_ITEM(
ret,
i++),
"calling class function:");
9755 if ((!is_staticmethod) && (!is_classmethod) && (
ptr->data) &&
9786#ifdef WITH_PYTHON_MODULE
9796 if (!Py_IsInitialized()) {
9801 PyGILState_STATE gilstate = PyGILState_Ensure();
9816 if (
self->ob_refcnt > 1) {
9826 PyGILState_Release(gilstate);
9834 bool decref =
false;
9843 if (PyObject *bases = cls->tp_bases) {
9844 const int bases_num = PyTuple_GET_SIZE(bases);
9845 for (
int i = 0;
i < bases_num;
i++) {
9846 PyTypeObject *base_cls = (PyTypeObject *)PyTuple_GET_ITEM(bases,
i);
9848 if (base_cls->tp_dict) {
9861 return base_cls_test;
9873 PyObject *subclasses =
static_cast<PyObject *
>(cls->tp_subclasses);
9876 PyObject *key =
nullptr;
9878 PyObject *value =
nullptr;
9879 while (PyDict_Next(subclasses, &
pos, &key, &value)) {
9881 PyObject *value_ref = PyWeakref_GET_OBJECT(value);
9882 if (value_ref == Py_None) {
9886 PyTypeObject *sub_cls =
reinterpret_cast<PyTypeObject *
>(value_ref);
9887 if (sub_cls->tp_dict) {
9900 return sub_cls_test;
9914 PyGILState_STATE gilstate = PyGILState_Ensure();
9924 if (item ==
nullptr) {
9925 if (PyErr_Occurred()) {
9936 PyGILState_Release(gilstate);
9956#define BPY_TYPEDEF_REGISTERABLE_DOC \
9958 ":class:`bpy.types.Panel` | " \
9959 ":class:`bpy.types.UIList` | " \
9960 ":class:`bpy.types.Menu` | " \
9961 ":class:`bpy.types.Header` | " \
9962 ":class:`bpy.types.Operator` | " \
9963 ":class:`bpy.types.KeyingSetInfo` | " \
9964 ":class:`bpy.types.RenderEngine` | " \
9965 ":class:`bpy.types.AssetShelf` | " \
9966 ":class:`bpy.types.FileHandler` | " \
9967 ":class:`bpy.types.PropertyGroup` | " \
9968 ":class:`bpy.types.AddonPreferences` | " \
9969 ":class:`bpy.types.NodeTree` | " \
9970 ":class:`bpy.types.Node` | " \
9971 ":class:`bpy.types.NodeSocket`" \
9987 pyrna_register_class_doc,
9988 ".. function:: register_class(cls)\n"
9990 " Register a subclass of a Blender type class.\n"
9992 " :arg cls: Registerable Blender class type.\n"
9996 " :raises ValueError:\n"
9997 " if the class is not a subclass of a registerable blender class.\n"
10001 " If the class has a *register* class method it will be called\n"
10002 " before registration.\n");
10012 const char *identifier;
10013 PyObject *py_cls_meth;
10014 const char *error_prefix =
"register_class(...):";
10016 if (!PyType_Check(py_class)) {
10017 PyErr_Format(PyExc_ValueError,
10018 "%s expected a class argument, not '%.200s'",
10020 Py_TYPE(py_class)->tp_name);
10025 PyErr_Format(PyExc_ValueError,
10026 "%s already registered as a subclass '%.200s'",
10028 ((PyTypeObject *)py_class)->tp_name);
10041 (PyTypeObject *)py_class))
10044 "%s warning, %.200s: references and already registered base-class %.200s\n",
10046 ((PyTypeObject *)py_class)->tp_name,
10047 base_cls_test->tp_name);
10050 (PyTypeObject *)py_class))
10053 "%s warning, %.200s: references and already registered sub-class %.200s\n",
10055 ((PyTypeObject *)py_class)->tp_name,
10056 sub_cls_test->tp_name);
10061 PyErr_Format(PyExc_RuntimeError,
10062 "%s can't run in readonly state '%.200s'",
10064 ((PyTypeObject *)py_class)->tp_name);
10070 if (srna ==
nullptr) {
10077 PyErr_Format(PyExc_ValueError,
10078 "%s %.200s's parent class %.200s is already registered, this is not allowed",
10080 ((PyTypeObject *)py_class)->tp_name,
10090 PyErr_Format(PyExc_ValueError,
10091 "%s expected a subclass of a registerable "
10092 "RNA type (%.200s does not support registration)",
10104 identifier = ((PyTypeObject *)py_class)->tp_name;
10129 if (srna_new ==
nullptr) {
10139 Py_DECREF(old_py_class);
10154 PyObject *
ret = PyObject_CallObject(py_cls_meth,
nullptr);
10155 Py_DECREF(py_cls_meth);
10174 const char **r_prop_identifier)
10204 pyrna_unregister_class_doc,
10205 ".. function:: unregister_class(cls)\n"
10207 " Unload the Python class from blender.\n"
10209 " :arg cls: Blender type class, \n"
10210 " see :mod:`bpy.utils.register_class` for classes which can \n"
10211 " be registered.\n"
10217 " If the class has an *unregister* class method it will be called\n"
10218 " before unregistering.\n");
10220 "unregister_class",
10223 pyrna_unregister_class_doc,
10230 PyObject *py_cls_meth;
10231 const char *error_prefix =
"unregister_class(...):";
10233 if (!PyType_Check(py_class)) {
10234 PyErr_Format(PyExc_ValueError,
10235 "%s expected a class argument, not '%.200s'",
10237 Py_TYPE(py_class)->tp_name);
10243 PyErr_Format(PyExc_ValueError,
"%s not a registered as a subclass", error_prefix);
10249 PyErr_Format(PyExc_RuntimeError,
10250 "%s can't run in readonly state '%.200s'",
10252 ((PyTypeObject *)py_class)->tp_name);
10257 if (srna ==
nullptr) {
10262 PyErr_Format(PyExc_RuntimeError,
10263 "%s can't unregister a built-in class '%.200s'",
10265 ((PyTypeObject *)py_class)->tp_name);
10273 PyErr_Format(PyExc_ValueError,
10274 "%s expected type '%.200s' subclassed from a registerable RNA type "
10275 "(unregister not supported)",
10277 ((PyTypeObject *)py_class)->tp_name);
10285 PyObject *
ret = PyObject_CallObject(py_cls_meth,
nullptr);
10286 Py_DECREF(py_cls_meth);
10305 const char *prop_identifier =
nullptr;
10312 srna_iter =
static_cast<StructRNA *
>(itemptr.data);
10319 if (prop_identifier) {
10320 PyErr_Format(PyExc_RuntimeError,
10321 "%s can't unregister %s because %s.%s pointer property is using this",
10356 PyObject *dict = type->tp_dict;
10357 if (method !=
nullptr) {
10358 for (; method->ml_name !=
nullptr; method++) {
10359 PyObject *py_method;
10361 if (method->ml_flags & METH_CLASS) {
10362 PyObject *cfunc = PyCFunction_New(method, (PyObject *)type);
10363 py_method = PyClassMethod_New(cfunc);
10366 else if (method->ml_flags & METH_STATIC) {
10367 py_method = PyCFunction_New(method,
nullptr);
10370 py_method = PyDescr_NewMethod(type, method);
10373 const int err = PyDict_SetItemString(dict, method->ml_name, py_method);
10374 Py_DECREF(py_method);
10380 if (getset !=
nullptr) {
10381 for (; getset->name !=
nullptr; getset++) {
10382 PyObject *descr = PyDescr_NewGetSet(type, getset);
10384 BLI_assert(PyDict_GetItem(dict, PyDescr_NAME(descr)) ==
nullptr);
10385 PyDict_SetItem(dict, PyDescr_NAME(descr), descr);
10404 return PyUnicode_FromString(name);
10412 if (value == Py_None) {
10415 else if (PyUnicode_Check(value)) {
10416 name = PyUnicode_AsUTF8(value);
10419 PyErr_Format(PyExc_ValueError,
10421 "expected None or a string, not '%.200s'",
10422 Py_TYPE(value)->tp_name);
10431# pragma clang diagnostic push
10432# pragma clang diagnostic ignored "-Wcast-function-type"
10434# pragma GCC diagnostic push
10435# pragma GCC diagnostic ignored "-Wcast-function-type"
10440 "_bl_owner_id_get",
10446 "_bl_owner_id_set",
10454# pragma clang diagnostic pop
10456# 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, short *r_type)
ListBase CTX_data_dir_get(const bContext *C)
@ CTX_RESULT_MEMBER_NOT_FOUND
Main * CTX_data_main(const bContext *C)
@ CTX_DATA_TYPE_COLLECTION
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)
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
#define SNPRINTF(dst, format,...)
char * STRNCPY(char(&dst)[N], const char *src)
size_t BLI_snprintf(char *__restrict dst, size_t dst_maxncpy, const char *__restrict format,...) ATTR_NONNULL(1
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
char * BLI_strncpy_utf8(char *__restrict dst, const char *__restrict src, size_t dst_maxncpy) ATTR_NONNULL(1
#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_INFO(clg_ref, level,...)
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
bool(*)(Main *bmain, StructRNA *type) StructUnregisterFunc
StructRNA *(*)(Main *bmain, ReportList *reports, void *data, const char *identifier, StructValidateFunc validate, StructCallbackFunc call, StructFreeFunc free) StructRegisterFunc
@ 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)
#define BPY_REPLACEMENT_STRING(rna_attr, py_attr)
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)
static int pyrna_function_init(PyObject *self, PyObject *args, PyObject *)
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)
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 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 *)
static PyObject * small_dict_get_item_string(PyObject *dict, const char *key_lookup)
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 * pyrna_func_call(BPy_FunctionRNA *self, PyObject *args, PyObject *kw)
static PyObject * prop_subscript_ass_array_slice__as_seq_fast(PyObject *value, int length)
static void bpy_class_free(void *pyob_ptr)
static const char * BPy_FunctionPointerRNA_capsule_identifier
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)
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_function_dealloc(PyObject *self)
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)
static PyObject * pyrna_func_to_py(const PointerRNA *ptr, FunctionRNA *func)
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
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 PyObject * pyrna_function_new(PyTypeObject *type, PyObject *args, PyObject *)
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)
#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 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 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_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)
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)
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)
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)
bool RNA_struct_idprops_register_check(const StructRNA *type)
void RNA_property_string_set_bytes(PointerRNA *ptr, PropertyRNA *prop, const char *value, int len)
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)
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)
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_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
PyObject_HEAD std::optional< PointerRNA > ptr
PyObject_VAR_HEAD IDProperty * property
PyObject_VAR_HEAD struct ID * owner_id
struct IDProperty * parent
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