declare getAllDerivedFrom as static method

This commit is contained in:
wmayer
2019-11-13 00:57:21 +01:00
parent e1f85cd091
commit d61bf15c42
2 changed files with 11 additions and 9 deletions

View File

@@ -95,22 +95,24 @@ PyObject* TypePy::isBad(PyObject *args)
PyObject* TypePy::isDerivedFrom(PyObject *args)
{
char *name;
if (!PyArg_ParseTuple(args, "s", &name)) // convert args: Python->C
return NULL; // NULL triggers exception
const char *name;
if (!PyArg_ParseTuple(args, "s", &name))
return NULL;
Base::Type type = Base::Type::fromName(name);
bool v = (type != Base::Type::badType() && getBaseTypePtr()->isDerivedFrom(type));
return PyBool_FromLong(v ? 1 : 0);
}
PyObject* TypePy::getAllDerivedFrom(PyObject *args)
PyObject* TypePy::staticCallback_getAllDerivedFrom(PyObject* /*self*/, PyObject *args)
{
if (!PyArg_ParseTuple(args, "")) // convert args: Python->C
return NULL; // NULL triggers exception
const char *name;
if (!PyArg_ParseTuple(args, "s", &name))
return NULL;
Base::Type type = Base::Type::fromName(name);
std::vector<Base::Type> ary;
Base::Type::getAllDerivedFrom(*getBaseTypePtr(), ary);
Base::Type::getAllDerivedFrom(type, ary);
Py::List res;
for (std::vector<Base::Type>::iterator it = ary.begin(); it != ary.end(); ++it)
res.append(Py::String(it->getName()));