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