summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorLucas Rocha <lucasr@gnome.org>2008-10-11 18:33:43 +0000
committerLucas Almeida Rocha <lucasr@src.gnome.org>2008-10-11 18:33:43 +0000
commit0be08ed820506a63b5a9342d52d695f977934145 (patch)
tree2955cbd94fba25494a18deedbf176a88e41a84a4 /tools
parentf1be097d3be66639374c160225f01cfd42275953 (diff)
downloadgobject-introspection-0be08ed820506a63b5a9342d52d695f977934145.tar.gz
Bug 554854: The --typelib-xml and --inject options should reuse giscanner
2008-10-11 Lucas Rocha <lucasr@gnome.org> Bug 554854: The --typelib-xml and --inject options should reuse giscanner parser/writer. * giscanner/ast.py: add constructor list to Struct and Union. Add new param in Return's contructor to define transfer. * giscanner/girparser.py: several additions to the parser in order to have parsing all nodes of the gir xml files. * tools/g-ir-scanner (typelib_xml_strip, inject): use gir parser and writer in --inject and --typelib-xml options. * giscanner/xmlwriter.py: ignore empty attributes instead of raising an error as this basically exposes a bug in GIRParser. This should be reverted as soon as the parser is fixed. svn path=/trunk/; revision=665
Diffstat (limited to 'tools')
-rwxr-xr-xtools/g-ir-scanner25
1 files changed, 19 insertions, 6 deletions
diff --git a/tools/g-ir-scanner b/tools/g-ir-scanner
index 4eb5a6f9..88800d70 100755
--- a/tools/g-ir-scanner
+++ b/tools/g-ir-scanner
@@ -104,22 +104,31 @@ def _error(msg):
raise SystemExit('ERROR: %s' % (msg, ))
def typelib_xml_strip(path):
+ from giscanner.girparser import GIRParser
+ from giscanner.girwriter import GIRWriter
from giscanner.girparser import C_NS
c_ns_key = '{%s}' % (C_NS, )
- from xml.etree.cElementTree import parse
- doc = parse(open(path))
+ parser = GIRParser(path, initial_parse=False)
+ doc = parser.get_doc()
for node in doc.getiterator():
for attrib in list(node.attrib):
if attrib.startswith(c_ns_key):
del node.attrib[attrib]
- doc.write(sys.stdout)
+ parser.parse()
+ writer = GIRWriter(parser.get_namespace(),
+ parser.get_shared_libraries(),
+ parser.get_includes())
+ sys.stdout.write(writer.get_xml())
return 0
def inject(path, additions, outpath):
+ from giscanner.girparser import GIRParser
+ from giscanner.girwriter import GIRWriter
from xml.etree.cElementTree import parse
- doc = parse(open(path))
- root = doc.getroot()
+
+ parser = GIRParser(path, initial_parse=False)
+ root = parser.get_doc().getroot()
injectDoc = parse(open(additions))
for node in injectDoc.getroot():
injectPath = node.attrib['path']
@@ -128,8 +137,12 @@ def inject(path, additions, outpath):
raise ValueError("Couldn't find path %r" % (injectPath, ))
for child in node:
target.append(child)
+ parser.parse()
+ writer = GIRWriter(parser.get_namespace(),
+ parser.get_shared_libraries(),
+ parser.get_includes())
outf = open(outpath, 'w')
- doc.write(outf)
+ outf.write(writer.get_xml())
outf.close()
return 0