Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2010-05-09 04:06:35 +0400
committerCampbell Barton <ideasman42@gmail.com>2010-05-09 04:06:35 +0400
commitd73af20b7acd50d9aaddcbce180fda1fb80df483 (patch)
treee2d7963c96629cff105c78f820235a590aa402cd /source/blender
parent5548e86795bc1b7f97112c418e611023765c5af6 (diff)
py/rna: defining new properties now replaces the old onces and raises an error if they collide with dynamic props.
Diffstat (limited to 'source/blender')
-rw-r--r--source/blender/makesrna/intern/rna_define.c2
-rw-r--r--source/blender/python/intern/bpy_props.c72
2 files changed, 32 insertions, 42 deletions
diff --git a/source/blender/makesrna/intern/rna_define.c b/source/blender/makesrna/intern/rna_define.c
index 01684482954..fbcc3109af4 100644
--- a/source/blender/makesrna/intern/rna_define.c
+++ b/source/blender/makesrna/intern/rna_define.c
@@ -2750,7 +2750,7 @@ int RNA_def_property_free_identifier(StructOrFunctionRNA *cont_, const char *ide
return 1;
}
else {
- return 0;
+ return -1;
}
}
}
diff --git a/source/blender/python/intern/bpy_props.c b/source/blender/python/intern/bpy_props.c
index 37fd83e3b9b..223b23a3dbd 100644
--- a/source/blender/python/intern/bpy_props.c
+++ b/source/blender/python/intern/bpy_props.c
@@ -132,10 +132,9 @@ PyObject *BPy_BoolProperty(PyObject *self, PyObject *args, PyObject *kw)
if (!PyArg_ParseTupleAndKeywords(args, kw, "s|ssiO!s:BoolProperty", (char **)kwlist, &id, &name, &description, &def, &PySet_Type, &pyopts, &pysubtype))
return NULL;
- if(bpy_struct_id_used(srna, id)) {
- // PyErr_Format(PyExc_TypeError, "BoolProperty(): '%s' already defined.", id);
- // return NULL;
- Py_RETURN_NONE;
+ if(RNA_def_property_free_identifier(srna, id) == -1) {
+ PyErr_Format(PyExc_TypeError, "BoolProperty(): '%s' is defined as a non-dynamic type.", id);
+ return NULL;
}
if(pyopts && pyrna_set_to_enum_bitfield(property_flag_items, pyopts, &opts, "BoolProperty(options={...}):"))
@@ -200,10 +199,9 @@ PyObject *BPy_BoolVectorProperty(PyObject *self, PyObject *args, PyObject *kw)
if (!PyArg_ParseTupleAndKeywords(args, kw, "s|ssOO!si:BoolVectorProperty", (char **)kwlist, &id, &name, &description, &pydef, &PySet_Type, &pyopts, &pysubtype, &size))
return NULL;
- if(bpy_struct_id_used(srna, id)) {
- // PyErr_Format(PyExc_TypeError, "BoolVectorProperty(): '%s' already defined.", id);
- // return NULL;
- Py_RETURN_NONE;
+ if(RNA_def_property_free_identifier(srna, id) == -1) {
+ PyErr_Format(PyExc_TypeError, "BoolVectorProperty(): '%s' is defined as a non-dynamic type.", id);
+ return NULL;
}
if(pyopts && pyrna_set_to_enum_bitfield(property_flag_items, pyopts, &opts, "BoolVectorProperty(options={...}):"))
@@ -275,10 +273,9 @@ PyObject *BPy_IntProperty(PyObject *self, PyObject *args, PyObject *kw)
if (!PyArg_ParseTupleAndKeywords(args, kw, "s|ssiiiiiiO!s:IntProperty", (char **)kwlist, &id, &name, &description, &def, &min, &max, &soft_min, &soft_max, &step, &PySet_Type, &pyopts, &pysubtype))
return NULL;
- if(bpy_struct_id_used(srna, id)) {
- // PyErr_Format(PyExc_TypeError, "IntProperty(): '%s' already defined.", id);
- // return NULL;
- Py_RETURN_NONE;
+ if(RNA_def_property_free_identifier(srna, id) == -1) {
+ PyErr_Format(PyExc_TypeError, "IntProperty(): '%s' is defined as a non-dynamic type.", id);
+ return NULL;
}
if(pyopts && pyrna_set_to_enum_bitfield(property_flag_items, pyopts, &opts, "IntProperty(options={...}):"))
@@ -344,10 +341,9 @@ PyObject *BPy_IntVectorProperty(PyObject *self, PyObject *args, PyObject *kw)
if (!PyArg_ParseTupleAndKeywords(args, kw, "s|ssOiiiiO!si:IntVectorProperty", (char **)kwlist, &id, &name, &description, &pydef, &min, &max, &soft_min, &soft_max, &PySet_Type, &pyopts, &pysubtype, &size))
return NULL;
- if(bpy_struct_id_used(srna, id)) {
- // PyErr_Format(PyExc_TypeError, "IntVectorProperty(): '%s' already defined.", id);
- // return NULL;
- Py_RETURN_NONE;
+ if(RNA_def_property_free_identifier(srna, id) == -1) {
+ PyErr_Format(PyExc_TypeError, "IntVectorProperty(): '%s' is defined as a non-dynamic type.", id);
+ return NULL;
}
if(pyopts && pyrna_set_to_enum_bitfield(property_flag_items, pyopts, &opts, "IntVectorProperty(options={...}):"))
@@ -426,10 +422,9 @@ PyObject *BPy_FloatProperty(PyObject *self, PyObject *args, PyObject *kw)
if (!PyArg_ParseTupleAndKeywords(args, kw, "s|ssffffffiO!ss:FloatProperty", (char **)kwlist, &id, &name, &description, &def, &min, &max, &soft_min, &soft_max, &step, &precision, &PySet_Type, &pyopts, &pysubtype, &pyunit))
return NULL;
- if(bpy_struct_id_used(srna, id)) {
- // PyErr_Format(PyExc_TypeError, "FloatProperty(): '%s' already defined.", id);
- // return NULL;
- Py_RETURN_NONE;
+ if(RNA_def_property_free_identifier(srna, id) == -1) {
+ PyErr_Format(PyExc_TypeError, "FloatProperty(): '%s' is defined as a non-dynamic type.", id);
+ return NULL;
}
if(pyopts && pyrna_set_to_enum_bitfield(property_flag_items, pyopts, &opts, "FloatProperty(options={...}):"))
@@ -500,10 +495,9 @@ PyObject *BPy_FloatVectorProperty(PyObject *self, PyObject *args, PyObject *kw)
if (!PyArg_ParseTupleAndKeywords(args, kw, "s|ssOfffffiO!si:FloatVectorProperty", (char **)kwlist, &id, &name, &description, &pydef, &min, &max, &soft_min, &soft_max, &step, &precision, &PySet_Type, &pyopts, &pysubtype, &size))
return NULL;
- if(bpy_struct_id_used(srna, id)) {
- // PyErr_Format(PyExc_TypeError, "FloatVectorProperty(): '%s' already defined.", id);
- // return NULL;
- Py_RETURN_NONE;
+ if(RNA_def_property_free_identifier(srna, id) == -1) {
+ PyErr_Format(PyExc_TypeError, "FloatVectorProperty(): '%s' is defined as a non-dynamic type.", id);
+ return NULL;
}
if(pyopts && pyrna_set_to_enum_bitfield(property_flag_items, pyopts, &opts, "FloatVectorProperty(options={...}):"))
@@ -576,10 +570,9 @@ PyObject *BPy_StringProperty(PyObject *self, PyObject *args, PyObject *kw)
if (!PyArg_ParseTupleAndKeywords(args, kw, "s|sssiO!s:StringProperty", (char **)kwlist, &id, &name, &description, &def, &maxlen, &PySet_Type, &pyopts, &pysubtype))
return NULL;
- if(bpy_struct_id_used(srna, id)) {
- // PyErr_Format(PyExc_TypeError, "StringProperty(): '%s' already defined.", id);
- // return NULL;
- Py_RETURN_NONE;
+ if(RNA_def_property_free_identifier(srna, id) == -1) {
+ PyErr_Format(PyExc_TypeError, "StringProperty(): '%s' is defined as a non-dynamic type.", id);
+ return NULL;
}
if(pyopts && pyrna_set_to_enum_bitfield(property_flag_items, pyopts, &opts, "StringProperty(options={...}):"))
@@ -688,10 +681,9 @@ PyObject *BPy_EnumProperty(PyObject *self, PyObject *args, PyObject *kw)
if (!PyArg_ParseTupleAndKeywords(args, kw, "sO|sssO!:EnumProperty", (char **)kwlist, &id, &items, &name, &description, &def, &PySet_Type, &pyopts))
return NULL;
- if(bpy_struct_id_used(srna, id)) {
- // PyErr_Format(PyExc_TypeError, "EnumProperty(): '%s' already defined.", id);
- // return NULL;
- Py_RETURN_NONE;
+ if(RNA_def_property_free_identifier(srna, id) == -1) {
+ PyErr_Format(PyExc_TypeError, "EnumProperty(): '%s' is defined as a non-dynamic type.", id);
+ return NULL;
}
if(pyopts && pyrna_set_to_enum_bitfield(property_flag_items, pyopts, &opts, "EnumProperty(options={...}):"))
@@ -772,10 +764,9 @@ PyObject *BPy_PointerProperty(PyObject *self, PyObject *args, PyObject *kw)
if (!PyArg_ParseTupleAndKeywords(args, kw, "sO|ssO!:PointerProperty", (char **)kwlist, &id, &type, &name, &description, &PySet_Type, &pyopts))
return NULL;
- if(bpy_struct_id_used(srna, id)) {
- // PyErr_Format(PyExc_TypeError, "PointerProperty(): '%s' already defined.", id);
- // return NULL;
- Py_RETURN_NONE;
+ if(RNA_def_property_free_identifier(srna, id) == -1) {
+ PyErr_Format(PyExc_TypeError, "PointerProperty(): '%s' is defined as a non-dynamic type.", id);
+ return NULL;
}
if(pyopts && pyrna_set_to_enum_bitfield(property_flag_items, pyopts, &opts, "PointerProperty(options={...}):"))
@@ -833,10 +824,9 @@ PyObject *BPy_CollectionProperty(PyObject *self, PyObject *args, PyObject *kw)
if (!PyArg_ParseTupleAndKeywords(args, kw, "sO|ssO!:CollectionProperty", (char **)kwlist, &id, &type, &name, &description, &PySet_Type, &pyopts))
return NULL;
- if(bpy_struct_id_used(srna, id)) {
- // PyErr_Format(PyExc_TypeError, "CollectionProperty(): '%s' already defined.", id);
- // return NULL;
- Py_RETURN_NONE;
+ if(RNA_def_property_free_identifier(srna, id) == -1) {
+ PyErr_Format(PyExc_TypeError, "CollectionProperty(): '%s' is defined as a non-dynamic type.", id);
+ return NULL;
}
if(pyopts && pyrna_set_to_enum_bitfield(property_flag_items, pyopts, &opts, "CollectionProperty(options={...}):"))
@@ -887,7 +877,7 @@ PyObject *BPy_RemoveProperty(PyObject *self, PyObject *args, PyObject *kw)
if (!PyArg_ParseTupleAndKeywords(args, kw, "s:RemoveProperty", (char **)kwlist, &id))
return NULL;
- if(RNA_def_property_free_identifier(srna, id) == 0) {
+ if(RNA_def_property_free_identifier(srna, id) != 1) {
PyErr_Format(PyExc_TypeError, "RemoveProperty(): '%s' not a defined dynamic property.", id);
return NULL;
}