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-05 15:09:30 +0300
committerCampbell Barton <ideasman42@gmail.com>2009-03-05 15:09:30 +0300
commita7c4009267afe756ff0fa1a3935ae13eee02b1e3 (patch)
tree6c8f1b17a53f116594a3d9749974bbae8f139fe1 /source/blender/python/intern/bpy_operator.c
parent0229621b512507fabcad8634bcfc02d131ec9450 (diff)
Make RNA an Operator dir() work in py 2.5 - 3.0
removed epy docstrings from RNA python api, since Python can get this info from rna. (could be redone in python if getting doc's on RNA is needed) epy_doc_gen works again
Diffstat (limited to 'source/blender/python/intern/bpy_operator.c')
-rw-r--r--source/blender/python/intern/bpy_operator.c54
1 files changed, 21 insertions, 33 deletions
diff --git a/source/blender/python/intern/bpy_operator.c b/source/blender/python/intern/bpy_operator.c
index 3947dc8ab1e..a05456cfe9b 100644
--- a/source/blender/python/intern/bpy_operator.c
+++ b/source/blender/python/intern/bpy_operator.c
@@ -116,7 +116,7 @@ static int pyop_func_compare( BPy_OperatorFunc * a, BPy_OperatorFunc * b )
}
/* For some reason python3 needs these :/ */
-static PyObject *pyop_func_richcmp(BPy_StructRNA * a, BPy_StructRNA * b, int op)
+static PyObject *pyop_func_richcmp(BPy_OperatorFunc * a, BPy_OperatorFunc * b, int op)
{
int cmp_result= -1; /* assume false */
if (BPy_OperatorFunc_Check(a) && BPy_OperatorFunc_Check(b)) {
@@ -138,6 +138,11 @@ static PyObject *pyop_func_repr( BPy_OperatorFunc * self )
return PyUnicode_FromFormat( "[BPy_OperatorFunc \"%s\"]", self->name);
}
+static struct PyMethodDef pyop_base_methods[] = {
+ {"add", (PyCFunction)PYOP_wrap_add, METH_VARARGS, ""},
+ {"remove", (PyCFunction)PYOP_wrap_remove, METH_VARARGS, ""},
+ {NULL, NULL, 0, NULL}
+};
//---------------getattr--------------------------------------------
static PyObject *pyop_base_getattro( BPy_OperatorBase * self, PyObject *pyname )
@@ -149,6 +154,20 @@ static PyObject *pyop_base_getattro( BPy_OperatorBase * self, PyObject *pyname )
if ((ot = WM_operatortype_find(name))) {
ret= pyop_func_CreatePyObject(self->C, name);
}
+ else if (strcmp(name, "__dict__")==0) {
+ ret = PyDict_New();
+
+ wmOperatorType *ot;
+ PyMethodDef *meth;
+
+ for(ot= WM_operatortype_first(); ot; ot= ot->next) {
+ PyDict_SetItemString(ret, ot->idname, Py_None);
+ }
+
+ for(meth=pyop_base_methods; meth->ml_name; meth++) {
+ PyDict_SetItemString(ret, meth->ml_name, Py_None);
+ }
+ }
else if ((ret = PyObject_GenericGetAttr((PyObject *)self, pyname))) {
/* do nothing, this accounts for methoddef's add and remove */
}
@@ -156,7 +175,7 @@ static PyObject *pyop_base_getattro( BPy_OperatorBase * self, PyObject *pyname )
PyErr_Format( PyExc_AttributeError, "Operator \"%s\" not found", name);
ret= NULL;
}
-
+
return ret;
}
@@ -256,37 +275,6 @@ static PyObject * pyop_func_call(BPy_OperatorFunc * self, PyObject *args, PyObje
Py_RETURN_NONE;
}
-PyObject *pyop_base_dir(PyObject *self);
-
-static struct PyMethodDef pyop_base_methods[] = {
- {"add", (PyCFunction)PYOP_wrap_add, METH_VARARGS, ""},
- {"remove", (PyCFunction)PYOP_wrap_remove, METH_VARARGS, ""},
- {"__dir__", (PyCFunction)pyop_base_dir, METH_NOARGS, ""},
- {NULL, NULL, 0, NULL}
-};
-
-PyObject *pyop_base_dir(PyObject *self)
-{
- PyObject *ret = PyList_New(0);
- PyObject *item;
- wmOperatorType *ot;
- PyMethodDef *meth;
-
- for(ot= WM_operatortype_first(); ot; ot= ot->next) {
- item = PyUnicode_FromString( ot->idname );
- PyList_Append(ret, item);
- Py_DECREF(item);
- }
-
- for(meth=pyop_base_methods; meth->ml_name; meth++) {
- item = PyUnicode_FromString( meth->ml_name );
- PyList_Append(ret, item);
- Py_DECREF(item);
- }
-
- return ret;
-}
-
/*-----------------------BPy_OperatorBase method def------------------------------*/
PyTypeObject pyop_base_Type = {
#if (PY_VERSION_HEX >= 0x02060000)