[Bf-blender-cvs] [330a37f3897] master: Revert "PyAPI: expose OperatorType.modal_keymap"

Campbell Barton noreply at git.blender.org
Mon Sep 16 08:46:29 CEST 2019


Commit: 330a37f3897d051ac7a81f13ffb69cc78c617e54
Author: Campbell Barton
Date:   Mon Sep 16 16:42:22 2019 +1000
Branches: master
https://developer.blender.org/rB330a37f3897d051ac7a81f13ffb69cc78c617e54

Revert "PyAPI: expose OperatorType.modal_keymap"

This reverts commit b53ee963b16d817a6367bd7c73b866036868b2e2.

Full support for defining modal enums and access through events
is more involved, revert for now.

===================================================================

M	release/scripts/modules/bpy_types.py
M	source/blender/python/intern/bpy_operator.c

===================================================================

diff --git a/release/scripts/modules/bpy_types.py b/release/scripts/modules/bpy_types.py
index 6c5cd01ffc2..29470895079 100644
--- a/release/scripts/modules/bpy_types.py
+++ b/release/scripts/modules/bpy_types.py
@@ -555,16 +555,6 @@ class RNAMetaPropGroup(StructMetaPropGroup, RNAMeta):
     pass
 
 
-class RNAMetaOperator(RNAMeta):
-    @property
-    def modal_keymap(cls):
-        return _bpy.ops.modal_keymap_get(cls.bl_idname)
-
-    @modal_keymap.setter
-    def modal_keymap(cls, keymap):
-        _bpy.ops.modal_keymap_set(cls.bl_idname, keymap)
-
-
 # Same as 'Operator'
 # only without 'as_keywords'
 class Gizmo(StructRNA):
@@ -674,7 +664,7 @@ class GizmoGroup(StructRNA):
 
 # Only defined so operators members can be used by accessing self.order
 # with doc generation 'self.properties.bl_rna.properties' can fail
-class Operator(StructRNA, metaclass=RNAMetaOperator):
+class Operator(StructRNA, metaclass=RNAMeta):
     __slots__ = ()
 
     def __getattribute__(self, attr):
diff --git a/source/blender/python/intern/bpy_operator.c b/source/blender/python/intern/bpy_operator.c
index e04630ca356..5e3b000c604 100644
--- a/source/blender/python/intern/bpy_operator.c
+++ b/source/blender/python/intern/bpy_operator.c
@@ -50,10 +50,8 @@
 
 #include "BLI_ghash.h"
 
-#include "BKE_context.h"
-#include "BKE_global.h"
-#include "BKE_main.h"
 #include "BKE_report.h"
+#include "BKE_context.h"
 
 /* so operators called can spawn threads which acquire the GIL */
 #define BPY_RELEASE_GIL
@@ -431,51 +429,6 @@ static PyObject *pyop_getrna_type(PyObject *UNUSED(self), PyObject *value)
   return (PyObject *)pyrna;
 }
 
-static PyObject *pyop_type_modal_keymap_get(PyObject *UNUSED(self), PyObject *value)
-{
-  wmOperatorType *ot;
-  if (!(ot = ot_lookup_from_py_string(value, "modal_keymap_get"))) {
-    return NULL;
-  }
-  if (ot->modalkeymap == NULL) {
-    Py_RETURN_NONE;
-  }
-  else {
-    PointerRNA ptr;
-    RNA_pointer_create(G.main->wm.first, &RNA_KeyMap, ot->modalkeymap, &ptr);
-    return pyrna_struct_CreatePyObject(&ptr);
-  }
-}
-
-static PyObject *pyop_type_modal_keymap_set(PyObject *UNUSED(self), PyObject *args)
-{
-  PyObject *ot_idname, *py_keymap;
-  wmOperatorType *ot;
-  if (!PyArg_ParseTuple(args, "OO", &ot_idname, &py_keymap) ||
-      !(ot = ot_lookup_from_py_string(ot_idname, "modal_keymap_set"))) {
-    return NULL;
-  }
-
-  if (py_keymap == Py_None) {
-    ot->modalkeymap = NULL;
-  }
-  else if (BPy_StructRNA_Check(py_keymap) &&
-           RNA_struct_is_a(((BPy_StructRNA *)py_keymap)->ptr.type, &RNA_KeyMap)) {
-    BPy_StructRNA *py_keymap_rna = (BPy_StructRNA *)py_keymap;
-    wmKeyMap *km = py_keymap_rna->ptr.data;
-    if ((km->flag & KEYMAP_MODAL) == 0) {
-      PyErr_SetString(PyExc_ValueError, "Expected a keymap a modal keymap");
-      return NULL;
-    }
-    ot->modalkeymap = km;
-  }
-  else {
-    PyErr_SetString(PyExc_TypeError, "Expected a keymap object or None");
-    return NULL;
-  }
-  Py_RETURN_NONE;
-}
-
 static struct PyMethodDef bpy_ops_methods[] = {
     {"poll", (PyCFunction)pyop_poll, METH_VARARGS, NULL},
     {"call", (PyCFunction)pyop_call, METH_VARARGS, NULL},
@@ -483,10 +436,6 @@ static struct PyMethodDef bpy_ops_methods[] = {
     {"dir", (PyCFunction)pyop_dir, METH_NOARGS, NULL},
     {"get_rna_type", (PyCFunction)pyop_getrna_type, METH_O, NULL},
     {"macro_define", (PyCFunction)PYOP_wrap_macro_define, METH_VARARGS, NULL},
-
-    /* Operator type functions (use to implement 'OperatorType.modal_keymap' property). */
-    {"modal_keymap_get", (PyCFunction)pyop_type_modal_keymap_get, METH_O, NULL},
-    {"modal_keymap_set", (PyCFunction)pyop_type_modal_keymap_set, METH_VARARGS, NULL},
     {NULL, NULL, 0, NULL},
 };



More information about the Bf-blender-cvs mailing list