[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [28679] trunk/blender/source/blender: py/ rna: defining new properties now replaces the old onces and raises an error if they collide with dynamic props .
Campbell Barton
ideasman42 at gmail.com
Sun May 9 02:06:35 CEST 2010
Revision: 28679
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=28679
Author: campbellbarton
Date: 2010-05-09 02:06:35 +0200 (Sun, 09 May 2010)
Log Message:
-----------
py/rna: defining new properties now replaces the old onces and raises an error if they collide with dynamic props.
Modified Paths:
--------------
trunk/blender/source/blender/makesrna/intern/rna_define.c
trunk/blender/source/blender/python/intern/bpy_props.c
Modified: trunk/blender/source/blender/makesrna/intern/rna_define.c
===================================================================
--- trunk/blender/source/blender/makesrna/intern/rna_define.c 2010-05-08 23:34:54 UTC (rev 28678)
+++ trunk/blender/source/blender/makesrna/intern/rna_define.c 2010-05-09 00:06:35 UTC (rev 28679)
@@ -2750,7 +2750,7 @@
return 1;
}
else {
- return 0;
+ return -1;
}
}
}
Modified: trunk/blender/source/blender/python/intern/bpy_props.c
===================================================================
--- trunk/blender/source/blender/python/intern/bpy_props.c 2010-05-08 23:34:54 UTC (rev 28678)
+++ trunk/blender/source/blender/python/intern/bpy_props.c 2010-05-09 00:06:35 UTC (rev 28679)
@@ -132,10 +132,9 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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;
}
More information about the Bf-blender-cvs
mailing list