[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [26026] trunk/blender/source/blender/ python/intern/bpy_operator_wrap.c: remove duplicate code from operator/ macro initialization
Campbell Barton
ideasman42 at gmail.com
Fri Jan 15 23:02:33 CET 2010
Revision: 26026
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=26026
Author: campbellbarton
Date: 2010-01-15 23:02:32 +0100 (Fri, 15 Jan 2010)
Log Message:
-----------
remove duplicate code from operator/macro initialization
Modified Paths:
--------------
trunk/blender/source/blender/python/intern/bpy_operator_wrap.c
Modified: trunk/blender/source/blender/python/intern/bpy_operator_wrap.c
===================================================================
--- trunk/blender/source/blender/python/intern/bpy_operator_wrap.c 2010-01-15 17:36:06 UTC (rev 26025)
+++ trunk/blender/source/blender/python/intern/bpy_operator_wrap.c 2010-01-15 22:02:32 UTC (rev 26026)
@@ -23,25 +23,39 @@
* ***** END GPL LICENSE BLOCK *****
*/
-
#include "bpy_operator_wrap.h"
-#include "BLI_listbase.h"
#include "BKE_context.h"
-#include "BKE_report.h"
-#include "DNA_windowmanager_types.h"
-#include "MEM_guardedalloc.h"
#include "WM_api.h"
#include "WM_types.h"
-#include "UI_interface.h"
-#include "ED_screen.h"
#include "RNA_define.h"
#include "bpy_rna.h"
#include "bpy_util.h"
-#include "../generic/bpy_internal_import.h" // our own imports
+static void operator_properties_init(wmOperatorType *ot)
+{
+ PyObject *py_class = ot->ext.data;
+ PyObject *item= ((PyTypeObject*)py_class)->tp_dict; /* getattr(..., "__dict__") returns a proxy */
+ RNA_struct_blender_type_set(ot->ext.srna, ot);
+
+ if(item) {
+ /* only call this so pyrna_deferred_register_props gives a useful error
+ * WM_operatortype_append_ptr will call RNA_def_struct_identifier
+ * later */
+ RNA_def_struct_identifier(ot->srna, ot->idname);
+
+ if(pyrna_deferred_register_props(ot->srna, item) != 0) {
+ PyErr_Print(); /* failed to register operator props */
+ PyErr_Clear();
+ }
+ }
+ else {
+ PyErr_Clear();
+ }
+}
+
void operator_wrapper(wmOperatorType *ot, void *userdata)
{
/* take care not to overwrite anything set in
@@ -50,33 +64,7 @@
*ot= *((wmOperatorType *)userdata);
ot->srna= srna; /* restore */
- RNA_struct_blender_type_set(ot->ext.srna, ot);
-
-
- /* Can't use this because it returns a dict proxy
- *
- * item= PyObject_GetAttrString(py_class, "__dict__");
- */
- {
- PyObject *py_class = ot->ext.data;
- PyObject *item= ((PyTypeObject*)py_class)->tp_dict;
- if(item) {
- /* only call this so pyrna_deferred_register_props gives a useful error
- * WM_operatortype_append_ptr will call RNA_def_struct_identifier
- * later */
- RNA_def_struct_identifier(ot->srna, ot->idname);
-
- if(pyrna_deferred_register_props(ot->srna, item)!=0) {
- /* failed to register operator props */
- PyErr_Print();
- PyErr_Clear();
-
- }
- }
- else {
- PyErr_Clear();
- }
- }
+ operator_properties_init(ot);
}
void macro_wrapper(wmOperatorType *ot, void *userdata)
@@ -92,33 +80,7 @@
ot->ui = data->ui;
ot->ext = data->ext;
- RNA_struct_blender_type_set(ot->ext.srna, ot);
-
-
- /* Can't use this because it returns a dict proxy
- *
- * item= PyObject_GetAttrString(py_class, "__dict__");
- */
- {
- PyObject *py_class = ot->ext.data;
- PyObject *item= ((PyTypeObject*)py_class)->tp_dict;
- if(item) {
- /* only call this so pyrna_deferred_register_props gives a useful error
- * WM_operatortype_append_ptr will call RNA_def_struct_identifier
- * later */
- RNA_def_struct_identifier(ot->srna, ot->idname);
-
- if(pyrna_deferred_register_props(ot->srna, item)!=0) {
- /* failed to register operator props */
- PyErr_Print();
- PyErr_Clear();
-
- }
- }
- else {
- PyErr_Clear();
- }
- }
+ operator_properties_init(ot);
}
PyObject *PYOP_wrap_macro_define(PyObject *self, PyObject *args)
More information about the Bf-blender-cvs
mailing list