From: Johan Dahlin Date: Thu, 2 Sep 2010 14:44:27 +0000 (-0300) Subject: [scanner] Move over remaining callsites to message X-Git-Tag: GOBJECT_INTROSPECTION_0_9_6~94 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=1dd0fcec1d80aa1c586044065ec320f82d542de2;p=platform%2Fupstream%2Fgobject-introspection.git [scanner] Move over remaining callsites to message Move the remaining callsites over to the new message module --- diff --git a/giscanner/gdumpparser.py b/giscanner/gdumpparser.py index d93a464..d88f2e3 100644 --- a/giscanner/gdumpparser.py +++ b/giscanner/gdumpparser.py @@ -209,8 +209,8 @@ blob containing data gleaned from GObject's primitive introspection.""" rettype = func.retval.type if not (rettype.is_equiv(ast.TYPE_GTYPE) or rettype.target_giname == 'Gtk.Type'): - self._transformer.log_warning("function returns '%r', not a GType" - % (func.retval.type, )) + message.warn("function returns '%r', not a GType" % ( + func.retval.type, )) return False self._get_type_functions.append(func.symbol) diff --git a/giscanner/introspectablepass.py b/giscanner/introspectablepass.py index 7843411..6653c09 100644 --- a/giscanner/introspectablepass.py +++ b/giscanner/introspectablepass.py @@ -19,6 +19,7 @@ from . import ast from . import glibast +from . import message class IntrospectablePass(object): @@ -38,7 +39,7 @@ class IntrospectablePass(object): if isinstance(node, glibast.GLibInterface): for vfunc in node.virtual_methods: if not vfunc.invoker: - self._transformer.log_node_warning(vfunc, + message.warn_node(vfunc, """Virtual function %r has no known invoker""" % (vfunc.name, ), context=node) @@ -51,7 +52,7 @@ class IntrospectablePass(object): context = "argument %s: " % (param.argname, ) else: context = "return value: " - self._transformer.log_node_warning(parent, prefix + context + text, *args) + message.warn_node(parent, prefix + context + text, *args) def _introspectable_param_analysis(self, parent, node): is_return = isinstance(node, ast.Return) diff --git a/giscanner/maintransformer.py b/giscanner/maintransformer.py index 867a6c7..5a5a21e 100644 --- a/giscanner/maintransformer.py +++ b/giscanner/maintransformer.py @@ -110,9 +110,10 @@ class MainTransformer(object): origin_name = 'parameter %s' % (origin.argname, ) else: origin_name = 'return value' - self._transformer.log_node_warning(parent, + message.log_node( + message.FATAL, parent, "can't find parameter %s referenced by %s of %r" - % (param_name, origin_name, parent.name), fatal=True) + % (param_name, origin_name, parent.name)) return param.argname @@ -125,18 +126,21 @@ class MainTransformer(object): rename_to = rename_to.value target = self._namespace.get_by_symbol(rename_to) if not target: - self._transformer.log_node_warning(node, -"Can't find symbol %r referenced by Rename annotation" % (rename_to, )) + message.warn_node(node, + "Can't find symbol %r referenced by Rename annotation" % ( + rename_to, )) elif target.shadowed_by: - self._transformer.log_node_warning(node, -"Function %r already shadowed by %r, can't overwrite with %r" % (target.symbol, - target.shadowed_by, - rename_to)) + message.warn_node(node, + "Function %r already shadowed by %r, can't overwrite with %r" % ( + target.symbol, + target.shadowed_by, + rename_to)) elif target.shadows: - self._transformer.log_node_warning(node, -"Function %r already shadows %r, can't multiply shadow with %r" % (target.symbol, - target.shadows, - rename_to)) + message.warn_node(node, + "Function %r already shadows %r, can't multiply shadow with %r" % ( + target.symbol, + target.shadows, + rename_to)) else: target.shadows = node.symbol node.shadowed_by = target.symbol @@ -225,8 +229,8 @@ class MainTransformer(object): return ast.List(base.name, *rest) if isinstance(base, ast.Map) and len(rest) == 2: return ast.Map(*rest) - self._transformer.log_warning( -"Too many parameters in type specification %r" % (type_str, )) + message.warn( + "Too many parameters in type specification %r" % (type_str, )) return base def top_combiner(base, *rest): if orig_node is not None: @@ -235,8 +239,8 @@ class MainTransformer(object): result, rest = grab_one(type_str, resolver, top_combiner, combiner) if rest: - self._transformer.log_warning( -"Trailing components in type specification %r" % (type_str, )) + message.warn("Trailing components in type specification %r" % ( + type_str, )) return result def _apply_annotations_array(self, parent, node, options): @@ -295,7 +299,7 @@ class MainTransformer(object): elif isinstance(node.type, ast.Array): node.type.element_type = self._resolve(element_type[0]) else: - self._transformer.log_node_warning(parent, + message.warn_node(parent, "Unknown container %r for element-type annotation" % (node.type, )) def _get_transfer_default_param(self, parent, node): @@ -404,8 +408,8 @@ class MainTransformer(object): elif subtype == 'callee-allocates': caller_allocates = False else: - self._transformer.log_warning( -"out allocation for %s is invalid (%r)" % (node, subtype), fatal=True) + message.fatal("out allocation for %s is invalid (%r)" % ( + node, subtype)) elif OPT_IN in options: annotated_direction = ast.PARAM_DIRECTION_IN @@ -481,8 +485,9 @@ class MainTransformer(object): if scope not in [ast.PARAM_SCOPE_CALL, ast.PARAM_SCOPE_ASYNC, ast.PARAM_SCOPE_NOTIFIED]: - self._transformer.log_warning(parent, -"Invalid scope %r for parameter %r" % (scope, param.name)) + message.warn( + parent, + "Invalid scope %r for parameter %r" % (scope, param.name)) else: param.scope = scope param.transfer = ast.PARAM_TRANSFER_NONE @@ -544,9 +549,9 @@ class MainTransformer(object): if param.argname == tag: break else: - self._transformer.log_warning( -"Annotation for '%s' refers to unknown argument '%s'" -% (parent.name, tag)) + message.warn( + "Annotation for '%s' refers to unknown argument '%s'" + % (parent.name, tag)) def _apply_annotations_field(self, parent, block, field): if not block: @@ -620,7 +625,7 @@ class MainTransformer(object): self._apply_annotations_callable(vfunc, [parent], block) break if not matched: - self._transformer.log_symbol_warning(node.symbol, + message.warn_symbol(node.symbol, "Virtual slot %r not found for %r annotation" % (invoker_name, TAG_VFUNC)) def _resolve_and_filter_type_list(self, typelist): @@ -716,8 +721,8 @@ the ones that failed to resolve removed.""" if enum is not None: enum.error_quark = node.symbol else: - self._transformer.log_node_warning(node, -"""%s: Couldn't find corresponding enumeration""" % (node.symbol, )) + message.warn_node(node, + """%s: Couldn't find corresponding enumeration""" % (node.symbol, )) def _split_uscored_by_type(self, uscored): """'uscored' should be an un-prefixed uscore string. This @@ -809,7 +814,7 @@ method or constructor of some type.""" split = self._split_uscored_by_type(subsymbol) if split is None: # TODO - need a e.g. (method) annotation - self._transformer.log_node_warning(func, + message.warn_node(func, "Can't find matching type for constructor; symbol=%r" % (func.symbol, )) return False (origin_node, funcname) = split @@ -823,15 +828,21 @@ method or constructor of some type.""" else: parent = None if parent is None: - self._transformer.log_node_warning(func, -"Return value is not superclass for constructor; symbol=%r constructed=%r return=%r" -% (func.symbol, str(origin_node.create_type()), str(func.retval.type))) + message.warn_node(func, + "Return value is not superclass for constructor; " + "symbol=%r constructed=%r return=%r" % ( + func.symbol, + str(origin_node.create_type()), + str(func.retval.type))) return False else: if origin_node != target: - self._transformer.log_node_warning(func, -"Constructor return type mismatch symbol=%r constructed=%r return=%r" -% (func.symbol, str(origin_node.create_type()), str(func.retval.type))) + message.warn_node(func, + "Constructor return type mismatch symbol=%r " + "constructed=%r return=%r" % ( + func.symbol, + str(origin_node.create_type()), + str(func.retval.type))) return False self._namespace.float(func) func.name = funcname @@ -845,7 +856,7 @@ method or constructor of some type.""" def _pair_class_virtuals(self, node): """Look for virtual methods from the class structure.""" if not node.glib_type_struct: - self._transformer.log_node_warning(node, + message.warn_node(node, "Failed to find class structure for %r" % (node.name, )) return diff --git a/giscanner/scannermain.py b/giscanner/scannermain.py index eae10f7..ea1299e 100644 --- a/giscanner/scannermain.py +++ b/giscanner/scannermain.py @@ -33,10 +33,10 @@ from giscanner.annotationparser import AnnotationParser from giscanner.ast import Include, Namespace from giscanner.dumper import compile_introspection_binary from giscanner.gdumpparser import GDumpParser, IntrospectionBinary -from giscanner.maintransformer import MainTransformer from giscanner.introspectablepass import IntrospectablePass from giscanner.girparser import GIRParser from giscanner.girwriter import GIRWriter +from giscanner.maintransformer import MainTransformer from giscanner.shlibs import resolve_shlibs from giscanner.sourcescanner import SourceScanner from giscanner.transformer import Transformer @@ -329,7 +329,7 @@ def scanner_main(args): final.validate() if options.warn_fatal and transformer.did_warn(): - transformer.log_warning("warnings configured as fatal", fatal=True) + message.fatal("warnings configured as fatal") return 1 # Write out AST diff --git a/giscanner/transformer.py b/giscanner/transformer.py index 30f7bbf..f83339c 100644 --- a/giscanner/transformer.py +++ b/giscanner/transformer.py @@ -86,8 +86,8 @@ class Transformer(object): positions = set() positions.update(original.file_positions) positions.update(node.file_positions) - self.log_warning("Namespace conflict for '%s'" % (node.name, ), - positions, fatal=True) + message.fatal("Namespace conflict for '%s'" % (node.name, ), + positions) else: self._namespace.append(node)