Changeset View
Changeset View
Standalone View
Standalone View
source/blender/python/intern/bpy_props.c
| Show First 20 Lines • Show All 1,868 Lines • ▼ Show 20 Lines | if (UNLIKELY(RNA_def_property_free_identifier(srna, id) == -1)) { \ | ||||
| return NULL; \ | return NULL; \ | ||||
| } \ | } \ | ||||
| if (UNLIKELY(pyopts && pyrna_set_to_enum_bitfield(_property_flag_items, \ | if (UNLIKELY(pyopts && pyrna_set_to_enum_bitfield(_property_flag_items, \ | ||||
| pyopts, \ | pyopts, \ | ||||
| &opts, \ | &opts, \ | ||||
| #_func"(options={ ...}):"))) \ | #_func"(options={ ...}):"))) \ | ||||
| { \ | { \ | ||||
| return NULL; \ | return NULL; \ | ||||
| } \ | |||||
| if (py_tags && (RNA_struct_property_tag_defines(srna) == NULL)) { \ | |||||
campbellbarton: *picky*, better assign a variable for `RNA_struct_property_tag_define` result in a nested scope. | |||||
| PyErr_Format(PyExc_TypeError, \ | |||||
| #_func"(): property-tags not available for '%s'", \ | |||||
| RNA_struct_identifier(srna)); \ | |||||
| return NULL; \ | |||||
| } \ | |||||
| if (UNLIKELY(py_tags && pyrna_set_to_enum_bitfield( \ | |||||
| (EnumPropertyItem *)RNA_struct_property_tag_defines(srna), /* XXX casting to non-const */\ | |||||
campbellbartonUnsubmitted Done Inline ActionsCast is no longer needed as of rBab7ebf2b10f67b002447fb0e2cb352c2c178e128 campbellbarton: Cast is no longer needed as of rBab7ebf2b10f67b002447fb0e2cb352c2c178e128 | |||||
| py_tags, &prop_tags, #_func"(tags={ ...}):"))) \ | |||||
| { \ | |||||
| return NULL; \ | |||||
| } (void)0 | } (void)0 | ||||
| #define BPY_PROPDEF_SUBTYPE_CHECK(_func, _property_flag_items, _subtype) \ | #define BPY_PROPDEF_SUBTYPE_CHECK(_func, _property_flag_items, _subtype) \ | ||||
| BPY_PROPDEF_CHECK(_func, _property_flag_items); \ | BPY_PROPDEF_CHECK(_func, _property_flag_items); \ | ||||
| if (UNLIKELY(pysubtype && RNA_enum_value_from_id(_subtype, \ | if (UNLIKELY(pysubtype && RNA_enum_value_from_id(_subtype, \ | ||||
| pysubtype, \ | pysubtype, \ | ||||
| &subtype) == 0)) \ | &subtype) == 0)) \ | ||||
| { \ | { \ | ||||
| ▲ Show 20 Lines • Show All 113 Lines • ▼ Show 20 Lines | static PyObject *BPy_BoolProperty(PyObject *self, PyObject *args, PyObject *kw) | ||||
| if (srna) { | if (srna) { | ||||
| const char *id = NULL, *name = NULL, *description = ""; | const char *id = NULL, *name = NULL, *description = ""; | ||||
| int id_len; | int id_len; | ||||
| bool def = false; | bool def = false; | ||||
| PropertyRNA *prop; | PropertyRNA *prop; | ||||
| PyObject *pyopts = NULL; | PyObject *pyopts = NULL; | ||||
| int opts = 0; | int opts = 0; | ||||
| int prop_tags = 0; | |||||
| const char *pysubtype = NULL; | const char *pysubtype = NULL; | ||||
| int subtype = PROP_NONE; | int subtype = PROP_NONE; | ||||
| PyObject *update_cb = NULL; | PyObject *update_cb = NULL; | ||||
| PyObject *get_cb = NULL; | PyObject *get_cb = NULL; | ||||
| PyObject *set_cb = NULL; | PyObject *set_cb = NULL; | ||||
| PyObject *py_tags = NULL; | |||||
| static const char *_keywords[] = { | static const char *_keywords[] = { | ||||
campbellbartonUnsubmitted Done Inline ActionsRather keep callbacks last, these are keyword-only arguments, see: "all args must be keywords" message, so adding new args between existing ones is fine. Adding after options would be best, since they're both set's used for all property definitions. campbellbarton: Rather keep callbacks last, these are keyword-only arguments, see: `"all args must be… | |||||
| "attr", "name", "description", "default", | "attr", "name", "description", "default", | ||||
| "options", "subtype", "update", "get", "set", NULL, | "options", "subtype", "update", "get", "set", | ||||
| "tags", NULL, | |||||
| }; | }; | ||||
| static _PyArg_Parser _parser = {"s#|ssO&O!sOOO:BoolProperty", _keywords, 0}; | static _PyArg_Parser _parser = {"s#|ssO&O!sOOOO:BoolProperty", _keywords, 0}; | ||||
Not Done Inline Actionstags verible must define the type O! & &PySet_Type, &pyopts. campbellbarton: `tags` verible must define the type `O!` & `&PySet_Type, &pyopts`.
This means we get a useful… | |||||
| if (!_PyArg_ParseTupleAndKeywordsFast( | if (!_PyArg_ParseTupleAndKeywordsFast( | ||||
| args, kw, &_parser, | args, kw, &_parser, | ||||
| &id, &id_len, | &id, &id_len, | ||||
| &name, &description, PyC_ParseBool, &def, | &name, &description, PyC_ParseBool, &def, | ||||
| &PySet_Type, &pyopts, &pysubtype, | &PySet_Type, &pyopts, &pysubtype, | ||||
| &update_cb, &get_cb, &set_cb)) | &update_cb, &get_cb, &set_cb, &py_tags)) | ||||
| { | { | ||||
| return NULL; | return NULL; | ||||
| } | } | ||||
| BPY_PROPDEF_SUBTYPE_CHECK(BoolProperty, property_flag_items, property_subtype_number_items); | BPY_PROPDEF_SUBTYPE_CHECK(BoolProperty, property_flag_items, property_subtype_number_items); | ||||
| if (bpy_prop_callback_check(update_cb, "update", 2) == -1) { | if (bpy_prop_callback_check(update_cb, "update", 2) == -1) { | ||||
| return NULL; | return NULL; | ||||
| } | } | ||||
| if (bpy_prop_callback_check(get_cb, "get", 1) == -1) { | if (bpy_prop_callback_check(get_cb, "get", 1) == -1) { | ||||
| return NULL; | return NULL; | ||||
| } | } | ||||
| if (bpy_prop_callback_check(set_cb, "set", 2) == -1) { | if (bpy_prop_callback_check(set_cb, "set", 2) == -1) { | ||||
| return NULL; | return NULL; | ||||
| } | } | ||||
| prop = RNA_def_property(srna, id, PROP_BOOLEAN, subtype); | prop = RNA_def_property(srna, id, PROP_BOOLEAN, subtype); | ||||
| RNA_def_property_boolean_default(prop, def); | RNA_def_property_boolean_default(prop, def); | ||||
| RNA_def_property_ui_text(prop, name ? name : id, description); | RNA_def_property_ui_text(prop, name ? name : id, description); | ||||
| if (py_tags) { | |||||
| RNA_def_property_tags(prop, prop_tags); | |||||
| } | |||||
| if (pyopts) { | if (pyopts) { | ||||
| bpy_prop_assign_flag(prop, opts); | bpy_prop_assign_flag(prop, opts); | ||||
| } | } | ||||
| bpy_prop_callback_assign_update(prop, update_cb); | bpy_prop_callback_assign_update(prop, update_cb); | ||||
| bpy_prop_callback_assign_boolean(prop, get_cb, set_cb); | bpy_prop_callback_assign_boolean(prop, get_cb, set_cb); | ||||
| RNA_def_property_duplicate_pointers(srna, prop); | RNA_def_property_duplicate_pointers(srna, prop); | ||||
| } | } | ||||
| Show All 34 Lines | if (srna) { | ||||
| const char *id = NULL, *name = NULL, *description = ""; | const char *id = NULL, *name = NULL, *description = ""; | ||||
| int id_len; | int id_len; | ||||
| int def[PYRNA_STACK_ARRAY] = {0}; | int def[PYRNA_STACK_ARRAY] = {0}; | ||||
| int size = 3; | int size = 3; | ||||
| PropertyRNA *prop; | PropertyRNA *prop; | ||||
| PyObject *pydef = NULL; | PyObject *pydef = NULL; | ||||
| PyObject *pyopts = NULL; | PyObject *pyopts = NULL; | ||||
| int opts = 0; | int opts = 0; | ||||
| int prop_tags = 0; | |||||
| const char *pysubtype = NULL; | const char *pysubtype = NULL; | ||||
| int subtype = PROP_NONE; | int subtype = PROP_NONE; | ||||
| PyObject *update_cb = NULL; | PyObject *update_cb = NULL; | ||||
| PyObject *get_cb = NULL; | PyObject *get_cb = NULL; | ||||
| PyObject *set_cb = NULL; | PyObject *set_cb = NULL; | ||||
| PyObject *py_tags = NULL; | |||||
| static const char *_keywords[] = { | static const char *_keywords[] = { | ||||
| "attr", "name", "description", "default", | "attr", "name", "description", "default", | ||||
| "options", "subtype", "size", "update", "get", "set", NULL, | "options", "subtype", "size", "update", | ||||
| "get", "set", "tags", NULL, | |||||
| }; | }; | ||||
| static _PyArg_Parser _parser = {"s#|ssOO!siOOO:BoolVectorProperty", _keywords, 0}; | static _PyArg_Parser _parser = {"s#|ssOO!siOOOO:BoolVectorProperty", _keywords, 0}; | ||||
| if (!_PyArg_ParseTupleAndKeywordsFast( | if (!_PyArg_ParseTupleAndKeywordsFast( | ||||
| args, kw, &_parser, | args, kw, &_parser, | ||||
| &id, &id_len, | &id, &id_len, | ||||
| &name, &description, &pydef, | &name, &description, &pydef, | ||||
| &PySet_Type, &pyopts, &pysubtype, &size, | &PySet_Type, &pyopts, &pysubtype, &size, | ||||
| &update_cb, &get_cb, &set_cb)) | &update_cb, &get_cb, &set_cb, &py_tags)) | ||||
| { | { | ||||
| return NULL; | return NULL; | ||||
| } | } | ||||
| BPY_PROPDEF_SUBTYPE_CHECK(BoolVectorProperty, property_flag_items, property_subtype_array_items); | BPY_PROPDEF_SUBTYPE_CHECK(BoolVectorProperty, property_flag_items, property_subtype_array_items); | ||||
| if (size < 1 || size > PYRNA_STACK_ARRAY) { | if (size < 1 || size > PYRNA_STACK_ARRAY) { | ||||
| PyErr_Format(PyExc_TypeError, | PyErr_Format(PyExc_TypeError, | ||||
| Show All 16 Lines | if (srna) { | ||||
| } | } | ||||
| // prop = RNA_def_boolean_array(srna, id, size, pydef ? def:NULL, name ? name : id, description); | // prop = RNA_def_boolean_array(srna, id, size, pydef ? def:NULL, name ? name : id, description); | ||||
| prop = RNA_def_property(srna, id, PROP_BOOLEAN, subtype); | prop = RNA_def_property(srna, id, PROP_BOOLEAN, subtype); | ||||
| RNA_def_property_array(prop, size); | RNA_def_property_array(prop, size); | ||||
| if (pydef) RNA_def_property_boolean_array_default(prop, def); | if (pydef) RNA_def_property_boolean_array_default(prop, def); | ||||
| RNA_def_property_ui_text(prop, name ? name : id, description); | RNA_def_property_ui_text(prop, name ? name : id, description); | ||||
| if (py_tags) { | |||||
| RNA_def_property_tags(prop, prop_tags); | |||||
| } | |||||
| if (pyopts) { | if (pyopts) { | ||||
| bpy_prop_assign_flag(prop, opts); | bpy_prop_assign_flag(prop, opts); | ||||
| } | } | ||||
| bpy_prop_callback_assign_update(prop, update_cb); | bpy_prop_callback_assign_update(prop, update_cb); | ||||
| bpy_prop_callback_assign_boolean_array(prop, get_cb, set_cb); | bpy_prop_callback_assign_boolean_array(prop, get_cb, set_cb); | ||||
| RNA_def_property_duplicate_pointers(srna, prop); | RNA_def_property_duplicate_pointers(srna, prop); | ||||
| } | } | ||||
| Show All 40 Lines | static PyObject *BPy_IntProperty(PyObject *self, PyObject *args, PyObject *kw) | ||||
| if (srna) { | if (srna) { | ||||
| const char *id = NULL, *name = NULL, *description = ""; | const char *id = NULL, *name = NULL, *description = ""; | ||||
| int id_len; | int id_len; | ||||
| int min = INT_MIN, max = INT_MAX, soft_min = INT_MIN, soft_max = INT_MAX, step = 1, def = 0; | int min = INT_MIN, max = INT_MAX, soft_min = INT_MIN, soft_max = INT_MAX, step = 1, def = 0; | ||||
| PropertyRNA *prop; | PropertyRNA *prop; | ||||
| PyObject *pyopts = NULL; | PyObject *pyopts = NULL; | ||||
| int opts = 0; | int opts = 0; | ||||
| int prop_tags = 0; | |||||
| const char *pysubtype = NULL; | const char *pysubtype = NULL; | ||||
| int subtype = PROP_NONE; | int subtype = PROP_NONE; | ||||
| PyObject *update_cb = NULL; | PyObject *update_cb = NULL; | ||||
| PyObject *get_cb = NULL; | PyObject *get_cb = NULL; | ||||
| PyObject *set_cb = NULL; | PyObject *set_cb = NULL; | ||||
| PyObject *py_tags = NULL; | |||||
| static const char *_keywords[] = { | static const char *_keywords[] = { | ||||
| "attr", "name", "description", "default", | "attr", "name", "description", "default", | ||||
| "min", "max", "soft_min", "soft_max", | "min", "max", "soft_min", "soft_max", | ||||
| "step", "options", "subtype", "update", "get", "set", NULL, | "step", "options", "subtype", "update", | ||||
| "get", "set", "tags", NULL, | |||||
| }; | }; | ||||
| static _PyArg_Parser _parser = {"s#|ssiiiiiiO!sOOO:IntProperty", _keywords, 0}; | static _PyArg_Parser _parser = {"s#|ssiiiiiiO!sOOOO:IntProperty", _keywords, 0}; | ||||
| if (!_PyArg_ParseTupleAndKeywordsFast( | if (!_PyArg_ParseTupleAndKeywordsFast( | ||||
| args, kw, &_parser, | args, kw, &_parser, | ||||
| &id, &id_len, | &id, &id_len, | ||||
| &name, &description, &def, | &name, &description, &def, | ||||
| &min, &max, &soft_min, &soft_max, | &min, &max, &soft_min, &soft_max, | ||||
| &step, &PySet_Type, &pyopts, &pysubtype, | &step, &PySet_Type, &pyopts, &pysubtype, | ||||
| &update_cb, &get_cb, &set_cb)) | &update_cb, &get_cb, &set_cb, &py_tags)) | ||||
| { | { | ||||
| return NULL; | return NULL; | ||||
| } | } | ||||
| BPY_PROPDEF_SUBTYPE_CHECK(IntProperty, property_flag_items, property_subtype_number_items); | BPY_PROPDEF_SUBTYPE_CHECK(IntProperty, property_flag_items, property_subtype_number_items); | ||||
| if (bpy_prop_callback_check(update_cb, "update", 2) == -1) { | if (bpy_prop_callback_check(update_cb, "update", 2) == -1) { | ||||
| return NULL; | return NULL; | ||||
| } | } | ||||
| if (bpy_prop_callback_check(get_cb, "get", 1) == -1) { | if (bpy_prop_callback_check(get_cb, "get", 1) == -1) { | ||||
| return NULL; | return NULL; | ||||
| } | } | ||||
| if (bpy_prop_callback_check(set_cb, "set", 2) == -1) { | if (bpy_prop_callback_check(set_cb, "set", 2) == -1) { | ||||
| return NULL; | return NULL; | ||||
| } | } | ||||
| prop = RNA_def_property(srna, id, PROP_INT, subtype); | prop = RNA_def_property(srna, id, PROP_INT, subtype); | ||||
| RNA_def_property_int_default(prop, def); | RNA_def_property_int_default(prop, def); | ||||
| RNA_def_property_ui_text(prop, name ? name : id, description); | RNA_def_property_ui_text(prop, name ? name : id, description); | ||||
| RNA_def_property_range(prop, min, max); | RNA_def_property_range(prop, min, max); | ||||
| RNA_def_property_ui_range(prop, MAX2(soft_min, min), MIN2(soft_max, max), step, 3); | RNA_def_property_ui_range(prop, MAX2(soft_min, min), MIN2(soft_max, max), step, 3); | ||||
| if (py_tags) { | |||||
| RNA_def_property_tags(prop, prop_tags); | |||||
| } | |||||
| if (pyopts) { | if (pyopts) { | ||||
| bpy_prop_assign_flag(prop, opts); | bpy_prop_assign_flag(prop, opts); | ||||
| } | } | ||||
| bpy_prop_callback_assign_update(prop, update_cb); | bpy_prop_callback_assign_update(prop, update_cb); | ||||
| bpy_prop_callback_assign_int(prop, get_cb, set_cb); | bpy_prop_callback_assign_int(prop, get_cb, set_cb); | ||||
| RNA_def_property_duplicate_pointers(srna, prop); | RNA_def_property_duplicate_pointers(srna, prop); | ||||
| } | } | ||||
| Py_RETURN_NONE; | Py_RETURN_NONE; | ||||
| ▲ Show 20 Lines • Show All 46 Lines • ▼ Show 20 Lines | if (srna) { | ||||
| int id_len; | int id_len; | ||||
| int min = INT_MIN, max = INT_MAX, soft_min = INT_MIN, soft_max = INT_MAX, step = 1; | int min = INT_MIN, max = INT_MAX, soft_min = INT_MIN, soft_max = INT_MAX, step = 1; | ||||
| int def[PYRNA_STACK_ARRAY] = {0}; | int def[PYRNA_STACK_ARRAY] = {0}; | ||||
| int size = 3; | int size = 3; | ||||
| PropertyRNA *prop; | PropertyRNA *prop; | ||||
| PyObject *pydef = NULL; | PyObject *pydef = NULL; | ||||
| PyObject *pyopts = NULL; | PyObject *pyopts = NULL; | ||||
| int opts = 0; | int opts = 0; | ||||
| int prop_tags = 0; | |||||
| const char *pysubtype = NULL; | const char *pysubtype = NULL; | ||||
| int subtype = PROP_NONE; | int subtype = PROP_NONE; | ||||
| PyObject *update_cb = NULL; | PyObject *update_cb = NULL; | ||||
| PyObject *get_cb = NULL; | PyObject *get_cb = NULL; | ||||
| PyObject *set_cb = NULL; | PyObject *set_cb = NULL; | ||||
| PyObject *py_tags = NULL; | |||||
| static const char *_keywords[] = { | static const char *_keywords[] = { | ||||
| "attr", "name", "description", "default", | "attr", "name", "description", "default", | ||||
| "min", "max", "soft_min", "soft_max", | "min", "max", "soft_min", "soft_max", | ||||
| "step", "options", "subtype", "size", "update", "get", "set", NULL, | "step", "options", "subtype", "size", "update", | ||||
| "get", "set", "tags", NULL, | |||||
| }; | }; | ||||
| static _PyArg_Parser _parser = {"s#|ssOiiiiiO!siOOO:IntVectorProperty", _keywords, 0}; | static _PyArg_Parser _parser = {"s#|ssOiiiiiO!siOOOO:IntVectorProperty", _keywords, 0}; | ||||
| if (!_PyArg_ParseTupleAndKeywordsFast( | if (!_PyArg_ParseTupleAndKeywordsFast( | ||||
| args, kw, &_parser, | args, kw, &_parser, | ||||
| &id, &id_len, | &id, &id_len, | ||||
| &name, &description, &pydef, | &name, &description, &pydef, | ||||
| &min, &max, &soft_min, &soft_max, | &min, &max, &soft_min, &soft_max, | ||||
| &step, &PySet_Type, &pyopts, | &step, &PySet_Type, &pyopts, | ||||
| &pysubtype, &size, | &pysubtype, &size, | ||||
| &update_cb, &get_cb, &set_cb)) | &update_cb, &get_cb, &set_cb, &py_tags)) | ||||
| { | { | ||||
| return NULL; | return NULL; | ||||
| } | } | ||||
| BPY_PROPDEF_SUBTYPE_CHECK(IntVectorProperty, property_flag_items, property_subtype_array_items); | BPY_PROPDEF_SUBTYPE_CHECK(IntVectorProperty, property_flag_items, property_subtype_array_items); | ||||
| if (size < 1 || size > PYRNA_STACK_ARRAY) { | if (size < 1 || size > PYRNA_STACK_ARRAY) { | ||||
| PyErr_Format(PyExc_TypeError, | PyErr_Format(PyExc_TypeError, | ||||
| Show All 17 Lines | if (srna) { | ||||
| prop = RNA_def_property(srna, id, PROP_INT, subtype); | prop = RNA_def_property(srna, id, PROP_INT, subtype); | ||||
| RNA_def_property_array(prop, size); | RNA_def_property_array(prop, size); | ||||
| if (pydef) RNA_def_property_int_array_default(prop, def); | if (pydef) RNA_def_property_int_array_default(prop, def); | ||||
| RNA_def_property_range(prop, min, max); | RNA_def_property_range(prop, min, max); | ||||
| RNA_def_property_ui_text(prop, name ? name : id, description); | RNA_def_property_ui_text(prop, name ? name : id, description); | ||||
| RNA_def_property_ui_range(prop, MAX2(soft_min, min), MIN2(soft_max, max), step, 3); | RNA_def_property_ui_range(prop, MAX2(soft_min, min), MIN2(soft_max, max), step, 3); | ||||
| if (py_tags) { | |||||
| RNA_def_property_tags(prop, prop_tags); | |||||
| } | |||||
| if (pyopts) { | if (pyopts) { | ||||
| bpy_prop_assign_flag(prop, opts); | bpy_prop_assign_flag(prop, opts); | ||||
| } | } | ||||
| bpy_prop_callback_assign_update(prop, update_cb); | bpy_prop_callback_assign_update(prop, update_cb); | ||||
| bpy_prop_callback_assign_int_array(prop, get_cb, set_cb); | bpy_prop_callback_assign_int_array(prop, get_cb, set_cb); | ||||
| RNA_def_property_duplicate_pointers(srna, prop); | RNA_def_property_duplicate_pointers(srna, prop); | ||||
| } | } | ||||
| Py_RETURN_NONE; | Py_RETURN_NONE; | ||||
| ▲ Show 20 Lines • Show All 45 Lines • ▼ Show 20 Lines | static PyObject *BPy_FloatProperty(PyObject *self, PyObject *args, PyObject *kw) | ||||
| if (srna) { | if (srna) { | ||||
| const char *id = NULL, *name = NULL, *description = ""; | const char *id = NULL, *name = NULL, *description = ""; | ||||
| int id_len; | int id_len; | ||||
| float min = -FLT_MAX, max = FLT_MAX, soft_min = -FLT_MAX, soft_max = FLT_MAX, step = 3, def = 0.0f; | float min = -FLT_MAX, max = FLT_MAX, soft_min = -FLT_MAX, soft_max = FLT_MAX, step = 3, def = 0.0f; | ||||
| int precision = 2; | int precision = 2; | ||||
| PropertyRNA *prop; | PropertyRNA *prop; | ||||
| PyObject *pyopts = NULL; | PyObject *pyopts = NULL; | ||||
| int opts = 0; | int opts = 0; | ||||
| int prop_tags = 0; | |||||
| const char *pysubtype = NULL; | const char *pysubtype = NULL; | ||||
| int subtype = PROP_NONE; | int subtype = PROP_NONE; | ||||
| const char *pyunit = NULL; | const char *pyunit = NULL; | ||||
| int unit = PROP_UNIT_NONE; | int unit = PROP_UNIT_NONE; | ||||
| PyObject *update_cb = NULL; | PyObject *update_cb = NULL; | ||||
| PyObject *get_cb = NULL; | PyObject *get_cb = NULL; | ||||
| PyObject *set_cb = NULL; | PyObject *set_cb = NULL; | ||||
| PyObject *py_tags = NULL; | |||||
| static const char *_keywords[] = { | static const char *_keywords[] = { | ||||
| "attr", "name", "description", "default", | "attr", "name", "description", "default", | ||||
| "min", "max", "soft_min", "soft_max", | "min", "max", "soft_min", "soft_max", | ||||
| "step", "precision", "options", "subtype", | "step", "precision", "options", "subtype", | ||||
| "unit", "update", "get", "set", NULL, | "unit", "update", "get", "set", "tags", NULL, | ||||
| }; | }; | ||||
| static _PyArg_Parser _parser = {"s#|ssffffffiO!ssOOO:FloatProperty", _keywords, 0}; | static _PyArg_Parser _parser = {"s#|ssffffffiO!ssOOOO:FloatProperty", _keywords, 0}; | ||||
| if (!_PyArg_ParseTupleAndKeywordsFast( | if (!_PyArg_ParseTupleAndKeywordsFast( | ||||
| args, kw, &_parser, | args, kw, &_parser, | ||||
| &id, &id_len, | &id, &id_len, | ||||
| &name, &description, &def, | &name, &description, &def, | ||||
| &min, &max, &soft_min, &soft_max, | &min, &max, &soft_min, &soft_max, | ||||
| &step, &precision, &PySet_Type, | &step, &precision, &PySet_Type, | ||||
| &pyopts, &pysubtype, &pyunit, | &pyopts, &pysubtype, &pyunit, | ||||
| &update_cb, &get_cb, &set_cb)) | &update_cb, &get_cb, &set_cb, | ||||
| &py_tags)) | |||||
| { | { | ||||
| return NULL; | return NULL; | ||||
| } | } | ||||
| BPY_PROPDEF_SUBTYPE_CHECK(FloatProperty, property_flag_items, property_subtype_number_items); | BPY_PROPDEF_SUBTYPE_CHECK(FloatProperty, property_flag_items, property_subtype_number_items); | ||||
| if (pyunit && RNA_enum_value_from_id(rna_enum_property_unit_items, pyunit, &unit) == 0) { | if (pyunit && RNA_enum_value_from_id(rna_enum_property_unit_items, pyunit, &unit) == 0) { | ||||
| PyErr_Format(PyExc_TypeError, "FloatProperty(unit='%s'): invalid unit", pyunit); | PyErr_Format(PyExc_TypeError, "FloatProperty(unit='%s'): invalid unit", pyunit); | ||||
| Show All 11 Lines | if (srna) { | ||||
| } | } | ||||
| prop = RNA_def_property(srna, id, PROP_FLOAT, subtype | unit); | prop = RNA_def_property(srna, id, PROP_FLOAT, subtype | unit); | ||||
| RNA_def_property_float_default(prop, def); | RNA_def_property_float_default(prop, def); | ||||
| RNA_def_property_range(prop, min, max); | RNA_def_property_range(prop, min, max); | ||||
| RNA_def_property_ui_text(prop, name ? name : id, description); | RNA_def_property_ui_text(prop, name ? name : id, description); | ||||
| RNA_def_property_ui_range(prop, MAX2(soft_min, min), MIN2(soft_max, max), step, precision); | RNA_def_property_ui_range(prop, MAX2(soft_min, min), MIN2(soft_max, max), step, precision); | ||||
| if (py_tags) { | |||||
| RNA_def_property_tags(prop, prop_tags); | |||||
| } | |||||
| if (pyopts) { | if (pyopts) { | ||||
| bpy_prop_assign_flag(prop, opts); | bpy_prop_assign_flag(prop, opts); | ||||
| } | } | ||||
| bpy_prop_callback_assign_update(prop, update_cb); | bpy_prop_callback_assign_update(prop, update_cb); | ||||
| bpy_prop_callback_assign_float(prop, get_cb, set_cb); | bpy_prop_callback_assign_float(prop, get_cb, set_cb); | ||||
| RNA_def_property_duplicate_pointers(srna, prop); | RNA_def_property_duplicate_pointers(srna, prop); | ||||
| } | } | ||||
| Py_RETURN_NONE; | Py_RETURN_NONE; | ||||
| ▲ Show 20 Lines • Show All 50 Lines • ▼ Show 20 Lines | if (srna) { | ||||
| int id_len; | int id_len; | ||||
| float min = -FLT_MAX, max = FLT_MAX, soft_min = -FLT_MAX, soft_max = FLT_MAX, step = 3; | float min = -FLT_MAX, max = FLT_MAX, soft_min = -FLT_MAX, soft_max = FLT_MAX, step = 3; | ||||
| float def[PYRNA_STACK_ARRAY] = {0.0f}; | float def[PYRNA_STACK_ARRAY] = {0.0f}; | ||||
| int precision = 2, size = 3; | int precision = 2, size = 3; | ||||
| PropertyRNA *prop; | PropertyRNA *prop; | ||||
| PyObject *pydef = NULL; | PyObject *pydef = NULL; | ||||
| PyObject *pyopts = NULL; | PyObject *pyopts = NULL; | ||||
| int opts = 0; | int opts = 0; | ||||
| int prop_tags = 0; | |||||
| const char *pysubtype = NULL; | const char *pysubtype = NULL; | ||||
| int subtype = PROP_NONE; | int subtype = PROP_NONE; | ||||
| const char *pyunit = NULL; | const char *pyunit = NULL; | ||||
| int unit = PROP_UNIT_NONE; | int unit = PROP_UNIT_NONE; | ||||
| PyObject *update_cb = NULL; | PyObject *update_cb = NULL; | ||||
| PyObject *get_cb = NULL; | PyObject *get_cb = NULL; | ||||
| PyObject *set_cb = NULL; | PyObject *set_cb = NULL; | ||||
| PyObject *py_tags = NULL; | |||||
| static const char *_keywords[] = { | static const char *_keywords[] = { | ||||
| "attr", "name", "description", "default", | "attr", "name", "description", "default", | ||||
| "min", "max", "soft_min", "soft_max", | "min", "max", "soft_min", "soft_max", | ||||
| "step", "precision", "options", "subtype", | "step", "precision", "options", "subtype", | ||||
| "unit", "size", "update", "get", "set", NULL, | "unit", "size", "update", "get", "set", "tags", NULL, | ||||
| }; | }; | ||||
| static _PyArg_Parser _parser = {"s#|ssOfffffiO!ssiOOO:FloatVectorProperty", _keywords, 0}; | static _PyArg_Parser _parser = {"s#|ssOfffffiO!ssiOOOO:FloatVectorProperty", _keywords, 0}; | ||||
| if (!_PyArg_ParseTupleAndKeywordsFast( | if (!_PyArg_ParseTupleAndKeywordsFast( | ||||
| args, kw, &_parser, | args, kw, &_parser, | ||||
| &id, &id_len, | &id, &id_len, | ||||
| &name, &description, &pydef, | &name, &description, &pydef, | ||||
| &min, &max, &soft_min, &soft_max, | &min, &max, &soft_min, &soft_max, | ||||
| &step, &precision, &PySet_Type, | &step, &precision, &PySet_Type, | ||||
| &pyopts, &pysubtype, &pyunit, &size, | &pyopts, &pysubtype, &pyunit, &size, | ||||
| &update_cb, &get_cb, &set_cb)) | &update_cb, &get_cb, &set_cb, &py_tags)) | ||||
| { | { | ||||
| return NULL; | return NULL; | ||||
| } | } | ||||
| BPY_PROPDEF_SUBTYPE_CHECK(FloatVectorProperty, property_flag_items, property_subtype_array_items); | BPY_PROPDEF_SUBTYPE_CHECK(FloatVectorProperty, property_flag_items, property_subtype_array_items); | ||||
| if (pyunit && RNA_enum_value_from_id(rna_enum_property_unit_items, pyunit, &unit) == 0) { | if (pyunit && RNA_enum_value_from_id(rna_enum_property_unit_items, pyunit, &unit) == 0) { | ||||
| PyErr_Format(PyExc_TypeError, "FloatVectorProperty(unit='%s'): invalid unit", pyunit); | PyErr_Format(PyExc_TypeError, "FloatVectorProperty(unit='%s'): invalid unit", pyunit); | ||||
| Show All 22 Lines | if (srna) { | ||||
| prop = RNA_def_property(srna, id, PROP_FLOAT, subtype | unit); | prop = RNA_def_property(srna, id, PROP_FLOAT, subtype | unit); | ||||
| RNA_def_property_array(prop, size); | RNA_def_property_array(prop, size); | ||||
| if (pydef) RNA_def_property_float_array_default(prop, def); | if (pydef) RNA_def_property_float_array_default(prop, def); | ||||
| RNA_def_property_range(prop, min, max); | RNA_def_property_range(prop, min, max); | ||||
| RNA_def_property_ui_text(prop, name ? name : id, description); | RNA_def_property_ui_text(prop, name ? name : id, description); | ||||
| RNA_def_property_ui_range(prop, MAX2(soft_min, min), MIN2(soft_max, max), step, precision); | RNA_def_property_ui_range(prop, MAX2(soft_min, min), MIN2(soft_max, max), step, precision); | ||||
| if (py_tags) { | |||||
| RNA_def_property_tags(prop, prop_tags); | |||||
| } | |||||
| if (pyopts) { | if (pyopts) { | ||||
| bpy_prop_assign_flag(prop, opts); | bpy_prop_assign_flag(prop, opts); | ||||
| } | } | ||||
| bpy_prop_callback_assign_update(prop, update_cb); | bpy_prop_callback_assign_update(prop, update_cb); | ||||
| bpy_prop_callback_assign_float_array(prop, get_cb, set_cb); | bpy_prop_callback_assign_float_array(prop, get_cb, set_cb); | ||||
| RNA_def_property_duplicate_pointers(srna, prop); | RNA_def_property_duplicate_pointers(srna, prop); | ||||
| } | } | ||||
| Py_RETURN_NONE; | Py_RETURN_NONE; | ||||
| Show All 32 Lines | static PyObject *BPy_StringProperty(PyObject *self, PyObject *args, PyObject *kw) | ||||
| if (srna) { | if (srna) { | ||||
| const char *id = NULL, *name = NULL, *description = "", *def = ""; | const char *id = NULL, *name = NULL, *description = "", *def = ""; | ||||
| int id_len; | int id_len; | ||||
| int maxlen = 0; | int maxlen = 0; | ||||
| PropertyRNA *prop; | PropertyRNA *prop; | ||||
| PyObject *pyopts = NULL; | PyObject *pyopts = NULL; | ||||
| int opts = 0; | int opts = 0; | ||||
| int prop_tags = 0; | |||||
| const char *pysubtype = NULL; | const char *pysubtype = NULL; | ||||
| int subtype = PROP_NONE; | int subtype = PROP_NONE; | ||||
| PyObject *update_cb = NULL; | PyObject *update_cb = NULL; | ||||
| PyObject *get_cb = NULL; | PyObject *get_cb = NULL; | ||||
| PyObject *set_cb = NULL; | PyObject *set_cb = NULL; | ||||
| PyObject *py_tags = NULL; | |||||
| static const char *_keywords[] = { | static const char *_keywords[] = { | ||||
| "attr", "name", "description", "default", | "attr", "name", "description", "default", | ||||
| "maxlen", "options", "subtype", "update", "get", "set", NULL, | "maxlen", "options", "subtype", "update", | ||||
| "get", "set", "tags", NULL, | |||||
| }; | }; | ||||
| static _PyArg_Parser _parser = {"s#|sssiO!sOOO:StringProperty", _keywords, 0}; | static _PyArg_Parser _parser = {"s#|sssiO!sOOOO:StringProperty", _keywords, 0}; | ||||
| if (!_PyArg_ParseTupleAndKeywordsFast( | if (!_PyArg_ParseTupleAndKeywordsFast( | ||||
| args, kw, &_parser, | args, kw, &_parser, | ||||
| &id, &id_len, | &id, &id_len, | ||||
| &name, &description, &def, | &name, &description, &def, | ||||
| &maxlen, &PySet_Type, &pyopts, &pysubtype, | &maxlen, &PySet_Type, &pyopts, &pysubtype, | ||||
| &update_cb, &get_cb, &set_cb)) | &update_cb, &get_cb, &set_cb, &py_tags)) | ||||
| { | { | ||||
| return NULL; | return NULL; | ||||
| } | } | ||||
| BPY_PROPDEF_SUBTYPE_CHECK(StringProperty, property_flag_items, property_subtype_string_items); | BPY_PROPDEF_SUBTYPE_CHECK(StringProperty, property_flag_items, property_subtype_string_items); | ||||
| if (bpy_prop_callback_check(update_cb, "update", 2) == -1) { | if (bpy_prop_callback_check(update_cb, "update", 2) == -1) { | ||||
| return NULL; | return NULL; | ||||
| } | } | ||||
| if (bpy_prop_callback_check(get_cb, "get", 1) == -1) { | if (bpy_prop_callback_check(get_cb, "get", 1) == -1) { | ||||
| return NULL; | return NULL; | ||||
| } | } | ||||
| if (bpy_prop_callback_check(set_cb, "set", 2) == -1) { | if (bpy_prop_callback_check(set_cb, "set", 2) == -1) { | ||||
| return NULL; | return NULL; | ||||
| } | } | ||||
| prop = RNA_def_property(srna, id, PROP_STRING, subtype); | prop = RNA_def_property(srna, id, PROP_STRING, subtype); | ||||
| if (maxlen != 0) RNA_def_property_string_maxlength(prop, maxlen + 1); /* +1 since it includes null terminator */ | if (maxlen != 0) RNA_def_property_string_maxlength(prop, maxlen + 1); /* +1 since it includes null terminator */ | ||||
| if (def && def[0]) RNA_def_property_string_default(prop, def); | if (def && def[0]) RNA_def_property_string_default(prop, def); | ||||
| RNA_def_property_ui_text(prop, name ? name : id, description); | RNA_def_property_ui_text(prop, name ? name : id, description); | ||||
| if (py_tags) { | |||||
| RNA_def_property_tags(prop, prop_tags); | |||||
| } | |||||
| if (pyopts) { | if (pyopts) { | ||||
| bpy_prop_assign_flag(prop, opts); | bpy_prop_assign_flag(prop, opts); | ||||
| } | } | ||||
| bpy_prop_callback_assign_update(prop, update_cb); | bpy_prop_callback_assign_update(prop, update_cb); | ||||
| bpy_prop_callback_assign_string(prop, get_cb, set_cb); | bpy_prop_callback_assign_string(prop, get_cb, set_cb); | ||||
| RNA_def_property_duplicate_pointers(srna, prop); | RNA_def_property_duplicate_pointers(srna, prop); | ||||
| } | } | ||||
| Py_RETURN_NONE; | Py_RETURN_NONE; | ||||
| ▲ Show 20 Lines • Show All 61 Lines • ▼ Show 20 Lines | if (srna) { | ||||
| PyObject *def = NULL; | PyObject *def = NULL; | ||||
| int id_len; | int id_len; | ||||
| int defvalue = 0; | int defvalue = 0; | ||||
| PyObject *items, *items_fast; | PyObject *items, *items_fast; | ||||
| EnumPropertyItem *eitems; | EnumPropertyItem *eitems; | ||||
| PropertyRNA *prop; | PropertyRNA *prop; | ||||
| PyObject *pyopts = NULL; | PyObject *pyopts = NULL; | ||||
| int opts = 0; | int opts = 0; | ||||
| int prop_tags = 0; | |||||
| bool is_itemf = false; | bool is_itemf = false; | ||||
| PyObject *update_cb = NULL; | PyObject *update_cb = NULL; | ||||
| PyObject *get_cb = NULL; | PyObject *get_cb = NULL; | ||||
| PyObject *set_cb = NULL; | PyObject *set_cb = NULL; | ||||
| PyObject *py_tags = NULL; | |||||
| static const char *_keywords[] = { | static const char *_keywords[] = { | ||||
| "attr", "items", "name", "description", "default", | "attr", "items", "name", "description", "default", | ||||
| "options", "update", "get", "set", NULL, | "options", "update", "get", "set", "tags", NULL, | ||||
| }; | }; | ||||
| static _PyArg_Parser _parser = {"s#O|ssOO!OOO:EnumProperty", _keywords, 0}; | static _PyArg_Parser _parser = {"s#O|ssOO!OOOO:EnumProperty", _keywords, 0}; | ||||
| if (!_PyArg_ParseTupleAndKeywordsFast( | if (!_PyArg_ParseTupleAndKeywordsFast( | ||||
| args, kw, &_parser, | args, kw, &_parser, | ||||
| &id, &id_len, | &id, &id_len, | ||||
| &items, &name, &description, | &items, &name, &description, | ||||
| &def, &PySet_Type, &pyopts, | &def, &PySet_Type, &pyopts, | ||||
| &update_cb, &get_cb, &set_cb)) | &update_cb, &get_cb, &set_cb, &py_tags)) | ||||
| { | { | ||||
| return NULL; | return NULL; | ||||
| } | } | ||||
| BPY_PROPDEF_CHECK(EnumProperty, property_flag_enum_items); | BPY_PROPDEF_CHECK(EnumProperty, property_flag_enum_items); | ||||
| if (bpy_prop_callback_check(update_cb, "update", 2) == -1) { | if (bpy_prop_callback_check(update_cb, "update", 2) == -1) { | ||||
| return NULL; | return NULL; | ||||
| ▲ Show 20 Lines • Show All 45 Lines • ▼ Show 20 Lines | else { | ||||
| Py_DECREF(items_fast); | Py_DECREF(items_fast); | ||||
| return NULL; | return NULL; | ||||
| } | } | ||||
| } | } | ||||
| if (opts & PROP_ENUM_FLAG) prop = RNA_def_enum_flag(srna, id, eitems, defvalue, name ? name : id, description); | if (opts & PROP_ENUM_FLAG) prop = RNA_def_enum_flag(srna, id, eitems, defvalue, name ? name : id, description); | ||||
| else prop = RNA_def_enum(srna, id, eitems, defvalue, name ? name : id, description); | else prop = RNA_def_enum(srna, id, eitems, defvalue, name ? name : id, description); | ||||
| if (py_tags) { | |||||
| RNA_def_property_tags(prop, prop_tags); | |||||
| } | |||||
| if (pyopts) { | if (pyopts) { | ||||
| bpy_prop_assign_flag(prop, opts); | bpy_prop_assign_flag(prop, opts); | ||||
| } | } | ||||
| bpy_prop_callback_assign_update(prop, update_cb); | bpy_prop_callback_assign_update(prop, update_cb); | ||||
| bpy_prop_callback_assign_enum(prop, get_cb, set_cb, (is_itemf ? items : NULL)); | bpy_prop_callback_assign_enum(prop, get_cb, set_cb, (is_itemf ? items : NULL)); | ||||
| RNA_def_property_duplicate_pointers(srna, prop); | RNA_def_property_duplicate_pointers(srna, prop); | ||||
| if (is_itemf == false) { | if (is_itemf == false) { | ||||
| ▲ Show 20 Lines • Show All 57 Lines • ▼ Show 20 Lines | PyObject *BPy_PointerProperty(PyObject *self, PyObject *args, PyObject *kw) | ||||
| if (srna) { | if (srna) { | ||||
| const char *id = NULL, *name = NULL, *description = ""; | const char *id = NULL, *name = NULL, *description = ""; | ||||
| int id_len; | int id_len; | ||||
| PropertyRNA *prop; | PropertyRNA *prop; | ||||
| StructRNA *ptype; | StructRNA *ptype; | ||||
| PyObject *type = Py_None; | PyObject *type = Py_None; | ||||
| PyObject *pyopts = NULL; | PyObject *pyopts = NULL; | ||||
| PyObject *py_tags = NULL; | |||||
| int opts = 0; | int opts = 0; | ||||
| int prop_tags = 0; | |||||
| PyObject *update_cb = NULL, *poll_cb = NULL; | PyObject *update_cb = NULL, *poll_cb = NULL; | ||||
| static const char *_keywords[] = { | static const char *_keywords[] = { | ||||
| "attr", "type", "name", "description", "options", "poll", "update", NULL, | "attr", "type", "name", "description", "options", | ||||
| "poll", "update", "tags", NULL, | |||||
| }; | }; | ||||
| static _PyArg_Parser _parser = {"s#O|ssO!OO:PointerProperty", _keywords, 0}; | static _PyArg_Parser _parser = {"s#O|ssO!OOO:PointerProperty", _keywords, 0}; | ||||
| if (!_PyArg_ParseTupleAndKeywordsFast( | if (!_PyArg_ParseTupleAndKeywordsFast( | ||||
| args, kw, &_parser, | args, kw, &_parser, | ||||
| &id, &id_len, | &id, &id_len, | ||||
| &type, &name, &description, | &type, &name, &description, | ||||
| &PySet_Type, &pyopts, | &PySet_Type, &pyopts, | ||||
| &poll_cb, &update_cb)) | &poll_cb, &update_cb, &py_tags)) | ||||
| { | { | ||||
| return NULL; | return NULL; | ||||
| } | } | ||||
| BPY_PROPDEF_CHECK(PointerProperty, property_flag_items); | BPY_PROPDEF_CHECK(PointerProperty, property_flag_items); | ||||
| ptype = pointer_type_from_py(type, "PointerProperty(...)"); | ptype = pointer_type_from_py(type, "PointerProperty(...)"); | ||||
| if (!ptype) | if (!ptype) | ||||
| return NULL; | return NULL; | ||||
| if (!RNA_struct_is_a(ptype, &RNA_PropertyGroup) && !RNA_struct_is_ID(ptype)) { | if (!RNA_struct_is_a(ptype, &RNA_PropertyGroup) && !RNA_struct_is_ID(ptype)) { | ||||
| PyErr_Format(PyExc_TypeError, | PyErr_Format(PyExc_TypeError, | ||||
| "PointerProperty(...) expected an RNA type derived from %.200s or %.200s", | "PointerProperty(...) expected an RNA type derived from %.200s or %.200s", | ||||
| RNA_struct_ui_name(&RNA_ID), RNA_struct_ui_name(&RNA_PropertyGroup)); | RNA_struct_ui_name(&RNA_ID), RNA_struct_ui_name(&RNA_PropertyGroup)); | ||||
| return NULL; | return NULL; | ||||
| } | } | ||||
| if (bpy_prop_callback_check(update_cb, "update", 2) == -1) { | if (bpy_prop_callback_check(update_cb, "update", 2) == -1) { | ||||
| return NULL; | return NULL; | ||||
| } | } | ||||
| if (bpy_prop_callback_check(poll_cb, "poll", 2) == -1) { | if (bpy_prop_callback_check(poll_cb, "poll", 2) == -1) { | ||||
| return NULL; | return NULL; | ||||
| } | } | ||||
| prop = RNA_def_pointer_runtime(srna, id, ptype, name ? name : id, description); | prop = RNA_def_pointer_runtime(srna, id, ptype, name ? name : id, description); | ||||
| if (py_tags) { | |||||
| RNA_def_property_tags(prop, prop_tags); | |||||
| } | |||||
| if (pyopts) { | if (pyopts) { | ||||
| bpy_prop_assign_flag(prop, opts); | bpy_prop_assign_flag(prop, opts); | ||||
| } | } | ||||
| if (RNA_struct_idprops_contains_datablock(ptype)) { | if (RNA_struct_idprops_contains_datablock(ptype)) { | ||||
| if (RNA_struct_is_a(srna, &RNA_PropertyGroup)) { | if (RNA_struct_is_a(srna, &RNA_PropertyGroup)) { | ||||
| RNA_def_struct_flag(srna, STRUCT_CONTAINS_DATABLOCK_IDPROPERTIES); | RNA_def_struct_flag(srna, STRUCT_CONTAINS_DATABLOCK_IDPROPERTIES); | ||||
| } | } | ||||
| Show All 26 Lines | PyObject *BPy_CollectionProperty(PyObject *self, PyObject *args, PyObject *kw) | ||||
| if (srna) { | if (srna) { | ||||
| int id_len; | int id_len; | ||||
| const char *id = NULL, *name = NULL, *description = ""; | const char *id = NULL, *name = NULL, *description = ""; | ||||
| PropertyRNA *prop; | PropertyRNA *prop; | ||||
| StructRNA *ptype; | StructRNA *ptype; | ||||
| PyObject *type = Py_None; | PyObject *type = Py_None; | ||||
| PyObject *pyopts = NULL; | PyObject *pyopts = NULL; | ||||
| PyObject *py_tags = NULL; | |||||
| int opts = 0; | int opts = 0; | ||||
| int prop_tags = 0; | |||||
| static const char *_keywords[] = { | static const char *_keywords[] = { | ||||
| "attr", "type", "name", "description", "options", NULL, | "attr", "type", "name", "description", | ||||
| "options", "tags", NULL, | |||||
| }; | }; | ||||
| static _PyArg_Parser _parser = {"s#O|ssO!:CollectionProperty", _keywords, 0}; | static _PyArg_Parser _parser = {"s#O|ssO!O:CollectionProperty", _keywords, 0}; | ||||
| if (!_PyArg_ParseTupleAndKeywordsFast( | if (!_PyArg_ParseTupleAndKeywordsFast( | ||||
| args, kw, &_parser, | args, kw, &_parser, | ||||
| &id, &id_len, | &id, &id_len, | ||||
| &type, &name, &description, | &type, &name, &description, | ||||
| &PySet_Type, &pyopts)) | &PySet_Type, &pyopts, &py_tags)) | ||||
| { | { | ||||
| return NULL; | return NULL; | ||||
| } | } | ||||
| BPY_PROPDEF_CHECK(CollectionProperty, property_flag_items); | BPY_PROPDEF_CHECK(CollectionProperty, property_flag_items); | ||||
| ptype = pointer_type_from_py(type, "CollectionProperty(...):"); | ptype = pointer_type_from_py(type, "CollectionProperty(...):"); | ||||
| if (!ptype) | if (!ptype) | ||||
| return NULL; | return NULL; | ||||
| if (!RNA_struct_is_a(ptype, &RNA_PropertyGroup)) { | if (!RNA_struct_is_a(ptype, &RNA_PropertyGroup)) { | ||||
| PyErr_Format(PyExc_TypeError, | PyErr_Format(PyExc_TypeError, | ||||
| "CollectionProperty(...) expected an RNA type derived from %.200s", | "CollectionProperty(...) expected an RNA type derived from %.200s", | ||||
| RNA_struct_ui_name(&RNA_ID), RNA_struct_ui_name(&RNA_PropertyGroup)); | RNA_struct_ui_name(&RNA_ID), RNA_struct_ui_name(&RNA_PropertyGroup)); | ||||
| return NULL; | return NULL; | ||||
| } | } | ||||
| prop = RNA_def_collection_runtime(srna, id, ptype, name ? name : id, description); | prop = RNA_def_collection_runtime(srna, id, ptype, name ? name : id, description); | ||||
| if (py_tags) { | |||||
| RNA_def_property_tags(prop, prop_tags); | |||||
| } | |||||
| if (pyopts) { | if (pyopts) { | ||||
| bpy_prop_assign_flag(prop, opts); | bpy_prop_assign_flag(prop, opts); | ||||
| } | } | ||||
| if (RNA_struct_idprops_contains_datablock(ptype)) { | if (RNA_struct_idprops_contains_datablock(ptype)) { | ||||
| if (RNA_struct_is_a(srna, &RNA_PropertyGroup)) { | if (RNA_struct_is_a(srna, &RNA_PropertyGroup)) { | ||||
| RNA_def_struct_flag(srna, STRUCT_CONTAINS_DATABLOCK_IDPROPERTIES); | RNA_def_struct_flag(srna, STRUCT_CONTAINS_DATABLOCK_IDPROPERTIES); | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 126 Lines • Show Last 20 Lines | |||||
*picky*, better assign a variable for RNA_struct_property_tag_define result in a nested scope.