Revision: 31846
          
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=31846
Author:   campbellbarton
Date:     2010-09-09 19:36:54 +0200 (Thu, 09 Sep 2010)

Log Message:
-----------
definition/syntax edits for operators and rna (no functional changes)

Modified Paths:
--------------
    trunk/blender/source/blender/python/intern/bpy_operator.c
    trunk/blender/source/blender/python/intern/bpy_rna.c

Modified: trunk/blender/source/blender/python/intern/bpy_operator.c
===================================================================
--- trunk/blender/source/blender/python/intern/bpy_operator.c   2010-09-09 
15:40:55 UTC (rev 31845)
+++ trunk/blender/source/blender/python/intern/bpy_operator.c   2010-09-09 
17:36:54 UTC (rev 31846)
@@ -289,24 +289,36 @@
        return (PyObject *)pyrna;
 }
 
-PyObject *BPY_operator_module( void )
+static struct PyMethodDef bpy_ops_methods[] = {
+       {"poll", (PyCFunction) pyop_poll, METH_VARARGS, NULL},
+       {"call", (PyCFunction) pyop_call, METH_VARARGS, NULL},
+       {"as_string", (PyCFunction) pyop_as_string, METH_VARARGS, NULL},
+       {"dir", (PyCFunction) pyop_dir, METH_NOARGS, NULL},
+       {"get_rna", (PyCFunction) pyop_getrna, METH_O, NULL},
+       {"macro_define", (PyCFunction) PYOP_wrap_macro_define, METH_VARARGS, 
NULL},
+       {NULL, NULL, 0, NULL}
+};
+
+static struct PyModuleDef bpy_ops_module = {
+       PyModuleDef_HEAD_INIT,
+       "_bpy.ops",
+       NULL,
+       -1,/* multiple "initialization" just copies the module dict. */
+       bpy_ops_methods,
+       NULL, NULL, NULL, NULL
+};
+
+PyObject *BPY_operator_module(void)
 {
-       static PyMethodDef pyop_poll_meth =             {"poll", (PyCFunction) 
pyop_poll, METH_VARARGS, NULL};
-       static PyMethodDef pyop_call_meth =             {"call", (PyCFunction) 
pyop_call, METH_VARARGS, NULL};
-       static PyMethodDef pyop_as_string_meth ={"as_string", (PyCFunction) 
pyop_as_string, METH_VARARGS, NULL};
-       static PyMethodDef pyop_dir_meth =              {"dir", (PyCFunction) 
pyop_dir, METH_NOARGS, NULL};
-       static PyMethodDef pyop_getrna_meth =   {"get_rna", (PyCFunction) 
pyop_getrna, METH_O, NULL};
-       static PyMethodDef pyop_macro_def_meth ={"macro_define", (PyCFunction) 
PYOP_wrap_macro_define, METH_VARARGS, NULL};
+       PyObject *submodule;
+       
+       submodule= PyModule_Create(&bpy_ops_module);
+       PyDict_SetItemString(PyImport_GetModuleDict(), bpy_ops_module.m_name, 
submodule);
 
-       PyObject *submodule = PyModule_New("_bpy.ops");
-       PyDict_SetItemString(PyImport_GetModuleDict(), "_bpy.ops", submodule);
+       /* INCREF since its its assumed that all these functions return the
+        * module with a new ref like PyDict_New, since they are passed to
+         * PyModule_AddObject which steals a ref */
+       Py_INCREF(submodule);
 
-       PyModule_AddObject( submodule, "poll",  
PyCFunction_New(&pyop_poll_meth, NULL) );
-       PyModule_AddObject( submodule, "call",  
PyCFunction_New(&pyop_call_meth, NULL) );
-       PyModule_AddObject( submodule, 
"as_string",PyCFunction_New(&pyop_as_string_meth, NULL) );
-       PyModule_AddObject( submodule, "dir",           
PyCFunction_New(&pyop_dir_meth, NULL) );
-       PyModule_AddObject( submodule, "get_rna",       
PyCFunction_New(&pyop_getrna_meth, NULL) );
-       PyModule_AddObject( submodule, 
"macro_define",PyCFunction_New(&pyop_macro_def_meth, NULL) );
-
        return submodule;
 }

Modified: trunk/blender/source/blender/python/intern/bpy_rna.c
===================================================================
--- trunk/blender/source/blender/python/intern/bpy_rna.c        2010-09-09 
15:40:55 UTC (rev 31845)
+++ trunk/blender/source/blender/python/intern/bpy_rna.c        2010-09-09 
17:36:54 UTC (rev 31846)
@@ -404,8 +404,7 @@
                return NULL;
        }
 
-       Py_INCREF(res);
-       return res;
+       return Py_INCREF(res), res;
 }
 
 static PyObject *pyrna_prop_richcmp(PyObject *a, PyObject *b, int op)
@@ -434,8 +433,7 @@
                return NULL;
        }
 
-       Py_INCREF(res);
-       return res;
+       return Py_INCREF(res), res;
 }
 
 /*----------------------repr--------------------------------------------*/
@@ -2761,7 +2759,6 @@
 
 static PyObject *pyrna_prop_collection_idprop_remove(BPy_PropertyRNA *self, 
PyObject *value)
 {
-       PyObject *ret;
        int key= PyLong_AsSsize_t(value);
 
        if (key==-1 && PyErr_Occurred()) {
@@ -2774,15 +2771,11 @@
                return NULL;
        }
 
-       ret = Py_None;
-       Py_INCREF(ret);
-
-       return ret;
+       Py_RETURN_NONE;
 }
 
 static PyObject *pyrna_prop_collection_idprop_move(BPy_PropertyRNA *self, 
PyObject *args)
 {
-       PyObject *ret;
        int key=0, pos=0;
 
        if (!PyArg_ParseTuple(args, "ii", &key, &pos)) {
@@ -2795,10 +2788,7 @@
                return NULL;
        }
 
-       ret = Py_None;
-       Py_INCREF(ret);
-
-       return ret;
+       Py_RETURN_NONE;
 }
 
 static PyObject *pyrna_struct_get_id_data(BPy_DummyPointerRNA *self)
@@ -2937,8 +2927,7 @@
                        return BPy_IDGroup_WrapData(self->ptr.id.data, idprop);
        }
 
-       Py_INCREF(def);
-       return def;
+       return Py_INCREF(def), def;
 }
 
 static char pyrna_struct_as_pointer_doc[] =
@@ -2968,9 +2957,8 @@
        
        if(RNA_property_collection_lookup_string(&self->ptr, self->prop, key, 
&newptr))
                return pyrna_struct_CreatePyObject(&newptr);
-       
-       Py_INCREF(def);
-       return def;
+
+       return Py_INCREF(def), def;
 }
 
 static void foreach_attr_type( BPy_PropertyRNA *self, char *attr,


_______________________________________________
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to