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-06-20 17:53:14 +0400
committerCampbell Barton <ideasman42@gmail.com>2009-06-20 17:53:14 +0400
commita68ebbbccdf6bc1854c7a947685254ca912de7bf (patch)
tree93c2a524c3923d79b734e3ef68849a417487e7f8 /source/blender/python
parent3511d72488501640fb9b38daff7cfed35e5beed2 (diff)
RNA Fixes
* Python apis iterator didnt work, for example [f for f in mesh.faces] # failed. * Python apis collection.items(), collections without names now return (index,value) pairs, better then returning nothing. * bpy.ui and bpy.props modules were incorrectly named * Mesh vertex colors red/blue needed to be swapped on getting/setting. * Mesh vertex colors were not clamped.
Diffstat (limited to 'source/blender/python')
-rw-r--r--source/blender/python/intern/bpy_rna.c35
-rw-r--r--source/blender/python/intern/bpy_ui.c2
2 files changed, 22 insertions, 15 deletions
diff --git a/source/blender/python/intern/bpy_rna.c b/source/blender/python/intern/bpy_rna.c
index 5727bb97483..e4c17e080b7 100644
--- a/source/blender/python/intern/bpy_rna.c
+++ b/source/blender/python/intern/bpy_rna.c
@@ -1011,22 +1011,30 @@ PyObject *pyrna_prop_items(BPy_PropertyRNA *self)
CollectionPropertyIterator iter;
PropertyRNA *nameprop;
char name[256], *nameptr;
+ int i= 0;
ret = PyList_New(0);
RNA_property_collection_begin(&self->ptr, self->prop, &iter);
for(; iter.valid; RNA_property_collection_next(&iter)) {
- if(iter.ptr.data && (nameprop = RNA_struct_name_property(iter.ptr.type))) {
- nameptr= RNA_property_string_get_alloc(&iter.ptr, nameprop, name, sizeof(name));
-
+ if(iter.ptr.data) {
/* add to python list */
- item = Py_BuildValue("(NN)", PyUnicode_FromString( nameptr ), pyrna_struct_CreatePyObject(&iter.ptr));
+ item= PyTuple_New(2);
+ if(nameprop = RNA_struct_name_property(iter.ptr.type)) {
+ nameptr= RNA_property_string_get_alloc(&iter.ptr, nameprop, name, sizeof(name));
+ PyTuple_SET_ITEM(item, 0, PyUnicode_FromString( nameptr ));
+ if ((char *)&name != nameptr)
+ MEM_freeN(nameptr);
+ }
+ else {
+ PyTuple_SET_ITEM(item, 0, PyLong_FromSsize_t(i)); /* a bit strange but better then returning an empty list */
+ }
+ PyTuple_SET_ITEM(item, 1, pyrna_struct_CreatePyObject(&iter.ptr));
+
PyList_Append(ret, item);
Py_DECREF(item);
- /* done */
- if ((char *)&name != nameptr)
- MEM_freeN(nameptr);
+ i++;
}
}
RNA_property_collection_end(&iter);
@@ -1039,23 +1047,22 @@ PyObject *pyrna_prop_items(BPy_PropertyRNA *self)
PyObject *pyrna_prop_values(BPy_PropertyRNA *self)
{
PyObject *ret;
+
if (RNA_property_type(self->prop) != PROP_COLLECTION) {
PyErr_SetString( PyExc_TypeError, "values() is only valid for collection types" );
ret = NULL;
} else {
PyObject *item;
CollectionPropertyIterator iter;
- PropertyRNA *nameprop;
-
+ PropertyRNA *iterprop;
ret = PyList_New(0);
+ //iterprop= RNA_struct_iterator_property(self->ptr.type);
RNA_property_collection_begin(&self->ptr, self->prop, &iter);
for(; iter.valid; RNA_property_collection_next(&iter)) {
- if(iter.ptr.data && (nameprop = RNA_struct_name_property(iter.ptr.type))) {
- item = pyrna_struct_CreatePyObject(&iter.ptr);
- PyList_Append(ret, item);
- Py_DECREF(item);
- }
+ item = pyrna_struct_CreatePyObject(&iter.ptr);
+ PyList_Append(ret, item);
+ Py_DECREF(item);
}
RNA_property_collection_end(&iter);
}
diff --git a/source/blender/python/intern/bpy_ui.c b/source/blender/python/intern/bpy_ui.c
index c15315ca350..088fe436c69 100644
--- a/source/blender/python/intern/bpy_ui.c
+++ b/source/blender/python/intern/bpy_ui.c
@@ -373,7 +373,7 @@ static struct PyMethodDef ui_methods[] = {
#if PY_VERSION_HEX >= 0x03000000
static struct PyModuleDef ui_module = {
PyModuleDef_HEAD_INIT,
- "bpyui",
+ "bpy.ui",
"",
-1,/* multiple "initialization" just copies the module dict. */
ui_methods,