diff options
author | Johan Dahlin <jdahlin@async.com.br> | 2008-04-25 23:50:02 +0000 |
---|---|---|
committer | Johan Dahlin <johan@src.gnome.org> | 2008-04-25 23:50:02 +0000 |
commit | 497c5eebcbf4af86ccca15aa87b4be28e76d638c (patch) | |
tree | 07c5de63d35f686f314d265b3e31ce08eeca9ce5 /giscanner/sourcescanner.py | |
parent | 6296ff6bc14c00a016ce809e595f4c0a96750828 (diff) | |
download | gobject-introspection-497c5eebcbf4af86ccca15aa87b4be28e76d638c.tar.gz |
Add support for virtual methods. Pair struct FooClass with struct Foo.
2008-04-25 Johan Dahlin <jdahlin@async.com.br>
* TODO:
* giscanner/gidlwriter.py:
* giscanner/giscannermodule.c (pygi_source_directive_new),
(directive_get_options), (pygi_source_symbol_new),
(symbol_get_base_type), (pygi_source_type_new),
(type_get_base_type), (type_get_child_list),
(pygi_source_scanner_get_symbols),
(pygi_source_scanner_get_directives):
* giscanner/gobjecttreebuilder.py:
* giscanner/sourcescanner.py:
* giscanner/treebuilder.py:
* tests/parser/foo-object.h:
Add support for virtual methods.
Pair struct FooClass with struct Foo.
Clean up the SourceScanner bindings a bit.
Add a testcase for virtual methods.
svn path=/trunk/; revision=226
Diffstat (limited to 'giscanner/sourcescanner.py')
-rw-r--r-- | giscanner/sourcescanner.py | 42 |
1 files changed, 36 insertions, 6 deletions
diff --git a/giscanner/sourcescanner.py b/giscanner/sourcescanner.py index c0b2044c..26f8dcf8 100644 --- a/giscanner/sourcescanner.py +++ b/giscanner/sourcescanner.py @@ -4,18 +4,48 @@ import subprocess import giscanner +class SourceType(object): + def __init__(self, scanner, stype): + self._scanner = scanner + self._stype = stype + + @property + def type(self): + return self._stype.type + + @property + def base_type(self): + if self._stype.base_type is not None: + return SourceType(self._scanner, self._stype.base_type) + + @property + def name(self): + return self._stype.name + + @property + def child_list(self): + for symbol in self._stype.child_list: + if symbol is None: + continue + yield SourceSymbol(self._scanner, symbol) + + class SourceSymbol(object): - def __init__(self, symbol, directives): + def __init__(self, scanner, symbol): + self._scanner = scanner self._symbol = symbol - self._directives = directives def directives(self): mapping = {} - for directive in self._directives: + for directive in self._scanner.get_directives(self._symbol.ident): mapping[directive.name] = directive.options return mapping @property + def const_int(self): + return self._symbol.const_int + + @property def ident(self): return self._symbol.ident @@ -25,7 +55,8 @@ class SourceSymbol(object): @property def base_type(self): - return self._symbol.base_type + if self._symbol.base_type is not None: + return SourceType(self._scanner, self._symbol.base_type) class SourceScanner(object): @@ -66,8 +97,7 @@ class SourceScanner(object): def get_symbols(self): for symbol in self._scanner.get_symbols(): - yield SourceSymbol( - symbol, self._scanner.get_directives(symbol.ident)) + yield SourceSymbol(self._scanner, symbol) def dump(self): print '-'*30 |