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>2018-09-13 13:15:18 +0300
committerCampbell Barton <ideasman42@gmail.com>2018-09-13 13:15:18 +0300
commit09aa4461004899e0da8f967a78e19303e50396a0 (patch)
tree7a56bb0b64efba896c1d149aa47d32e1ae95eac8
parent2c4f091feb0b0eca4893bf6914f4698daf4556ed (diff)
parent254067106e58736298b73353281992638d2951ac (diff)
Merge branch 'master' into blender2.8
-rw-r--r--release/scripts/modules/bl_i18n_utils/bl_extract_messages.py2
-rw-r--r--release/scripts/modules/bl_i18n_utils/utils.py2
-rw-r--r--release/scripts/modules/bpy/ops.py39
-rw-r--r--source/blender/python/intern/bpy_operator.c54
4 files changed, 13 insertions, 84 deletions
diff --git a/release/scripts/modules/bl_i18n_utils/bl_extract_messages.py b/release/scripts/modules/bl_i18n_utils/bl_extract_messages.py
index dd679f230d2..db46bf0736a 100644
--- a/release/scripts/modules/bl_i18n_utils/bl_extract_messages.py
+++ b/release/scripts/modules/bl_i18n_utils/bl_extract_messages.py
@@ -545,7 +545,7 @@ def dump_py_messages_from_files(msgs, reports, files, settings):
for n in opname.split('.'):
op = getattr(op, n)
try:
- return op.get_rna().bl_rna.translation_context
+ return op.get_rna_type().translation_context
except Exception as e:
default_op_context = i18n_contexts.operator_default
print("ERROR: ", str(e))
diff --git a/release/scripts/modules/bl_i18n_utils/utils.py b/release/scripts/modules/bl_i18n_utils/utils.py
index 4be7ccf3356..55a210c56ed 100644
--- a/release/scripts/modules/bl_i18n_utils/utils.py
+++ b/release/scripts/modules/bl_i18n_utils/utils.py
@@ -208,7 +208,7 @@ def enable_addons(addons=None, support=None, disable=False, check_only=False):
for cat in dir(bpy.ops):
cat = getattr(bpy.ops, cat)
for op in dir(cat):
- getattr(cat, op).get_rna()
+ getattr(cat, op).get_rna_type()
return ret
diff --git a/release/scripts/modules/bpy/ops.py b/release/scripts/modules/bpy/ops.py
index 961c9d99a7b..f4e37ebc9a8 100644
--- a/release/scripts/modules/bpy/ops.py
+++ b/release/scripts/modules/bpy/ops.py
@@ -26,9 +26,7 @@ op_dir = ops_module.dir
op_poll = ops_module.poll
op_call = ops_module.call
op_as_string = ops_module.as_string
-op_get_rna = ops_module.get_rna
op_get_rna_type = ops_module.get_rna_type
-op_get_instance = ops_module.get_instance
class BPyOps:
@@ -116,7 +114,16 @@ class BPyOpsSubModOp:
__slots__ = ("_module", "_func")
def _get_doc(self):
- return op_as_string(self.idname())
+ idname = self.idname()
+ sig = op_as_string(self.idname())
+ # XXX You never quite know what you get from bpy.types,
+ # with operators... Operator and OperatorProperties
+ # are shadowing each other, and not in the same way for
+ # native ops and py ones! See T39158.
+ # op_class = getattr(bpy.types, idname)
+ op_class = op_get_rna_type(idname)
+ descr = op_class.description
+ return f"{sig}\n{descr}"
@staticmethod
def _parse_args(args):
@@ -201,33 +208,9 @@ class BPyOpsSubModOp:
"""Internal function for introspection"""
return op_get_rna_type(self.idname())
- def get_rna(self):
- """Internal function for introspection"""
- return op_get_rna(self.idname())
-
- def get_instance(self):
- """Internal function for introspection"""
- return op_get_instance(self.idname())
-
def __repr__(self): # useful display, repr(op)
# import bpy
- idname = self.idname()
- as_string = op_as_string(idname)
- # XXX You never quite know what you get from bpy.types,
- # with operators... Operator and OperatorProperties
- # are shadowing each other, and not in the same way for
- # native ops and py ones! See T39158.
- # op_class = getattr(bpy.types, idname)
- op_class = op_get_rna(idname)
- descr = op_class.bl_rna.description
- # XXX, workaround for not registering
- # every __doc__ to save time on load.
- if not descr:
- descr = op_class.__doc__
- if not descr:
- descr = ""
-
- return "# %s\n%s" % (descr, as_string)
+ return op_as_string(self.idname())
def __str__(self): # used for print(...)
return ("<function bpy.ops.%s.%s at 0x%x'>" %
diff --git a/source/blender/python/intern/bpy_operator.c b/source/blender/python/intern/bpy_operator.c
index 555aec00b2c..d3abaf43aef 100644
--- a/source/blender/python/intern/bpy_operator.c
+++ b/source/blender/python/intern/bpy_operator.c
@@ -422,66 +422,12 @@ static PyObject *pyop_getrna_type(PyObject *UNUSED(self), PyObject *value)
return (PyObject *)pyrna;
}
-static PyObject *pyop_getrna(PyObject *UNUSED(self), PyObject *value)
-{
- wmOperatorType *ot;
-
- if ((ot = ot_lookup_from_py_string(value, "getrna")) == NULL) {
- return NULL;
- }
-
- /* type */
- //RNA_pointer_create(NULL, &RNA_Struct, ot->srna, &ptr);
-
- /* XXX - should call WM_operator_properties_free */
- PointerRNA ptr;
- WM_operator_properties_create_ptr(&ptr, ot);
- WM_operator_properties_sanitize(&ptr, 0);
-
- BPy_StructRNA *pyrna = (BPy_StructRNA *)pyrna_struct_CreatePyObject(&ptr);
-#ifdef PYRNA_FREE_SUPPORT
- pyrna->freeptr = true;
-#endif
- return (PyObject *)pyrna;
-}
-
-static PyObject *pyop_getinstance(PyObject *UNUSED(self), PyObject *value)
-{
- wmOperatorType *ot;
- if ((ot = ot_lookup_from_py_string(value, "get_instance")) == NULL) {
- return NULL;
- }
-
- wmOperator *op;
-#ifdef PYRNA_FREE_SUPPORT
- op = MEM_callocN(sizeof(wmOperator), __func__);
-#else
- op = PyMem_MALLOC(sizeof(wmOperator));
- memset(op, 0, sizeof(wmOperator));
-#endif
- BLI_strncpy(op->idname, ot->idname, sizeof(op->idname)); /* in case its needed */
- op->type = ot;
-
- PointerRNA ptr;
- RNA_pointer_create(NULL, &RNA_Operator, op, &ptr);
-
- BPy_StructRNA *pyrna = (BPy_StructRNA *)pyrna_struct_CreatePyObject(&ptr);
-#ifdef PYRNA_FREE_SUPPORT
- pyrna->freeptr = true;
-#endif
- op->ptr = &pyrna->ptr;
-
- return (PyObject *)pyrna;
-}
-
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_type", (PyCFunction) pyop_getrna_type, METH_O, NULL},
- {"get_rna", (PyCFunction) pyop_getrna, METH_O, NULL}, /* only for introspection, leaks memory */
- {"get_instance", (PyCFunction) pyop_getinstance, METH_O, NULL}, /* only for introspection, leaks memory */
{"macro_define", (PyCFunction) PYOP_wrap_macro_define, METH_VARARGS, NULL},
{NULL, NULL, 0, NULL}
};