Base: apply clang format
This commit is contained in:
@@ -36,27 +36,32 @@ std::string BaseClassPy::representation() const
|
||||
}
|
||||
|
||||
|
||||
PyObject* BaseClassPy::isDerivedFrom(PyObject *args)
|
||||
PyObject* BaseClassPy::isDerivedFrom(PyObject* args)
|
||||
{
|
||||
char *name{};
|
||||
if (!PyArg_ParseTuple(args, "s", &name))
|
||||
char* name {};
|
||||
if (!PyArg_ParseTuple(args, "s", &name)) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// clang-format off
|
||||
Base::Type type = Base::Type::fromName(name);
|
||||
bool valid = (type != Base::Type::badType() && getBaseClassPtr()->getTypeId().isDerivedFrom(type));
|
||||
return PyBool_FromLong(valid ? 1 : 0);
|
||||
// clang-format on
|
||||
}
|
||||
|
||||
PyObject* BaseClassPy::getAllDerivedFrom(PyObject *args)
|
||||
PyObject* BaseClassPy::getAllDerivedFrom(PyObject* args)
|
||||
{
|
||||
if (!PyArg_ParseTuple(args, ""))
|
||||
if (!PyArg_ParseTuple(args, "")) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
std::vector<Base::Type> ary;
|
||||
Base::Type::getAllDerivedFrom(getBaseClassPtr()->getTypeId(), ary);
|
||||
Py::List res;
|
||||
for (const auto & it : ary)
|
||||
for (const auto& it : ary) {
|
||||
res.append(Py::String(it.getName()));
|
||||
}
|
||||
return Py::new_reference_to(res);
|
||||
}
|
||||
|
||||
@@ -70,15 +75,17 @@ Py::String BaseClassPy::getModule() const
|
||||
std::string module(getBaseClassPtr()->getTypeId().getName());
|
||||
std::string::size_type pos = module.find_first_of("::");
|
||||
|
||||
if (pos != std::string::npos)
|
||||
if (pos != std::string::npos) {
|
||||
module = std::string(module, 0, pos);
|
||||
else
|
||||
}
|
||||
else {
|
||||
module.clear();
|
||||
}
|
||||
|
||||
return {module};
|
||||
}
|
||||
|
||||
PyObject *BaseClassPy::getCustomAttributes(const char* /*attr*/) const
|
||||
PyObject* BaseClassPy::getCustomAttributes(const char* /*attr*/) const
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
@@ -87,5 +94,3 @@ int BaseClassPy::setCustomAttributes(const char* /*attr*/, PyObject* /*obj*/)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user