gobject-introspection 2.0.0-x86-mingw32
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/Rakefile +118 -0
- data/ext/gobject-introspection/depend +10 -0
- data/ext/gobject-introspection/extconf.rb +97 -0
- data/ext/gobject-introspection/gobject_introspection.def +5 -0
- data/ext/gobject-introspection/rb-gi-arg-info.c +151 -0
- data/ext/gobject-introspection/rb-gi-argument.c +1015 -0
- data/ext/gobject-introspection/rb-gi-base-info.c +218 -0
- data/ext/gobject-introspection/rb-gi-boxed-info.c +48 -0
- data/ext/gobject-introspection/rb-gi-callable-info.c +104 -0
- data/ext/gobject-introspection/rb-gi-callback-info.c +48 -0
- data/ext/gobject-introspection/rb-gi-constant-info.c +77 -0
- data/ext/gobject-introspection/rb-gi-constructor-info.c +120 -0
- data/ext/gobject-introspection/rb-gi-conversions.h +116 -0
- data/ext/gobject-introspection/rb-gi-enum-info.c +145 -0
- data/ext/gobject-introspection/rb-gi-field-info.c +153 -0
- data/ext/gobject-introspection/rb-gi-flags-info.c +48 -0
- data/ext/gobject-introspection/rb-gi-function-info.c +658 -0
- data/ext/gobject-introspection/rb-gi-interface-info.c +222 -0
- data/ext/gobject-introspection/rb-gi-loader.c +162 -0
- data/ext/gobject-introspection/rb-gi-method-info.c +109 -0
- data/ext/gobject-introspection/rb-gi-object-info.c +345 -0
- data/ext/gobject-introspection/rb-gi-private.h +110 -0
- data/ext/gobject-introspection/rb-gi-property-info.c +77 -0
- data/ext/gobject-introspection/rb-gi-registered-type-info.c +86 -0
- data/ext/gobject-introspection/rb-gi-repository.c +164 -0
- data/ext/gobject-introspection/rb-gi-signal-info.c +77 -0
- data/ext/gobject-introspection/rb-gi-struct-info.c +190 -0
- data/ext/gobject-introspection/rb-gi-type-info.c +143 -0
- data/ext/gobject-introspection/rb-gi-type-tag.c +43 -0
- data/ext/gobject-introspection/rb-gi-types.h +71 -0
- data/ext/gobject-introspection/rb-gi-union-info.c +206 -0
- data/ext/gobject-introspection/rb-gi-unresolved-info.c +48 -0
- data/ext/gobject-introspection/rb-gi-value-info.c +57 -0
- data/ext/gobject-introspection/rb-gi-vfunc-info.c +91 -0
- data/ext/gobject-introspection/rb-gobject-introspection.c +44 -0
- data/ext/gobject-introspection/rb-gobject-introspection.h +57 -0
- data/extconf.rb +71 -0
- data/lib/1.9/gobject_introspection.so +0 -0
- data/lib/2.0/gobject_introspection.so +0 -0
- data/lib/gobject-introspection.rb +52 -0
- data/lib/gobject-introspection/callable-info.rb +91 -0
- data/lib/gobject-introspection/collection-reader.rb +34 -0
- data/lib/gobject-introspection/interface-info.rb +32 -0
- data/lib/gobject-introspection/loader.rb +328 -0
- data/lib/gobject-introspection/object-info.rb +33 -0
- data/lib/gobject-introspection/repository.rb +32 -0
- data/lib/gobject-introspection/struct-info.rb +28 -0
- data/lib/gobject-introspection/union-info.rb +28 -0
- data/test/gobject-introspection-test-utils.rb +26 -0
- data/test/run-test.rb +45 -0
- data/test/test-arg-info.rb +68 -0
- data/test/test-base-info.rb +31 -0
- data/test/test-boxed-info.rb +21 -0
- data/test/test-callable-info.rb +49 -0
- data/test/test-callback-info.rb +29 -0
- data/test/test-constant-info.rb +24 -0
- data/test/test-enum-info.rb +56 -0
- data/test/test-field-type.rb +42 -0
- data/test/test-flags-info.rb +27 -0
- data/test/test-function-info.rb +37 -0
- data/test/test-interface-info.rb +97 -0
- data/test/test-loader.rb +30 -0
- data/test/test-object-info.rb +131 -0
- data/test/test-property-info.rb +38 -0
- data/test/test-registered-type-info.rb +35 -0
- data/test/test-repository.rb +59 -0
- data/test/test-signal-info.rb +37 -0
- data/test/test-struct-info.rb +57 -0
- data/test/test-type-info.rb +62 -0
- data/test/test-type-tag.rb +29 -0
- data/test/test-union-info.rb +21 -0
- data/test/test-value-info.rb +28 -0
- data/test/test-vfunc-info.rb +42 -0
- data/vendor/local/bin/g-ir-compiler.exe +0 -0
- data/vendor/local/bin/g-ir-generate.exe +0 -0
- data/vendor/local/bin/libgirepository-1.0-1.dll +0 -0
- data/vendor/local/include/gobject-introspection-1.0/giarginfo.h +52 -0
- data/vendor/local/include/gobject-introspection-1.0/gibaseinfo.h +89 -0
- data/vendor/local/include/gobject-introspection-1.0/gicallableinfo.h +74 -0
- data/vendor/local/include/gobject-introspection-1.0/giconstantinfo.h +46 -0
- data/vendor/local/include/gobject-introspection-1.0/gienuminfo.h +56 -0
- data/vendor/local/include/gobject-introspection-1.0/gifieldinfo.h +52 -0
- data/vendor/local/include/gobject-introspection-1.0/gifunctioninfo.h +77 -0
- data/vendor/local/include/gobject-introspection-1.0/giinterfaceinfo.h +68 -0
- data/vendor/local/include/gobject-introspection-1.0/giobjectinfo.h +137 -0
- data/vendor/local/include/gobject-introspection-1.0/gipropertyinfo.h +44 -0
- data/vendor/local/include/gobject-introspection-1.0/giregisteredtypeinfo.h +53 -0
- data/vendor/local/include/gobject-introspection-1.0/girepository.h +179 -0
- data/vendor/local/include/gobject-introspection-1.0/girffi.h +80 -0
- data/vendor/local/include/gobject-introspection-1.0/gisignalinfo.h +45 -0
- data/vendor/local/include/gobject-introspection-1.0/gistructinfo.h +53 -0
- data/vendor/local/include/gobject-introspection-1.0/gitypeinfo.h +56 -0
- data/vendor/local/include/gobject-introspection-1.0/gitypelib.h +55 -0
- data/vendor/local/include/gobject-introspection-1.0/gitypes.h +453 -0
- data/vendor/local/include/gobject-introspection-1.0/giunioninfo.h +57 -0
- data/vendor/local/include/gobject-introspection-1.0/givfuncinfo.h +56 -0
- data/vendor/local/lib/girepository-1.0/DBus-1.0.typelib +0 -0
- data/vendor/local/lib/girepository-1.0/DBusGLib-1.0.typelib +0 -0
- data/vendor/local/lib/girepository-1.0/GIRepository-2.0.typelib +0 -0
- data/vendor/local/lib/girepository-1.0/GL-1.0.typelib +0 -0
- data/vendor/local/lib/girepository-1.0/GLib-2.0.typelib +0 -0
- data/vendor/local/lib/girepository-1.0/GModule-2.0.typelib +0 -0
- data/vendor/local/lib/girepository-1.0/GObject-2.0.typelib +0 -0
- data/vendor/local/lib/girepository-1.0/Gio-2.0.typelib +0 -0
- data/vendor/local/lib/girepository-1.0/cairo-1.0.typelib +0 -0
- data/vendor/local/lib/girepository-1.0/fontconfig-2.0.typelib +0 -0
- data/vendor/local/lib/girepository-1.0/freetype2-2.0.typelib +0 -0
- data/vendor/local/lib/girepository-1.0/libxml2-2.0.typelib +0 -0
- data/vendor/local/lib/girepository-1.0/xfixes-4.0.typelib +0 -0
- data/vendor/local/lib/girepository-1.0/xft-2.0.typelib +0 -0
- data/vendor/local/lib/girepository-1.0/xlib-2.0.typelib +0 -0
- data/vendor/local/lib/girepository-1.0/xrandr-1.3.typelib +0 -0
- data/vendor/local/lib/gobject-introspection/giscanner/__init__.py +24 -0
- data/vendor/local/lib/gobject-introspection/giscanner/__init__.pyc +0 -0
- data/vendor/local/lib/gobject-introspection/giscanner/__init__.pyo +0 -0
- data/vendor/local/lib/gobject-introspection/giscanner/annotationmain.py +74 -0
- data/vendor/local/lib/gobject-introspection/giscanner/annotationmain.pyc +0 -0
- data/vendor/local/lib/gobject-introspection/giscanner/annotationmain.pyo +0 -0
- data/vendor/local/lib/gobject-introspection/giscanner/annotationparser.py +1204 -0
- data/vendor/local/lib/gobject-introspection/giscanner/annotationparser.pyc +0 -0
- data/vendor/local/lib/gobject-introspection/giscanner/annotationparser.pyo +0 -0
- data/vendor/local/lib/gobject-introspection/giscanner/ast.py +1100 -0
- data/vendor/local/lib/gobject-introspection/giscanner/ast.pyc +0 -0
- data/vendor/local/lib/gobject-introspection/giscanner/ast.pyo +0 -0
- data/vendor/local/lib/gobject-introspection/giscanner/cachestore.py +196 -0
- data/vendor/local/lib/gobject-introspection/giscanner/cachestore.pyc +0 -0
- data/vendor/local/lib/gobject-introspection/giscanner/cachestore.pyo +0 -0
- data/vendor/local/lib/gobject-introspection/giscanner/codegen.py +140 -0
- data/vendor/local/lib/gobject-introspection/giscanner/codegen.pyc +0 -0
- data/vendor/local/lib/gobject-introspection/giscanner/codegen.pyo +0 -0
- data/vendor/local/lib/gobject-introspection/giscanner/docmain.py +60 -0
- data/vendor/local/lib/gobject-introspection/giscanner/docmain.pyc +0 -0
- data/vendor/local/lib/gobject-introspection/giscanner/docmain.pyo +0 -0
- data/vendor/local/lib/gobject-introspection/giscanner/doctemplates/C/class.tmpl +2 -0
- data/vendor/local/lib/gobject-introspection/giscanner/doctemplates/C/constructor.tmpl +1 -0
- data/vendor/local/lib/gobject-introspection/giscanner/doctemplates/C/default.tmpl +1 -0
- data/vendor/local/lib/gobject-introspection/giscanner/doctemplates/C/enum.tmpl +2 -0
- data/vendor/local/lib/gobject-introspection/giscanner/doctemplates/C/function.tmpl +61 -0
- data/vendor/local/lib/gobject-introspection/giscanner/doctemplates/C/method.tmpl +1 -0
- data/vendor/local/lib/gobject-introspection/giscanner/doctemplates/C/namespace.tmpl +1 -0
- data/vendor/local/lib/gobject-introspection/giscanner/doctemplates/C/property.tmpl +5 -0
- data/vendor/local/lib/gobject-introspection/giscanner/doctemplates/C/record.tmpl +1 -0
- data/vendor/local/lib/gobject-introspection/giscanner/doctemplates/C/signal.tmpl +5 -0
- data/vendor/local/lib/gobject-introspection/giscanner/doctemplates/C/vfunc.tmpl +4 -0
- data/vendor/local/lib/gobject-introspection/giscanner/doctemplates/Gjs/class.tmpl +18 -0
- data/vendor/local/lib/gobject-introspection/giscanner/doctemplates/Gjs/constructor.tmpl +1 -0
- data/vendor/local/lib/gobject-introspection/giscanner/doctemplates/Gjs/default.tmpl +1 -0
- data/vendor/local/lib/gobject-introspection/giscanner/doctemplates/Gjs/enum.tmpl +13 -0
- data/vendor/local/lib/gobject-introspection/giscanner/doctemplates/Gjs/function.tmpl +48 -0
- data/vendor/local/lib/gobject-introspection/giscanner/doctemplates/Gjs/method.tmpl +1 -0
- data/vendor/local/lib/gobject-introspection/giscanner/doctemplates/Gjs/namespace.tmpl +2 -0
- data/vendor/local/lib/gobject-introspection/giscanner/doctemplates/Gjs/property.tmpl +10 -0
- data/vendor/local/lib/gobject-introspection/giscanner/doctemplates/Gjs/record.tmpl +2 -0
- data/vendor/local/lib/gobject-introspection/giscanner/doctemplates/Gjs/signal.tmpl +37 -0
- data/vendor/local/lib/gobject-introspection/giscanner/doctemplates/Gjs/vfunc.tmpl +27 -0
- data/vendor/local/lib/gobject-introspection/giscanner/doctemplates/Python/class.tmpl +17 -0
- data/vendor/local/lib/gobject-introspection/giscanner/doctemplates/Python/constructor.tmpl +1 -0
- data/vendor/local/lib/gobject-introspection/giscanner/doctemplates/Python/default.tmpl +1 -0
- data/vendor/local/lib/gobject-introspection/giscanner/doctemplates/Python/enum.tmpl +13 -0
- data/vendor/local/lib/gobject-introspection/giscanner/doctemplates/Python/function.tmpl +53 -0
- data/vendor/local/lib/gobject-introspection/giscanner/doctemplates/Python/method.tmpl +1 -0
- data/vendor/local/lib/gobject-introspection/giscanner/doctemplates/Python/namespace.tmpl +2 -0
- data/vendor/local/lib/gobject-introspection/giscanner/doctemplates/Python/property.tmpl +10 -0
- data/vendor/local/lib/gobject-introspection/giscanner/doctemplates/Python/record.tmpl +2 -0
- data/vendor/local/lib/gobject-introspection/giscanner/doctemplates/Python/signal.tmpl +42 -0
- data/vendor/local/lib/gobject-introspection/giscanner/doctemplates/Python/vfunc.tmpl +33 -0
- data/vendor/local/lib/gobject-introspection/giscanner/doctemplates/base.tmpl +29 -0
- data/vendor/local/lib/gobject-introspection/giscanner/doctemplates/class.tmpl +40 -0
- data/vendor/local/lib/gobject-introspection/giscanner/doctemplates/namespace.tmpl +19 -0
- data/vendor/local/lib/gobject-introspection/giscanner/docwriter.py +635 -0
- data/vendor/local/lib/gobject-introspection/giscanner/docwriter.pyc +0 -0
- data/vendor/local/lib/gobject-introspection/giscanner/docwriter.pyo +0 -0
- data/vendor/local/lib/gobject-introspection/giscanner/dumper.py +363 -0
- data/vendor/local/lib/gobject-introspection/giscanner/dumper.pyc +0 -0
- data/vendor/local/lib/gobject-introspection/giscanner/dumper.pyo +0 -0
- data/vendor/local/lib/gobject-introspection/giscanner/gdumpparser.py +551 -0
- data/vendor/local/lib/gobject-introspection/giscanner/gdumpparser.pyc +0 -0
- data/vendor/local/lib/gobject-introspection/giscanner/gdumpparser.pyo +0 -0
- data/vendor/local/lib/gobject-introspection/giscanner/girparser.py +581 -0
- data/vendor/local/lib/gobject-introspection/giscanner/girparser.pyc +0 -0
- data/vendor/local/lib/gobject-introspection/giscanner/girparser.pyo +0 -0
- data/vendor/local/lib/gobject-introspection/giscanner/girwriter.py +584 -0
- data/vendor/local/lib/gobject-introspection/giscanner/girwriter.pyc +0 -0
- data/vendor/local/lib/gobject-introspection/giscanner/girwriter.pyo +0 -0
- data/vendor/local/lib/gobject-introspection/giscanner/introspectablepass.py +236 -0
- data/vendor/local/lib/gobject-introspection/giscanner/introspectablepass.pyc +0 -0
- data/vendor/local/lib/gobject-introspection/giscanner/introspectablepass.pyo +0 -0
- data/vendor/local/lib/gobject-introspection/giscanner/libtoolimporter.py +76 -0
- data/vendor/local/lib/gobject-introspection/giscanner/libtoolimporter.pyc +0 -0
- data/vendor/local/lib/gobject-introspection/giscanner/libtoolimporter.pyo +0 -0
- data/vendor/local/lib/gobject-introspection/giscanner/maintransformer.py +1337 -0
- data/vendor/local/lib/gobject-introspection/giscanner/maintransformer.pyc +0 -0
- data/vendor/local/lib/gobject-introspection/giscanner/maintransformer.pyo +0 -0
- data/vendor/local/lib/gobject-introspection/giscanner/message.py +185 -0
- data/vendor/local/lib/gobject-introspection/giscanner/message.pyc +0 -0
- data/vendor/local/lib/gobject-introspection/giscanner/message.pyo +0 -0
- data/vendor/local/lib/gobject-introspection/giscanner/odict.py +50 -0
- data/vendor/local/lib/gobject-introspection/giscanner/odict.pyc +0 -0
- data/vendor/local/lib/gobject-introspection/giscanner/odict.pyo +0 -0
- data/vendor/local/lib/gobject-introspection/giscanner/scannermain.py +497 -0
- data/vendor/local/lib/gobject-introspection/giscanner/scannermain.pyc +0 -0
- data/vendor/local/lib/gobject-introspection/giscanner/scannermain.pyo +0 -0
- data/vendor/local/lib/gobject-introspection/giscanner/sectionparser.py +78 -0
- data/vendor/local/lib/gobject-introspection/giscanner/sectionparser.pyc +0 -0
- data/vendor/local/lib/gobject-introspection/giscanner/sectionparser.pyo +0 -0
- data/vendor/local/lib/gobject-introspection/giscanner/shlibs.py +132 -0
- data/vendor/local/lib/gobject-introspection/giscanner/shlibs.pyc +0 -0
- data/vendor/local/lib/gobject-introspection/giscanner/shlibs.pyo +0 -0
- data/vendor/local/lib/gobject-introspection/giscanner/sourcescanner.py +324 -0
- data/vendor/local/lib/gobject-introspection/giscanner/sourcescanner.pyc +0 -0
- data/vendor/local/lib/gobject-introspection/giscanner/sourcescanner.pyo +0 -0
- data/vendor/local/lib/gobject-introspection/giscanner/testcodegen.py +119 -0
- data/vendor/local/lib/gobject-introspection/giscanner/testcodegen.pyc +0 -0
- data/vendor/local/lib/gobject-introspection/giscanner/testcodegen.pyo +0 -0
- data/vendor/local/lib/gobject-introspection/giscanner/transformer.py +999 -0
- data/vendor/local/lib/gobject-introspection/giscanner/transformer.pyc +0 -0
- data/vendor/local/lib/gobject-introspection/giscanner/transformer.pyo +0 -0
- data/vendor/local/lib/gobject-introspection/giscanner/utils.py +141 -0
- data/vendor/local/lib/gobject-introspection/giscanner/utils.pyc +0 -0
- data/vendor/local/lib/gobject-introspection/giscanner/utils.pyo +0 -0
- data/vendor/local/lib/gobject-introspection/giscanner/xmlwriter.py +197 -0
- data/vendor/local/lib/gobject-introspection/giscanner/xmlwriter.pyc +0 -0
- data/vendor/local/lib/gobject-introspection/giscanner/xmlwriter.pyo +0 -0
- data/vendor/local/lib/libgirepository-1.0.a +0 -0
- data/vendor/local/lib/libgirepository-1.0.dll.a +0 -0
- data/vendor/local/lib/libgirepository-1.0.la +41 -0
- data/vendor/local/lib/pkgconfig/gobject-introspection-1.0.pc +26 -0
- data/vendor/local/lib/pkgconfig/gobject-introspection-no-export-1.0.pc +23 -0
- data/vendor/local/share/aclocal/introspection.m4 +96 -0
- data/vendor/local/share/gir-1.0/DBus-1.0.gir +32 -0
- data/vendor/local/share/gir-1.0/DBusGLib-1.0.gir +18 -0
- data/vendor/local/share/gir-1.0/GIRepository-2.0.gir +3833 -0
- data/vendor/local/share/gir-1.0/GL-1.0.gir +31 -0
- data/vendor/local/share/gir-1.0/GLib-2.0.gir +44304 -0
- data/vendor/local/share/gir-1.0/GModule-2.0.gir +184 -0
- data/vendor/local/share/gir-1.0/GObject-2.0.gir +13947 -0
- data/vendor/local/share/gir-1.0/Gio-2.0.gir +73619 -0
- data/vendor/local/share/gir-1.0/cairo-1.0.gir +70 -0
- data/vendor/local/share/gir-1.0/fontconfig-2.0.gir +18 -0
- data/vendor/local/share/gir-1.0/freetype2-2.0.gir +22 -0
- data/vendor/local/share/gir-1.0/libxml2-2.0.gir +25 -0
- data/vendor/local/share/gir-1.0/xfixes-4.0.gir +10 -0
- data/vendor/local/share/gir-1.0/xft-2.0.gir +23 -0
- data/vendor/local/share/gir-1.0/xlib-2.0.gir +67 -0
- data/vendor/local/share/gir-1.0/xrandr-1.3.gir +16 -0
- data/vendor/local/share/gobject-introspection-1.0/Makefile.introspection +166 -0
- data/vendor/local/share/gobject-introspection-1.0/gdump.c +564 -0
- data/vendor/local/share/gobject-introspection-1.0/tests/annotation.c +835 -0
- data/vendor/local/share/gobject-introspection-1.0/tests/annotation.h +198 -0
- data/vendor/local/share/gobject-introspection-1.0/tests/drawable.c +55 -0
- data/vendor/local/share/gobject-introspection-1.0/tests/drawable.h +33 -0
- data/vendor/local/share/gobject-introspection-1.0/tests/everything.c +1473 -0
- data/vendor/local/share/gobject-introspection-1.0/tests/everything.h +428 -0
- data/vendor/local/share/gobject-introspection-1.0/tests/foo.c +790 -0
- data/vendor/local/share/gobject-introspection-1.0/tests/foo.h +437 -0
- data/vendor/local/share/gobject-introspection-1.0/tests/gimarshallingtests.c +5256 -0
- data/vendor/local/share/gobject-introspection-1.0/tests/gimarshallingtests.h +1158 -0
- data/vendor/local/share/gobject-introspection-1.0/tests/regress.c +4009 -0
- data/vendor/local/share/gobject-introspection-1.0/tests/regress.h +944 -0
- data/vendor/local/share/gobject-introspection-1.0/tests/utility.c +45 -0
- data/vendor/local/share/gobject-introspection-1.0/tests/utility.h +95 -0
- data/vendor/local/share/gobject-introspection-1.0/tests/warnlib.c +33 -0
- data/vendor/local/share/gobject-introspection-1.0/tests/warnlib.h +36 -0
- data/vendor/local/share/license/gobject-introspection/AUTHORS +9 -0
- data/vendor/local/share/license/gobject-introspection/COPYING +12 -0
- data/vendor/local/share/man/man1/g-ir-compiler.1 +51 -0
- data/vendor/local/share/man/man1/g-ir-generate.1 +29 -0
- metadata +343 -0
Binary file
|
Binary file
|
@@ -0,0 +1,363 @@
|
|
1
|
+
# -*- Mode: Python -*-
|
2
|
+
# GObject-Introspection - a framework for introspecting GObject libraries
|
3
|
+
# Copyright (C) 2008 Colin Walters
|
4
|
+
# Copyright (C) 2008 Johan Dahlin
|
5
|
+
#
|
6
|
+
# This library is free software; you can redistribute it and/or
|
7
|
+
# modify it under the terms of the GNU Lesser General Public
|
8
|
+
# License as published by the Free Software Foundation; either
|
9
|
+
# version 2 of the License, or (at your option) any later version.
|
10
|
+
#
|
11
|
+
# This library is distributed in the hope that it will be useful,
|
12
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
14
|
+
# Lesser General Public License for more details.
|
15
|
+
#
|
16
|
+
# You should have received a copy of the GNU Lesser General Public
|
17
|
+
# License along with this library; if not, write to the
|
18
|
+
# Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
19
|
+
# Boston, MA 02111-1307, USA.
|
20
|
+
#
|
21
|
+
|
22
|
+
import os
|
23
|
+
import sys
|
24
|
+
import subprocess
|
25
|
+
import shutil
|
26
|
+
import tempfile
|
27
|
+
|
28
|
+
from .gdumpparser import IntrospectionBinary
|
29
|
+
from . import utils
|
30
|
+
|
31
|
+
# bugzilla.gnome.org/558436
|
32
|
+
# Compile a binary program which is then linked to a library
|
33
|
+
# we want to introspect, in order to call its get_type functions.
|
34
|
+
|
35
|
+
_PROGRAM_TEMPLATE = """/* This file is generated, do not edit */
|
36
|
+
#include <glib.h>
|
37
|
+
#include <string.h>
|
38
|
+
#include <stdlib.h>
|
39
|
+
|
40
|
+
%(gdump_include)s
|
41
|
+
|
42
|
+
int
|
43
|
+
main(int argc, char **argv)
|
44
|
+
{
|
45
|
+
GError *error = NULL;
|
46
|
+
const char *introspect_dump_prefix = "--introspect-dump=";
|
47
|
+
|
48
|
+
#if !GLIB_CHECK_VERSION(2,35,0)
|
49
|
+
g_type_init ();
|
50
|
+
#endif
|
51
|
+
|
52
|
+
%(init_sections)s
|
53
|
+
|
54
|
+
if (argc != 2 || !g_str_has_prefix (argv[1], introspect_dump_prefix))
|
55
|
+
{
|
56
|
+
g_printerr ("Usage: %%s --introspect-dump=input,output", argv[0]);
|
57
|
+
exit (1);
|
58
|
+
}
|
59
|
+
|
60
|
+
if (!dump_irepository (argv[1] + strlen(introspect_dump_prefix), &error))
|
61
|
+
{
|
62
|
+
g_printerr ("%%s\\n", error->message);
|
63
|
+
exit (1);
|
64
|
+
}
|
65
|
+
exit (0);
|
66
|
+
}
|
67
|
+
"""
|
68
|
+
|
69
|
+
|
70
|
+
class CompilerError(Exception):
|
71
|
+
pass
|
72
|
+
|
73
|
+
|
74
|
+
class LinkerError(Exception):
|
75
|
+
pass
|
76
|
+
|
77
|
+
|
78
|
+
class DumpCompiler(object):
|
79
|
+
|
80
|
+
def __init__(self, options, get_type_functions, error_quark_functions):
|
81
|
+
self._options = options
|
82
|
+
self._get_type_functions = get_type_functions
|
83
|
+
self._error_quark_functions = error_quark_functions
|
84
|
+
|
85
|
+
self._compiler_cmd = os.environ.get('CC', 'gcc')
|
86
|
+
self._linker_cmd = os.environ.get('CC', self._compiler_cmd)
|
87
|
+
self._pkgconfig_cmd = os.environ.get('PKG_CONFIG', 'pkg-config')
|
88
|
+
self._pkgconfig_msvc_flags = ''
|
89
|
+
# Enable the --msvc-syntax pkg-config flag when
|
90
|
+
# the Microsoft compiler is used
|
91
|
+
# (This is the other way to check whether Visual C++ is used subsequently)
|
92
|
+
if 'cl' in self._compiler_cmd:
|
93
|
+
self._pkgconfig_msvc_flags = '--msvc-syntax'
|
94
|
+
self._uninst_srcdir = os.environ.get(
|
95
|
+
'UNINSTALLED_INTROSPECTION_SRCDIR')
|
96
|
+
self._packages = ['gio-2.0 gmodule-2.0']
|
97
|
+
self._packages.extend(options.packages)
|
98
|
+
|
99
|
+
# Public API
|
100
|
+
|
101
|
+
def run(self):
|
102
|
+
# We have to use the current directory to work around Unix
|
103
|
+
# sysadmins who mount /tmp noexec
|
104
|
+
tmpdir = tempfile.mkdtemp('', 'tmp-introspect', dir=os.getcwd())
|
105
|
+
|
106
|
+
tpl_args = {}
|
107
|
+
if self._uninst_srcdir is not None:
|
108
|
+
gdump_path = os.path.join(self._uninst_srcdir, 'girepository', 'gdump.c')
|
109
|
+
else:
|
110
|
+
gdump_path = os.path.join(os.path.join(DATADIR), 'gobject-introspection-1.0',
|
111
|
+
'gdump.c')
|
112
|
+
if not os.path.isfile(gdump_path):
|
113
|
+
raise SystemExit("Couldn't find %r" % (gdump_path, ))
|
114
|
+
gdump_file = open(gdump_path)
|
115
|
+
gdump_contents = gdump_file.read()
|
116
|
+
gdump_file.close()
|
117
|
+
tpl_args['gdump_include'] = gdump_contents
|
118
|
+
tpl_args['init_sections'] = "\n".join(self._options.init_sections)
|
119
|
+
|
120
|
+
c_path = self._generate_tempfile(tmpdir, '.c')
|
121
|
+
f = open(c_path, 'w')
|
122
|
+
f.write(_PROGRAM_TEMPLATE % tpl_args)
|
123
|
+
|
124
|
+
# We need to reference our get_type and error_quark functions
|
125
|
+
# to make sure they are pulled in at the linking stage if the
|
126
|
+
# library is a static library rather than a shared library.
|
127
|
+
if len(self._get_type_functions) > 0:
|
128
|
+
for func in self._get_type_functions:
|
129
|
+
f.write("extern GType " + func + "(void);\n")
|
130
|
+
f.write("GType (*GI_GET_TYPE_FUNCS_[])(void) = {\n")
|
131
|
+
first = True
|
132
|
+
for func in self._get_type_functions:
|
133
|
+
if first:
|
134
|
+
first = False
|
135
|
+
else:
|
136
|
+
f.write(",\n")
|
137
|
+
f.write(" " + func)
|
138
|
+
f.write("\n};\n")
|
139
|
+
if len(self._error_quark_functions) > 0:
|
140
|
+
for func in self._error_quark_functions:
|
141
|
+
f.write("extern GQuark " + func + "(void);\n")
|
142
|
+
f.write("GQuark (*GI_ERROR_QUARK_FUNCS_[])(void) = {\n")
|
143
|
+
first = True
|
144
|
+
for func in self._error_quark_functions:
|
145
|
+
if first:
|
146
|
+
first = False
|
147
|
+
else:
|
148
|
+
f.write(",\n")
|
149
|
+
f.write(" " + func)
|
150
|
+
f.write("\n};\n")
|
151
|
+
f.close()
|
152
|
+
|
153
|
+
# Microsoft compilers generate intermediate .obj files
|
154
|
+
# during compilation, unlike .o files like GCC and others
|
155
|
+
if self._pkgconfig_msvc_flags:
|
156
|
+
o_path = self._generate_tempfile(tmpdir, '.obj')
|
157
|
+
else:
|
158
|
+
o_path = self._generate_tempfile(tmpdir, '.o')
|
159
|
+
|
160
|
+
if os.name == 'nt':
|
161
|
+
ext = 'exe'
|
162
|
+
else:
|
163
|
+
ext = ''
|
164
|
+
|
165
|
+
bin_path = self._generate_tempfile(tmpdir, ext)
|
166
|
+
|
167
|
+
try:
|
168
|
+
self._compile(o_path, c_path)
|
169
|
+
except CompilerError, e:
|
170
|
+
if not utils.have_debug_flag('save-temps'):
|
171
|
+
shutil.rmtree(tmpdir)
|
172
|
+
raise SystemExit('compilation of temporary binary failed:' + str(e))
|
173
|
+
|
174
|
+
try:
|
175
|
+
self._link(bin_path, o_path)
|
176
|
+
except LinkerError, e:
|
177
|
+
if not utils.have_debug_flag('save-temps'):
|
178
|
+
shutil.rmtree(tmpdir)
|
179
|
+
raise SystemExit('linking of temporary binary failed: ' + str(e))
|
180
|
+
|
181
|
+
return IntrospectionBinary([bin_path], tmpdir)
|
182
|
+
|
183
|
+
# Private API
|
184
|
+
|
185
|
+
def _generate_tempfile(self, tmpdir, suffix=''):
|
186
|
+
tmpl = '%s-%s%s' % (self._options.namespace_name,
|
187
|
+
self._options.namespace_version, suffix)
|
188
|
+
return os.path.join(tmpdir, tmpl)
|
189
|
+
|
190
|
+
def _run_pkgconfig(self, flag):
|
191
|
+
# Enable the --msvc-syntax pkg-config flag when
|
192
|
+
# the Microsoft compiler is used
|
193
|
+
if self._pkgconfig_msvc_flags:
|
194
|
+
cmd = [self._pkgconfig_cmd, self._pkgconfig_msvc_flags, flag]
|
195
|
+
else:
|
196
|
+
cmd = [self._pkgconfig_cmd, flag]
|
197
|
+
proc = subprocess.Popen(
|
198
|
+
cmd + self._packages,
|
199
|
+
stdout=subprocess.PIPE)
|
200
|
+
return proc.communicate()[0].split()
|
201
|
+
|
202
|
+
def _compile(self, output, *sources):
|
203
|
+
# Not strictly speaking correct, but easier than parsing shell
|
204
|
+
args = self._compiler_cmd.split()
|
205
|
+
# Do not add -Wall when using init code as we do not include any
|
206
|
+
# header of the library being introspected
|
207
|
+
if self._compiler_cmd == 'gcc' and not self._options.init_sections:
|
208
|
+
args.append('-Wall')
|
209
|
+
# The Microsoft compiler uses different option flags for
|
210
|
+
# silencing warnings on deprecated function usage
|
211
|
+
if self._pkgconfig_msvc_flags:
|
212
|
+
args.append("-wd4996")
|
213
|
+
else:
|
214
|
+
args.append("-Wno-deprecated-declarations")
|
215
|
+
pkgconfig_flags = self._run_pkgconfig('--cflags')
|
216
|
+
args.extend(pkgconfig_flags)
|
217
|
+
cflags = os.environ.get('CFLAGS', '')
|
218
|
+
for cflag in cflags.split():
|
219
|
+
args.append(cflag)
|
220
|
+
for include in self._options.cpp_includes:
|
221
|
+
args.append('-I' + include)
|
222
|
+
# The Microsoft compiler uses different option flags for
|
223
|
+
# compilation result output
|
224
|
+
if self._pkgconfig_msvc_flags:
|
225
|
+
args.extend(['-c', '-Fe'+output, '-Fo'+output])
|
226
|
+
else:
|
227
|
+
args.extend(['-c', '-o', output])
|
228
|
+
for source in sources:
|
229
|
+
if not os.path.exists(source):
|
230
|
+
raise CompilerError(
|
231
|
+
"Could not find c source file: %s" % (source, ))
|
232
|
+
args.extend(list(sources))
|
233
|
+
if not self._options.quiet:
|
234
|
+
print "g-ir-scanner: compile: %s" % (
|
235
|
+
subprocess.list2cmdline(args), )
|
236
|
+
sys.stdout.flush()
|
237
|
+
try:
|
238
|
+
subprocess.check_call(args)
|
239
|
+
except subprocess.CalledProcessError, e:
|
240
|
+
raise CompilerError(e)
|
241
|
+
|
242
|
+
def _link(self, output, *sources):
|
243
|
+
args = []
|
244
|
+
libtool = utils.get_libtool_command(self._options)
|
245
|
+
if libtool:
|
246
|
+
args.extend(libtool)
|
247
|
+
args.append('--mode=link')
|
248
|
+
args.append('--tag=CC')
|
249
|
+
if self._options.quiet:
|
250
|
+
args.append('--silent')
|
251
|
+
|
252
|
+
args.extend(self._linker_cmd.split())
|
253
|
+
# We can use -o for the Microsoft compiler/linker,
|
254
|
+
# but it is considered deprecated usage with that
|
255
|
+
if self._pkgconfig_msvc_flags:
|
256
|
+
args.extend(['-Fe'+output])
|
257
|
+
else:
|
258
|
+
args.extend(['-o', output])
|
259
|
+
if libtool:
|
260
|
+
if os.name == 'nt':
|
261
|
+
args.append('-export-all-symbols')
|
262
|
+
else:
|
263
|
+
args.append('-export-dynamic')
|
264
|
+
|
265
|
+
cflags = os.environ.get('CFLAGS', '')
|
266
|
+
for cflag in cflags.split():
|
267
|
+
args.append(cflag)
|
268
|
+
ldflags = os.environ.get('LDFLAGS', '')
|
269
|
+
for ldflag in ldflags.split():
|
270
|
+
args.append(ldflag)
|
271
|
+
|
272
|
+
# Make sure to list the library to be introspected first since it's
|
273
|
+
# likely to be uninstalled yet and we want the uninstalled RPATHs have
|
274
|
+
# priority (or we might run with installed library that is older)
|
275
|
+
|
276
|
+
for source in sources:
|
277
|
+
if not os.path.exists(source):
|
278
|
+
raise CompilerError(
|
279
|
+
"Could not find object file: %s" % (source, ))
|
280
|
+
args.extend(list(sources))
|
281
|
+
|
282
|
+
if not self._options.external_library:
|
283
|
+
self._add_link_internal_args(args, libtool)
|
284
|
+
else:
|
285
|
+
self._add_link_external_args(args)
|
286
|
+
|
287
|
+
if not self._options.quiet:
|
288
|
+
print "g-ir-scanner: link: %s" % (
|
289
|
+
subprocess.list2cmdline(args), )
|
290
|
+
sys.stdout.flush()
|
291
|
+
try:
|
292
|
+
subprocess.check_call(args)
|
293
|
+
except subprocess.CalledProcessError, e:
|
294
|
+
raise LinkerError(e)
|
295
|
+
|
296
|
+
def _add_link_internal_args(self, args, libtool):
|
297
|
+
# An "internal" link is where the library to be introspected
|
298
|
+
# is being built in the current directory.
|
299
|
+
|
300
|
+
# Search the current directory first
|
301
|
+
# (This flag is not supported nor needed for Visual C++)
|
302
|
+
if self._pkgconfig_msvc_flags == '':
|
303
|
+
args.append('-L.')
|
304
|
+
|
305
|
+
# https://bugzilla.gnome.org/show_bug.cgi?id=625195
|
306
|
+
if not libtool:
|
307
|
+
# We don't have -Wl,-rpath for Visual C++, and that's
|
308
|
+
# going to cause a problem. Instead, link to internal
|
309
|
+
# libraries by deducing the .lib file name using
|
310
|
+
# the namespace name and version
|
311
|
+
if self._pkgconfig_msvc_flags:
|
312
|
+
if self._options.namespace_version:
|
313
|
+
args.append(str.lower(self._options.namespace_name) +
|
314
|
+
'-' +
|
315
|
+
self._options.namespace_version+'.lib')
|
316
|
+
else:
|
317
|
+
args.append(str.lower(self._options.namespace_name)+'.lib')
|
318
|
+
else:
|
319
|
+
args.append('-Wl,-rpath=.')
|
320
|
+
|
321
|
+
for library in self._options.libraries:
|
322
|
+
# Visual C++: We have the needed .lib files now, and we need to link
|
323
|
+
# to .lib files, not the .dll as the --library option specifies the
|
324
|
+
# .dll(s) the .gir file refers to
|
325
|
+
if self._pkgconfig_msvc_flags == '':
|
326
|
+
if library.endswith(".la"): # explicitly specified libtool library
|
327
|
+
args.append(library)
|
328
|
+
else:
|
329
|
+
args.append('-l' + library)
|
330
|
+
|
331
|
+
for library_path in self._options.library_paths:
|
332
|
+
# Not used/needed on Visual C++, and -Wl,-rpath options
|
333
|
+
# will cause grief
|
334
|
+
if self._pkgconfig_msvc_flags == '':
|
335
|
+
args.append('-L' + library_path)
|
336
|
+
if os.path.isabs(library_path):
|
337
|
+
if libtool:
|
338
|
+
args.append('-rpath')
|
339
|
+
args.append(library_path)
|
340
|
+
else:
|
341
|
+
args.append('-Wl,-rpath=' + library_path)
|
342
|
+
|
343
|
+
args.extend(self._run_pkgconfig('--libs'))
|
344
|
+
|
345
|
+
def _add_link_external_args(self, args):
|
346
|
+
# An "external" link is where the library to be introspected
|
347
|
+
# is installed on the system; this case is used for the scanning
|
348
|
+
# of GLib in gobject-introspection itself.
|
349
|
+
|
350
|
+
args.extend(self._run_pkgconfig('--libs'))
|
351
|
+
for library in self._options.libraries:
|
352
|
+
# The --library option on Windows pass in the .dll file(s) the
|
353
|
+
# .gir files refer to, so don't link to them on Visual C++
|
354
|
+
if self._pkgconfig_msvc_flags == '':
|
355
|
+
if library.endswith(".la"): # explicitly specified libtool library
|
356
|
+
args.append(library)
|
357
|
+
else:
|
358
|
+
args.append('-l' + library)
|
359
|
+
|
360
|
+
def compile_introspection_binary(options, get_type_functions,
|
361
|
+
error_quark_functions):
|
362
|
+
dc = DumpCompiler(options, get_type_functions, error_quark_functions)
|
363
|
+
return dc.run()
|
Binary file
|
Binary file
|
@@ -0,0 +1,551 @@
|
|
1
|
+
# -*- Mode: Python -*-
|
2
|
+
# GObject-Introspection - a framework for introspecting GObject libraries
|
3
|
+
# Copyright (C) 2008 Johan Dahlin
|
4
|
+
#
|
5
|
+
# This library is free software; you can redistribute it and/or
|
6
|
+
# modify it under the terms of the GNU Lesser General Public
|
7
|
+
# License as published by the Free Software Foundation; either
|
8
|
+
# version 2 of the License, or (at your option) any later version.
|
9
|
+
#
|
10
|
+
# This library is distributed in the hope that it will be useful,
|
11
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
12
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
13
|
+
# Lesser General Public License for more details.
|
14
|
+
#
|
15
|
+
# You should have received a copy of the GNU Lesser General Public
|
16
|
+
# License along with this library; if not, write to the
|
17
|
+
# Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
18
|
+
# Boston, MA 02111-1307, USA.
|
19
|
+
#
|
20
|
+
|
21
|
+
import os
|
22
|
+
import sys
|
23
|
+
import tempfile
|
24
|
+
import shutil
|
25
|
+
import subprocess
|
26
|
+
from xml.etree.cElementTree import parse
|
27
|
+
|
28
|
+
from . import ast
|
29
|
+
from . import message
|
30
|
+
from . import utils
|
31
|
+
from .transformer import TransformerException
|
32
|
+
from .utils import to_underscores
|
33
|
+
|
34
|
+
# GParamFlags
|
35
|
+
G_PARAM_READABLE = 1 << 0
|
36
|
+
G_PARAM_WRITABLE = 1 << 1
|
37
|
+
G_PARAM_CONSTRUCT = 1 << 2
|
38
|
+
G_PARAM_CONSTRUCT_ONLY = 1 << 3
|
39
|
+
G_PARAM_LAX_VALIDATION = 1 << 4
|
40
|
+
G_PARAM_STATIC_NAME = 1 << 5
|
41
|
+
G_PARAM_STATIC_NICK = 1 << 6
|
42
|
+
G_PARAM_STATIC_BLURB = 1 << 7
|
43
|
+
|
44
|
+
|
45
|
+
class IntrospectionBinary(object):
|
46
|
+
|
47
|
+
def __init__(self, args, tmpdir=None):
|
48
|
+
self.args = args
|
49
|
+
if tmpdir is None:
|
50
|
+
self.tmpdir = tempfile.mkdtemp('', 'tmp-introspect')
|
51
|
+
else:
|
52
|
+
self.tmpdir = tmpdir
|
53
|
+
|
54
|
+
|
55
|
+
class Unresolved(object):
|
56
|
+
|
57
|
+
def __init__(self, target):
|
58
|
+
self.target = target
|
59
|
+
|
60
|
+
|
61
|
+
class UnknownTypeError(Exception):
|
62
|
+
pass
|
63
|
+
|
64
|
+
|
65
|
+
class GDumpParser(object):
|
66
|
+
|
67
|
+
def __init__(self, transformer):
|
68
|
+
self._transformer = transformer
|
69
|
+
self._namespace = transformer.namespace
|
70
|
+
self._binary = None
|
71
|
+
self._get_type_functions = []
|
72
|
+
self._error_quark_functions = []
|
73
|
+
self._error_domains = {}
|
74
|
+
self._boxed_types = {}
|
75
|
+
self._private_internal_types = {}
|
76
|
+
|
77
|
+
# Public API
|
78
|
+
|
79
|
+
def init_parse(self):
|
80
|
+
"""Do parsing steps that don't involve the introspection binary
|
81
|
+
|
82
|
+
This does enough work that get_type_functions() can be called.
|
83
|
+
|
84
|
+
"""
|
85
|
+
|
86
|
+
# First pass: parsing
|
87
|
+
for node in self._namespace.itervalues():
|
88
|
+
if isinstance(node, ast.Function):
|
89
|
+
self._initparse_function(node)
|
90
|
+
|
91
|
+
if self._namespace.name == 'GObject' or self._namespace.name == 'GLib':
|
92
|
+
for node in self._namespace.itervalues():
|
93
|
+
if isinstance(node, ast.Record):
|
94
|
+
self._initparse_gobject_record(node)
|
95
|
+
|
96
|
+
def get_get_type_functions(self):
|
97
|
+
return self._get_type_functions
|
98
|
+
|
99
|
+
def get_error_quark_functions(self):
|
100
|
+
return self._error_quark_functions
|
101
|
+
|
102
|
+
def set_introspection_binary(self, binary):
|
103
|
+
self._binary = binary
|
104
|
+
|
105
|
+
def parse(self):
|
106
|
+
"""Do remaining parsing steps requiring introspection binary"""
|
107
|
+
|
108
|
+
# Get all the GObject data by passing our list of get_type
|
109
|
+
# functions to the compiled binary, returning an XML blob.
|
110
|
+
tree = self._execute_binary_get_tree()
|
111
|
+
root = tree.getroot()
|
112
|
+
for child in root:
|
113
|
+
if child.tag == 'error-quark':
|
114
|
+
self._introspect_error_quark(child)
|
115
|
+
else:
|
116
|
+
self._introspect_type(child)
|
117
|
+
|
118
|
+
# Pair up boxed types and class records
|
119
|
+
for name, boxed in self._boxed_types.iteritems():
|
120
|
+
self._pair_boxed_type(boxed)
|
121
|
+
for node in self._namespace.itervalues():
|
122
|
+
if isinstance(node, (ast.Class, ast.Interface)):
|
123
|
+
self._find_class_record(node)
|
124
|
+
|
125
|
+
# Clear the _get_type functions out of the namespace;
|
126
|
+
# Anyone who wants them can get them from the ast.Class/Interface/Boxed
|
127
|
+
to_remove = []
|
128
|
+
for name, node in self._namespace.iteritems():
|
129
|
+
if isinstance(node, ast.Registered) and node.get_type is not None:
|
130
|
+
get_type_name = node.get_type
|
131
|
+
if get_type_name == 'intern':
|
132
|
+
continue
|
133
|
+
assert get_type_name, node
|
134
|
+
(ns, name) = self._transformer.split_csymbol(get_type_name)
|
135
|
+
assert ns is self._namespace
|
136
|
+
get_type_func = self._namespace.get(name)
|
137
|
+
assert get_type_func, name
|
138
|
+
to_remove.append(get_type_func)
|
139
|
+
for node in to_remove:
|
140
|
+
self._namespace.remove(node)
|
141
|
+
|
142
|
+
# Helper functions
|
143
|
+
|
144
|
+
def _execute_binary_get_tree(self):
|
145
|
+
"""Load the library (or executable), returning an XML
|
146
|
+
blob containing data gleaned from GObject's primitive introspection."""
|
147
|
+
in_path = os.path.join(self._binary.tmpdir, 'functions.txt')
|
148
|
+
f = open(in_path, 'w')
|
149
|
+
for func in self._get_type_functions:
|
150
|
+
f.write('get-type:')
|
151
|
+
f.write(func)
|
152
|
+
f.write('\n')
|
153
|
+
for func in self._error_quark_functions:
|
154
|
+
f.write('error-quark:')
|
155
|
+
f.write(func)
|
156
|
+
f.write('\n')
|
157
|
+
f.close()
|
158
|
+
out_path = os.path.join(self._binary.tmpdir, 'dump.xml')
|
159
|
+
|
160
|
+
args = []
|
161
|
+
args.extend(self._binary.args)
|
162
|
+
args.append('--introspect-dump=%s,%s' % (in_path, out_path))
|
163
|
+
|
164
|
+
# Invoke the binary, having written our get_type functions to types.txt
|
165
|
+
try:
|
166
|
+
try:
|
167
|
+
subprocess.check_call(args, stdout=sys.stdout, stderr=sys.stderr)
|
168
|
+
except subprocess.CalledProcessError, e:
|
169
|
+
# Clean up temporaries
|
170
|
+
raise SystemExit(e)
|
171
|
+
return parse(out_path)
|
172
|
+
finally:
|
173
|
+
if not utils.have_debug_flag('save-temps'):
|
174
|
+
shutil.rmtree(self._binary.tmpdir)
|
175
|
+
|
176
|
+
# Parser
|
177
|
+
|
178
|
+
def _initparse_function(self, func):
|
179
|
+
symbol = func.symbol
|
180
|
+
if symbol.startswith('_'):
|
181
|
+
return
|
182
|
+
elif (symbol.endswith('_get_type') or symbol.endswith('_get_gtype')):
|
183
|
+
self._initparse_get_type_function(func)
|
184
|
+
elif symbol.endswith('_error_quark'):
|
185
|
+
self._initparse_error_quark_function(func)
|
186
|
+
|
187
|
+
def _initparse_get_type_function(self, func):
|
188
|
+
if func.symbol == 'g_variant_get_gtype':
|
189
|
+
# We handle variants internally, see _initparse_gobject_record
|
190
|
+
return True
|
191
|
+
|
192
|
+
if func.is_type_meta_function():
|
193
|
+
self._get_type_functions.append(func.symbol)
|
194
|
+
return True
|
195
|
+
|
196
|
+
return False
|
197
|
+
|
198
|
+
def _initparse_error_quark_function(self, func):
|
199
|
+
if (func.retval.type.ctype != 'GQuark'):
|
200
|
+
return False
|
201
|
+
self._error_quark_functions.append(func.symbol)
|
202
|
+
return True
|
203
|
+
|
204
|
+
def _initparse_gobject_record(self, record):
|
205
|
+
if (record.name.startswith('ParamSpec')
|
206
|
+
and not record.name in ('ParamSpecPool', 'ParamSpecClass',
|
207
|
+
'ParamSpecTypeInfo')):
|
208
|
+
parent = None
|
209
|
+
if record.name != 'ParamSpec':
|
210
|
+
parent = ast.Type(target_giname='GObject.ParamSpec')
|
211
|
+
prefix = to_underscores(record.name).lower()
|
212
|
+
node = ast.Class(record.name, parent,
|
213
|
+
ctype=record.ctype,
|
214
|
+
# GParamSpecXxx has g_type_name 'GParamXxx'
|
215
|
+
gtype_name=record.ctype.replace('Spec', ''),
|
216
|
+
get_type='intern',
|
217
|
+
c_symbol_prefix=prefix)
|
218
|
+
node.fundamental = True
|
219
|
+
if record.name == 'ParamSpec':
|
220
|
+
node.is_abstract = True
|
221
|
+
self._add_record_fields(node)
|
222
|
+
self._namespace.append(node, replace=True)
|
223
|
+
elif record.name == 'Variant':
|
224
|
+
self._boxed_types['GVariant'] = ast.Boxed('Variant',
|
225
|
+
gtype_name='GVariant',
|
226
|
+
get_type='intern',
|
227
|
+
c_symbol_prefix='variant')
|
228
|
+
elif record.name == 'InitiallyUnownedClass':
|
229
|
+
record.fields = self._namespace.get('ObjectClass').fields
|
230
|
+
record.disguised = False
|
231
|
+
|
232
|
+
# Introspection over the data we get from the dynamic
|
233
|
+
# GObject/GType system out of the binary
|
234
|
+
|
235
|
+
def _introspect_type(self, xmlnode):
|
236
|
+
if xmlnode.tag in ('enum', 'flags'):
|
237
|
+
self._introspect_enum(xmlnode)
|
238
|
+
elif xmlnode.tag == 'class':
|
239
|
+
self._introspect_object(xmlnode)
|
240
|
+
elif xmlnode.tag == 'interface':
|
241
|
+
self._introspect_interface(xmlnode)
|
242
|
+
elif xmlnode.tag == 'boxed':
|
243
|
+
self._introspect_boxed(xmlnode)
|
244
|
+
elif xmlnode.tag == 'fundamental':
|
245
|
+
self._introspect_fundamental(xmlnode)
|
246
|
+
else:
|
247
|
+
raise ValueError("Unhandled introspection XML tag %s", xmlnode.tag)
|
248
|
+
|
249
|
+
def _introspect_enum(self, xmlnode):
|
250
|
+
type_name = xmlnode.attrib['name']
|
251
|
+
(get_type, c_symbol_prefix) = self._split_type_and_symbol_prefix(xmlnode)
|
252
|
+
try:
|
253
|
+
enum_name = self._transformer.strip_identifier(type_name)
|
254
|
+
except TransformerException, e:
|
255
|
+
message.fatal(e)
|
256
|
+
|
257
|
+
# The scanned member values are more accurate than the values that the
|
258
|
+
# we dumped from GEnumValue.value because GEnumValue.value has the
|
259
|
+
# values as a 32-bit signed integer, even if they were unsigned
|
260
|
+
# in the source code.
|
261
|
+
previous_values = {}
|
262
|
+
previous = self._namespace.get(enum_name)
|
263
|
+
if isinstance(previous, (ast.Enum, ast.Bitfield)):
|
264
|
+
for member in previous.members:
|
265
|
+
previous_values[member.name] = member.value
|
266
|
+
|
267
|
+
members = []
|
268
|
+
for member in xmlnode.findall('member'):
|
269
|
+
# Keep the name closer to what we'd take from C by default;
|
270
|
+
# see http://bugzilla.gnome.org/show_bug.cgi?id=575613
|
271
|
+
name = member.attrib['nick'].replace('-', '_')
|
272
|
+
|
273
|
+
if name in previous_values:
|
274
|
+
value = previous_values[name]
|
275
|
+
else:
|
276
|
+
value = member.attrib['value']
|
277
|
+
|
278
|
+
members.append(ast.Member(name,
|
279
|
+
value,
|
280
|
+
member.attrib['name'],
|
281
|
+
member.attrib['nick']))
|
282
|
+
|
283
|
+
|
284
|
+
if xmlnode.tag == 'flags':
|
285
|
+
klass = ast.Bitfield
|
286
|
+
else:
|
287
|
+
klass = ast.Enum
|
288
|
+
|
289
|
+
node = klass(enum_name, type_name,
|
290
|
+
gtype_name=type_name,
|
291
|
+
c_symbol_prefix=c_symbol_prefix,
|
292
|
+
members=members,
|
293
|
+
get_type=xmlnode.attrib['get-type'])
|
294
|
+
self._namespace.append(node, replace=True)
|
295
|
+
|
296
|
+
def _split_type_and_symbol_prefix(self, xmlnode):
|
297
|
+
"""Infer the C symbol prefix from the _get_type function."""
|
298
|
+
get_type = xmlnode.attrib['get-type']
|
299
|
+
(ns, name) = self._transformer.split_csymbol(get_type)
|
300
|
+
assert ns is self._namespace
|
301
|
+
if name in ('get_type', '_get_gtype'):
|
302
|
+
message.fatal("""The GObject name %r isn't compatibile
|
303
|
+
with the configured identifier prefixes:
|
304
|
+
%r
|
305
|
+
The class would have no name. Most likely you want to specify a
|
306
|
+
different --identifier-prefix.""" % (xmlnode.attrib['name'], self._namespace.identifier_prefixes))
|
307
|
+
if name.endswith('_get_type'):
|
308
|
+
type_suffix = '_get_type'
|
309
|
+
else:
|
310
|
+
type_suffix = '_get_gtype'
|
311
|
+
return (get_type, name[:-len(type_suffix)])
|
312
|
+
|
313
|
+
def _introspect_object(self, xmlnode):
|
314
|
+
type_name = xmlnode.attrib['name']
|
315
|
+
is_abstract = bool(xmlnode.attrib.get('abstract', False))
|
316
|
+
(get_type, c_symbol_prefix) = self._split_type_and_symbol_prefix(xmlnode)
|
317
|
+
try:
|
318
|
+
object_name = self._transformer.strip_identifier(type_name)
|
319
|
+
except TransformerException, e:
|
320
|
+
message.fatal(e)
|
321
|
+
node = ast.Class(object_name, None,
|
322
|
+
gtype_name=type_name,
|
323
|
+
get_type=get_type,
|
324
|
+
c_symbol_prefix=c_symbol_prefix,
|
325
|
+
is_abstract=is_abstract)
|
326
|
+
self._parse_parents(xmlnode, node)
|
327
|
+
self._introspect_properties(node, xmlnode)
|
328
|
+
self._introspect_signals(node, xmlnode)
|
329
|
+
self._introspect_implemented_interfaces(node, xmlnode)
|
330
|
+
self._add_record_fields(node)
|
331
|
+
|
332
|
+
if node.name == 'InitiallyUnowned':
|
333
|
+
# http://bugzilla.gnome.org/show_bug.cgi?id=569408
|
334
|
+
# GInitiallyUnowned is actually a typedef for GObject, but
|
335
|
+
# that's not reflected in the GIR, where it appears as a
|
336
|
+
# subclass (as it appears in the GType hierarchy). So
|
337
|
+
# what we do here is copy all of the GObject fields into
|
338
|
+
# GInitiallyUnowned so that struct offset computation
|
339
|
+
# works correctly.
|
340
|
+
node.fields = self._namespace.get('Object').fields
|
341
|
+
|
342
|
+
self._namespace.append(node, replace=True)
|
343
|
+
|
344
|
+
def _introspect_interface(self, xmlnode):
|
345
|
+
type_name = xmlnode.attrib['name']
|
346
|
+
(get_type, c_symbol_prefix) = self._split_type_and_symbol_prefix(xmlnode)
|
347
|
+
try:
|
348
|
+
interface_name = self._transformer.strip_identifier(type_name)
|
349
|
+
except TransformerException, e:
|
350
|
+
message.fatal(e)
|
351
|
+
node = ast.Interface(interface_name, None,
|
352
|
+
gtype_name=type_name,
|
353
|
+
get_type=get_type,
|
354
|
+
c_symbol_prefix=c_symbol_prefix)
|
355
|
+
self._introspect_properties(node, xmlnode)
|
356
|
+
self._introspect_signals(node, xmlnode)
|
357
|
+
for child in xmlnode.findall('prerequisite'):
|
358
|
+
name = child.attrib['name']
|
359
|
+
prereq = ast.Type.create_from_gtype_name(name)
|
360
|
+
node.prerequisites.append(prereq)
|
361
|
+
|
362
|
+
record = self._namespace.get(node.name)
|
363
|
+
if isinstance(record, ast.Record):
|
364
|
+
node.ctype = record.ctype
|
365
|
+
else:
|
366
|
+
message.warn_node(node, "Couldn't find associated structure for '%r'" % (node.name, ))
|
367
|
+
|
368
|
+
# GtkFileChooserEmbed is an example of a private interface, we
|
369
|
+
# just filter them out
|
370
|
+
if xmlnode.attrib['get-type'].startswith('_'):
|
371
|
+
self._private_internal_types[type_name] = node
|
372
|
+
else:
|
373
|
+
self._namespace.append(node, replace=True)
|
374
|
+
|
375
|
+
## WORKAROUND ##
|
376
|
+
# https://bugzilla.gnome.org/show_bug.cgi?id=550616
|
377
|
+
def _introspect_boxed_gstreamer_workaround(self, xmlnode):
|
378
|
+
node = ast.Boxed('ParamSpecMiniObject', gtype_name='GParamSpecMiniObject',
|
379
|
+
get_type='gst_param_spec_mini_object_get_type',
|
380
|
+
c_symbol_prefix='param_spec_mini_object')
|
381
|
+
self._boxed_types[node.gtype_name] = node
|
382
|
+
|
383
|
+
def _introspect_boxed(self, xmlnode):
|
384
|
+
type_name = xmlnode.attrib['name']
|
385
|
+
|
386
|
+
# Work around GStreamer legacy naming issue
|
387
|
+
# https://bugzilla.gnome.org/show_bug.cgi?id=550616
|
388
|
+
if type_name == 'GParamSpecMiniObject':
|
389
|
+
self._introspect_boxed_gstreamer_workaround(xmlnode)
|
390
|
+
return
|
391
|
+
|
392
|
+
try:
|
393
|
+
name = self._transformer.strip_identifier(type_name)
|
394
|
+
except TransformerException, e:
|
395
|
+
message.fatal(e)
|
396
|
+
# This one doesn't go in the main namespace; we associate it with
|
397
|
+
# the struct or union
|
398
|
+
(get_type, c_symbol_prefix) = self._split_type_and_symbol_prefix(xmlnode)
|
399
|
+
node = ast.Boxed(name, gtype_name=type_name,
|
400
|
+
get_type=get_type,
|
401
|
+
c_symbol_prefix=c_symbol_prefix)
|
402
|
+
self._boxed_types[node.gtype_name] = node
|
403
|
+
|
404
|
+
def _introspect_implemented_interfaces(self, node, xmlnode):
|
405
|
+
gt_interfaces = []
|
406
|
+
for interface in xmlnode.findall('implements'):
|
407
|
+
gitype = ast.Type.create_from_gtype_name(interface.attrib['name'])
|
408
|
+
gt_interfaces.append(gitype)
|
409
|
+
node.interfaces = gt_interfaces
|
410
|
+
|
411
|
+
def _introspect_properties(self, node, xmlnode):
|
412
|
+
for pspec in xmlnode.findall('property'):
|
413
|
+
ctype = pspec.attrib['type']
|
414
|
+
flags = int(pspec.attrib['flags'])
|
415
|
+
readable = (flags & G_PARAM_READABLE) != 0
|
416
|
+
writable = (flags & G_PARAM_WRITABLE) != 0
|
417
|
+
construct = (flags & G_PARAM_CONSTRUCT) != 0
|
418
|
+
construct_only = (flags & G_PARAM_CONSTRUCT_ONLY) != 0
|
419
|
+
node.properties.append(ast.Property(
|
420
|
+
pspec.attrib['name'],
|
421
|
+
ast.Type.create_from_gtype_name(ctype),
|
422
|
+
readable, writable, construct, construct_only))
|
423
|
+
node.properties = node.properties
|
424
|
+
|
425
|
+
def _introspect_signals(self, node, xmlnode):
|
426
|
+
for signal_info in xmlnode.findall('signal'):
|
427
|
+
rctype = signal_info.attrib['return']
|
428
|
+
rtype = ast.Type.create_from_gtype_name(rctype)
|
429
|
+
return_ = ast.Return(rtype)
|
430
|
+
parameters = []
|
431
|
+
when = signal_info.attrib.get('when')
|
432
|
+
no_recurse = signal_info.attrib.get('no-recurse', '0') == '1'
|
433
|
+
detailed = signal_info.attrib.get('detailed', '0') == '1'
|
434
|
+
action = signal_info.attrib.get('action', '0') == '1'
|
435
|
+
no_hooks = signal_info.attrib.get('no-hooks', '0') == '1'
|
436
|
+
for i, parameter in enumerate(signal_info.findall('param')):
|
437
|
+
if i == 0:
|
438
|
+
argname = 'object'
|
439
|
+
else:
|
440
|
+
argname = 'p%s' % (i-1, )
|
441
|
+
pctype = parameter.attrib['type']
|
442
|
+
ptype = ast.Type.create_from_gtype_name(pctype)
|
443
|
+
param = ast.Parameter(argname, ptype)
|
444
|
+
param.transfer = ast.PARAM_TRANSFER_NONE
|
445
|
+
parameters.append(param)
|
446
|
+
signal = ast.Signal(signal_info.attrib['name'], return_, parameters,
|
447
|
+
when=when, no_recurse=no_recurse, detailed=detailed,
|
448
|
+
action=action, no_hooks=no_hooks)
|
449
|
+
node.signals.append(signal)
|
450
|
+
node.signals = node.signals
|
451
|
+
|
452
|
+
def _parse_parents(self, xmlnode, node):
|
453
|
+
parents_str = xmlnode.attrib.get('parents', '')
|
454
|
+
if parents_str != '':
|
455
|
+
parent_types = map(lambda s: ast.Type.create_from_gtype_name(s),
|
456
|
+
parents_str.split(','))
|
457
|
+
else:
|
458
|
+
parent_types = []
|
459
|
+
node.parent_chain = parent_types
|
460
|
+
|
461
|
+
def _introspect_fundamental(self, xmlnode):
|
462
|
+
type_name = xmlnode.attrib['name']
|
463
|
+
|
464
|
+
is_abstract = bool(xmlnode.attrib.get('abstract', False))
|
465
|
+
(get_type, c_symbol_prefix) = self._split_type_and_symbol_prefix(xmlnode)
|
466
|
+
try:
|
467
|
+
fundamental_name = self._transformer.strip_identifier(type_name)
|
468
|
+
except TransformerException, e:
|
469
|
+
message.warn(e)
|
470
|
+
return
|
471
|
+
|
472
|
+
node = ast.Class(fundamental_name, None,
|
473
|
+
gtype_name=type_name,
|
474
|
+
get_type=get_type,
|
475
|
+
c_symbol_prefix=c_symbol_prefix,
|
476
|
+
is_abstract=is_abstract)
|
477
|
+
self._parse_parents(xmlnode, node)
|
478
|
+
node.fundamental = True
|
479
|
+
self._introspect_implemented_interfaces(node, xmlnode)
|
480
|
+
|
481
|
+
self._add_record_fields(node)
|
482
|
+
self._namespace.append(node, replace=True)
|
483
|
+
|
484
|
+
def _add_record_fields(self, node):
|
485
|
+
# add record fields
|
486
|
+
record = self._namespace.get(node.name)
|
487
|
+
if not isinstance(record, ast.Record):
|
488
|
+
return
|
489
|
+
node.ctype = record.ctype
|
490
|
+
node.fields = record.fields
|
491
|
+
for field in node.fields:
|
492
|
+
if isinstance(field, ast.Field):
|
493
|
+
# Object instance fields are assumed to be read-only
|
494
|
+
# (see also _find_class_record and transformer.py)
|
495
|
+
field.writable = False
|
496
|
+
|
497
|
+
def _introspect_error_quark(self, xmlnode):
|
498
|
+
symbol = xmlnode.attrib['function']
|
499
|
+
error_domain = xmlnode.attrib['domain']
|
500
|
+
function = self._namespace.get_by_symbol(symbol)
|
501
|
+
if function is None:
|
502
|
+
return
|
503
|
+
|
504
|
+
node = ast.ErrorQuarkFunction(function.name, function.retval,
|
505
|
+
function.parameters, function.throws,
|
506
|
+
function.symbol, error_domain)
|
507
|
+
self._namespace.append(node, replace=True)
|
508
|
+
|
509
|
+
def _pair_boxed_type(self, boxed):
|
510
|
+
try:
|
511
|
+
name = self._transformer.strip_identifier(boxed.gtype_name)
|
512
|
+
except TransformerException, e:
|
513
|
+
message.fatal(e)
|
514
|
+
pair_node = self._namespace.get(name)
|
515
|
+
if not pair_node:
|
516
|
+
# Keep the "bare" boxed instance
|
517
|
+
self._namespace.append(boxed)
|
518
|
+
elif isinstance(pair_node, (ast.Record, ast.Union)):
|
519
|
+
pair_node.add_gtype(boxed.gtype_name, boxed.get_type)
|
520
|
+
assert boxed.c_symbol_prefix is not None
|
521
|
+
pair_node.c_symbol_prefix = boxed.c_symbol_prefix
|
522
|
+
# Quick hack - reset the disguised flag; we're setting it
|
523
|
+
# incorrectly in the scanner
|
524
|
+
pair_node.disguised = False
|
525
|
+
else:
|
526
|
+
return False
|
527
|
+
|
528
|
+
def _strip_class_suffix(self, name):
|
529
|
+
if (name.endswith('Class') or
|
530
|
+
name.endswith('Iface')):
|
531
|
+
return name[:-5]
|
532
|
+
elif name.endswith('Interface'):
|
533
|
+
return name[:-9]
|
534
|
+
else:
|
535
|
+
return None
|
536
|
+
|
537
|
+
def _find_class_record(self, cls):
|
538
|
+
pair_record = None
|
539
|
+
if isinstance(cls, ast.Class):
|
540
|
+
pair_record = self._namespace.get(cls.name + 'Class')
|
541
|
+
else:
|
542
|
+
for suffix in ('Iface', 'Interface'):
|
543
|
+
pair_record = self._namespace.get(cls.name + suffix)
|
544
|
+
if pair_record:
|
545
|
+
break
|
546
|
+
if not (pair_record and isinstance(pair_record, ast.Record)):
|
547
|
+
return
|
548
|
+
|
549
|
+
cls.glib_type_struct = pair_record.create_type()
|
550
|
+
cls.inherit_file_positions(pair_record)
|
551
|
+
pair_record.is_gtype_struct_for = cls.create_type()
|