summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Winship <danw@gnome.org>2009-12-09 16:38:57 -0500
committerDan Winship <danw@gnome.org>2009-12-09 17:04:25 -0500
commitb65d598f82d3cbdc56e3a94b42c1472bf3607c69 (patch)
tree042019760a8ed5ab9043004f34f30d2c7d01041e
parent6710cfa5063c041894d700b6cf6b4b85cdd08025 (diff)
downloadgobject-introspection-b65d598f82d3cbdc56e3a94b42c1472bf3607c69.tar.gz
[scanner] Fix various hardcoded type name checks
Various places that check hardcoded type names were not always handling the case of the type being used from within its own library (in which case it won't have a type prefix). Make them more consistent. https://bugzilla.gnome.org/show_bug.cgi?id=602512
-rw-r--r--giscanner/annotationparser.py19
-rw-r--r--giscanner/glibtransformer.py4
-rw-r--r--giscanner/transformer.py5
3 files changed, 16 insertions, 12 deletions
diff --git a/giscanner/annotationparser.py b/giscanner/annotationparser.py
index 18c40edc..d91bb1c4 100644
--- a/giscanner/annotationparser.py
+++ b/giscanner/annotationparser.py
@@ -417,7 +417,8 @@ class AnnotationApplier(object):
def _parse_callable(self, callable, block):
self._parse_node_common(callable, block)
for i, param in enumerate(callable.parameters):
- if param.type.name not in ['DestroyNotify', 'GLib.DestroyNotify']:
+ if (param.type.ctype != 'GDestroyNotify' and
+ param.type.name != 'GLib.DestroyNotify'):
continue
if i < 2:
break
@@ -511,8 +512,8 @@ class AnnotationApplier(object):
if scope:
param.scope = scope.one()
param.transfer = PARAM_TRANSFER_NONE
- elif param.type.name in ['AsyncReadyCallback',
- 'Gio.AsyncReadyCallback']:
+ elif (param.type.ctype == 'GAsyncReadyCallback' or
+ param.type.name == 'Gio.AsyncReadyCallback'):
param.scope = OPT_SCOPE_ASYNC
param.transfer = PARAM_TRANSFER_NONE
@@ -661,9 +662,11 @@ class AnnotationApplier(object):
def combiner(base, *rest):
if not rest:
return base
- if base.name in ['GLib.List', 'GLib.SList'] and len(rest)==1:
+ if (base.name in ['GLib.List', 'GLib.SList'] or
+ base.ctype in ['GList*', 'GSList*']) and len(rest)==1:
return List(base.name, base.ctype, *rest)
- if base.name in ['GLib.HashTable'] and len(rest)==2:
+ if (base.name in ['GLib.HashTable'] or
+ base.ctype in ['GHashTable*']) and len(rest)==2:
return Map(base.name, base.ctype, *rest)
print "WARNING: throwing away type parameters:", type_str
return base
@@ -682,13 +685,15 @@ class AnnotationApplier(object):
def _parse_element_type(self, parent, node, options):
element_type_opt = options.get(OPT_ELEMENT_TYPE)
element_type = element_type_opt.flat()
- if node.type.name in ['GLib.List', 'GLib.SList']:
+ if (node.type.name in ['GLib.List', 'GLib.SList'] or
+ node.type.ctype in ['GList*', 'GSList*']):
assert len(element_type) == 1
container_type = List(
node.type.name,
node.type.ctype,
self._resolve(element_type[0]))
- elif node.type.name in ['GLib.HashTable']:
+ elif (node.type.name in ['GLib.HashTable'] or
+ node.type.ctype in ['GHashTable*']):
assert len(element_type) == 2
container_type = Map(
node.type.name,
diff --git a/giscanner/glibtransformer.py b/giscanner/glibtransformer.py
index d44987b9..658be697 100644
--- a/giscanner/glibtransformer.py
+++ b/giscanner/glibtransformer.py
@@ -408,8 +408,8 @@ class GLibTransformer(object):
return False
if func.parameters:
return False
- if func.retval.type.name not in ['GLib.Quark',
- 'GQuark']:
+ if (func.retval.type.name != 'GLib.Quark' and
+ func.retval.type.ctype != 'GQuark'):
return False
self._error_quark_functions.append(func)
diff --git a/giscanner/transformer.py b/giscanner/transformer.py
index bc5d943d..1024ee35 100644
--- a/giscanner/transformer.py
+++ b/giscanner/transformer.py
@@ -283,9 +283,8 @@ class Transformer(object):
return False
def _handle_destroy(self, param, destroy_idx, destroy_param):
- if ((self._namespace.name == 'GLib' and
- destroy_param.type.name == 'DestroyNotify') or
- destroy_param.type.name == 'GLib.DestroyNotify'):
+ if (destroy_param.type.name == 'GLib.DestroyNotify' or
+ destroy_param.type.ctype == 'GDestroyNotify'):
param.destroy_name = destroy_param.name
param.destroy_index = destroy_idx
return True