summaryrefslogtreecommitdiff
path: root/giscanner/girwriter.py
diff options
context:
space:
mode:
authorColin Walters <walters@verbum.org>2009-02-12 17:40:08 -0500
committerColin Walters <walters@verbum.org>2009-03-17 16:28:30 -0400
commit5dfa997724551ed163fefc11782b7163db3be378 (patch)
tree3e7e5cabcecd27e1ab10b3db083a5e944d79b4fd /giscanner/girwriter.py
parente9dcc3cfb985292b5ff96772b73029a32b18ff11 (diff)
downloadgobject-introspection-5dfa997724551ed163fefc11782b7163db3be378.tar.gz
Bug 564016 - Add c:prefix to .gir
This has a few use cases; the main one in mind right now is that when we place this in the .typelib as well, we can use it to optimize lookups based on GType names, by skipping entirely typelibs whose c:prefix is not a prefix of the target type lookup.
Diffstat (limited to 'giscanner/girwriter.py')
-rw-r--r--giscanner/girwriter.py14
1 files changed, 8 insertions, 6 deletions
diff --git a/giscanner/girwriter.py b/giscanner/girwriter.py
index e30bc6b9..ddd562cd 100644
--- a/giscanner/girwriter.py
+++ b/giscanner/girwriter.py
@@ -35,16 +35,17 @@ from .xmlwriter import XMLWriter
class GIRWriter(XMLWriter):
- def __init__(self, namespace, shlibs, includes, pkgs, c_includes):
+ def __init__(self, namespace, shlibs, includes, pkgs, c_includes, cprefix):
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, shlibs, includes, pkgs, c_includes)
+ self._write_repository(namespace, shlibs, includes, pkgs,
+ c_includes, cprefix)
def _write_repository(self, namespace, shlibs, includes=None,
- packages=None, c_includes=None):
+ packages=None, c_includes=None, cprefix=None):
if includes is None:
includes = frozenset()
if packages is None:
@@ -64,7 +65,7 @@ and/or use gtk-doc annotations. ''')
self._write_pkgconfig_pkg(pkg)
for c_include in sorted(set(c_includes)):
self._write_c_include(c_include)
- self._write_namespace(namespace, shlibs)
+ self._write_namespace(namespace, shlibs, cprefix)
def _write_include(self, include):
attrs = [('name', include.name), ('version', include.version)]
@@ -78,7 +79,7 @@ and/or use gtk-doc annotations. ''')
attrs = [('name', c_include)]
self.write_tag('c:include', attrs)
- def _write_namespace(self, namespace, shlibs):
+ def _write_namespace(self, namespace, shlibs, cprefix):
libraries = []
for l in shlibs:
found_libname = find_library(l)
@@ -88,7 +89,8 @@ and/or use gtk-doc annotations. ''')
attrs = [('name', namespace.name),
('version', namespace.version),
- ('shared-library', ','.join(libraries))]
+ ('shared-library', ','.join(libraries)),
+ ('c:prefix', cprefix)]
with self.tagcontext('namespace', attrs):
# We define a custom sorting function here because
# we want aliases to be first. They're a bit