summaryrefslogtreecommitdiff
path: root/giscanner/ast.py
diff options
context:
space:
mode:
authorJohan Dahlin <jdahlin@async.com.br>2009-01-12 20:11:44 +0000
committerJohan Dahlin <johan@src.gnome.org>2009-01-12 20:11:44 +0000
commit7dbbda9abea9882d2c98726f382a905fa8738706 (patch)
treebdf438fc921de19ddee90d7f2c5972cf76fec48f /giscanner/ast.py
parentba4ee2e606545ac703941698aa25e6d865e6976f (diff)
downloadgobject-introspection-7dbbda9abea9882d2c98726f382a905fa8738706.tar.gz
Bug 563794 - Redo annotation parsing & applying
2009-01-12 Johan Dahlin <jdahlin@async.com.br> Bug 563794 - Redo annotation parsing & applying Thanks to Colin for helping out considerably in landing this. * giscanner/Makefile.am: * giscanner/ast.py: * giscanner/dumper.py: * giscanner/girparser.py: * giscanner/giscannermodule.c (pygi_source_scanner_get_comments), (calc_attrs_length), (pygi_collect_attributes), (init_giscanner): * giscanner/glibtransformer.py: * giscanner/scannerlexer.l: * giscanner/sourcescanner.c (gi_source_symbol_unref), (gi_source_scanner_new), (gi_source_scanner_free), (gi_source_scanner_get_comments): * giscanner/sourcescanner.h: * giscanner/sourcescanner.py: * giscanner/transformer.py: * giscanner/xmlwriter.py: * tests/scanner/annotation-1.0-expected.gir: * tests/scanner/annotation-1.0-expected.tgir: * tests/scanner/annotation.c: * tests/scanner/annotation.h: * tests/scanner/foo-1.0-expected.gir: * tests/scanner/foo-1.0-expected.tgir: * tests/scanner/foo.h: * tools/g-ir-scanner: This commit merges the annotation parser rewrite branch. It'll change the annotation parsing to be done completely in python code which will make it easier to do further annotation parsing easier. svn path=/trunk/; revision=1017
Diffstat (limited to 'giscanner/ast.py')
-rw-r--r--giscanner/ast.py32
1 files changed, 24 insertions, 8 deletions
diff --git a/giscanner/ast.py b/giscanner/ast.py
index 6bd858b2..c5dc436c 100644
--- a/giscanner/ast.py
+++ b/giscanner/ast.py
@@ -200,6 +200,17 @@ class Function(Node):
self.parameters = parameters
self.symbol = symbol
self.throws = not not throws
+ self.is_method = False
+
+ def get_parameter_index(self, name):
+ for i, parameter in enumerate(self.parameters):
+ if parameter.name == name:
+ return i + int(self.is_method)
+
+ def get_parameter(self, name):
+ for parameter in self.parameters:
+ if parameter.name == name:
+ return parameter
def __repr__(self):
return '%s(%r, %r, %r)' % (self.__class__.__name__,
@@ -217,6 +228,9 @@ class Type(Node):
Node.__init__(self, name)
self.ctype = ctype
self.resolved = False
+ self.is_const = False
+ self.canonical = None
+ self.derefed_canonical = None
class Varargs(Type):
@@ -236,7 +250,7 @@ class Array(Type):
self.size = None
def __repr__(self):
- return 'Array(%r of %r)' % (self.name, self.element_type, )
+ return 'Array(%r, %r)' % (self.name, self.element_type, )
class List(Type):
@@ -282,22 +296,19 @@ class TypeContainer(Node):
else:
self.transfer = None
- # transformer.py overrides this as needed
- self.transfer_inferred = False
-
class Parameter(TypeContainer):
- def __init__(self, name, typenode, direction=PARAM_DIRECTION_IN,
+ def __init__(self, name, typenode, direction=None,
transfer=None, allow_none=False, scope=None):
TypeContainer.__init__(self, name, typenode, transfer)
if direction in [PARAM_DIRECTION_IN, PARAM_DIRECTION_OUT,
- PARAM_DIRECTION_INOUT]:
+ PARAM_DIRECTION_INOUT, None]:
self.direction = direction
else:
self.direction = PARAM_DIRECTION_IN
- self.allow_none = not not allow_none
+ self.allow_none = allow_none
self.scope = scope
self.closure_index = -1
self.destroy_index = -1
@@ -328,7 +339,7 @@ class Member(Node):
return 'Member(%r, %r)' % (self.name, self.value)
-class Struct(Node):
+class Record(Node):
def __init__(self, name, symbol, disguised=False):
Node.__init__(self, name)
@@ -337,6 +348,9 @@ class Struct(Node):
self.symbol = symbol
self.disguised = disguised
+# BW compat, remove
+Struct = Record
+
class Field(Node):
@@ -359,6 +373,7 @@ class Return(TypeContainer):
def __init__(self, rtype, transfer=None):
TypeContainer.__init__(self, None, rtype, transfer)
+ self.direction = PARAM_DIRECTION_OUT
def __repr__(self):
return 'Return(%r)' % (self.type, )
@@ -431,6 +446,7 @@ class Property(Node):
# FIXME: Inherit from Function
+
class Callback(Node):
def __init__(self, name, retval, parameters, ctype=None):