Move the remaining callsites over to the new message
module
rettype = func.retval.type
if not (rettype.is_equiv(ast.TYPE_GTYPE)
or rettype.target_giname == 'Gtk.Type'):
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)
return False
self._get_type_functions.append(func.symbol)
from . import ast
from . import glibast
from . import ast
from . import glibast
class IntrospectablePass(object):
class IntrospectablePass(object):
if isinstance(node, glibast.GLibInterface):
for vfunc in node.virtual_methods:
if not vfunc.invoker:
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)
"""Virtual function %r has no known invoker""" % (vfunc.name, ),
context=node)
context = "argument %s: " % (param.argname, )
else:
context = "return value: "
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)
def _introspectable_param_analysis(self, parent, node):
is_return = isinstance(node, ast.Return)
origin_name = 'parameter %s' % (origin.argname, )
else:
origin_name = 'return value'
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"
"can't find parameter %s referenced by %s of %r"
- % (param_name, origin_name, parent.name), fatal=True)
+ % (param_name, origin_name, parent.name))
rename_to = rename_to.value
target = self._namespace.get_by_symbol(rename_to)
if not target:
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, ))
- 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))
- 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
else:
target.shadows = node.symbol
node.shadowed_by = target.symbol
return ast.List(base.name, *rest)
if isinstance(base, ast.Map) and len(rest) == 2:
return ast.Map(*rest)
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:
return base
def top_combiner(base, *rest):
if orig_node is not None:
result, rest = grab_one(type_str, resolver, top_combiner, combiner)
if rest:
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):
return result
def _apply_annotations_array(self, parent, node, options):
elif isinstance(node.type, ast.Array):
node.type.element_type = self._resolve(element_type[0])
else:
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):
"Unknown container %r for element-type annotation" % (node.type, ))
def _get_transfer_default_param(self, parent, node):
elif subtype == 'callee-allocates':
caller_allocates = False
else:
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
elif OPT_IN in options:
annotated_direction = ast.PARAM_DIRECTION_IN
if scope not in [ast.PARAM_SCOPE_CALL,
ast.PARAM_SCOPE_ASYNC,
ast.PARAM_SCOPE_NOTIFIED]:
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
else:
param.scope = scope
param.transfer = ast.PARAM_TRANSFER_NONE
if param.argname == tag:
break
else:
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:
def _apply_annotations_field(self, parent, block, field):
if not block:
self._apply_annotations_callable(vfunc, [parent], block)
break
if not matched:
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):
"Virtual slot %r not found for %r annotation" % (invoker_name, TAG_VFUNC))
def _resolve_and_filter_type_list(self, typelist):
if enum is not None:
enum.error_quark = node.symbol
else:
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
def _split_uscored_by_type(self, uscored):
"""'uscored' should be an un-prefixed uscore string. This
split = self._split_uscored_by_type(subsymbol)
if split is None:
# TODO - need a e.g. (method) annotation
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
"Can't find matching type for constructor; symbol=%r" % (func.symbol, ))
return False
(origin_node, funcname) = split
else:
parent = None
if parent is None:
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:
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
return False
self._namespace.float(func)
func.name = funcname
def _pair_class_virtuals(self, node):
"""Look for virtual methods from the class structure."""
if not node.glib_type_struct:
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
"Failed to find class structure for %r" % (node.name, ))
return
from giscanner.ast import Include, Namespace
from giscanner.dumper import compile_introspection_binary
from giscanner.gdumpparser import GDumpParser, IntrospectionBinary
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.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
from giscanner.shlibs import resolve_shlibs
from giscanner.sourcescanner import SourceScanner
from giscanner.transformer import Transformer
final.validate()
if options.warn_fatal and transformer.did_warn():
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")
positions = set()
positions.update(original.file_positions)
positions.update(node.file_positions)
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)
else:
self._namespace.append(node)