diff options
author | Colin Walters <walters@src.gnome.org> | 2008-09-29 19:03:35 +0000 |
---|---|---|
committer | Colin Walters <walters@src.gnome.org> | 2008-09-29 19:03:35 +0000 |
commit | 3de4dd3835dd294dc76e186cf0d756356cfe281e (patch) | |
tree | e6a6bb74cacf52fbd152c34fee2ed7f82a84b1d4 /giscanner/ast.py | |
parent | 195b04e2c35d8bb3075ee846c77ae89bd3b8ab26 (diff) | |
download | gobject-introspection-3de4dd3835dd294dc76e186cf0d756356cfe281e.tar.gz |
Some work on arrays
svn path=/trunk/; revision=633
Diffstat (limited to 'giscanner/ast.py')
-rw-r--r-- | giscanner/ast.py | 52 |
1 files changed, 40 insertions, 12 deletions
diff --git a/giscanner/ast.py b/giscanner/ast.py index d4f784d2..db1df440 100644 --- a/giscanner/ast.py +++ b/giscanner/ast.py @@ -109,6 +109,13 @@ type_names['pointer'] = TYPE_ANY type_names['constpointer'] = TYPE_ANY +# These types, when seen by reference, are converted into an Array() +# by default +default_array_types = {} +default_array_types['uint8*'] = TYPE_UINT8 +default_array_types['char**'] = TYPE_STRING + + def type_name_from_ctype(ctype): return type_names.get(ctype, ctype) @@ -161,6 +168,39 @@ class Type(Node): self.resolved = False +class Array(Type): + + def __init__(self, name, ctype, element_type): + Type.__init__(self, name, ctype) + self.element_type = element_type + self.zeroterminated = True + self.length_param_index = -1 + + def __repr__(self): + return 'Array(%r of %r)' % (self.name, self.element_type, ) + + +class List(Type): + + def __init__(self, name, ctype, element_type): + Type.__init__(self, name, ctype) + self.element_type = element_type + + def __repr__(self): + return 'List(%r of %r)' % (self.name, self.element_type, ) + + +class Map(Type): + + def __init__(self, name, ctype, key_type, value_type): + Type.__init__(self, name, ctype) + self.key_type = key_type + self.value_type = value_type + + def __repr__(self): + return 'Map(%r <%r,%r.)' % (self.name, self.key_type, self.value_type) + + class Alias(Node): def __init__(self, name, target, ctype=None): @@ -315,18 +355,6 @@ class Callback(Node): self.name, self.retval, self.parameters) -class Sequence(Type): - # Subclass, because a Sequence is a kind of Type - - def __init__(self, name, ctype, element_type): - Type.__init__(self, name, ctype) - self.element_type = element_type - self.transfer = False - - def __repr__(self): - return 'Sequence(%r of %r)' % (self.name, self.element_type, ) - - class Union(Node): def __init__(self, name, symbol): |