Add python interface consistency check that we don't use non-class enums

* These enums are generally not preferred anyway, but they also can't have
  docstrings so can't be checked for *missing* docstrings.
This commit is contained in:
baldurk
2020-12-03 22:29:15 +00:00
parent 170f29ebfa
commit 6f7e8bb396
3 changed files with 77 additions and 3 deletions
@@ -480,8 +480,36 @@ bool PythonContext::CheckInterfaces(rdcstr &log)
PyGILState_STATE gil = PyGILState_Ensure();
errors |= CheckCoreInterface(log);
errors |= CheckQtInterface(log);
for(rdcstr module_name : {"renderdoc", "qrenderdoc"})
{
PyObject *mod = PyImport_ImportModule(module_name.c_str());
PyObject *dict = PyModule_GetDict(mod);
PyObject *key, *value;
Py_ssize_t pos = 0;
while(PyDict_Next(dict, &pos, &key, &value))
{
rdcstr name = ToQStr(key);
if(name.beginsWith("__"))
continue;
if(!PyCallable_Check(value))
{
log += "Non-callable object found: " + module_name + "." + name +
". Expected only classes and functions.\n";
errors = true;
}
}
Py_DECREF(mod);
}
PyGILState_Release(gil);
log.trim();
return errors;
}