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-03-21 09:55:30 +0300
committerCampbell Barton <ideasman42@gmail.com>2009-03-21 09:55:30 +0300
commit6ab2d7ad659606cbf2a315ef9a576c364e6ec9bb (patch)
tree56250d1706115c5e4fd5aa8157a8dda91b8d950a /source/blender/python/intern/bpy_operator.c
parentb4209c56565660c20718fc2e1ad74d4257683a3e (diff)
- lazy subtype initialization rna, was initializing every type in bpy.types at startup, which is slow and doesn't allow access to dynamically added types.
- bpy.types isnt a module anymore, defined as its own PyType, getattr looks up the rna collection each time. - refcounting fixes - fixe epydoc generation with undefined values
Diffstat (limited to 'source/blender/python/intern/bpy_operator.c')
-rw-r--r--source/blender/python/intern/bpy_operator.c27
1 files changed, 26 insertions, 1 deletions
diff --git a/source/blender/python/intern/bpy_operator.c b/source/blender/python/intern/bpy_operator.c
index a35c5ed2cb4..b40d4640bcb 100644
--- a/source/blender/python/intern/bpy_operator.c
+++ b/source/blender/python/intern/bpy_operator.c
@@ -108,8 +108,10 @@ int PYOP_props_from_dict(PointerRNA *ptr, PyObject *kw)
}
static PyObject *pyop_base_dir(PyObject *self);
+static PyObject *pyop_base_rna(PyObject *self, PyObject *pyname);
static struct PyMethodDef pyop_base_methods[] = {
{"__dir__", (PyCFunction)pyop_base_dir, METH_NOARGS, ""},
+ {"__rna__", (PyCFunction)pyop_base_rna, METH_O, ""},
{"add", (PyCFunction)PYOP_wrap_add, METH_O, ""},
{"remove", (PyCFunction)PYOP_wrap_remove, METH_O, ""},
{NULL, NULL, 0, NULL}
@@ -199,8 +201,9 @@ static PyObject *pyop_base_getattro( BPy_OperatorBase * self, PyObject *pyname )
{
char *name = _PyUnicode_AsString(pyname);
PyObject *ret;
+ wmOperatorType *ot;
- if ((WM_operatortype_find(name))) {
+ if ((ot= WM_operatortype_find(name))) {
ret = PyCFunction_New( pyop_base_call_meth, pyname); /* set the name string as self, PyCFunction_New incref's self */
}
else if ((ret = PyObject_GenericGetAttr((PyObject *)self, pyname))) {
@@ -235,6 +238,28 @@ static PyObject *pyop_base_dir(PyObject *self)
return list;
}
+static PyObject *pyop_base_rna(PyObject *self, PyObject *pyname)
+{
+ char *name = _PyUnicode_AsString(pyname);
+ wmOperatorType *ot;
+
+ if ((ot= WM_operatortype_find(name))) {
+ BPy_StructRNA *pyrna;
+ PointerRNA ptr;
+
+ /* XXX POINTER - if this 'ot' is python generated, it could be free'd */
+ RNA_pointer_create(NULL, ot->srna, NULL, &ptr);
+
+ pyrna= (BPy_StructRNA *)pyrna_struct_CreatePyObject(&ptr); /* were not really using &ptr, overwite next */
+ //pyrna->freeptr= 1;
+ return pyrna;
+ }
+ else {
+ PyErr_SetString(PyExc_AttributeError, "Operator not found");
+ return NULL;
+ }
+}
+
PyTypeObject pyop_base_Type = {NULL};
PyObject *BPY_operator_module( bContext *C )