diff options
author | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2009-06-27 05:10:39 +0400 |
---|---|---|
committer | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2009-06-27 05:10:39 +0400 |
commit | d839a9ae9ccbf17375e28cc92aa75a0cb4cf6b11 (patch) | |
tree | 3ee663e436f751f799dcd3542788f10be4cb121d /source/blender/python | |
parent | 524b8614373df3e1eb212939f048a79b75450c28 (diff) |
RNA
* Added support for passing collections to/from RNA functions,
this is done using a ListBase of CollectionPointerLink, which
is a standard ListBase link + PointerRNA.
* Added editable active uv/vcol layer to Mesh.
* Armature.bones now includes all bones, not only the ones without
parents.
* Modifier UV layer fields now are allowed to be empty, previously
this would set the name during modifier evaluation if there was
none.
Diffstat (limited to 'source/blender/python')
-rw-r--r-- | source/blender/python/intern/bpy_rna.c | 34 |
1 files changed, 29 insertions, 5 deletions
diff --git a/source/blender/python/intern/bpy_rna.c b/source/blender/python/intern/bpy_rna.c index 0b8a7df1ae1..558722cc5e6 100644 --- a/source/blender/python/intern/bpy_rna.c +++ b/source/blender/python/intern/bpy_rna.c @@ -269,6 +269,8 @@ PyObject * pyrna_prop_to_py(PointerRNA *ptr, PropertyRNA *prop) ret= quat_cb; /* return the matrix instead */ } break; + default: + break; } } @@ -677,6 +679,10 @@ int pyrna_py_to_prop(PointerRNA *ptr, PropertyRNA *prop, void *data, PyObject *v int seq_len, i; PyObject *item; PointerRNA itemptr; + ListBase *lb; + CollectionPointerLink *link; + + lb= (data)? (ListBase*)data: NULL; /* convert a sequence of dict's into a collection */ if(!PySequence_Check(value)) { @@ -692,8 +698,15 @@ int pyrna_py_to_prop(PointerRNA *ptr, PropertyRNA *prop, void *data, PyObject *v Py_XDECREF(item); return -1; } - - RNA_property_collection_add(ptr, prop, &itemptr); + + if(lb) { + link= MEM_callocN(sizeof(CollectionPointerLink), "PyCollectionPointerLink"); + link->ptr= itemptr; + BLI_addtail(lb, link); + } + else + RNA_property_collection_add(ptr, prop, &itemptr); + if(pyrna_pydict_to_props(&itemptr, item, "Converting a python list to an RNA collection")==-1) { Py_DECREF(item); return -1; @@ -1380,10 +1393,21 @@ PyObject *pyrna_param_to_py(PointerRNA *ptr, PropertyRNA *prop, void *data) break; } case PROP_COLLECTION: - /* XXX not supported yet - * ret = pyrna_prop_CreatePyObject(ptr, prop); */ - ret = NULL; + { + ListBase *lb= (ListBase*)data; + CollectionPointerLink *link; + PyObject *linkptr; + + ret = PyList_New(0); + + for(link=lb->first; link; link=link->next) { + linkptr= pyrna_struct_CreatePyObject(&link->ptr); + PyList_Append(ret, linkptr); + Py_DECREF(linkptr); + } + break; + } default: PyErr_Format(PyExc_AttributeError, "RNA Error: unknown type \"%d\" (pyrna_param_to_py)", type); ret = NULL; |