diff options
author | Campbell Barton <ideasman42@gmail.com> | 2018-09-13 11:16:06 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2018-09-13 11:16:06 +0300 |
commit | a6fc7180297f855c2592b20b26f96eb8e5a9e0ca (patch) | |
tree | ca62e3e1c301e42814a76f522975855bc1d6ceea /source/blender/python/intern | |
parent | 9900addf11d9a5b964aa745cf141998195f7c8db (diff) |
PyAPI: add API call to get an operators type
Getting the instance leaks memory and was only meant to be used for
generating docs.
Diffstat (limited to 'source/blender/python/intern')
-rw-r--r-- | source/blender/python/intern/bpy_operator.c | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/source/blender/python/intern/bpy_operator.c b/source/blender/python/intern/bpy_operator.c index 78ae9976586..555aec00b2c 100644 --- a/source/blender/python/intern/bpy_operator.c +++ b/source/blender/python/intern/bpy_operator.c @@ -409,6 +409,19 @@ static PyObject *pyop_dir(PyObject *UNUSED(self)) return list; } +static PyObject *pyop_getrna_type(PyObject *UNUSED(self), PyObject *value) +{ + wmOperatorType *ot; + if ((ot = ot_lookup_from_py_string(value, "get_rna_type")) == NULL) { + return NULL; + } + + PointerRNA ptr; + RNA_pointer_create(NULL, &RNA_Struct, ot->srna, &ptr); + BPy_StructRNA *pyrna = (BPy_StructRNA *)pyrna_struct_CreatePyObject(&ptr); + return (PyObject *)pyrna; +} + static PyObject *pyop_getrna(PyObject *UNUSED(self), PyObject *value) { wmOperatorType *ot; @@ -466,6 +479,7 @@ static struct PyMethodDef bpy_ops_methods[] = { {"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}, |