14#define PY_SSIZE_T_CLEAN
34#include "RNA_prototypes.hh"
56#define BPY_PROPDEF_OPTIONS_DOC \
57 " :arg options: Enumerator in :ref:`rna_enum_property_flag_items`.\n" \
58 " :type options: set[str]\n"
60#define BPY_PROPDEF_OPTIONS_ENUM_DOC \
61 " :arg options: Enumerator in :ref:`rna_enum_property_flag_enum_items`.\n" \
62 " :type options: set[str]\n"
64#define BPY_PROPDEF_OPTIONS_OVERRIDE_DOC \
65 " :arg override: Enumerator in :ref:`rna_enum_property_override_flag_items`.\n" \
66 " :type override: set[str]\n"
68#define BPY_PROPDEF_OPTIONS_OVERRIDE_COLLECTION_DOC \
69 " :arg override: Enumerator in :ref:`rna_enum_property_override_flag_collection_items`.\n" \
70 " :type override: set[str]\n"
72#define BPY_PROPDEF_SUBTYPE_STRING_DOC \
73 " :arg subtype: Enumerator in :ref:`rna_enum_property_subtype_string_items`.\n" \
74 " :type subtype: str\n"
76#define BPY_PROPDEF_SUBTYPE_NUMBER_DOC \
77 " :arg subtype: Enumerator in :ref:`rna_enum_property_subtype_number_items`.\n" \
78 " :type subtype: str\n"
80#define BPY_PROPDEF_SUBTYPE_NUMBER_ARRAY_DOC \
81 " :arg subtype: Enumerator in :ref:`rna_enum_property_subtype_number_array_items`.\n" \
82 " :type subtype: str\n"
179#define BPY_PROP_STORE_PY_DATA_SIZE (sizeof(BPyPropStore::py_data) / sizeof(PyObject *))
181#define ASSIGN_PYOBJECT_INCREF(a, b) \
183 BLI_assert((a) == nullptr); \
198 if (prop_store ==
nullptr) {
212 if (prop_store ==
nullptr) {
216 PyObject **py_data = (PyObject **)&prop_store->
py_data;
218 Py_XDECREF(py_data[
i]);
235 PyObject_GC_UnTrack(
self);
237 PyObject_GC_Del(
self);
254 return PyUnicode_FromFormat(
"<%.200s, %R, %R>", Py_TYPE(
self)->tp_name,
self->fn,
self->kw);
279 PyObject *
ret =
static_cast<PyObject *
>(
self->fn);
298 {
nullptr,
nullptr,
nullptr,
nullptr,
nullptr}
303 bpy_prop_deferred_doc,
304 "Intermediate storage for properties before registration.\n"
308 " This is not part of the stable API and may change between releases.\n");
310 PyVarObject_HEAD_INIT(
nullptr, 0)
329 Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC,
330 bpy_prop_deferred_doc,
373 PyObject_GC_Track(
self);
374 return (PyObject *)
self;
398 PyObject *
self =
nullptr;
406 self =
static_cast<PyObject *
>(*instance);
413 if (
self ==
nullptr) {
433 if (flag_mask_clear) {
454 const PyGILState_STATE gilstate = PyGILState_Ensure();
467 PyGILState_Release(prop_state.
gilstate);
491 if ((this->len_total != other.
len_total) || (this->dims_len != other.
dims_len)) {
494 for (
int i = 0;
i < this->dims_len;
i++) {
495 if (this->dims[
i] != other.
dims[
i]) {
510 if (PyLong_CheckExact(o)) {
512 if ((
size = PyLong_AsLong(o)) == -1) {
514 PyExc_ValueError,
"expected number or sequence of numbers, got %s", Py_TYPE(o)->tp_name);
529 if (!(seq_fast = PySequence_Fast(o,
"size must be a number of a sequence of numbers"))) {
532 const int seq_len = PySequence_Fast_GET_SIZE(seq_fast);
542 PyObject **seq_items = PySequence_Fast_ITEMS(seq_fast);
544 for (
int i = 0;
i < seq_len;
i++) {
546 if ((
size = PyLong_AsLong(seq_items[
i])) == -1) {
548 PyErr_Format(PyExc_ValueError,
549 "expected number in sequence, got %s at index %d",
556 PyErr_Format(PyExc_TypeError,
575 size_t values_elem_size,
578 const PyTypeObject *type,
579 const char *error_str)
581 if (array_len_info->
dims_len == 0) {
583 values, values_elem_size, py_values, array_len_info->
len_total, type, error_str);
585 const int *dims = array_len_info->
dims;
586 const int dims_len = array_len_info->
dims_len;
587 return PyC_AsArray_Multi(values, values_elem_size, py_values, dims, dims_len, type, error_str);
593 const PyTypeObject &type)
595 PyObject *py_values =
nullptr;
597 if (&type == &PyBool_Type) {
604 static_cast<const bool *
>(values), array_len_info.
dims, array_len_info.
dims_len);
607 else if (&type == &PyLong_Type) {
614 static_cast<const int *
>(values), array_len_info.
dims, array_len_info.
dims_len);
617 else if (&type == &PyFloat_Type) {
625 static_cast<const float *
>(values), array_len_info.
dims, array_len_info.
dims_len);
639 ((array_len_info->
dims[0] >= 2) && (array_len_info->
dims[0] <= 4)) &&
640 ((array_len_info->
dims[1] >= 2) && (array_len_info->
dims[1] <= 4)));
654 const float *values_src,
658 const int dim0 = array_len_info->
dims[0], dim1 = array_len_info->
dims[1];
660 for (
int i = 0;
i < dim0;
i++) {
661 for (
int j = 0; j < dim1; j++) {
662 values_dst[(j * dim0) +
i] = values_src[(
i * dim1) + j];
670 const int dim0 = array_len_info->
dims[0], dim1 = array_len_info->
dims[1];
672 float values_orig[4 * 4];
673 memcpy(values_orig, values,
sizeof(
float) * (dim0 * dim1));
688 PyGILState_STATE gilstate;
704 PyObject *args = PyTuple_New(2);
709 ret = PyObject_CallObject(py_func, args);
714 if (
ret ==
nullptr) {
718 if (
ret != Py_None) {
719 PyErr_SetString(PyExc_ValueError,
"the return value must be None");
753 PyObject *args = PyTuple_New(1);
757 ret = PyObject_CallObject(py_func, args);
762 if (
ret ==
nullptr) {
769 if (value_i == -1 && PyErr_Occurred()) {
774 value = bool(value_i);
801 PyObject *args = PyTuple_New(3);
805 ret = PyObject_CallObject(py_func, args);
810 bool ret_value = curr_value;
811 if (
ret ==
nullptr) {
817 if (value_i == -1 && PyErr_Occurred()) {
821 ret_value = bool(value_i);
845 PyObject *args = PyTuple_New(2);
849 ret = PyObject_CallObject(py_func, args);
854 if (
ret ==
nullptr) {
858 if (
ret != Py_None) {
859 PyErr_SetString(PyExc_ValueError,
"the return value must be None");
883 PyObject *args = PyTuple_New(4);
887 PyBool_FromLong(new_value),
888 PyBool_FromLong(curr_value),
889 PyBool_FromLong(is_set));
891 ret = PyObject_CallObject(py_func, args);
896 bool ret_value = curr_value;
897 if (
ret ==
nullptr) {
903 if (value_i == -1 && PyErr_Occurred()) {
907 ret_value = bool(value_i);
923 bool is_values_set =
false;
925 if (bool_array_obj !=
nullptr) {
931 "BoolVectorProperty get callback") == -1)
936 is_values_set =
true;
940 if (is_values_set ==
false) {
947 Py_XDECREF(bool_array_obj);
964 PyObject *args = PyTuple_New(1);
968 ret = PyObject_CallObject(py_func, args);
993 PyObject *args = PyTuple_New(3);
999 PyBool_FromLong(is_set));
1001 ret = PyObject_CallObject(py_func, args);
1026 PyObject *args = PyTuple_New(2);
1031 ret = PyObject_CallObject(py_func, args);
1036 if (
ret ==
nullptr) {
1040 if (
ret != Py_None) {
1041 PyErr_SetString(PyExc_ValueError,
"the return value must be None");
1053 const bool *new_values,
1054 const bool *curr_values,
1056 bool *r_final_values)
1071 PyObject *args = PyTuple_New(4);
1078 PyBool_FromLong(is_set));
1080 ret = PyObject_CallObject(py_func, args);
1110 PyObject *args = PyTuple_New(1);
1114 ret = PyObject_CallObject(py_func, args);
1119 if (
ret ==
nullptr) {
1124 value = PyC_Long_AsI32(
ret);
1126 if (value == -1 && PyErr_Occurred()) {
1155 PyObject *args = PyTuple_New(3);
1159 ret = PyObject_CallObject(py_func, args);
1164 int ret_value = curr_value;
1165 if (
ret ==
nullptr) {
1169 ret_value = PyC_Long_AsI32(
ret);
1171 if (ret_value == -1 && PyErr_Occurred()) {
1173 ret_value = curr_value;
1197 PyObject *args = PyTuple_New(2);
1201 ret = PyObject_CallObject(py_func, args);
1206 if (
ret ==
nullptr) {
1210 if (
ret != Py_None) {
1211 PyErr_SetString(PyExc_ValueError,
"the return value must be None");
1235 PyObject *args = PyTuple_New(4);
1239 PyLong_FromLong(new_value),
1240 PyLong_FromLong(curr_value),
1241 PyBool_FromLong(is_set));
1243 ret = PyObject_CallObject(py_func, args);
1248 int ret_value = curr_value;
1249 if (
ret ==
nullptr) {
1253 ret_value = PyC_Long_AsI32(
ret);
1255 if (ret_value == -1 && PyErr_Occurred()) {
1257 ret_value = curr_value;
1273 bool is_values_set =
false;
1275 if (int_array_obj !=
nullptr) {
1281 "IntVectorProperty get callback") == -1)
1286 is_values_set =
true;
1290 if (is_values_set ==
false) {
1297 Py_XDECREF(int_array_obj);
1314 PyObject *args = PyTuple_New(1);
1318 ret = PyObject_CallObject(py_func, args);
1343 PyObject *args = PyTuple_New(3);
1349 PyBool_FromLong(is_set));
1351 ret = PyObject_CallObject(py_func, args);
1376 PyObject *args = PyTuple_New(2);
1381 ret = PyObject_CallObject(py_func, args);
1386 if (
ret ==
nullptr) {
1390 if (
ret != Py_None) {
1391 PyErr_SetString(PyExc_ValueError,
"the return value must be None");
1403 const int *new_values,
1404 const int *curr_values,
1406 int *r_final_values)
1421 PyObject *args = PyTuple_New(4);
1428 PyBool_FromLong(is_set));
1430 ret = PyObject_CallObject(py_func, args);
1460 PyObject *args = PyTuple_New(1);
1464 ret = PyObject_CallObject(py_func, args);
1469 if (
ret ==
nullptr) {
1474 value = PyFloat_AsDouble(
ret);
1476 if (value == -1.0f && PyErr_Occurred()) {
1505 PyObject *args = PyTuple_New(3);
1509 ret = PyObject_CallObject(py_func, args);
1514 float ret_value = curr_value;
1515 if (
ret ==
nullptr) {
1519 ret_value = PyFloat_AsDouble(
ret);
1521 if (ret_value == -1.0f && PyErr_Occurred()) {
1523 ret_value = curr_value;
1547 PyObject *args = PyTuple_New(2);
1551 ret = PyObject_CallObject(py_func, args);
1556 if (
ret ==
nullptr) {
1560 if (
ret != Py_None) {
1561 PyErr_SetString(PyExc_ValueError,
"the return value must be None");
1585 PyObject *args = PyTuple_New(4);
1589 PyFloat_FromDouble(new_value),
1590 PyFloat_FromDouble(curr_value),
1591 PyBool_FromLong(is_set));
1593 ret = PyObject_CallObject(py_func, args);
1598 float ret_value = curr_value;
1599 if (
ret ==
nullptr) {
1603 ret_value = PyFloat_AsDouble(
ret);
1605 if (ret_value == -1.0f && PyErr_Occurred()) {
1607 ret_value = curr_value;
1619 PyObject *float_array_obj,
1622 const bool do_matrix_row_col_swap,
1625 bool is_values_set =
false;
1627 if (float_array_obj !=
nullptr) {
1633 "FloatVectorProperty get callback") == -1)
1643 is_values_set =
true;
1647 if (is_values_set ==
false) {
1654 Py_XDECREF(float_array_obj);
1671 PyObject *args = PyTuple_New(1);
1675 ret = PyObject_CallObject(py_func, args);
1701 PyObject *args = PyTuple_New(3);
1707 PyBool_FromLong(is_set));
1709 ret = PyObject_CallObject(py_func, args);
1716 const bool do_matrix_row_col_swap = prop_store->
py_data.
get_fn ==
nullptr;
1718 prop,
ret, array_len_info, py_func, do_matrix_row_col_swap, r_values);
1738 PyObject *args = PyTuple_New(2);
1743 ret = PyObject_CallObject(py_func, args);
1748 if (
ret ==
nullptr) {
1752 if (
ret != Py_None) {
1753 PyErr_SetString(PyExc_ValueError,
"the return value must be None");
1765 const float *new_values,
1766 const float *curr_values,
1768 float *r_final_values)
1783 PyObject *args = PyTuple_New(4);
1790 PyBool_FromLong(is_set));
1792 ret = PyObject_CallObject(py_func, args);
1799 prop,
ret, array_len_info, py_func,
false, r_final_values);
1811 const size_t max_length,
1814 std::optional<std::string> ret_value{};
1817 if (str_obj ==
nullptr) {
1820 else if (!PyUnicode_Check(str_obj)) {
1822 PyExc_TypeError,
"return value must be a string, not %.200s", Py_TYPE(str_obj)->tp_name);
1828 const char *ret_cstr = PyUnicode_AsUTF8AndSize(str_obj, &
length);
1829 if (max_length &&
size_t(
length) + 1 > max_length) {
1830 PyErr_Format(PyExc_ValueError,
1831 "return string must be of max length %zu, not %d",
1837 ret_value = {ret_cstr, size_t(
length)};
1841 Py_XDECREF(str_obj);
1856 PyObject *args = PyTuple_New(1);
1860 ret = PyObject_CallObject(py_func, args);
1882 const std::string &curr_value,
1895 PyObject *args = PyTuple_New(3);
1900 PyUnicode_FromStringAndSize(curr_value.c_str(), Py_ssize_t(curr_value.size())),
1901 PyBool_FromLong(is_set));
1903 ret = PyObject_CallObject(py_func, args);
1909 .value_or(curr_value);
1914 const std::string &curr_value,
1953 PyObject *args = PyTuple_New(2);
1958 if (max_length && value.size() >= max_length) {
1959 PyErr_Format(PyExc_ValueError,
1960 "the given string must be of max length %zu, not %zu",
1965 PyObject *py_value = PyUnicode_FromStringAndSize(value.c_str(), value.size());
1967 PyErr_SetString(PyExc_ValueError,
1968 "the given string value cannot be converted into a python string");
1971 Py_INCREF(py_value);
1975 ret = PyObject_CallObject(py_func, args);
1980 if (
ret ==
nullptr) {
1984 if (
ret != Py_None) {
1985 PyErr_SetString(PyExc_ValueError,
"the return value must be None");
1997 const std::string &new_value,
1998 const std::string &curr_value,
2012 PyObject *args = PyTuple_New(4);
2017 PyUnicode_FromStringAndSize(new_value.c_str(), Py_ssize_t(new_value.size())),
2018 PyUnicode_FromStringAndSize(curr_value.c_str(), Py_ssize_t(curr_value.size())),
2019 PyBool_FromLong(is_set));
2021 ret = PyObject_CallObject(py_func, args);
2028 .value_or(curr_value);
2041 const char *info =
nullptr;
2043 if (PyTuple_CheckExact(item)) {
2045 static const char *_keywords[] = {
2050 static _PyArg_Parser _parser = {
2058 if (!_PyArg_ParseTupleAndKeywordsFast(item,
nullptr, &_parser, &text, &info)) {
2064 text = PyUnicode_AsUTF8(item);
2067 PyErr_Format(PyExc_TypeError,
2068 "expected sequence of strings or tuple pairs of strings, not %.200s",
2069 Py_TYPE(item)->tp_name);
2076 visit_params.
text = text;
2077 visit_params.
info = info ? info :
"";
2078 visit_fn(visit_params);
2086 const char *edit_text,
2089 PyGILState_STATE gilstate;
2094 gilstate = PyGILState_Ensure();
2106 PyObject *args = PyTuple_New(3);
2109 PyObject *py_edit_text = PyUnicode_FromString(edit_text);
2110 Py_INCREF(py_context);
2113 ret = PyObject_CallObject(py_func, args);
2118 if (
ret ==
nullptr) {
2122 if (PyIter_Check(
ret)) {
2125 PyObject *(*iternext)(PyObject *);
2126 it = PyObject_GetIter(
ret);
2127 if (it ==
nullptr) {
2131 iternext = *Py_TYPE(it)->tp_iternext;
2133 PyObject *py_text = iternext(it);
2134 if (py_text ==
nullptr) {
2144 if (PyErr_Occurred()) {
2145 if (PyErr_ExceptionMatches(PyExc_StopIteration)) {
2156 PyObject *ret_fast = PySequence_Fast(
2158 "StringProperty(...): "
2159 "return value from search callback was not a sequence, iterator or generator");
2160 if (ret_fast ==
nullptr) {
2164 const Py_ssize_t ret_num = PySequence_Fast_GET_SIZE(ret_fast);
2165 PyObject **ret_fast_items = PySequence_Fast_ITEMS(ret_fast);
2166 for (Py_ssize_t
i = 0;
i < ret_num;
i++) {
2183 PyGILState_Release(gilstate);
2207 PyObject *args = PyTuple_New(2);
2212 ret = PyObject_CallObject(py_func, args);
2217 if (
ret ==
nullptr) {
2251 PyObject *args = PyTuple_New(1);
2255 ret = PyObject_CallObject(py_func, args);
2260 if (
ret ==
nullptr) {
2265 value = PyC_Long_AsI32(
ret);
2267 if (value == -1 && PyErr_Occurred()) {
2296 PyObject *args = PyTuple_New(3);
2300 ret = PyObject_CallObject(py_func, args);
2305 int ret_value = curr_value;
2306 if (
ret ==
nullptr) {
2310 ret_value = PyC_Long_AsI32(
ret);
2312 if (ret_value == -1 && PyErr_Occurred()) {
2314 ret_value = curr_value;
2338 PyObject *args = PyTuple_New(2);
2342 ret = PyObject_CallObject(py_func, args);
2347 if (
ret ==
nullptr) {
2351 if (
ret != Py_None) {
2352 PyErr_SetString(PyExc_ValueError,
"the return value must be None");
2376 PyObject *args = PyTuple_New(4);
2380 PyLong_FromLong(new_value),
2381 PyLong_FromLong(curr_value),
2382 PyBool_FromLong(is_set));
2384 ret = PyObject_CallObject(py_func, args);
2389 int ret_value = curr_value;
2390 if (
ret ==
nullptr) {
2394 ret_value = PyC_Long_AsI32(
ret);
2396 if (ret_value == -1 && PyErr_Occurred()) {
2398 ret_value = curr_value;
2412 if (PyLong_CheckExact(py_long)) {
2413 *r_int = int(PyLong_AS_LONG(py_long));
2420#ifdef USE_ENUM_COPY_STRINGS
2422static size_t strswapbufcpy(
char *buf,
const char **orig)
2424 const char *src = *orig;
2428 while ((*dst = *src)) {
2454 const bool is_enum_flag,
2455 PyObject *default_py,
2456 int *r_default_value)
2460 const Py_ssize_t seq_len = PySequence_Fast_GET_SIZE(seq_fast);
2461 PyObject **seq_fast_items = PySequence_Fast_ITEMS(seq_fast);
2463#ifdef USE_ENUM_COPY_STRINGS
2464 Py_ssize_t totbuf = 0;
2466 short default_used = 0;
2467 const char *default_str_cmp =
nullptr;
2468 int default_int_cmp = 0;
2472 PyErr_SetString(PyExc_TypeError,
2473 "EnumProperty(...): maximum " STRINGIFY(
2477 if (default_py && !PySet_Check(default_py)) {
2478 PyErr_Format(PyExc_TypeError,
2479 "EnumProperty(...): default option must be a 'set' "
2480 "type when ENUM_FLAG is enabled, not a '%.200s'",
2481 Py_TYPE(default_py)->tp_name);
2488 default_str_cmp = PyUnicode_AsUTF8(default_py);
2489 if (default_str_cmp ==
nullptr) {
2490 PyErr_Format(PyExc_TypeError,
2491 "EnumProperty(...): default option must be a 'str' or 'int' "
2492 "type when ENUM_FLAG is disabled, not a '%.200s'",
2493 Py_TYPE(default_py)->tp_name);
2501 *r_default_value = 0;
2505 for (
i = 0;
i < seq_len;
i++) {
2507 const char *tmp_icon =
nullptr;
2508 Py_ssize_t item_size;
2509 Py_ssize_t id_str_len;
2510 Py_ssize_t name_str_len;
2511 Py_ssize_t desc_str_len;
2513 item = seq_fast_items[
i];
2515 if (PyTuple_CheckExact(item) && (item_size = PyTuple_GET_SIZE(item)) &&
2516 (item_size >= 3 && item_size <= 5) &&
2517 (tmp.
identifier = PyUnicode_AsUTF8AndSize(PyTuple_GET_ITEM(item, 0), &id_str_len)) &&
2518 (tmp.
name = PyUnicode_AsUTF8AndSize(PyTuple_GET_ITEM(item, 1), &name_str_len)) &&
2519 (tmp.
description = PyUnicode_AsUTF8AndSize(PyTuple_GET_ITEM(item, 2), &desc_str_len)) &&
2523 (tmp_icon = PyUnicode_AsUTF8(PyTuple_GET_ITEM(item, 3)))) &&
2527 if (item_size < 4) {
2531 if (default_py && PySet_Contains(default_py, PyTuple_GET_ITEM(item, 0))) {
2532 *r_default_value |= tmp.
value;
2537 if (item_size < 4) {
2541 if (default_py && default_used == 0) {
2542 if ((default_str_cmp !=
nullptr &&
STREQ(default_str_cmp, tmp.
identifier)) ||
2543 (default_str_cmp ==
nullptr && default_int_cmp == tmp.
value))
2545 *r_default_value = tmp.
value;
2557#ifdef USE_ENUM_COPY_STRINGS
2559 totbuf += id_str_len + name_str_len + desc_str_len + 3;
2562 else if (item == Py_None) {
2568 PyErr_SetString(PyExc_TypeError,
2569 "EnumProperty(...): expected a tuple containing "
2570 "(identifier, name, description) and optionally an "
2571 "icon name and unique number");
2578 if (default_py && default_used != PySet_GET_SIZE(default_py)) {
2581 PyErr_Format(PyExc_TypeError,
2582 "EnumProperty(..., default={...}): set has %d unused member(s)",
2583 PySet_GET_SIZE(default_py) - default_used);
2588 if (default_py && default_used == 0) {
2591 if (default_str_cmp) {
2592 PyErr_Format(PyExc_TypeError,
2593 "EnumProperty(..., default=\'%s\'): not found in enum members",
2597 PyErr_Format(PyExc_TypeError,
2598 "EnumProperty(..., default=%d): not found in enum members",
2605#ifdef USE_ENUM_COPY_STRINGS
2610 (
sizeof(
char) * totbuf),
2611 "enum_items_from_py2");
2613 char *buf = ((
char *)items_dup) + (
sizeof(
EnumPropertyItem) * (seq_len + 1));
2615 for (
i = 0;
i < seq_len;
i++, items_ptr++) {
2616 buf += strswapbufcpy(buf, &items_ptr->
identifier);
2617 buf += strswapbufcpy(buf, &items_ptr->
name);
2618 buf += strswapbufcpy(buf, &items_ptr->
description);
2634 PyGILState_STATE gilstate;
2639 gilstate = PyGILState_Ensure();
2650 PyObject *args = PyTuple_New(2);
2653 Py_INCREF(py_context);
2656 items = PyObject_CallObject(py_func, args);
2661 if (items ==
nullptr) {
2665 PyObject *items_fast;
2666 int default_value_dummy = 0;
2668 if (!(items_fast = PySequence_Fast(items,
2669 "EnumProperty(...): "
2670 "return value from the callback was not a sequence")))
2678 &default_value_dummy);
2703 PyGILState_Release(gilstate);
2711 if (py_func && py_func != Py_None) {
2712 if (!PyFunction_Check(py_func)) {
2713 PyErr_Format(PyExc_TypeError,
2714 "%s keyword: expected a function type, not a %.200s",
2716 Py_TYPE(py_func)->tp_name);
2720 PyCodeObject *f_code = (PyCodeObject *)PyFunction_GET_CODE(py_func);
2721 if (f_code->co_argcount != argcount) {
2722 PyErr_Format(PyExc_TypeError,
2723 "%s keyword: expected a function taking %d arguments, not %d",
2726 f_code->co_argcount);
2743 if (update_fn && update_fn != Py_None) {
2753 if (poll_fn && poll_fn != Py_None) {
2764 PyObject *get_transform_fn,
2765 PyObject *set_transform_fn)
2772 if (get_fn && get_fn != Py_None) {
2779 if (set_fn && set_fn != Py_None) {
2781 PyErr_SetString(PyExc_ValueError,
2782 "The `set` callback is defined without a matching `get` function, this is "
2783 "not supported. `set_transform` should probably be used instead?");
2793 if (get_transform_fn && get_transform_fn != Py_None) {
2800 if (set_transform_fn && set_transform_fn != Py_None) {
2808 prop, rna_get_fn, rna_set_fn, rna_get_transform_fn, rna_set_transform_fn);
2816 PyObject *get_transform_fn,
2817 PyObject *set_transform_fn)
2824 if (get_fn && get_fn != Py_None) {
2831 if (set_fn && set_fn != Py_None) {
2833 PyErr_SetString(PyExc_ValueError,
2834 "The `set` callback is defined without a matching `get` function, this is "
2835 "not supported. `set_transform` should probably be used instead?");
2845 if (get_transform_fn && get_transform_fn != Py_None) {
2852 if (set_transform_fn && set_transform_fn != Py_None) {
2860 prop, rna_get_fn, rna_set_fn, rna_get_transform_fn, rna_set_transform_fn);
2868 PyObject *get_transform_fn,
2869 PyObject *set_transform_fn)
2876 if (get_fn && get_fn != Py_None) {
2883 if (set_fn && set_fn != Py_None) {
2885 PyErr_SetString(PyExc_ValueError,
2886 "The `set` callback is defined without a matching `get` function, this is "
2887 "not supported. `set_transform` should probably be used instead?");
2897 if (get_transform_fn && get_transform_fn != Py_None) {
2904 if (set_transform_fn && set_transform_fn != Py_None) {
2912 prop, rna_get_fn, rna_set_fn,
nullptr, rna_get_transform_fn, rna_set_transform_fn);
2920 PyObject *get_transform_fn,
2921 PyObject *set_transform_fn)
2928 if (get_fn && get_fn != Py_None) {
2935 if (set_fn && set_fn != Py_None) {
2937 PyErr_SetString(PyExc_ValueError,
2938 "The `set` callback is defined without a matching `get` function, this is "
2939 "not supported. `set_transform` should probably be used instead?");
2948 if (get_transform_fn && get_transform_fn != Py_None) {
2955 if (set_transform_fn && set_transform_fn != Py_None) {
2963 prop, rna_get_fn, rna_set_fn,
nullptr, rna_get_transform_fn, rna_set_transform_fn);
2969 PyObject *get_transform_fn,
2970 PyObject *set_transform_fn)
2977 if (get_fn && get_fn != Py_None) {
2984 if (set_fn && set_fn != Py_None) {
2986 PyErr_SetString(PyExc_ValueError,
2987 "The `set` callback is defined without a matching `get` function, this is "
2988 "not supported. `set_transform` should probably be used instead?");
2998 if (get_transform_fn && get_transform_fn != Py_None) {
3005 if (set_transform_fn && set_transform_fn != Py_None) {
3013 prop, rna_get_fn, rna_set_fn,
nullptr, rna_get_transform_fn, rna_set_transform_fn);
3021 PyObject *get_transform_fn,
3022 PyObject *set_transform_fn)
3029 if (get_fn && get_fn != Py_None) {
3036 if (set_fn && set_fn != Py_None) {
3038 PyErr_SetString(PyExc_ValueError,
3039 "The `set` callback is defined without a matching `get` function, this is "
3040 "not supported. `set_transform` should probably be used instead?");
3049 if (get_transform_fn && get_transform_fn != Py_None) {
3056 if (set_transform_fn && set_transform_fn != Py_None) {
3064 prop, rna_get_fn, rna_set_fn,
nullptr, rna_get_transform_fn, rna_set_transform_fn);
3070 PyObject *get_transform_fn,
3071 PyObject *set_transform_fn,
3072 PyObject *search_fn,
3082 if (get_fn && get_fn != Py_None) {
3090 if (set_fn && set_fn != Py_None) {
3092 PyErr_SetString(PyExc_ValueError,
3093 "The `set` callback is defined without a matching `get` function, this is "
3094 "not supported. `set_transform` should probably be used instead?");
3104 if (get_transform_fn && get_transform_fn != Py_None) {
3111 if (set_transform_fn && set_transform_fn != Py_None) {
3126 prop, rna_get_fn, rna_length_fn, rna_set_fn, rna_get_transform_fn, rna_set_transform_fn);
3127 if (rna_search_fn) {
3138 PyObject *get_transform_fn,
3139 PyObject *set_transform_fn)
3147 if (get_fn && get_fn != Py_None) {
3154 if (set_fn && set_fn != Py_None) {
3156 PyErr_SetString(PyExc_ValueError,
3157 "The `set` callback is defined without a matching `get` function, this is "
3158 "not supported. `set_transform` should probably be used instead?");
3168 if (itemf_fn && itemf_fn != Py_None) {
3174 if (get_transform_fn && get_transform_fn != Py_None) {
3181 if (set_transform_fn && set_transform_fn != Py_None) {
3189 prop, rna_get_fn, rna_set_fn, rna_itemf_fn, rna_get_transform_fn, rna_set_transform_fn);
3216 PyObject *method_object,
3217 PyObject **r_deferred_result)
3220 BLI_assert(PyCFunction_CheckExact(method_object));
3222 const int args_len = PyTuple_GET_SIZE(args);
3223 PyMethodDef *method_def = ((PyCFunctionObject *)method_object)->m_ml;
3226 if (args_len == 1) {
3227 self = PyTuple_GET_ITEM(args, 0);
3228 args = PyTuple_New(0);
3231 PyCFunctionWithKeywords method_fn = (PyCFunctionWithKeywords)(
void *)method_def->ml_meth;
3232 *r_deferred_result = method_fn(
self, args, kw);
3238 const char *error_prefix = method_def->ml_name;
3240 PyErr_Format(PyExc_ValueError,
"%s: all args must be keywords", error_prefix);
3241 *r_deferred_result =
nullptr;
3247 if (srna ==
nullptr) {
3248 *r_deferred_result = PyErr_Occurred() ?
3257 *r_deferred_result = (PyObject *)intptr_t(1);
3284 if (!PyUnicode_Check(o)) {
3285 PyErr_Format(PyExc_TypeError,
"expected a string (got %.200s)", Py_TYPE(o)->tp_name);
3292 id = PyUnicode_AsUTF8AndSize(o, &id_len);
3294 PyErr_Format(PyExc_TypeError,
"'%.200s' too long, max length is %d",
id,
MAX_IDPROP_NAME - 1);
3302 PyErr_Format(PyExc_TypeError,
3303 "'%s' is defined as a non-dynamic type for '%s'",
3308 parse_data->
value = id;
3328 if (parse_data->
base.
items ==
nullptr) {
3329 PyErr_Format(PyExc_TypeError,
3330 "property-tags not available for '%s'",
3343#define BPY_PROPDEF_NAME_DOC \
3344 " :arg name: Name used in the user interface.\n" \
3345 " :type name: str\n"
3347#define BPY_PROPDEF_DESC_DOC \
3348 " :arg description: Text used for the tooltip and api documentation.\n" \
3349 " :type description: str\n"
3351#define BPY_PROPDEF_CTXT_DOC \
3352 " :arg translation_context: Text used as context to disambiguate translations.\n" \
3353 " :type translation_context: str\n"
3355#define BPY_PROPDEF_UNIT_DOC \
3356 " :arg unit: Enumerator in :ref:`rna_enum_property_unit_items`.\n" \
3357 " :type unit: str\n"
3359#define BPY_PROPDEF_NUM_MIN_DOC_(ty) \
3360 " :arg min: Hard minimum, trying to assign a value below will silently assign this minimum " \
3362 " :type min: " ty "\n"
3364#define BPY_PROPDEF_NUM_MAX_DOC_(ty) \
3365 " :arg max: Hard maximum, trying to assign a value above will silently assign this maximum " \
3367 " :type max: " ty "\n"
3369#define BPY_PROPDEF_NUM_MINMAX_DOC(ty) BPY_PROPDEF_NUM_MIN_DOC_(ty) BPY_PROPDEF_NUM_MAX_DOC_(ty)
3371#define BPY_PROPDEF_NUM_SOFT_MIN_DOC_(ty) \
3372 " :arg soft_min: Soft minimum (>= *min*), " \
3373 "user won't be able to drag the widget below this value in the UI.\n" \
3374 " :type soft_min: " ty "\n"
3376#define BPY_PROPDEF_NUM_SOFT_MAX_DOC_(ty) \
3377 " :arg soft_max: Soft maximum (<= *max*), " \
3378 "user won't be able to drag the widget above this value in the UI.\n" \
3379 " :type soft_max: " ty "\n"
3381#define BPY_PROPDEF_NUM_SOFT_MINMAX_DOC(ty) \
3382 BPY_PROPDEF_NUM_SOFT_MIN_DOC_(ty) BPY_PROPDEF_NUM_SOFT_MAX_DOC_(ty)
3384#define BPY_PROPDEF_VECSIZE_DOC \
3385 " :arg size: Vector dimensions in [1, " STRINGIFY(PYRNA_STACK_ARRAY) "]. " \
3386"An int sequence can be used to define multi-dimension arrays.\n" \
3387" :type size: int | Sequence[int]\n"
3389#define BPY_PROPDEF_INT_STEP_DOC \
3390 " :arg step: Step of increment/decrement in UI, in [1, 100], defaults to 1 (WARNING: unused " \
3392 " :type step: int\n"
3394#define BPY_PROPDEF_FLOAT_STEP_DOC \
3395 " :arg step: Step of increment/decrement in UI, in [1, 100], defaults to 3 (WARNING: actual " \
3396 "value is /100).\n" \
3397 " :type step: int\n"
3399#define BPY_PROPDEF_FLOAT_PREC_DOC \
3400 " :arg precision: Maximum number of decimal digits to display, in [0, 6]. Fraction is " \
3401 "automatically hidden for exact integer values of fields with unit 'NONE' or 'TIME' (frame " \
3402 "count) and step divisible by 100.\n" \
3403 " :type precision: int\n"
3405#define BPY_PROPDEF_UPDATE_DOC \
3406 " :arg update: Function to be called when this value is modified,\n" \
3407 " This function must take 2 values (self, context) and return None.\n" \
3408 " *Warning* there are no safety checks to avoid infinite recursion.\n" \
3409 " :type update: Callable[[:class:`bpy.types.bpy_struct`, :class:`bpy.types.Context`], " \
3412#define BPY_PROPDEF_POLL_DOC \
3413 " :arg poll: Function that determines whether an item is valid for this property.\n" \
3414 " The function must take 2 values (self, object) and return a boolean.\n" \
3416 " .. note:: The return value will be checked only when assigning an item from the UI, " \
3417 "but it is still possible to assign an \"invalid\" item to the property directly.\n" \
3419 " :type poll: Callable[[:class:`bpy.types.bpy_struct`, :class:`bpy.types.ID`], " \
3422#define BPY_PROPDEF_GET_DOC(ty) \
3423 " :arg get: Function to be called when this value is 'read', and the default,\n" \
3424 " system-defined storage is not used for this property.\n" \
3425 " This function must take 1 value (self) and return the value of the property.\n" \
3427 " .. note:: Defining this callback without a matching ``set`` one will make " \
3428 "the property read-only (even if ``READ_ONLY`` option is not set)." \
3430 " :type get: Callable[[:class:`bpy.types.bpy_struct`], " ty "]\n"
3432#define BPY_PROPDEF_SET_DOC(ty) \
3433 " :arg set: Function to be called when this value is 'written', and the default,\n" \
3434 " system-defined storage is not used for this property.\n" \
3435 " This function must take 2 values (self, value) and return None.\n" \
3437 " .. note:: Defining this callback without a matching ``get`` one is invalid." \
3439 " :type set: Callable[[:class:`bpy.types.bpy_struct`, " ty "], None]\n"
3441#define BPY_PROPDEF_GET_TRANSFORM_DOC(ty) \
3442 " :arg get_transform: Function to be called when this value is 'read',\n" \
3443 " if some additional processing must be performed on the stored value.\n" \
3444 " This function must take three arguments (self, the stored value,\n" \
3445 " and a boolean indicating if the property is currently set),\n" \
3446 " and return the final, transformed value of the property.\n" \
3448 " .. note:: The callback is responsible to ensure that value limits of the property " \
3449 "(min/max, length...) are respected. Otherwise a ValueError exception is raised.\n" \
3451 " :type get_transform: Callable[[:class:`bpy.types.bpy_struct`, " ty ", bool], " ty "]\n"
3453#define BPY_PROPDEF_SET_TRANSFORM_DOC(ty) \
3454 " :arg set_transform: Function to be called when this value is 'written',\n" \
3455 " if some additional processing must be performed on the given value before storing it.\n" \
3456 " This function must take four arguments (self, the given value to store,\n" \
3457 " the currently stored value ('raw' value, without any ``get_transform`` applied to " \
3459 " and a boolean indicating if the property is currently set),\n" \
3460 " and return the final, transformed value of the property.\n" \
3462 " .. note:: The callback is responsible to ensure that value limits (min/max, " \
3463 "length...) are respected. Otherwise a ValueError exception is raised.\n" \
3465 " :type set_transform: " \
3466 "Callable[[:class:`bpy.types.bpy_struct`, " ty ", " ty ", bool], " ty "]\n"
3468#define BPY_PROPDEF_SEARCH_DOC \
3469 " :arg search: Function to be called to show candidates for this string (shown in the UI).\n" \
3470 " This function must take 3 values (self, context, edit_text)\n" \
3471 " and return a sequence, iterator or generator where each item must be:\n" \
3473 " - A single string (representing a candidate to display).\n" \
3474 " - A tuple-pair of strings, where the first is a candidate and the second\n" \
3475 " is additional information about the candidate.\n" \
3476 " :type search: Callable[[:class:`bpy.types.bpy_struct`, :class:`bpy.types.Context`, str], " \
3477 "Iterable[str | tuple[str, str]]" \
3479 " :arg search_options: Set of strings in:\n" \
3481 " - 'SORT' sorts the resulting items.\n" \
3482 " - 'SUGGESTION' lets the user enter values not found in search candidates.\n" \
3483 " **WARNING** disabling this flag causes the search callback to run on redraw,\n" \
3484 " so only disable this flag if it's not likely to cause performance issues.\n" \
3486 " :type search_options: set[str]\n"
3488#define BPY_PROPDEF_POINTER_TYPE_DOC \
3489 " :arg type: A subclass of a property group or ID types.\n" \
3490 " :type type: type[:class:`bpy.types.PropertyGroup` | :class:`bpy.types.ID`]\n"
3492#define BPY_PROPDEF_COLLECTION_TYPE_DOC \
3493 " :arg type: A subclass of a property group.\n" \
3494 " :type type: type[:class:`bpy.types.PropertyGroup`]\n"
3496#define BPY_PROPDEF_TAGS_DOC \
3497 " :arg tags: Enumerator of tags that are defined by parent class.\n" \
3498 " :type tags: set[str]\n"
3501static int bpy_struct_id_used(
StructRNA *srna,
char *identifier)
3523 BPy_BoolProperty_doc,
3524 ".. function:: BoolProperty("
3527 "description=\"\", "
3528 "translation_context=\"*\", "
3530 "options={'ANIMATABLE'}, "
3537 "get_transform=None, "
3538 "set_transform=None)\n"
3540 " Returns a new boolean property definition.\n"
3549 PyObject *deferred_result;
3551 if (srna ==
nullptr) {
3552 return deferred_result;
3557 id_data.
srna = srna;
3559 const char *
name =
nullptr, *description =
"";
3560 const char *translation_context =
nullptr;
3561 bool default_value =
false;
3565 options_enum.
value = 0;
3569 override_enum.
value = 0;
3572 tags_enum.
srna = srna;
3578 PyObject *update_fn =
nullptr;
3579 PyObject *get_fn =
nullptr;
3580 PyObject *set_fn =
nullptr;
3582 PyObject *get_transform_fn =
nullptr;
3583 PyObject *set_transform_fn =
nullptr;
3585 static const char *_keywords[] = {
3589 "translation_context",
3602 static _PyArg_Parser _parser = {
3623 if (!_PyArg_ParseTupleAndKeywordsFast(args,
3630 &translation_context,
3673 if (translation_context) {
3680 if (options_enum.
is_set) {
3683 if (override_enum.
is_set) {
3698 BPy_BoolVectorProperty_doc,
3699 ".. function:: BoolVectorProperty("
3702 "description=\"\", "
3703 "translation_context=\"*\", "
3704 "default=(False, False, False), "
3705 "options={'ANIMATABLE'}, "
3713 "get_transform=None, "
3714 "set_transform=None)\n"
3716 " Returns a new vector boolean property definition.\n"
3718 " :arg default: sequence of booleans the length of *size*.\n"
3729 PyObject *deferred_result;
3732 if (srna ==
nullptr) {
3733 return deferred_result;
3738 id_data.
srna = srna;
3740 const char *
name =
nullptr, *description =
"";
3741 const char *translation_context =
nullptr;
3746 PyObject *default_py =
nullptr;
3750 options_enum.
value = 0;
3754 override_enum.
value = 0;
3757 tags_enum.
srna = srna;
3763 PyObject *update_fn =
nullptr;
3764 PyObject *get_fn =
nullptr;
3765 PyObject *set_fn =
nullptr;
3766 PyObject *get_transform_fn =
nullptr;
3767 PyObject *set_transform_fn =
nullptr;
3769 static const char *_keywords[] = {
3773 "translation_context",
3787 static _PyArg_Parser _parser = {
3805 ":BoolVectorProperty",
3809 if (!_PyArg_ParseTupleAndKeywordsFast(args,
3816 &translation_context,
3837 if (default_py !=
nullptr) {
3840 sizeof(*default_value.
data()),
3844 "BoolVectorProperty(default=sequence)") == -1)
3871 if (array_len_info.
dims_len == 0) {
3873 if (default_py !=
nullptr) {
3879 if (default_py !=
nullptr) {
3885 if (translation_context) {
3892 if (options_enum.
is_set) {
3895 if (override_enum.
is_set) {
3907 BPy_IntProperty_doc,
3908 ".. function:: IntProperty("
3911 "description=\"\", "
3912 "translation_context=\"*\", "
3914 "min=-2**31, max=2**31-1, "
3915 "soft_min=-2**31, soft_max=2**31-1, "
3917 "options={'ANIMATABLE'}, "
3924 "get_transform=None, "
3925 "set_transform=None)\n"
3927 " Returns a new int property definition.\n"
3938 PyObject *deferred_result;
3940 if (srna ==
nullptr) {
3941 return deferred_result;
3946 id_data.
srna = srna;
3948 const char *
name =
nullptr, *description =
"";
3949 const char *translation_context =
nullptr;
3950 int min = INT_MIN,
max = INT_MAX, soft_min = INT_MIN, soft_max = INT_MAX;
3952 int default_value = 0;
3957 options_enum.
value = 0;
3961 override_enum.
value = 0;
3964 tags_enum.
srna = srna;
3970 PyObject *update_fn =
nullptr;
3971 PyObject *get_fn =
nullptr;
3972 PyObject *set_fn =
nullptr;
3973 PyObject *get_transform_fn =
nullptr;
3974 PyObject *set_transform_fn =
nullptr;
3976 static const char *_keywords[] = {
3977 "attr",
"name",
"description",
"translation_context",
3978 "default",
"min",
"max",
"soft_min",
3979 "soft_max",
"step",
"options",
"override",
3980 "tags",
"subtype",
"update",
"get",
3981 "set",
"get_transform",
"set_transform",
nullptr,
3983 static _PyArg_Parser _parser = {
4009 if (!_PyArg_ParseTupleAndKeywordsFast(args,
4016 &translation_context,
4063 if (translation_context) {
4072 if (options_enum.
is_set) {
4075 if (override_enum.
is_set) {
4087 BPy_IntVectorProperty_doc,
4088 ".. function:: IntVectorProperty("
4091 "description=\"\", "
4092 "translation_context=\"*\", "
4093 "default=(0, 0, 0), min=-2**31, max=2**31-1, "
4095 "soft_max=2**31-1, "
4097 "options={'ANIMATABLE'}, "
4105 "get_transform=None, "
4106 "set_transform=None)\n"
4108 " Returns a new vector int property definition.\n"
4110 " :arg default: sequence of ints the length of *size*.\n"
4123 PyObject *deferred_result;
4126 if (srna ==
nullptr) {
4127 return deferred_result;
4132 id_data.
srna = srna;
4134 const char *
name =
nullptr, *description =
"";
4135 const char *translation_context =
nullptr;
4136 int min = INT_MIN,
max = INT_MAX, soft_min = INT_MIN, soft_max = INT_MAX;
4142 PyObject *default_py =
nullptr;
4146 options_enum.
value = 0;
4150 override_enum.
value = 0;
4153 tags_enum.
srna = srna;
4159 PyObject *update_fn =
nullptr;
4160 PyObject *get_fn =
nullptr;
4161 PyObject *set_fn =
nullptr;
4162 PyObject *get_transform_fn =
nullptr;
4163 PyObject *set_transform_fn =
nullptr;
4165 static const char *_keywords[] = {
4166 "attr",
"name",
"description",
"translation_context",
4167 "default",
"min",
"max",
"soft_min",
4168 "soft_max",
"step",
"options",
"override",
4169 "tags",
"subtype",
"size",
"update",
4170 "get",
"set",
"get_transform",
"set_transform",
4173 static _PyArg_Parser _parser = {
4196 ":IntVectorProperty",
4200 if (!_PyArg_ParseTupleAndKeywordsFast(args,
4207 &translation_context,
4233 if (default_py !=
nullptr) {
4236 sizeof(*default_value.
data()),
4240 "IntVectorProperty(default=sequence)") == -1)
4267 if (array_len_info.
dims_len == 0) {
4269 if (default_py !=
nullptr) {
4275 if (default_py !=
nullptr) {
4282 if (translation_context) {
4290 if (options_enum.
is_set) {
4293 if (override_enum.
is_set) {
4305 BPy_FloatProperty_doc,
4306 ".. function:: FloatProperty("
4309 "description=\"\", "
4310 "translation_context=\"*\", "
4312 "min=-3.402823e+38, max=3.402823e+38, "
4313 "soft_min=-3.402823e+38, soft_max=3.402823e+38, "
4316 "options={'ANIMATABLE'}, "
4324 "get_transform=None, "
4325 "set_transform=None)\n"
4327 " Returns a new float (single precision) property definition.\n"
4339 PyObject *deferred_result;
4341 if (srna ==
nullptr) {
4342 return deferred_result;
4347 id_data.
srna = srna;
4349 const char *
name =
nullptr, *description =
"";
4350 const char *translation_context =
nullptr;
4353 float default_value = 0.0f;
4359 options_enum.
value = 0;
4363 override_enum.
value = 0;
4366 tags_enum.
srna = srna;
4376 PyObject *update_fn =
nullptr;
4377 PyObject *get_fn =
nullptr;
4378 PyObject *set_fn =
nullptr;
4379 PyObject *get_transform_fn =
nullptr;
4380 PyObject *set_transform_fn =
nullptr;
4382 static const char *_keywords[] = {
4383 "attr",
"name",
"description",
"translation_context",
4384 "default",
"min",
"max",
"soft_min",
4385 "soft_max",
"step",
"precision",
"options",
4386 "override",
"tags",
"subtype",
"unit",
4387 "update",
"get",
"set",
"get_transform",
4388 "set_transform",
nullptr,
4390 static _PyArg_Parser _parser = {
4418 if (!_PyArg_ParseTupleAndKeywordsFast(args,
4425 &translation_context,
4476 if (translation_context) {
4480 prop, std::max(soft_min,
min), std::min(soft_max,
max),
step, precision);
4485 if (options_enum.
is_set) {
4488 if (override_enum.
is_set) {
4500 BPy_FloatVectorProperty_doc,
4501 ".. function:: FloatVectorProperty("
4504 "description=\"\", "
4505 "translation_context=\"*\", "
4506 "default=(0.0, 0.0, 0.0), "
4507 "min=sys.float_info.min, max=sys.float_info.max, "
4508 "soft_min=sys.float_info.min, soft_max=sys.float_info.max, "
4511 "options={'ANIMATABLE'}, "
4521 " Returns a new vector float property definition.\n"
4523 " :arg default: Sequence of floats the length of *size*.\n"
4537 PyObject *deferred_result;
4540 if (srna ==
nullptr) {
4541 return deferred_result;
4546 id_data.
srna = srna;
4548 const char *
name =
nullptr, *description =
"";
4549 const char *translation_context =
nullptr;
4557 PyObject *default_py =
nullptr;
4561 options_enum.
value = 0;
4565 override_enum.
value = 0;
4568 tags_enum.
srna = srna;
4578 PyObject *update_fn =
nullptr;
4579 PyObject *get_fn =
nullptr;
4580 PyObject *set_fn =
nullptr;
4581 PyObject *get_transform_fn =
nullptr;
4582 PyObject *set_transform_fn =
nullptr;
4584 static const char *_keywords[] = {
4585 "attr",
"name",
"description",
"translation_context",
4586 "default",
"min",
"max",
"soft_min",
4587 "soft_max",
"step",
"precision",
"options",
4588 "override",
"tags",
"subtype",
"unit",
4589 "size",
"update",
"get",
"set",
4590 "get_transform",
"set_transform",
nullptr,
4592 static _PyArg_Parser _parser = {
4617 ":FloatVectorProperty",
4621 if (!_PyArg_ParseTupleAndKeywordsFast(args,
4628 &translation_context,
4657 if (default_py !=
nullptr) {
4660 sizeof(*default_value.
data()),
4664 "FloatVectorProperty(default=sequence)") == -1)
4694 if (array_len_info.
dims_len == 0) {
4696 if (default_py !=
nullptr) {
4702 if (default_py !=
nullptr) {
4709 if (translation_context) {
4713 prop, std::max(soft_min,
min), std::min(soft_max,
max),
step, precision);
4718 if (options_enum.
is_set) {
4721 if (override_enum.
is_set) {
4733 BPy_StringProperty_doc,
4734 ".. function:: StringProperty("
4737 "description=\"\", "
4738 "translation_context=\"*\", "
4741 "options={'ANIMATABLE'}, "
4748 "get_transform=None, "
4749 "set_transform=None, "
4751 "search_options={'SUGGESTION'})\n"
4753 " Returns a new string property definition.\n"
4755 " :arg default: initializer string.\n"
4756 " :type default: str\n"
4757 " :arg maxlen: maximum length of the string.\n"
4767 PyObject *deferred_result;
4769 if (srna ==
nullptr) {
4770 return deferred_result;
4775 id_data.
srna = srna;
4777 const char *
name =
nullptr, *description =
"";
4778 const char *translation_context =
nullptr, *default_value =
"";
4784 options_enum.
value = 0;
4788 override_enum.
value = 0;
4791 tags_enum.
srna = srna;
4797 PyObject *update_fn =
nullptr;
4798 PyObject *get_fn =
nullptr;
4799 PyObject *set_fn =
nullptr;
4800 PyObject *get_transform_fn =
nullptr;
4801 PyObject *set_transform_fn =
nullptr;
4802 PyObject *search_fn =
nullptr;
4807 static const char *_keywords[] = {
4811 "translation_context",
4827 static _PyArg_Parser _parser = {
4851 if (!_PyArg_ParseTupleAndKeywordsFast(args,
4858 &translation_context,
4876 &search_options_enum))
4909 if (default_value && default_value[0]) {
4913 if (translation_context) {
4920 if (options_enum.
is_set) {
4923 if (override_enum.
is_set) {
4941 BPy_EnumProperty_doc,
4942 ".. function:: EnumProperty("
4946 "description=\"\", "
4947 "translation_context=\"*\", "
4949 "options={'ANIMATABLE'}, "
4955 "get_transform=None, "
4956 "set_transform=None)\n"
4958 " Returns a new enumerator property definition.\n"
4960 " :arg items: sequence of enum items formatted:\n"
4961 " ``[(identifier, name, description, icon, number), ...]``.\n"
4963 " The first three elements of the tuples are mandatory.\n"
4965 " :identifier: The identifier is used for Python access.\n"
4966 " An empty identifier means that the item is a separator\n"
4967 " :name: Name for the interface.\n"
4968 " :description: Used for documentation and tooltips.\n"
4969 " :icon: An icon string identifier or integer icon value\n"
4970 " (e.g. returned by :class:`bpy.types.UILayout.icon`)\n"
4971 " :number: Unique value used as the identifier for this item (stored in file data).\n"
4972 " Use when the identifier may need to change. If the *ENUM_FLAG* option is used,\n"
4973 " the values are bit-masks and should be powers of two.\n"
4975 " When an item only contains 4 items they define ``(identifier, name, description, "
4978 " Separators may be added using either None (nameless separator),\n"
4979 " or a regular item tuple with an empty identifier string, in which case the name,\n"
4980 " if non-empty, will be displayed in the UI above the separator line."
4982 " For dynamic values a callback can be passed which returns a list in\n"
4983 " the same format as the static list.\n"
4984 " This function must take 2 arguments ``(self, context)``, **context may be None**.\n"
4988 " There is a known bug with using a callback,\n"
4989 " Python must keep a reference to the strings returned by the callback or Blender\n"
4990 " will misbehave or even crash."
4992 " :type items: Iterable["
4993 "tuple[str, str, str] | "
4994 "tuple[str, str, str, int] | "
4995 "tuple[str, str, str, int, int] | "
4997 "Callable[[:class:`bpy.types.bpy_struct`, :class:`bpy.types.Context` | None], "
5000 "tuple[str, str, str] | "
5001 "tuple[str, str, str, int] | "
5002 "tuple[str, str, str, int, int] | "
5005 " :arg default: The default value for this enum, a string from the identifiers used in "
5006 "*items*, or integer matching an item number.\n"
5007 " If the *ENUM_FLAG* option is used this must be a set of such string identifiers "
5009 " WARNING: Strings cannot be specified for dynamic enums\n"
5010 " (i.e. if a callback function is given as *items* parameter).\n"
5019 PyObject *deferred_result;
5021 if (srna ==
nullptr) {
5022 return deferred_result;
5027 id_data.
srna = srna;
5029 const char *
name =
nullptr, *description =
"";
5030 const char *translation_context =
nullptr;
5031 PyObject *default_py =
nullptr;
5032 int default_value = 0;
5033 PyObject *items, *items_fast;
5039 options_enum.
value = 0;
5043 override_enum.
value = 0;
5046 tags_enum.
srna = srna;
5048 bool is_itemf =
false;
5049 PyObject *update_fn =
nullptr;
5050 PyObject *get_fn =
nullptr;
5051 PyObject *set_fn =
nullptr;
5052 PyObject *get_transform_fn =
nullptr;
5053 PyObject *set_transform_fn =
nullptr;
5055 static const char *_keywords[] = {
5060 "translation_context",
5072 static _PyArg_Parser _parser = {
5093 if (!_PyArg_ParseTupleAndKeywordsFast(args,
5101 &translation_context,
5134 if (default_py == Py_None) {
5137 default_py =
nullptr;
5142 if (PyFunction_Check(items)) {
5143 PyCodeObject *f_code = (PyCodeObject *)PyFunction_GET_CODE(items);
5144 if (f_code->co_argcount != 2) {
5145 PyErr_Format(PyExc_ValueError,
5146 "EnumProperty(...): expected 'items' function to take 2 arguments, not %d",
5147 f_code->co_argcount);
5157 "EnumProperty(...): 'default' can only be an integer when 'items' is a function");
5166 if (!(items_fast = PySequence_Fast(
5168 "EnumProperty(...): "
5169 "expected a sequence of tuples for the enum items or a function")))
5188 srna, id_data.
value, eitems, default_value,
name ?
name : id_data.
value, description);
5192 srna, id_data.
value, eitems, default_value,
name ?
name : id_data.
value, description);
5194 if (translation_context) {
5201 if (options_enum.
is_set) {
5204 if (override_enum.
is_set) {
5209 prop, get_fn, set_fn, (is_itemf ? items :
nullptr), get_transform_fn, set_transform_fn);
5212 if (is_itemf ==
false) {
5229 if (PyErr_Occurred()) {
5231 const char *msg_char = PyUnicode_AsUTF8(msg);
5235 PyExc_TypeError,
"%.200s expected an RNA type, failed with: %s", error_prefix, msg_char);
5239 PyErr_Format(PyExc_TypeError,
5240 "%.200s expected an RNA type, failed with type '%s'",
5242 Py_TYPE(value)->tp_name);
5252 BPy_PointerProperty_doc,
5253 ".. function:: PointerProperty("
5257 "description=\"\", "
5258 "translation_context=\"*\", "
5259 "options={'ANIMATABLE'}, "
5265 " Returns a new pointer property definition.\n"
5270 ".. note:: Pointer properties do not support storing references to embedded IDs "
5271 "(e.g. :class:`bpy.types.Scene.collection`, :class:`bpy.types.Material.node_tree`).\n"
5272 " These should exclusively be referenced and accessed through their owner ID "
5273 "(e.g. the scene or material).\n");
5278 PyObject *deferred_result;
5281 if (srna ==
nullptr) {
5282 return deferred_result;
5287 id_data.
srna = srna;
5289 const char *
name =
nullptr, *description =
"";
5290 const char *translation_context =
nullptr;
5293 PyObject *type = Py_None;
5297 options_enum.
value = 0;
5301 override_enum.
value = 0;
5304 tags_enum.
srna = srna;
5306 PyObject *update_fn =
nullptr, *poll_fn =
nullptr;
5308 static const char *_keywords[] = {
5313 "translation_context",
5321 static _PyArg_Parser _parser = {
5338 if (!_PyArg_ParseTupleAndKeywordsFast(args,
5346 &translation_context,
5364 PyErr_Format(PyExc_TypeError,
5365 "PointerProperty(...) expected an RNA type derived from %.200s or %.200s",
5382 if (translation_context) {
5389 if (options_enum.
is_set) {
5392 if (override_enum.
is_set) {
5410 BPy_CollectionProperty_doc,
5411 ".. function:: CollectionProperty("
5415 "description=\"\", "
5416 "translation_context=\"*\", "
5417 "options={'ANIMATABLE'}, "
5421 " Returns a new collection property definition.\n"
5429 PyObject *deferred_result;
5432 if (srna ==
nullptr) {
5433 return deferred_result;
5438 id_data.
srna = srna;
5440 const char *
name =
nullptr, *description =
"";
5441 const char *translation_context =
nullptr;
5444 PyObject *type = Py_None;
5448 options_enum.
value = 0;
5452 override_enum.
value = 0;
5455 tags_enum.
srna = srna;
5457 static const char *_keywords[] = {
5462 "translation_context",
5468 static _PyArg_Parser _parser = {
5479 ":CollectionProperty",
5483 if (!_PyArg_ParseTupleAndKeywordsFast(args,
5491 &translation_context,
5508 PyErr_Format(PyExc_TypeError,
5509 "CollectionProperty(...) expected an RNA type derived from %.200s",
5519 if (translation_context) {
5526 if (options_enum.
is_set) {
5529 if (override_enum.
is_set) {
5545 BPy_RemoveProperty_doc,
5546 ".. function:: RemoveProperty(cls, attr)\n"
5548 " Removes a dynamically defined property.\n"
5550 " :arg cls: The class containing the property (must be a positional argument).\n"
5551 " :type cls: type\n"
5552 " :arg attr: Property name (must be passed as a keyword).\n"
5553 " :type attr: str\n"
5555 ".. note:: Typically this function doesn't need to be accessed directly.\n"
5556 " Instead use ``del cls.attr``\n");
5561 if (PyTuple_GET_SIZE(args) == 1) {
5563 self = PyTuple_GET_ITEM(args, 0);
5564 args = PyTuple_New(0);
5569 if (PyTuple_GET_SIZE(args) > 1) {
5570 PyErr_SetString(PyExc_ValueError,
"expected one positional arg, one keyword arg");
5575 if (srna ==
nullptr && PyErr_Occurred()) {
5578 if (srna ==
nullptr) {
5579 PyErr_SetString(PyExc_TypeError,
"RemoveProperty(): struct rna not available for this type");
5583 const char *
id =
nullptr;
5585 static const char *_keywords[] = {
5589 static _PyArg_Parser _parser = {
5596 if (!_PyArg_ParseTupleAndKeywordsFast(args, kw, &_parser, &
id)) {
5601 PyErr_Format(PyExc_TypeError,
"RemoveProperty(): '%s' not a defined dynamic property",
id);
5616# pragma clang diagnostic push
5617# pragma clang diagnostic ignored "-Wcast-function-type"
5619# pragma GCC diagnostic push
5620# pragma GCC diagnostic ignored "-Wcast-function-type"
5627 METH_VARARGS | METH_KEYWORDS,
5628 BPy_BoolProperty_doc},
5629 {
"BoolVectorProperty",
5631 METH_VARARGS | METH_KEYWORDS,
5632 BPy_BoolVectorProperty_doc},
5635 METH_VARARGS | METH_KEYWORDS,
5636 BPy_IntProperty_doc},
5637 {
"IntVectorProperty",
5639 METH_VARARGS | METH_KEYWORDS,
5640 BPy_IntVectorProperty_doc},
5643 METH_VARARGS | METH_KEYWORDS,
5644 BPy_FloatProperty_doc},
5645 {
"FloatVectorProperty",
5647 METH_VARARGS | METH_KEYWORDS,
5648 BPy_FloatVectorProperty_doc},
5651 METH_VARARGS | METH_KEYWORDS,
5652 BPy_StringProperty_doc},
5655 METH_VARARGS | METH_KEYWORDS,
5656 BPy_EnumProperty_doc},
5659 METH_VARARGS | METH_KEYWORDS,
5660 BPy_PointerProperty_doc},
5661 {
"CollectionProperty",
5663 METH_VARARGS | METH_KEYWORDS,
5664 BPy_CollectionProperty_doc},
5668 METH_VARARGS | METH_KEYWORDS,
5669 BPy_RemoveProperty_doc},
5670 {
nullptr,
nullptr, 0,
nullptr},
5675# pragma clang diagnostic pop
5677# pragma GCC diagnostic pop
5684 PyObject **py_data = (PyObject **)&prop_store->py_data;
5686 Py_VISIT(py_data[
i]);
5695 PyObject **py_data = (PyObject **)&prop_store->py_data;
5697 Py_CLEAR(py_data[
i]);
5706 "This module defines properties to extend Blender's internal data. The result of these "
5708 " is used to assign properties to classes registered with Blender and can't be used "
5711 ".. note:: All parameters to these functions must be passed as keywords.\n");
5726 PyObject *submodule;
5727 PyObject *submodule_dict;
5730 PyDict_SetItemString(PyImport_GetModuleDict(),
props_module.m_name, submodule);
5733 submodule_dict = PyModule_GetDict(submodule);
5735#define ASSIGN_STATIC(_name) pymeth_##_name = PyDict_GetItemString(submodule_dict, #_name)
#define BLI_assert_unreachable()
#define LISTBASE_FOREACH(type, var, list)
BLI_INLINE void BLI_listbase_clear(ListBase *lb)
void BLI_addtail(ListBase *listbase, void *vlink) ATTR_NONNULL(1)
void BLI_remlink(ListBase *listbase, void *vlink) ATTR_NONNULL(1)
ID and Library types, which are fundamental for SDNA.
Read Guarded memory(de)allocation.
int RNA_def_property_free_identifier(StructOrFunctionRNA *cont_, const char *identifier)
void RNA_def_property_duplicate_pointers(StructOrFunctionRNA *cont_, PropertyRNA *prop)
void RNA_def_property_free_pointers_set_py_data_callback(void(*py_data_clear_fn)(PropertyRNA *prop))
void RNA_def_property_free_identifier_deferred_finish(StructOrFunctionRNA *cont_, void *handle)
int RNA_def_property_free_identifier_deferred_prepare(StructOrFunctionRNA *cont_, const char *identifier, void **handle)
#define RNA_MAX_ARRAY_DIMENSION
int(*)(PointerRNA *ptr, PropertyRNA *prop) EnumPropertyGetFunc
void(*)(PointerRNA *ptr, PropertyRNA *prop, const std::string &value) StringPropertySetFunc
void(*)(PointerRNA *ptr, PropertyRNA *prop, const float *new_values, const float *curr_values, bool is_set, float *r_values) FloatArrayPropertySetTransformFunc
float(*)(PointerRNA *ptr, PropertyRNA *prop, float value, bool is_set) FloatPropertyGetTransformFunc
int(*)(PointerRNA *ptr, PropertyRNA *prop) StringPropertyLengthFunc
@ STRUCT_CONTAINS_DATABLOCK_IDPROPERTIES
void(*)(PointerRNA *ptr, PropertyRNA *prop, const int *new_values, const int *curr_values, bool is_set, int *r_values) IntArrayPropertySetTransformFunc
void(*)(PointerRNA *ptr, PropertyRNA *prop, const bool *r_values) BooleanArrayPropertySetFunc
const EnumPropertyItem *(*)(bContext *C, PointerRNA *ptr, PropertyRNA *prop, bool *r_free) EnumPropertyItemFunc
int(*)(PointerRNA *ptr, PropertyRNA *prop, int value, bool is_set) EnumPropertyGetTransformFunc
void(*)(PointerRNA *ptr, PropertyRNA *prop, float *values) FloatArrayPropertyGetFunc
int(*)(PointerRNA *ptr, PropertyRNA *prop, int value, bool is_set) IntPropertyGetTransformFunc
void(*)(PointerRNA *ptr, PropertyRNA *prop, bool *r_values) BooleanArrayPropertyGetFunc
#define RNA_ENUM_BITFLAG_SIZE
void(*)(PointerRNA *ptr, PropertyRNA *prop, const bool *new_values, const bool *curr_values, bool is_set, bool *r_values) BooleanArrayPropertySetTransformFunc
eStringPropertySearchFlag
@ PROP_STRING_SEARCH_SUGGESTION
void(*)(PointerRNA *ptr, PropertyRNA *prop, int *values) IntArrayPropertyGetFunc
void(*)( PointerRNA *ptr, PropertyRNA *prop, const bool *curr_values, bool is_set, bool *r_values) BooleanArrayPropertyGetTransformFunc
void(*)(PointerRNA *ptr, PropertyRNA *prop, int value) EnumPropertySetFunc
std::string(*)(PointerRNA *ptr, PropertyRNA *prop) StringPropertyGetFunc
void(*)(PointerRNA *ptr, PropertyRNA *prop, const int *values) IntArrayPropertySetFunc
void(*)( PointerRNA *ptr, PropertyRNA *prop, const float *curr_values, bool is_set, float *r_values) FloatArrayPropertyGetTransformFunc
std::string(*)(PointerRNA *ptr, PropertyRNA *prop, const std::string &value, bool is_set) StringPropertyGetTransformFunc
bool(*)(PointerRNA *ptr, PropertyRNA *prop) BooleanPropertyGetFunc
void(*)(const bContext *C, PointerRNA *ptr, PropertyRNA *prop, const char *edit_text, blender::FunctionRef< void(StringPropertySearchVisitParams)> visit_fn) StringPropertySearchFunc
bool(*)(PointerRNA *ptr, PropertyRNA *prop, bool value, bool is_set) BooleanPropertyGetTransformFunc
int(*)(PointerRNA *ptr, PropertyRNA *prop, int new_value, int curr_value, bool is_set) IntPropertySetTransformFunc
float(*)(PointerRNA *ptr, PropertyRNA *prop) FloatPropertyGetFunc
int(*)(PointerRNA *ptr, PropertyRNA *prop) IntPropertyGetFunc
void(*)( PointerRNA *ptr, PropertyRNA *prop, const int *curr_values, bool is_set, int *r_values) IntArrayPropertyGetTransformFunc
float(*)(PointerRNA *ptr, PropertyRNA *prop, float new_value, float curr_value, bool is_set) FloatPropertySetTransformFunc
void(*)(PointerRNA *ptr, PropertyRNA *prop, float value) FloatPropertySetFunc
bool(*)(PointerRNA *ptr, PropertyRNA *prop, bool new_value, bool curr_value, bool is_set) BooleanPropertySetTransformFunc
int(*)(PointerRNA *ptr, PropertyRNA *prop, int new_value, int curr_value, bool is_set) EnumPropertySetTransformFunc
void(*)(PointerRNA *ptr, PropertyRNA *prop, int value) IntPropertySetFunc
std::string(*)(PointerRNA *ptr, PropertyRNA *prop, const std::string &new_value, const std::string &curr_value, bool is_set) StringPropertySetTransformFunc
void(*)(PointerRNA *ptr, PropertyRNA *prop, const float *values) FloatArrayPropertySetFunc
void(*)(PointerRNA *ptr, PropertyRNA *prop, bool value) BooleanPropertySetFunc
void bpy_context_clear(struct bContext *C, const PyGILState_STATE *gilstate)
void bpy_context_set(struct bContext *C, PyGILState_STATE *gilstate)
static std::string bpy_prop_string_get_transform_locked_fn(PointerRNA *ptr, PropertyRNA *prop, const std::string &curr_value, bool is_set)
#define BPY_PROPDEF_SUBTYPE_STRING_DOC
static void bpy_prop_string_visit_for_search_fn(const bContext *C, PointerRNA *ptr, PropertyRNA *prop, const char *edit_text, blender::FunctionRef< void(StringPropertySearchVisitParams)> visit_fn)
PyDoc_STRVAR(bpy_prop_deferred_doc, "Intermediate storage for properties before registration.\n" "\n" ".. note::\n" "\n" " This is not part of the stable API and may change between releases.\n")
static PyObject * pymeth_FloatProperty
static bool bpy_prop_string_visit_fn_call(PyObject *py_func, PyObject *item, blender::FunctionRef< void(StringPropertySearchVisitParams)> visit_fn)
static void bpy_prop_string_set_fn(PointerRNA *ptr, PropertyRNA *prop, const std::string &value)
static void bpy_prop_boolean_array_set_fn(PointerRNA *ptr, PropertyRNA *prop, const bool *values)
static PyObject * BPy_EnumProperty(PyObject *self, PyObject *args, PyObject *kw)
#define ASSIGN_PYOBJECT_INCREF(a, b)
static void bpy_prop_array_matrix_swap_row_column_vn_vn(float *values_dst, const float *values_src, const BPyPropArrayLength *array_len_info)
static PyObject * BPy_FloatProperty(PyObject *self, PyObject *args, PyObject *kw)
static PyModuleDef props_module
static bool bpy_prop_pointer_poll_fn(PointerRNA *self, PointerRNA candidate, PropertyRNA *prop)
static void bpy_prop_callback_assign_int_array(PropertyRNA *prop, PyObject *get_fn, PyObject *set_fn, PyObject *get_transform_fn, PyObject *set_transform_fn)
#define BPY_PROPDEF_OPTIONS_OVERRIDE_COLLECTION_DOC
static PyObject * bpy_py_object_from_prop_array_with_dims(const void *values, const BPyPropArrayLength &array_len_info, const PyTypeObject &type)
static bool py_long_as_int(PyObject *py_long, int *r_int)
static std::string bpy_prop_string_set_transform_fn(PointerRNA *ptr, PropertyRNA *prop, const std::string &new_value, const std::string &curr_value, bool is_set)
PyObject * BPy_CollectionProperty(PyObject *self, PyObject *args, PyObject *kw)
static bool bpy_prop_array_is_matrix_compatible_ex(int subtype, const BPyPropArrayLength *array_len_info)
static std::string bpy_prop_string_get_locked_fn(PointerRNA *ptr, PropertyRNA *prop)
static float bpy_prop_float_get_fn(PointerRNA *ptr, PropertyRNA *prop)
static int bpy_prop_int_get_transform_fn(PointerRNA *ptr, PropertyRNA *prop, int curr_value, bool is_set)
static bool bpy_prop_callback_assign_string(PropertyRNA *prop, PyObject *get_fn, PyObject *set_fn, PyObject *get_transform_fn, PyObject *set_transform_fn, PyObject *search_fn, const eStringPropertySearchFlag search_flag)
#define BPY_PROPDEF_NAME_DOC
static int bpy_prop_int_get_fn(PointerRNA *ptr, PropertyRNA *prop)
static PyGetSetDef bpy_prop_deferred_getset[]
static int bpy_prop_int_set_transform_fn(PointerRNA *ptr, PropertyRNA *prop, int new_value, int curr_value, bool is_set)
#define BPY_PROPDEF_FLOAT_STEP_DOC
static PyObject * pymeth_IntVectorProperty
static void bpy_prop_boolean_array_set_transform_fn(PointerRNA *ptr, PropertyRNA *prop, const bool *new_values, const bool *curr_values, bool is_set, bool *r_final_values)
#define BPY_PROPDEF_UPDATE_DOC
static float bpy_prop_float_set_transform_fn(PointerRNA *ptr, PropertyRNA *prop, float new_value, float curr_value, bool is_set)
static bool bpy_prop_array_is_matrix_compatible(PropertyRNA *prop, const BPyPropArrayLength *array_len_info)
static void bpy_prop_boolean_array_get_fn(PointerRNA *ptr, PropertyRNA *prop, bool *values)
static int bpy_prop_string_length_fn(PointerRNA *ptr, PropertyRNA *prop)
static PyObject * pymeth_EnumProperty
static bool bpy_prop_callback_assign_boolean(PropertyRNA *prop, PyObject *get_fn, PyObject *set_fn, PyObject *get_transform_fn, PyObject *set_transform_fn)
#define BPY_PROPDEF_NUM_SOFT_MINMAX_DOC(ty)
static float bpy_prop_float_get_transform_fn(PointerRNA *ptr, PropertyRNA *prop, float curr_value, bool is_set)
static std::optional< std::string > bpy_prop_string_from_callback_or_error(PyObject *str_obj, const size_t max_length, PyObject *py_func)
static PyObject * bpy_prop_deferred_keywords_get(BPy_PropDeferred *self, void *)
static int bpy_prop_deferred_clear(BPy_PropDeferred *self)
static void bpy_prop_callback_assign_float_array(PropertyRNA *prop, PyObject *get_fn, PyObject *set_fn, PyObject *get_transform_fn, PyObject *set_transform_fn)
static void bpy_prop_py_data_remove(PropertyRNA *prop)
static void bpy_prop_int_array_get_fn(PointerRNA *ptr, PropertyRNA *prop, int *values)
#define BPY_PROPDEF_FLOAT_PREC_DOC
static void bpy_prop_float_array_set_fn(PointerRNA *ptr, PropertyRNA *prop, const float *values)
#define BPY_PROPDEF_POLL_DOC
#define BPY_PROPDEF_NUM_MINMAX_DOC(ty)
static bool bpy_prop_callback_assign_enum(PropertyRNA *prop, PyObject *get_fn, PyObject *set_fn, PyObject *itemf_fn, PyObject *get_transform_fn, PyObject *set_transform_fn)
static PyObject * BPy_BoolVectorProperty(PyObject *self, PyObject *args, PyObject *kw)
static std::string bpy_prop_string_get_fn(PointerRNA *ptr, PropertyRNA *prop)
static PyObject * pymeth_FloatVectorProperty
static PyObject * BPy_StringProperty(PyObject *self, PyObject *args, PyObject *kw)
PyObject * BPy_PointerProperty(PyObject *self, PyObject *args, PyObject *kw)
static void bpy_prop_int_set_fn(PointerRNA *ptr, PropertyRNA *prop, int value)
static PyObject * pymeth_IntProperty
static int bpy_prop_enum_set_transform_fn(PointerRNA *ptr, PropertyRNA *prop, int new_value, int curr_value, bool is_set)
static bool bpy_prop_boolean_get_transform_fn(PointerRNA *ptr, PropertyRNA *prop, bool curr_value, bool is_set)
#define BPY_PROPDEF_SET_DOC(ty)
static void bpy_prop_int_array_set_fn(PointerRNA *ptr, PropertyRNA *prop, const int *values)
static int bpy_prop_enum_get_transform_fn(PointerRNA *ptr, PropertyRNA *prop, int curr_value, bool is_set)
static void bpy_prop_int_array_set_transform_fn(PointerRNA *ptr, PropertyRNA *prop, const int *new_values, const int *curr_values, bool is_set, int *r_final_values)
#define BPY_PROPDEF_POINTER_TYPE_DOC
PyObject * BPY_rna_props()
static PyMethodDef props_methods[]
static bool bpy_prop_boolean_set_transform_fn(PointerRNA *ptr, PropertyRNA *prop, bool new_value, bool curr_value, bool is_set)
static void bpy_prop_float_array_set_transform_fn(PointerRNA *ptr, PropertyRNA *prop, const float *new_values, const float *curr_values, bool is_set, float *r_final_values)
static void bpy_prop_callback_assign_pointer(PropertyRNA *prop, PyObject *poll_fn)
static PyObject * pyrna_struct_as_instance(PointerRNA *ptr)
static bool bpy_prop_callback_assign_float(PropertyRNA *prop, PyObject *get_fn, PyObject *set_fn, PyObject *get_transform_fn, PyObject *set_transform_fn)
static PyObject * BPy_BoolProperty(PyObject *self, PyObject *args, PyObject *kw)
static bool bpy_prop_callback_assign_boolean_array(PropertyRNA *prop, PyObject *get_fn, PyObject *set_fn, PyObject *get_transform_fn, PyObject *set_transform_fn)
static PyObject * bpy_prop_deferred_function_get(BPy_PropDeferred *self, void *)
static void bpy_prop_deferred_dealloc(BPy_PropDeferred *self)
#define BPY_PROPDEF_GET_TRANSFORM_DOC(ty)
static int props_clear(PyObject *)
static void bpy_prop_boolean_set_fn(PointerRNA *ptr, PropertyRNA *prop, bool value)
static void bpy_prop_float_array_get_transform_fn(PointerRNA *ptr, PropertyRNA *prop, const float *curr_values, bool is_set, float *r_values)
void BPY_rna_props_clear_all()
static PyObject * pymeth_RemoveProperty
static void bpy_prop_enum_set_fn(PointerRNA *ptr, PropertyRNA *prop, int value)
static int icon_id_from_name(const char *name)
static PyObject * pymeth_CollectionProperty
static void bpy_prop_int_array_get_transform_fn(PointerRNA *ptr, PropertyRNA *prop, const int *curr_values, bool is_set, int *r_values)
static void bpy_prop_boolean_array_from_callback_or_error(PyObject *bool_array_obj, const BPyPropArrayLength &array_len_info, PyObject *py_func, bool *r_values)
static const EnumPropertyItem * enum_items_from_py(PyObject *seq_fast, const bool is_enum_flag, PyObject *default_py, int *r_default_value)
static PyObject * BPy_FloatVectorProperty(PyObject *self, PyObject *args, PyObject *kw)
static PyObject * BPy_IntProperty(PyObject *self, PyObject *args, PyObject *kw)
#define BPY_PROPDEF_CTXT_DOC
#define BPY_PROPDEF_COLLECTION_TYPE_DOC
#define BPY_PROPDEF_TAGS_DOC
static int bpy_prop_deferred_traverse(BPy_PropDeferred *self, visitproc visit, void *arg)
#define BPY_PROP_STORE_PY_DATA_SIZE
static int bpy_prop_array_length_parse(PyObject *o, void *p)
static void bpy_prop_float_array_get_fn(PointerRNA *ptr, PropertyRNA *prop, float *values)
static bool bpy_prop_callback_assign_int(PropertyRNA *prop, PyObject *get_fn, PyObject *set_fn, PyObject *get_transform_fn, PyObject *set_transform_fn)
static void bpy_prop_int_array_from_callback_or_error(PyObject *int_array_obj, const BPyPropArrayLength &array_len_info, PyObject *py_func, int *r_values)
static PyObject * pymeth_PointerProperty
#define BPY_PROPDEF_OPTIONS_DOC
static int bpy_prop_arg_parse_id(PyObject *o, void *p)
static int bpy_prop_array_from_py_with_dims(void *values, size_t values_elem_size, PyObject *py_values, const BPyPropArrayLength *array_len_info, const PyTypeObject *type, const char *error_str)
static void bpy_prop_gil_rna_writable_end(const BPyPropGIL_RNAWritable_State &prop_state)
static bool bpy_prop_boolean_get_fn(PointerRNA *ptr, PropertyRNA *prop)
#define BPY_PROPDEF_GET_DOC(ty)
#define BPY_PROPDEF_SET_TRANSFORM_DOC(ty)
static void bpy_prop_float_set_fn(PointerRNA *ptr, PropertyRNA *prop, float value)
static std::string bpy_prop_string_get_transform_fn(PointerRNA *ptr, PropertyRNA *prop, const std::string &curr_value, bool is_set)
static BPyPropStore * bpy_prop_py_data_ensure(PropertyRNA *prop)
static StructRNA * bpy_prop_deferred_data_or_srna(PyObject *self, PyObject *args, PyObject *kw, PyObject *method_object, PyObject **r_deferred_result)
#define BPY_PROPDEF_SEARCH_DOC
static void bpy_prop_float_array_from_callback_or_error(PropertyRNA *prop, PyObject *float_array_obj, const BPyPropArrayLength &array_len_info, PyObject *py_func, const bool do_matrix_row_col_swap, float *r_values)
StructRNA * pointer_type_from_py(PyObject *value, const char *error_prefix)
static PyObject * bpy_prop_deferred_data_CreatePyObject(PyObject *fn, PyObject *kw)
static int bpy_prop_enum_get_fn(PointerRNA *ptr, PropertyRNA *prop)
static const EnumPropertyItem * bpy_prop_enum_itemf_fn(bContext *C, PointerRNA *ptr, PropertyRNA *prop, bool *r_free)
static PyObject * pymeth_BoolProperty
static void bpy_prop_array_matrix_swap_row_column_vn(float *values, const BPyPropArrayLength *array_len_info)
static void bpy_prop_boolean_array_get_transform_fn(PointerRNA *ptr, PropertyRNA *prop, const bool *curr_values, bool is_set, bool *r_values)
static BPyPropGIL_RNAWritable_State bpy_prop_gil_rna_writable_begin()
#define BPY_PROPDEF_OPTIONS_ENUM_DOC
static int bpy_prop_arg_parse_tag_defines(PyObject *o, void *p)
static void bpy_prop_update_fn(bContext *C, PointerRNA *ptr, PropertyRNA *prop)
static void bpy_prop_callback_assign_update(PropertyRNA *prop, PyObject *update_fn)
#define BPY_PROPDEF_UNIT_DOC
#define BPY_PROPDEF_SUBTYPE_NUMBER_DOC
static PyObject * bpy_prop_deferred_call(BPy_PropDeferred *, PyObject *, PyObject *)
static void bpy_prop_assign_flag(PropertyRNA *prop, int flag)
static int bpy_prop_callback_check(PyObject *py_func, const char *keyword, int argcount)
static PyObject * BPy_RemoveProperty(PyObject *self, PyObject *args, PyObject *kw)
#define ASSIGN_STATIC(_name)
#define BPY_PROPDEF_SUBTYPE_NUMBER_ARRAY_DOC
#define BPY_PROPDEF_VECSIZE_DOC
#define BPY_PROPDEF_INT_STEP_DOC
#define BPY_PROPDEF_DESC_DOC
PyTypeObject bpy_prop_deferred_Type
static PyObject * pymeth_BoolVectorProperty
static PyObject * BPy_IntVectorProperty(PyObject *self, PyObject *args, PyObject *kw)
static ListBase g_bpy_prop_store_list
static void bpy_prop_assign_flag_override(PropertyRNA *prop, const int flag_override)
#define BPY_PROPDEF_OPTIONS_OVERRIDE_DOC
static int props_visit(PyObject *, visitproc visit, void *arg)
static PyObject * bpy_prop_deferred_repr(BPy_PropDeferred *self)
static PyObject * pymeth_StringProperty
#define PYRNA_STACK_ARRAY
StructRNA * srna_from_self(PyObject *self, const char *error_prefix)
void pyrna_write_set(bool val)
PyObject * pyrna_struct_CreatePyObject(PointerRNA *ptr)
BPy_StructRNA * bpy_context_module
static DBVT_INLINE btScalar size(const btDbvtVolume &a)
void reinitialize(const int64_t new_size)
VecBase< float, D > step(VecOp< float, D >, VecOp< float, D >) RET
float length(VecOp< float, D >) RET
static bool py_long_as_int(PyObject *py_long, int *r_int)
void * MEM_mallocN(size_t len, const char *str)
void * MEM_calloc_arrayN(size_t len, size_t size, const char *str)
void * MEM_callocN(size_t len, const char *str)
void MEM_freeN(void *vmemh)
int pyrna_enum_bitfield_parse_set(PyObject *o, void *p)
int pyrna_enum_value_parse_string(PyObject *o, void *p)
PyObject * PyC_Tuple_PackArray_Bool(const bool *array, uint len)
PyObject * PyC_Tuple_PackArray_Multi_Bool(const bool *array, const int dims[], const int dims_len)
PyObject * PyC_Tuple_PackArray_I32(const int *array, uint len)
PyObject * PyC_ExceptionBuffer()
int PyC_Long_AsBool(PyObject *value)
int PyC_AsArray(void *array, const size_t array_item_size, PyObject *value, const Py_ssize_t length, const PyTypeObject *type, const char *error_prefix)
PyObject * PyC_Tuple_PackArray_Multi_F32(const float *array, const int dims[], const int dims_len)
int PyC_AsArray_Multi(void *array, const size_t array_item_size, PyObject *value, const int *dims, const int dims_len, const PyTypeObject *type, const char *error_prefix)
void PyC_Err_PrintWithFunc(PyObject *py_func)
PyObject * PyC_Tuple_PackArray_F32(const float *array, uint len)
PyObject * PyC_Tuple_PackArray_Multi_I32(const int *array, const int dims[], const int dims_len)
int PyC_ParseBool(PyObject *o, void *p)
header-only compatibility defines.
#define PY_ARG_PARSER_HEAD_COMPAT()
#define PyTuple_SET_ITEMS(op_arg,...)
bool RNA_struct_is_a(const StructRNA *type, const StructRNA *srna)
bool RNA_struct_is_ID(const StructRNA *type)
PropertyRNA * RNA_struct_find_property(PointerRNA *ptr, const char *identifier)
const EnumPropertyItem * RNA_struct_property_tag_defines(const StructRNA *type)
int RNA_property_enum_get_default(PointerRNA *ptr, PropertyRNA *prop)
PropertyType RNA_property_type(PropertyRNA *prop)
void ** RNA_struct_instance(PointerRNA *ptr)
const char * RNA_struct_identifier(const StructRNA *type)
bool RNA_struct_idprops_contains_datablock(const StructRNA *type)
int RNA_property_array_dimension(const PointerRNA *ptr, PropertyRNA *prop, int length[])
void * RNA_property_py_data_get(PropertyRNA *prop)
int RNA_property_flag(PropertyRNA *prop)
const char * RNA_struct_ui_name(const StructRNA *type)
int RNA_property_array_length(PointerRNA *ptr, PropertyRNA *prop)
int RNA_property_string_maxlength(PropertyRNA *prop)
PropertySubType RNA_property_subtype(PropertyRNA *prop)
PointerRNA RNA_pointer_create_discrete(ID *id, StructRNA *type, void *data)
void RNA_def_property_int_array_funcs_runtime(PropertyRNA *prop, IntArrayPropertyGetFunc getfunc, IntArrayPropertySetFunc setfunc, IntPropertyRangeFunc rangefunc, IntArrayPropertyGetTransformFunc get_transform_fn, IntArrayPropertySetTransformFunc set_transform_fn)
void RNA_def_property_string_search_func_runtime(PropertyRNA *prop, StringPropertySearchFunc search_fn, const eStringPropertySearchFlag search_flag)
void RNA_def_struct_flag(StructRNA *srna, int flag)
PropertyRNA * RNA_def_pointer_runtime(StructOrFunctionRNA *cont_, const char *identifier, StructRNA *type, const char *ui_name, const char *ui_description)
void RNA_def_property_float_default(PropertyRNA *prop, float value)
void RNA_def_property_ui_text(PropertyRNA *prop, const char *name, const char *description)
void RNA_def_property_boolean_default(PropertyRNA *prop, bool value)
void RNA_def_property_multi_array(PropertyRNA *prop, int dimension, const int length[])
PropertyRNA * RNA_def_enum(StructOrFunctionRNA *cont_, const char *identifier, const EnumPropertyItem *items, const int default_value, const char *ui_name, const char *ui_description)
void RNA_def_property_int_default(PropertyRNA *prop, int value)
void RNA_def_property_boolean_funcs_runtime(PropertyRNA *prop, BooleanPropertyGetFunc getfunc, BooleanPropertySetFunc setfunc, BooleanPropertyGetTransformFunc get_transform_fn, BooleanPropertySetTransformFunc set_transform_fn)
void RNA_def_py_data(PropertyRNA *prop, void *py_data)
void RNA_def_property_array(PropertyRNA *prop, int length)
void RNA_def_property_range(PropertyRNA *prop, double min, double max)
void RNA_def_property_poll_runtime(PropertyRNA *prop, const void *func)
void RNA_def_property_string_maxlength(PropertyRNA *prop, int maxlength)
void RNA_def_property_update_runtime_with_context_and_property(PropertyRNA *prop, RNAPropertyUpdateFuncWithContextAndProperty func)
PropertyRNA * RNA_def_property(StructOrFunctionRNA *cont_, const char *identifier, int type, int subtype)
void RNA_def_property_float_array_funcs_runtime(PropertyRNA *prop, FloatArrayPropertyGetFunc getfunc, FloatArrayPropertySetFunc setfunc, FloatPropertyRangeFunc rangefunc, FloatArrayPropertyGetTransformFunc get_transform_fn, FloatArrayPropertySetTransformFunc set_transform_fn)
PropertyRNA * RNA_def_collection_runtime(StructOrFunctionRNA *cont_, const char *identifier, StructRNA *type, const char *ui_name, const char *ui_description)
void RNA_def_property_enum_funcs_runtime(PropertyRNA *prop, EnumPropertyGetFunc getfunc, EnumPropertySetFunc setfunc, EnumPropertyItemFunc itemfunc, EnumPropertyGetTransformFunc get_transform_fn, EnumPropertySetTransformFunc set_transform_fn)
PropertyRNA * RNA_def_enum_flag(StructOrFunctionRNA *cont_, const char *identifier, const EnumPropertyItem *items, const int default_value, const char *ui_name, const char *ui_description)
void RNA_def_property_string_funcs_runtime(PropertyRNA *prop, StringPropertyGetFunc getfunc, StringPropertyLengthFunc lengthfunc, StringPropertySetFunc setfunc, StringPropertyGetTransformFunc get_transform_fn, StringPropertySetTransformFunc set_transform_fn)
void RNA_def_property_int_array_default(PropertyRNA *prop, const int *array)
void RNA_def_property_float_funcs_runtime(PropertyRNA *prop, FloatPropertyGetFunc getfunc, FloatPropertySetFunc setfunc, FloatPropertyRangeFunc rangefunc, FloatPropertyGetTransformFunc get_transform_fn, FloatPropertySetTransformFunc set_transform_fn)
void RNA_def_property_clear_flag(PropertyRNA *prop, PropertyFlag flag)
void RNA_def_property_string_default(PropertyRNA *prop, const char *value)
void RNA_def_property_translation_context(PropertyRNA *prop, const char *context)
void RNA_def_property_int_funcs_runtime(PropertyRNA *prop, IntPropertyGetFunc getfunc, IntPropertySetFunc setfunc, IntPropertyRangeFunc rangefunc, IntPropertyGetTransformFunc get_transform_fn, IntPropertySetTransformFunc set_transform_fn)
void RNA_def_property_flag(PropertyRNA *prop, PropertyFlag flag)
void RNA_def_property_boolean_array_default(PropertyRNA *prop, const bool *array)
void RNA_def_property_ui_range(PropertyRNA *prop, double min, double max, double step, int precision)
void RNA_def_property_tags(PropertyRNA *prop, int tags)
void RNA_def_property_float_array_default(PropertyRNA *prop, const float *array)
void RNA_def_property_boolean_array_funcs_runtime(PropertyRNA *prop, BooleanArrayPropertyGetFunc getfunc, BooleanArrayPropertySetFunc setfunc, BooleanArrayPropertyGetTransformFunc get_transform_fn, BooleanArrayPropertySetTransformFunc set_transform_fn)
void RNA_def_property_override_flag(PropertyRNA *prop, PropertyOverrideFlag flag)
StructRNA RNA_PropertyGroup
const EnumPropertyItem rna_enum_property_override_flag_collection_items[]
const EnumPropertyItem rna_enum_dummy_NULL_items[]
const EnumPropertyItem rna_enum_property_subtype_number_array_items[]
const EnumPropertyItem rna_enum_property_unit_items[]
const EnumPropertyItem rna_enum_property_subtype_number_items[]
const EnumPropertyItem rna_enum_property_string_search_flag_items[]
const EnumPropertyItem rna_enum_property_override_flag_items[]
const EnumPropertyItem rna_enum_property_subtype_string_items[]
const EnumPropertyItem rna_enum_property_flag_items[]
const EnumPropertyItem rna_enum_property_flag_enum_items[]
const EnumPropertyItem rna_enum_icon_items[]
bool operator==(const BPyPropArrayLength &other) const
BPyPropArrayLength(PointerRNA *ptr, PropertyRNA *prop)
BPyPropArrayLength()=default
int dims[RNA_MAX_ARRAY_DIMENSION]
PyGILState_STATE gilstate
struct BPyPropStore::@011277245316035333236375302160165252076054344031 py_data
struct BPyPropStore::@011277245316035333236375302160165252076054344031::@161001040054361261366031313257143126255124070321::@035000154373154163256114102376000262050350366117 pointer_data
PyObject * set_transform_fn
struct BPyPropStore::@011277245316035333236375302160165252076054344031::@161001040054361261366031313257143126255124070321::@357037322072311333322324224201060265100110237071 string_data
struct BPyPropStore::@011277245316035333236375302160165252076054344031::@161001040054361261366031313257143126255124070321::@153150171102020060327110151332372002250132146302 enum_data
PyObject * get_transform_fn
BPy_EnumProperty_Parse base
const EnumPropertyItem * items
std::optional< std::string > info