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
This commit is contained in:
2009-03-05 12:09:30 +00:00
parent 0229621b51
commit a7c4009267
3 changed files with 65 additions and 211 deletions

View File

@@ -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)