[gobject-introspection] scanner: internals cleanup: Move c_includes to Namespace



commit c0ebb1e9888ee745437e87482d0b89c30cab355f
Author: Colin Walters <walters verbum org>
Date:   Sun Feb 24 12:07:28 2013 -0500

    scanner: internals cleanup: Move c_includes to Namespace
    
    Continuation of previous work.

 giscanner/ast.py         |    1 +
 giscanner/girparser.py   |    4 +---
 giscanner/girwriter.py   |   12 ++++--------
 giscanner/scannermain.py |    6 +++---
 4 files changed, 9 insertions(+), 14 deletions(-)
---
diff --git a/giscanner/ast.py b/giscanner/ast.py
index 23a0c9e..506643d 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 bae09b9..5944cc4 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 e15ad51..58169eb 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 ccd828d..3d402fa 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)


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]