Blender V4.5
bpy_props.cc
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2023 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
12
13/* Future-proof, See https://docs.python.org/3/c-api/arg.html#strings-and-buffers */
14#define PY_SSIZE_T_CLEAN
15
16#include <algorithm>
17
18#include <Python.h>
19
20#include "RNA_types.hh"
21
22#include "BLI_array.hh"
23#include "BLI_listbase.h"
24#include "BLI_utildefines.h"
25
26#include "bpy_capi_utils.hh"
27#include "bpy_props.hh"
28#include "bpy_rna.hh"
29
30#include "RNA_access.hh"
31#include "RNA_define.hh" /* for defining our own rna */
32#include "RNA_enum_types.hh"
33#include "RNA_prototypes.hh"
34
35#include "MEM_guardedalloc.h"
36
37#include "DNA_ID.h" /* MAX_IDPROP_NAME */
38
41#include "../generic/python_compat.hh" /* IWYU pragma: keep. */
42
43using blender::Array;
44
45/* Disabled duplicating strings because the array can still be freed and
46 * the strings from it referenced, for now we can't support dynamically
47 * created strings from Python. */
48// #define USE_ENUM_COPY_STRINGS
49
50/* -------------------------------------------------------------------- */
53
54#define BPY_PROPDEF_OPTIONS_DOC \
55 " :arg options: Enumerator in :ref:`rna_enum_property_flag_items`.\n" \
56 " :type options: set[str]\n"
57
58#define BPY_PROPDEF_OPTIONS_ENUM_DOC \
59 " :arg options: Enumerator in :ref:`rna_enum_property_flag_enum_items`.\n" \
60 " :type options: set[str]\n"
61
62#define BPY_PROPDEF_OPTIONS_OVERRIDE_DOC \
63 " :arg override: Enumerator in :ref:`rna_enum_property_override_flag_items`.\n" \
64 " :type override: set[str]\n"
65
66#define BPY_PROPDEF_OPTIONS_OVERRIDE_COLLECTION_DOC \
67 " :arg override: Enumerator in :ref:`rna_enum_property_override_flag_collection_items`.\n" \
68 " :type override: set[str]\n"
69
70#define BPY_PROPDEF_SUBTYPE_STRING_DOC \
71 " :arg subtype: Enumerator in :ref:`rna_enum_property_subtype_string_items`.\n" \
72 " :type subtype: str\n"
73
74#define BPY_PROPDEF_SUBTYPE_NUMBER_DOC \
75 " :arg subtype: Enumerator in :ref:`rna_enum_property_subtype_number_items`.\n" \
76 " :type subtype: str\n"
77
78#define BPY_PROPDEF_SUBTYPE_NUMBER_ARRAY_DOC \
79 " :arg subtype: Enumerator in :ref:`rna_enum_property_subtype_number_array_items`.\n" \
80 " :type subtype: str\n"
81
83
84/* -------------------------------------------------------------------- */
89
124
129 struct {
131 PyObject *get_fn;
132 PyObject *set_fn;
134 PyObject *update_fn;
135
137 union {
139 struct {
141 PyObject *itemf_fn;
144 struct {
146 PyObject *poll_fn;
149 struct {
151 PyObject *search_fn;
153 };
155};
156
157#define BPY_PROP_STORE_PY_DATA_SIZE (sizeof(BPyPropStore::py_data) / sizeof(PyObject *))
158
159#define ASSIGN_PYOBJECT_INCREF(a, b) \
160 { \
161 BLI_assert((a) == nullptr); \
162 Py_INCREF(b); \
163 a = b; \
164 } \
165 ((void)0)
166
171static ListBase g_bpy_prop_store_list = {nullptr, nullptr};
172
174{
175 BPyPropStore *prop_store = static_cast<BPyPropStore *>(RNA_property_py_data_get(prop));
176 if (prop_store == nullptr) {
177 prop_store = MEM_callocN<BPyPropStore>(__func__);
178 RNA_def_py_data(prop, prop_store);
180 }
181 return prop_store;
182}
183
188{
189 BPyPropStore *prop_store = static_cast<BPyPropStore *>(RNA_property_py_data_get(prop));
190 if (prop_store == nullptr) {
191 return;
192 }
193
194 PyObject **py_data = (PyObject **)&prop_store->py_data;
195 for (int i = 0; i < BPY_PROP_STORE_PY_DATA_SIZE; i++) {
196 Py_XDECREF(py_data[i]);
197 }
199}
200
202
203/* -------------------------------------------------------------------- */
210
212{
213 PyObject_GC_UnTrack(self);
214 Py_CLEAR(self->kw);
215 PyObject_GC_Del(self);
216}
217
218static int bpy_prop_deferred_traverse(BPy_PropDeferred *self, visitproc visit, void *arg)
219{
220 Py_VISIT(self->kw);
221 return 0;
222}
223
225{
226 Py_CLEAR(self->kw);
227 return 0;
228}
229
231{
232 return PyUnicode_FromFormat("<%.200s, %R, %R>", Py_TYPE(self)->tp_name, self->fn, self->kw);
233}
234
241static PyObject *bpy_prop_deferred_call(BPy_PropDeferred * /*self*/,
242 PyObject * /*args*/,
243 PyObject * /*kw*/)
244{
245 /* Dummy value. */
246 Py_RETURN_NONE;
247}
248
249/* Get/Set Items. */
250
255static PyObject *bpy_prop_deferred_function_get(BPy_PropDeferred *self, void * /*closure*/)
256{
257 PyObject *ret = static_cast<PyObject *>(self->fn);
258 Py_IncRef(ret);
259 return ret;
260}
261
266static PyObject *bpy_prop_deferred_keywords_get(BPy_PropDeferred *self, void * /*closure*/)
267{
268 PyObject *ret = self->kw;
269 Py_IncRef(ret);
270 return ret;
271}
272
273static PyGetSetDef bpy_prop_deferred_getset[] = {
274 {"function", (getter)bpy_prop_deferred_function_get, (setter) nullptr, nullptr, nullptr},
275 {"keywords", (getter)bpy_prop_deferred_keywords_get, (setter) nullptr, nullptr, nullptr},
276 {nullptr, nullptr, nullptr, nullptr, nullptr} /* Sentinel */
277};
278
280 /* Wrap. */
281 bpy_prop_deferred_doc,
282 "Intermediate storage for properties before registration.\n"
283 "\n"
284 ".. note::\n"
285 "\n"
286 " This is not part of the stable API and may change between releases.");
287
289 /*ob_base*/ PyVarObject_HEAD_INIT(nullptr, 0)
290 /*tp_name*/ "_PropertyDeferred",
291 /*tp_basicsize*/ sizeof(BPy_PropDeferred),
292 /*tp_itemsize*/ 0,
293 /*tp_dealloc*/ (destructor)bpy_prop_deferred_dealloc,
294 /*tp_vectorcall_offset*/ 0,
295 /*tp_getattr*/ nullptr,
296 /*tp_setattr*/ nullptr,
297 /*tp_as_async*/ nullptr,
298 /*tp_repr*/ (reprfunc)bpy_prop_deferred_repr,
299 /*tp_as_number*/ nullptr,
300 /*tp_as_sequence*/ nullptr,
301 /*tp_as_mapping*/ nullptr,
302 /*tp_hash*/ nullptr,
303 /*tp_call*/ (ternaryfunc)bpy_prop_deferred_call,
304 /*tp_str*/ nullptr,
305 /*tp_getattro*/ nullptr,
306 /*tp_setattro*/ nullptr,
307 /*tp_as_buffer*/ nullptr,
308 /*tp_flags*/ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC,
309 /*tp_doc*/ bpy_prop_deferred_doc,
310 /*tp_traverse*/ (traverseproc)bpy_prop_deferred_traverse,
311 /*tp_clear*/ (inquiry)bpy_prop_deferred_clear,
312 /*tp_richcompare*/ nullptr,
313 /*tp_weaklistoffset*/ 0,
314 /*tp_iter*/ nullptr,
315 /*tp_iternext*/ nullptr,
316 /*tp_methods*/ nullptr,
317 /*tp_members*/ nullptr,
318 /*tp_getset*/ bpy_prop_deferred_getset,
319 /*tp_base*/ nullptr,
320 /*tp_dict*/ nullptr,
321 /*tp_descr_get*/ nullptr,
322 /*tp_descr_set*/ nullptr,
323 /*tp_dictoffset*/ 0,
324 /*tp_init*/ nullptr,
325 /*tp_alloc*/ nullptr,
326 /*tp_new*/ nullptr,
327 /*tp_free*/ nullptr,
328 /*tp_is_gc*/ nullptr,
329 /*tp_bases*/ nullptr,
330 /*tp_mro*/ nullptr,
331 /*tp_cache*/ nullptr,
332 /*tp_subclasses*/ nullptr,
333 /*tp_weaklist*/ nullptr,
334 /*tp_del*/ nullptr,
335 /*tp_version_tag*/ 0,
336 /*tp_finalize*/ nullptr,
337 /*tp_vectorcall*/ nullptr,
338};
339
340static PyObject *bpy_prop_deferred_data_CreatePyObject(PyObject *fn, PyObject *kw)
341{
343 self->fn = fn;
344 if (kw == nullptr) {
345 kw = PyDict_New();
346 }
347 else {
348 Py_INCREF(kw);
349 }
350 self->kw = kw;
351 BLI_assert(!PyObject_GC_IsTracked((PyObject *)self));
352 PyObject_GC_Track(self);
353 return (PyObject *)self;
354}
355
357
358/* -------------------------------------------------------------------- */
361
362/* PyObject's */
363static PyObject *pymeth_BoolProperty = nullptr;
364static PyObject *pymeth_BoolVectorProperty = nullptr;
365static PyObject *pymeth_IntProperty = nullptr;
366static PyObject *pymeth_IntVectorProperty = nullptr;
367static PyObject *pymeth_FloatProperty = nullptr;
368static PyObject *pymeth_FloatVectorProperty = nullptr;
369static PyObject *pymeth_StringProperty = nullptr;
370static PyObject *pymeth_EnumProperty = nullptr;
371static PyObject *pymeth_PointerProperty = nullptr;
372static PyObject *pymeth_CollectionProperty = nullptr;
373static PyObject *pymeth_RemoveProperty = nullptr;
374
376{
377 PyObject *self = nullptr;
378 /* first get self */
379 /* operators can store their own instance for later use */
380 if (ptr->data) {
381 void **instance = RNA_struct_instance(ptr);
382
383 if (instance) {
384 if (*instance) {
385 self = static_cast<PyObject *>(*instance);
386 Py_INCREF(self);
387 }
388 }
389 }
390
391 /* in most cases this will run */
392 if (self == nullptr) {
394 }
395
396 return self;
397}
398
399static void bpy_prop_assign_flag(PropertyRNA *prop, const int flag)
400{
401 const int flag_mask = ((PROP_ANIMATABLE) & ~flag);
402
403 if (flag) {
405 }
406
407 if (flag_mask) {
409 }
410}
411
412static void bpy_prop_assign_flag_override(PropertyRNA *prop, const int flag_override)
413{
415}
416
417/* These utility functions de-duplicate boiler plate code used by most property callbacks.
418 * It's important they're at the beginning & end of the callbacks and both are always called. */
419
421 PyGILState_STATE gilstate;
423};
424
426{
427 /* It's important to acquire the lock before reading other state information, see: #127767. */
428 const PyGILState_STATE gilstate = PyGILState_Ensure();
429 const bool is_write_ok = pyrna_write_check();
430 return {
431 /*gilstate*/ gilstate,
432 /*is_write_ok*/ is_write_ok,
433 };
434}
435
437{
438 if (!prop_state.is_write_ok) {
439 pyrna_write_set(false);
440 }
441 PyGILState_Release(prop_state.gilstate);
442}
443
445
446/* -------------------------------------------------------------------- */
449
456
460static int bpy_prop_array_length_parse(PyObject *o, void *p)
461{
462 BPyPropArrayLength *array_len_info = static_cast<BPyPropArrayLength *>(p);
463
464 if (PyLong_CheckExact(o)) {
465 int size;
466 if ((size = PyLong_AsLong(o)) == -1) {
467 PyErr_Format(
468 PyExc_ValueError, "expected number or sequence of numbers, got %s", Py_TYPE(o)->tp_name);
469 return 0;
470 }
472 PyErr_Format(
473 PyExc_TypeError, "(size=%d) must be between 1 and " STRINGIFY(PYRNA_STACK_ARRAY), size);
474 return 0;
475 }
476 array_len_info->len_total = size;
477
478 /* Don't use this value. */
479 array_len_info->dims_len = 0;
480 }
481 else {
482 PyObject *seq_fast;
483 if (!(seq_fast = PySequence_Fast(o, "size must be a number of a sequence of numbers"))) {
484 return 0;
485 }
486 const int seq_len = PySequence_Fast_GET_SIZE(seq_fast);
487 if (seq_len < 1 || seq_len > RNA_MAX_ARRAY_DIMENSION) {
488 PyErr_Format(
489 PyExc_TypeError,
490 "(len(size)=%d) length must be between 1 and " STRINGIFY(RNA_MAX_ARRAY_DIMENSION),
491 seq_len);
492 Py_DECREF(seq_fast);
493 return 0;
494 }
495
496 PyObject **seq_items = PySequence_Fast_ITEMS(seq_fast);
497 array_len_info->len_total = 1;
498 for (int i = 0; i < seq_len; i++) {
499 int size;
500 if ((size = PyLong_AsLong(seq_items[i])) == -1) {
501 Py_DECREF(seq_fast);
502 PyErr_Format(PyExc_ValueError,
503 "expected number in sequence, got %s at index %d",
504 Py_TYPE(o)->tp_name,
505 i);
506 return 0;
507 }
509 Py_DECREF(seq_fast);
510 PyErr_Format(PyExc_TypeError,
511 "(size[%d]=%d) must be between 1 and " STRINGIFY(PYRNA_STACK_ARRAY),
512 i,
513 size);
514 return 0;
515 }
516
517 array_len_info->dims[i] = size;
518 array_len_info->dims_len = seq_len;
519 array_len_info->len_total *= size;
520 }
521 }
522 return 1;
523}
524
528static int bpy_prop_array_from_py_with_dims(void *values,
529 size_t values_elem_size,
530 PyObject *py_values,
531 const BPyPropArrayLength *array_len_info,
532 const PyTypeObject *type,
533 const char *error_str)
534{
535 if (array_len_info->dims_len == 0) {
536 return PyC_AsArray(
537 values, values_elem_size, py_values, array_len_info->len_total, type, error_str);
538 }
539 const int *dims = array_len_info->dims;
540 const int dims_len = array_len_info->dims_len;
541 return PyC_AsArray_Multi(values, values_elem_size, py_values, dims, dims_len, type, error_str);
542}
543
545 const BPyPropArrayLength *array_len_info)
546{
547 return ((subtype == PROP_MATRIX) && (array_len_info->dims_len == 2) &&
548 ((array_len_info->dims[0] >= 2) && (array_len_info->dims[0] <= 4)) &&
549 ((array_len_info->dims[1] >= 2) && (array_len_info->dims[1] <= 4)));
550}
551
553 const BPyPropArrayLength *array_len_info)
554{
557}
558
563 const float *values_src,
564 const BPyPropArrayLength *array_len_info)
565{
566 BLI_assert(values_dst != values_src);
567 const int dim0 = array_len_info->dims[0], dim1 = array_len_info->dims[1];
568 BLI_assert(dim0 <= 4 && dim1 <= 4);
569 for (int i = 0; i < dim0; i++) {
570 for (int j = 0; j < dim1; j++) {
571 values_dst[(j * dim0) + i] = values_src[(i * dim1) + j];
572 }
573 }
574}
575
577 const BPyPropArrayLength *array_len_info)
578{
579 const int dim0 = array_len_info->dims[0], dim1 = array_len_info->dims[1];
580 BLI_assert(dim0 <= 4 && dim1 <= 4);
581 float values_orig[4 * 4];
582 memcpy(values_orig, values, sizeof(float) * (dim0 * dim1));
583 bpy_prop_array_matrix_swap_row_column_vn_vn(values, values_orig, array_len_info);
584}
585
587
588/* -------------------------------------------------------------------- */
593
594/* callbacks */
596{
597 PyGILState_STATE gilstate;
598 bpy_context_set(C, &gilstate);
599 const bool is_write_ok = pyrna_write_check();
600 if (!is_write_ok) {
601 pyrna_write_set(true);
602 }
603
604 BPyPropStore *prop_store = static_cast<BPyPropStore *>(RNA_property_py_data_get(prop));
605 PyObject *py_func;
606 PyObject *args;
607 PyObject *self;
608 PyObject *ret;
609
610 BLI_assert(prop_store != nullptr);
611
612 py_func = prop_store->py_data.update_fn;
613
614 args = PyTuple_New(2);
616 PyTuple_SET_ITEM(args, 0, self);
617
618 PyTuple_SET_ITEM(args, 1, (PyObject *)bpy_context_module);
619 Py_INCREF(bpy_context_module);
620
621 ret = PyObject_CallObject(py_func, args);
622
623 Py_DECREF(args);
624
625 if (ret == nullptr) {
626 PyC_Err_PrintWithFunc(py_func);
627 }
628 else {
629 if (ret != Py_None) {
630 PyErr_SetString(PyExc_ValueError, "the return value must be None");
631 PyC_Err_PrintWithFunc(py_func);
632 }
633
634 Py_DECREF(ret);
635 }
636
637 if (!is_write_ok) {
638 pyrna_write_set(false);
639 }
640
641 bpy_context_clear(C, &gilstate);
642}
643
645
646/* -------------------------------------------------------------------- */
649
651{
653
654 BPyPropStore *prop_store = static_cast<BPyPropStore *>(RNA_property_py_data_get(prop));
655 PyObject *py_func;
656 PyObject *args;
657 PyObject *self;
658 PyObject *ret;
659 bool value;
660
661 BLI_assert(prop_store != nullptr);
662
663 py_func = prop_store->py_data.get_fn;
664
665 args = PyTuple_New(1);
667 PyTuple_SET_ITEM(args, 0, self);
668
669 ret = PyObject_CallObject(py_func, args);
670
671 Py_DECREF(args);
672
673 if (ret == nullptr) {
674 PyC_Err_PrintWithFunc(py_func);
675 value = false;
676 }
677 else {
678 const int value_i = PyC_Long_AsBool(ret);
679
680 if (value_i == -1 && PyErr_Occurred()) {
681 PyC_Err_PrintWithFunc(py_func);
682 value = false;
683 }
684 else {
685 value = bool(value_i);
686 }
687
688 Py_DECREF(ret);
689 }
690
692
693 return value;
694}
695
696static void bpy_prop_boolean_set_fn(PointerRNA *ptr, PropertyRNA *prop, bool value)
697{
699
700 BPyPropStore *prop_store = static_cast<BPyPropStore *>(RNA_property_py_data_get(prop));
701 PyObject *py_func;
702 PyObject *args;
703 PyObject *self;
704 PyObject *ret;
705
706 BLI_assert(prop_store != nullptr);
707
708 py_func = prop_store->py_data.set_fn;
709
710 args = PyTuple_New(2);
712 PyTuple_SET_ITEM(args, 0, self);
713
714 PyTuple_SET_ITEM(args, 1, PyBool_FromLong(value));
715
716 ret = PyObject_CallObject(py_func, args);
717
718 Py_DECREF(args);
719
720 if (ret == nullptr) {
721 PyC_Err_PrintWithFunc(py_func);
722 }
723 else {
724 if (ret != Py_None) {
725 PyErr_SetString(PyExc_ValueError, "the return value must be None");
726 PyC_Err_PrintWithFunc(py_func);
727 }
728
729 Py_DECREF(ret);
730 }
731
733}
734
735static void bpy_prop_boolean_array_get_fn(PointerRNA *ptr, PropertyRNA *prop, bool *values)
736{
738
739 BPyPropStore *prop_store = static_cast<BPyPropStore *>(RNA_property_py_data_get(prop));
740 PyObject *py_func;
741 PyObject *args;
742 PyObject *self;
743 PyObject *ret;
744
745 bool is_values_set = false;
746 int i, len = RNA_property_array_length(ptr, prop);
747 BPyPropArrayLength array_len_info{};
748 array_len_info.len_total = len;
749 array_len_info.dims_len = RNA_property_array_dimension(ptr, prop, array_len_info.dims);
750
751 BLI_assert(prop_store != nullptr);
752
753 py_func = prop_store->py_data.get_fn;
754
755 args = PyTuple_New(1);
757 PyTuple_SET_ITEM(args, 0, self);
758
759 ret = PyObject_CallObject(py_func, args);
760
761 Py_DECREF(args);
762
763 if (ret != nullptr) {
765 sizeof(*values),
766 ret,
767 &array_len_info,
768 &PyBool_Type,
769 "BoolVectorProperty get callback") == -1)
770 {
771 PyC_Err_PrintWithFunc(py_func);
772 }
773 else {
774 is_values_set = true;
775 }
776 Py_DECREF(ret);
777 }
778
779 if (is_values_set == false) {
780 /* This is the flattened length for multi-dimensional arrays. */
781 for (i = 0; i < len; i++) {
782 values[i] = false;
783 }
784 }
785
787}
788
789static void bpy_prop_boolean_array_set_fn(PointerRNA *ptr, PropertyRNA *prop, const bool *values)
790{
792
793 BPyPropStore *prop_store = static_cast<BPyPropStore *>(RNA_property_py_data_get(prop));
794 PyObject *py_func;
795 PyObject *args;
796 PyObject *self;
797 PyObject *ret;
798 PyObject *py_values;
799
800 const int len = RNA_property_array_length(ptr, prop);
801 BPyPropArrayLength array_len_info{};
802 array_len_info.len_total = len;
803 array_len_info.dims_len = RNA_property_array_dimension(ptr, prop, array_len_info.dims);
804
805 BLI_assert(prop_store != nullptr);
806
807 py_func = prop_store->py_data.set_fn;
808
809 args = PyTuple_New(2);
811 PyTuple_SET_ITEM(args, 0, self);
812
813 if (array_len_info.dims_len == 0) {
814 py_values = PyC_Tuple_PackArray_Bool(values, len);
815 }
816 else {
818 values, array_len_info.dims, array_len_info.dims_len);
819 }
820 PyTuple_SET_ITEM(args, 1, py_values);
821
822 ret = PyObject_CallObject(py_func, args);
823
824 Py_DECREF(args);
825
826 if (ret == nullptr) {
827 PyC_Err_PrintWithFunc(py_func);
828 }
829 else {
830 if (ret != Py_None) {
831 PyErr_SetString(PyExc_ValueError, "the return value must be None");
832 PyC_Err_PrintWithFunc(py_func);
833 }
834
835 Py_DECREF(ret);
836 }
837
839}
840
842
843/* -------------------------------------------------------------------- */
846
848{
850
851 BPyPropStore *prop_store = static_cast<BPyPropStore *>(RNA_property_py_data_get(prop));
852 PyObject *py_func;
853 PyObject *args;
854 PyObject *self;
855 PyObject *ret;
856
857 int value;
858
859 BLI_assert(prop_store != nullptr);
860
861 py_func = prop_store->py_data.get_fn;
862
863 args = PyTuple_New(1);
865 PyTuple_SET_ITEM(args, 0, self);
866
867 ret = PyObject_CallObject(py_func, args);
868
869 Py_DECREF(args);
870
871 if (ret == nullptr) {
872 PyC_Err_PrintWithFunc(py_func);
873 value = 0.0f;
874 }
875 else {
876 value = PyC_Long_AsI32(ret);
877
878 if (value == -1 && PyErr_Occurred()) {
879 PyC_Err_PrintWithFunc(py_func);
880 value = 0;
881 }
882
883 Py_DECREF(ret);
884 }
885
887
888 return value;
889}
890
891static void bpy_prop_int_set_fn(PointerRNA *ptr, PropertyRNA *prop, int value)
892{
894
895 BPyPropStore *prop_store = static_cast<BPyPropStore *>(RNA_property_py_data_get(prop));
896 PyObject *py_func;
897 PyObject *args;
898 PyObject *self;
899 PyObject *ret;
900
901 BLI_assert(prop_store != nullptr);
902
903 py_func = prop_store->py_data.set_fn;
904
905 args = PyTuple_New(2);
907 PyTuple_SET_ITEM(args, 0, self);
908
909 PyTuple_SET_ITEM(args, 1, PyLong_FromLong(value));
910
911 ret = PyObject_CallObject(py_func, args);
912
913 Py_DECREF(args);
914
915 if (ret == nullptr) {
916 PyC_Err_PrintWithFunc(py_func);
917 }
918 else {
919 if (ret != Py_None) {
920 PyErr_SetString(PyExc_ValueError, "the return value must be None");
921 PyC_Err_PrintWithFunc(py_func);
922 }
923
924 Py_DECREF(ret);
925 }
926
928}
929
930static void bpy_prop_int_array_get_fn(PointerRNA *ptr, PropertyRNA *prop, int *values)
931{
933
934 BPyPropStore *prop_store = static_cast<BPyPropStore *>(RNA_property_py_data_get(prop));
935 PyObject *py_func;
936 PyObject *args;
937 PyObject *self;
938 PyObject *ret;
939
940 bool is_values_set = false;
941 int i, len = RNA_property_array_length(ptr, prop);
942 BPyPropArrayLength array_len_info{};
943 array_len_info.len_total = len;
944 array_len_info.dims_len = RNA_property_array_dimension(ptr, prop, array_len_info.dims);
945
946 BLI_assert(prop_store != nullptr);
947
948 py_func = prop_store->py_data.get_fn;
949
950 args = PyTuple_New(1);
952 PyTuple_SET_ITEM(args, 0, self);
953
954 ret = PyObject_CallObject(py_func, args);
955
956 Py_DECREF(args);
957
958 if (ret != nullptr) {
960 sizeof(*values),
961 ret,
962 &array_len_info,
963 &PyLong_Type,
964 "IntVectorProperty get callback") == -1)
965 {
966 PyC_Err_PrintWithFunc(py_func);
967 }
968 else {
969 is_values_set = true;
970 }
971 Py_DECREF(ret);
972 }
973
974 if (is_values_set == false) {
975 /* This is the flattened length for multi-dimensional arrays. */
976 for (i = 0; i < len; i++) {
977 values[i] = 0;
978 }
979 }
980
982}
983
984static void bpy_prop_int_array_set_fn(PointerRNA *ptr, PropertyRNA *prop, const int *values)
985{
987
988 BPyPropStore *prop_store = static_cast<BPyPropStore *>(RNA_property_py_data_get(prop));
989 PyObject *py_func;
990 PyObject *args;
991 PyObject *self;
992 PyObject *ret;
993 PyObject *py_values;
994
995 const int len = RNA_property_array_length(ptr, prop);
996 BPyPropArrayLength array_len_info{};
997 array_len_info.len_total = len;
998 array_len_info.dims_len = RNA_property_array_dimension(ptr, prop, array_len_info.dims);
999
1000 BLI_assert(prop_store != nullptr);
1001
1002 py_func = prop_store->py_data.set_fn;
1003
1004 args = PyTuple_New(2);
1006 PyTuple_SET_ITEM(args, 0, self);
1007
1008 if (array_len_info.dims_len == 0) {
1009 py_values = PyC_Tuple_PackArray_I32(values, len);
1010 }
1011 else {
1013 values, array_len_info.dims, array_len_info.dims_len);
1014 }
1015
1016 PyTuple_SET_ITEM(args, 1, py_values);
1017
1018 ret = PyObject_CallObject(py_func, args);
1019
1020 Py_DECREF(args);
1021
1022 if (ret == nullptr) {
1023 PyC_Err_PrintWithFunc(py_func);
1024 }
1025 else {
1026 if (ret != Py_None) {
1027 PyErr_SetString(PyExc_ValueError, "the return value must be None");
1028 PyC_Err_PrintWithFunc(py_func);
1029 }
1030
1031 Py_DECREF(ret);
1032 }
1033
1035}
1036
1038
1039/* -------------------------------------------------------------------- */
1042
1044{
1046
1047 BPyPropStore *prop_store = static_cast<BPyPropStore *>(RNA_property_py_data_get(prop));
1048 PyObject *py_func;
1049 PyObject *args;
1050 PyObject *self;
1051 PyObject *ret;
1052
1053 float value;
1054
1055 BLI_assert(prop_store != nullptr);
1056
1057 py_func = prop_store->py_data.get_fn;
1058
1059 args = PyTuple_New(1);
1061 PyTuple_SET_ITEM(args, 0, self);
1062
1063 ret = PyObject_CallObject(py_func, args);
1064
1065 Py_DECREF(args);
1066
1067 if (ret == nullptr) {
1068 PyC_Err_PrintWithFunc(py_func);
1069 value = 0.0f;
1070 }
1071 else {
1072 value = PyFloat_AsDouble(ret);
1073
1074 if (value == -1.0f && PyErr_Occurred()) {
1075 PyC_Err_PrintWithFunc(py_func);
1076 value = 0.0f;
1077 }
1078
1079 Py_DECREF(ret);
1080 }
1081
1083
1084 return value;
1085}
1086
1087static void bpy_prop_float_set_fn(PointerRNA *ptr, PropertyRNA *prop, float value)
1088{
1090
1091 BPyPropStore *prop_store = static_cast<BPyPropStore *>(RNA_property_py_data_get(prop));
1092 PyObject *py_func;
1093 PyObject *args;
1094 PyObject *self;
1095 PyObject *ret;
1096
1097 BLI_assert(prop_store != nullptr);
1098
1099 py_func = prop_store->py_data.set_fn;
1100
1101 args = PyTuple_New(2);
1103 PyTuple_SET_ITEM(args, 0, self);
1104
1105 PyTuple_SET_ITEM(args, 1, PyFloat_FromDouble(value));
1106
1107 ret = PyObject_CallObject(py_func, args);
1108
1109 Py_DECREF(args);
1110
1111 if (ret == nullptr) {
1112 PyC_Err_PrintWithFunc(py_func);
1113 }
1114 else {
1115 if (ret != Py_None) {
1116 PyErr_SetString(PyExc_ValueError, "the return value must be None");
1117 PyC_Err_PrintWithFunc(py_func);
1118 }
1119
1120 Py_DECREF(ret);
1121 }
1122
1124}
1125
1126static void bpy_prop_float_array_get_fn(PointerRNA *ptr, PropertyRNA *prop, float *values)
1127{
1129
1130 BPyPropStore *prop_store = static_cast<BPyPropStore *>(RNA_property_py_data_get(prop));
1131 PyObject *py_func;
1132 PyObject *args;
1133 PyObject *self;
1134 PyObject *ret;
1135
1136 bool is_values_set = false;
1137 int i, len = RNA_property_array_length(ptr, prop);
1138 BPyPropArrayLength array_len_info{};
1139 array_len_info.len_total = len;
1140 array_len_info.dims_len = RNA_property_array_dimension(ptr, prop, array_len_info.dims);
1141
1142 BLI_assert(prop_store != nullptr);
1143
1144 py_func = prop_store->py_data.get_fn;
1145
1146 args = PyTuple_New(1);
1148 PyTuple_SET_ITEM(args, 0, self);
1149
1150 ret = PyObject_CallObject(py_func, args);
1151
1152 Py_DECREF(args);
1153
1154 if (ret != nullptr) {
1156 sizeof(*values),
1157 ret,
1158 &array_len_info,
1159 &PyFloat_Type,
1160 "FloatVectorProperty get callback") == -1)
1161 {
1162 PyC_Err_PrintWithFunc(py_func);
1163 }
1164 else {
1165 /* Only for float types. */
1166 if (bpy_prop_array_is_matrix_compatible(prop, &array_len_info)) {
1167 bpy_prop_array_matrix_swap_row_column_vn(values, &array_len_info);
1168 }
1169 is_values_set = true;
1170 }
1171 Py_DECREF(ret);
1172 }
1173
1174 if (is_values_set == false) {
1175 /* This is the flattened length for multi-dimensional arrays. */
1176 for (i = 0; i < len; i++) {
1177 values[i] = 0.0f;
1178 }
1179 }
1180
1182}
1183
1184static void bpy_prop_float_array_set_fn(PointerRNA *ptr, PropertyRNA *prop, const float *values)
1185{
1187
1188 BPyPropStore *prop_store = static_cast<BPyPropStore *>(RNA_property_py_data_get(prop));
1189 PyObject *py_func;
1190 PyObject *args;
1191 PyObject *self;
1192 PyObject *ret;
1193 PyObject *py_values;
1194
1195 const int len = RNA_property_array_length(ptr, prop);
1196 BPyPropArrayLength array_len_info{};
1197 array_len_info.len_total = len;
1198 array_len_info.dims_len = RNA_property_array_dimension(ptr, prop, array_len_info.dims);
1199
1200 BLI_assert(prop_store != nullptr);
1201
1202 py_func = prop_store->py_data.set_fn;
1203
1204 args = PyTuple_New(2);
1206 PyTuple_SET_ITEM(args, 0, self);
1207
1208 if (array_len_info.dims_len == 0) {
1209 py_values = PyC_Tuple_PackArray_F32(values, len);
1210 }
1211 else {
1212 /* No need for matrix column/row swapping here unless the matrix data is read directly. */
1214 values, array_len_info.dims, array_len_info.dims_len);
1215 }
1216 PyTuple_SET_ITEM(args, 1, py_values);
1217
1218 ret = PyObject_CallObject(py_func, args);
1219
1220 Py_DECREF(args);
1221
1222 if (ret == nullptr) {
1223 PyC_Err_PrintWithFunc(py_func);
1224 }
1225 else {
1226 if (ret != Py_None) {
1227 PyErr_SetString(PyExc_ValueError, "the return value must be None");
1228 PyC_Err_PrintWithFunc(py_func);
1229 }
1230
1231 Py_DECREF(ret);
1232 }
1233
1235}
1236
1238
1239/* -------------------------------------------------------------------- */
1242
1243static void bpy_prop_string_get_fn(PointerRNA *ptr, PropertyRNA *prop, char *value)
1244{
1246
1247 BPyPropStore *prop_store = static_cast<BPyPropStore *>(RNA_property_py_data_get(prop));
1248 PyObject *py_func;
1249 PyObject *args;
1250 PyObject *self;
1251 PyObject *ret;
1252
1253 BLI_assert(prop_store != nullptr);
1254
1255 py_func = prop_store->py_data.get_fn;
1256
1257 args = PyTuple_New(1);
1259 PyTuple_SET_ITEM(args, 0, self);
1260
1261 ret = PyObject_CallObject(py_func, args);
1262
1263 Py_DECREF(args);
1264
1265 if (ret == nullptr) {
1266 PyC_Err_PrintWithFunc(py_func);
1267 value[0] = '\0';
1268 }
1269 else if (!PyUnicode_Check(ret)) {
1270 PyErr_Format(
1271 PyExc_TypeError, "return value must be a string, not %.200s", Py_TYPE(ret)->tp_name);
1272 PyC_Err_PrintWithFunc(py_func);
1273 value[0] = '\0';
1274 Py_DECREF(ret);
1275 }
1276 else {
1277 Py_ssize_t length;
1278 const char *buffer = PyUnicode_AsUTF8AndSize(ret, &length);
1279 memcpy(value, buffer, length + 1);
1280 Py_DECREF(ret);
1281 }
1282
1284}
1285
1287{
1289
1290 BPyPropStore *prop_store = static_cast<BPyPropStore *>(RNA_property_py_data_get(prop));
1291 PyObject *py_func;
1292 PyObject *args;
1293 PyObject *self;
1294 PyObject *ret;
1295
1296 int length;
1297
1298 BLI_assert(prop_store != nullptr);
1299
1300 py_func = prop_store->py_data.get_fn;
1301
1302 args = PyTuple_New(1);
1304 PyTuple_SET_ITEM(args, 0, self);
1305
1306 ret = PyObject_CallObject(py_func, args);
1307
1308 Py_DECREF(args);
1309
1310 if (ret == nullptr) {
1311 PyC_Err_PrintWithFunc(py_func);
1312 length = 0;
1313 }
1314 else if (!PyUnicode_Check(ret)) {
1315 PyErr_Format(
1316 PyExc_TypeError, "return value must be a string, not %.200s", Py_TYPE(ret)->tp_name);
1317 PyC_Err_PrintWithFunc(py_func);
1318 length = 0;
1319 Py_DECREF(ret);
1320 }
1321 else {
1322 Py_ssize_t length_ssize = 0;
1323 PyUnicode_AsUTF8AndSize(ret, &length_ssize);
1324 length = length_ssize;
1325 Py_DECREF(ret);
1326 }
1327
1329
1330 return length;
1331}
1332
1333static void bpy_prop_string_set_fn(PointerRNA *ptr, PropertyRNA *prop, const char *value)
1334{
1336
1337 BPyPropStore *prop_store = static_cast<BPyPropStore *>(RNA_property_py_data_get(prop));
1338 PyObject *py_func;
1339 PyObject *args;
1340 PyObject *self;
1341 PyObject *ret;
1342
1343 PyObject *py_value;
1344
1345 BLI_assert(prop_store != nullptr);
1346
1347 py_func = prop_store->py_data.set_fn;
1348
1349 args = PyTuple_New(2);
1351 PyTuple_SET_ITEM(args, 0, self);
1352
1353 py_value = PyUnicode_FromString(value);
1354 if (!py_value) {
1355 PyErr_SetString(PyExc_ValueError, "the return value must be a string");
1356 PyC_Err_PrintWithFunc(py_func);
1357 }
1358 else {
1359 PyTuple_SET_ITEM(args, 1, py_value);
1360 }
1361
1362 ret = PyObject_CallObject(py_func, args);
1363
1364 Py_DECREF(args);
1365
1366 if (ret == nullptr) {
1367 PyC_Err_PrintWithFunc(py_func);
1368 }
1369 else {
1370 if (ret != Py_None) {
1371 PyErr_SetString(PyExc_ValueError, "the return value must be None");
1372 PyC_Err_PrintWithFunc(py_func);
1373 }
1374
1375 Py_DECREF(ret);
1376 }
1377
1379}
1380
1382 PyObject *py_func,
1383 PyObject *item,
1385{
1386 const char *text;
1387 const char *info = nullptr;
1388
1389 if (PyTuple_CheckExact(item)) {
1390 /* Positional only. */
1391 static const char *_keywords[] = {
1392 "",
1393 "",
1394 nullptr,
1395 };
1396 static _PyArg_Parser _parser = {
1398 "s" /* `text` */
1399 "s" /* `info` */
1400 ":search",
1401 _keywords,
1402 nullptr,
1403 };
1404 if (!_PyArg_ParseTupleAndKeywordsFast(item, nullptr, &_parser, &text, &info)) {
1405 PyC_Err_PrintWithFunc(py_func);
1406 return false;
1407 }
1408 }
1409 else {
1410 text = PyUnicode_AsUTF8(item);
1411 if (UNLIKELY(text == nullptr)) {
1412 PyErr_Clear();
1413 PyErr_Format(PyExc_TypeError,
1414 "expected sequence of strings or tuple pairs of strings, not %.200s",
1415 Py_TYPE(item)->tp_name);
1416 PyC_Err_PrintWithFunc(py_func);
1417 return false;
1418 }
1419 }
1420
1421 StringPropertySearchVisitParams visit_params{};
1422 visit_params.text = text;
1423 visit_params.info = info ? info : "";
1424 visit_fn(visit_params);
1425 return true;
1426}
1427
1429 const bContext *C,
1430 PointerRNA *ptr,
1431 PropertyRNA *prop,
1432 const char *edit_text,
1434{
1435 PyGILState_STATE gilstate;
1436 if (C) {
1437 bpy_context_set((bContext *)C, &gilstate);
1438 }
1439 else {
1440 gilstate = PyGILState_Ensure();
1441 }
1442
1443 BPyPropStore *prop_store = static_cast<BPyPropStore *>(RNA_property_py_data_get(prop));
1444 PyObject *py_func;
1445 PyObject *args;
1446 PyObject *self;
1447 PyObject *ret;
1448 PyObject *py_edit_text;
1449
1450 BLI_assert(prop_store != nullptr);
1451
1452 py_func = prop_store->py_data.string_data.search_fn;
1453
1454 args = PyTuple_New(3);
1456 PyTuple_SET_ITEM(args, 0, self);
1457
1458 Py_INCREF(bpy_context_module);
1459 PyTuple_SET_ITEM(args, 1, (PyObject *)bpy_context_module);
1460
1461 py_edit_text = PyUnicode_FromString(edit_text);
1462 PyTuple_SET_ITEM(args, 2, py_edit_text);
1463
1464 ret = PyObject_CallObject(py_func, args);
1465
1466 Py_DECREF(args);
1467
1468 if (ret == nullptr) {
1469 PyC_Err_PrintWithFunc(py_func);
1470 }
1471 else {
1472 if (PyIter_Check(ret)) {
1473 /* Iterators / generator types. */
1474 PyObject *it;
1475 PyObject *(*iternext)(PyObject *);
1476 it = PyObject_GetIter(ret);
1477 if (it == nullptr) {
1478 PyC_Err_PrintWithFunc(py_func);
1479 }
1480 else {
1481 iternext = *Py_TYPE(it)->tp_iternext;
1482 for (;;) {
1483 PyObject *py_text = iternext(it);
1484 if (py_text == nullptr) {
1485 break;
1486 }
1487 const bool ok = bpy_prop_string_visit_fn_call(py_func, py_text, visit_fn);
1488 Py_DECREF(py_text);
1489 if (!ok) {
1490 break;
1491 }
1492 }
1493 Py_DECREF(it);
1494 if (PyErr_Occurred()) {
1495 if (PyErr_ExceptionMatches(PyExc_StopIteration)) {
1496 PyErr_Clear();
1497 }
1498 else {
1499 PyC_Err_PrintWithFunc(py_func);
1500 }
1501 }
1502 }
1503 }
1504 else {
1505 /* Sequence (typically list/tuple). */
1506 PyObject *ret_fast = PySequence_Fast(
1507 ret,
1508 "StringProperty(...): "
1509 "return value from search callback was not a sequence, iterator or generator");
1510 if (ret_fast == nullptr) {
1511 PyC_Err_PrintWithFunc(py_func);
1512 }
1513 else {
1514 const Py_ssize_t ret_num = PySequence_Fast_GET_SIZE(ret_fast);
1515 PyObject **ret_fast_items = PySequence_Fast_ITEMS(ret_fast);
1516 for (Py_ssize_t i = 0; i < ret_num; i++) {
1517 const bool ok = bpy_prop_string_visit_fn_call(py_func, ret_fast_items[i], visit_fn);
1518 if (!ok) {
1519 break;
1520 }
1521 }
1522 Py_DECREF(ret_fast);
1523 }
1524 }
1525
1526 Py_DECREF(ret);
1527 }
1528
1529 if (C) {
1530 bpy_context_clear((bContext *)C, &gilstate);
1531 }
1532 else {
1533 PyGILState_Release(gilstate);
1534 }
1535}
1536
1538
1539/* -------------------------------------------------------------------- */
1542
1544{
1546
1547 BPyPropStore *prop_store = static_cast<BPyPropStore *>(RNA_property_py_data_get(prop));
1548 PyObject *py_self;
1549 PyObject *py_candidate;
1550 PyObject *py_func;
1551 PyObject *args;
1552 PyObject *ret;
1553 bool result;
1554
1555 BLI_assert(self != nullptr);
1556
1557 py_self = pyrna_struct_as_instance(self);
1558 py_candidate = pyrna_struct_as_instance(&candidate);
1559 py_func = prop_store->py_data.pointer_data.poll_fn;
1560
1561 args = PyTuple_New(2);
1562 PyTuple_SET_ITEM(args, 0, py_self);
1563 PyTuple_SET_ITEM(args, 1, py_candidate);
1564
1565 ret = PyObject_CallObject(py_func, args);
1566
1567 Py_DECREF(args);
1568
1569 if (ret == nullptr) {
1570 PyC_Err_PrintWithFunc(py_func);
1571 result = false;
1572 }
1573 else {
1574 result = PyObject_IsTrue(ret);
1575 Py_DECREF(ret);
1576 }
1577
1579
1580 return result;
1581}
1582
1584
1585/* -------------------------------------------------------------------- */
1588
1590{
1592
1593 BPyPropStore *prop_store = static_cast<BPyPropStore *>(RNA_property_py_data_get(prop));
1594 PyObject *py_func;
1595 PyObject *args;
1596 PyObject *self;
1597 PyObject *ret;
1598
1599 int value;
1600
1601 BLI_assert(prop_store != nullptr);
1602
1603 py_func = prop_store->py_data.get_fn;
1604
1605 args = PyTuple_New(1);
1607 PyTuple_SET_ITEM(args, 0, self);
1608
1609 ret = PyObject_CallObject(py_func, args);
1610
1611 Py_DECREF(args);
1612
1613 if (ret == nullptr) {
1614 PyC_Err_PrintWithFunc(py_func);
1615 value = RNA_property_enum_get_default(ptr, prop);
1616 }
1617 else {
1618 value = PyC_Long_AsI32(ret);
1619
1620 if (value == -1 && PyErr_Occurred()) {
1621 PyC_Err_PrintWithFunc(py_func);
1622 value = RNA_property_enum_get_default(ptr, prop);
1623 }
1624
1625 Py_DECREF(ret);
1626 }
1627
1629
1630 return value;
1631}
1632
1633static void bpy_prop_enum_set_fn(PointerRNA *ptr, PropertyRNA *prop, int value)
1634{
1636
1637 BPyPropStore *prop_store = static_cast<BPyPropStore *>(RNA_property_py_data_get(prop));
1638 PyObject *py_func;
1639 PyObject *args;
1640 PyObject *self;
1641 PyObject *ret;
1642
1643 BLI_assert(prop_store != nullptr);
1644
1645 py_func = prop_store->py_data.set_fn;
1646
1647 args = PyTuple_New(2);
1649 PyTuple_SET_ITEM(args, 0, self);
1650
1651 PyTuple_SET_ITEM(args, 1, PyLong_FromLong(value));
1652
1653 ret = PyObject_CallObject(py_func, args);
1654
1655 Py_DECREF(args);
1656
1657 if (ret == nullptr) {
1658 PyC_Err_PrintWithFunc(py_func);
1659 }
1660 else {
1661 if (ret != Py_None) {
1662 PyErr_SetString(PyExc_ValueError, "the return value must be None");
1663 PyC_Err_PrintWithFunc(py_func);
1664 }
1665
1666 Py_DECREF(ret);
1667 }
1668
1670}
1671
1672/* utility function we need for parsing int's in an if statement */
1673static bool py_long_as_int(PyObject *py_long, int *r_int)
1674{
1675 if (PyLong_CheckExact(py_long)) {
1676 *r_int = int(PyLong_AS_LONG(py_long));
1677 return true;
1678 }
1679
1680 return false;
1681}
1682
1683#ifdef USE_ENUM_COPY_STRINGS
1684/* copies orig to buf, then sets orig to buf, returns copy length */
1685static size_t strswapbufcpy(char *buf, const char **orig)
1686{
1687 const char *src = *orig;
1688 char *dst = buf;
1689 size_t i = 0;
1690 *orig = buf;
1691 while ((*dst = *src)) {
1692 dst++;
1693 src++;
1694 i++;
1695 }
1696 return i + 1; /* include '\0' */
1697}
1698#endif
1699
1700static int icon_id_from_name(const char *name)
1701{
1702 const EnumPropertyItem *item;
1703 int id;
1704
1705 if (name[0]) {
1706 for (item = rna_enum_icon_items, id = 0; item->identifier; item++, id++) {
1707 if (STREQ(item->name, name)) {
1708 return item->value;
1709 }
1710 }
1711 }
1712
1713 return 0;
1714}
1715
1716static const EnumPropertyItem *enum_items_from_py(PyObject *seq_fast,
1717 const bool is_enum_flag,
1718 PyObject *default_py,
1719 int *r_default_value)
1720{
1721 EnumPropertyItem *items;
1722 PyObject *item;
1723 const Py_ssize_t seq_len = PySequence_Fast_GET_SIZE(seq_fast);
1724 PyObject **seq_fast_items = PySequence_Fast_ITEMS(seq_fast);
1725 int i;
1726#ifdef USE_ENUM_COPY_STRINGS
1727 Py_ssize_t totbuf = 0;
1728#endif
1729 short default_used = 0;
1730 const char *default_str_cmp = nullptr;
1731 int default_int_cmp = 0;
1732
1733 if (is_enum_flag) {
1734 if (seq_len > RNA_ENUM_BITFLAG_SIZE) {
1735 PyErr_SetString(PyExc_TypeError,
1736 "EnumProperty(...): maximum " STRINGIFY(
1737 RNA_ENUM_BITFLAG_SIZE) " members for a ENUM_FLAG type property");
1738 return nullptr;
1739 }
1740 if (default_py && !PySet_Check(default_py)) {
1741 PyErr_Format(PyExc_TypeError,
1742 "EnumProperty(...): default option must be a 'set' "
1743 "type when ENUM_FLAG is enabled, not a '%.200s'",
1744 Py_TYPE(default_py)->tp_name);
1745 return nullptr;
1746 }
1747 }
1748 else {
1749 if (default_py) {
1750 if (!py_long_as_int(default_py, &default_int_cmp)) {
1751 default_str_cmp = PyUnicode_AsUTF8(default_py);
1752 if (default_str_cmp == nullptr) {
1753 PyErr_Format(PyExc_TypeError,
1754 "EnumProperty(...): default option must be a 'str' or 'int' "
1755 "type when ENUM_FLAG is disabled, not a '%.200s'",
1756 Py_TYPE(default_py)->tp_name);
1757 return nullptr;
1758 }
1759 }
1760 }
1761 }
1762
1763 /* blank value */
1764 *r_default_value = 0;
1765
1766 items = MEM_calloc_arrayN<EnumPropertyItem>(size_t(seq_len) + 1, "enum_items_from_py1");
1767
1768 for (i = 0; i < seq_len; i++) {
1769 EnumPropertyItem tmp = {0, "", 0, "", ""};
1770 const char *tmp_icon = nullptr;
1771 Py_ssize_t item_size;
1772 Py_ssize_t id_str_len;
1773 Py_ssize_t name_str_len;
1774 Py_ssize_t desc_str_len;
1775
1776 item = seq_fast_items[i];
1777
1778 if (PyTuple_CheckExact(item) && (item_size = PyTuple_GET_SIZE(item)) &&
1779 (item_size >= 3 && item_size <= 5) &&
1780 (tmp.identifier = PyUnicode_AsUTF8AndSize(PyTuple_GET_ITEM(item, 0), &id_str_len)) &&
1781 (tmp.name = PyUnicode_AsUTF8AndSize(PyTuple_GET_ITEM(item, 1), &name_str_len)) &&
1782 (tmp.description = PyUnicode_AsUTF8AndSize(PyTuple_GET_ITEM(item, 2), &desc_str_len)) &&
1783 /* TODO: number isn't ensured to be unique from the script author. */
1784 (item_size != 4 || py_long_as_int(PyTuple_GET_ITEM(item, 3), &tmp.value)) &&
1785 (item_size != 5 || ((py_long_as_int(PyTuple_GET_ITEM(item, 3), &tmp.icon) ||
1786 (tmp_icon = PyUnicode_AsUTF8(PyTuple_GET_ITEM(item, 3)))) &&
1787 py_long_as_int(PyTuple_GET_ITEM(item, 4), &tmp.value))))
1788 {
1789 if (is_enum_flag) {
1790 if (item_size < 4) {
1791 tmp.value = 1 << i;
1792 }
1793
1794 if (default_py && PySet_Contains(default_py, PyTuple_GET_ITEM(item, 0))) {
1795 *r_default_value |= tmp.value;
1796 default_used++;
1797 }
1798 }
1799 else {
1800 if (item_size < 4) {
1801 tmp.value = i;
1802 }
1803
1804 if (default_py && default_used == 0) {
1805 if ((default_str_cmp != nullptr && STREQ(default_str_cmp, tmp.identifier)) ||
1806 (default_str_cmp == nullptr && default_int_cmp == tmp.value))
1807 {
1808 *r_default_value = tmp.value;
1809 default_used++; /* only ever 1 */
1810 }
1811 }
1812 }
1813
1814 if (tmp_icon) {
1815 tmp.icon = icon_id_from_name(tmp_icon);
1816 }
1817
1818 items[i] = tmp;
1819
1820#ifdef USE_ENUM_COPY_STRINGS
1821 /* Calculate combine string length. */
1822 totbuf += id_str_len + name_str_len + desc_str_len + 3; /* 3 is for '\0's */
1823#endif
1824 }
1825 else if (item == Py_None) {
1826 /* Only set since the rest is cleared. */
1827 items[i].identifier = "";
1828 }
1829 else {
1830 MEM_freeN(items);
1831 PyErr_SetString(PyExc_TypeError,
1832 "EnumProperty(...): expected a tuple containing "
1833 "(identifier, name, description) and optionally an "
1834 "icon name and unique number");
1835 return nullptr;
1836 }
1837 }
1838
1839 if (is_enum_flag) {
1840 /* strict check that all set members were used */
1841 if (default_py && default_used != PySet_GET_SIZE(default_py)) {
1842 MEM_freeN(items);
1843
1844 PyErr_Format(PyExc_TypeError,
1845 "EnumProperty(..., default={...}): set has %d unused member(s)",
1846 PySet_GET_SIZE(default_py) - default_used);
1847 return nullptr;
1848 }
1849 }
1850 else {
1851 if (default_py && default_used == 0) {
1852 MEM_freeN(items);
1853
1854 if (default_str_cmp) {
1855 PyErr_Format(PyExc_TypeError,
1856 "EnumProperty(..., default=\'%s\'): not found in enum members",
1857 default_str_cmp);
1858 }
1859 else {
1860 PyErr_Format(PyExc_TypeError,
1861 "EnumProperty(..., default=%d): not found in enum members",
1862 default_int_cmp);
1863 }
1864 return nullptr;
1865 }
1866 }
1867
1868#ifdef USE_ENUM_COPY_STRINGS
1869 /* This would all work perfectly _but_ the python strings may be freed immediately after use,
1870 * so we need to duplicate them, ugh. annoying because it works most of the time without this. */
1871 {
1872 EnumPropertyItem *items_dup = MEM_mallocN((sizeof(EnumPropertyItem) * (seq_len + 1)) +
1873 (sizeof(char) * totbuf),
1874 "enum_items_from_py2");
1875 EnumPropertyItem *items_ptr = items_dup;
1876 char *buf = ((char *)items_dup) + (sizeof(EnumPropertyItem) * (seq_len + 1));
1877 memcpy(items_dup, items, sizeof(EnumPropertyItem) * (seq_len + 1));
1878 for (i = 0; i < seq_len; i++, items_ptr++) {
1879 buf += strswapbufcpy(buf, &items_ptr->identifier);
1880 buf += strswapbufcpy(buf, &items_ptr->name);
1881 buf += strswapbufcpy(buf, &items_ptr->description);
1882 }
1883 MEM_freeN(items);
1884 items = items_dup;
1885 }
1886/* end string duplication */
1887#endif
1888
1889 return items;
1890}
1891
1893 PointerRNA *ptr,
1894 PropertyRNA *prop,
1895 bool *r_free)
1896{
1897 PyGILState_STATE gilstate;
1898 if (C) {
1899 bpy_context_set(C, &gilstate);
1900 }
1901 else {
1902 gilstate = PyGILState_Ensure();
1903 }
1904
1905 BPyPropStore *prop_store = static_cast<BPyPropStore *>(RNA_property_py_data_get(prop));
1906 PyObject *py_func = prop_store->py_data.enum_data.itemf_fn;
1907 PyObject *self = nullptr;
1908 PyObject *args;
1909 PyObject *items; /* returned from the function call */
1910
1911 const EnumPropertyItem *eitems = nullptr;
1912 int err = 0;
1913
1914 args = PyTuple_New(2);
1916 PyTuple_SET_ITEM(args, 0, self);
1917
1918 /* now get the context */
1919 if (C) {
1920 PyTuple_SET_ITEM(args, 1, (PyObject *)bpy_context_module);
1921 Py_INCREF(bpy_context_module);
1922 }
1923 else {
1924 PyTuple_SET_ITEM(args, 1, Py_None);
1925 Py_INCREF(Py_None);
1926 }
1927
1928 items = PyObject_CallObject(py_func, args);
1929
1930 Py_DECREF(args);
1931
1932 if (items == nullptr) {
1933 err = -1;
1934 }
1935 else {
1936 PyObject *items_fast;
1937 int default_value_dummy = 0;
1938
1939 if (!(items_fast = PySequence_Fast(items,
1940 "EnumProperty(...): "
1941 "return value from the callback was not a sequence")))
1942 {
1943 err = -1;
1944 }
1945 else {
1946 eitems = enum_items_from_py(items_fast,
1947 (RNA_property_flag(prop) & PROP_ENUM_FLAG) != 0,
1948 nullptr,
1949 &default_value_dummy);
1950
1951 Py_DECREF(items_fast);
1952
1953 if (!eitems) {
1954 err = -1;
1955 }
1956 }
1957
1958 Py_DECREF(items);
1959 }
1960
1961 if (err != -1) { /* worked */
1962 *r_free = true;
1963 }
1964 else {
1965 PyC_Err_PrintWithFunc(py_func);
1966
1968 }
1969
1970 if (C) {
1971 bpy_context_clear(C, &gilstate);
1972 }
1973 else {
1974 PyGILState_Release(gilstate);
1975 }
1976
1977 return eitems;
1978}
1979
1980static int bpy_prop_callback_check(PyObject *py_func, const char *keyword, int argcount)
1981{
1982 if (py_func && py_func != Py_None) {
1983 if (!PyFunction_Check(py_func)) {
1984 PyErr_Format(PyExc_TypeError,
1985 "%s keyword: expected a function type, not a %.200s",
1986 keyword,
1987 Py_TYPE(py_func)->tp_name);
1988 return -1;
1989 }
1990
1991 PyCodeObject *f_code = (PyCodeObject *)PyFunction_GET_CODE(py_func);
1992 if (f_code->co_argcount != argcount) {
1993 PyErr_Format(PyExc_TypeError,
1994 "%s keyword: expected a function taking %d arguments, not %d",
1995 keyword,
1996 argcount,
1997 f_code->co_argcount);
1998 return -1;
1999 }
2000 }
2001
2002 return 0;
2003}
2004
2006
2007/* -------------------------------------------------------------------- */
2010
2011static void bpy_prop_callback_assign_update(PropertyRNA *prop, PyObject *update_fn)
2012{
2013 /* assume this is already checked for type and arg length */
2014 if (update_fn && update_fn != Py_None) {
2015 BPyPropStore *prop_store = bpy_prop_py_data_ensure(prop);
2016
2018 ASSIGN_PYOBJECT_INCREF(prop_store->py_data.update_fn, update_fn);
2019 }
2020}
2021
2022static void bpy_prop_callback_assign_pointer(PropertyRNA *prop, PyObject *poll_fn)
2023{
2024 if (poll_fn && poll_fn != Py_None) {
2025 BPyPropStore *prop_store = bpy_prop_py_data_ensure(prop);
2026
2027 RNA_def_property_poll_runtime(prop, reinterpret_cast<const void *>(bpy_prop_pointer_poll_fn));
2028 ASSIGN_PYOBJECT_INCREF(prop_store->py_data.pointer_data.poll_fn, poll_fn);
2029 }
2030}
2031
2032static void bpy_prop_callback_assign_boolean(PropertyRNA *prop, PyObject *get_fn, PyObject *set_fn)
2033{
2034 BooleanPropertyGetFunc rna_get_fn = nullptr;
2035 BooleanPropertySetFunc rna_set_fn = nullptr;
2036
2037 if (get_fn && get_fn != Py_None) {
2038 BPyPropStore *prop_store = bpy_prop_py_data_ensure(prop);
2039
2040 rna_get_fn = bpy_prop_boolean_get_fn;
2041 ASSIGN_PYOBJECT_INCREF(prop_store->py_data.get_fn, get_fn);
2042 }
2043
2044 if (set_fn && set_fn != Py_None) {
2045 BPyPropStore *prop_store = bpy_prop_py_data_ensure(prop);
2046
2047 rna_set_fn = bpy_prop_boolean_set_fn;
2048 ASSIGN_PYOBJECT_INCREF(prop_store->py_data.set_fn, set_fn);
2049 }
2050
2051 RNA_def_property_boolean_funcs_runtime(prop, rna_get_fn, rna_set_fn);
2052}
2053
2055 PyObject *get_fn,
2056 PyObject *set_fn)
2057{
2058 BooleanArrayPropertyGetFunc rna_get_fn = nullptr;
2059 BooleanArrayPropertySetFunc rna_set_fn = nullptr;
2060
2061 if (get_fn && get_fn != Py_None) {
2062 BPyPropStore *prop_store = bpy_prop_py_data_ensure(prop);
2063
2064 rna_get_fn = bpy_prop_boolean_array_get_fn;
2065 ASSIGN_PYOBJECT_INCREF(prop_store->py_data.get_fn, get_fn);
2066 }
2067
2068 if (set_fn && set_fn != Py_None) {
2069 BPyPropStore *prop_store = bpy_prop_py_data_ensure(prop);
2070
2071 rna_set_fn = bpy_prop_boolean_array_set_fn;
2072 ASSIGN_PYOBJECT_INCREF(prop_store->py_data.set_fn, set_fn);
2073 }
2074
2075 RNA_def_property_boolean_array_funcs_runtime(prop, rna_get_fn, rna_set_fn);
2076}
2077
2078static void bpy_prop_callback_assign_int(PropertyRNA *prop, PyObject *get_fn, PyObject *set_fn)
2079{
2080 IntPropertyGetFunc rna_get_fn = nullptr;
2081 IntPropertySetFunc rna_set_fn = nullptr;
2082
2083 if (get_fn && get_fn != Py_None) {
2084 BPyPropStore *prop_store = bpy_prop_py_data_ensure(prop);
2085
2086 rna_get_fn = bpy_prop_int_get_fn;
2087 ASSIGN_PYOBJECT_INCREF(prop_store->py_data.get_fn, get_fn);
2088 }
2089
2090 if (set_fn && set_fn != Py_None) {
2091 BPyPropStore *prop_store = bpy_prop_py_data_ensure(prop);
2092
2093 rna_set_fn = bpy_prop_int_set_fn;
2094 ASSIGN_PYOBJECT_INCREF(prop_store->py_data.set_fn, set_fn);
2095 }
2096
2097 RNA_def_property_int_funcs_runtime(prop, rna_get_fn, rna_set_fn, nullptr);
2098}
2099
2101 PyObject *get_fn,
2102 PyObject *set_fn)
2103{
2104 IntArrayPropertyGetFunc rna_get_fn = nullptr;
2105 IntArrayPropertySetFunc rna_set_fn = nullptr;
2106
2107 if (get_fn && get_fn != Py_None) {
2108 BPyPropStore *prop_store = bpy_prop_py_data_ensure(prop);
2109
2110 rna_get_fn = bpy_prop_int_array_get_fn;
2111 ASSIGN_PYOBJECT_INCREF(prop_store->py_data.get_fn, get_fn);
2112 }
2113
2114 if (set_fn && set_fn != Py_None) {
2115 BPyPropStore *prop_store = bpy_prop_py_data_ensure(prop);
2116
2117 rna_set_fn = bpy_prop_int_array_set_fn;
2118 ASSIGN_PYOBJECT_INCREF(prop_store->py_data.set_fn, set_fn);
2119 }
2120
2121 RNA_def_property_int_array_funcs_runtime(prop, rna_get_fn, rna_set_fn, nullptr);
2122}
2123
2124static void bpy_prop_callback_assign_float(PropertyRNA *prop, PyObject *get_fn, PyObject *set_fn)
2125{
2126 FloatPropertyGetFunc rna_get_fn = nullptr;
2127 FloatPropertySetFunc rna_set_fn = nullptr;
2128
2129 if (get_fn && get_fn != Py_None) {
2130 BPyPropStore *prop_store = bpy_prop_py_data_ensure(prop);
2131
2132 rna_get_fn = bpy_prop_float_get_fn;
2133 ASSIGN_PYOBJECT_INCREF(prop_store->py_data.get_fn, get_fn);
2134 }
2135
2136 if (set_fn && set_fn != Py_None) {
2137 BPyPropStore *prop_store = bpy_prop_py_data_ensure(prop);
2138
2139 rna_set_fn = bpy_prop_float_set_fn;
2140 ASSIGN_PYOBJECT_INCREF(prop_store->py_data.set_fn, set_fn);
2141 }
2142
2143 RNA_def_property_float_funcs_runtime(prop, rna_get_fn, rna_set_fn, nullptr);
2144}
2145
2147 PyObject *get_fn,
2148 PyObject *set_fn)
2149{
2150 FloatArrayPropertyGetFunc rna_get_fn = nullptr;
2151 FloatArrayPropertySetFunc rna_set_fn = nullptr;
2152
2153 if (get_fn && get_fn != Py_None) {
2154 BPyPropStore *prop_store = bpy_prop_py_data_ensure(prop);
2155
2156 rna_get_fn = bpy_prop_float_array_get_fn;
2157 ASSIGN_PYOBJECT_INCREF(prop_store->py_data.get_fn, get_fn);
2158 }
2159
2160 if (set_fn && set_fn != Py_None) {
2161 BPyPropStore *prop_store = bpy_prop_py_data_ensure(prop);
2162
2163 rna_set_fn = bpy_prop_float_array_set_fn;
2164 ASSIGN_PYOBJECT_INCREF(prop_store->py_data.set_fn, set_fn);
2165 }
2166
2167 RNA_def_property_float_array_funcs_runtime(prop, rna_get_fn, rna_set_fn, nullptr);
2168}
2169
2171 PyObject *get_fn,
2172 PyObject *set_fn,
2173 PyObject *search_fn,
2174 const eStringPropertySearchFlag search_flag)
2175{
2176 StringPropertyGetFunc rna_get_fn = nullptr;
2177 StringPropertyLengthFunc rna_length_fn = nullptr;
2178 StringPropertySetFunc rna_set_fn = nullptr;
2179 StringPropertySearchFunc rna_search_fn = nullptr;
2180
2181 if (get_fn && get_fn != Py_None) {
2182 BPyPropStore *prop_store = bpy_prop_py_data_ensure(prop);
2183
2184 rna_get_fn = bpy_prop_string_get_fn;
2185 rna_length_fn = bpy_prop_string_length_fn;
2186 ASSIGN_PYOBJECT_INCREF(prop_store->py_data.get_fn, get_fn);
2187 }
2188
2189 if (set_fn && set_fn != Py_None) {
2190 BPyPropStore *prop_store = bpy_prop_py_data_ensure(prop);
2191
2192 rna_set_fn = bpy_prop_string_set_fn;
2193 ASSIGN_PYOBJECT_INCREF(prop_store->py_data.set_fn, set_fn);
2194 }
2195 if (search_fn) {
2196 BPyPropStore *prop_store = bpy_prop_py_data_ensure(prop);
2197
2199 ASSIGN_PYOBJECT_INCREF(prop_store->py_data.string_data.search_fn, search_fn);
2200 }
2201
2202 RNA_def_property_string_funcs_runtime(prop, rna_get_fn, rna_length_fn, rna_set_fn);
2203 if (rna_search_fn) {
2204 RNA_def_property_string_search_func_runtime(prop, rna_search_fn, search_flag);
2205 }
2206}
2207
2209 PyObject *get_fn,
2210 PyObject *set_fn,
2211 PyObject *itemf_fn)
2212{
2213 EnumPropertyGetFunc rna_get_fn = nullptr;
2214 EnumPropertyItemFunc rna_itemf_fn = nullptr;
2215 EnumPropertySetFunc rna_set_fn = nullptr;
2216
2217 if (get_fn && get_fn != Py_None) {
2218 BPyPropStore *prop_store = bpy_prop_py_data_ensure(prop);
2219
2220 rna_get_fn = bpy_prop_enum_get_fn;
2221 ASSIGN_PYOBJECT_INCREF(prop_store->py_data.get_fn, get_fn);
2222 }
2223
2224 if (set_fn && set_fn != Py_None) {
2225 BPyPropStore *prop_store = bpy_prop_py_data_ensure(prop);
2226
2227 rna_set_fn = bpy_prop_enum_set_fn;
2228 ASSIGN_PYOBJECT_INCREF(prop_store->py_data.set_fn, set_fn);
2229 }
2230
2231 if (itemf_fn && itemf_fn != Py_None) {
2232 BPyPropStore *prop_store = bpy_prop_py_data_ensure(prop);
2233 rna_itemf_fn = bpy_prop_enum_itemf_fn;
2234 ASSIGN_PYOBJECT_INCREF(prop_store->py_data.enum_data.itemf_fn, itemf_fn);
2235 }
2236
2237 RNA_def_property_enum_funcs_runtime(prop, rna_get_fn, rna_set_fn, rna_itemf_fn);
2238}
2239
2241
2242/* -------------------------------------------------------------------- */
2245
2260 PyObject *args,
2261 PyObject *kw,
2262 PyObject *method_object,
2263 PyObject **r_deferred_result)
2264{
2265 /* This must be the methods of one of the main property types defined in this file. */
2266 BLI_assert(PyCFunction_CheckExact(method_object));
2267
2268 const int args_len = PyTuple_GET_SIZE(args);
2269 PyMethodDef *method_def = ((PyCFunctionObject *)method_object)->m_ml;
2270
2271 /* Call this function with the first argument set to `self`. */
2272 if (args_len == 1) {
2273 self = PyTuple_GET_ITEM(args, 0);
2274 args = PyTuple_New(0);
2275
2276 /* This will be #BPy_BoolProperty` or one of the functions that define a type. */
2277 PyCFunctionWithKeywords method_fn = (PyCFunctionWithKeywords)(void *)method_def->ml_meth;
2278 *r_deferred_result = method_fn(self, args, kw);
2279 Py_DECREF(args);
2280 /* May be an error (depending on `r_deferred_result`). */
2281 return nullptr;
2282 }
2283
2284 const char *error_prefix = method_def->ml_name;
2285 if (args_len > 1) {
2286 PyErr_Format(PyExc_ValueError, "%s: all args must be keywords", error_prefix);
2287 *r_deferred_result = nullptr;
2288 /* An error. */
2289 return nullptr;
2290 }
2291
2292 StructRNA *srna = srna_from_self(self, error_prefix);
2293 if (srna == nullptr) {
2294 *r_deferred_result = PyErr_Occurred() ?
2295 nullptr :
2296 bpy_prop_deferred_data_CreatePyObject(method_object, kw);
2297 /* May be an error (depending on `r_deferred_result`). */
2298 return nullptr;
2299 }
2300
2301/* Crash if this is ever used by accident! */
2302#ifndef NDEBUG
2303 *r_deferred_result = (PyObject *)intptr_t(1);
2304#endif
2305
2306 /* No error or deferred result, perform registration immediately. */
2307 return srna;
2308}
2309
2321
2325static int bpy_prop_arg_parse_id(PyObject *o, void *p)
2326{
2327 BPy_PropIDParse *parse_data = static_cast<BPy_PropIDParse *>(p);
2328 StructRNA *srna = parse_data->srna;
2329
2330 if (!PyUnicode_Check(o)) {
2331 PyErr_Format(PyExc_TypeError, "expected a string (got %.200s)", Py_TYPE(o)->tp_name);
2332 return 0;
2333 }
2334
2335 Py_ssize_t id_len;
2336 const char *id;
2337
2338 id = PyUnicode_AsUTF8AndSize(o, &id_len);
2339 if (UNLIKELY(id_len >= MAX_IDPROP_NAME)) {
2340 PyErr_Format(PyExc_TypeError, "'%.200s' too long, max length is %d", id, MAX_IDPROP_NAME - 1);
2341 return 0;
2342 }
2343
2344 parse_data->prop_free_handle = nullptr;
2346 srna, id, &parse_data->prop_free_handle) == -1))
2347 {
2348 PyErr_Format(PyExc_TypeError,
2349 "'%s' is defined as a non-dynamic type for '%s'",
2350 id,
2351 RNA_struct_identifier(srna));
2352 return 0;
2353 }
2354 parse_data->value = id;
2355 return 1;
2356}
2357
2365
2370static int bpy_prop_arg_parse_tag_defines(PyObject *o, void *p)
2371{
2373 parse_data->base.items = RNA_struct_property_tag_defines(parse_data->srna);
2374 if (parse_data->base.items == nullptr) {
2375 PyErr_Format(PyExc_TypeError,
2376 "property-tags not available for '%s'",
2377 RNA_struct_identifier(parse_data->srna));
2378 return 0;
2379 }
2380 return pyrna_enum_bitfield_parse_set(o, &parse_data->base);
2381}
2382
2384
2385/* -------------------------------------------------------------------- */
2388
2389#define BPY_PROPDEF_NAME_DOC \
2390 " :arg name: Name used in the user interface.\n" \
2391 " :type name: str\n"
2392
2393#define BPY_PROPDEF_DESC_DOC \
2394 " :arg description: Text used for the tooltip and api documentation.\n" \
2395 " :type description: str\n"
2396
2397#define BPY_PROPDEF_CTXT_DOC \
2398 " :arg translation_context: Text used as context to disambiguate translations.\n" \
2399 " :type translation_context: str\n"
2400
2401#define BPY_PROPDEF_UNIT_DOC \
2402 " :arg unit: Enumerator in :ref:`rna_enum_property_unit_items`.\n" \
2403 " :type unit: str\n"
2404
2405#define BPY_PROPDEF_NUM_MIN_DOC_(ty) \
2406 " :arg min: Hard minimum, trying to assign a value below will silently assign this minimum " \
2407 "instead.\n" \
2408 " :type min: " ty "\n"
2409
2410#define BPY_PROPDEF_NUM_MAX_DOC_(ty) \
2411 " :arg max: Hard maximum, trying to assign a value above will silently assign this maximum " \
2412 "instead.\n" \
2413 " :type max: " ty "\n"
2414
2415#define BPY_PROPDEF_NUM_MINMAX_DOC(ty) BPY_PROPDEF_NUM_MIN_DOC_(ty) BPY_PROPDEF_NUM_MAX_DOC_(ty)
2416
2417#define BPY_PROPDEF_NUM_SOFT_MIN_DOC_(ty) \
2418 " :arg soft_min: Soft minimum (>= *min*), " \
2419 "user won't be able to drag the widget below this value in the UI.\n" \
2420 " :type soft_min: " ty "\n"
2421
2422#define BPY_PROPDEF_NUM_SOFT_MAX_DOC_(ty) \
2423 " :arg soft_max: Soft maximum (<= *max*), " \
2424 "user won't be able to drag the widget above this value in the UI.\n" \
2425 " :type soft_max: " ty "\n"
2426
2427#define BPY_PROPDEF_NUM_SOFT_MINMAX_DOC(ty) \
2428 BPY_PROPDEF_NUM_SOFT_MIN_DOC_(ty) BPY_PROPDEF_NUM_SOFT_MAX_DOC_(ty)
2429
2430#define BPY_PROPDEF_VECSIZE_DOC \
2431 " :arg size: Vector dimensions in [1, " STRINGIFY(PYRNA_STACK_ARRAY) "]. " \
2432"An int sequence can be used to define multi-dimension arrays.\n" \
2433" :type size: int | Sequence[int]\n"
2434
2435#define BPY_PROPDEF_INT_STEP_DOC \
2436 " :arg step: Step of increment/decrement in UI, in [1, 100], defaults to 1 (WARNING: unused " \
2437 "currently!).\n" \
2438 " :type step: int\n"
2439
2440#define BPY_PROPDEF_FLOAT_STEP_DOC \
2441 " :arg step: Step of increment/decrement in UI, in [1, 100], defaults to 3 (WARNING: actual " \
2442 "value is /100).\n" \
2443 " :type step: int\n"
2444
2445#define BPY_PROPDEF_FLOAT_PREC_DOC \
2446 " :arg precision: Maximum number of decimal digits to display, in [0, 6]. Fraction is " \
2447 "automatically hidden for exact integer values of fields with unit 'NONE' or 'TIME' (frame " \
2448 "count) and step divisible by 100.\n" \
2449 " :type precision: int\n"
2450
2451#define BPY_PROPDEF_UPDATE_DOC \
2452 " :arg update: Function to be called when this value is modified,\n" \
2453 " This function must take 2 values (self, context) and return None.\n" \
2454 " *Warning* there are no safety checks to avoid infinite recursion.\n" \
2455 " :type update: Callable[[:class:`bpy.types.bpy_struct`, :class:`bpy.types.Context`], " \
2456 "None]\n"
2457
2458#define BPY_PROPDEF_POLL_DOC \
2459 " :arg poll: Function that determines whether an item is valid for this property.\n" \
2460 " The function must take 2 values (self, object) and return a boolean.\n" \
2461 "\n" \
2462 " .. note:: The return value will be checked only when assigning an item from the UI, " \
2463 "but it is still possible to assign an \"invalid\" item to the property directly.\n" \
2464 "\n" \
2465 " :type poll: Callable[[:class:`bpy.types.bpy_struct`, :class:`bpy.types.ID`], " \
2466 "bool]\n"
2467
2468#define BPY_PROPDEF_GET_DOC(ty) \
2469 " :arg get: Function to be called when this value is 'read',\n" \
2470 " This function must take 1 value (self) and return the value of the property.\n" \
2471 " :type get: Callable[[:class:`bpy.types.bpy_struct`], " ty "]\n"
2472
2473#define BPY_PROPDEF_SET_DOC(ty) \
2474 " :arg set: Function to be called when this value is 'written',\n" \
2475 " This function must take 2 values (self, value) and return None.\n" \
2476 " :type set: Callable[[:class:`bpy.types.bpy_struct`, " ty "], None]\n"
2477
2478#define BPY_PROPDEF_SEARCH_DOC \
2479 " :arg search: Function to be called to show candidates for this string (shown in the UI).\n" \
2480 " This function must take 3 values (self, context, edit_text)\n" \
2481 " and return a sequence, iterator or generator where each item must be:\n" \
2482 "\n" \
2483 " - A single string (representing a candidate to display).\n" \
2484 " - A tuple-pair of strings, where the first is a candidate and the second\n" \
2485 " is additional information about the candidate.\n" \
2486 " :type search: Callable[[:class:`bpy.types.bpy_struct`, :class:`bpy.types.Context`, str], " \
2487 "Iterable[str | tuple[str, str]]" \
2488 "]\n" \
2489 " :arg search_options: Set of strings in:\n" \
2490 "\n" \
2491 " - 'SORT' sorts the resulting items.\n" \
2492 " - 'SUGGESTION' lets the user enter values not found in search candidates.\n" \
2493 " **WARNING** disabling this flag causes the search callback to run on redraw,\n" \
2494 " so only disable this flag if it's not likely to cause performance issues.\n" \
2495 "\n" \
2496 " :type search_options: set[str]\n"
2497
2498#define BPY_PROPDEF_POINTER_TYPE_DOC \
2499 " :arg type: A subclass of a property group or ID types.\n" \
2500 " :type type: type[:class:`bpy.types.PropertyGroup` | :class:`bpy.types.ID`]\n"
2501
2502#define BPY_PROPDEF_COLLECTION_TYPE_DOC \
2503 " :arg type: A subclass of a property group.\n" \
2504 " :type type: type[:class:`bpy.types.PropertyGroup`]\n"
2505
2506#define BPY_PROPDEF_TAGS_DOC \
2507 " :arg tags: Enumerator of tags that are defined by parent class.\n" \
2508 " :type tags: set[str]\n"
2509
2510#if 0
2511static int bpy_struct_id_used(StructRNA *srna, char *identifier)
2512{
2513 PointerRNA ptr = RNA_pointer_create_discrete(nullptr, srna, nullptr);
2514 return (RNA_struct_find_property(&ptr, identifier) != nullptr);
2515}
2516#endif
2517
2519
2520/* -------------------------------------------------------------------- */
2530
2532 /* Wrap. */
2533 BPy_BoolProperty_doc,
2534 ".. function:: BoolProperty("
2535 "*, "
2536 "name=\"\", "
2537 "description=\"\", "
2538 "translation_context=\"*\", "
2539 "default=False, "
2540 "options={'ANIMATABLE'}, "
2541 "override=set(), "
2542 "tags=set(), "
2543 "subtype='NONE', "
2544 "update=None, "
2545 "get=None, "
2546 "set=None)\n"
2547 "\n"
2548 " Returns a new boolean property definition.\n"
2552static PyObject *BPy_BoolProperty(PyObject *self, PyObject *args, PyObject *kw)
2553{
2554 StructRNA *srna;
2555 { /* Keep this block first. */
2556 PyObject *deferred_result;
2557 srna = bpy_prop_deferred_data_or_srna(self, args, kw, pymeth_BoolProperty, &deferred_result);
2558 if (srna == nullptr) {
2559 return deferred_result;
2560 }
2561 }
2562
2563 BPy_PropIDParse id_data{};
2564 id_data.srna = srna;
2565
2566 const char *name = nullptr, *description = "";
2567 const char *translation_context = nullptr;
2568 bool default_value = false;
2569 PropertyRNA *prop;
2570 BPy_EnumProperty_Parse options_enum{};
2571 options_enum.items = rna_enum_property_flag_items;
2572 options_enum.value = 0;
2573
2574 BPy_EnumProperty_Parse override_enum{};
2576 override_enum.value = 0;
2577
2579 tags_enum.srna = srna;
2580
2581 BPy_EnumProperty_Parse subtype_enum{};
2583 subtype_enum.value = PROP_NONE;
2584
2585 PyObject *update_fn = nullptr;
2586 PyObject *get_fn = nullptr;
2587 PyObject *set_fn = nullptr;
2588
2589 static const char *_keywords[] = {
2590 "attr",
2591 "name",
2592 "description",
2593 "translation_context",
2594 "default",
2595 "options",
2596 "override",
2597 "tags",
2598 "subtype",
2599 "update",
2600 "get",
2601 "set",
2602 nullptr,
2603 };
2604 static _PyArg_Parser _parser = {
2606 "O&" /* `attr` */
2607 "|$" /* Optional, keyword only arguments. */
2608 "s" /* `name` */
2609 "s" /* `description` */
2610 "s" /* `translation_context` */
2611 "O&" /* `default` */
2612 "O&" /* `options` */
2613 "O&" /* `override` */
2614 "O&" /* `tags` */
2615 "O&" /* `subtype` */
2616 "O" /* `update` */
2617 "O" /* `get` */
2618 "O" /* `set` */
2619 ":BoolProperty",
2620 _keywords,
2621 nullptr,
2622 };
2623 if (!_PyArg_ParseTupleAndKeywordsFast(args,
2624 kw,
2625 &_parser,
2627 &id_data,
2628 &name,
2629 &description,
2630 &translation_context,
2632 &default_value,
2634 &options_enum,
2636 &override_enum,
2638 &tags_enum,
2640 &subtype_enum,
2641 &update_fn,
2642 &get_fn,
2643 &set_fn))
2644 {
2645 return nullptr;
2646 }
2647
2648 if (bpy_prop_callback_check(update_fn, "update", 2) == -1) {
2649 return nullptr;
2650 }
2651 if (bpy_prop_callback_check(get_fn, "get", 1) == -1) {
2652 return nullptr;
2653 }
2654 if (bpy_prop_callback_check(set_fn, "set", 2) == -1) {
2655 return nullptr;
2656 }
2657
2658 if (id_data.prop_free_handle != nullptr) {
2660 }
2661 prop = RNA_def_property(srna, id_data.value, PROP_BOOLEAN, subtype_enum.value);
2662
2663 RNA_def_property_boolean_default(prop, default_value);
2664 RNA_def_property_ui_text(prop, name ? name : id_data.value, description);
2665 if (translation_context) {
2666 RNA_def_property_translation_context(prop, translation_context);
2667 }
2668
2669 if (tags_enum.base.is_set) {
2670 RNA_def_property_tags(prop, tags_enum.base.value);
2671 }
2672 if (options_enum.is_set) {
2673 bpy_prop_assign_flag(prop, options_enum.value);
2674 }
2675 if (override_enum.is_set) {
2676 bpy_prop_assign_flag_override(prop, override_enum.value);
2677 }
2678 bpy_prop_callback_assign_update(prop, update_fn);
2679 bpy_prop_callback_assign_boolean(prop, get_fn, set_fn);
2681
2682 Py_RETURN_NONE;
2683}
2684
2686 /* Wrap. */
2687 BPy_BoolVectorProperty_doc,
2688 ".. function:: BoolVectorProperty("
2689 "*, "
2690 "name=\"\", "
2691 "description=\"\", "
2692 "translation_context=\"*\", "
2693 "default=(False, False, False), "
2694 "options={'ANIMATABLE'}, "
2695 "override=set(), "
2696 "tags=set(), "
2697 "subtype='NONE', "
2698 "size=3, "
2699 "update=None, "
2700 "get=None, "
2701 "set=None)\n"
2702 "\n"
2703 " Returns a new vector boolean property definition.\n"
2705 " :arg default: sequence of booleans the length of *size*.\n"
2706 " :type default: Sequence[bool]\n" BPY_PROPDEF_OPTIONS_DOC BPY_PROPDEF_OPTIONS_OVERRIDE_DOC
2709 BPY_PROPDEF_SET_DOC("tuple[bool, ...]"));
2710static PyObject *BPy_BoolVectorProperty(PyObject *self, PyObject *args, PyObject *kw)
2711{
2712 StructRNA *srna;
2713 { /* Keep this block first. */
2714 PyObject *deferred_result;
2716 self, args, kw, pymeth_BoolVectorProperty, &deferred_result);
2717 if (srna == nullptr) {
2718 return deferred_result;
2719 }
2720 }
2721
2722 BPy_PropIDParse id_data{};
2723 id_data.srna = srna;
2724
2725 const char *name = nullptr, *description = "";
2726 const char *translation_context = nullptr;
2727 Array<bool, RNA_STACK_ARRAY> default_value;
2728 BPyPropArrayLength array_len_info{};
2729 array_len_info.len_total = 3;
2730 PropertyRNA *prop;
2731 PyObject *default_py = nullptr;
2732
2733 BPy_EnumProperty_Parse options_enum{};
2734 options_enum.items = rna_enum_property_flag_items;
2735 options_enum.value = 0;
2736
2737 BPy_EnumProperty_Parse override_enum{};
2739 override_enum.value = 0;
2740
2742 tags_enum.srna = srna;
2743
2744 BPy_EnumProperty_Parse subtype_enum{};
2746 subtype_enum.value = PROP_NONE;
2747
2748 PyObject *update_fn = nullptr;
2749 PyObject *get_fn = nullptr;
2750 PyObject *set_fn = nullptr;
2751
2752 static const char *_keywords[] = {
2753 "attr",
2754 "name",
2755 "description",
2756 "translation_context",
2757 "default",
2758 "options",
2759 "override",
2760 "tags",
2761 "subtype",
2762 "size",
2763 "update",
2764 "get",
2765 "set",
2766 nullptr,
2767 };
2768 static _PyArg_Parser _parser = {
2770 "O&" /* `attr` */
2771 "|$" /* Optional, keyword only arguments. */
2772 "s" /* `name` */
2773 "s" /* `description` */
2774 "s" /* `translation_context` */
2775 "O" /* `default` */
2776 "O&" /* `options` */
2777 "O&" /* `override` */
2778 "O&" /* `tags` */
2779 "O&" /* `subtype` */
2780 "O&" /* `size` */
2781 "O" /* `update` */
2782 "O" /* `get` */
2783 "O" /* `set` */
2784 ":BoolVectorProperty",
2785 _keywords,
2786 nullptr,
2787 };
2788 if (!_PyArg_ParseTupleAndKeywordsFast(args,
2789 kw,
2790 &_parser,
2792 &id_data,
2793 &name,
2794 &description,
2795 &translation_context,
2796 &default_py,
2798 &options_enum,
2800 &override_enum,
2802 &tags_enum,
2804 &subtype_enum,
2806 &array_len_info,
2807 &update_fn,
2808 &get_fn,
2809 &set_fn))
2810 {
2811 return nullptr;
2812 }
2813
2814 if (default_py != nullptr) {
2815 default_value.reinitialize(array_len_info.len_total);
2816 if (bpy_prop_array_from_py_with_dims(default_value.data(),
2817 sizeof(*default_value.data()),
2818 default_py,
2819 &array_len_info,
2820 &PyBool_Type,
2821 "BoolVectorProperty(default=sequence)") == -1)
2822 {
2823 return nullptr;
2824 }
2825 }
2826
2827 if (bpy_prop_callback_check(update_fn, "update", 2) == -1) {
2828 return nullptr;
2829 }
2830 if (bpy_prop_callback_check(get_fn, "get", 1) == -1) {
2831 return nullptr;
2832 }
2833 if (bpy_prop_callback_check(set_fn, "set", 2) == -1) {
2834 return nullptr;
2835 }
2836
2837 if (id_data.prop_free_handle != nullptr) {
2839 }
2840 prop = RNA_def_property(srna, id_data.value, PROP_BOOLEAN, subtype_enum.value);
2841
2842 if (array_len_info.dims_len == 0) {
2843 RNA_def_property_array(prop, array_len_info.len_total);
2844 if (default_py != nullptr) {
2845 RNA_def_property_boolean_array_default(prop, default_value.data());
2846 }
2847 }
2848 else {
2849 RNA_def_property_multi_array(prop, array_len_info.dims_len, array_len_info.dims);
2850 if (default_py != nullptr) {
2851 RNA_def_property_boolean_array_default(prop, default_value.data());
2852 }
2853 }
2854
2855 RNA_def_property_ui_text(prop, name ? name : id_data.value, description);
2856 if (translation_context) {
2857 RNA_def_property_translation_context(prop, translation_context);
2858 }
2859
2860 if (tags_enum.base.is_set) {
2861 RNA_def_property_tags(prop, tags_enum.base.value);
2862 }
2863 if (options_enum.is_set) {
2864 bpy_prop_assign_flag(prop, options_enum.value);
2865 }
2866 if (override_enum.is_set) {
2867 bpy_prop_assign_flag_override(prop, override_enum.value);
2868 }
2869 bpy_prop_callback_assign_update(prop, update_fn);
2870 bpy_prop_callback_assign_boolean_array(prop, get_fn, set_fn);
2872
2873 Py_RETURN_NONE;
2874}
2875
2877 /* Wrap. */
2878 BPy_IntProperty_doc,
2879 ".. function:: IntProperty("
2880 "*, "
2881 "name=\"\", "
2882 "description=\"\", "
2883 "translation_context=\"*\", "
2884 "default=0, "
2885 "min=-2**31, max=2**31-1, "
2886 "soft_min=-2**31, soft_max=2**31-1, "
2887 "step=1, "
2888 "options={'ANIMATABLE'}, "
2889 "override=set(), "
2890 "tags=set(), "
2891 "subtype='NONE', "
2892 "update=None, "
2893 "get=None, "
2894 "set=None)\n"
2895 "\n"
2896 " Returns a new int property definition.\n"
2902static PyObject *BPy_IntProperty(PyObject *self, PyObject *args, PyObject *kw)
2903{
2904 StructRNA *srna;
2905 { /* Keep this block first. */
2906 PyObject *deferred_result;
2907 srna = bpy_prop_deferred_data_or_srna(self, args, kw, pymeth_IntProperty, &deferred_result);
2908 if (srna == nullptr) {
2909 return deferred_result;
2910 }
2911 }
2912
2913 BPy_PropIDParse id_data{};
2914 id_data.srna = srna;
2915
2916 const char *name = nullptr, *description = "";
2917 const char *translation_context = nullptr;
2918 int min = INT_MIN, max = INT_MAX, soft_min = INT_MIN, soft_max = INT_MAX;
2919 int step = 1;
2920 int default_value = 0;
2921 PropertyRNA *prop;
2922
2923 BPy_EnumProperty_Parse options_enum{};
2924 options_enum.items = rna_enum_property_flag_items;
2925 options_enum.value = 0;
2926
2927 BPy_EnumProperty_Parse override_enum{};
2929 override_enum.value = 0;
2930
2932 tags_enum.srna = srna;
2933
2934 BPy_EnumProperty_Parse subtype_enum{};
2936 subtype_enum.value = PROP_NONE;
2937
2938 PyObject *update_fn = nullptr;
2939 PyObject *get_fn = nullptr;
2940 PyObject *set_fn = nullptr;
2941
2942 static const char *_keywords[] = {
2943 "attr",
2944 "name",
2945 "description",
2946 "translation_context",
2947 "default",
2948 "min",
2949 "max",
2950 "soft_min",
2951 "soft_max",
2952 "step",
2953 "options",
2954 "override",
2955 "tags",
2956 "subtype",
2957 "update",
2958 "get",
2959 "set",
2960 nullptr,
2961 };
2962 static _PyArg_Parser _parser = {
2964 "O&" /* `attr` */
2965 "|$" /* Optional, keyword only arguments. */
2966 "s" /* `name` */
2967 "s" /* `description` */
2968 "s" /* `translation_context` */
2969 "i" /* `default` */
2970 "i" /* `min` */
2971 "i" /* `max` */
2972 "i" /* `soft_min` */
2973 "i" /* `soft_max` */
2974 "i" /* `step` */
2975 "O&" /* `options` */
2976 "O&" /* `override` */
2977 "O&" /* `tags` */
2978 "O&" /* `subtype` */
2979 "O" /* `update` */
2980 "O" /* `get` */
2981 "O" /* `set` */
2982 ":IntProperty",
2983 _keywords,
2984 nullptr,
2985 };
2986 if (!_PyArg_ParseTupleAndKeywordsFast(args,
2987 kw,
2988 &_parser,
2990 &id_data,
2991 &name,
2992 &description,
2993 &translation_context,
2994 &default_value,
2995 &min,
2996 &max,
2997 &soft_min,
2998 &soft_max,
2999 &step,
3001 &options_enum,
3003 &override_enum,
3005 &tags_enum,
3007 &subtype_enum,
3008 &update_fn,
3009 &get_fn,
3010 &set_fn))
3011 {
3012 return nullptr;
3013 }
3014
3015 if (bpy_prop_callback_check(update_fn, "update", 2) == -1) {
3016 return nullptr;
3017 }
3018 if (bpy_prop_callback_check(get_fn, "get", 1) == -1) {
3019 return nullptr;
3020 }
3021 if (bpy_prop_callback_check(set_fn, "set", 2) == -1) {
3022 return nullptr;
3023 }
3024
3025 if (id_data.prop_free_handle != nullptr) {
3027 }
3028 prop = RNA_def_property(srna, id_data.value, PROP_INT, subtype_enum.value);
3029
3030 RNA_def_property_int_default(prop, default_value);
3031 RNA_def_property_ui_text(prop, name ? name : id_data.value, description);
3032 if (translation_context) {
3033 RNA_def_property_translation_context(prop, translation_context);
3034 }
3036 RNA_def_property_ui_range(prop, std::max(soft_min, min), std::min(soft_max, max), step, 3);
3037
3038 if (tags_enum.base.is_set) {
3039 RNA_def_property_tags(prop, tags_enum.base.value);
3040 }
3041 if (options_enum.is_set) {
3042 bpy_prop_assign_flag(prop, options_enum.value);
3043 }
3044 if (override_enum.is_set) {
3045 bpy_prop_assign_flag_override(prop, override_enum.value);
3046 }
3047 bpy_prop_callback_assign_update(prop, update_fn);
3048 bpy_prop_callback_assign_int(prop, get_fn, set_fn);
3050
3051 Py_RETURN_NONE;
3052}
3053
3055 /* Wrap. */
3056 BPy_IntVectorProperty_doc,
3057 ".. function:: IntVectorProperty("
3058 "*, "
3059 "name=\"\", "
3060 "description=\"\", "
3061 "translation_context=\"*\", "
3062 "default=(0, 0, 0), min=-2**31, max=2**31-1, "
3063 "soft_min=-2**31, "
3064 "soft_max=2**31-1, "
3065 "step=1, "
3066 "options={'ANIMATABLE'}, "
3067 "override=set(), "
3068 "tags=set(), "
3069 "subtype='NONE', "
3070 "size=3, "
3071 "update=None, "
3072 "get=None, "
3073 "set=None)\n"
3074 "\n"
3075 " Returns a new vector int property definition.\n"
3077 " :arg default: sequence of ints the length of *size*.\n"
3078 " :type default: Sequence[int]\n" BPY_PROPDEF_NUM_MINMAX_DOC("int")
3083 BPY_PROPDEF_SET_DOC("tuple[int, ...]"));
3084static PyObject *BPy_IntVectorProperty(PyObject *self, PyObject *args, PyObject *kw)
3085{
3086 StructRNA *srna;
3087 { /* Keep this block first. */
3088 PyObject *deferred_result;
3090 self, args, kw, pymeth_IntVectorProperty, &deferred_result);
3091 if (srna == nullptr) {
3092 return deferred_result;
3093 }
3094 }
3095
3096 BPy_PropIDParse id_data{};
3097 id_data.srna = srna;
3098
3099 const char *name = nullptr, *description = "";
3100 const char *translation_context = nullptr;
3101 int min = INT_MIN, max = INT_MAX, soft_min = INT_MIN, soft_max = INT_MAX;
3102 int step = 1;
3103 Array<int, RNA_STACK_ARRAY> default_value;
3104 BPyPropArrayLength array_len_info{};
3105 array_len_info.len_total = 3;
3106 PropertyRNA *prop;
3107 PyObject *default_py = nullptr;
3108
3109 BPy_EnumProperty_Parse options_enum{};
3110 options_enum.items = rna_enum_property_flag_items;
3111 options_enum.value = 0;
3112
3113 BPy_EnumProperty_Parse override_enum{};
3115 override_enum.value = 0;
3116
3118 tags_enum.srna = srna;
3119
3120 BPy_EnumProperty_Parse subtype_enum{};
3122 subtype_enum.value = PROP_NONE;
3123
3124 PyObject *update_fn = nullptr;
3125 PyObject *get_fn = nullptr;
3126 PyObject *set_fn = nullptr;
3127
3128 static const char *_keywords[] = {
3129 "attr", "name", "description", "translation_context",
3130 "default", "min", "max", "soft_min",
3131 "soft_max", "step", "options", "override",
3132 "tags", "subtype", "size", "update",
3133 "get", "set", nullptr,
3134 };
3135 static _PyArg_Parser _parser = {
3137 "O&" /* `attr` */
3138 "|$" /* Optional, keyword only arguments. */
3139 "s" /* `name` */
3140 "s" /* `description` */
3141 "s" /* `translation_context` */
3142 "O" /* `default` */
3143 "i" /* `min` */
3144 "i" /* `max` */
3145 "i" /* `soft_min` */
3146 "i" /* `soft_max` */
3147 "i" /* `step` */
3148 "O&" /* `options` */
3149 "O&" /* `override` */
3150 "O&" /* `tags` */
3151 "O&" /* `subtype` */
3152 "O&" /* `size` */
3153 "O" /* `update` */
3154 "O" /* `get` */
3155 "O" /* `set` */
3156 ":IntVectorProperty",
3157 _keywords,
3158 nullptr,
3159 };
3160 if (!_PyArg_ParseTupleAndKeywordsFast(args,
3161 kw,
3162 &_parser,
3164 &id_data,
3165 &name,
3166 &description,
3167 &translation_context,
3168 &default_py,
3169 &min,
3170 &max,
3171 &soft_min,
3172 &soft_max,
3173 &step,
3175 &options_enum,
3177 &override_enum,
3179 &tags_enum,
3181 &subtype_enum,
3183 &array_len_info,
3184 &update_fn,
3185 &get_fn,
3186 &set_fn))
3187 {
3188 return nullptr;
3189 }
3190
3191 if (default_py != nullptr) {
3192 default_value.reinitialize(array_len_info.len_total);
3193 if (bpy_prop_array_from_py_with_dims(default_value.data(),
3194 sizeof(*default_value.data()),
3195 default_py,
3196 &array_len_info,
3197 &PyLong_Type,
3198 "IntVectorProperty(default=sequence)") == -1)
3199 {
3200 return nullptr;
3201 }
3202 }
3203
3204 if (bpy_prop_callback_check(update_fn, "update", 2) == -1) {
3205 return nullptr;
3206 }
3207 if (bpy_prop_callback_check(get_fn, "get", 1) == -1) {
3208 return nullptr;
3209 }
3210 if (bpy_prop_callback_check(set_fn, "set", 2) == -1) {
3211 return nullptr;
3212 }
3213
3214 if (id_data.prop_free_handle != nullptr) {
3216 }
3217 prop = RNA_def_property(srna, id_data.value, PROP_INT, subtype_enum.value);
3218
3219 if (array_len_info.dims_len == 0) {
3220 RNA_def_property_array(prop, array_len_info.len_total);
3221 if (default_py != nullptr) {
3222 RNA_def_property_int_array_default(prop, default_value.data());
3223 }
3224 }
3225 else {
3226 RNA_def_property_multi_array(prop, array_len_info.dims_len, array_len_info.dims);
3227 if (default_py != nullptr) {
3228 RNA_def_property_int_array_default(prop, default_value.data());
3229 }
3230 }
3231
3233 RNA_def_property_ui_text(prop, name ? name : id_data.value, description);
3234 if (translation_context) {
3235 RNA_def_property_translation_context(prop, translation_context);
3236 }
3237 RNA_def_property_ui_range(prop, std::max(soft_min, min), std::min(soft_max, max), step, 3);
3238
3239 if (tags_enum.base.is_set) {
3240 RNA_def_property_tags(prop, tags_enum.base.value);
3241 }
3242 if (options_enum.is_set) {
3243 bpy_prop_assign_flag(prop, options_enum.value);
3244 }
3245 if (override_enum.is_set) {
3246 bpy_prop_assign_flag_override(prop, override_enum.value);
3247 }
3248 bpy_prop_callback_assign_update(prop, update_fn);
3249 bpy_prop_callback_assign_int_array(prop, get_fn, set_fn);
3251
3252 Py_RETURN_NONE;
3253}
3254
3256 /* Wrap. */
3257 BPy_FloatProperty_doc,
3258 ".. function:: FloatProperty("
3259 "*, "
3260 "name=\"\", "
3261 "description=\"\", "
3262 "translation_context=\"*\", "
3263 "default=0.0, "
3264 "min=-3.402823e+38, max=3.402823e+38, "
3265 "soft_min=-3.402823e+38, soft_max=3.402823e+38, "
3266 "step=3, "
3267 "precision=2, "
3268 "options={'ANIMATABLE'}, "
3269 "override=set(), "
3270 "tags=set(), "
3271 "subtype='NONE', "
3272 "unit='NONE', "
3273 "update=None, "
3274 "get=None, "
3275 "set=None)\n"
3276 "\n"
3277 " Returns a new float (single precision) property definition.\n"
3279 "float") BPY_PROPDEF_NUM_SOFT_MINMAX_DOC("float")
3283 BPY_PROPDEF_SET_DOC("float"));
3284static PyObject *BPy_FloatProperty(PyObject *self, PyObject *args, PyObject *kw)
3285{
3286 StructRNA *srna;
3287 { /* Keep this block first. */
3288 PyObject *deferred_result;
3289 srna = bpy_prop_deferred_data_or_srna(self, args, kw, pymeth_FloatProperty, &deferred_result);
3290 if (srna == nullptr) {
3291 return deferred_result;
3292 }
3293 }
3294
3295 BPy_PropIDParse id_data{};
3296 id_data.srna = srna;
3297
3298 const char *name = nullptr, *description = "";
3299 const char *translation_context = nullptr;
3300 float min = -FLT_MAX, max = FLT_MAX, soft_min = -FLT_MAX, soft_max = FLT_MAX;
3301 float step = 3;
3302 float default_value = 0.0f;
3303 int precision = 2;
3304 PropertyRNA *prop;
3305
3306 BPy_EnumProperty_Parse options_enum{};
3307 options_enum.items = rna_enum_property_flag_items;
3308 options_enum.value = 0;
3309
3310 BPy_EnumProperty_Parse override_enum{};
3312 override_enum.value = 0;
3313
3315 tags_enum.srna = srna;
3316
3317 BPy_EnumProperty_Parse subtype_enum{};
3319 subtype_enum.value = PROP_NONE;
3320
3321 BPy_EnumProperty_Parse unit_enum{};
3323 unit_enum.value = PROP_UNIT_NONE;
3324
3325 PyObject *update_fn = nullptr;
3326 PyObject *get_fn = nullptr;
3327 PyObject *set_fn = nullptr;
3328
3329 static const char *_keywords[] = {
3330 "attr", "name", "description", "translation_context",
3331 "default", "min", "max", "soft_min",
3332 "soft_max", "step", "precision", "options",
3333 "override", "tags", "subtype", "unit",
3334 "update", "get", "set", nullptr,
3335 };
3336 static _PyArg_Parser _parser = {
3338 "O&" /* `attr` */
3339 "|$" /* Optional, keyword only arguments. */
3340 "s" /* `name` */
3341 "s" /* `description` */
3342 "s" /* `translation_context` */
3343 "f" /* `default` */
3344 "f" /* `min` */
3345 "f" /* `max` */
3346 "f" /* `soft_min` */
3347 "f" /* `soft_max` */
3348 "f" /* `step` */
3349 "i" /* `precision` */
3350 "O&" /* `options` */
3351 "O&" /* `override` */
3352 "O&" /* `tags` */
3353 "O&" /* `subtype` */
3354 "O&" /* `unit` */
3355 "O" /* `update` */
3356 "O" /* `get` */
3357 "O" /* `set` */
3358 ":FloatProperty",
3359 _keywords,
3360 nullptr,
3361 };
3362 if (!_PyArg_ParseTupleAndKeywordsFast(args,
3363 kw,
3364 &_parser,
3366 &id_data,
3367 &name,
3368 &description,
3369 &translation_context,
3370 &default_value,
3371 &min,
3372 &max,
3373 &soft_min,
3374 &soft_max,
3375 &step,
3376 &precision,
3378 &options_enum,
3380 &override_enum,
3382 &tags_enum,
3384 &subtype_enum,
3386 &unit_enum,
3387 &update_fn,
3388 &get_fn,
3389 &set_fn))
3390 {
3391 return nullptr;
3392 }
3393
3394 if (bpy_prop_callback_check(update_fn, "update", 2) == -1) {
3395 return nullptr;
3396 }
3397 if (bpy_prop_callback_check(get_fn, "get", 1) == -1) {
3398 return nullptr;
3399 }
3400 if (bpy_prop_callback_check(set_fn, "set", 2) == -1) {
3401 return nullptr;
3402 }
3403
3404 if (id_data.prop_free_handle != nullptr) {
3406 }
3407 prop = RNA_def_property(srna, id_data.value, PROP_FLOAT, subtype_enum.value | unit_enum.value);
3408
3409 RNA_def_property_float_default(prop, default_value);
3411 RNA_def_property_ui_text(prop, name ? name : id_data.value, description);
3412 if (translation_context) {
3413 RNA_def_property_translation_context(prop, translation_context);
3414 }
3416 prop, std::max(soft_min, min), std::min(soft_max, max), step, precision);
3417
3418 if (tags_enum.base.is_set) {
3419 RNA_def_property_tags(prop, tags_enum.base.value);
3420 }
3421 if (options_enum.is_set) {
3422 bpy_prop_assign_flag(prop, options_enum.value);
3423 }
3424 if (override_enum.is_set) {
3425 bpy_prop_assign_flag_override(prop, override_enum.value);
3426 }
3427 bpy_prop_callback_assign_update(prop, update_fn);
3428 bpy_prop_callback_assign_float(prop, get_fn, set_fn);
3430
3431 Py_RETURN_NONE;
3432}
3433
3435 /* Wrap. */
3436 BPy_FloatVectorProperty_doc,
3437 ".. function:: FloatVectorProperty("
3438 "*, "
3439 "name=\"\", "
3440 "description=\"\", "
3441 "translation_context=\"*\", "
3442 "default=(0.0, 0.0, 0.0), "
3443 "min=sys.float_info.min, max=sys.float_info.max, "
3444 "soft_min=sys.float_info.min, soft_max=sys.float_info.max, "
3445 "step=3, "
3446 "precision=2, "
3447 "options={'ANIMATABLE'}, "
3448 "override=set(), "
3449 "tags=set(), "
3450 "subtype='NONE', "
3451 "unit='NONE', "
3452 "size=3, "
3453 "update=None, "
3454 "get=None, "
3455 "set=None)\n"
3456 "\n"
3457 " Returns a new vector float property definition.\n"
3459 " :arg default: Sequence of floats the length of *size*.\n"
3460 " :type default: Sequence[float]\n" BPY_PROPDEF_NUM_MINMAX_DOC(
3461 "float") BPY_PROPDEF_NUM_SOFT_MINMAX_DOC("float")
3466 BPY_PROPDEF_SET_DOC("tuple[float, ...]"));
3467static PyObject *BPy_FloatVectorProperty(PyObject *self, PyObject *args, PyObject *kw)
3468{
3469 StructRNA *srna;
3470 { /* Keep this block first. */
3471 PyObject *deferred_result;
3473 self, args, kw, pymeth_FloatVectorProperty, &deferred_result);
3474 if (srna == nullptr) {
3475 return deferred_result;
3476 }
3477 }
3478
3479 BPy_PropIDParse id_data{};
3480 id_data.srna = srna;
3481
3482 const char *name = nullptr, *description = "";
3483 const char *translation_context = nullptr;
3484 float min = -FLT_MAX, max = FLT_MAX, soft_min = -FLT_MAX, soft_max = FLT_MAX;
3485 float step = 3;
3486 Array<float, RNA_STACK_ARRAY> default_value;
3487 int precision = 2;
3488 BPyPropArrayLength array_len_info{};
3489 array_len_info.len_total = 3;
3490 PropertyRNA *prop;
3491 PyObject *default_py = nullptr;
3492
3493 BPy_EnumProperty_Parse options_enum{};
3494 options_enum.items = rna_enum_property_flag_items;
3495 options_enum.value = 0;
3496
3497 BPy_EnumProperty_Parse override_enum{};
3499 override_enum.value = 0;
3500
3502 tags_enum.srna = srna;
3503
3504 BPy_EnumProperty_Parse subtype_enum{};
3506 subtype_enum.value = PROP_NONE;
3507
3508 BPy_EnumProperty_Parse unit_enum{};
3510 unit_enum.value = PROP_UNIT_NONE;
3511
3512 PyObject *update_fn = nullptr;
3513 PyObject *get_fn = nullptr;
3514 PyObject *set_fn = nullptr;
3515
3516 static const char *_keywords[] = {
3517 "attr", "name", "description", "translation_context",
3518 "default", "min", "max", "soft_min",
3519 "soft_max", "step", "precision", "options",
3520 "override", "tags", "subtype", "unit",
3521 "size", "update", "get", "set",
3522 nullptr,
3523 };
3524 static _PyArg_Parser _parser = {
3526 "O&" /* `attr` */
3527 "|$" /* Optional, keyword only arguments. */
3528 "s" /* `name` */
3529 "s" /* `description` */
3530 "s" /* `translation_context` */
3531 "O" /* `default` */
3532 "f" /* `min` */
3533 "f" /* `max` */
3534 "f" /* `soft_min` */
3535 "f" /* `soft_max` */
3536 "f" /* `step` */
3537 "i" /* `precision` */
3538 "O&" /* `options` */
3539 "O&" /* `override` */
3540 "O&" /* `tags` */
3541 "O&" /* `subtype` */
3542 "O&" /* `unit` */
3543 "O&" /* `size` */
3544 "O" /* `update` */
3545 "O" /* `get` */
3546 "O" /* `set` */
3547 ":FloatVectorProperty",
3548 _keywords,
3549 nullptr,
3550 };
3551 if (!_PyArg_ParseTupleAndKeywordsFast(args,
3552 kw,
3553 &_parser,
3555 &id_data,
3556 &name,
3557 &description,
3558 &translation_context,
3559 &default_py,
3560 &min,
3561 &max,
3562 &soft_min,
3563 &soft_max,
3564 &step,
3565 &precision,
3567 &options_enum,
3569 &override_enum,
3571 &tags_enum,
3573 &subtype_enum,
3575 &unit_enum,
3577 &array_len_info,
3578 &update_fn,
3579 &get_fn,
3580 &set_fn))
3581 {
3582 return nullptr;
3583 }
3584
3585 if (default_py != nullptr) {
3586 default_value.reinitialize(array_len_info.len_total);
3587 if (bpy_prop_array_from_py_with_dims(default_value.data(),
3588 sizeof(*default_value.data()),
3589 default_py,
3590 &array_len_info,
3591 &PyFloat_Type,
3592 "FloatVectorProperty(default=sequence)") == -1)
3593 {
3594 return nullptr;
3595 }
3596 if (bpy_prop_array_is_matrix_compatible_ex(subtype_enum.value, &array_len_info)) {
3597 bpy_prop_array_matrix_swap_row_column_vn(default_value.data(), &array_len_info);
3598 }
3599 }
3600
3601 if (bpy_prop_callback_check(update_fn, "update", 2) == -1) {
3602 return nullptr;
3603 }
3604 if (bpy_prop_callback_check(get_fn, "get", 1) == -1) {
3605 return nullptr;
3606 }
3607 if (bpy_prop_callback_check(set_fn, "set", 2) == -1) {
3608 return nullptr;
3609 }
3610
3611 if (id_data.prop_free_handle != nullptr) {
3613 }
3614 prop = RNA_def_property(srna, id_data.value, PROP_FLOAT, subtype_enum.value | unit_enum.value);
3615
3616 if (array_len_info.dims_len == 0) {
3617 RNA_def_property_array(prop, array_len_info.len_total);
3618 if (default_py != nullptr) {
3619 RNA_def_property_float_array_default(prop, default_value.data());
3620 }
3621 }
3622 else {
3623 RNA_def_property_multi_array(prop, array_len_info.dims_len, array_len_info.dims);
3624 if (default_py != nullptr) {
3625 RNA_def_property_float_array_default(prop, default_value.data());
3626 }
3627 }
3628
3630 RNA_def_property_ui_text(prop, name ? name : id_data.value, description);
3631 if (translation_context) {
3632 RNA_def_property_translation_context(prop, translation_context);
3633 }
3635 prop, std::max(soft_min, min), std::min(soft_max, max), step, precision);
3636
3637 if (tags_enum.base.is_set) {
3638 RNA_def_property_tags(prop, tags_enum.base.value);
3639 }
3640 if (options_enum.is_set) {
3641 bpy_prop_assign_flag(prop, options_enum.value);
3642 }
3643 if (override_enum.is_set) {
3644 bpy_prop_assign_flag_override(prop, override_enum.value);
3645 }
3646 bpy_prop_callback_assign_update(prop, update_fn);
3647 bpy_prop_callback_assign_float_array(prop, get_fn, set_fn);
3649
3650 Py_RETURN_NONE;
3651}
3652
3654 /* Wrap. */
3655 BPy_StringProperty_doc,
3656 ".. function:: StringProperty("
3657 "*, "
3658 "name=\"\", "
3659 "description=\"\", "
3660 "translation_context=\"*\", "
3661 "default=\"\", "
3662 "maxlen=0, "
3663 "options={'ANIMATABLE'}, "
3664 "override=set(), "
3665 "tags=set(), "
3666 "subtype='NONE', "
3667 "update=None, "
3668 "get=None, "
3669 "set=None, "
3670 "search=None, "
3671 "search_options={'SUGGESTION'})\n"
3672 "\n"
3673 " Returns a new string property definition.\n"
3675 " :arg default: initializer string.\n"
3676 " :type default: str\n"
3677 " :arg maxlen: maximum length of the string.\n"
3681static PyObject *BPy_StringProperty(PyObject *self, PyObject *args, PyObject *kw)
3682{
3683 StructRNA *srna;
3684 { /* Keep this block first. */
3685 PyObject *deferred_result;
3686 srna = bpy_prop_deferred_data_or_srna(self, args, kw, pymeth_StringProperty, &deferred_result);
3687 if (srna == nullptr) {
3688 return deferred_result;
3689 }
3690 }
3691
3692 BPy_PropIDParse id_data{};
3693 id_data.srna = srna;
3694
3695 const char *name = nullptr, *description = "";
3696 const char *translation_context = nullptr, *default_value = "";
3697 int maxlen = 0;
3698 PropertyRNA *prop;
3699
3700 BPy_EnumProperty_Parse options_enum{};
3701 options_enum.items = rna_enum_property_flag_items;
3702 options_enum.value = 0;
3703
3704 BPy_EnumProperty_Parse override_enum{};
3706 override_enum.value = 0;
3707
3709 tags_enum.srna = srna;
3710
3711 BPy_EnumProperty_Parse subtype_enum{};
3713 subtype_enum.value = PROP_NONE;
3714
3715 PyObject *update_fn = nullptr;
3716 PyObject *get_fn = nullptr;
3717 PyObject *set_fn = nullptr;
3718 PyObject *search_fn = nullptr;
3719 BPy_EnumProperty_Parse search_options_enum{};
3721 search_options_enum.value = PROP_STRING_SEARCH_SUGGESTION;
3722
3723 static const char *_keywords[] = {
3724 "attr",
3725 "name",
3726 "description",
3727 "translation_context",
3728 "default",
3729 "maxlen",
3730 "options",
3731 "override",
3732 "tags",
3733 "subtype",
3734 "update",
3735 "get",
3736 "set",
3737 "search",
3738 "search_options",
3739 nullptr,
3740 };
3741 static _PyArg_Parser _parser = {
3743 "O&" /* `attr` */
3744 "|$" /* Optional, keyword only arguments. */
3745 "s" /* `name` */
3746 "s" /* `description` */
3747 "s" /* `translation_context` */
3748 "s" /* `default` */
3749 "i" /* `maxlen` */
3750 "O&" /* `options` */
3751 "O&" /* `override` */
3752 "O&" /* `tags` */
3753 "O&" /* `subtype` */
3754 "O" /* `update` */
3755 "O" /* `get` */
3756 "O" /* `set` */
3757 "O" /* `search` */
3758 "O&" /* `search_options` */
3759 ":StringProperty",
3760 _keywords,
3761 nullptr,
3762 };
3763 if (!_PyArg_ParseTupleAndKeywordsFast(args,
3764 kw,
3765 &_parser,
3767 &id_data,
3768 &name,
3769 &description,
3770 &translation_context,
3771 &default_value,
3772 &maxlen,
3774 &options_enum,
3776 &override_enum,
3778 &tags_enum,
3780 &subtype_enum,
3781 &update_fn,
3782 &get_fn,
3783 &set_fn,
3784 &search_fn,
3786 &search_options_enum))
3787 {
3788 return nullptr;
3789 }
3790
3791 if (bpy_prop_callback_check(update_fn, "update", 2) == -1) {
3792 return nullptr;
3793 }
3794 if (bpy_prop_callback_check(get_fn, "get", 1) == -1) {
3795 return nullptr;
3796 }
3797 if (bpy_prop_callback_check(set_fn, "set", 2) == -1) {
3798 return nullptr;
3799 }
3800 if (bpy_prop_callback_check(search_fn, "search", 3) == -1) {
3801 return nullptr;
3802 }
3803
3804 if (id_data.prop_free_handle != nullptr) {
3806 }
3807 prop = RNA_def_property(srna, id_data.value, PROP_STRING, subtype_enum.value);
3808
3809 if (maxlen != 0) {
3810 /* +1 since it includes null terminator. */
3811 RNA_def_property_string_maxlength(prop, maxlen + 1);
3812 }
3813 if (default_value && default_value[0]) {
3814 RNA_def_property_string_default(prop, default_value);
3815 }
3816 RNA_def_property_ui_text(prop, name ? name : id_data.value, description);
3817 if (translation_context) {
3818 RNA_def_property_translation_context(prop, translation_context);
3819 }
3820
3821 if (tags_enum.base.is_set) {
3822 RNA_def_property_tags(prop, tags_enum.base.value);
3823 }
3824 if (options_enum.is_set) {
3825 bpy_prop_assign_flag(prop, options_enum.value);
3826 }
3827 if (override_enum.is_set) {
3828 bpy_prop_assign_flag_override(prop, override_enum.value);
3829 }
3830 bpy_prop_callback_assign_update(prop, update_fn);
3832 prop, get_fn, set_fn, search_fn, eStringPropertySearchFlag(search_options_enum.value));
3834
3835 Py_RETURN_NONE;
3836}
3837
3839 /* Wrap. */
3840 BPy_EnumProperty_doc,
3841 ".. function:: EnumProperty("
3842 "items, "
3843 "*, "
3844 "name=\"\", "
3845 "description=\"\", "
3846 "translation_context=\"*\", "
3847 "default=None, "
3848 "options={'ANIMATABLE'}, "
3849 "override=set(), "
3850 "tags=set(), "
3851 "update=None, "
3852 "get=None, "
3853 "set=None)\n"
3854 "\n"
3855 " Returns a new enumerator property definition.\n"
3856 "\n"
3857 " :arg items: sequence of enum items formatted:\n"
3858 " ``[(identifier, name, description, icon, number), ...]``.\n"
3859 "\n"
3860 " The first three elements of the tuples are mandatory.\n"
3861 "\n"
3862 " :identifier: The identifier is used for Python access.\n"
3863 " An empty identifier means that the item is a separator\n"
3864 " :name: Name for the interface.\n"
3865 " :description: Used for documentation and tooltips.\n"
3866 " :icon: An icon string identifier or integer icon value\n"
3867 " (e.g. returned by :class:`bpy.types.UILayout.icon`)\n"
3868 " :number: Unique value used as the identifier for this item (stored in file data).\n"
3869 " Use when the identifier may need to change. If the *ENUM_FLAG* option is used,\n"
3870 " the values are bit-masks and should be powers of two.\n"
3871 "\n"
3872 " When an item only contains 4 items they define ``(identifier, name, description, "
3873 "number)``.\n"
3874 "\n"
3875 " Separators may be added using either None (nameless separator),\n"
3876 " or a regular item tuple with an empty identifier string, in which case the name,\n"
3877 " if non-empty, will be displayed in the UI above the separator line."
3878 "\n"
3879 " For dynamic values a callback can be passed which returns a list in\n"
3880 " the same format as the static list.\n"
3881 " This function must take 2 arguments ``(self, context)``, **context may be None**.\n"
3882 "\n"
3883 " .. warning::\n"
3884 "\n"
3885 " There is a known bug with using a callback,\n"
3886 " Python must keep a reference to the strings returned by the callback or Blender\n"
3887 " will misbehave or even crash."
3888 "\n"
3889 " :type items: Iterable["
3890 "tuple[str, str, str] | "
3891 "tuple[str, str, str, int] | "
3892 "tuple[str, str, str, int, int] | "
3893 "None] | "
3894 "Callable[[:class:`bpy.types.bpy_struct`, :class:`bpy.types.Context` | None], "
3895 /* NOTE(@ideasman42): a type alias would be useful here (same as above). */
3896 "Iterable["
3897 "tuple[str, str, str] | "
3898 "tuple[str, str, str, int] | "
3899 "tuple[str, str, str, int, int] | "
3900 "None]"
3902 " :arg default: The default value for this enum, a string from the identifiers used in "
3903 "*items*, or integer matching an item number.\n"
3904 " If the *ENUM_FLAG* option is used this must be a set of such string identifiers "
3905 "instead.\n"
3906 " WARNING: Strings cannot be specified for dynamic enums\n"
3907 " (i.e. if a callback function is given as *items* parameter).\n"
3908 " :type default: str | int | set[str]\n" BPY_PROPDEF_OPTIONS_ENUM_DOC
3911static PyObject *BPy_EnumProperty(PyObject *self, PyObject *args, PyObject *kw)
3912{
3913 StructRNA *srna;
3914 { /* Keep this block first. */
3915 PyObject *deferred_result;
3916 srna = bpy_prop_deferred_data_or_srna(self, args, kw, pymeth_EnumProperty, &deferred_result);
3917 if (srna == nullptr) {
3918 return deferred_result;
3919 }
3920 }
3921
3922 BPy_PropIDParse id_data{};
3923 id_data.srna = srna;
3924
3925 const char *name = nullptr, *description = "";
3926 const char *translation_context = nullptr;
3927 PyObject *default_py = nullptr;
3928 int default_value = 0;
3929 PyObject *items, *items_fast;
3930 const EnumPropertyItem *eitems;
3931 PropertyRNA *prop;
3932
3933 BPy_EnumProperty_Parse options_enum{};
3935 options_enum.value = 0;
3936
3937 BPy_EnumProperty_Parse override_enum{};
3939 override_enum.value = 0;
3940
3942 tags_enum.srna = srna;
3943
3944 bool is_itemf = false;
3945 PyObject *update_fn = nullptr;
3946 PyObject *get_fn = nullptr;
3947 PyObject *set_fn = nullptr;
3948
3949 static const char *_keywords[] = {
3950 "attr",
3951 "items",
3952 "name",
3953 "description",
3954 "translation_context",
3955 "default",
3956 "options",
3957 "override",
3958 "tags",
3959 "update",
3960 "get",
3961 "set",
3962 nullptr,
3963 };
3964 static _PyArg_Parser _parser = {
3966 "O&" /* `attr` */
3967 "O" /* `items` */
3968 "|$" /* Optional, keyword only arguments. */
3969 "s" /* `name` */
3970 "s" /* `description` */
3971 "s" /* `translation_context` */
3972 "O" /* `default` */
3973 "O&" /* `options` */
3974 "O&" /* `override` */
3975 "O&" /* `tags` */
3976 "O" /* `update` */
3977 "O" /* `get` */
3978 "O" /* `set` */
3979 ":EnumProperty",
3980 _keywords,
3981 nullptr,
3982 };
3983 if (!_PyArg_ParseTupleAndKeywordsFast(args,
3984 kw,
3985 &_parser,
3987 &id_data,
3988 &items,
3989 &name,
3990 &description,
3991 &translation_context,
3992 &default_py,
3994 &options_enum,
3996 &override_enum,
3998 &tags_enum,
3999 &update_fn,
4000 &get_fn,
4001 &set_fn))
4002 {
4003 return nullptr;
4004 }
4005
4006 if (bpy_prop_callback_check(update_fn, "update", 2) == -1) {
4007 return nullptr;
4008 }
4009 if (bpy_prop_callback_check(get_fn, "get", 1) == -1) {
4010 return nullptr;
4011 }
4012 if (bpy_prop_callback_check(set_fn, "set", 2) == -1) {
4013 return nullptr;
4014 }
4015
4016 if (default_py == Py_None) {
4017 /* This allows to get same behavior when explicitly passing None as default value,
4018 * and not defining a default value at all! */
4019 default_py = nullptr;
4020 }
4021
4022 /* Items can be a list or a callable.
4023 * NOTE: Don't use #PyCallable_Check because we need the function code for errors. */
4024 if (PyFunction_Check(items)) {
4025 PyCodeObject *f_code = (PyCodeObject *)PyFunction_GET_CODE(items);
4026 if (f_code->co_argcount != 2) {
4027 PyErr_Format(PyExc_ValueError,
4028 "EnumProperty(...): expected 'items' function to take 2 arguments, not %d",
4029 f_code->co_argcount);
4030 return nullptr;
4031 }
4032
4033 if (default_py) {
4034 /* Only support getting integer default values here. */
4035 if (!py_long_as_int(default_py, &default_value)) {
4036 /* NOTE: using type error here is odd but python does this for invalid arguments. */
4037 PyErr_SetString(
4038 PyExc_TypeError,
4039 "EnumProperty(...): 'default' can only be an integer when 'items' is a function");
4040 return nullptr;
4041 }
4042 }
4043
4044 is_itemf = true;
4046 }
4047 else {
4048 if (!(items_fast = PySequence_Fast(
4049 items,
4050 "EnumProperty(...): "
4051 "expected a sequence of tuples for the enum items or a function")))
4052 {
4053 return nullptr;
4054 }
4055
4056 eitems = enum_items_from_py(
4057 items_fast, (options_enum.value & PROP_ENUM_FLAG) != 0, default_py, &default_value);
4058
4059 if (!eitems) {
4060 Py_DECREF(items_fast);
4061 return nullptr;
4062 }
4063 }
4064
4065 if (id_data.prop_free_handle != nullptr) {
4067 }
4068 if (options_enum.value & PROP_ENUM_FLAG) {
4069 prop = RNA_def_enum_flag(
4070 srna, id_data.value, eitems, default_value, name ? name : id_data.value, description);
4071 }
4072 else {
4073 prop = RNA_def_enum(
4074 srna, id_data.value, eitems, default_value, name ? name : id_data.value, description);
4075 }
4076 if (translation_context) {
4077 RNA_def_property_translation_context(prop, translation_context);
4078 }
4079
4080 if (tags_enum.base.is_set) {
4081 RNA_def_property_tags(prop, tags_enum.base.value);
4082 }
4083 if (options_enum.is_set) {
4084 bpy_prop_assign_flag(prop, options_enum.value);
4085 }
4086 if (override_enum.is_set) {
4087 bpy_prop_assign_flag_override(prop, override_enum.value);
4088 }
4089 bpy_prop_callback_assign_update(prop, update_fn);
4090 bpy_prop_callback_assign_enum(prop, get_fn, set_fn, (is_itemf ? items : nullptr));
4092
4093 if (is_itemf == false) {
4094 /* NOTE: this must be postponed until after #RNA_def_property_duplicate_pointers
4095 * otherwise if this is a generator it may free the strings before we copy them */
4096 Py_DECREF(items_fast);
4097
4098 MEM_freeN(eitems);
4099 }
4100
4101 Py_RETURN_NONE;
4102}
4103
4104StructRNA *pointer_type_from_py(PyObject *value, const char *error_prefix)
4105{
4106 StructRNA *srna;
4107
4108 srna = srna_from_self(value, "");
4109 if (!srna) {
4110 if (PyErr_Occurred()) {
4111 PyObject *msg = PyC_ExceptionBuffer();
4112 const char *msg_char = PyUnicode_AsUTF8(msg);
4113 PyErr_Clear();
4114
4115 PyErr_Format(
4116 PyExc_TypeError, "%.200s expected an RNA type, failed with: %s", error_prefix, msg_char);
4117 Py_DECREF(msg);
4118 }
4119 else {
4120 PyErr_Format(PyExc_TypeError,
4121 "%.200s expected an RNA type, failed with type '%s'",
4122 error_prefix,
4123 Py_TYPE(value)->tp_name);
4124 }
4125 return nullptr;
4126 }
4127
4128 return srna;
4129}
4130
4132 /* Wrap. */
4133 BPy_PointerProperty_doc,
4134 ".. function:: PointerProperty("
4135 "type=None, "
4136 "*, "
4137 "name=\"\", "
4138 "description=\"\", "
4139 "translation_context=\"*\", "
4140 "options={'ANIMATABLE'}, "
4141 "override=set(), "
4142 "tags=set(), "
4143 "poll=None, "
4144 "update=None)\n"
4145 "\n"
4146 " Returns a new pointer property definition.\n"
4150 "\n"
4151 ".. note:: Pointer properties do not support storing references to embedded IDs "
4152 "(e.g. `bpy.types.Scene.collection`, `bpy.types.Material.node_tree`).\n"
4153 " These should exclusively be referenced and accessed through their owner ID "
4154 "(e.g. the scene or material).\n");
4155PyObject *BPy_PointerProperty(PyObject *self, PyObject *args, PyObject *kw)
4156{
4157 StructRNA *srna;
4158 { /* Keep this block first. */
4159 PyObject *deferred_result;
4161 self, args, kw, pymeth_PointerProperty, &deferred_result);
4162 if (srna == nullptr) {
4163 return deferred_result;
4164 }
4165 }
4166
4167 BPy_PropIDParse id_data{};
4168 id_data.srna = srna;
4169
4170 const char *name = nullptr, *description = "";
4171 const char *translation_context = nullptr;
4172 PropertyRNA *prop;
4173 StructRNA *ptype;
4174 PyObject *type = Py_None;
4175
4176 BPy_EnumProperty_Parse options_enum{};
4177 options_enum.items = rna_enum_property_flag_items;
4178 options_enum.value = 0;
4179
4180 BPy_EnumProperty_Parse override_enum{};
4182 override_enum.value = 0;
4183
4185 tags_enum.srna = srna;
4186
4187 PyObject *update_fn = nullptr, *poll_fn = nullptr;
4188
4189 static const char *_keywords[] = {
4190 "attr",
4191 "type",
4192 "name",
4193 "description",
4194 "translation_context",
4195 "options",
4196 "override",
4197 "tags",
4198 "poll",
4199 "update",
4200 nullptr,
4201 };
4202 static _PyArg_Parser _parser = {
4204 "O&" /* `attr` */
4205 "O" /* `type` */
4206 "|$" /* Optional, keyword only arguments. */
4207 "s" /* `name` */
4208 "s" /* `description` */
4209 "s" /* `translation_context` */
4210 "O&" /* `options` */
4211 "O&" /* `override` */
4212 "O&" /* `tags` */
4213 "O" /* `poll` */
4214 "O" /* `update` */
4215 ":PointerProperty",
4216 _keywords,
4217 nullptr,
4218 };
4219 if (!_PyArg_ParseTupleAndKeywordsFast(args,
4220 kw,
4221 &_parser,
4223 &id_data,
4224 &type,
4225 &name,
4226 &description,
4227 &translation_context,
4229 &options_enum,
4231 &override_enum,
4233 &tags_enum,
4234 &poll_fn,
4235 &update_fn))
4236 {
4237 return nullptr;
4238 }
4239
4240 ptype = pointer_type_from_py(type, "PointerProperty(...)");
4241 if (!ptype) {
4242 return nullptr;
4243 }
4244 if (!RNA_struct_is_a(ptype, &RNA_PropertyGroup) && !RNA_struct_is_ID(ptype)) {
4245 PyErr_Format(PyExc_TypeError,
4246 "PointerProperty(...) expected an RNA type derived from %.200s or %.200s",
4247 RNA_struct_ui_name(&RNA_ID),
4249 return nullptr;
4250 }
4251 if (bpy_prop_callback_check(update_fn, "update", 2) == -1) {
4252 return nullptr;
4253 }
4254 if (bpy_prop_callback_check(poll_fn, "poll", 2) == -1) {
4255 return nullptr;
4256 }
4257
4258 if (id_data.prop_free_handle != nullptr) {
4260 }
4262 srna, id_data.value, ptype, name ? name : id_data.value, description);
4263 if (translation_context) {
4264 RNA_def_property_translation_context(prop, translation_context);
4265 }
4266
4267 if (tags_enum.base.is_set) {
4268 RNA_def_property_tags(prop, tags_enum.base.value);
4269 }
4270 if (options_enum.is_set) {
4271 bpy_prop_assign_flag(prop, options_enum.value);
4272 }
4273 if (override_enum.is_set) {
4274 bpy_prop_assign_flag_override(prop, override_enum.value);
4275 }
4276
4278 if (RNA_struct_is_a(srna, &RNA_PropertyGroup)) {
4280 }
4281 }
4282 bpy_prop_callback_assign_update(prop, update_fn);
4283 bpy_prop_callback_assign_pointer(prop, poll_fn);
4285
4286 Py_RETURN_NONE;
4287}
4288
4290 /* Wrap. */
4291 BPy_CollectionProperty_doc,
4292 ".. function:: CollectionProperty("
4293 "type=None, "
4294 "*, "
4295 "name=\"\", "
4296 "description=\"\", "
4297 "translation_context=\"*\", "
4298 "options={'ANIMATABLE'}, "
4299 "override=set(), "
4300 "tags=set())\n"
4301 "\n"
4302 " Returns a new collection property definition.\n"
4306PyObject *BPy_CollectionProperty(PyObject *self, PyObject *args, PyObject *kw)
4307{
4308 StructRNA *srna;
4309 { /* Keep this block first. */
4310 PyObject *deferred_result;
4312 self, args, kw, pymeth_CollectionProperty, &deferred_result);
4313 if (srna == nullptr) {
4314 return deferred_result;
4315 }
4316 }
4317
4318 BPy_PropIDParse id_data{};
4319 id_data.srna = srna;
4320
4321 const char *name = nullptr, *description = "";
4322 const char *translation_context = nullptr;
4323 PropertyRNA *prop;
4324 StructRNA *ptype;
4325 PyObject *type = Py_None;
4326
4327 BPy_EnumProperty_Parse options_enum{};
4328 options_enum.items = rna_enum_property_flag_items;
4329 options_enum.value = 0;
4330
4331 BPy_EnumProperty_Parse override_enum{};
4333 override_enum.value = 0;
4334
4336 tags_enum.srna = srna;
4337
4338 static const char *_keywords[] = {
4339 "attr",
4340 "type",
4341 "name",
4342 "description",
4343 "translation_context",
4344 "options",
4345 "override",
4346 "tags",
4347 nullptr,
4348 };
4349 static _PyArg_Parser _parser = {
4351 "O&" /* `attr` */
4352 "O" /* `type` */
4353 "|$" /* Optional, keyword only arguments. */
4354 "s" /* `name` */
4355 "s" /* `description` */
4356 "s" /* `translation_context` */
4357 "O&" /* `options` */
4358 "O&" /* `override` */
4359 "O&" /* `tags` */
4360 ":CollectionProperty",
4361 _keywords,
4362 nullptr,
4363 };
4364 if (!_PyArg_ParseTupleAndKeywordsFast(args,
4365 kw,
4366 &_parser,
4368 &id_data,
4369 &type,
4370 &name,
4371 &description,
4372 &translation_context,
4374 &options_enum,
4376 &override_enum,
4378 &tags_enum))
4379 {
4380 return nullptr;
4381 }
4382
4383 ptype = pointer_type_from_py(type, "CollectionProperty(...):");
4384 if (!ptype) {
4385 return nullptr;
4386 }
4387
4388 if (!RNA_struct_is_a(ptype, &RNA_PropertyGroup)) {
4389 PyErr_Format(PyExc_TypeError,
4390 "CollectionProperty(...) expected an RNA type derived from %.200s",
4392 return nullptr;
4393 }
4394
4395 if (id_data.prop_free_handle != nullptr) {
4397 }
4399 srna, id_data.value, ptype, name ? name : id_data.value, description);
4400 if (translation_context) {
4401 RNA_def_property_translation_context(prop, translation_context);
4402 }
4403
4404 if (tags_enum.base.is_set) {
4405 RNA_def_property_tags(prop, tags_enum.base.value);
4406 }
4407 if (options_enum.is_set) {
4408 bpy_prop_assign_flag(prop, options_enum.value);
4409 }
4410 if (override_enum.is_set) {
4411 bpy_prop_assign_flag_override(prop, override_enum.value);
4412 }
4413
4415 if (RNA_struct_is_a(srna, &RNA_PropertyGroup)) {
4417 }
4418 }
4420
4421 Py_RETURN_NONE;
4422}
4423
4425 /* Wrap. */
4426 BPy_RemoveProperty_doc,
4427 ".. function:: RemoveProperty(cls, attr)\n"
4428 "\n"
4429 " Removes a dynamically defined property.\n"
4430 "\n"
4431 " :arg cls: The class containing the property (must be a positional argument).\n"
4432 " :type cls: type\n"
4433 " :arg attr: Property name (must be passed as a keyword).\n"
4434 " :type attr: str\n"
4435 "\n"
4436 ".. note:: Typically this function doesn't need to be accessed directly.\n"
4437 " Instead use ``del cls.attr``\n");
4438static PyObject *BPy_RemoveProperty(PyObject *self, PyObject *args, PyObject *kw)
4439{
4440 StructRNA *srna;
4441
4442 if (PyTuple_GET_SIZE(args) == 1) {
4443 PyObject *ret;
4444 self = PyTuple_GET_ITEM(args, 0);
4445 args = PyTuple_New(0);
4446 ret = BPy_RemoveProperty(self, args, kw);
4447 Py_DECREF(args);
4448 return ret;
4449 }
4450 if (PyTuple_GET_SIZE(args) > 1) {
4451 PyErr_SetString(PyExc_ValueError, "expected one positional arg, one keyword arg");
4452 return nullptr;
4453 }
4454
4455 srna = srna_from_self(self, "RemoveProperty(...):");
4456 if (srna == nullptr && PyErr_Occurred()) {
4457 return nullptr; /* self's type was compatible but error getting the srna */
4458 }
4459 if (srna == nullptr) {
4460 PyErr_SetString(PyExc_TypeError, "RemoveProperty(): struct rna not available for this type");
4461 return nullptr;
4462 }
4463
4464 const char *id = nullptr;
4465
4466 static const char *_keywords[] = {
4467 "attr",
4468 nullptr,
4469 };
4470 static _PyArg_Parser _parser = {
4472 "s" /* `attr` */
4473 ":RemoveProperty",
4474 _keywords,
4475 nullptr,
4476 };
4477 if (!_PyArg_ParseTupleAndKeywordsFast(args, kw, &_parser, &id)) {
4478 return nullptr;
4479 }
4480
4481 if (RNA_def_property_free_identifier(srna, id) != 1) {
4482 PyErr_Format(PyExc_TypeError, "RemoveProperty(): '%s' not a defined dynamic property", id);
4483 return nullptr;
4484 }
4485
4486 Py_RETURN_NONE;
4487}
4488
4490
4491/* -------------------------------------------------------------------- */
4494
4495#ifdef __GNUC__
4496# ifdef __clang__
4497# pragma clang diagnostic push
4498# pragma clang diagnostic ignored "-Wcast-function-type"
4499# else
4500# pragma GCC diagnostic push
4501# pragma GCC diagnostic ignored "-Wcast-function-type"
4502# endif
4503#endif
4504
4505static PyMethodDef props_methods[] = {
4506 {"BoolProperty",
4507 (PyCFunction)BPy_BoolProperty,
4508 METH_VARARGS | METH_KEYWORDS,
4509 BPy_BoolProperty_doc},
4510 {"BoolVectorProperty",
4511 (PyCFunction)BPy_BoolVectorProperty,
4512 METH_VARARGS | METH_KEYWORDS,
4513 BPy_BoolVectorProperty_doc},
4514 {"IntProperty",
4515 (PyCFunction)BPy_IntProperty,
4516 METH_VARARGS | METH_KEYWORDS,
4517 BPy_IntProperty_doc},
4518 {"IntVectorProperty",
4519 (PyCFunction)BPy_IntVectorProperty,
4520 METH_VARARGS | METH_KEYWORDS,
4521 BPy_IntVectorProperty_doc},
4522 {"FloatProperty",
4523 (PyCFunction)BPy_FloatProperty,
4524 METH_VARARGS | METH_KEYWORDS,
4525 BPy_FloatProperty_doc},
4526 {"FloatVectorProperty",
4527 (PyCFunction)BPy_FloatVectorProperty,
4528 METH_VARARGS | METH_KEYWORDS,
4529 BPy_FloatVectorProperty_doc},
4530 {"StringProperty",
4531 (PyCFunction)BPy_StringProperty,
4532 METH_VARARGS | METH_KEYWORDS,
4533 BPy_StringProperty_doc},
4534 {"EnumProperty",
4535 (PyCFunction)BPy_EnumProperty,
4536 METH_VARARGS | METH_KEYWORDS,
4537 BPy_EnumProperty_doc},
4538 {"PointerProperty",
4539 (PyCFunction)BPy_PointerProperty,
4540 METH_VARARGS | METH_KEYWORDS,
4541 BPy_PointerProperty_doc},
4542 {"CollectionProperty",
4543 (PyCFunction)BPy_CollectionProperty,
4544 METH_VARARGS | METH_KEYWORDS,
4545 BPy_CollectionProperty_doc},
4546
4547 {"RemoveProperty",
4548 (PyCFunction)BPy_RemoveProperty,
4549 METH_VARARGS | METH_KEYWORDS,
4550 BPy_RemoveProperty_doc},
4551 {nullptr, nullptr, 0, nullptr},
4552};
4553
4554#ifdef __GNUC__
4555# ifdef __clang__
4556# pragma clang diagnostic pop
4557# else
4558# pragma GCC diagnostic pop
4559# endif
4560#endif
4561
4562static int props_visit(PyObject * /*self*/, visitproc visit, void *arg)
4563{
4565 PyObject **py_data = (PyObject **)&prop_store->py_data;
4566 for (int i = 0; i < BPY_PROP_STORE_PY_DATA_SIZE; i++) {
4567 Py_VISIT(py_data[i]);
4568 }
4569 }
4570 return 0;
4571}
4572
4573static int props_clear(PyObject * /*self*/)
4574{
4576 PyObject **py_data = (PyObject **)&prop_store->py_data;
4577 for (int i = 0; i < BPY_PROP_STORE_PY_DATA_SIZE; i++) {
4578 Py_CLEAR(py_data[i]);
4579 }
4580 }
4581 return 0;
4582}
4583
4585 /* Wrap. */
4586 props_module_doc,
4587 "This module defines properties to extend Blender's internal data. The result of these "
4588 "functions"
4589 " is used to assign properties to classes registered with Blender and can't be used "
4590 "directly.\n"
4591 "\n"
4592 ".. note:: All parameters to these functions must be passed as keywords.\n");
4593
4594static PyModuleDef props_module = {
4595 /*m_base*/ PyModuleDef_HEAD_INIT,
4596 /*m_name*/ "bpy.props",
4597 /*m_doc*/ props_module_doc,
4598 /*m_size*/ -1, /* multiple "initialization" just copies the module dict. */
4599 /*m_methods*/ props_methods,
4600 /*m_slots*/ nullptr,
4601 /*m_traverse*/ props_visit,
4602 /*m_clear*/ props_clear,
4603 /*m_free*/ nullptr,
4604};
4605
4606PyObject *BPY_rna_props()
4607{
4608 PyObject *submodule;
4609 PyObject *submodule_dict;
4610
4611 submodule = PyModule_Create(&props_module);
4612 PyDict_SetItemString(PyImport_GetModuleDict(), props_module.m_name, submodule);
4613
4614 /* API needs the PyObjects internally. */
4615 submodule_dict = PyModule_GetDict(submodule);
4616
4617#define ASSIGN_STATIC(_name) pymeth_##_name = PyDict_GetItemString(submodule_dict, #_name)
4618
4619 ASSIGN_STATIC(BoolProperty);
4620 ASSIGN_STATIC(BoolVectorProperty);
4621 ASSIGN_STATIC(IntProperty);
4622 ASSIGN_STATIC(IntVectorProperty);
4623 ASSIGN_STATIC(FloatProperty);
4624 ASSIGN_STATIC(FloatVectorProperty);
4625 ASSIGN_STATIC(StringProperty);
4626 ASSIGN_STATIC(EnumProperty);
4627 ASSIGN_STATIC(PointerProperty);
4628 ASSIGN_STATIC(CollectionProperty);
4629 ASSIGN_STATIC(RemoveProperty);
4630
4631 if (PyType_Ready(&bpy_prop_deferred_Type) < 0) {
4632 return nullptr;
4633 }
4634 PyModule_AddType(submodule, &bpy_prop_deferred_Type);
4635
4636 /* Run this when properties are freed. */
4638
4639 return submodule;
4640}
4641
4643{
4644 /* Remove all user counts, so this isn't considered a leak from Python's perspective. */
4645 props_clear(nullptr);
4646
4647 /* Running is harmless, but redundant. */
4649
4650 /* Include as it's correct, in practice this should never be used again. */
4652}
4653
#define BLI_assert(a)
Definition BLI_assert.h:46
#define LISTBASE_FOREACH(type, var, list)
BLI_INLINE void BLI_listbase_clear(ListBase *lb)
void BLI_addtail(ListBase *listbase, void *vlink) ATTR_NONNULL(1)
Definition listbase.cc:111
void BLI_remlink(ListBase *listbase, void *vlink) ATTR_NONNULL(1)
Definition listbase.cc:131
#define STRINGIFY(x)
#define UNLIKELY(x)
#define STREQ(a, b)
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
Definition RNA_define.hh:26
int(*)(PointerRNA *ptr, PropertyRNA *prop) EnumPropertyGetFunc
Definition RNA_types.hh:730
void(*)(PointerRNA *ptr, PropertyRNA *prop, const bool *values) BooleanArrayPropertySetFunc
Definition RNA_types.hh:657
void(*)(PointerRNA *ptr, PropertyRNA *prop, char *value) StringPropertyGetFunc
Definition RNA_types.hh:674
void(*)(PointerRNA *ptr, PropertyRNA *prop, bool *values) BooleanArrayPropertyGetFunc
Definition RNA_types.hh:656
int(*)(PointerRNA *ptr, PropertyRNA *prop) StringPropertyLengthFunc
Definition RNA_types.hh:675
@ STRUCT_CONTAINS_DATABLOCK_IDPROPERTIES
Definition RNA_types.hh:858
void(*)(PointerRNA *ptr, PropertyRNA *prop, float *values) FloatArrayPropertyGetFunc
Definition RNA_types.hh:668
#define RNA_ENUM_BITFLAG_SIZE
Definition RNA_types.hh:210
void(*)(PointerRNA *ptr, PropertyRNA *prop, const char *value) StringPropertySetFunc
Definition RNA_types.hh:676
eStringPropertySearchFlag
Definition RNA_types.hh:687
@ PROP_STRING_SEARCH_SUGGESTION
Definition RNA_types.hh:701
void(*)(PointerRNA *ptr, PropertyRNA *prop, int *values) IntArrayPropertyGetFunc
Definition RNA_types.hh:662
void(*)(PointerRNA *ptr, PropertyRNA *prop, int value) EnumPropertySetFunc
Definition RNA_types.hh:731
void(*)(PointerRNA *ptr, PropertyRNA *prop, const int *values) IntArrayPropertySetFunc
Definition RNA_types.hh:663
@ PROP_FLOAT
Definition RNA_types.hh:152
@ PROP_BOOLEAN
Definition RNA_types.hh:150
@ PROP_INT
Definition RNA_types.hh:151
@ PROP_STRING
Definition RNA_types.hh:153
bool(*)(PointerRNA *ptr, PropertyRNA *prop) BooleanPropertyGetFunc
Definition RNA_types.hh:654
void(*)(const bContext *C, PointerRNA *ptr, PropertyRNA *prop, const char *edit_text, blender::FunctionRef< void(StringPropertySearchVisitParams)> visit_fn) StringPropertySearchFunc
Definition RNA_types.hh:715
@ PROP_UNIT_NONE
Definition RNA_types.hh:161
float(*)(PointerRNA *ptr, PropertyRNA *prop) FloatPropertyGetFunc
Definition RNA_types.hh:666
int(*)(PointerRNA *ptr, PropertyRNA *prop) IntPropertyGetFunc
Definition RNA_types.hh:660
void(*)(PointerRNA *ptr, PropertyRNA *prop, float value) FloatPropertySetFunc
Definition RNA_types.hh:667
PropertyOverrideFlag
Definition RNA_types.hh:467
void(*)(PointerRNA *ptr, PropertyRNA *prop, int value) IntPropertySetFunc
Definition RNA_types.hh:661
const EnumPropertyItem *(*)(bContext *C, PointerRNA *ptr, PropertyRNA *prop, bool *r_free) EnumPropertyItemFunc
Definition RNA_types.hh:733
void(*)(PointerRNA *ptr, PropertyRNA *prop, const float *values) FloatArrayPropertySetFunc
Definition RNA_types.hh:669
PropertyFlag
Definition RNA_types.hh:286
@ PROP_ANIMATABLE
Definition RNA_types.hh:305
@ PROP_ENUM_FLAG
Definition RNA_types.hh:378
void(*)(PointerRNA *ptr, PropertyRNA *prop, bool value) BooleanPropertySetFunc
Definition RNA_types.hh:655
@ PROP_MATRIX
Definition RNA_types.hh:253
@ PROP_NONE
Definition RNA_types.hh:221
#define C
Definition RandGen.cpp:29
void bpy_context_clear(struct bContext *C, const PyGILState_STATE *gilstate)
void bpy_context_set(struct bContext *C, PyGILState_STATE *gilstate)
PyObject * self
#define BPY_PROPDEF_SUBTYPE_STRING_DOC
Definition bpy_props.cc:70
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)
static PyObject * pymeth_FloatProperty
Definition bpy_props.cc:367
static void bpy_prop_callback_assign_float_array(PropertyRNA *prop, PyObject *get_fn, PyObject *set_fn)
static bool bpy_prop_string_visit_fn_call(PyObject *py_func, PyObject *item, blender::FunctionRef< void(StringPropertySearchVisitParams)> visit_fn)
static void bpy_prop_callback_assign_boolean_array(PropertyRNA *prop, PyObject *get_fn, PyObject *set_fn)
static void bpy_prop_boolean_array_set_fn(PointerRNA *ptr, PropertyRNA *prop, const bool *values)
Definition bpy_props.cc:789
static PyObject * BPy_EnumProperty(PyObject *self, PyObject *args, PyObject *kw)
#define ASSIGN_PYOBJECT_INCREF(a, b)
Definition bpy_props.cc:159
static void bpy_prop_array_matrix_swap_row_column_vn_vn(float *values_dst, const float *values_src, const BPyPropArrayLength *array_len_info)
Definition bpy_props.cc:562
static PyObject * BPy_FloatProperty(PyObject *self, PyObject *args, PyObject *kw)
static void bpy_prop_callback_assign_string(PropertyRNA *prop, PyObject *get_fn, PyObject *set_fn, PyObject *search_fn, const eStringPropertySearchFlag search_flag)
static PyModuleDef props_module
static bool bpy_prop_pointer_poll_fn(PointerRNA *self, PointerRNA candidate, PropertyRNA *prop)
#define BPY_PROPDEF_OPTIONS_OVERRIDE_COLLECTION_DOC
Definition bpy_props.cc:66
static bool py_long_as_int(PyObject *py_long, int *r_int)
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)
Definition bpy_props.cc:544
static float bpy_prop_float_get_fn(PointerRNA *ptr, PropertyRNA *prop)
#define BPY_PROPDEF_NAME_DOC
static int bpy_prop_int_get_fn(PointerRNA *ptr, PropertyRNA *prop)
Definition bpy_props.cc:847
static PyGetSetDef bpy_prop_deferred_getset[]
Definition bpy_props.cc:273
static void bpy_prop_callback_assign_int_array(PropertyRNA *prop, PyObject *get_fn, PyObject *set_fn)
#define BPY_PROPDEF_FLOAT_STEP_DOC
static PyObject * pymeth_IntVectorProperty
Definition bpy_props.cc:366
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.")
#define BPY_PROPDEF_UPDATE_DOC
static bool bpy_prop_array_is_matrix_compatible(PropertyRNA *prop, const BPyPropArrayLength *array_len_info)
Definition bpy_props.cc:552
static void bpy_prop_boolean_array_get_fn(PointerRNA *ptr, PropertyRNA *prop, bool *values)
Definition bpy_props.cc:735
static int bpy_prop_string_length_fn(PointerRNA *ptr, PropertyRNA *prop)
static PyObject * pymeth_EnumProperty
Definition bpy_props.cc:370
#define BPY_PROPDEF_NUM_SOFT_MINMAX_DOC(ty)
static PyObject * bpy_prop_deferred_keywords_get(BPy_PropDeferred *self, void *)
Definition bpy_props.cc:266
static int bpy_prop_deferred_clear(BPy_PropDeferred *self)
Definition bpy_props.cc:224
static void bpy_prop_py_data_remove(PropertyRNA *prop)
Definition bpy_props.cc:187
static void bpy_prop_int_array_get_fn(PointerRNA *ptr, PropertyRNA *prop, int *values)
Definition bpy_props.cc:930
#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 PyObject * BPy_BoolVectorProperty(PyObject *self, PyObject *args, PyObject *kw)
static PyObject * pymeth_FloatVectorProperty
Definition bpy_props.cc:368
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)
Definition bpy_props.cc:891
static PyObject * pymeth_IntProperty
Definition bpy_props.cc:365
#define BPY_PROPDEF_SET_DOC(ty)
static void bpy_prop_int_array_set_fn(PointerRNA *ptr, PropertyRNA *prop, const int *values)
Definition bpy_props.cc:984
#define BPY_PROPDEF_POINTER_TYPE_DOC
PyObject * BPY_rna_props()
static PyMethodDef props_methods[]
static void bpy_prop_callback_assign_pointer(PropertyRNA *prop, PyObject *poll_fn)
static PyObject * pyrna_struct_as_instance(PointerRNA *ptr)
Definition bpy_props.cc:375
static PyObject * BPy_BoolProperty(PyObject *self, PyObject *args, PyObject *kw)
static PyObject * bpy_prop_deferred_function_get(BPy_PropDeferred *self, void *)
Definition bpy_props.cc:255
static void bpy_prop_deferred_dealloc(BPy_PropDeferred *self)
Definition bpy_props.cc:211
static int props_clear(PyObject *)
static void bpy_prop_boolean_set_fn(PointerRNA *ptr, PropertyRNA *prop, bool value)
Definition bpy_props.cc:696
void BPY_rna_props_clear_all()
static PyObject * pymeth_RemoveProperty
Definition bpy_props.cc:373
static void bpy_prop_callback_assign_int(PropertyRNA *prop, PyObject *get_fn, PyObject *set_fn)
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
Definition bpy_props.cc:372
static void bpy_prop_assign_flag(PropertyRNA *prop, const int flag)
Definition bpy_props.cc:399
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 void bpy_prop_callback_assign_float(PropertyRNA *prop, PyObject *get_fn, PyObject *set_fn)
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)
Definition bpy_props.cc:218
#define BPY_PROP_STORE_PY_DATA_SIZE
Definition bpy_props.cc:157
static int bpy_prop_array_length_parse(PyObject *o, void *p)
Definition bpy_props.cc:460
static void bpy_prop_float_array_get_fn(PointerRNA *ptr, PropertyRNA *prop, float *values)
static PyObject * pymeth_PointerProperty
Definition bpy_props.cc:371
#define BPY_PROPDEF_OPTIONS_DOC
Definition bpy_props.cc:54
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)
Definition bpy_props.cc:528
static void bpy_prop_gil_rna_writable_end(const BPyPropGIL_RNAWritable_State &prop_state)
Definition bpy_props.cc:436
static bool bpy_prop_boolean_get_fn(PointerRNA *ptr, PropertyRNA *prop)
Definition bpy_props.cc:650
#define BPY_PROPDEF_GET_DOC(ty)
static void bpy_prop_float_set_fn(PointerRNA *ptr, PropertyRNA *prop, float value)
static void bpy_prop_callback_assign_boolean(PropertyRNA *prop, PyObject *get_fn, PyObject *set_fn)
static BPyPropStore * bpy_prop_py_data_ensure(PropertyRNA *prop)
Definition bpy_props.cc:173
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_string_get_fn(PointerRNA *ptr, PropertyRNA *prop, char *value)
StructRNA * pointer_type_from_py(PyObject *value, const char *error_prefix)
static PyObject * bpy_prop_deferred_data_CreatePyObject(PyObject *fn, PyObject *kw)
Definition bpy_props.cc:340
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
Definition bpy_props.cc:363
static void bpy_prop_array_matrix_swap_row_column_vn(float *values, const BPyPropArrayLength *array_len_info)
Definition bpy_props.cc:576
static BPyPropGIL_RNAWritable_State bpy_prop_gil_rna_writable_begin()
Definition bpy_props.cc:425
#define BPY_PROPDEF_OPTIONS_ENUM_DOC
Definition bpy_props.cc:58
static int bpy_prop_arg_parse_tag_defines(PyObject *o, void *p)
static void bpy_prop_update_fn(bContext *C, PointerRNA *ptr, PropertyRNA *prop)
Definition bpy_props.cc:595
static void bpy_prop_callback_assign_update(PropertyRNA *prop, PyObject *update_fn)
#define BPY_PROPDEF_UNIT_DOC
static void bpy_prop_callback_assign_enum(PropertyRNA *prop, PyObject *get_fn, PyObject *set_fn, PyObject *itemf_fn)
#define BPY_PROPDEF_SUBTYPE_NUMBER_DOC
Definition bpy_props.cc:74
static PyObject * bpy_prop_deferred_call(BPy_PropDeferred *, PyObject *, PyObject *)
Definition bpy_props.cc:241
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
Definition bpy_props.cc:78
#define BPY_PROPDEF_VECSIZE_DOC
#define BPY_PROPDEF_INT_STEP_DOC
#define BPY_PROPDEF_DESC_DOC
PyTypeObject bpy_prop_deferred_Type
Definition bpy_props.cc:288
static PyObject * pymeth_BoolVectorProperty
Definition bpy_props.cc:364
static PyObject * BPy_IntVectorProperty(PyObject *self, PyObject *args, PyObject *kw)
static void bpy_prop_string_set_fn(PointerRNA *ptr, PropertyRNA *prop, const char *value)
static ListBase g_bpy_prop_store_list
Definition bpy_props.cc:171
static void bpy_prop_assign_flag_override(PropertyRNA *prop, const int flag_override)
Definition bpy_props.cc:412
#define BPY_PROPDEF_OPTIONS_OVERRIDE_DOC
Definition bpy_props.cc:62
static int props_visit(PyObject *, visitproc visit, void *arg)
static PyObject * bpy_prop_deferred_repr(BPy_PropDeferred *self)
Definition bpy_props.cc:230
static PyObject * pymeth_StringProperty
Definition bpy_props.cc:369
#define PYRNA_STACK_ARRAY
Definition bpy_props.hh:39
bool pyrna_write_check()
Definition bpy_rna.cc:406
StructRNA * srna_from_self(PyObject *self, const char *error_prefix)
Definition bpy_rna.cc:8948
void pyrna_write_set(bool val)
Definition bpy_rna.cc:413
PyObject * pyrna_struct_CreatePyObject(PointerRNA *ptr)
Definition bpy_rna.cc:8386
BPy_StructRNA * bpy_context_module
Definition bpy_rna.cc:94
static DBVT_INLINE btScalar size(const btDbvtVolume &a)
Definition btDbvt.cpp:52
const T * data() const
Definition BLI_array.hh:301
void reinitialize(const int64_t new_size)
Definition BLI_array.hh:398
VecBase< float, D > step(VecOp< float, D >, VecOp< float, D >) RET
float length(VecOp< float, D >) RET
#define MAX_IDPROP_NAME
static bool py_long_as_int(PyObject *py_long, int *r_int)
void * MEM_mallocN(size_t len, const char *str)
Definition mallocn.cc:128
void * MEM_calloc_arrayN(size_t len, size_t size, const char *str)
Definition mallocn.cc:123
void * MEM_callocN(size_t len, const char *str)
Definition mallocn.cc:118
void MEM_freeN(void *vmemh)
Definition mallocn.cc:113
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()
return ret
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)
PropertySubType RNA_property_subtype(PropertyRNA *prop)
PointerRNA RNA_pointer_create_discrete(ID *id, StructRNA *type, void *data)
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_int_funcs_runtime(PropertyRNA *prop, IntPropertyGetFunc getfunc, IntPropertySetFunc setfunc, IntPropertyRangeFunc rangefunc)
void RNA_def_property_boolean_default(PropertyRNA *prop, bool value)
void RNA_def_property_multi_array(PropertyRNA *prop, int dimension, const int length[])
void RNA_def_property_enum_funcs_runtime(PropertyRNA *prop, EnumPropertyGetFunc getfunc, EnumPropertySetFunc setfunc, EnumPropertyItemFunc itemfunc)
void RNA_def_property_boolean_array_funcs_runtime(PropertyRNA *prop, BooleanArrayPropertyGetFunc getfunc, BooleanArrayPropertySetFunc setfunc)
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_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_funcs_runtime(PropertyRNA *prop, FloatPropertyGetFunc getfunc, FloatPropertySetFunc setfunc, FloatPropertyRangeFunc rangefunc)
PropertyRNA * RNA_def_collection_runtime(StructOrFunctionRNA *cont_, const char *identifier, StructRNA *type, const char *ui_name, const char *ui_description)
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_int_array_default(PropertyRNA *prop, const int *array)
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_int_array_funcs_runtime(PropertyRNA *prop, IntArrayPropertyGetFunc getfunc, IntArrayPropertySetFunc setfunc, IntPropertyRangeFunc rangefunc)
void RNA_def_property_float_array_funcs_runtime(PropertyRNA *prop, FloatArrayPropertyGetFunc getfunc, FloatArrayPropertySetFunc setfunc, FloatPropertyRangeFunc rangefunc)
void RNA_def_property_translation_context(PropertyRNA *prop, const char *context)
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_boolean_funcs_runtime(PropertyRNA *prop, BooleanPropertyGetFunc getfunc, BooleanPropertySetFunc setfunc)
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_string_funcs_runtime(PropertyRNA *prop, StringPropertyGetFunc getfunc, StringPropertyLengthFunc lengthfunc, StringPropertySetFunc setfunc)
void RNA_def_property_override_flag(PropertyRNA *prop, PropertyOverrideFlag flag)
StructRNA RNA_PropertyGroup
const EnumPropertyItem rna_enum_property_override_flag_collection_items[]
Definition rna_rna.cc:237
const EnumPropertyItem rna_enum_dummy_NULL_items[]
Definition rna_rna.cc:26
const EnumPropertyItem rna_enum_property_subtype_number_array_items[]
Definition rna_rna.cc:117
const EnumPropertyItem rna_enum_property_unit_items[]
Definition rna_rna.cc:139
const EnumPropertyItem rna_enum_property_subtype_number_items[]
Definition rna_rna.cc:110
const EnumPropertyItem rna_enum_property_string_search_flag_items[]
Definition rna_rna.cc:252
const EnumPropertyItem rna_enum_property_override_flag_items[]
Definition rna_rna.cc:232
const EnumPropertyItem rna_enum_property_subtype_string_items[]
Definition rna_rna.cc:103
const EnumPropertyItem rna_enum_property_flag_items[]
Definition rna_rna.cc:183
const EnumPropertyItem rna_enum_property_flag_enum_items[]
Definition rna_rna.cc:214
const EnumPropertyItem rna_enum_icon_items[]
Definition rna_ui_api.cc:25
#define min(a, b)
Definition sort.cc:36
#define FLT_MAX
Definition stdcycles.h:14
int dims[RNA_MAX_ARRAY_DIMENSION]
Definition bpy_props.cc:453
PyGILState_STATE gilstate
Definition bpy_props.cc:421
PyObject * get_fn
Definition bpy_props.cc:131
PyObject * update_fn
Definition bpy_props.cc:134
BPyPropStore * next
Definition bpy_props.cc:123
struct BPyPropStore::@045253354374066325225004065140246371330176132224 py_data
BPyPropStore * prev
Definition bpy_props.cc:123
struct BPyPropStore::@045253354374066325225004065140246371330176132224::@067356206063336111073261153207263225151360127245::@215275161260315117263144050163362050025006225224 pointer_data
PyObject * itemf_fn
Definition bpy_props.cc:141
PyObject * poll_fn
Definition bpy_props.cc:146
PyObject * set_fn
Definition bpy_props.cc:132
struct BPyPropStore::@045253354374066325225004065140246371330176132224::@067356206063336111073261153207263225151360127245::@073373270032074363113064101052205365032167232105 string_data
struct BPyPropStore::@045253354374066325225004065140246371330176132224::@067356206063336111073261153207263225151360127245::@225312033354166071227014112076276313013274163254 enum_data
PyObject * search_fn
Definition bpy_props.cc:151
BPy_EnumProperty_Parse base
const EnumPropertyItem * items
void * prop_free_handle
const char * value
StructRNA * srna
const char * identifier
Definition RNA_types.hh:623
const char * name
Definition RNA_types.hh:627
const char * description
Definition RNA_types.hh:629
std::optional< std::string > info
Definition RNA_types.hh:682
i
Definition text_draw.cc:230
max
Definition text_draw.cc:251
uint len
PointerRNA * ptr
Definition wm_files.cc:4227
uint8_t flag
Definition wm_window.cc:139