summaryrefslogtreecommitdiff
path: root/giscanner
diff options
context:
space:
mode:
authorTomeu Vizoso <tomeu.vizoso@collabora.co.uk>2011-02-04 11:33:26 +0100
committerTomeu Vizoso <tomeu.vizoso@collabora.co.uk>2011-02-22 17:10:08 +0100
commita988cd414ce6aa40f1d77fcfa2d5721d169b5927 (patch)
treed025f82a9c9cc2613c2ce9f5120e66b48711e387 /giscanner
parentf49f46f0c2b4ab2c7e33598596e6df72bd960c19 (diff)
downloadgobject-introspection-a988cd414ce6aa40f1d77fcfa2d5721d169b5927.tar.gz
Add warnings for the (method) annotation
https://bugzilla.gnome.org/show_bug.cgi?id=641347
Diffstat (limited to 'giscanner')
-rw-r--r--giscanner/maintransformer.py20
1 files changed, 16 insertions, 4 deletions
diff --git a/giscanner/maintransformer.py b/giscanner/maintransformer.py
index ea1b170d..38642081 100644
--- a/giscanner/maintransformer.py
+++ b/giscanner/maintransformer.py
@@ -900,7 +900,7 @@ method or constructor of some type."""
if func.is_constructor or self._is_constructor(func, subsymbol):
self._set_up_constructor(func, subsymbol)
return
- elif func.is_method or self._is_method(func, subsymbol):
+ elif self._is_method(func, subsymbol):
self._setup_method(func, subsymbol)
return
elif self._pair_static_method(func, subsymbol):
@@ -913,14 +913,25 @@ method or constructor of some type."""
def _is_method(self, func, subsymbol):
if not func.parameters:
+ if func.is_method:
+ message.warn_node(func,
+ '%s: Methods must have parameters' % (func.symbol, ))
return False
first = func.parameters[0]
target = self._transformer.lookup_typenode(first.type)
if not isinstance(target, (ast.Class, ast.Interface,
ast.Record, ast.Union,
ast.Boxed)):
+ if func.is_method:
+ message.warn_node(func,
+ '%s: Methods must have a pointer as their first '
+ 'parameter' % (func.symbol, ))
return False
if target.namespace != self._namespace:
+ if func.is_method:
+ message.warn_node(func,
+ '%s: Methods must belong to the same namespace as the '
+ 'class they belong to' % (func.symbol, ))
return False
# A quick hack here...in the future we should catch C signature/GI signature
@@ -928,9 +939,10 @@ method or constructor of some type."""
if first.type.ctype is not None and first.type.ctype.count('*') != 1:
return False
- uscored_prefix = self._get_uscored_prefix(func, subsymbol)
- if not subsymbol.startswith(uscored_prefix):
- return False
+ if not func.is_method:
+ uscored_prefix = self._get_uscored_prefix(func, subsymbol)
+ if not subsymbol.startswith(uscored_prefix):
+ return False
return True