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
@@ -219,7 +219,9 @@ struct ShaderProcessingTool
DECLARE_REFLECTION_STRUCT(ShaderProcessingTool);
#if !defined(SWIG)
#define BUGREPORT_URL "https://renderdoc.org/bugreporter"
#endif
DOCUMENT("Describes a submitted bug report.");
struct BugReport
@@ -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;
}
+47 -3
View File
@@ -469,7 +469,29 @@ enum class AddressMode : uint32_t
DECLARE_REFLECTION_ENUM(AddressMode);
enum YcbcrConversion
DOCUMENT(R"(The color model conversion that a YCbCr sampler uses to convert from YCbCr to RGB.
.. data:: Raw
The input values are not converted at all.
.. data:: RangeOnly
There is no model conversion but the inputs are range expanded as for YCbCr.
.. data:: BT709
The conversion uses the BT.709 color model conversion.
.. data:: BT601
The conversion uses the BT.601 color model conversion.
.. data:: BT2020
The conversion uses the BT.2020 color model conversion.
)");
enum class YcbcrConversion
{
Raw,
RangeOnly,
@@ -480,7 +502,18 @@ enum YcbcrConversion
DECLARE_REFLECTION_ENUM(YcbcrConversion);
enum YcbcrRange
DOCUMENT(R"(Specifies the range of encoded values and their interpretation.
.. data:: ITUFull
The full range of input values are valid and interpreted according to ITU "full range" rules.
.. data:: ITUNarrow
A head and foot are reserved in the encoded values, and the remaining values are expanded
according to "narrow range" rules.
)");
enum class YcbcrRange
{
ITUFull,
ITUNarrow,
@@ -488,7 +521,18 @@ enum YcbcrRange
DECLARE_REFLECTION_ENUM(YcbcrRange);
enum ChromaSampleLocation
DOCUMENT(R"(Determines where in the pixel downsampled chrome samples are positioned.
.. data:: CositedEven
The chroma samples are positioned exactly in the same place as the even luma co-ordinates.
.. data:: Midpoint
The chrome samples are positioned half way between each even luma sample and the next highest odd
luma sample.
)");
enum class ChromaSampleLocation
{
CositedEven,
Midpoint,