diff options
author | Campbell Barton <ideasman42@gmail.com> | 2009-10-29 13:03:34 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2009-10-29 13:03:34 +0300 |
commit | e14a8635cca97f339d28744624cf1284866bc63d (patch) | |
tree | e57bc7d6ea858bb921dd5876730df2ecab9fece2 /source/blender/python/intern/bpy_interface.c | |
parent | c508e6198a614619bb9d82cd59c0fdb7f55f427d (diff) |
Modified python rna property types (BPy_PropertyRNA), so PySequence_Check() returns true
this means you can do...
C = {"selected_editable_objects":bpy.data.objects}
...when defining pythons context, without doing list(bpy.data.objects)
Diffstat (limited to 'source/blender/python/intern/bpy_interface.c')
-rw-r--r-- | source/blender/python/intern/bpy_interface.c | 46 |
1 files changed, 27 insertions, 19 deletions
diff --git a/source/blender/python/intern/bpy_interface.c b/source/blender/python/intern/bpy_interface.c index dc7f6947f38..d0c70a9ee96 100644 --- a/source/blender/python/intern/bpy_interface.c +++ b/source/blender/python/intern/bpy_interface.c @@ -971,28 +971,36 @@ int bpy_context_get(bContext *C, const char *member, bContextDataResult *result) CTX_data_pointer_set(result, ptr->id.data, ptr->type, ptr->data); done= 1; } - else if (PyList_Check(item)) { - int len= PyList_Size(item); - int i; - for(i = 0; i < len; i++) { - PyObject *list_item = PyList_GET_ITEM(item, i); // XXX check type - - if(BPy_StructRNA_Check(list_item)) { - /* - CollectionPointerLink *link= MEM_callocN(sizeof(CollectionPointerLink), "bpy_context_get"); - link->ptr= ((BPy_StructRNA *)item)->ptr; - BLI_addtail(&result->list, link); - */ - ptr= &(((BPy_StructRNA *)list_item)->ptr); - CTX_data_list_add(result, ptr->id.data, ptr->type, ptr->data); - } - else { - printf("List item not a valid type\n"); + else if (PySequence_Check(item)) { + PyObject *seq_fast= PySequence_Fast(item, "bpy_context_get sequence conversion"); + if (seq_fast==NULL) { + PyErr_Print(); + PyErr_Clear(); + } + else { + int len= PySequence_Fast_GET_SIZE(seq_fast); + int i; + for(i = 0; i < len; i++) { + PyObject *list_item= PySequence_Fast_GET_ITEM(seq_fast, i); + + if(BPy_StructRNA_Check(list_item)) { + /* + CollectionPointerLink *link= MEM_callocN(sizeof(CollectionPointerLink), "bpy_context_get"); + link->ptr= ((BPy_StructRNA *)item)->ptr; + BLI_addtail(&result->list, link); + */ + ptr= &(((BPy_StructRNA *)list_item)->ptr); + CTX_data_list_add(result, ptr->id.data, ptr->type, ptr->data); + } + else { + printf("List item not a valid type\n"); + } + } + Py_DECREF(seq_fast); + done= 1; } - - done= 1; } if(done==0) { |