Work around g-ir-scanner problem with Gdk.Rectangle

g-ir-scanner is currently buggy and confuses the Gdk.Rectangle alias
with MetaRectangle. Since this is moderately hard to fix in
gobject-introspection and the fix would conflict with in-progress
changes, work around by doing a 'sed job' on the generated Meta.gir.

https://bugzilla.gnome.org/show_bug.cgi?id=623640
This commit is contained in:
Owen W. Taylor 2010-07-05 17:08:36 -04:00
parent ab0d57d6ca
commit 174caf0016
2 changed files with 26 additions and 1 deletions

View File

@ -210,8 +210,12 @@ Shell-0.1.gir: $(mutter) $(G_IR_SCANNER) St-1.0.gir libgnome-shell.la Makefile
$(addprefix $(srcdir)/,$(libgnome_shell_la_gir_sources)) \
$(libgnome_shell_la_CPPFLAGS) \
-I $(srcdir) \
-o $@
-o $@.tmp && \
$(PYTHON) $(srcdir)/fix-meta-rectangle.py $@.tmp $@.tmp2 && \
rm $@.tmp && \
mv $@.tmp2 $@
CLEANFILES += Shell-0.1.gir
EXTRA_DIST += fix-meta-rectangle.py
# The dependency on libgnome-shell.la here is because g-ir-compiler opens it
# (not the fake library, since we've already done the rewriting)

21
src/fix-meta-rectangle.py Executable file
View File

@ -0,0 +1,21 @@
#!/usr/bin/python
import re
import sys
# gobject-introspection currently has a bug where an alias like
# 'typedef GdkRectangle cairo_rect_int_t' is stored un-namespaced,
# so it is taken to apply to all *Rectangle types. Fixing this
# requires a significant rework of g-ir-scanner, so for the moment
# we fix up the output using this script.
#
# https://bugzilla.gnome.org/show_bug.cgi?id=622609
GDK_RECTANGLE = re.compile(r'Gdk\.Rectangle')
META_RECTANGLE = re.compile(r'MetaRectangle')
i = open(sys.argv[1], 'r')
o = open(sys.argv[2], 'w')
for line in i:
if GDK_RECTANGLE.search(line) and META_RECTANGLE.search(line):
line = re.sub('Gdk.Rectangle', 'Meta.Rectangle', line)
o.write(line)