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>2009-09-04 02:37:09 +0400
committerCampbell Barton <ideasman42@gmail.com>2009-09-04 02:37:09 +0400
commit02f951c3a05f6586f12d129c70adffd8315ec3b7 (patch)
treefea0ba96dffe2ee86a781046c57c52863532f73f /source/blender/python/intern/bpy_operator.c
parentfc975a91484a1346049071fa9c6c8877820245cd (diff)
allow execution mode to be given as an argument to operators from python (requested by algorith)
example. bpy.ops.tfm.rotate('INVOKE_REGION_WIN', pivot=(0,1,2), ......) bpy_array.c - was too strict with types, 0 should be allowed as well as 0.0 in a float array.
Diffstat (limited to 'source/blender/python/intern/bpy_operator.c')
-rw-r--r--source/blender/python/intern/bpy_operator.c35
1 files changed, 8 insertions, 27 deletions
diff --git a/source/blender/python/intern/bpy_operator.c b/source/blender/python/intern/bpy_operator.c
index e431f2a21e9..062db42e0e9 100644
--- a/source/blender/python/intern/bpy_operator.c
+++ b/source/blender/python/intern/bpy_operator.c
@@ -40,42 +40,23 @@
#include "BKE_utildefines.h"
-/* 'self' stores the operator string */
static PyObject *pyop_call( PyObject * self, PyObject * args)
{
wmOperatorType *ot;
int error_val = 0;
PointerRNA ptr;
- char *opname;
- PyObject *kw= NULL;
+ char *opname;
+ PyObject *kw= NULL; /* optional args */
+
+ /* note that context is an int, python does the conversion in this case */
+ int context= WM_OP_EXEC_DEFAULT;
// XXX Todo, work out a better solution for passing on context, could make a tuple from self and pack the name and Context into it...
bContext *C = BPy_GetContext();
-
- switch(PyTuple_Size(args)) {
- case 2:
- kw = PyTuple_GET_ITEM(args, 1);
-
- if(!PyDict_Check(kw)) {
- PyErr_SetString( PyExc_AttributeError, "bpy.__ops__.call: expected second arg to be a dict");
- return NULL;
- }
- /* pass through */
- case 1:
- opname = _PyUnicode_AsString(PyTuple_GET_ITEM(args, 0));
-
- if(opname==NULL) {
- PyErr_SetString( PyExc_AttributeError, "bpy.__ops__.call: expected the first arg to be a string");
- return NULL;
- }
- break;
- default:
- PyErr_SetString( PyExc_AttributeError, "bpy.__ops__.call: expected a string and optional dict");
+ if (!PyArg_ParseTuple(args, "s|O!i:bpy.__ops__.call", &opname, &PyDict_Type, &kw, &context))
return NULL;
- }
-
ot= WM_operatortype_find(opname, TRUE);
@@ -88,7 +69,7 @@ static PyObject *pyop_call( PyObject * self, PyObject * args)
PyErr_SetString( PyExc_SystemError, "bpy.__ops__.call: operator poll() function failed, context is incorrect");
return NULL;
}
-
+
/* WM_operator_properties_create(&ptr, opname); */
/* Save another lookup */
RNA_pointer_create(NULL, ot->srna, NULL, &ptr);
@@ -102,7 +83,7 @@ static PyObject *pyop_call( PyObject * self, PyObject * args)
BKE_reports_init(&reports, RPT_STORE);
- WM_operator_call_py(C, ot, &ptr, &reports);
+ WM_operator_call_py(C, ot, context, &ptr, &reports);
if(BPy_reports_to_error(&reports))
error_val = -1;