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>2010-01-16 01:02:32 +0300
committerCampbell Barton <ideasman42@gmail.com>2010-01-16 01:02:32 +0300
commit2b3a6b38b764717878de39a97feeee186e3694ad (patch)
treefac013c9a2d036176b22966ba809471b8c3dcd15 /source/blender/python/intern/bpy_operator_wrap.c
parent6d1f5f8f5dcabd9071dc190b85ab5aa118eb03c9 (diff)
remove duplicate code from operator/macro initialization
Diffstat (limited to 'source/blender/python/intern/bpy_operator_wrap.c')
-rw-r--r--source/blender/python/intern/bpy_operator_wrap.c86
1 files changed, 24 insertions, 62 deletions
diff --git a/source/blender/python/intern/bpy_operator_wrap.c b/source/blender/python/intern/bpy_operator_wrap.c
index 11f36d5f8ec..0b855a9cacb 100644
--- a/source/blender/python/intern/bpy_operator_wrap.c
+++ b/source/blender/python/intern/bpy_operator_wrap.c
@@ -23,24 +23,38 @@
* ***** 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)
{
@@ -50,33 +64,7 @@ void operator_wrapper(wmOperatorType *ot, void *userdata)
*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 @@ void macro_wrapper(wmOperatorType *ot, void *userdata)
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)