summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorColin Walters <walters@verbum.org>2013-02-24 12:07:28 -0500
committerColin Walters <walters@verbum.org>2013-02-24 12:13:50 -0500
commit046de5c3b5e23f4b0700e21dac2f0272bbee0f22 (patch)
tree53582ca777f078c056e42a8aeac4ba9a5295b60c
parentefde09fafc8248b8e37862f39d2b43cf3c1f2a57 (diff)
downloadgobject-introspection-046de5c3b5e23f4b0700e21dac2f0272bbee0f22.tar.gz
scanner: internals cleanup: Move c_includes to Namespace
Continuation of previous work.
-rw-r--r--giscanner/ast.py1
-rw-r--r--giscanner/girparser.py4
-rw-r--r--giscanner/girwriter.py12
-rwxr-xr-xgiscanner/scannermain.py6
4 files changed, 9 insertions, 14 deletions
diff --git a/giscanner/ast.py b/giscanner/ast.py
index 23a0c9e7..506643d0 100644
--- a/giscanner/ast.py
+++ b/giscanner/ast.py
@@ -374,6 +374,7 @@ class Namespace(object):
self.symbols = {} # Maps from function symbols -> Function
self.includes = set() # Include
self.shared_libraries = [] # str
+ self.c_includes = [] # 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 bae09b9a..5944cc41 100644
--- a/giscanner/girparser.py
+++ b/giscanner/girparser.py
@@ -70,9 +70,6 @@ class GIRParser(object):
def get_namespace(self):
return self._namespace
- def get_c_includes(self):
- return self._c_includes
-
def get_c_prefix(self):
return self._c_prefix
@@ -137,6 +134,7 @@ class GIRParser(object):
if 'shared-library' in ns.attrib:
self._namespace.shared_libraries = ns.attrib['shared-library'].split(',')
self._namespace.includes = self._includes
+ self._namespace.c_includes = self._c_includes
parser_methods = {
_corens('alias'): self._parse_alias,
diff --git a/giscanner/girwriter.py b/giscanner/girwriter.py
index e15ad51f..58169eba 100644
--- a/giscanner/girwriter.py
+++ b/giscanner/girwriter.py
@@ -30,21 +30,17 @@ COMPATIBLE_GIR_VERSION = '1.2'
class GIRWriter(XMLWriter):
- def __init__(self, namespace, pkgs, c_includes):
+ def __init__(self, namespace, pkgs):
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,
- c_includes)
+ self._write_repository(namespace, pkgs)
- def _write_repository(self, namespace,
- packages=None, c_includes=None):
+ def _write_repository(self, namespace, packages=None):
if packages is None:
packages = frozenset()
- if c_includes is None:
- c_includes = frozenset()
attrs = [
('version', COMPATIBLE_GIR_VERSION),
('xmlns', 'http://www.gtk.org/introspection/core/1.0'),
@@ -56,7 +52,7 @@ and/or use gtk-doc annotations. ''')
self._write_include(include)
for pkg in sorted(set(packages)):
self._write_pkgconfig_pkg(pkg)
- for c_include in sorted(set(c_includes)):
+ for c_include in sorted(set(namespace.c_includes)):
self._write_c_include(c_include)
self._namespace = namespace
self._write_namespace(namespace)
diff --git a/giscanner/scannermain.py b/giscanner/scannermain.py
index ccd828da..3d402fac 100755
--- a/giscanner/scannermain.py
+++ b/giscanner/scannermain.py
@@ -194,8 +194,7 @@ def passthrough_gir(path, f):
parser.parse(path)
writer = GIRWriter(parser.get_namespace(),
- parser.get_pkgconfig_packages(),
- parser.get_c_includes())
+ parser.get_pkgconfig_packages())
f.write(writer.get_xml())
def test_codegen(optstring):
@@ -473,8 +472,9 @@ def scanner_main(args):
else:
exported_packages = options.packages
+ transformer.namespace.c_includes = options.c_includes
writer = Writer(transformer.namespace,
- exported_packages, options.c_includes)
+ exported_packages)
data = writer.get_xml()
write_output(data, options)