gobject-introspection 2.0.0-x86-mingw32
Sign up to get free protection for your applications and to get access to all the features.
- 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
@@ -0,0 +1,185 @@
|
|
1
|
+
#!/usr/bin/env python
|
2
|
+
# -*- Mode: Python -*-
|
3
|
+
# GObject-Introspection - a framework for introspecting GObject libraries
|
4
|
+
# Copyright (C) 2010 Red Hat, Inc.
|
5
|
+
# Copyright (C) 2010 Johan Dahlin
|
6
|
+
#
|
7
|
+
# This program is free software; you can redistribute it and/or
|
8
|
+
# modify it under the terms of the GNU General Public License
|
9
|
+
# as published by the Free Software Foundation; either version 2
|
10
|
+
# of the License, or (at your option) any later version.
|
11
|
+
#
|
12
|
+
# This program is distributed in the hope that it will be useful,
|
13
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
14
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
15
|
+
# GNU General Public License for more details.
|
16
|
+
#
|
17
|
+
# You should have received a copy of the GNU General Public License
|
18
|
+
# along with this program; if not, write to the Free Software
|
19
|
+
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
20
|
+
# 02110-1301, USA.
|
21
|
+
#
|
22
|
+
|
23
|
+
import os
|
24
|
+
import sys
|
25
|
+
|
26
|
+
from . import utils
|
27
|
+
|
28
|
+
(WARNING,
|
29
|
+
ERROR,
|
30
|
+
FATAL) = range(3)
|
31
|
+
|
32
|
+
|
33
|
+
class Position(object):
|
34
|
+
"""Represents a position in the source file which we
|
35
|
+
want to inform about.
|
36
|
+
"""
|
37
|
+
def __init__(self, filename=None, line=None, column=None):
|
38
|
+
self.filename = filename
|
39
|
+
self.line = line
|
40
|
+
self.column = column
|
41
|
+
|
42
|
+
def __cmp__(self, other):
|
43
|
+
return cmp((self.filename, self.line, self.column),
|
44
|
+
(other.filename, other.line, other.column))
|
45
|
+
|
46
|
+
def __repr__(self):
|
47
|
+
return '<Position %s:%d:%d>' % (
|
48
|
+
os.path.basename(self.filename),
|
49
|
+
self.line or -1,
|
50
|
+
self.column or -1)
|
51
|
+
|
52
|
+
def format(self, cwd):
|
53
|
+
filename = self.filename
|
54
|
+
if filename.startswith(cwd):
|
55
|
+
filename = filename[len(cwd):]
|
56
|
+
if self.column is not None:
|
57
|
+
return '%s:%d:%d' % (filename, self.line, self.column)
|
58
|
+
elif self.line is not None:
|
59
|
+
return '%s:%d' % (filename, self.line, )
|
60
|
+
else:
|
61
|
+
return '%s:' % (filename, )
|
62
|
+
|
63
|
+
def offset(self, offset):
|
64
|
+
return Position(self.filename, self.line+offset, self.column)
|
65
|
+
|
66
|
+
|
67
|
+
class MessageLogger(object):
|
68
|
+
_instance = None
|
69
|
+
|
70
|
+
def __init__(self, namespace, output=None):
|
71
|
+
if output is None:
|
72
|
+
output = sys.stderr
|
73
|
+
self._cwd = os.getcwd() + os.sep
|
74
|
+
self._output = output
|
75
|
+
self._namespace = namespace
|
76
|
+
self._enable_warnings = False
|
77
|
+
self._warning_count = 0
|
78
|
+
|
79
|
+
@classmethod
|
80
|
+
def get(cls, *args, **kwargs):
|
81
|
+
if cls._instance is None:
|
82
|
+
cls._instance = cls(*args, **kwargs)
|
83
|
+
return cls._instance
|
84
|
+
|
85
|
+
def enable_warnings(self, enable):
|
86
|
+
self._enable_warnings = enable
|
87
|
+
|
88
|
+
def get_warning_count(self):
|
89
|
+
return self._warning_count
|
90
|
+
|
91
|
+
def log(self, log_type, text, positions=None, prefix=None):
|
92
|
+
"""Log a warning, using optional file positioning information.
|
93
|
+
If the warning is related to a ast.Node type, see log_node()."""
|
94
|
+
utils.break_on_debug_flag('warning')
|
95
|
+
|
96
|
+
self._warning_count += 1
|
97
|
+
|
98
|
+
if not self._enable_warnings and log_type != FATAL:
|
99
|
+
return
|
100
|
+
|
101
|
+
# Always drop through on fatal
|
102
|
+
|
103
|
+
if type(positions) == set:
|
104
|
+
positions = list(positions)
|
105
|
+
if isinstance(positions, Position):
|
106
|
+
positions = [positions]
|
107
|
+
|
108
|
+
if not positions:
|
109
|
+
positions = [Position('<unknown>')]
|
110
|
+
|
111
|
+
for position in positions[:-1]:
|
112
|
+
self._output.write("%s:\n" % (position.format(cwd=self._cwd), ))
|
113
|
+
last_position = positions[-1].format(cwd=self._cwd)
|
114
|
+
|
115
|
+
if log_type == WARNING:
|
116
|
+
error_type = "Warning"
|
117
|
+
elif log_type == ERROR:
|
118
|
+
error_type = "Error"
|
119
|
+
elif log_type == FATAL:
|
120
|
+
error_type = "Fatal"
|
121
|
+
if prefix:
|
122
|
+
text = (
|
123
|
+
'''%s: %s: %s: %s: %s\n''' % (last_position, error_type, self._namespace.name,
|
124
|
+
prefix, text))
|
125
|
+
else:
|
126
|
+
if self._namespace:
|
127
|
+
text = (
|
128
|
+
'''%s: %s: %s: %s\n''' % (last_position, error_type, self._namespace.name, text))
|
129
|
+
else:
|
130
|
+
text = (
|
131
|
+
'''%s: %s: %s\n''' % (last_position, error_type, text))
|
132
|
+
|
133
|
+
self._output.write(text)
|
134
|
+
if log_type == FATAL:
|
135
|
+
utils.break_on_debug_flag('fatal')
|
136
|
+
raise SystemExit(text)
|
137
|
+
|
138
|
+
def log_node(self, log_type, node, text, context=None, positions=None):
|
139
|
+
"""Log a warning, using information about file positions from
|
140
|
+
the given node. The optional context argument, if given, should be
|
141
|
+
another ast.Node type which will also be displayed. If no file position
|
142
|
+
information is available from the node, the position data from the
|
143
|
+
context will be used."""
|
144
|
+
if positions:
|
145
|
+
pass
|
146
|
+
elif getattr(node, 'file_positions', None):
|
147
|
+
positions = node.file_positions
|
148
|
+
elif context and context.file_positions:
|
149
|
+
positions = context.file_positions
|
150
|
+
else:
|
151
|
+
positions = []
|
152
|
+
if not context:
|
153
|
+
text = "context=%r %s" % (node, text)
|
154
|
+
|
155
|
+
if context:
|
156
|
+
text = "%s: %s" % (getattr(context, 'symbol', context.name), text)
|
157
|
+
elif not positions and hasattr(node, 'name'):
|
158
|
+
text = "(%s)%s: %s" % (node.__class__.__name__, node.name, text)
|
159
|
+
|
160
|
+
self.log(log_type, text, positions)
|
161
|
+
|
162
|
+
def log_symbol(self, log_type, symbol, text):
|
163
|
+
"""Log a warning in the context of the given symbol."""
|
164
|
+
self.log(log_type, text, symbol.position,
|
165
|
+
prefix="symbol=%r" % (symbol.ident, ))
|
166
|
+
|
167
|
+
|
168
|
+
def log_node(log_type, node, text, context=None, positions=None):
|
169
|
+
ml = MessageLogger.get()
|
170
|
+
ml.log_node(log_type, node, text, context=context, positions=positions)
|
171
|
+
|
172
|
+
def warn(text, positions=None, prefix=None):
|
173
|
+
ml = MessageLogger.get()
|
174
|
+
ml.log(WARNING, text, positions, prefix)
|
175
|
+
|
176
|
+
def warn_node(node, text, context=None, positions=None):
|
177
|
+
log_node(WARNING, node, text, context=context, positions=positions)
|
178
|
+
|
179
|
+
def warn_symbol(symbol, text):
|
180
|
+
ml = MessageLogger.get()
|
181
|
+
ml.log_symbol(WARNING, symbol, text)
|
182
|
+
|
183
|
+
def fatal(text, positions=None, prefix=None):
|
184
|
+
ml = MessageLogger.get()
|
185
|
+
ml.log(FATAL, text, positions, prefix)
|
Binary file
|
Binary file
|
@@ -0,0 +1,50 @@
|
|
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
|
+
"""odict - an ordered dictionary"""
|
22
|
+
|
23
|
+
try:
|
24
|
+
# Starting with Python 2.7 we can use collections.OrderedDict
|
25
|
+
from collections import OrderedDict as odict
|
26
|
+
except ImportError:
|
27
|
+
# But we still support Python 2.5 and 2.6
|
28
|
+
from UserDict import DictMixin
|
29
|
+
|
30
|
+
|
31
|
+
class odict(DictMixin):
|
32
|
+
|
33
|
+
def __init__(self):
|
34
|
+
self._items = {}
|
35
|
+
self._keys = []
|
36
|
+
|
37
|
+
def __setitem__(self, key, value):
|
38
|
+
if key not in self._items:
|
39
|
+
self._keys.append(key)
|
40
|
+
self._items[key] = value
|
41
|
+
|
42
|
+
def __getitem__(self, key):
|
43
|
+
return self._items[key]
|
44
|
+
|
45
|
+
def __delitem__(self, key):
|
46
|
+
del self._items[key]
|
47
|
+
self._keys.remove(key)
|
48
|
+
|
49
|
+
def keys(self):
|
50
|
+
return self._keys[:]
|
Binary file
|
Binary file
|
@@ -0,0 +1,497 @@
|
|
1
|
+
#!/usr/bin/env python
|
2
|
+
# -*- Mode: Python -*-
|
3
|
+
# GObject-Introspection - a framework for introspecting GObject libraries
|
4
|
+
# Copyright (C) 2008-2010 Johan Dahlin
|
5
|
+
# Copyright (C) 2009 Red Hat, Inc.
|
6
|
+
#
|
7
|
+
# This program is free software; you can redistribute it and/or
|
8
|
+
# modify it under the terms of the GNU General Public License
|
9
|
+
# as published by the Free Software Foundation; either version 2
|
10
|
+
# of the License, or (at your option) any later version.
|
11
|
+
#
|
12
|
+
# This program is distributed in the hope that it will be useful,
|
13
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
14
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
15
|
+
# GNU General Public License for more details.
|
16
|
+
#
|
17
|
+
# You should have received a copy of the GNU General Public License
|
18
|
+
# along with this program; if not, write to the Free Software
|
19
|
+
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
20
|
+
# 02110-1301, USA.
|
21
|
+
#
|
22
|
+
|
23
|
+
import errno
|
24
|
+
import optparse
|
25
|
+
import os
|
26
|
+
import shutil
|
27
|
+
import subprocess
|
28
|
+
import sys
|
29
|
+
import tempfile
|
30
|
+
|
31
|
+
from giscanner import message
|
32
|
+
from giscanner.annotationparser import AnnotationParser
|
33
|
+
from giscanner.ast import Include, Namespace
|
34
|
+
from giscanner.dumper import compile_introspection_binary
|
35
|
+
from giscanner.gdumpparser import GDumpParser, IntrospectionBinary
|
36
|
+
from giscanner.introspectablepass import IntrospectablePass
|
37
|
+
from giscanner.girparser import GIRParser
|
38
|
+
from giscanner.girwriter import GIRWriter
|
39
|
+
from giscanner.maintransformer import MainTransformer
|
40
|
+
from giscanner.shlibs import resolve_shlibs
|
41
|
+
from giscanner.sourcescanner import SourceScanner
|
42
|
+
from giscanner.transformer import Transformer
|
43
|
+
from . import utils
|
44
|
+
|
45
|
+
def process_cflags_begin(option, opt, value, parser):
|
46
|
+
cflags = getattr(parser.values, option.dest)
|
47
|
+
while len(parser.rargs) > 0 and parser.rargs[0] != '--cflags-end':
|
48
|
+
cflags.append(parser.rargs.pop(0))
|
49
|
+
|
50
|
+
def process_cflags_end(option, opt, value, parser):
|
51
|
+
pass
|
52
|
+
|
53
|
+
def get_preprocessor_option_group(parser):
|
54
|
+
group = optparse.OptionGroup(parser, "Preprocessor options")
|
55
|
+
group.add_option("", "--cflags-begin",
|
56
|
+
help="Start preprocessor/compiler flags",
|
57
|
+
dest="cflags", default=[],
|
58
|
+
action="callback", callback=process_cflags_begin)
|
59
|
+
group.add_option("", "--cflags-end",
|
60
|
+
help="End preprocessor/compiler flags",
|
61
|
+
action="callback", callback=process_cflags_end)
|
62
|
+
group.add_option("-I", help="Pre-processor include file",
|
63
|
+
action="append", dest="cpp_includes",
|
64
|
+
default=[])
|
65
|
+
group.add_option("-D", help="Pre-processor define",
|
66
|
+
action="append", dest="cpp_defines",
|
67
|
+
default=[])
|
68
|
+
group.add_option("-U", help="Pre-processor undefine",
|
69
|
+
action="append", dest="cpp_undefines",
|
70
|
+
default=[])
|
71
|
+
group.add_option("-p", dest="", help="Ignored")
|
72
|
+
return group
|
73
|
+
|
74
|
+
def get_windows_option_group(parser):
|
75
|
+
group = optparse.OptionGroup(parser, "Machine Dependent Options")
|
76
|
+
group.add_option("-m", help="some machine dependent option",
|
77
|
+
action="append", dest='m_option',
|
78
|
+
default=[])
|
79
|
+
|
80
|
+
return group
|
81
|
+
|
82
|
+
def _get_option_parser():
|
83
|
+
parser = optparse.OptionParser('%prog [options] sources')
|
84
|
+
parser.add_option('', "--quiet",
|
85
|
+
action="store_true", dest="quiet",
|
86
|
+
default=False,
|
87
|
+
help="If passed, do not print details of normal" \
|
88
|
+
+ " operation")
|
89
|
+
parser.add_option("", "--format",
|
90
|
+
action="store", dest="format",
|
91
|
+
default="gir",
|
92
|
+
help="format to use, one of gidl, gir")
|
93
|
+
parser.add_option("-i", "--include",
|
94
|
+
action="append", dest="includes", default=[],
|
95
|
+
help="Add specified gir file as dependency")
|
96
|
+
parser.add_option("", "--include-uninstalled",
|
97
|
+
action="append", dest="includes_uninstalled", default=[],
|
98
|
+
help=("""A file path to a dependency; only use this "
|
99
|
+
"when building multiple .gir files inside a "
|
100
|
+
"single module."""))
|
101
|
+
parser.add_option("", "--add-include-path",
|
102
|
+
action="append", dest="include_paths", default=[],
|
103
|
+
help="include paths for other GIR files")
|
104
|
+
parser.add_option("", "--program",
|
105
|
+
action="store", dest="program", default=None,
|
106
|
+
help="program to execute")
|
107
|
+
parser.add_option("", "--program-arg",
|
108
|
+
action="append", dest="program_args", default=[],
|
109
|
+
help="extra arguments to program")
|
110
|
+
parser.add_option("", "--libtool",
|
111
|
+
action="store", dest="libtool_path", default=None,
|
112
|
+
help="full path to libtool")
|
113
|
+
parser.add_option("", "--no-libtool",
|
114
|
+
action="store_true", dest="nolibtool", default=False,
|
115
|
+
help="do not use libtool")
|
116
|
+
parser.add_option("", "--external-library",
|
117
|
+
action="store_true", dest="external_library", default=False,
|
118
|
+
help=("""If true, the library is located on the system,""" +
|
119
|
+
"""not in the current directory"""))
|
120
|
+
parser.add_option("-l", "--library",
|
121
|
+
action="append", dest="libraries", default=[],
|
122
|
+
help="libraries of this unit")
|
123
|
+
parser.add_option("-L", "--library-path",
|
124
|
+
action="append", dest="library_paths", default=[],
|
125
|
+
help="directories to search for libraries")
|
126
|
+
parser.add_option("", "--header-only",
|
127
|
+
action="store_true", dest="header_only", default=[],
|
128
|
+
help="If specified, just generate a GIR for the given header files")
|
129
|
+
parser.add_option("-n", "--namespace",
|
130
|
+
action="store", dest="namespace_name",
|
131
|
+
help=("name of namespace for this unit, also "
|
132
|
+
"used to compute --identifier-prefix and --symbol-prefix"))
|
133
|
+
parser.add_option("", "--nsversion",
|
134
|
+
action="store", dest="namespace_version",
|
135
|
+
help="version of namespace for this unit")
|
136
|
+
parser.add_option("", "--strip-prefix",
|
137
|
+
action="store", dest="strip_prefix",
|
138
|
+
help="""Option --strip-prefix is deprecated, please see --identifier-prefix
|
139
|
+
and --symbol-prefix.""")
|
140
|
+
parser.add_option("", "--identifier-prefix",
|
141
|
+
action="append", dest="identifier_prefixes", default=[],
|
142
|
+
help="""Remove this prefix from C identifiers (structure typedefs, etc.).
|
143
|
+
May be specified multiple times. This is also used as the default for --symbol-prefix if
|
144
|
+
the latter is not specified.""")
|
145
|
+
parser.add_option("", "--symbol-prefix",
|
146
|
+
action="append", dest="symbol_prefixes", default=[],
|
147
|
+
help="Remove this prefix from C symbols (function names)")
|
148
|
+
parser.add_option("", "--accept-unprefixed",
|
149
|
+
action="store_true", dest="accept_unprefixed", default=False,
|
150
|
+
help="""If specified, accept symbols and identifiers that do not
|
151
|
+
match the namespace prefix.""")
|
152
|
+
parser.add_option("", "--add-init-section",
|
153
|
+
action="append", dest="init_sections", default=[],
|
154
|
+
help="add extra initialization code in the introspection program")
|
155
|
+
parser.add_option("-o", "--output",
|
156
|
+
action="store", dest="output", default="-",
|
157
|
+
help="output filename to write to, defaults to - (stdout)")
|
158
|
+
parser.add_option("", "--pkg",
|
159
|
+
action="append", dest="packages", default=[],
|
160
|
+
help="pkg-config packages to get cflags from")
|
161
|
+
parser.add_option("", "--pkg-export",
|
162
|
+
action="append", dest="packages_export", default=[],
|
163
|
+
help="Associated pkg-config packages for this library")
|
164
|
+
parser.add_option('', "--warn-all",
|
165
|
+
action="store_true", dest="warn_all", default=False,
|
166
|
+
help="If true, enable all warnings for introspection")
|
167
|
+
parser.add_option('', "--warn-error",
|
168
|
+
action="store_true", dest="warn_fatal",
|
169
|
+
help="Turn warnings into fatal errors")
|
170
|
+
parser.add_option("-v", "--verbose",
|
171
|
+
action="store_true", dest="verbose",
|
172
|
+
help="be verbose")
|
173
|
+
parser.add_option("", "--c-include",
|
174
|
+
action="append", dest="c_includes", default=[],
|
175
|
+
help="headers which should be included in C programs")
|
176
|
+
parser.add_option("", "--filelist",
|
177
|
+
action="store", dest="filelist", default=[],
|
178
|
+
help="file containing headers and sources to be scanned")
|
179
|
+
|
180
|
+
group = get_preprocessor_option_group(parser)
|
181
|
+
parser.add_option_group(group)
|
182
|
+
|
183
|
+
if os.environ.get('MSYSTEM') == 'MINGW32':
|
184
|
+
group = get_windows_option_group(parser)
|
185
|
+
parser.add_option_group(group)
|
186
|
+
|
187
|
+
# Private options
|
188
|
+
parser.add_option('', "--generate-typelib-tests",
|
189
|
+
action="store", dest="test_codegen", default=None,
|
190
|
+
help=optparse.SUPPRESS_HELP)
|
191
|
+
parser.add_option('', "--passthrough-gir",
|
192
|
+
action="store", dest="passthrough_gir", default=None,
|
193
|
+
help=optparse.SUPPRESS_HELP)
|
194
|
+
parser.add_option('', "--reparse-validate",
|
195
|
+
action="store_true", dest="reparse_validate_gir", default=False,
|
196
|
+
help=optparse.SUPPRESS_HELP)
|
197
|
+
parser.add_option("", "--typelib-xml",
|
198
|
+
action="store_true", dest="typelib_xml",
|
199
|
+
help=optparse.SUPPRESS_HELP)
|
200
|
+
|
201
|
+
return parser
|
202
|
+
|
203
|
+
|
204
|
+
def _error(msg):
|
205
|
+
raise SystemExit('ERROR: %s' % (msg, ))
|
206
|
+
|
207
|
+
def passthrough_gir(path, f):
|
208
|
+
parser = GIRParser()
|
209
|
+
parser.parse(path)
|
210
|
+
|
211
|
+
writer = GIRWriter(parser.get_namespace())
|
212
|
+
f.write(writer.get_xml())
|
213
|
+
|
214
|
+
def test_codegen(optstring):
|
215
|
+
(namespace, out_h_filename, out_c_filename) = optstring.split(',')
|
216
|
+
if namespace == 'Everything':
|
217
|
+
from .testcodegen import EverythingCodeGenerator
|
218
|
+
gen = EverythingCodeGenerator(out_h_filename, out_c_filename)
|
219
|
+
gen.write()
|
220
|
+
else:
|
221
|
+
_error("Invaild namespace %r" % (namespace, ))
|
222
|
+
return 0
|
223
|
+
|
224
|
+
def process_options(output, allowed_flags):
|
225
|
+
for option in output.split():
|
226
|
+
for flag in allowed_flags:
|
227
|
+
if not option.startswith(flag):
|
228
|
+
continue
|
229
|
+
yield option
|
230
|
+
break
|
231
|
+
|
232
|
+
def process_packages(options, packages):
|
233
|
+
args = ['pkg-config', '--cflags']
|
234
|
+
args.extend(packages)
|
235
|
+
output = subprocess.Popen(args,
|
236
|
+
stdout=subprocess.PIPE).communicate()[0]
|
237
|
+
if output is None:
|
238
|
+
# the error output should have already appeared on our stderr,
|
239
|
+
# so we just exit
|
240
|
+
return 1
|
241
|
+
# Some pkg-config files on Windows have options we don't understand,
|
242
|
+
# so we explicitly filter to only the ones we need.
|
243
|
+
options_whitelist = ['-I', '-D', '-U', '-l', '-L']
|
244
|
+
filtered_output = list(process_options(output, options_whitelist))
|
245
|
+
parser = _get_option_parser()
|
246
|
+
pkg_options, unused = parser.parse_args(filtered_output)
|
247
|
+
options.cpp_includes.extend(pkg_options.cpp_includes)
|
248
|
+
options.cpp_defines.extend(pkg_options.cpp_defines)
|
249
|
+
options.cpp_undefines.extend(pkg_options.cpp_undefines)
|
250
|
+
|
251
|
+
def extract_filenames(args):
|
252
|
+
filenames = []
|
253
|
+
for arg in args:
|
254
|
+
# We don't support real C++ parsing yet, but we should be able
|
255
|
+
# to understand C API implemented in C++ files.
|
256
|
+
if (arg.endswith('.c') or arg.endswith('.cpp') or
|
257
|
+
arg.endswith('.cc') or arg.endswith('.cxx') or
|
258
|
+
arg.endswith('.h') or arg.endswith('.hpp') or
|
259
|
+
arg.endswith('.hxx')):
|
260
|
+
if not os.path.exists(arg):
|
261
|
+
_error('%s: no such a file or directory' % (arg, ))
|
262
|
+
# Make absolute, because we do comparisons inside scannerparser.c
|
263
|
+
# against the absolute path that cpp will give us
|
264
|
+
filenames.append(os.path.abspath(arg))
|
265
|
+
return filenames
|
266
|
+
|
267
|
+
def extract_filelist(options):
|
268
|
+
filenames = []
|
269
|
+
if not os.path.exists(options.filelist):
|
270
|
+
_error('%s: no such filelist file' % (options.filelist, ))
|
271
|
+
filelist_file = open(options.filelist, "r")
|
272
|
+
lines = filelist_file.readlines()
|
273
|
+
for line in lines:
|
274
|
+
# We don't support real C++ parsing yet, but we should be able
|
275
|
+
# to understand C API implemented in C++ files.
|
276
|
+
filename = line.strip()
|
277
|
+
if (filename.endswith('.c') or filename.endswith('.cpp') or
|
278
|
+
filename.endswith('.cc') or filename.endswith('.cxx') or
|
279
|
+
filename.endswith('.h') or filename.endswith('.hpp') or
|
280
|
+
filename.endswith('.hxx')):
|
281
|
+
if not os.path.exists(filename):
|
282
|
+
_error('%s: Invalid filelist entry-no such file or directory' % (line, ))
|
283
|
+
# Make absolute, because we do comparisons inside scannerparser.c
|
284
|
+
# against the absolute path that cpp will give us
|
285
|
+
filenames.append(os.path.abspath(filename))
|
286
|
+
return filenames
|
287
|
+
|
288
|
+
def create_namespace(options):
|
289
|
+
if options.strip_prefix:
|
290
|
+
print """g-ir-scanner: warning: Option --strip-prefix has been deprecated;
|
291
|
+
see --identifier-prefix and --symbol-prefix."""
|
292
|
+
options.identifier_prefixes.append(options.strip_prefix)
|
293
|
+
|
294
|
+
# We do this dance because the empty list has different semantics from
|
295
|
+
# None; if the user didn't specify the options, we want to use None so
|
296
|
+
# the Namespace constructor picks the defaults.
|
297
|
+
if options.identifier_prefixes:
|
298
|
+
identifier_prefixes = options.identifier_prefixes
|
299
|
+
else:
|
300
|
+
identifier_prefixes = None
|
301
|
+
if options.symbol_prefixes:
|
302
|
+
for prefix in options.symbol_prefixes:
|
303
|
+
# See Transformer._split_c_string_for_namespace_matches() for
|
304
|
+
# why this check is needed
|
305
|
+
if prefix.lower() != prefix:
|
306
|
+
_error("Values for --symbol-prefix must be entirely lowercase")
|
307
|
+
symbol_prefixes = options.symbol_prefixes
|
308
|
+
else:
|
309
|
+
symbol_prefixes = None
|
310
|
+
|
311
|
+
return Namespace(options.namespace_name,
|
312
|
+
options.namespace_version,
|
313
|
+
identifier_prefixes=identifier_prefixes,
|
314
|
+
symbol_prefixes=symbol_prefixes)
|
315
|
+
|
316
|
+
def create_transformer(namespace, options):
|
317
|
+
transformer = Transformer(namespace,
|
318
|
+
accept_unprefixed=options.accept_unprefixed)
|
319
|
+
transformer.set_include_paths(options.include_paths)
|
320
|
+
if options.passthrough_gir:
|
321
|
+
transformer.disable_cache()
|
322
|
+
transformer.set_passthrough_mode()
|
323
|
+
|
324
|
+
for include in options.includes:
|
325
|
+
if os.sep in include:
|
326
|
+
_error("Invalid include path %r" % (include, ))
|
327
|
+
try:
|
328
|
+
include_obj = Include.from_string(include)
|
329
|
+
except:
|
330
|
+
_error("Malformed include %r\n" % (include, ))
|
331
|
+
transformer.register_include(include_obj)
|
332
|
+
for include_path in options.includes_uninstalled:
|
333
|
+
transformer.register_include_uninstalled(include_path)
|
334
|
+
|
335
|
+
return transformer
|
336
|
+
|
337
|
+
def create_binary(transformer, options, args):
|
338
|
+
# Transform the C AST nodes into higher level
|
339
|
+
# GLib/GObject nodes
|
340
|
+
gdump_parser = GDumpParser(transformer)
|
341
|
+
|
342
|
+
# Do enough parsing that we have the get_type() functions to reference
|
343
|
+
# when creating the introspection binary
|
344
|
+
gdump_parser.init_parse()
|
345
|
+
|
346
|
+
if options.program:
|
347
|
+
args=[options.program]
|
348
|
+
args.extend(options.program_args)
|
349
|
+
binary = IntrospectionBinary(args)
|
350
|
+
else:
|
351
|
+
binary = compile_introspection_binary(options,
|
352
|
+
gdump_parser.get_get_type_functions(),
|
353
|
+
gdump_parser.get_error_quark_functions())
|
354
|
+
|
355
|
+
shlibs = resolve_shlibs(options, binary, options.libraries)
|
356
|
+
gdump_parser.set_introspection_binary(binary)
|
357
|
+
gdump_parser.parse()
|
358
|
+
return shlibs
|
359
|
+
|
360
|
+
def create_source_scanner(options, args):
|
361
|
+
if hasattr(options, 'filelist') and options.filelist:
|
362
|
+
filenames = extract_filelist(options)
|
363
|
+
else:
|
364
|
+
filenames = extract_filenames(args)
|
365
|
+
|
366
|
+
# Run the preprocessor, tokenize and construct simple
|
367
|
+
# objects representing the raw C symbols
|
368
|
+
ss = SourceScanner()
|
369
|
+
ss.set_cpp_options(options.cpp_includes,
|
370
|
+
options.cpp_defines,
|
371
|
+
options.cpp_undefines,
|
372
|
+
cflags=options.cflags)
|
373
|
+
ss.parse_files(filenames)
|
374
|
+
ss.parse_macros(filenames)
|
375
|
+
return ss
|
376
|
+
|
377
|
+
def write_output(data, options):
|
378
|
+
if options.output == "-":
|
379
|
+
output = sys.stdout
|
380
|
+
elif options.reparse_validate_gir:
|
381
|
+
main_f, main_f_name = tempfile.mkstemp(suffix='.gir')
|
382
|
+
main_f = os.fdopen(main_f, 'w')
|
383
|
+
main_f.write(data)
|
384
|
+
main_f.close()
|
385
|
+
|
386
|
+
temp_f, temp_f_name = tempfile.mkstemp(suffix='.gir')
|
387
|
+
temp_f = os.fdopen(temp_f, 'w')
|
388
|
+
passthrough_gir(main_f_name, temp_f)
|
389
|
+
temp_f.close()
|
390
|
+
if not utils.files_are_identical(main_f_name, temp_f_name):
|
391
|
+
_error("Failed to re-parse gir file; scanned=%r passthrough=%r" % (
|
392
|
+
main_f_name, temp_f_name))
|
393
|
+
os.unlink(temp_f_name)
|
394
|
+
try:
|
395
|
+
shutil.move(main_f_name, options.output)
|
396
|
+
except OSError, e:
|
397
|
+
if e.errno == errno.EPERM:
|
398
|
+
os.unlink(main_f_name)
|
399
|
+
return 0
|
400
|
+
raise
|
401
|
+
return 0
|
402
|
+
else:
|
403
|
+
try:
|
404
|
+
output = open(options.output, "w")
|
405
|
+
except IOError, e:
|
406
|
+
_error("opening output for writing: %s" % (e.strerror, ))
|
407
|
+
|
408
|
+
try:
|
409
|
+
output.write(data)
|
410
|
+
except IOError, e:
|
411
|
+
_error("while writing output: %s" % (e.strerror, ))
|
412
|
+
|
413
|
+
def scanner_main(args):
|
414
|
+
parser = _get_option_parser()
|
415
|
+
(options, args) = parser.parse_args(args)
|
416
|
+
|
417
|
+
if options.passthrough_gir:
|
418
|
+
passthrough_gir(options.passthrough_gir, sys.stdout)
|
419
|
+
if options.test_codegen:
|
420
|
+
return test_codegen(options.test_codegen)
|
421
|
+
|
422
|
+
if hasattr(options, 'filelist') and not options.filelist:
|
423
|
+
if len(args) <= 1:
|
424
|
+
_error('Need at least one filename')
|
425
|
+
|
426
|
+
if not options.namespace_name:
|
427
|
+
_error('Namespace name missing')
|
428
|
+
|
429
|
+
if options.format == 'gir':
|
430
|
+
from giscanner.girwriter import GIRWriter as Writer
|
431
|
+
else:
|
432
|
+
_error("Unknown format: %s" % (options.format, ))
|
433
|
+
|
434
|
+
if not (options.libraries
|
435
|
+
or options.program
|
436
|
+
or options.header_only):
|
437
|
+
_error("Must specify --program or --library")
|
438
|
+
|
439
|
+
namespace = create_namespace(options)
|
440
|
+
logger = message.MessageLogger.get(namespace=namespace)
|
441
|
+
if options.warn_all:
|
442
|
+
logger.enable_warnings(True)
|
443
|
+
transformer = create_transformer(namespace, options)
|
444
|
+
|
445
|
+
packages = set(options.packages)
|
446
|
+
packages.update(transformer.get_pkgconfig_packages())
|
447
|
+
if packages:
|
448
|
+
exit_code = process_packages(options, packages)
|
449
|
+
if exit_code:
|
450
|
+
return exit_code
|
451
|
+
|
452
|
+
ss = create_source_scanner(options, args)
|
453
|
+
|
454
|
+
ap = AnnotationParser()
|
455
|
+
blocks = ap.parse(ss.get_comments())
|
456
|
+
|
457
|
+
# Transform the C symbols into AST nodes
|
458
|
+
transformer.set_annotations(blocks)
|
459
|
+
transformer.parse(ss.get_symbols())
|
460
|
+
|
461
|
+
if not options.header_only:
|
462
|
+
shlibs = create_binary(transformer, options, args)
|
463
|
+
else:
|
464
|
+
shlibs = []
|
465
|
+
|
466
|
+
transformer.namespace.shared_libraries = shlibs
|
467
|
+
|
468
|
+
main = MainTransformer(transformer, blocks)
|
469
|
+
main.transform()
|
470
|
+
|
471
|
+
utils.break_on_debug_flag('tree')
|
472
|
+
|
473
|
+
final = IntrospectablePass(transformer, blocks)
|
474
|
+
final.validate()
|
475
|
+
|
476
|
+
warning_count = logger.get_warning_count()
|
477
|
+
if options.warn_fatal and warning_count > 0:
|
478
|
+
message.fatal("warnings configured as fatal")
|
479
|
+
return 1
|
480
|
+
elif warning_count > 0 and options.warn_all is False:
|
481
|
+
print ("g-ir-scanner: %s: warning: %d warnings suppressed (use --warn-all to see them)"
|
482
|
+
% (transformer.namespace.name, warning_count, ))
|
483
|
+
|
484
|
+
# Write out AST
|
485
|
+
if options.packages_export:
|
486
|
+
exported_packages = options.packages_export
|
487
|
+
else:
|
488
|
+
exported_packages = options.packages
|
489
|
+
|
490
|
+
transformer.namespace.c_includes = options.c_includes
|
491
|
+
transformer.namespace.exported_packages = exported_packages
|
492
|
+
writer = Writer(transformer.namespace)
|
493
|
+
data = writer.get_xml()
|
494
|
+
|
495
|
+
write_output(data, options)
|
496
|
+
|
497
|
+
return 0
|