aboutsummaryrefslogtreecommitdiff
path: root/find-modules/sip_generator.py
diff options
context:
space:
mode:
authorStephen Kelly <steveire@gmail.com>2017-01-11 21:27:03 +0000
committerStephen Kelly <steveire@gmail.com>2017-01-11 21:27:03 +0000
commited1b9ce2bb2a2e51410e0a1754a72c110010a6a0 (patch)
tree74e69c7f76a0ec8c8abf5357cefe235531e821fd /find-modules/sip_generator.py
parent8aa6843404f9c6faef66cb9c76358158eafc1af1 (diff)
downloadextra-cmake-modules-ed1b9ce2bb2a2e51410e0a1754a72c110010a6a0.tar.gz
extra-cmake-modules-ed1b9ce2bb2a2e51410e0a1754a72c110010a6a0.tar.bz2
Bindings: Fix logging output severity for parsing messages
The Python logging module uses logging severities with numerical values which form a sequence in steps of 10. The Clang cindex.Diagnostic numerical values use a step size of 1, so the two are incompatible. Introduce a mapping function so that appropriate errors get issued when attempting to build the bindings. The logging module has one surplus diagnostic level, but we simply never use it. BUG: 374801
Diffstat (limited to 'find-modules/sip_generator.py')
-rw-r--r--find-modules/sip_generator.py30
1 files changed, 29 insertions, 1 deletions
diff --git a/find-modules/sip_generator.py b/find-modules/sip_generator.py
index acdec86e..f44c2b34 100644
--- a/find-modules/sip_generator.py
+++ b/find-modules/sip_generator.py
@@ -62,6 +62,32 @@ TEMPLATE_KINDS = [
CursorKind.TYPE_REF, CursorKind.TEMPLATE_REF, CursorKind.NAMESPACE_REF
] + EXPR_KINDS
+def clang_diagnostic_to_logging_diagnostic(lvl):
+ """
+
+ The diagnostic levels in cindex.py are
+
+ Ignored = 0
+ Note = 1
+ Warning = 2
+ Error = 3
+ Fatal = 4
+
+ and the leves in the python logging module are
+
+ NOTSET 0
+ DEBUG 10
+ INFO 20
+ WARNING 30
+ ERROR 40
+ CRITICAL 50
+
+ """
+ return (logging.NOTSET,
+ logging.INFO,
+ logging.WARNING,
+ logging.ERROR,
+ logging.CRITICAL)[lvl]
class SipGenerator(object):
def __init__(self, project_rules, compile_flags, verbose=False, dump_includes=False, dump_privates=False):
@@ -114,10 +140,12 @@ class SipGenerator(object):
#
loc = diag.location
msg = "{}:{}[{}] {}".format(loc.file, loc.line, loc.column, diag.spelling)
+ if (diag.spelling == "#pragma once in main file"):
+ continue
if msg in self.diagnostics:
continue
self.diagnostics.add(msg)
- logger.log(diag.severity, "Parse error {}".format(msg))
+ logger.log(clang_diagnostic_to_logging_diagnostic(diag.severity), "Parse error {}".format(msg))
if self.dump_includes:
for include in sorted(set(self.tu.get_includes())):
logger.debug(_("Used includes {}").format(include.include.name))