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
path: root/source
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2009-07-22 23:50:21 +0400
committerCampbell Barton <ideasman42@gmail.com>2009-07-22 23:50:21 +0400
commit413fa4730b7d087fef9f92179c107f58e2286a49 (patch)
tree448d9f191c461161ceb506832ca9ce546ba18879 /source
parent3ecb88fc7671ff671b8de2b56bab61986df51304 (diff)
less verbose subtyping Py/C API code, use PyObject_CallFunction which supports packing the function args into a string.
Diffstat (limited to 'source')
-rw-r--r--source/blender/python/intern/bpy_rna.c54
1 files changed, 10 insertions, 44 deletions
diff --git a/source/blender/python/intern/bpy_rna.c b/source/blender/python/intern/bpy_rna.c
index 7319a269ffb..be98a985ac2 100644
--- a/source/blender/python/intern/bpy_rna.c
+++ b/source/blender/python/intern/bpy_rna.c
@@ -2300,31 +2300,23 @@ PyObject* pyrna_srna_Subtype(StructRNA *srna)
} else if ((newclass= RNA_struct_py_type_get(srna))) {
Py_INCREF(newclass);
} else {
- StructRNA *base;
-
- /* for now, return the base RNA type rather then a real module */
-
- /* Assume RNA_struct_py_type_get(srna) was alredy checked */
-
/* subclass equivelents
- class myClass(myBase):
some='value' # or ...
- myClass = type(name='myClass', bases=(myBase,), dict={'__module__':'bpy.types'})
*/
- const char *descr= RNA_struct_ui_description(srna);
- PyObject *args = PyTuple_New(3);
- PyObject *bases = PyTuple_New(1);
+ /* Assume RNA_struct_py_type_get(srna) was alredy checked */
+ StructRNA *base;
+
PyObject *py_base= NULL;
- PyObject *dict = PyDict_New();
- PyObject *item;
-
-
- // arg 1
- //PyTuple_SET_ITEM(args, 0, PyUnicode_FromString(tp_name));
- PyTuple_SET_ITEM(args, 0, PyUnicode_FromString(RNA_struct_identifier(srna)));
+
+ const char *idname= RNA_struct_identifier(srna);
+ const char *descr= RNA_struct_ui_description(srna);
+
+ if(!descr) descr= "(no docs)";
- // arg 2
+ /* get the base type */
base= RNA_struct_base(srna);
if(base && base != srna) {
/*/printf("debug subtype %s %p\n", RNA_struct_identifier(srna), srna); */
@@ -2336,33 +2328,7 @@ PyObject* pyrna_srna_Subtype(StructRNA *srna)
Py_INCREF(py_base);
}
- PyTuple_SET_ITEM(bases, 0, py_base);
-
- PyTuple_SET_ITEM(args, 1, bases);
-
- // arg 3 - add an instance of the rna
- if(descr) {
- item= PyUnicode_FromString(descr);
- PyDict_SetItemString(dict, "__doc__", item);
- Py_DECREF(item);
- }
-
- /* this isnt needed however its confusing if we get python script names in blender types,
- * because the __module__ is used when printing the class */
- item= PyUnicode_FromString("bpy.types"); /* just to know its an internal type */
- PyDict_SetItemString(dict, "__module__", item);
- Py_DECREF(item);
-
-
- PyTuple_SET_ITEM(args, 2, dict); // fill with useful subclass things!
-
- if (PyErr_Occurred()) {
- PyErr_Print();
- PyErr_Clear();
- }
-
- newclass = PyObject_CallObject((PyObject *)&PyType_Type, args);
- Py_DECREF(args);
+ newclass = PyObject_CallFunction( (PyObject*)&PyType_Type, "s(N){ssss}", idname, py_base, "__module__","bpy.types", "__doc__",descr);
if (newclass) {
pyrna_subtype_set_rna(newclass, srna);