diff options
author | Colin Walters <walters@verbum.org> | 2013-02-24 12:07:28 -0500 |
---|---|---|
committer | Colin Walters <walters@verbum.org> | 2013-02-26 16:25:11 -0500 |
commit | f17dfbe3e65acd9274c2f98292362b0824564e0d (patch) | |
tree | 6af18d5fa7831f67218ad4187dd32d184d806d2d /giscanner | |
parent | c0ebb1e9888ee745437e87482d0b89c30cab355f (diff) | |
download | gobject-introspection-f17dfbe3e65acd9274c2f98292362b0824564e0d.tar.gz |
scanner: internals cleanup: Move pkgconfig list to Namespace
Continuation of previous work.
Diffstat (limited to 'giscanner')
-rw-r--r-- | giscanner/ast.py | 1 | ||||
-rw-r--r-- | giscanner/girparser.py | 7 | ||||
-rw-r--r-- | giscanner/girwriter.py | 10 | ||||
-rwxr-xr-x | giscanner/scannermain.py | 7 | ||||
-rw-r--r-- | giscanner/transformer.py | 2 |
5 files changed, 10 insertions, 17 deletions
diff --git a/giscanner/ast.py b/giscanner/ast.py index 506643d0..58540912 100644 --- a/giscanner/ast.py +++ b/giscanner/ast.py @@ -375,6 +375,7 @@ class Namespace(object): self.includes = set() # Include self.shared_libraries = [] # str self.c_includes = [] # str + self.exported_packages = [] # str def type_from_name(self, name, ctype=None): """Backwards compatibility method for older .gir files, which diff --git a/giscanner/girparser.py b/giscanner/girparser.py index 5944cc41..63a3fd02 100644 --- a/giscanner/girparser.py +++ b/giscanner/girparser.py @@ -46,7 +46,6 @@ class GIRParser(object): def __init__(self, types_only=False): self._types_only = types_only - self._pkgconfig_packages = set() self._namespace = None self._filename_stack = [] @@ -73,11 +72,6 @@ class GIRParser(object): def get_c_prefix(self): return self._c_prefix - def get_pkgconfig_packages(self): - if not hasattr(self, '_pkgconfig_packages'): - self._pkgconfig_packages = [] - return self._pkgconfig_packages - # Private def _find_first_child(self, node, name_or_names): @@ -135,6 +129,7 @@ class GIRParser(object): self._namespace.shared_libraries = ns.attrib['shared-library'].split(',') self._namespace.includes = self._includes self._namespace.c_includes = self._c_includes + self._namespace.exported_packages = self._pkgconfig_packages parser_methods = { _corens('alias'): self._parse_alias, diff --git a/giscanner/girwriter.py b/giscanner/girwriter.py index 58169eba..d6b3485b 100644 --- a/giscanner/girwriter.py +++ b/giscanner/girwriter.py @@ -30,17 +30,15 @@ COMPATIBLE_GIR_VERSION = '1.2' class GIRWriter(XMLWriter): - def __init__(self, namespace, pkgs): + def __init__(self, namespace): super(GIRWriter, self).__init__() self.write_comment( '''This file was automatically generated from C sources - DO NOT EDIT! To affect the contents of this file, edit the original C definitions, and/or use gtk-doc annotations. ''') - self._write_repository(namespace, pkgs) + self._write_repository(namespace) - def _write_repository(self, namespace, packages=None): - if packages is None: - packages = frozenset() + def _write_repository(self, namespace): attrs = [ ('version', COMPATIBLE_GIR_VERSION), ('xmlns', 'http://www.gtk.org/introspection/core/1.0'), @@ -50,7 +48,7 @@ and/or use gtk-doc annotations. ''') with self.tagcontext('repository', attrs): for include in sorted(namespace.includes): self._write_include(include) - for pkg in sorted(set(packages)): + for pkg in sorted(set(namespace.exported_packages)): self._write_pkgconfig_pkg(pkg) for c_include in sorted(set(namespace.c_includes)): self._write_c_include(c_include) diff --git a/giscanner/scannermain.py b/giscanner/scannermain.py index 3d402fac..5fa370ce 100755 --- a/giscanner/scannermain.py +++ b/giscanner/scannermain.py @@ -193,8 +193,7 @@ def passthrough_gir(path, f): parser = GIRParser() parser.parse(path) - writer = GIRWriter(parser.get_namespace(), - parser.get_pkgconfig_packages()) + writer = GIRWriter(parser.get_namespace()) f.write(writer.get_xml()) def test_codegen(optstring): @@ -473,8 +472,8 @@ def scanner_main(args): exported_packages = options.packages transformer.namespace.c_includes = options.c_includes - writer = Writer(transformer.namespace, - exported_packages) + transformer.namespace.exported_packages = exported_packages + writer = Writer(transformer.namespace) data = writer.get_xml() write_output(data, options) diff --git a/giscanner/transformer.py b/giscanner/transformer.py index 4c008da1..e8cbf3d9 100644 --- a/giscanner/transformer.py +++ b/giscanner/transformer.py @@ -210,7 +210,7 @@ None.""" self._parse_include(dep_filename) if not uninstalled: - for pkg in parser.get_pkgconfig_packages(): + for pkg in parser.get_namespace().exported_packages: self._pkg_config_packages.add(pkg) namespace = parser.get_namespace() self._parsed_includes[namespace.name] = namespace |