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
371 ID *
id =
ptr->owner_id;
373 const short idcode =
GS(id->
name);
378 if (key && PyUnicode_Check(key)) {
379 pyname = PyUnicode_AsUTF8(key);
382 pyname =
"<UNKNOWN>";
387 PyErr_Format(PyExc_AttributeError,
388 "Writing to ID classes in this context is not allowed: "
389 "%.200s, %.200s datablock, error setting %.200s.%.200s",
402#ifdef USE_PEDANTIC_WRITE
450 const short order_fallback,
457# define MATHUTILS_CB_SUBTYPE_EUL 0
458# define MATHUTILS_CB_SUBTYPE_VEC 1
459# define MATHUTILS_CB_SUBTYPE_QUAT 2
460# define MATHUTILS_CB_SUBTYPE_COLOR 3
468 return self->prop ? 0 : -1;
477 if (
self->prop ==
nullptr) {
500 if (
self->prop ==
nullptr) {
504# ifdef USE_PEDANTIC_WRITE
511 PyErr_Format(PyExc_AttributeError,
512 "bpy_prop \"%.200s.%.200s\" is read-only",
522 for (
i = 0;
i <
len;
i++) {
537 &
self->ptr.value(), eul->
order, &prop_eul_order);
538 if (order != eul->
order) {
554 if (
self->prop ==
nullptr) {
568 if (
self->prop ==
nullptr) {
572# ifdef USE_PEDANTIC_WRITE
579 PyErr_Format(PyExc_AttributeError,
580 "bpy_prop \"%.200s.%.200s\" is read-only",
613 if (
self->prop ==
nullptr) {
627 if (
self->prop ==
nullptr) {
631# ifdef USE_PEDANTIC_WRITE
638 PyErr_Format(PyExc_AttributeError,
639 "bpy_prop \"%.200s.%.200s\" is read-only",
663 const short order_fallback,
667 if (*r_prop_eul_order ==
nullptr) {
671 if (*r_prop_eul_order) {
679 return order_fallback;
688#define PROP_ALL_VECTOR_SUBTYPES \
690 case PROP_TRANSLATION: \
691 case PROP_DIRECTION: \
692 case PROP_VELOCITY: \
693 case PROP_ACCELERATION: \
699 PyObject *
ret =
nullptr;
720 goto thick_wrap_slice;
733 if (totdim == 1 || (totdim == 2 && subtype ==
PROP_MATRIX)) {
741 if (
len >= 2 &&
len <= 4) {
835 if (
ret ==
nullptr) {
866 return (((a->
ptr->data ==
b->ptr->data) && (a->
ptr->type ==
b->ptr->type)) ? 0 : -1);
872 ((a->
prop ==
b->prop) && (a->
ptr->data ==
b->ptr->data) && (a->
ptr->type ==
b->ptr->type)) ?
891 res = ok ? Py_False : Py_True;
898 res = Py_NotImplemented;
905 return Py_NewRef(res);
922 res = ok ? Py_False : Py_True;
929 res = Py_NotImplemented;
936 return Py_NewRef(res);
944 const char *extra_info =
"";
947 return PyUnicode_FromFormat(
"<bpy_struct, %.200s invalid>", Py_TYPE(
self)->tp_name);
950 ID *
id =
self->ptr->owner_id;
952 extra_info =
", evaluated";
961 ret = PyUnicode_FromFormat(
"<bpy_struct, %.200s(\"%.200s\") at %p%s>",
970 return PyUnicode_FromFormat(
"<bpy_struct, %.200s at %p%s>",
978 ID *
id =
self->ptr->owner_id;
987 tmp_str = PyUnicode_FromString(id->
name + 2);
990 ret = PyUnicode_FromFormat(
994 ID *real_id =
nullptr;
1003 if (real_id !=
nullptr) {
1005 tmp_str = PyUnicode_FromString(real_id->
name + 2);
1006 ret = PyUnicode_FromFormat(
"bpy.data.%s[%R].%s",
1013 ret = PyUnicode_FromFormat(
"bpy.data.%s[%R]...%s",
1021 ret = PyUnicode_FromFormat(
"bpy.data.%s[%R]...%s",
1038 const char *type_id =
nullptr;
1039 char type_lower[64];
1040 char type_count[16];
1049 PyErr_SetString(PyExc_RuntimeError,
"could not use property type, internal error");
1068 type_count[0] =
'\0';
1077 ret = PyUnicode_FromFormat(
"<bpy_%.200s%.200s, %.200s.%.200s(\"%.200s\")>",
1090 return PyUnicode_FromFormat(
1095 return PyUnicode_FromFormat(
"<bpy_%.200s%.200s, %.200s.%.200s>",
1104 ID *
id =
self->ptr->owner_id;
1110 if (
id ==
nullptr) {
1115 tmp_str = PyUnicode_FromString(id->
name + 2);
1119 ID *real_id =
nullptr;
1121 G_MAIN, &
self->ptr.value(),
self->prop, index_dim, index, &real_id);
1124 if (real_id !=
id) {
1126 tmp_str = PyUnicode_FromString(real_id->
name + 2);
1128 const char *data_delim = ((*path)[0] ==
'[') ?
"" :
".";
1129 ret = PyUnicode_FromFormat(
"bpy.data.%s[%R]%s%s",
1137 ret = PyUnicode_FromFormat(
"bpy.data.%s[%R]...%s",
1160 return PyUnicode_FromFormat(
"<%.200s %.200s.%.200s()>",
1161 Py_TYPE(
self)->tp_name,
1175 if (
self->ptr->data ==
nullptr) {
1195#ifdef USE_PYRNA_STRUCT_REFERENCE
1196static int pyrna_struct_traverse(
BPy_StructRNA *
self, visitproc visit,
void *arg)
1198 Py_VISIT(
self->reference);
1204 Py_CLEAR(
self->reference);
1209#ifdef USE_PYRNA_STRUCT_REFERENCE
1212 if (
self->reference) {
1213 PyObject_GC_UnTrack(
self);
1214 Py_CLEAR(
self->reference);
1219 self->reference = reference;
1220 Py_INCREF(reference);
1222 PyObject_GC_Track(
self);
1251 const char *param = PyUnicode_AsUTF8(item);
1253 if (param ==
nullptr) {
1254 PyErr_Format(PyExc_TypeError,
1255 "%.200s expected a string enum, not %.200s",
1257 Py_TYPE(item)->tp_name);
1263 PyErr_Format(PyExc_TypeError,
1264 "%.200s enum \"%.200s\" not found in (%s)",
1284 if (!PyAnySet_Check(value)) {
1285 PyErr_Format(PyExc_TypeError,
1286 "%.200s, %.200s.%.200s expected a set, not a %.200s",
1290 Py_TYPE(value)->tp_name);
1300 if (PySet_GET_SIZE(value)) {
1301 PyErr_Format(PyExc_TypeError,
1302 "%.200s: empty enum \"%.200s\" could not have any values assigned",
1321 PyObject *item, *
ret =
nullptr;
1326 ret = PySet_New(
nullptr);
1331 for (index = 0; identifier[index]; index++) {
1332 item = PyUnicode_FromString(identifier[index]);
1333 PySet_Add(
ret, item);
1339 const char *identifier;
1341 ret = PyUnicode_FromString(identifier);
1357 "current value '%d' "
1358 "matches no enum in '%s', '%s', '%s'",
1365 char error_str[256];
1368 "RNA Warning: Current value \"%d\" "
1369 "matches no enum in '%s', '%s', '%s'",
1375 PyErr_Warn(PyExc_RuntimeWarning, error_str);
1383 ret = PyUnicode_FromString(
"");
1385 PyErr_Format(PyExc_AttributeError,
"RNA Error: Current value \"%d\" matches no enum", val);
1421#ifdef USE_STRING_COERCE
1424 ret = PyBytes_FromStringAndSize(buf, buf_len);
1430 ret = PyUnicode_FromStringAndSize(buf, buf_len);
1434 ret = PyBytes_FromStringAndSize(buf, buf_len);
1437 ret = PyUnicode_FromStringAndSize(buf, buf_len);
1440 if (buf_fixed != buf) {
1465 PyErr_Format(PyExc_TypeError,
1466 "bpy_struct internal error: unknown type '%d' (pyrna_prop_to_py)",
1477 const bool all_args,
1478 const char *error_prefix)
1482 const char *arg_name =
nullptr;
1485 totkw = kw ? PyDict_Size(kw) : 0;
1490 if (
STREQ(arg_name,
"rna_type")) {
1494 if (kw ==
nullptr) {
1496 PyExc_TypeError,
"%.200s: no keywords, expected \"%.200s\"", error_prefix, arg_name);
1501 item = PyDict_GetItemString(kw, arg_name);
1503 if (item ==
nullptr) {
1505 PyErr_Format(PyExc_TypeError,
1506 "%.200s: keyword \"%.200s\" missing",
1508 arg_name ? arg_name :
"<UNKNOWN>");
1523 if (error_val == 0 && totkw > 0) {
1524 PyObject *key, *value;
1527 while (PyDict_Next(kw, &
pos, &key, &value)) {
1528 arg_name = PyUnicode_AsUTF8(key);
1535 PyErr_Format(PyExc_TypeError,
1536 "%.200s: keyword \"%.200s\" unrecognized",
1538 arg_name ? arg_name :
"<UNKNOWN>");
1548 PyObject *pyfuncrna_ptr = PyCapsule_New(
1551 PyObject_CallOneArg(
reinterpret_cast<PyObject *
>(&
pyrna_func_Type), pyfuncrna_ptr));
1554 PyErr_SetString(PyExc_MemoryError,
"couldn't create bpy_func object");
1559 Py_DECREF(pyfuncrna_ptr);
1561 return reinterpret_cast<PyObject *
>(pyfunc);
1587 param = PyObject_IsTrue(value);
1590 param = PyC_Long_AsI32(value);
1598 PyErr_Format(PyExc_TypeError,
1599 "%.200s %.200s.%.200s expected True/False or 0/1, not %.200s",
1603 Py_TYPE(value)->tp_name);
1608 *((
bool *)
data) = param;
1618 const long param = PyLong_AsLongAndOverflow(value, &overflow);
1619 if (overflow || (param > INT_MAX) || (param < INT_MIN)) {
1620 PyErr_Format(PyExc_ValueError,
1621 "%.200s %.200s.%.200s value not in 'int' range "
1628 if (param == -1 && PyErr_Occurred()) {
1629 PyErr_Format(PyExc_TypeError,
1630 "%.200s %.200s.%.200s expected an int type, not %.200s",
1634 Py_TYPE(value)->tp_name);
1638 int param_i = int(param);
1641 *((
int *)
data) = param_i;
1650 const float param = PyFloat_AsDouble(value);
1651 if (PyErr_Occurred()) {
1652 PyErr_Format(PyExc_TypeError,
1653 "%.200s %.200s.%.200s expected a float type, not %.200s",
1657 Py_TYPE(value)->tp_name);
1663 *((
float *)
data) = param;
1676 if (value == Py_None) {
1683 *((
char **)
data) = (
char *)
nullptr;
1691 PyErr_Format(PyExc_TypeError,
1692 "%.200s %.200s.%.200s doesn't support None from string types",
1703 param = PyBytes_AsString(value);
1705 if (param ==
nullptr) {
1706 if (PyBytes_Check(value)) {
1711 "%.200s %.200s.%.200s error assigning bytes",
1717 PyErr_Format(PyExc_TypeError,
1718 "%.200s %.200s.%.200s expected a bytes type, not %.200s",
1722 Py_TYPE(value)->tp_name);
1733 *((
char **)
data) = (
char *)param;
1742#ifdef USE_STRING_COERCE
1743 PyObject *value_coerce =
nullptr;
1749 param = PyUnicode_AsUTF8(value);
1752 param = PyUnicode_AsUTF8(value);
1755 if (param ==
nullptr) {
1756 if (PyUnicode_Check(value)) {
1761 "%.200s %.200s.%.200s error assigning string",
1767 PyErr_Format(PyExc_TypeError,
1768 "%.200s %.200s.%.200s expected a string type, not %.200s",
1772 Py_TYPE(value)->tp_name);
1781 char warning_buf[256];
1783 "%.200s.%.200s: does not support blend relative \"//\" prefix",
1786 PyErr_WarnEx(PyExc_RuntimeWarning, warning_buf, 1);
1799 *((
char **)
data) = (
char *)param;
1806#ifdef USE_STRING_COERCE
1807 Py_XDECREF(value_coerce);
1830 *((
int *)
data) = val;
1839 PyObject *value_new =
nullptr;
1861 if (
ELEM(base_type, &RNA_Operator, &RNA_Gizmo)) {
1869 if (PyDict_Check(value)) {
1871 if (
ELEM(base_type, &RNA_OperatorProperties, &RNA_GizmoProperties)) {
1883 if (
ptr->type != &RNA_Function) {
1884 PyErr_Format(PyExc_TypeError,
1885 "%.200s %.200s.%.200s internal error coercing a dict for %.200s type",
1905 PyErr_Format(PyExc_TypeError,
1906 "%.200s %.200s.%.200s collection has no type, "
1907 "can't be used as a %.200s type",
1917 if (value == Py_None) {
1919 PyErr_Format(PyExc_TypeError,
1920 "%.200s %.200s.%.200s does not support a 'None' assignment %.200s type",
1925 Py_XDECREF(value_new);
1932 PyErr_Format(PyExc_TypeError,
1933 "%.200s %.200s.%.200s expected a %.200s type, not %.200s",
1938 Py_TYPE(value)->tp_name);
1939 Py_XDECREF(value_new);
1945 if (value_owner_id !=
nullptr) {
1947 PyErr_Format(PyExc_TypeError,
1948 "%.200s %.200s.%.200s ID type does not support assignment to itself",
1952 Py_XDECREF(value_new);
1958 if (
ptr->type != &RNA_Function) {
1959 PyErr_Format(PyExc_TypeError,
1960 "%.200s %.200s.%.200s ID type assignment is temporary, can't assign",
1964 Py_XDECREF(value_new);
1971 bool raise_error =
false;
1976 if (param ==
nullptr) {
1991 if (param ==
nullptr) {
1992 *((
void **)
data) =
nullptr;
2002 else if (param ==
nullptr) {
2003 *((
void **)
data) =
nullptr;
2006 *((
void **)
data) = param->
ptr->data;
2021 Py_XDECREF(value_new);
2036 PyErr_Format(PyExc_TypeError,
2037 "%.200s %.200s.%.200s expected a %.200s type, not %.200s",
2044 Py_XDECREF(value_new);
2048 Py_XDECREF(value_new);
2053 Py_ssize_t seq_len,
i;
2061 if (!PySequence_Check(value)) {
2064 "%.200s %.200s.%.200s expected a sequence for an RNA collection, not %.200s",
2068 Py_TYPE(value)->tp_name);
2072 seq_len = PySequence_Size(value);
2073 for (
i = 0;
i < seq_len;
i++) {
2074 item = PySequence_GetItem(value,
i);
2076 if (item ==
nullptr) {
2079 "%.200s %.200s.%.200s failed to get sequence index '%d' for an RNA collection",
2088 if (PyDict_Check(item) == 0) {
2089 PyErr_Format(PyExc_TypeError,
2090 "%.200s %.200s.%.200s expected a each sequence "
2091 "member to be a dict for an RNA collection, not %.200s",
2095 Py_TYPE(item)->tp_name);
2108 &itemptr, item,
true,
"Converting a Python list to an RNA collection") == -1)
2111 const char *msg_char = PyUnicode_AsUTF8(msg);
2114 PyErr_Format(PyExc_TypeError,
2115 "%.200s %.200s.%.200s error converting a member of a collection "
2116 "from a dicts into an RNA collection, failed with: %s",
2132 PyErr_Format(PyExc_AttributeError,
2133 "%.200s %.200s.%.200s unknown property type (pyrna_py_to_prop)",
2166 &
self->ptr.value(),
self->prop,
self->arraydim,
self->arrayoffset, index, value,
"") ==
2189 int param = PyC_Long_AsI32(value);
2190 if (param == -1 && PyErr_Occurred()) {
2191 PyErr_SetString(PyExc_TypeError,
"expected an int type");
2201 float param = PyFloat_AsDouble(value);
2202 if (PyErr_Occurred()) {
2203 PyErr_SetString(PyExc_TypeError,
"expected a float type");
2213 PyErr_SetString(PyExc_AttributeError,
"not an array type");
2265#define PYRNA_PROP_COLLECTION_ABS_INDEX(ret_err) \
2267 keynum_abs += RNA_property_collection_length(&self->ptr.value(), self->prop); \
2268 if (keynum_abs < 0) { \
2269 PyErr_Format(PyExc_IndexError, "bpy_prop_collection[%d]: out of range.", keynum); \
2280 if (value != Py_None) {
2283 if (
UNLIKELY(value_pyrna->
ptr->type ==
nullptr)) {
2286 PyErr_Format(PyExc_TypeError,
2287 "'%.200s' object is not subscriptable (only iteration is supported)",
2288 Py_TYPE(value)->tp_name);
2296 const char *error_prefix)
2298 PyErr_Format(PyExc_TypeError,
2299 "%.200s: %.200s.%.200s does not support string lookups",
2306 const char *error_prefix)
2320 Py_ssize_t keynum_abs = keynum;
2333 const int key = int(keynum_abs);
2334 PyObject *
result =
nullptr;
2358 if (keynum_abs >=
len) {
2359 PyErr_Format(PyExc_IndexError,
2360 "bpy_prop_collection[index]: "
2361 "index %d out of range, size %d",
2366 PyErr_Format(PyExc_RuntimeError,
2367 "bpy_prop_collection[index]: internal error, "
2368 "valid index %d given in %d sized collection, but value not found",
2381 Py_ssize_t keynum_abs = keynum;
2392 if (keynum_abs >=
len) {
2393 PyErr_Format(PyExc_IndexError,
2394 "bpy_prop_collection[index] = value: "
2395 "index %d out of range, size %d",
2400 PyErr_Format(PyExc_IndexError,
2401 "bpy_prop_collection[index] = value: "
2402 "index %d failed assignment (unknown reason)",
2423 if (keynum >= 0 && keynum <
len) {
2427 PyErr_Format(PyExc_IndexError,
"bpy_prop_array[index]: index %d out of range", keynum);
2444 const int key_len = strlen(keyname);
2447 PyObject *
result =
nullptr;
2458 &iter.
ptr, nameprop, name,
sizeof(name), &name_len);
2459 if ((key_len == name_len) &&
STREQ(name_ptr, keyname)) {
2462 if (name != name_ptr) {
2486 PyErr_Format(PyExc_KeyError,
"bpy_prop_collection[key]: key \"%.200s\" not found", keyname);
2504 const char *err_prefix,
2505 const short err_not_found,
2508 const char *keyname;
2511 if (PyTuple_GET_SIZE(key) != 2) {
2512 PyErr_Format(PyExc_KeyError,
2513 "%s: tuple key must be a pair, not size %d",
2515 PyTuple_GET_SIZE(key));
2518 if (
self->ptr->type != &RNA_BlendData) {
2519 PyErr_Format(PyExc_KeyError,
2520 "%s: is only valid for bpy.data collections, not %.200s",
2525 if ((keyname = PyUnicode_AsUTF8(PyTuple_GET_ITEM(key, 0))) ==
nullptr) {
2526 PyErr_Format(PyExc_KeyError,
2527 "%s: id must be a string, not %.200s",
2529 Py_TYPE(PyTuple_GET_ITEM(key, 0))->tp_name);
2533 PyObject *keylib = PyTuple_GET_ITEM(key, 1);
2537 if (keylib == Py_None) {
2540 else if (PyUnicode_Check(keylib)) {
2542 const char *keylib_str = PyUnicode_AsUTF8(keylib);
2545 if (
lib ==
nullptr) {
2546 if (err_not_found) {
2547 PyErr_Format(PyExc_KeyError,
2548 "%s: lib filepath '%.1024s' "
2549 "does not reference a valid library",
2559 PyErr_Format(PyExc_KeyError,
2560 "%s: lib must be a string or None, not %.200s",
2562 Py_TYPE(keylib)->tp_name);
2570 ID *
id =
static_cast<ID *
>(itemptr.data);
2582 if ((found ==
false) && err_not_found) {
2584 PyErr_SetString(PyExc_KeyError,
"bpy_prop_collection[key, lib]: not found");
2593 const char *err_prefix,
2594 const bool err_not_found)
2598 self, key, err_prefix, err_not_found, &
ptr);
2600 if (contains == 1) {
2619 list = PyList_New(0);
2628 PyList_APPEND(list, item);
2659 tuple = PyTuple_New(
stop - start);
2674 values =
static_cast<float *
>(PyMem_MALLOC(
sizeof(
float) *
length));
2677 values = values_stack;
2682 PyTuple_SET_ITEM(tuple,
count - start, PyFloat_FromDouble(values[
count]));
2685 if (values != values_stack) {
2694 values =
static_cast<bool *
>(PyMem_MALLOC(
sizeof(
bool) *
length));
2697 values = values_stack;
2702 PyTuple_SET_ITEM(tuple,
count - start, PyBool_FromLong(values[
count]));
2705 if (values != values_stack) {
2714 values =
static_cast<int *
>(PyMem_MALLOC(
sizeof(
int) *
length));
2717 values = values_stack;
2722 PyTuple_SET_ITEM(tuple,
count - start, PyLong_FromLong(values[
count]));
2725 if (values != values_stack) {
2733 PyErr_SetString(PyExc_TypeError,
"not an array type");
2746 if (PyUnicode_Check(key)) {
2749 if (PyIndex_Check(key)) {
2750 const Py_ssize_t
i = PyNumber_AsSsize_t(key, PyExc_IndexError);
2751 if (
i == -1 && PyErr_Occurred()) {
2757 if (PySlice_Check(key)) {
2758 PySliceObject *key_slice = (PySliceObject *)key;
2759 Py_ssize_t
step = 1;
2761 if (key_slice->step != Py_None && !_PyEval_SliceIndex(key, &
step)) {
2765 PyErr_SetString(PyExc_TypeError,
"bpy_prop_collection[slice]: slice steps not supported");
2768 if (key_slice->start == Py_None && key_slice->stop == Py_None) {
2772 Py_ssize_t start = 0,
stop = PY_SSIZE_T_MAX;
2775 if (key_slice->start != Py_None && !_PyEval_SliceIndex(key_slice->start, &start)) {
2778 if (key_slice->stop != Py_None && !_PyEval_SliceIndex(key_slice->stop, &
stop)) {
2782 if (start < 0 ||
stop < 0) {
2796 if (
stop - start <= 0) {
2797 return PyList_New(0);
2802 if (PyTuple_Check(key)) {
2805 self, key,
"bpy_prop_collection[id, lib]",
true);
2808 PyErr_Format(PyExc_TypeError,
2809 "bpy_prop_collection[key]: invalid key, "
2810 "must be a string or an int, not %.200s",
2811 Py_TYPE(key)->tp_name);
2821 if (value == Py_None) {
2823 PyErr_Format(PyExc_TypeError,
2824 "bpy_prop_collection[key] = value: invalid, "
2825 "this collection doesn't support None assignment");
2832 PyErr_Format(PyExc_TypeError,
2833 "bpy_prop_collection[key] = value: invalid, "
2834 "expected a StructRNA type or None, not a %.200s",
2835 Py_TYPE(value)->tp_name);
2841 PyErr_Format(PyExc_TypeError,
2842 "bpy_prop_collection[key] = value: invalid, "
2843 "expected a '%.200s' type or None, not a '%.200s'",
2852 PyErr_Format(PyExc_TypeError,
2853 "bpy_prop_collection[key] = value: internal error, "
2854 "failed to get the collection type");
2867 if (value ==
nullptr) {
2868 PyErr_SetString(PyExc_TypeError,
"del bpy_prop_collection[key]: not supported");
2876 if (PyUnicode_Check(key)) {
2881 if (PyIndex_Check(key)) {
2882 const Py_ssize_t
i = PyNumber_AsSsize_t(key, PyExc_IndexError);
2883 if (
i == -1 && PyErr_Occurred()) {
2890 else if (PySlice_Check(key)) {
2891 PySliceObject *key_slice = (PySliceObject *)key;
2892 Py_ssize_t
step = 1;
2894 if (key_slice->step != Py_None && !_PyEval_SliceIndex(key, &
step)) {
2897 else if (
step != 1) {
2898 PyErr_SetString(PyExc_TypeError,
"bpy_prop_collection[slice]: slice steps not supported");
2901 else if (key_slice->start == Py_None && key_slice->stop == Py_None) {
2905 Py_ssize_t start = 0,
stop = PY_SSIZE_T_MAX;
2908 if (key_slice->start != Py_None && !_PyEval_SliceIndex(key_slice->start, &start)) {
2911 if (key_slice->stop != Py_None && !_PyEval_SliceIndex(key_slice->stop, &
stop)) {
2915 if (start < 0 ||
stop < 0) {
2928 if (
stop - start <= 0) {
2929 return PyList_New(0);
2938 PyErr_Format(PyExc_TypeError,
2939 "bpy_prop_collection[key]: invalid key, "
2940 "must be an int, not %.200s",
2941 Py_TYPE(key)->tp_name);
2950 if (PyUnicode_Check(key)) {
2951 return pyrna_prop_array_subscript_str(
self, PyUnicode_AsUTF8(key));
2955 if (PyIndex_Check(key)) {
2956 const Py_ssize_t
i = PyNumber_AsSsize_t(key, PyExc_IndexError);
2957 if (
i == -1 && PyErr_Occurred()) {
2962 if (PySlice_Check(key)) {
2963 Py_ssize_t
step = 1;
2964 PySliceObject *key_slice = (PySliceObject *)key;
2966 if (key_slice->step != Py_None && !_PyEval_SliceIndex(key, &
step)) {
2970 PyErr_SetString(PyExc_TypeError,
"bpy_prop_array[slice]: slice steps not supported");
2973 if (key_slice->start == Py_None && key_slice->stop == Py_None) {
2981 Py_ssize_t start,
stop, slicelength;
2983 if (PySlice_GetIndicesEx(key,
len, &start, &
stop, &
step, &slicelength) < 0) {
2987 if (slicelength <= 0) {
2988 return PyTuple_New(0);
2995 PyErr_SetString(PyExc_AttributeError,
"bpy_prop_array[key]: invalid key, key must be an int");
3005 PyObject *value_fast;
3006 if (!(value_fast = PySequence_Fast(value,
3007 "bpy_prop_array[slice] = value: "
3008 "element in assignment is not a sequence type")))
3012 if (PySequence_Fast_GET_SIZE(value_fast) !=
length) {
3013 Py_DECREF(value_fast);
3014 PyErr_SetString(PyExc_ValueError,
3015 "bpy_prop_array[slice] = value: "
3016 "re-sizing bpy_struct element in arrays isn't supported");
3025 PyObject **value_items,
float *value,
int totdim,
const int dimsize[],
const float range[2])
3027 const int length = dimsize[0];
3033 if (
UNLIKELY(subvalue ==
nullptr)) {
3038 PySequence_Fast_ITEMS(subvalue), &value[index], totdim - 1, &dimsize[1], range);
3040 Py_DECREF(subvalue);
3046 const float min = range[0],
max = range[1];
3049 float v = PyFloat_AsDouble(value_items[
i]);
3057 PyObject **value_items,
int *value,
int totdim,
const int dimsize[],
const int range[2])
3059 const int length = dimsize[0];
3065 if (
UNLIKELY(subvalue ==
nullptr)) {
3070 PySequence_Fast_ITEMS(subvalue), &value[index], totdim - 1, &dimsize[1], range);
3072 Py_DECREF(subvalue);
3078 const int min = range[0],
max = range[1];
3081 int v = PyLong_AsLong(value_items[
i]);
3091 const int dimsize[])
3093 const int length = dimsize[0];
3099 if (
UNLIKELY(subvalue ==
nullptr)) {
3104 PySequence_Fast_ITEMS(subvalue), &value[index], totdim - 1, &dimsize[1]);
3106 Py_DECREF(subvalue);
3114 const int v = PyLong_AsLong(value_items[
i]);
3128 PyObject *value_orig)
3132 void *values_alloc =
nullptr;
3135 if (value_orig ==
nullptr) {
3138 "bpy_prop_array[slice] = value: deleting with list types is not supported by bpy_struct");
3142 if (!(value = PySequence_Fast(
3143 value_orig,
"bpy_prop_array[slice] = value: assignment is not a sequence type")))
3148 if (PySequence_Fast_GET_SIZE(value) !=
stop - start) {
3150 PyErr_SetString(PyExc_TypeError,
3151 "bpy_prop_array[slice] = value: re-sizing bpy_struct arrays isn't supported");
3163 for (
int i = arraydim + 1;
i < totdim;
i++) {
3168 PyObject **value_items = PySequence_Fast_ITEMS(value);
3172 float *values =
static_cast<float *
>(
3174 (values_alloc = PyMem_MALLOC(
sizeof(*values) * length_flat)) :
3184 dimsize[arraydim] =
stop - start;
3186 &values[arrayoffset + (start * span)],
3191 if (PyErr_Occurred()) {
3201 int *values =
static_cast<int *
>(
3203 (values_alloc = PyMem_MALLOC(
sizeof(*values) * length_flat)) :
3213 dimsize[arraydim] =
stop - start;
3215 &values[arrayoffset + (start * span)],
3220 if (PyErr_Occurred()) {
3230 bool *values =
static_cast<bool *
>(
3232 (values_alloc = PyMem_MALLOC(
sizeof(
bool) * length_flat)) :
3240 dimsize[arraydim] =
stop - start;
3242 &values[arrayoffset + (start * span)],
3244 &dimsize[arraydim]);
3246 if (PyErr_Occurred()) {
3255 PyErr_SetString(PyExc_TypeError,
"not an array type");
3263 PyMem_FREE(values_alloc);
3281 if (keynum >= 0 && keynum <
len) {
3285 PyErr_SetString(PyExc_IndexError,
"bpy_prop_array[index] = value: index out of range");
3299 PyErr_Format(PyExc_AttributeError,
3300 "bpy_prop_collection: attribute \"%.200s\" from \"%.200s\" is read-only",
3306 else if (PyIndex_Check(key)) {
3307 const Py_ssize_t
i = PyNumber_AsSsize_t(key, PyExc_IndexError);
3308 if (
i == -1 && PyErr_Occurred()) {
3315 else if (PySlice_Check(key)) {
3317 Py_ssize_t start,
stop,
step, slicelength;
3319 if (PySlice_GetIndicesEx(key,
len, &start, &
stop, &
step, &slicelength) < 0) {
3322 else if (slicelength <= 0) {
3325 else if (
step == 1) {
3336 PyErr_SetString(PyExc_TypeError,
"slice steps not supported with RNA");
3341 PyErr_SetString(PyExc_AttributeError,
"invalid key, key must be an int");
3428 if (PyTuple_Check(key)) {
3431 self, key,
"(id, lib) in bpy_prop_collection",
false,
nullptr);
3435 const char *keyname = PyUnicode_AsUTF8(key);
3437 if (keyname ==
nullptr) {
3438 PyErr_SetString(PyExc_TypeError,
3439 "bpy_prop_collection.__contains__: expected a string or a tuple of strings");
3447 self,
"bpy_prop_collection.__contains__") == -1)
3457 const char *name = PyUnicode_AsUTF8(value);
3462 PyErr_SetString(PyExc_TypeError,
"bpy_struct.__contains__: expected a string");
3467 PyErr_SetString(PyExc_TypeError,
"bpy_struct: this type doesn't support IDProperties");
3526 const char *name = PyUnicode_AsUTF8(key);
3531 PyErr_SetString(PyExc_TypeError,
"this type doesn't support IDProperties");
3535 if (name ==
nullptr) {
3536 PyErr_SetString(PyExc_TypeError,
3537 "bpy_struct[key]: only strings are allowed as keys of ID properties");
3543 if (group ==
nullptr) {
3544 PyErr_Format(PyExc_KeyError,
"bpy_struct[key]: key \"%s\" not found", name);
3550 if (idprop ==
nullptr) {
3551 PyErr_Format(PyExc_KeyError,
"bpy_struct[key]: key \"%s\" not found", name);
3564#ifdef USE_PEDANTIC_WRITE
3570 if (group ==
nullptr) {
3571 PyErr_SetString(PyExc_TypeError,
3572 "bpy_struct[key] = val: id properties not supported for this type");
3578 if (val &&
self->ptr->type && val->
ptr->type) {
3584 "bpy_struct[key] = val: datablock id properties not supported for this type");
3601 pyrna_struct_keys_doc,
3602 ".. method:: keys()\n"
3604 " Returns the keys of this objects custom properties (matches Python's\n"
3605 " dictionary function of the same name).\n"
3607 " :return: custom property keys.\n"
3608 " :rtype: :class:`idprop.types.IDPropertyGroupViewKeys`\n"
3615 PyErr_SetString(PyExc_TypeError,
"bpy_struct.keys(): this type doesn't support IDProperties");
3626 pyrna_struct_items_doc,
3627 ".. method:: items()\n"
3629 " Returns the items of this objects custom properties (matches Python's\n"
3630 " dictionary function of the same name).\n"
3632 " :return: custom property key, value pairs.\n"
3633 " :rtype: :class:`idprop.types.IDPropertyGroupViewItems`\n"
3640 PyErr_SetString(PyExc_TypeError,
"bpy_struct.items(): this type doesn't support IDProperties");
3651 pyrna_struct_values_doc,
3652 ".. method:: values()\n"
3654 " Returns the values of this objects custom properties (matches Python's\n"
3655 " dictionary function of the same name).\n"
3657 " :return: custom property values.\n"
3658 " :rtype: :class:`idprop.types.IDPropertyGroupViewValues`\n"
3665 PyErr_SetString(PyExc_TypeError,
3666 "bpy_struct.values(): this type doesn't support IDProperties");
3677 pyrna_struct_is_property_set_doc,
3678 ".. method:: is_property_set(property, /, *, ghost=True)\n"
3680 " Check if a property is set, use for testing operator properties.\n"
3682 " :arg property: Property name.\n"
3683 " :type property: str\n"
3684 " :arg ghost: Used for operators that re-run with previous settings.\n"
3685 " In this case the property is not marked as set,\n"
3686 " yet the value from the previous execution is used.\n"
3688 " In rare cases you may want to set this option to false.\n"
3690 " :type ghost: bool\n"
3691 " :return: True when the property has been set.\n"
3697 bool use_ghost =
true;
3701 static const char *_keywords[] = {
"",
"ghost",
nullptr};
3702 static _PyArg_Parser _parser = {
3711 if (!_PyArg_ParseTupleAndKeywordsFast(args, kw, &_parser, &name,
PyC_ParseBool, &use_ghost)) {
3716 PyErr_Format(PyExc_TypeError,
3717 "%.200s.is_property_set(\"%.200s\") not found",
3728 pyrna_struct_property_unset_doc,
3729 ".. method:: property_unset(property, /)\n"
3731 " Unset a property, will use default value afterward.\n"
3733 " :arg property: Property name.\n"
3734 " :type property: str\n");
3742 if (!PyArg_ParseTuple(args,
"s:property_unset", &name)) {
3747 PyErr_Format(PyExc_TypeError,
3748 "%.200s.property_unset(\"%.200s\") not found",
3761 pyrna_struct_is_property_hidden_doc,
3762 ".. method:: is_property_hidden(property, /)\n"
3764 " Check if a property is hidden.\n"
3766 " :arg property: Property name.\n"
3767 " :type property: str\n"
3768 " :return: True when the property is hidden.\n"
3777 if (!PyArg_ParseTuple(args,
"s:is_property_hidden", &name)) {
3782 PyErr_Format(PyExc_TypeError,
3783 "%.200s.is_property_hidden(\"%.200s\") not found",
3794 pyrna_struct_is_property_readonly_doc,
3795 ".. method:: is_property_readonly(property, /)\n"
3797 " Check if a property is readonly.\n"
3799 " :arg property: Property name.\n"
3800 " :type property: str\n"
3801 " :return: True when the property is readonly (not writable).\n"
3810 if (!PyArg_ParseTuple(args,
"s:is_property_readonly", &name)) {
3815 PyErr_Format(PyExc_TypeError,
3816 "%.200s.is_property_readonly(\"%.200s\") not found",
3827 pyrna_struct_is_property_overridable_library_doc,
3828 ".. method:: is_property_overridable_library(property, /)\n"
3830 " Check if a property is overridable.\n"
3832 " :arg property: Property name.\n"
3833 " :type property: str\n"
3834 " :return: True when the property is overridable.\n"
3843 if (!PyArg_ParseTuple(args,
"s:is_property_overridable_library", &name)) {
3848 PyErr_Format(PyExc_TypeError,
3849 "%.200s.is_property_overridable_library(\"%.200s\") not found",
3860 pyrna_struct_property_overridable_library_set_doc,
3861 ".. method:: property_overridable_library_set(property, overridable, /)\n"
3863 " Define a property as overridable or not (only for custom properties!).\n"
3865 " :arg property: Property name.\n"
3866 " :type property: str\n"
3867 " :arg overridable: Overridable status to set.\n"
3868 " :type overridable: bool\n"
3869 " :return: True when the overridable status of the property was successfully set.\n"
3879 if (!PyArg_ParseTuple(args,
"sp:property_overridable_library_set", &name, &is_overridable)) {
3884 PyErr_Format(PyExc_TypeError,
3885 "%.200s.property_overridable_library_set(\"%.200s\") not found",
3891 return PyBool_FromLong(
3897 pyrna_struct_path_resolve_doc,
3898 ".. method:: path_resolve(path, coerce=True, /)\n"
3900 " Returns the property from the path, raise an exception when not found.\n"
3902 " :arg path: path which this property resolves.\n"
3903 " :type path: str\n"
3904 " :arg coerce: optional argument, when True, the property will be converted\n"
3905 " into its Python representation.\n"
3906 " :type coerce: bool\n"
3907 " :return: Property value or property object.\n"
3908 " :rtype: Any | :class:`bpy.types.bpy_prop`\n");
3912 PyObject *coerce = Py_True;
3919 if (!PyArg_ParseTuple(args,
"s|O!:path_resolve", &path, &PyBool_Type, &coerce)) {
3927 PyErr_Format(PyExc_IndexError,
3928 "%.200s.path_resolve(\"%.200s\") index out of range",
3937 if (coerce == Py_False) {
3947 PyErr_Format(PyExc_ValueError,
3948 "%.200s.path_resolve(\"%.200s\") could not be resolved",
3956 pyrna_struct_path_from_id_doc,
3957 ".. method:: path_from_id(property=\"\", /)\n"
3959 " Returns the data path from the ID to this object (string).\n"
3961 " :arg property: Optional property name which can be used if the path is\n"
3962 " to a property of this object.\n"
3963 " :type property: str\n"
3964 " :return: The path from :class:`bpy.types.bpy_struct.id_data`\n"
3965 " to this struct and property (when given).\n"
3969 const char *name =
nullptr;
3974 if (!PyArg_ParseTuple(args,
"|s:path_from_id", &name)) {
3978 std::optional<std::string> path;
3981 if (prop ==
nullptr) {
3982 PyErr_Format(PyExc_AttributeError,
3983 "%.200s.path_from_id(\"%.200s\") not found",
3997 PyErr_Format(PyExc_ValueError,
3998 "%.200s.path_from_id(\"%s\") found, but does not support path creation",
4003 PyErr_Format(PyExc_ValueError,
4004 "%.200s.path_from_id() does not support path creation for this type",
4015 pyrna_prop_path_from_id_doc,
4016 ".. method:: path_from_id()\n"
4018 " Returns the data path from the ID to this property (string).\n"
4020 " :return: The path from :class:`bpy.types.bpy_struct.id_data` to this property.\n"
4030 PyErr_Format(PyExc_ValueError,
4031 "%.200s.%.200s.path_from_id() does not support path creation for this type",
4042 pyrna_prop_as_bytes_doc,
4043 ".. method:: as_bytes()\n"
4045 " Returns this string property as a byte rather than a Python string.\n"
4047 " :return: The string as bytes.\n"
4048 " :rtype: bytes\n");
4053 PyErr_Format(PyExc_TypeError,
4054 "%.200s.%.200s.as_bytes() must be a string",
4061 char buf_fixed[256], *buf;
4065 &
self->ptr.value(),
self->prop, buf_fixed,
sizeof(buf_fixed), &buf_len);
4067 ret = PyBytes_FromStringAndSize(buf, buf_len);
4069 if (buf_fixed != buf) {
4078 pyrna_prop_update_doc,
4079 ".. method:: update()\n"
4081 " Execute the properties update callback.\n"
4084 " This is called when assigning a property,\n"
4085 " however in rare cases it's useful to call explicitly.\n");
4094 pyrna_struct_type_recast_doc,
4095 ".. method:: type_recast()\n"
4097 " Return a new instance, this is needed because types\n"
4098 " such as textures can be changed at runtime.\n"
4100 " :return: a new instance of this object with the type initialized again.\n"
4101 " :rtype: :class:`bpy.types.bpy_struct`\n");
4116 PyObject *ret_test =
nullptr;
4117 PyObject *subclasses = (PyObject *)((PyTypeObject *)cls)->tp_subclasses;
4122 PyObject *key =
nullptr;
4124 PyObject *value =
nullptr;
4125 while (PyDict_Next(subclasses, &
pos, &key, &value)) {
4127 PyObject *subcls = PyWeakref_GET_OBJECT(value);
4128 if (subcls != Py_None) {
4150 pyrna_struct_bl_rna_get_subclass_py_doc,
4151 ".. classmethod:: bl_rna_get_subclass_py(id, default=None, /)\n"
4153 " :arg id: The RNA type identifier.\n"
4155 " :return: The class or default when not found.\n"
4160 PyObject *ret_default = Py_None;
4162 if (!PyArg_ParseTuple(args,
"s|O:bl_rna_get_subclass_py", &
id, &ret_default)) {
4166 if (
ret ==
nullptr) {
4169 return Py_NewRef(
ret);
4174 pyrna_struct_bl_rna_get_subclass_doc,
4175 ".. classmethod:: bl_rna_get_subclass(id, default=None, /)\n"
4177 " :arg id: The RNA type identifier.\n"
4179 " :return: The RNA type or default when not found.\n"
4180 " :rtype: :class:`bpy.types.Struct` subclass\n");
4184 PyObject *ret_default = Py_None;
4186 if (!PyArg_ParseTuple(args,
"s|O:bl_rna_get_subclass", &
id, &ret_default)) {
4192 if (py_srna ==
nullptr) {
4193 PyErr_SetString(PyExc_ValueError,
"Not a registered class");
4198 if (srna_base == &RNA_Node) {
4215 return Py_NewRef(ret_default);
4220 pyrna_struct_get_ancestors_doc,
4221 ".. method:: rna_ancestors()\n"
4223 " Return the chain of data containing this struct, if known.\n"
4224 " The first item is the root (typically an ID), the last one is the immediate parent.\n"
4227 " :return: a list of this object's ancestors.\n"
4228 " :rtype: list[:class:`bpy.types.bpy_struct`]\n");
4234 const int ancestors_num(
self->ptr->ancestors.size());
4236 ret = PyList_New(ancestors_num);
4238 for (
int i = 0;
i < ancestors_num;
i++) {
4241 PyList_SET_ITEM(
ret,
i, ancestor);
4251 list_tmp = PyDict_Keys(dict);
4252 PyList_SetSlice(list, INT_MAX, INT_MAX, list_tmp);
4253 Py_DECREF(list_tmp);
4259 PyObject **dict_ptr;
4261 dict_ptr = _PyObject_GetDictPtr(
self);
4263 if (dict_ptr && (dict = *dict_ptr)) {
4267 dict = ((PyTypeObject *)Py_TYPE(
self))->tp_dict;
4280 dict = ((PyTypeObject *)cls)->tp_dict;
4303 PyList_APPEND(list, PyUnicode_FromString(idname));
4313 char name[256], *name_ptr;
4326 PyList_APPEND(list, PyUnicode_FromStringAndSize(name_ptr, name_len));
4328 if (name != name_ptr) {
4345 ret = PyList_New(0);
4353 if (
self->ptr->type == &RNA_Context) {
4357 PyList_APPEND(
ret, PyUnicode_FromString(
static_cast<const char *
>(link->data)));
4367 PyObject *set = PySet_New(
ret);
4370 ret = PySequence_List(set);
4379 pyrna_struct_id_properties_ensure_doc,
4380 ".. method:: id_properties_ensure()\n"
4382 " :return: the parent group for an RNA struct's custom IDProperties.\n"
4383 " :rtype: :class:`idprop.types.IDPropertyGroup`\n");
4389 PyErr_SetString(PyExc_TypeError,
"This type doesn't support IDProperties");
4397 if (idprops ==
nullptr) {
4403 group->
prop = idprops;
4405 return (PyObject *)group;
4410 pyrna_struct_id_properties_ui_doc,
4411 ".. method:: id_properties_ui(key, /)\n"
4413 " :return: Return an object used to manage an IDProperty's UI data.\n"
4414 " :arg key: String name of the property.\n"
4415 " :type key: str.\n"
4416 " :rtype: :class:`bpy.types.IDPropertyUIManager`\n");
4422 PyErr_SetString(PyExc_TypeError,
"This type doesn't support IDProperties");
4427 if (!PyArg_ParseTuple(args,
"s:ui_data", &key)) {
4435 if (parent_group ==
nullptr) {
4440 if (property ==
nullptr) {
4441 PyErr_SetString(PyExc_KeyError,
"Property not found in IDProperty group");
4446 PyErr_Format(PyExc_TypeError,
"IDProperty \"%s\" does not support UI data", property->name);
4453 return (PyObject *)ui_manager;
4458 pyrna_struct_id_properties_clear_doc,
4459 ".. method:: id_properties_clear()\n"
4461 " :return: Remove the parent group for an RNA struct's custom IDProperties.\n");
4467 PyErr_SetString(PyExc_TypeError,
"This type doesn't support IDProperties");
4484 const char *name = PyUnicode_AsUTF8(pyname);
4492 if (name ==
nullptr) {
4493 PyErr_SetString(PyExc_AttributeError,
"bpy_struct: __getattr__ must be a string");
4503 PyErr_SetString(PyExc_AttributeError,
"bpy_struct: no __getitem__ support for this type");
4507 ret = PyObject_GenericGetAttr((PyObject *)
self, pyname);
4518 else if (
self->ptr->type == &RNA_Context) {
4521 PyErr_Format(PyExc_AttributeError,
4522 "bpy_struct: Context is 'nullptr', can't get \"%.200s\" from context",
4532 std::optional<int64_t> newint;
4540 C, name, &newptr, &newlb, &newprop, &newindex, &newstr, &newint, &newtype));
4550 if (newptr.
data ==
nullptr) {
4564 ret = PyUnicode_FromStringAndSize(newstr.
data(), newstr.
size());
4569 if (!newint.has_value()) {
4574 ret = PyLong_FromLong(*newint);
4579 ret = PyList_New(0);
4586 if (newprop !=
nullptr) {
4591 std::optional<std::string> path_str;
4604 ret = PyTuple_New(3);
4608 PyLong_FromLong(newindex));
4625 PyErr_Format(PyExc_AttributeError,
4626 "bpy_struct: Context type invalid %d, can't get \"%.200s\" from context",
4639 ret = PyObject_GenericGetAttr((PyObject *)
self, pyname);
4645 PyErr_Format(PyExc_AttributeError,
"bpy_struct: attribute \"%.200s\" not found", name);
4655 ret = PyObject_GenericGetAttr((PyObject *)
self, pyname);
4662static int pyrna_struct_pydict_contains(PyObject *
self, PyObject *pyname)
4664 PyObject *dict = *(_PyObject_GetDictPtr((PyObject *)
self));
4669 return PyDict_Contains(dict, pyname);
4676static PyObject *pyrna_struct_meta_idprop_getattro(PyObject *cls, PyObject *attr)
4678 PyObject *
ret = PyType_Type.tp_getattro(cls, attr);
4690 if ((
ret ==
nullptr) ) {
4700 if (
ret ==
nullptr) {
4701 PyErr_Format(PyExc_AttributeError,
4702 "StructRNA.__getattr__: attribute \"%.200s\" not found",
4703 PyUnicode_AsUTF8(attr));
4716 const char *attr_str = PyUnicode_AsUTF8(attr);
4721 PyErr_Format(PyExc_AttributeError,
4722 "pyrna_struct_meta_idprop_setattro() "
4723 "can't set in readonly state '%.200s.%S'",
4724 ((PyTypeObject *)cls)->tp_name,
4729 if (srna ==
nullptr) {
4732 if (value && is_deferred_prop) {
4733 PyErr_Format(PyExc_AttributeError,
4734 "pyrna_struct_meta_idprop_setattro() unable to get srna from class '%.200s'",
4735 ((PyTypeObject *)cls)->tp_name);
4741 return PyType_Type.tp_setattro(cls, attr, value);
4746 if (is_deferred_prop) {
4767 PyExc_TypeError,
"struct_meta_idprop.detattr(): '%s' not a dynamic property", attr_str);
4773 return PyType_Type.tp_setattro(cls, attr, value);
4778 const char *name = PyUnicode_AsUTF8(pyname);
4783#ifdef USE_PEDANTIC_WRITE
4789 if (name ==
nullptr) {
4790 PyErr_SetString(PyExc_AttributeError,
"bpy_struct: __setattr__ must be a string");
4795 PyErr_Format(PyExc_AttributeError,
4796 "bpy_struct: attribute \"%.200s\" from \"%.200s\" is read-only",
4802 else if (
self->ptr->type == &RNA_Context) {
4807 PyErr_Format(PyExc_AttributeError,
4808 "bpy_struct: Context is 'nullptr', can't set \"%.200s\" from context",
4818 std::optional<int64_t> newint;
4822 CTX_data_get(
C, name, &newptr, &newlb, &newprop, &newindex, &newstr, &newint, &newtype));
4826 PyExc_AttributeError,
"bpy_struct: Context property \"%.200s\" is read-only", name);
4833 if (value ==
nullptr) {
4834 PyErr_SetString(PyExc_AttributeError,
"bpy_struct: del not supported");
4838 &
self->ptr.value(), prop,
nullptr, value,
"bpy_struct: item.attr = val:");
4841 return PyObject_GenericSetAttr((PyObject *)
self, pyname, value);
4851 ret = PyList_New(0);
4868 return PyObject_GenericGetAttr((PyObject *)
self, pyname);
4873 const char *name = PyUnicode_AsUTF8(pyname);
4875 if (name ==
nullptr) {
4876 PyErr_SetString(PyExc_AttributeError,
"bpy_prop_collection: __getattr__ must be a string");
4879 if (name[0] !=
'_') {
4895 Py_DECREF(self_collection);
4903 return PyObject_GenericGetAttr((PyObject *)
self, pyname);
4910 PyObject *
ret = _PyObject_GenericGetAttrWithDict((PyObject *)
self, pyname,
nullptr, 1);
4913 if ((
ret ==
nullptr) && (name[0] !=
'_')) {
4918 ret = _PyObject_GenericGetAttrWithDict(cls, pyname,
nullptr, 1);
4921 if (
ret !=
nullptr) {
4922 if (Py_TYPE(
ret) == &PyMethodDescr_Type) {
4923 PyMethodDef *m = ((PyMethodDescrObject *)
ret)->d_method;
4925 if (m->ml_flags & METH_STATIC) {
4930 ret = PyCMethod_New(m, (PyObject *)
self,
nullptr,
nullptr);
4937 if (
ret ==
nullptr) {
4939 PyExc_AttributeError,
"bpy_prop_collection: attribute \"%.200s\" not found", name);
4950 const char *name = PyUnicode_AsUTF8(pyname);
4954#ifdef USE_PEDANTIC_WRITE
4960 if (name ==
nullptr) {
4961 PyErr_SetString(PyExc_AttributeError,
"bpy_prop: __setattr__ must be a string");
4964 if (value ==
nullptr) {
4965 PyErr_SetString(PyExc_AttributeError,
"bpy_prop: del not supported");
4972 &r_ptr, prop,
nullptr, value,
"BPy_PropertyRNA - Attribute (setattr):");
4976 PyErr_Format(PyExc_AttributeError,
"bpy_prop_collection: attribute \"%.200s\" not found", name);
4985 pyrna_prop_collection_idprop_add_doc,
4986 ".. method:: add()\n"
4988 " This is a function to add a new item to a collection.\n"
4990 " :return: A newly created item.\n"
4996#ifdef USE_PEDANTIC_WRITE
5004 PyErr_SetString(PyExc_TypeError,
5005 "bpy_prop_collection.add(): not supported for this collection");
5014 pyrna_prop_collection_idprop_remove_doc,
5015 ".. method:: remove(index)\n"
5017 " This is a function to remove an item from a collection.\n"
5019 " :arg index: Index of the item to be removed.\n"
5020 " :type index: int\n");
5023 const int key = PyLong_AsLong(value);
5025#ifdef USE_PEDANTIC_WRITE
5031 if (key == -1 && PyErr_Occurred()) {
5032 PyErr_SetString(PyExc_TypeError,
"bpy_prop_collection.remove(): expected one int argument");
5037 PyErr_SetString(PyExc_TypeError,
5038 "bpy_prop_collection.remove() not supported for this collection");
5047 pyrna_prop_collection_idprop_clear_doc,
5048 ".. method:: clear()\n"
5050 " This is a function to remove all items from a collection.\n");
5053#ifdef USE_PEDANTIC_WRITE
5066 pyrna_prop_collection_idprop_move_doc,
5067 ".. method:: move(src_index, dst_index)\n"
5069 " This is a function to move an item in a collection.\n"
5071 " :arg src_index: Source item index.\n"
5072 " :type src_index: int\n"
5073 " :arg dst_index: Destination item index.\n"
5074 " :type dst_index: int\n");
5077 int key = 0,
pos = 0;
5079#ifdef USE_PEDANTIC_WRITE
5085 if (!PyArg_ParseTuple(args,
"ii", &key, &
pos)) {
5086 PyErr_SetString(PyExc_TypeError,
"bpy_prop_collection.move(): expected two ints as arguments");
5091 PyErr_SetString(PyExc_TypeError,
5092 "bpy_prop_collection.move() not supported for this collection");
5101 pyrna_struct_get_id_data_doc,
5102 "The :class:`bpy.types.ID` object this datablock is from or None, (not available for "
5105 ":type: :class:`bpy.types.ID`, (readonly)\n");
5109 if (
self->ptr->owner_id) {
5119 pyrna_struct_get_data_doc,
5120 "The data this property is using, *type* :class:`bpy.types.bpy_struct`");
5128 pyrna_struct_get_rna_type_doc,
5129 "The property type for introspection");
5144 pyrna_struct_get_id_data_doc,
5150 pyrna_struct_get_rna_type_doc,
5152 {
nullptr,
nullptr,
nullptr,
nullptr,
nullptr}
5159 pyrna_struct_get_id_data_doc,
5161 {
nullptr,
nullptr,
nullptr,
nullptr,
nullptr}
5168 {
nullptr,
nullptr,
nullptr,
nullptr,
nullptr}
5173 pyrna_prop_collection_keys_doc,
5174 ".. method:: keys()\n"
5176 " Return the identifiers of collection members\n"
5177 " (matching Python's dict.keys() functionality).\n"
5179 " :return: the identifiers for each member of this collection.\n"
5180 " :rtype: list[str]\n");
5183 PyObject *
ret = PyList_New(0);
5184 char name[256], *name_ptr;
5191 PyList_APPEND(
ret, PyUnicode_FromStringAndSize(name_ptr, name_len));
5193 if (name != name_ptr) {
5205 pyrna_prop_collection_items_doc,
5206 ".. method:: items()\n"
5208 " Return the identifiers of collection members\n"
5209 " (matching Python's dict.items() functionality).\n"
5211 " :return: (key, value) pairs for each member of this collection.\n"
5212 " :rtype: list[tuple[str, :class:`bpy.types.bpy_struct`]]\n");
5215 PyObject *
ret = PyList_New(0);
5217 char name[256], *name_ptr;
5224 item = PyTuple_New(2);
5227 PyTuple_SET_ITEM(item, 0, PyUnicode_FromStringAndSize(name_ptr, name_len));
5228 if (name != name_ptr) {
5234 PyTuple_SET_ITEM(item, 0, PyLong_FromLong(
i));
5238 PyList_APPEND(
ret, item);
5250 pyrna_prop_collection_values_doc,
5251 ".. method:: values()\n"
5253 " Return the values of collection\n"
5254 " (matching Python's dict.values() functionality).\n"
5256 " :return: The members of this collection.\n"
5257 " :rtype: list[:class:`bpy.types.bpy_struct` | None]\n");
5266 pyrna_struct_get_doc,
5267 ".. method:: get(key, default=None, /)\n"
5269 " Returns the value of the custom property assigned to key or default\n"
5270 " when not found (matches Python's dictionary function of the same name).\n"
5272 " :arg key: The key associated with the custom property.\n"
5274 " :arg default: Optional argument for the value to return if\n"
5275 " *key* is not found.\n"
5276 " :type default: Any\n"
5277 " :return: Custom property value or default.\n"
5285 PyObject *def = Py_None;
5289 if (!PyArg_ParseTuple(args,
"s|O:get", &key, &def)) {
5295 PyErr_SetString(PyExc_TypeError,
"this type doesn't support IDProperties");
5308 return Py_NewRef(def);
5313 pyrna_struct_pop_doc,
5314 ".. method:: pop(key, default=None, /)\n"
5316 " Remove and return the value of the custom property assigned to key or default\n"
5317 " when not found (matches Python's dictionary function of the same name).\n"
5319 " :arg key: The key associated with the custom property.\n"
5321 " :arg default: Optional argument for the value to return if\n"
5322 " *key* is not found.\n"
5323 " :type default: Any\n"
5324 " :return: Custom property value or default.\n"
5332 PyObject *def =
nullptr;
5336 if (!PyArg_ParseTuple(args,
"s|O:get", &key, &def)) {
5342 PyErr_SetString(PyExc_TypeError,
"this type doesn't support IDProperties");
5362 if (def ==
nullptr) {
5363 PyErr_SetString(PyExc_KeyError,
"key not found");
5366 return Py_NewRef(def);
5371 pyrna_struct_as_pointer_doc,
5372 ".. method:: as_pointer()\n"
5374 " Returns the memory address which holds a pointer to Blender's internal data\n"
5376 " :return: int (memory address).\n"
5379 " .. note:: This is intended only for advanced script writers who need to\n"
5380 " pass blender data to their own C/Python modules.\n");
5383 return PyLong_FromVoidPtr(
self->ptr->data);
5388 pyrna_prop_collection_get_doc,
5389 ".. method:: get(key, default=None)\n"
5391 " Returns the value of the item assigned to key or default when not found\n"
5392 " (matches Python's dictionary function of the same name).\n"
5394 " :arg key: The identifier for the collection member.\n"
5396 " :arg default: Optional argument for the value to return if\n"
5397 " *key* is not found.\n"
5398 " :type default: Any\n");
5404 PyObject *def = Py_None;
5408 if (!PyArg_ParseTuple(args,
"O|O:get", &key_ob, &def)) {
5412 if (PyUnicode_Check(key_ob)) {
5413 const char *key = PyUnicode_AsUTF8(key_ob);
5419 "bpy_prop_collection.get") == -1)
5424 else if (PyTuple_Check(key_ob)) {
5426 self, key_ob,
"bpy_prop_collection.get((id, lib))",
false);
5432 PyErr_Format(PyExc_KeyError,
5433 "bpy_prop_collection.get(key, ...): key must be a string or tuple, not %.200s",
5434 Py_TYPE(key_ob)->tp_name);
5437 return Py_NewRef(def);
5442 pyrna_prop_collection_find_doc,
5443 ".. method:: find(key)\n"
5445 " Returns the index of a key in a collection or -1 when not found\n"
5446 " (matches Python's string find function of the same name).\n"
5448 " :arg key: The identifier for the collection member.\n"
5450 " :return: index of the key.\n"
5454 Py_ssize_t key_len_ssize;
5455 const char *key = PyUnicode_AsUTF8AndSize(key_ob, &key_len_ssize);
5456 const int key_len = int(key_len_ssize);
5458 char name[256], *name_ptr;
5469 if ((key_len == name_len) && memcmp(name_ptr, key, key_len) == 0) {
5474 if (name != name_ptr) {
5483 return PyLong_FromLong(index);
5491 bool *r_attr_signed,
5495 bool attr_ok =
true;
5498 *r_attr_signed =
false;
5512 *r_is_empty =
false;
5523 const char *function_name,
5526 const char **r_attr,
5532 bool *r_attr_signed)
5534 *r_size = *r_attr_tot = 0;
5535 *r_attr_signed =
false;
5538 if (!PyArg_ParseTuple(args,
"sO:foreach_get/set", r_attr, r_seq)) {
5542 if (!PySequence_Check(*r_seq) && PyObject_CheckBuffer(*r_seq)) {
5543 PyErr_Format(PyExc_TypeError,
5544 "%s(..) expected second argument to be a sequence or buffer, not a %.200s",
5546 Py_TYPE(*r_seq)->tp_name);
5551 *r_tot = PySequence_Size(*r_seq);
5564 if (array_tot == 0) {
5565 PyErr_Format(PyExc_TypeError,
5566 "%s(..) sequence length mismatch given %d, needed 0",
5573 bool is_empty =
false;
5575 PyErr_Format(PyExc_AttributeError,
5576 "%s(..) '%.200s.%200s[...]' elements have no attribute '%.200s'",
5585 PyErr_Format(PyExc_TypeError,
5586 "%s(..) sequence length mismatch given %d, needed 0",
5599 if ((*r_attr_tot) < 1) {
5603 const int target_tot = array_tot * (*r_attr_tot);
5606 if (target_tot != (*r_tot)) {
5607 PyErr_Format(PyExc_TypeError,
5608 "%s(..) sequence length mismatch given %d, needed %d",
5620 if (*r_size == 0 && *r_attr_tot != 0) {
5622 PyExc_AttributeError,
"%s(..): attribute does not support foreach method", function_name);
5635 return (f ==
'b') ?
true :
false;
5638 return (f ==
'B') ?
true :
false;
5642 return (f ==
'B') ?
true :
false;
5645 return (f ==
'h') ?
true :
false;
5648 return (f ==
'H') ?
true :
false;
5651 return (f ==
'H') ?
true :
false;
5654 return (f ==
'i') ?
true :
false;
5657 return (f ==
'I') ?
true :
false;
5660 return (f ==
'?') ?
true :
false;
5662 return (f ==
'f') ?
true :
false;
5664 return (f ==
'd') ?
true :
false;
5667 return (f ==
'q') ?
true :
false;
5670 return (f ==
'Q') ?
true :
false;
5673 return (f ==
'Q') ?
true :
false;
5683 PyObject *item =
nullptr;
5685 bool buffer_is_compat;
5686 void *
array =
nullptr;
5698 set ?
"foreach_set" :
"foreach_get",
5705 &attr_signed) == -1)
5715 buffer_is_compat =
false;
5716 if (PyObject_CheckBuffer(seq)) {
5718 if (PyObject_GetBuffer(seq, &buf, PyBUF_ND | PyBUF_FORMAT) == -1) {
5728 if (buffer_is_compat) {
5730 nullptr, &
self->ptr.value(),
self->prop, attr, buf.buf, raw_type, tot);
5733 PyBuffer_Release(&buf);
5738 if (!buffer_is_compat) {
5741 for (;
i < tot;
i++) {
5742 item = PySequence_GetItem(seq,
i);
5760 ((
int *)
array)[
i] = int(PyC_Long_AsI32(item));
5766 ((
float *)
array)[
i] = float(PyFloat_AsDouble(item));
5769 ((
double *)
array)[
i] = PyFloat_AsDouble(item);
5787 nullptr, &
self->ptr.value(),
self->prop, attr,
array, raw_type, tot);
5791 buffer_is_compat =
false;
5792 if (PyObject_CheckBuffer(seq)) {
5794 if (PyObject_GetBuffer(seq, &buf, PyBUF_ND | PyBUF_FORMAT) == -1) {
5804 if (buffer_is_compat) {
5806 nullptr, &
self->ptr.value(),
self->prop, attr, buf.buf, raw_type, tot);
5809 PyBuffer_Release(&buf);
5814 if (!buffer_is_compat) {
5818 nullptr, &
self->ptr.value(),
self->prop, attr,
array, raw_type, tot);
5825 for (;
i < tot;
i++) {
5829 item = PyLong_FromLong(
long(((
char *)
array)[
i]));
5832 item = PyLong_FromLong(
long(((int8_t *)
array)[
i]));
5835 item = PyLong_FromLong(
long(((uint8_t *)
array)[
i]));
5838 item = PyLong_FromLong(
long(((
short *)
array)[
i]));
5841 item = PyLong_FromLong(
long(((uint16_t *)
array)[
i]));
5844 item = PyLong_FromLong(
long(((
int *)
array)[
i]));
5847 item = PyFloat_FromDouble(
double(((
float *)
array)[
i]));
5850 item = PyFloat_FromDouble(((
double *)
array)[
i]);
5853 item = PyBool_FromLong(
long(((
bool *)
array)[
i]));
5869 PySequence_SetItem(seq,
i, item);
5879 if (PyErr_Occurred()) {
5882 PyErr_SetString(PyExc_TypeError,
"couldn't access the py sequence");
5886 PyErr_SetString(PyExc_RuntimeError,
"internal error setting the array");
5898 pyrna_prop_collection_foreach_get_doc,
5899 ".. method:: foreach_get(attr, seq)\n"
5901 " This is a function to give fast access to attributes within a collection.\n");
5911 pyrna_prop_collection_foreach_set_doc,
5912 ".. method:: foreach_set(attr, seq)\n"
5914 " This is a function to give fast access to attributes within a collection.\n");
5926 PyObject *item =
nullptr;
5927 Py_ssize_t
i, seq_size,
size;
5928 void *
array =
nullptr;
5935 PyErr_Format(PyExc_TypeError,
"foreach_get/set available only for int and float");
5939 if (!PyArg_ParseTuple(args,
"O:foreach_get/set", &seq)) {
5943 if (!PySequence_Check(seq) && PyObject_CheckBuffer(seq)) {
5946 "foreach_get/set expected second argument to be a sequence or buffer, not a %.200s",
5947 Py_TYPE(seq)->tp_name);
5954 seq_size = PySequence_Size(seq);
5956 if (
size != seq_size) {
5957 PyErr_Format(PyExc_TypeError,
"expected sequence size %d, got %d",
size, seq_size);
5962 if (PyObject_GetBuffer(seq, &buf, PyBUF_ND | PyBUF_FORMAT) == -1) {
5965 switch (prop_type) {
5967 array = PyMem_Malloc(
sizeof(
int) *
size);
5970 item = PySequence_GetItem(seq,
i);
5971 ((
int *)
array)[
i] = int(PyLong_AsLong(item));
5976 &
self->ptr.value(),
self->prop,
static_cast<const int *
>(
array));
5982 item = PyLong_FromLong(
long(((
int *)
array)[
i]));
5983 PySequence_SetItem(seq,
i, item);
5990 array = PyMem_Malloc(
sizeof(
float) *
size);
5993 item = PySequence_GetItem(seq,
i);
5994 ((
float *)
array)[
i] = float(PyFloat_AsDouble(item));
5999 &
self->ptr.value(),
self->prop,
static_cast<const float *
>(
array));
6003 &
self->ptr.value(),
self->prop,
static_cast<float *
>(
array));
6006 item = PyFloat_FromDouble(
double(((
float *)
array)[
i]));
6007 PySequence_SetItem(seq,
i, item);
6024 if (PyErr_Occurred()) {
6027 PyErr_SetString(PyExc_TypeError,
"couldn't access the py sequence");
6032 const char f = buf.format ? buf.format[0] : 0;
6033 if ((prop_type ==
PROP_INT && (buf.itemsize !=
sizeof(
int) || !
ELEM(f,
'l',
'i'))) ||
6034 (prop_type ==
PROP_FLOAT && (buf.itemsize !=
sizeof(
float) || f !=
'f')))
6036 PyBuffer_Release(&buf);
6037 PyErr_Format(PyExc_TypeError,
"incorrect sequence item type: %s", buf.format);
6041 switch (prop_type) {
6045 &
self->ptr.value(),
self->prop,
static_cast<const int *
>(buf.buf));
6054 &
self->ptr.value(),
self->prop,
static_cast<const float *
>(buf.buf));
6058 &
self->ptr.value(),
self->prop,
static_cast<float *
>(buf.buf));
6071 PyBuffer_Release(&buf);
6079 pyrna_prop_array_foreach_get_doc,
6080 ".. method:: foreach_get(seq)\n"
6082 " This is a function to give fast access to array data.\n");
6092 pyrna_prop_array_foreach_set_doc,
6093 ".. method:: foreach_set(seq)\n"
6095 " This is a function to give fast access to array data.\n");
6109 PyObject *iter =
nullptr;
6120 iter = PyObject_GetIter(
ret);
6129#ifndef USE_PYRNA_ITER
6136 PyObject *iter =
nullptr;
6142 iter = PyObject_GetIter(
ret);
6152# pragma clang diagnostic push
6153# pragma clang diagnostic ignored "-Wcast-function-type"
6155# pragma GCC diagnostic push
6156# pragma GCC diagnostic ignored "-Wcast-function-type"
6167 {
"get", (PyCFunction)
pyrna_struct_get, METH_VARARGS, pyrna_struct_get_doc},
6168 {
"pop", (PyCFunction)
pyrna_struct_pop, METH_VARARGS, pyrna_struct_pop_doc},
6175 METH_VARARGS | METH_KEYWORDS,
6179 METH_VARARGS | METH_KEYWORDS,
6192 METH_VARARGS | METH_KEYWORDS,
6193 pyrna_struct_is_property_set_doc},
6197 pyrna_struct_property_unset_doc},
6198 {
"is_property_hidden",
6201 pyrna_struct_is_property_hidden_doc},
6202 {
"is_property_readonly",
6205 pyrna_struct_is_property_readonly_doc},
6206 {
"is_property_overridable_library",
6209 pyrna_struct_is_property_overridable_library_doc},
6210 {
"property_overridable_library_set",
6213 pyrna_struct_property_overridable_library_set_doc},
6217 pyrna_struct_path_resolve_doc},
6221 pyrna_struct_path_from_id_doc},
6225 pyrna_struct_type_recast_doc},
6226 {
"bl_rna_get_subclass_py",
6228 METH_VARARGS | METH_CLASS,
6229 pyrna_struct_bl_rna_get_subclass_py_doc},
6230 {
"bl_rna_get_subclass",
6232 METH_VARARGS | METH_CLASS,
6233 pyrna_struct_bl_rna_get_subclass_doc},
6237 pyrna_struct_get_ancestors_doc},
6239 {
"id_properties_ensure",
6242 pyrna_struct_id_properties_ensure_doc},
6243 {
"id_properties_clear",
6246 pyrna_struct_id_properties_clear_doc},
6247 {
"id_properties_ui",
6250 pyrna_struct_id_properties_ui_doc},
6255 {
"callback_add", (PyCFunction)pyrna_callback_add, METH_VARARGS,
nullptr},
6256 {
"callback_remove", (PyCFunction)pyrna_callback_remove, METH_VARARGS,
nullptr},
6260 METH_VARARGS | METH_CLASS,
6264 METH_VARARGS | METH_CLASS,
6267 {
nullptr,
nullptr, 0,
nullptr},
6274 pyrna_prop_path_from_id_doc},
6278 {
nullptr,
nullptr, 0,
nullptr},
6285 pyrna_prop_array_foreach_get_doc},
6289 pyrna_prop_array_foreach_set_doc},
6291 {
nullptr,
nullptr, 0,
nullptr},
6298 pyrna_prop_collection_foreach_get_doc},
6302 pyrna_prop_collection_foreach_set_doc},
6308 pyrna_prop_collection_items_doc},
6312 pyrna_prop_collection_values_doc},
6316 {
nullptr,
nullptr, 0,
nullptr},
6323 pyrna_prop_collection_idprop_add_doc},
6327 pyrna_prop_collection_idprop_remove_doc},
6331 pyrna_prop_collection_idprop_clear_doc},
6335 pyrna_prop_collection_idprop_move_doc},
6336 {
nullptr,
nullptr, 0,
nullptr},
6341# pragma clang diagnostic pop
6343# pragma GCC diagnostic pop
6373 for (a = 0; a <
len; a++) {
6374 PyTuple_SET_ITEM(
ret, a, PyBool_FromLong(((
bool *)
data)[a]));
6379 for (a = 0; a <
len; a++) {
6380 PyTuple_SET_ITEM(
ret, a, PyLong_FromLong(((
int *)
data)[a]));
6394 else if (
len == 9) {
6402 for (a = 0; a <
len; a++) {
6403 PyTuple_SET_ITEM(
ret, a, PyFloat_FromDouble(((
float *)
data)[a]));
6410 PyExc_TypeError,
"RNA Error: unknown array type \"%d\" (pyrna_param_to_py)", type);
6419 ret = PyBool_FromLong(*(
bool *)
data);
6422 ret = PyLong_FromLong(*(
int *)
data);
6425 ret = PyFloat_FromDouble(*(
float *)
data);
6428 const char *data_ch;
6434 data_ch =
static_cast<const char *
>(data_alloc->
array);
6436 BLI_assert((data_ch ==
nullptr) || strlen(data_ch) == data_ch_len);
6440 data_ch_len = data_ch ? strlen(data_ch) : 0;
6443 if (
UNLIKELY(data_ch ==
nullptr)) {
6448#ifdef USE_STRING_COERCE
6450 ret = PyBytes_FromStringAndSize(data_ch, data_ch_len);
6456 ret = PyUnicode_FromStringAndSize(data_ch, data_ch_len);
6460 ret = PyBytes_FromString(buf);
6463 ret = PyUnicode_FromString(data_ch);
6502 if (newptr_p->
data) {
6513 ret = PyList_New(0);
6520 PyErr_Format(PyExc_TypeError,
"RNA Error: unknown type \"%d\" (pyrna_param_to_py)", type);
6537 const Py_ssize_t key_lookup_len = strlen(key_lookup);
6538 PyObject *key =
nullptr;
6540 PyObject *value =
nullptr;
6542 while (PyDict_Next(dict, &
pos, &key, &value)) {
6543 if (PyUnicode_Check(key)) {
6544 Py_ssize_t key_buf_len;
6545 const char *key_buf = PyUnicode_AsUTF8AndSize(key, &key_buf_len);
6546 if ((key_lookup_len == key_buf_len) && (memcmp(key_lookup, key_buf, key_lookup_len) == 0)) {
6560 const int parm_index,
6562 const size_t error_size)
6566 if (parm_index == -1) {
6569 "%.200s.%.200s(): error with keyword argument \"%.200s\" - ",
6577 "%.200s.%.200s(): error with argument %d, \"%.200s\" - ",
6594 PyObject *
ret, *item;
6595 int i, pyargs_len, pykw_len, parms_len, ret_len, flag_parameter, err = 0, kw_tot = 0;
6599 void *retdata_single =
nullptr;
6605#ifdef DEBUG_STRING_FREE
6606 PyObject *string_free_ls = PyList_New(0);
6612 if (self_ptr ==
nullptr) {
6613 PyErr_SetString(PyExc_RuntimeError,
6614 "RNA functions internal RNA pointer is nullptr, this is a bug. aborting");
6618 if (self_func ==
nullptr) {
6621 "%.200s.<unknown>(): RNA function internal function is nullptr, this is a bug. aborting",
6632 printf(
"pyrna_func_call > %.200s.%.200s : %.200s:%d\n",
6645 pyargs_len = PyTuple_GET_SIZE(args);
6646 pykw_len = kw ? PyDict_Size(kw) : 0;
6653 if (pyargs_len + pykw_len > parms_len) {
6655 PyErr_Format(PyExc_TypeError,
6656 "%.200s.%.200s(): takes at most %d arguments, got %d",
6660 pyargs_len + pykw_len);
6672 if (pret_single ==
nullptr) {
6674 retdata_single = iter.
data;
6682 if (
i < pyargs_len) {
6685 PyErr_Format(PyExc_TypeError,
6686 "%.200s.%.200s(): required parameter \"%.200s\" to be a keyword argument!",
6694 item = PyTuple_GET_ITEM(args,
i);
6697 else if (kw !=
nullptr) {
6710 if (item ==
nullptr) {
6712 PyErr_Format(PyExc_TypeError,
6713 "%.200s.%.200s(): required parameter \"%.200s\" not specified",
6724#ifdef DEBUG_STRING_FREE
6726 if (PyUnicode_Check(item)) {
6727 PyList_APPEND(string_free_ls, PyUnicode_FromString(PyUnicode_AsUTF8(item)));
6734 char error_prefix[512];
6758 if (err == 0 && kw && (pykw_len > kw_tot)) {
6759 PyObject *key, *value;
6765 const char *arg_name, *bad_args_str, *good_args_str;
6766 bool found =
false, first =
true;
6768 while (PyDict_Next(kw, &
pos, &key, &value)) {
6770 arg_name = PyUnicode_AsUTF8(key);
6773 if (arg_name ==
nullptr)
6790 if (found ==
false) {
6817 "%.200s.%.200s(): was called with invalid keyword argument(s) (%s), expected (%s)",
6846 ret = PyTuple_New(ret_len);
6866 if (
ret ==
nullptr) {
6873#ifdef DEBUG_STRING_FREE
6875 if (PyList_GET_SIZE(string_free_ls)) {
6876 printf(
"%.200s.%.200s(): has %d strings\n",
6879 int(PyList_GET_SIZE(string_free_ls)));
6882 Py_DECREF(string_free_ls);
6883# undef DEBUG_STRING_FREE
6907 ret = PyUnicode_FromFormat(
"%.200s.%.200s(%.200s)\n%s",
6917 PyVarObject_HEAD_INIT(
nullptr, 0)
6918 "bpy_struct_meta_idprop",
6921 sizeof(PyHeapTypeObject),
6938 Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
6949#if defined(_MSC_VER)
7004static PyObject *
pyrna_struct_new(PyTypeObject *type, PyObject *args, PyObject * );
7009 PyVarObject_HEAD_INIT(
nullptr, 0)
7028 Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE
7029#ifdef USE_PYRNA_STRUCT_REFERENCE
7030 | Py_TPFLAGS_HAVE_GC
7034#ifdef USE_PYRNA_STRUCT_REFERENCE
7035 (traverseproc)pyrna_struct_traverse,
7036 (inquiry)pyrna_struct_clear,
7075 if (PyTuple_GET_SIZE(args) != 1) {
7076 PyErr_Format(PyExc_TypeError,
"bpy_struct.__new__(struct): expected a single argument");
7080 PyObject *arg_1 = PyTuple_GET_ITEM(args, 0);
7083 if (!PyCapsule_CheckExact(arg_1)) {
7089 "bpy_struct.__new__(struct): struct type '%.200s' is not a subtype of bpy_struct",
7090 Py_TYPE(base)->tp_name);
7094 if (Py_TYPE(base) == type) {
7097 return reinterpret_cast<PyObject *
>(base);
7104 PyObject *
self = type->tp_alloc(type, 0);
7107#ifdef USE_PYRNA_STRUCT_REFERENCE
7110 PyObject_GC_UnTrack(
self);
7112 self_struct->
ptr = std::nullopt;
7122 size_t args_num = PyTuple_GET_SIZE(args);
7123 if (args_num != 1) {
7124 PyErr_Format(PyExc_TypeError,
"bpy_struct.__init__(self, struct): expected a single argument");
7128 PyObject *arg_1 = PyTuple_GET_ITEM(args, 0);
7130 if (PyCapsule_CheckExact(arg_1)) {
7141 PyErr_Format(PyExc_TypeError,
7142 "bpy_struct.__init__(self, struct): struct type '%.200s' is not a subtype of "
7144 Py_TYPE(base_struct)->tp_name);
7148 if (base_struct == self_struct) {
7154 ptr = &base_struct->
ptr.value();
7157 if (
ptr ==
nullptr) {
7158 PyErr_Format(PyExc_TypeError,
7159 "bpy_struct.__init__(self, struct): failed to get a valid PointerRNA data "
7160 "from the given `struct` argument");
7164 self_struct->
ptr.reset();
7178 PyObject *error_type, *error_value, *error_traceback;
7179 PyErr_Fetch(&error_type, &error_value, &error_traceback);
7183#ifdef PYRNA_FREE_SUPPORT
7184 if (self_struct->freeptr && self_struct->
ptr->data) {
7186 self_struct->
ptr->data =
nullptr;
7191 if (self_struct->in_weakreflist !=
nullptr) {
7192 PyObject_ClearWeakRefs(
self);
7196#ifdef USE_PYRNA_STRUCT_REFERENCE
7197 if (self_struct->reference) {
7198 PyObject_GC_UnTrack(
self);
7199 pyrna_struct_clear(self_struct);
7202 PyTypeObject *base = Py_TYPE(
self)->tp_base;
7204 if (base && PyType_IS_GC(base)) {
7205 PyObject_GC_UnTrack(
self);
7211 self_struct->
ptr.~optional();
7216 PyErr_Restore(error_type, error_value, error_traceback);
7248 PyVarObject_HEAD_INIT(
nullptr, 0)
7267 Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
7304 PyVarObject_HEAD_INIT(
nullptr, 0)
7323 Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
7360 PyVarObject_HEAD_INIT(
nullptr, 0)
7361 "bpy_prop_collection",
7379 Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
7417 PyVarObject_HEAD_INIT(
nullptr, 0)
7418 "bpy_prop_collection_idprop",
7436 Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
7474 if (PyTuple_GET_SIZE(args) != 1) {
7475 PyErr_Format(PyExc_TypeError,
"bpy_prop.__new__(property): expected a single argument");
7479 PyObject *arg_1 = PyTuple_GET_ITEM(args, 0);
7482 if (!PyCapsule_CheckExact(arg_1)) {
7488 "bpy_prop.__new__(property): property type '%.200s' is not a subtype of bpy_prop",
7489 Py_TYPE(base)->tp_name);
7493 if (Py_TYPE(base) == type) {
7496 return reinterpret_cast<PyObject *
>(base);
7503 PyObject *
self = type->tp_alloc(type, 0);
7506 self_property->
ptr = std::nullopt;
7516 size_t args_num = PyTuple_GET_SIZE(args);
7517 if (args_num != 1) {
7518 PyErr_Format(PyExc_TypeError,
"bpy_prop.__init__(self, property): expected a single argument");
7522 PyObject *arg_1 = PyTuple_GET_ITEM(args, 0);
7525 if (PyCapsule_CheckExact(arg_1)) {
7531 if (pypropptr_rna) {
7532 ptr = pypropptr_rna->
ptr;
7533 prop = pypropptr_rna->
prop;
7543 "bpy_prop.__init__(self, property): property type '%.200s' is not a subtype of bpy_prop",
7544 Py_TYPE(base_property)->tp_name);
7548 if (base_property == self_property) {
7552 ptr = &base_property->
ptr.value();
7553 prop = base_property->
prop;
7556 self_property->
ptr = *
ptr;
7557 self_property->
prop = prop;
7565 PyObject *error_type, *error_value, *error_traceback;
7566 PyErr_Fetch(&error_type, &error_value, &error_traceback);
7570 if (self_property->in_weakreflist !=
nullptr) {
7571 PyObject_ClearWeakRefs(
self);
7575 self_property->
ptr.~optional();
7580 PyErr_Restore(error_type, error_value, error_traceback);
7587 size_t args_num = PyTuple_GET_SIZE(args);
7588 if (args_num != 1) {
7589 PyErr_Format(PyExc_TypeError,
7590 "bpy_prop_array.__init__(self, property): expected a single argument");
7594 PyObject *arg_1 = PyTuple_GET_ITEM(args, 0);
7597 if (PyCapsule_CheckExact(arg_1)) {
7603 if (pypropptr_rna) {
7604 ptr = pypropptr_rna->
ptr;
7605 prop = pypropptr_rna->
prop;
7613 PyErr_Format(PyExc_TypeError,
7614 "bpy_prop_array.__init__(self, property): property type '%.200s' is not a "
7615 "subtype of bpy_prop_array",
7616 Py_TYPE(base_property)->tp_name);
7620 if (base_property == self_property) {
7624 ptr = &base_property->
ptr.value();
7625 prop = base_property->
prop;
7628 self_property->
prop = prop;
7631 self_property->
ptr = *
ptr;
7636#ifdef USE_PYRNA_ITER
7655 PyVarObject_HEAD_INIT(
nullptr, 0)
7656 "bpy_prop_collection_iter",
7671 PyObject_GenericGetAttr,
7714 if (PyTuple_GET_SIZE(args) != 1) {
7715 PyErr_Format(PyExc_TypeError,
7716 "bpy_prop_collection_iter.__new__(arg): expected a single argument");
7720 PyObject *arg_1 = PyTuple_GET_ITEM(args, 0);
7722 if (!PyCapsule_CheckExact(arg_1)) {
7723 PyErr_Format(PyExc_TypeError,
7724 "bpy_prop_collection_iter.__new__(arg): arg type '%.200s' is not a PyCapsule",
7725 Py_TYPE(arg_1)->tp_name);
7730 PyObject *
self = type->tp_alloc(type, 0);
7733 if (self_prop_iter) {
7734 self_prop_iter->
iter = std::nullopt;
7745 size_t args_num = PyTuple_GET_SIZE(args);
7746 if (args_num != 1) {
7749 "bpy_prop_collection_iter.__init__(self, arg): expected at most a single argument");
7753 PyObject *arg_1 = PyTuple_GET_ITEM(args, 0);
7756 if (PyCapsule_CheckExact(arg_1)) {
7762 if (pypropptr_rna) {
7763 ptr = pypropptr_rna->
ptr;
7764 prop = pypropptr_rna->
prop;
7770 "bpy_prop_collection_iter.__init__(self, arg): arg type '%.200s' is not a PyCapsule",
7771 Py_TYPE(arg_1)->tp_name);
7774 if (self_prop_iter->
iter.has_value()) {
7776 self_prop_iter->
iter.reset();
7788 PyObject *error_type, *error_value, *error_traceback;
7789 PyErr_Fetch(&error_type, &error_value, &error_traceback);
7794 if (self_property->in_weakreflist !=
nullptr) {
7795 PyObject_ClearWeakRefs(
self);
7799 if (self_property->
iter.has_value()) {
7801 self_property->
iter.reset();
7807 PyErr_Restore(error_type, error_value, error_traceback);
7815 PyObject *pypropptr_rna = PyCapsule_New(
7818 PyObject *
self = PyObject_CallOneArg(
7824 Py_DECREF(pypropptr_rna);
7827 self_property->in_weakreflist =
nullptr;
7839 self_property->
prop);
7846 if (self_property->
iter->valid ==
false) {
7847 PyErr_SetNone(PyExc_StopIteration);
7853# ifdef USE_PYRNA_STRUCT_REFERENCE
7856 if (iter_data != Py_None) {
7861 pyrna_struct_reference_set(iter_data_struct,
self);
7887 PyVarObject_HEAD_INIT(
nullptr, 0)
7944 if (PyTuple_GET_SIZE(args) != 1) {
7945 PyErr_Format(PyExc_TypeError,
"bpy_func.__new__(arg): expected a single argument");
7949 PyObject *arg_1 = PyTuple_GET_ITEM(args, 0);
7952 if (!PyCapsule_CheckExact(arg_1)) {
7953 PyErr_Format(PyExc_TypeError,
7954 "bpy_func.__new__(arg): arg type '%.200s' is not a PyCapsule",
7955 Py_TYPE(arg_1)->tp_name);
7960 PyObject *
self = type->tp_alloc(type, 0);
7962 if (self_function) {
7963 self_function->
ptr = std::nullopt;
7973 size_t args_num = PyTuple_GET_SIZE(args);
7974 if (args_num != 1) {
7975 PyErr_Format(PyExc_TypeError,
7976 "bpy_func.__init__(self, arg): expected at most a single argument");
7980 PyObject *arg_1 = PyTuple_GET_ITEM(args, 0);
7983 if (PyCapsule_CheckExact(arg_1)) {
7989 if (pyfuncptr_rna) {
7990 ptr = pyfuncptr_rna->
ptr;
7991 func = pyfuncptr_rna->
func;
7995 PyErr_Format(PyExc_TypeError,
7996 "bpy_func.__init__(self, arg): arg type '%.200s' is not a PyCapsule",
7997 Py_TYPE(arg_1)->tp_name);
8000 self_function->
func = func;
8001 self_function->
ptr = *
ptr;
8009 PyObject *error_type, *error_value, *error_traceback;
8010 PyErr_Fetch(&error_type, &error_value, &error_traceback);
8015 if (self_func->in_weakreflist !=
nullptr) {
8016 PyObject_ClearWeakRefs(
self);
8020 self_func->
ptr.~optional();
8025 PyErr_Restore(error_type, error_value, error_traceback);
8032 Py_INCREF(newclass);
8036 Py_DECREF(oldclass);
8067 const PointerRNA func_ptr = {
nullptr, srna,
nullptr};
8096 PyObject *py_base =
nullptr;
8101 if (base && base != srna) {
8107 if (py_base ==
nullptr) {
8129 PyObject *bpy_types = PyImport_ImportModuleLevel(
"bpy_types",
nullptr,
nullptr,
nullptr, 0);
8131 if (bpy_types ==
nullptr) {
8138 Py_DECREF(bpy_types);
8150 PyObject *tp_bases = ((PyTypeObject *)newclass)->tp_bases;
8151 PyObject *tp_slots = PyDict_GetItem(((PyTypeObject *)newclass)->tp_dict,
8154 if (tp_slots ==
nullptr) {
8156 BPY_LOG_RNA,
"expected class '%s' to have __slots__ defined, see bpy_types.py", idname);
8159 else if (PyTuple_GET_SIZE(tp_bases)) {
8160 PyObject *base = PyTuple_GET_ITEM(tp_bases, 0);
8162 if (base_compare != base) {
8163 char pyob_info[256];
8166 "incorrect subclassing of SRNA '%s', expected '%s', see bpy_types.py",
8187 PyObject *newclass =
nullptr;
8190 if (srna ==
nullptr) {
8195 Py_INCREF(newclass);
8200 Py_INCREF(newclass);
8215 PyObject *metaclass;
8222 descr =
"(no docs)";
8232 metaclass = (PyObject *)&PyType_Type;
8237 newclass = PyObject_CallFunction(
8238 metaclass,
"s(O) {sss()}", idname, py_base,
"__module__",
"bpy.types",
"__slots__");
8242 PyObject *args, *item, *value;
8245 args = PyTuple_New(3);
8248 PyTuple_SET_ITEM(args, 0, PyUnicode_FromString(idname));
8251 PyTuple_SET_ITEM(args, 1, item = PyTuple_New(1));
8252 PyTuple_SET_ITEM(item, 0, Py_NewRef(py_base));
8255 PyTuple_SET_ITEM(args, 2, item = PyDict_New());
8262 newclass = PyObject_CallObject(metaclass, args);
8294 if (
ptr->type == &RNA_Struct) {
8322 PyObject *pyptr_rna = PyCapsule_New(
8328 PyObject_CallOneArg(
reinterpret_cast<PyObject *
>(tp), pyptr_rna));
8334 PyObject_CallOneArg(
reinterpret_cast<PyObject *
>(&
pyrna_struct_Type), pyptr_rna));
8337#ifdef USE_PYRNA_STRUCT_REFERENCE
8340 if (pyrna !=
nullptr) {
8341 PyObject_GC_UnTrack(pyrna);
8346 if (pyrna !=
nullptr) {
8347 pyrna->in_weakreflist =
nullptr;
8351 if (pyrna ==
nullptr) {
8352 if (!PyErr_Occurred()) {
8353 PyErr_SetString(PyExc_MemoryError,
"couldn't create bpy_struct object");
8359 Py_DECREF(pyptr_rna);
8367#ifdef PYRNA_FREE_SUPPORT
8368 pyrna->freeptr =
false;
8371#ifdef USE_PYRNA_STRUCT_REFERENCE
8372 pyrna->reference =
nullptr;
8377#ifdef USE_PYRNA_INVALIDATE_WEAKREF
8378 if (
ptr->owner_id) {
8383 return reinterpret_cast<PyObject *
>(pyrna);
8390 if (
ptr->data ==
nullptr &&
ptr->type ==
nullptr) {
8399 if (instance && *instance) {
8403 if (
ptr->type == pyrna->
ptr->type) {
8405 return reinterpret_cast<PyObject *
>(pyrna);
8410 *instance =
nullptr;
8419 return reinterpret_cast<PyObject *
>(pyrna);
8424 if (
ptr->type == &RNA_PrimitiveString) {
8428 if (
ptr->type == &RNA_PrimitiveInt) {
8430 return PyLong_FromLong(
data->value);
8432 if (
ptr->type == &RNA_PrimitiveFloat) {
8434 return PyFloat_FromDouble(
data->value);
8436 if (
ptr->type == &RNA_PrimitiveBoolean) {
8438 return PyBool_FromLong(
data->value);
8464 PyObject *pypropptr_rna = PyCapsule_New(
8468 PyObject_CallOneArg(
reinterpret_cast<PyObject *
>(type), pypropptr_rna));
8470 if (pyrna ==
nullptr) {
8471 PyErr_SetString(PyExc_MemoryError,
"couldn't create BPy_rna object");
8476 Py_DECREF(pypropptr_rna);
8479 pyrna->in_weakreflist =
nullptr;
8482#ifdef USE_PYRNA_INVALIDATE_WEAKREF
8483 if (
ptr->owner_id) {
8488 return (PyObject *)pyrna;
8525#if defined(_MSC_VER)
8558#ifdef USE_PYRNA_ITER
8564#ifdef USE_PYRNA_INVALIDATE_WEAKREF
8572#ifdef USE_PYRNA_INVALIDATE_WEAKREF
8577 const int id_weakref_pool_len =
BLI_ghash_len(id_weakref_pool);
8578 if (id_weakref_pool_len != 0) {
8579 printf(
"Found %d unreleased ID's\n", id_weakref_pool_len);
8586 BLI_ghash_free(id_weakref_pool,
nullptr, id_weakref_pool_free_value_fn);
8587 id_weakref_pool =
nullptr;
8602 return (PyObject *)pyrna;
8619PyObject *BPY_rna_doc()
8641 std::optional<PointerRNA>
ptr;
8653 const char *name = PyUnicode_AsUTF8(pyname);
8655 if (name ==
nullptr) {
8656 PyErr_SetString(PyExc_AttributeError,
"bpy.types: __getattr__ must be a string");
8662 if (
ret ==
nullptr) {
8663 PyErr_Format(PyExc_RuntimeError,
8664 "bpy.types.%.200s subtype could not be generated, this is a bug!",
8665 PyUnicode_AsUTF8(pyname));
8670 PyErr_Format(PyExc_AttributeError,
8671 "bpy.types.%.200s RNA_Struct does not exist",
8672 PyUnicode_AsUTF8(pyname));
8676 ret = PyObject_GenericGetAttr(
self, pyname);
8687 PyObject *
ret = PyList_New(0);
8696 PyObject *submodule_dict = PyModule_GetDict(
self);
8697 PyObject *key, *value;
8699 while (PyDict_Next(submodule_dict, &
pos, &key, &value)) {
8700 PyList_Append(
ret, key);
8707# pragma clang diagnostic push
8708# pragma clang diagnostic ignored "-Wcast-function-type"
8710# pragma GCC diagnostic push
8711# pragma GCC diagnostic ignored "-Wcast-function-type"
8718 {
nullptr,
nullptr, 0,
nullptr},
8723# pragma clang diagnostic pop
8725# pragma GCC diagnostic pop
8735 PyObject *submodule =
static_cast<PyObject *
>(
self);
8737 PyModule_GetState(submodule));
8739 state->ptr.~optional();
8744 bpy_types_module_doc,
8745 "Access to internal Blender types");
8749 bpy_types_module_doc,
8762 PyModule_GetState(submodule));
8769 static PyTypeObject *pyrna_types[] = {
8779 PyObject *submodule_dict = PyModule_GetDict(submodule);
8781 PyDict_SetItemString(submodule_dict, pyrna_types[
i]->tp_name, (PyObject *)pyrna_types[
i]);
8801 PyModule_GetState(submodule));
8804 PyObject *arg_key, *arg_value;
8805 Py_ssize_t arg_pos = 0;
8806 while (PyDict_Next(
bpy_types_dict, &arg_pos, &arg_key, &arg_value)) {
8807 const char *key_str = PyUnicode_AsUTF8(arg_key);
8808 if (key_str[0] ==
'_') {
8814 "Members of bpy_types.py which are not StructRNA sub-classes must use a \"_\" prefix!");
8830 if (
STREQ(key_str,
"USDHook")) {
8835 BPY_LOG_RNA,
"bpy_types.py defines \"%.200s\" which is not a known RNA type!", key_str);
8855 if (PyType_Check(
self)) {
8858 Py_XINCREF(py_srna);
8864 if (py_srna ==
nullptr) {
8869 if (py_srna ==
nullptr) {
8870 PyErr_Format(PyExc_RuntimeError,
8871 "%.200s, missing bl_rna attribute from '%.200s' instance (may not be registered)",
8873 Py_TYPE(
self)->tp_name);
8878 PyErr_Format(PyExc_TypeError,
8879 "%.200s, bl_rna attribute wrong type '%.200s' on '%.200s'' instance",
8881 Py_TYPE(py_srna)->tp_name,
8882 Py_TYPE(
self)->tp_name);
8887 if (py_srna->
ptr->type != &RNA_Struct) {
8888 PyErr_Format(PyExc_TypeError,
8889 "%.200s, bl_rna attribute not a RNA_Struct, on '%.200s'' instance",
8891 Py_TYPE(
self)->tp_name);
8906 PyErr_Format(PyExc_TypeError,
8907 "Expected a \"bpy.types.%.200s\" not a \"%.200s\"",
8909 Py_TYPE(py_obj)->tp_name);
8913 return &bpy_srna->
ptr.value();
8918 if (py_obj == Py_None) {
8929 if (srna_parse->
ptr ==
nullptr) {
8940 if (srna_parse->
ptr ==
nullptr) {
8950 if (
self ==
nullptr) {
8953 if (PyCapsule_CheckExact(
self)) {
8954 return static_cast<StructRNA *
>(PyCapsule_GetPointer(
self,
nullptr));
8956 if (PyType_Check(
self) == 0) {
8980 PyObject *py_func =
static_cast<PyObject *
>(((
BPy_PropDeferred *)item)->fn);
8982 PyObject *py_srna_cobject, *py_ret;
8986 PyMethodDef *py_func_method_def = ((PyCFunctionObject *)py_func)->m_ml;
8987 const char *func_name = py_func_method_def->ml_name;
8989 PyObject *args_fake;
8990 const char *key_str = PyUnicode_AsUTF8(key);
8992 if (*key_str ==
'_') {
8993 PyErr_Format(PyExc_ValueError,
8994 "bpy_struct \"%.200s\" registration error: "
8995 "'%.200s' %.200s could not register because it starts with an '_'",
9001 py_srna_cobject = PyCapsule_New(srna,
nullptr,
nullptr);
9006 args_fake = PyTuple_New(1);
9007 PyTuple_SET_ITEM(args_fake, 0, py_srna_cobject);
9009 PyObject *type = PyDict_GetItemString(py_kw,
"type");
9013 PyCFunctionWithKeywords py_func_ref = *(
9014 PyCFunctionWithKeywords)(
void *)PyCFunction_GET_FUNCTION(py_func);
9018 PyErr_Format(PyExc_ValueError,
9019 "bpy_struct \"%.200s\" registration error: "
9020 "'%.200s' %.200s could not register because "
9021 "this type doesn't support data-block properties",
9031 py_ret = PyObject_Call(py_func, args_fake, py_kw);
9035 Py_DECREF(args_fake);
9042 Py_DECREF(args_fake);
9044 PyErr_Format(PyExc_ValueError,
9045 "bpy_struct \"%.200s\" registration error: "
9046 "'%.200s' %.200s could not register (see previous error)",
9061 PyObject *annotations_dict =
nullptr;
9065 PyObject *typing_mod = PyImport_ImportModuleLevel(
"typing",
nullptr,
nullptr,
nullptr, 0);
9066 if (typing_mod !=
nullptr) {
9067 PyObject *get_type_hints_fn = PyObject_GetAttrString(typing_mod,
"get_type_hints");
9068 if (get_type_hints_fn !=
nullptr) {
9069 PyObject *args = PyTuple_New(1);
9071 PyTuple_SET_ITEM(args, 0, (PyObject *)py_class);
9072 Py_INCREF(py_class);
9074 annotations_dict = PyObject_CallObject(get_type_hints_fn, args);
9077 Py_DECREF(get_type_hints_fn);
9079 Py_DECREF(typing_mod);
9084 if (annotations_dict !=
nullptr) {
9085 if (PyDict_CheckExact(annotations_dict)) {
9086 PyObject *item, *key;
9089 while (PyDict_Next(annotations_dict, &
pos, &key, &item)) {
9098 PyErr_Format(PyExc_TypeError,
9099 "typing.get_type_hints returned: %.200s, expected dict\n",
9100 Py_TYPE(annotations_dict)->tp_name);
9104 Py_DECREF(annotations_dict);
9108 fprintf(stderr,
"typing.get_type_hints failed with: %.200s\n", py_class->tp_name);
9117 PyObject *annotations_dict;
9118 PyObject *item, *key;
9125 PyDict_CheckExact(annotations_dict))
9127 while (PyDict_Next(annotations_dict, &
pos, &key, &item)) {
9141 const int len = PyTuple_GET_SIZE(py_class->tp_bases);
9145 for (
i = 0;
i <
len;
i++) {
9146 PyTypeObject *py_superclass = (PyTypeObject *)PyTuple_GET_ITEM(py_class->tp_bases,
i);
9157 if (py_superclass != &PyBaseObject_Type &&
9158 !PyObject_IsSubclass((PyObject *)py_superclass, (PyObject *)&
pyrna_struct_Type))
9181#ifdef USE_POSTPONED_ANNOTATIONS
9182 const bool use_postponed_annotations =
true;
9184 const bool use_postponed_annotations =
false;
9187 if (use_postponed_annotations) {
9199 int count = is_staticmethod ? 0 : 1;
9200 bool done_min_count =
false;
9210 done_min_count =
true;
9216 if (!done_min_count && min_count) {
9233 bool *have_function)
9238 PyObject *py_class = (PyObject *)py_data;
9241 int i, arg_count, func_arg_count, func_arg_min_count = 0;
9242 const char *py_class_name = ((PyTypeObject *)py_class)->tp_name;
9251 if (!PyObject_IsSubclass(py_class, base_class)) {
9252 PyErr_Format(PyExc_TypeError,
9253 "expected %.200s subclass of class \"%.200s\"",
9271 have_function[
i] = (item !=
nullptr);
9274 if (item ==
nullptr) {
9276 PyErr_Format(PyExc_AttributeError,
9277 "expected %.200s, %.200s class to have an \"%.200s\" attribute",
9295 PyObject *item_orig = item;
9297 if (is_staticmethod) {
9298 if (PyMethod_Check(item) == 0) {
9299 PyErr_Format(PyExc_TypeError,
9300 "expected %.200s, %.200s class \"%.200s\" "
9301 "attribute to be a static/class method, not a %.200s",
9305 Py_TYPE(item)->tp_name);
9306 Py_DECREF(item_orig);
9309 item = ((PyMethodObject *)item)->im_func;
9312 if (PyFunction_Check(item) == 0) {
9313 PyErr_Format(PyExc_TypeError,
9314 "expected %.200s, %.200s class \"%.200s\" "
9315 "attribute to be a function, not a %.200s",
9319 Py_TYPE(item)->tp_name);
9320 Py_DECREF(item_orig);
9327 if (func_arg_count >= 0) {
9328 arg_count = ((PyCodeObject *)PyFunction_GET_CODE(item))->co_argcount;
9333 if (is_staticmethod) {
9335 func_arg_min_count++;
9338 if (arg_count < func_arg_min_count || arg_count > func_arg_count) {
9339 if (func_arg_min_count != func_arg_count) {
9342 "expected %.200s, %.200s class \"%.200s\" function to have between %d and %d "
9354 "expected %.200s, %.200s class \"%.200s\" function to have %d args, found %d",
9361 Py_DECREF(item_orig);
9365 Py_DECREF(item_orig);
9371 const char *identifier;
9381 item = PyObject_GetAttrString(py_class, identifier);
9383 if (item ==
nullptr) {
9387#define BPY_REPLACEMENT_STRING(rna_attr, py_attr) \
9388 else if (STREQ(identifier, rna_attr)) { \
9389 if ((item = PyObject_GetAttr(py_class, py_attr))) { \
9390 if (item != Py_None) { \
9391 if (pyrna_py_to_prop(dummy_ptr, prop, nullptr, item, "validating class:") != 0) { \
9408#undef BPY_REPLACEMENT_STRING
9411 PyErr_Format(PyExc_AttributeError,
9412 "expected %.200s, %.200s class to have an \"%.200s\" attribute",
9422 if (
pyrna_py_to_prop(dummy_ptr, prop,
nullptr, item,
"validating class:") != 0) {
9442 PyObject *
ret =
nullptr, *py_srna =
nullptr, *py_class_instance =
nullptr, *parmitem;
9443 PyTypeObject *py_class;
9447 int err = 0,
i, ret_len = 0;
9453 void *retdata_single =
nullptr;
9455 PyGILState_STATE gilstate;
9457#ifdef USE_PEDANTIC_WRITE
9467 if (py_class ==
nullptr) {
9469 "unable to get Python class for RNA struct '%.200s'",
9486 if (!(is_staticmethod || is_classmethod)) {
9493 py_class_instance =
static_cast<PyObject *
>(*instance);
9494 Py_INCREF(py_class_instance);
9500 if (py_class_instance ==
nullptr) {
9504 if (py_class_instance) {
9507 else if (py_srna ==
nullptr) {
9508 py_class_instance =
nullptr;
9509 if (PyErr_Occurred()) {
9513 else if (py_srna == Py_None) {
9515 py_class_instance =
nullptr;
9516 if (PyErr_Occurred()) {
9527 if (py_class->tp_init) {
9528# ifdef USE_PEDANTIC_WRITE
9535 args = PyTuple_New(0);
9536 if (py_class->tp_init(py_srna, args,
nullptr) < 0) {
9542# ifdef USE_PEDANTIC_WRITE
9546 py_class_instance = py_srna;
9549# ifdef USE_PEDANTIC_WRITE
9558 py_class_instance = py_srna;
9559 Py_INCREF(py_class_instance);
9566 py_class_instance = PyObject_CallOneArg(
reinterpret_cast<PyObject *
>(py_class), py_srna);
9568# ifdef USE_PEDANTIC_WRITE
9574 if (py_class_instance ==
nullptr) {
9575 if (PyErr_Occurred()) {
9585 if (err != -1 && (is_staticmethod || is_classmethod || py_class_instance)) {
9588 const bool item_type_valid = (item !=
nullptr) &&
9589 (is_staticmethod ? PyMethod_Check(item) : PyFunction_Check(item));
9590 if (item_type_valid) {
9597 if (is_staticmethod) {
9599 ((PyCodeObject *)PyFunction_GET_CODE(((PyMethodObject *)item)->im_func))->co_argcount -
9603 arg_count = ((PyCodeObject *)PyFunction_GET_CODE(item))->co_argcount;
9605 args = PyTuple_New(arg_count);
9607 if (is_staticmethod) {
9610 else if (is_classmethod) {
9611 PyTuple_SET_ITEM(args, 0, (PyObject *)py_class);
9615 PyTuple_SET_ITEM(args, 0, py_class_instance);
9628 if (pret_single ==
nullptr) {
9630 retdata_single = iter.
data;
9636 if (
i < arg_count) {
9638 PyTuple_SET_ITEM(args,
i, parmitem);
9643#ifdef USE_PEDANTIC_WRITE
9650 ret = PyObject_Call(item, args,
nullptr);
9654#ifdef USE_PEDANTIC_WRITE
9665 PyErr_Format(PyExc_TypeError,
9666 "could not find function %.200s in %.200s to execute callback",
9675 PyErr_Format(PyExc_RuntimeError,
9676 "could not create instance of %.200s to call callback function '%.200s'",
9683 if (
ret ==
nullptr) {
9687 if (ret_len == 0 &&
ret != Py_None) {
9688 PyErr_Format(PyExc_RuntimeError,
9689 "expected class %.200s, function %.200s to return None, not %.200s",
9692 Py_TYPE(
ret)->tp_name);
9695 else if (ret_len == 1) {
9704 "class %.200s, function %.200s: incompatible return value ",
9709 else if (ret_len > 1) {
9711 if (PyTuple_Check(
ret) == 0) {
9714 "expected class %.200s, function %.200s to return a tuple of size %d, not %.200s",
9718 Py_TYPE(
ret)->tp_name);
9721 else if (PyTuple_GET_SIZE(
ret) != ret_len) {
9722 PyErr_Format(PyExc_RuntimeError,
9723 "class %.200s, function %.200s to returned %d items, expected %d",
9726 PyTuple_GET_SIZE(
ret),
9741 &funcptr, parm, iter.
data, PyTuple_GET_ITEM(
ret,
i++),
"calling class function:");
9757 if ((!is_staticmethod) && (!is_classmethod) && (
ptr->data) &&
9788#ifdef WITH_PYTHON_MODULE
9798 if (!Py_IsInitialized()) {
9803 PyGILState_STATE gilstate = PyGILState_Ensure();
9818 if (
self->ob_refcnt > 1) {
9828 PyGILState_Release(gilstate);
9836 bool decref =
false;
9845 if (PyObject *bases = cls->tp_bases) {
9846 const int bases_num = PyTuple_GET_SIZE(bases);
9847 for (
int i = 0;
i < bases_num;
i++) {
9848 PyTypeObject *base_cls = (PyTypeObject *)PyTuple_GET_ITEM(bases,
i);
9850 if (base_cls->tp_dict) {
9863 return base_cls_test;
9875 PyObject *subclasses =
static_cast<PyObject *
>(cls->tp_subclasses);
9878 PyObject *key =
nullptr;
9880 PyObject *value =
nullptr;
9881 while (PyDict_Next(subclasses, &
pos, &key, &value)) {
9883 PyObject *value_ref = PyWeakref_GET_OBJECT(value);
9884 if (value_ref == Py_None) {
9888 PyTypeObject *sub_cls =
reinterpret_cast<PyTypeObject *
>(value_ref);
9889 if (sub_cls->tp_dict) {
9902 return sub_cls_test;
9916 PyGILState_STATE gilstate = PyGILState_Ensure();
9926 if (item ==
nullptr) {
9927 if (PyErr_Occurred()) {
9938 PyGILState_Release(gilstate);
9958#define BPY_TYPEDEF_REGISTERABLE_DOC \
9960 ":class:`bpy.types.Panel` | " \
9961 ":class:`bpy.types.UIList` | " \
9962 ":class:`bpy.types.Menu` | " \
9963 ":class:`bpy.types.Header` | " \
9964 ":class:`bpy.types.Operator` | " \
9965 ":class:`bpy.types.KeyingSetInfo` | " \
9966 ":class:`bpy.types.RenderEngine` | " \
9967 ":class:`bpy.types.AssetShelf` | " \
9968 ":class:`bpy.types.FileHandler` | " \
9969 ":class:`bpy.types.PropertyGroup` | " \
9970 ":class:`bpy.types.AddonPreferences` | " \
9971 ":class:`bpy.types.NodeTree` | " \
9972 ":class:`bpy.types.Node` | " \
9973 ":class:`bpy.types.NodeSocket`" \
9989 pyrna_register_class_doc,
9990 ".. function:: register_class(cls)\n"
9992 " Register a subclass of a Blender type class.\n"
9994 " :arg cls: Registerable Blender class type.\n"
9998 " :raises ValueError:\n"
9999 " if the class is not a subclass of a registerable blender class.\n"
10003 " If the class has a *register* class method it will be called\n"
10004 " before registration.\n");
10014 const char *identifier;
10015 PyObject *py_cls_meth;
10016 const char *error_prefix =
"register_class(...):";
10018 if (!PyType_Check(py_class)) {
10019 PyErr_Format(PyExc_ValueError,
10020 "%s expected a class argument, not '%.200s'",
10022 Py_TYPE(py_class)->tp_name);
10027 PyErr_Format(PyExc_ValueError,
10028 "%s already registered as a subclass '%.200s'",
10030 ((PyTypeObject *)py_class)->tp_name);
10043 (PyTypeObject *)py_class))
10046 "%s warning, %.200s: references and already registered base-class %.200s\n",
10048 ((PyTypeObject *)py_class)->tp_name,
10049 base_cls_test->tp_name);
10052 (PyTypeObject *)py_class))
10055 "%s warning, %.200s: references and already registered sub-class %.200s\n",
10057 ((PyTypeObject *)py_class)->tp_name,
10058 sub_cls_test->tp_name);
10063 PyErr_Format(PyExc_RuntimeError,
10064 "%s can't run in readonly state '%.200s'",
10066 ((PyTypeObject *)py_class)->tp_name);
10072 if (srna ==
nullptr) {
10079 PyErr_Format(PyExc_ValueError,
10080 "%s %.200s's parent class %.200s is already registered, this is not allowed",
10082 ((PyTypeObject *)py_class)->tp_name,
10092 PyErr_Format(PyExc_ValueError,
10093 "%s expected a subclass of a registerable "
10094 "RNA type (%.200s does not support registration)",
10106 identifier = ((PyTypeObject *)py_class)->tp_name;
10131 if (srna_new ==
nullptr) {
10141 Py_DECREF(old_py_class);
10156 PyObject *
ret = PyObject_CallObject(py_cls_meth,
nullptr);
10157 Py_DECREF(py_cls_meth);
10176 const char **r_prop_identifier)
10206 pyrna_unregister_class_doc,
10207 ".. function:: unregister_class(cls)\n"
10209 " Unload the Python class from blender.\n"
10211 " :arg cls: Blender type class, \n"
10212 " see :mod:`bpy.utils.register_class` for classes which can \n"
10213 " be registered.\n"
10219 " If the class has an *unregister* class method it will be called\n"
10220 " before unregistering.\n");
10222 "unregister_class",
10225 pyrna_unregister_class_doc,
10232 PyObject *py_cls_meth;
10233 const char *error_prefix =
"unregister_class(...):";
10235 if (!PyType_Check(py_class)) {
10236 PyErr_Format(PyExc_ValueError,
10237 "%s expected a class argument, not '%.200s'",
10239 Py_TYPE(py_class)->tp_name);
10245 PyErr_Format(PyExc_ValueError,
"%s not a registered as a subclass", error_prefix);
10251 PyErr_Format(PyExc_RuntimeError,
10252 "%s can't run in readonly state '%.200s'",
10254 ((PyTypeObject *)py_class)->tp_name);
10259 if (srna ==
nullptr) {
10264 PyErr_Format(PyExc_RuntimeError,
10265 "%s can't unregister a built-in class '%.200s'",
10267 ((PyTypeObject *)py_class)->tp_name);
10275 PyErr_Format(PyExc_ValueError,
10276 "%s expected type '%.200s' subclassed from a registerable RNA type "
10277 "(unregister not supported)",
10279 ((PyTypeObject *)py_class)->tp_name);
10287 PyObject *
ret = PyObject_CallObject(py_cls_meth,
nullptr);
10288 Py_DECREF(py_cls_meth);
10307 const char *prop_identifier =
nullptr;
10314 srna_iter =
static_cast<StructRNA *
>(itemptr.data);
10321 if (prop_identifier) {
10322 PyErr_Format(PyExc_RuntimeError,
10323 "%s can't unregister %s because %s.%s pointer property is using this",
10358 PyObject *dict = type->tp_dict;
10359 if (method !=
nullptr) {
10360 for (; method->ml_name !=
nullptr; method++) {
10361 PyObject *py_method;
10363 if (method->ml_flags & METH_CLASS) {
10364 PyObject *cfunc = PyCFunction_New(method, (PyObject *)type);
10365 py_method = PyClassMethod_New(cfunc);
10368 else if (method->ml_flags & METH_STATIC) {
10369 py_method = PyCFunction_New(method,
nullptr);
10372 py_method = PyDescr_NewMethod(type, method);
10375 const int err = PyDict_SetItemString(dict, method->ml_name, py_method);
10376 Py_DECREF(py_method);
10382 if (getset !=
nullptr) {
10383 for (; getset->name !=
nullptr; getset++) {
10384 PyObject *descr = PyDescr_NewGetSet(type, getset);
10386 BLI_assert(PyDict_GetItem(dict, PyDescr_NAME(descr)) ==
nullptr);
10387 PyDict_SetItem(dict, PyDescr_NAME(descr), descr);
10406 return PyUnicode_FromString(name);
10414 if (value == Py_None) {
10417 else if (PyUnicode_Check(value)) {
10418 name = PyUnicode_AsUTF8(value);
10421 PyErr_Format(PyExc_ValueError,
10423 "expected None or a string, not '%.200s'",
10424 Py_TYPE(value)->tp_name);
10433# pragma clang diagnostic push
10434# pragma clang diagnostic ignored "-Wcast-function-type"
10436# pragma GCC diagnostic push
10437# pragma GCC diagnostic ignored "-Wcast-function-type"
10442 "_bl_owner_id_get",
10448 "_bl_owner_id_set",
10456# pragma clang diagnostic pop
10458# 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
@ CTX_DATA_TYPE_COLLECTION
Main * CTX_data_main(const bContext *C)
wmWindowManager * CTX_wm_manager(const bContext *C)
IDProperty * IDP_GetPropertyFromGroup(const IDProperty *prop, blender::StringRef name) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL()
void IDP_FreeFromGroup(IDProperty *group, IDProperty *prop) ATTR_NONNULL()
bool IDP_ui_data_supported(const IDProperty *prop)
void IDP_FreeProperty(IDProperty *prop)
const char * BKE_idtype_idcode_to_name(short idcode)
const char * BKE_idtype_idcode_to_name_plural(short idcode)
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
StructRNA *(*)(Main *bmain, ReportList *reports, void *data, const char *identifier, StructValidateFunc validate, StructCallbackFunc call, StructFreeFunc free) StructRegisterFunc
#define RNA_ENUM_BITFLAG_SIZE
bool(*)(Main *bmain, StructRNA *type) StructUnregisterFunc
@ PROP_PATH_SUPPORTS_BLEND_RELATIVE
BMesh const char void * data
ATTR_WARN_UNUSED_RESULT const BMVert * v
void BPy_reports_write_stdout(const ReportList *reports, const char *header)
short BPy_reports_to_error(ReportList *reports, PyObject *exception, const bool clear)
bool BPy_errors_to_report(ReportList *reports)
void bpy_context_clear(struct bContext *C, const PyGILState_STATE *gilstate)
void bpy_context_set(struct bContext *C, PyGILState_STATE *gilstate)
struct bContext * BPY_context_get()
PyObject * bpy_intern_str_bpy_types
PyObject * bpy_intern_str___name__
PyObject * bpy_intern_str_register
PyObject * bpy_intern_str_bl_rna
PyObject * bpy_intern_str___module__
PyObject * bpy_intern_str___doc__
PyObject * bpy_intern_str_attr
PyObject * bpy_intern_str___annotations__
PyObject * bpy_intern_str_unregister
PyObject * bpy_intern_str___slots__
PyObject * bpy_intern_str_properties
PyObject * BPy_CollectionProperty(PyObject *self, PyObject *args, PyObject *kw)
PyObject * BPy_PointerProperty(PyObject *self, PyObject *args, PyObject *kw)
#define BPy_PropDeferred_CheckTypeExact(v)
#define PYRNA_STACK_ARRAY
static PyModuleDef bpy_types_module_def
static PyTypeObject pyrna_prop_collection_iter_Type
static PyObject * pyrna_struct_is_property_overridable_library(BPy_StructRNA *self, PyObject *args)
const PointerRNA * pyrna_struct_as_ptr(PyObject *py_obj, const StructRNA *srna)
static PyObject * pyrna_prop_collection_subscript_slice(BPy_PropertyRNA *self, Py_ssize_t start, Py_ssize_t stop)
static int mathutils_rna_vector_set(BaseMathObject *bmo, int subtype)
static PyObject * pyrna_prop_collection_get(BPy_PropertyRNA *self, PyObject *args)
PyDoc_STRVAR(pyrna_struct_keys_doc, ".. method:: keys()\n" "\n" " Returns the keys of this objects custom properties (matches Python's\n" " dictionary function of the same name).\n" "\n" " :return: custom property keys.\n" " :rtype: :class:`idprop.types.IDPropertyGroupViewKeys`\n" "\n" BPY_DOC_ID_PROP_TYPE_NOTE)
static int pyrna_property_init(PyObject *self, PyObject *args, PyObject *)
PyTypeObject pyrna_struct_meta_idprop_Type
PyTypeObject pyrna_prop_Type
static PyObject * pyrna_register_class(PyObject *self, PyObject *py_class)
static PyObject * pyrna_bl_owner_id_get(PyObject *)
void pyrna_invalidate(BPy_DummyPointerRNA *self)
static PyObject * pyrna_struct_dir(BPy_StructRNA *self)
StructRNA * pyrna_struct_as_srna(PyObject *self, const bool parent, const char *error_prefix)
static PyTypeObject * bpy_class_check_any_bases_registered(PyTypeObject *cls)
static int pyrna_struct_compare(BPy_StructRNA *a, BPy_StructRNA *b)
static PyObject * pyrna_prop_array_repr(BPy_PropertyArrayRNA *self)
static int pyrna_prop_array_contains(BPy_PropertyRNA *self, PyObject *value)
static int pyrna_py_to_prop_array_index(BPy_PropertyArrayRNA *self, int index, PyObject *value)
static Py_ssize_t pyrna_prop_array_length(BPy_PropertyArrayRNA *self)
static PointerRNA * rna_module_ptr
static int pyrna_prop_array_ass_subscript(BPy_PropertyArrayRNA *self, PyObject *key, PyObject *value)
#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