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>2009-11-17 01:21:39 +0300
committerCampbell Barton <ideasman42@gmail.com>2009-11-17 01:21:39 +0300
commit3087da0b25bd6bd6b3d3e1d0de2eb765feb0cfe6 (patch)
treed65a4d56e79b5cda6214771d8644067c8abc7c05 /source/blender/python/generic/IDProp.c
parent98d4a56d5517be497c4628ad8bf67082d21767f2 (diff)
my chnges broke 'del idprop["key"]'
made it possible to remove properties from rna types. eg. del group["someprop"]
Diffstat (limited to 'source/blender/python/generic/IDProp.c')
-rw-r--r--source/blender/python/generic/IDProp.c40
1 files changed, 23 insertions, 17 deletions
diff --git a/source/blender/python/generic/IDProp.c b/source/blender/python/generic/IDProp.c
index ccb68149931..68d3e3879e5 100644
--- a/source/blender/python/generic/IDProp.c
+++ b/source/blender/python/generic/IDProp.c
@@ -307,24 +307,17 @@ char *BPy_IDProperty_Map_ValidateAndCreate(char *name, IDProperty *group, PyObje
return NULL;
}
-static int BPy_IDGroup_Map_SetItem(BPy_IDProperty *self, PyObject *key, PyObject *val)
+int BPy_Wrap_SetMapItem(IDProperty *prop, PyObject *key, PyObject *val)
{
- char *err;
-
- if (self->prop->type != IDP_GROUP) {
+ if (prop->type != IDP_GROUP) {
PyErr_SetString( PyExc_TypeError, "unsubscriptable object");
return -1;
}
- if (!PyUnicode_Check(key)) {
- PyErr_SetString( PyExc_TypeError, "only strings are allowed as subgroup keys" );
- return -1;
- }
-
- if (val == NULL) {
- IDProperty *pkey = IDP_GetPropertyFromGroup(self->prop, _PyUnicode_AsString(key));
+ if (val == NULL) { /* del idprop[key] */
+ IDProperty *pkey = IDP_GetPropertyFromGroup(prop, _PyUnicode_AsString(key));
if (pkey) {
- IDP_RemFromGroup(self->prop, pkey);
+ IDP_RemFromGroup(prop, pkey);
IDP_FreeProperty(pkey);
MEM_freeN(pkey);
return 0;
@@ -333,14 +326,27 @@ static int BPy_IDGroup_Map_SetItem(BPy_IDProperty *self, PyObject *key, PyObject
return -1;
}
}
+ else {
+ char *err;
- err = BPy_IDProperty_Map_ValidateAndCreate(_PyUnicode_AsString(key), self->prop, val);
- if (err) {
- PyErr_SetString( PyExc_RuntimeError, err );
- return -1;
+ if (!PyUnicode_Check(key)) {
+ PyErr_SetString( PyExc_TypeError, "only strings are allowed as subgroup keys" );
+ return -1;
+ }
+
+ err = BPy_IDProperty_Map_ValidateAndCreate(_PyUnicode_AsString(key), prop, val);
+ if (err) {
+ PyErr_SetString( PyExc_RuntimeError, err );
+ return -1;
+ }
+
+ return 0;
}
+}
- return 0;
+static int BPy_IDGroup_Map_SetItem(BPy_IDProperty *self, PyObject *key, PyObject *val)
+{
+ BPy_Wrap_SetMapItem(self->prop, key, val);
}
static PyObject *BPy_IDGroup_SpawnIterator(BPy_IDProperty *self)