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,48 @@
|
|
1
|
+
/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */
|
2
|
+
/*
|
3
|
+
* Copyright (C) 2012 Ruby-GNOME2 Project Team
|
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.1 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 Free Software
|
17
|
+
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
18
|
+
* MA 02110-1301 USA
|
19
|
+
*/
|
20
|
+
|
21
|
+
#include "rb-gi-private.h"
|
22
|
+
|
23
|
+
#define RG_TARGET_NAMESPACE rb_cGIFlagsInfo
|
24
|
+
|
25
|
+
GType
|
26
|
+
gi_flags_info_get_type(void)
|
27
|
+
{
|
28
|
+
static GType type = 0;
|
29
|
+
if (type == 0) {
|
30
|
+
type = g_boxed_type_register_static("GIFlagsInfo",
|
31
|
+
(GBoxedCopyFunc)g_base_info_ref,
|
32
|
+
(GBoxedFreeFunc)g_base_info_unref);
|
33
|
+
}
|
34
|
+
return type;
|
35
|
+
}
|
36
|
+
|
37
|
+
void
|
38
|
+
rb_gi_flags_info_init(VALUE rb_mGI, VALUE rb_cGIEnumInfo)
|
39
|
+
{
|
40
|
+
VALUE RG_TARGET_NAMESPACE;
|
41
|
+
|
42
|
+
RG_TARGET_NAMESPACE =
|
43
|
+
G_DEF_CLASS_WITH_PARENT(GI_TYPE_FLAGS_INFO, "FlagsInfo", rb_mGI,
|
44
|
+
rb_cGIEnumInfo);
|
45
|
+
|
46
|
+
/* Suppress a warning. */
|
47
|
+
(void)RG_TARGET_NAMESPACE;
|
48
|
+
}
|
@@ -0,0 +1,658 @@
|
|
1
|
+
/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */
|
2
|
+
/*
|
3
|
+
* Copyright (C) 2012-2013 Ruby-GNOME2 Project Team
|
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.1 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 Free Software
|
17
|
+
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
18
|
+
* MA 02110-1301 USA
|
19
|
+
*/
|
20
|
+
|
21
|
+
#include "rb-gi-private.h"
|
22
|
+
|
23
|
+
#define RG_TARGET_NAMESPACE rb_cGIFunctionInfo
|
24
|
+
#define SELF(self) RVAL2GI_FUNCTION_INFO(self)
|
25
|
+
|
26
|
+
static VALUE RG_TARGET_NAMESPACE;
|
27
|
+
static VALUE rb_cGLibError;
|
28
|
+
static const char *callbacks_key = "gi_callbacks";
|
29
|
+
static GPtrArray *callback_finders;
|
30
|
+
|
31
|
+
GType
|
32
|
+
gi_function_info_get_type(void)
|
33
|
+
{
|
34
|
+
static GType type = 0;
|
35
|
+
if (type == 0) {
|
36
|
+
type = g_boxed_type_register_static("GIFunctionInfo",
|
37
|
+
(GBoxedCopyFunc)g_base_info_ref,
|
38
|
+
(GBoxedFreeFunc)g_base_info_unref);
|
39
|
+
}
|
40
|
+
return type;
|
41
|
+
}
|
42
|
+
|
43
|
+
static VALUE
|
44
|
+
rg_symbol(VALUE self)
|
45
|
+
{
|
46
|
+
GIFunctionInfo *info;
|
47
|
+
|
48
|
+
info = SELF(self);
|
49
|
+
return CSTR2RVAL(g_function_info_get_symbol(info));
|
50
|
+
}
|
51
|
+
|
52
|
+
static VALUE
|
53
|
+
rg_flags(VALUE self)
|
54
|
+
{
|
55
|
+
GIFunctionInfo *info;
|
56
|
+
|
57
|
+
info = SELF(self);
|
58
|
+
return GI_FUNCTION_INFO_FLAGS2RVAL(g_function_info_get_flags(info));
|
59
|
+
}
|
60
|
+
|
61
|
+
static VALUE
|
62
|
+
rg_property(VALUE self)
|
63
|
+
{
|
64
|
+
GIFunctionInfo *info;
|
65
|
+
|
66
|
+
info = SELF(self);
|
67
|
+
return GI_BASE_INFO2RVAL(g_function_info_get_property(info));
|
68
|
+
}
|
69
|
+
|
70
|
+
static VALUE
|
71
|
+
rg_vfunc(VALUE self)
|
72
|
+
{
|
73
|
+
GIFunctionInfo *info;
|
74
|
+
|
75
|
+
info = SELF(self);
|
76
|
+
return GI_BASE_INFO2RVAL(g_function_info_get_vfunc(info));
|
77
|
+
}
|
78
|
+
|
79
|
+
static void
|
80
|
+
allocate_arguments(GICallableInfo *info,
|
81
|
+
GArray *in_args, GArray *out_args,
|
82
|
+
GPtrArray *args_metadata)
|
83
|
+
{
|
84
|
+
gint i, n_args;
|
85
|
+
gint rb_arg_index = 0;
|
86
|
+
|
87
|
+
n_args = g_callable_info_get_n_args(info);
|
88
|
+
for (i = 0; i < n_args; i++) {
|
89
|
+
GIArgument argument;
|
90
|
+
RBGIArgMetadata *metadata;
|
91
|
+
GIArgInfo *arg_info;
|
92
|
+
GIDirection direction;
|
93
|
+
|
94
|
+
memset(&argument, 0, sizeof(GIArgument));
|
95
|
+
|
96
|
+
metadata = ALLOC(RBGIArgMetadata);
|
97
|
+
arg_info = &(metadata->arg_info);
|
98
|
+
g_callable_info_load_arg(info, i, arg_info);
|
99
|
+
metadata->scope_type = g_arg_info_get_scope(arg_info);
|
100
|
+
metadata->direction = g_arg_info_get_direction(arg_info);
|
101
|
+
metadata->callback_p = (metadata->scope_type != GI_SCOPE_TYPE_INVALID);
|
102
|
+
metadata->closure_p = FALSE;
|
103
|
+
metadata->destroy_p = FALSE;
|
104
|
+
metadata->inout_argv_p = FALSE;
|
105
|
+
metadata->in_arg_index = -1;
|
106
|
+
metadata->closure_in_arg_index = -1;
|
107
|
+
metadata->destroy_in_arg_index = -1;
|
108
|
+
metadata->rb_arg_index = -1;
|
109
|
+
metadata->out_arg_index = -1;
|
110
|
+
metadata->inout_argc_arg_index = -1;
|
111
|
+
|
112
|
+
direction = metadata->direction;
|
113
|
+
if (direction == GI_DIRECTION_IN || direction == GI_DIRECTION_INOUT) {
|
114
|
+
metadata->in_arg_index = in_args->len;
|
115
|
+
g_array_append_val(in_args, argument);
|
116
|
+
metadata->rb_arg_index = rb_arg_index++;
|
117
|
+
}
|
118
|
+
if (direction == GI_DIRECTION_OUT || direction == GI_DIRECTION_INOUT) {
|
119
|
+
metadata->out_arg_index = out_args->len;
|
120
|
+
g_array_append_val(out_args, argument);
|
121
|
+
}
|
122
|
+
|
123
|
+
g_ptr_array_add(args_metadata, metadata);
|
124
|
+
}
|
125
|
+
}
|
126
|
+
|
127
|
+
static void
|
128
|
+
fill_metadata_inout_argv(GPtrArray *args_metadata)
|
129
|
+
{
|
130
|
+
guint i;
|
131
|
+
gint inout_argc_arg_index = -1;
|
132
|
+
|
133
|
+
for (i = 0; i < args_metadata->len; i++) {
|
134
|
+
RBGIArgMetadata *metadata;
|
135
|
+
GIArgInfo *arg_info;
|
136
|
+
const gchar *name;
|
137
|
+
|
138
|
+
metadata = g_ptr_array_index(args_metadata, i);
|
139
|
+
if (metadata->direction != GI_DIRECTION_INOUT) {
|
140
|
+
continue;
|
141
|
+
}
|
142
|
+
arg_info = &(metadata->arg_info);
|
143
|
+
name = g_base_info_get_name(arg_info);
|
144
|
+
if (strcmp(name, "argc") == 0) {
|
145
|
+
inout_argc_arg_index = i;
|
146
|
+
} else if (strcmp(name, "argv") == 0) {
|
147
|
+
metadata->inout_argv_p = TRUE;
|
148
|
+
metadata->inout_argc_arg_index = inout_argc_arg_index;
|
149
|
+
}
|
150
|
+
}
|
151
|
+
}
|
152
|
+
|
153
|
+
static void
|
154
|
+
fill_metadata_callback(GPtrArray *args_metadata)
|
155
|
+
{
|
156
|
+
guint i;
|
157
|
+
|
158
|
+
for (i = 0; i < args_metadata->len; i++) {
|
159
|
+
RBGIArgMetadata *metadata;
|
160
|
+
GIArgInfo *arg_info;
|
161
|
+
gint closure_index;
|
162
|
+
gint destroy_index;
|
163
|
+
|
164
|
+
metadata = g_ptr_array_index(args_metadata, i);
|
165
|
+
if (!metadata->callback_p) {
|
166
|
+
continue;
|
167
|
+
}
|
168
|
+
|
169
|
+
arg_info = &(metadata->arg_info);
|
170
|
+
closure_index = g_arg_info_get_closure(arg_info);
|
171
|
+
if (closure_index != -1) {
|
172
|
+
RBGIArgMetadata *closure_metadata;
|
173
|
+
closure_metadata = g_ptr_array_index(args_metadata, closure_index);
|
174
|
+
closure_metadata->closure_p = TRUE;
|
175
|
+
metadata->closure_in_arg_index = closure_metadata->in_arg_index;
|
176
|
+
closure_metadata->rb_arg_index = -1;
|
177
|
+
}
|
178
|
+
|
179
|
+
destroy_index = g_arg_info_get_destroy(arg_info);
|
180
|
+
if (destroy_index != -1) {
|
181
|
+
RBGIArgMetadata *destroy_metadata;
|
182
|
+
destroy_metadata = g_ptr_array_index(args_metadata, destroy_index);
|
183
|
+
destroy_metadata->destroy_p = TRUE;
|
184
|
+
metadata->destroy_in_arg_index = destroy_metadata->in_arg_index;
|
185
|
+
destroy_metadata->rb_arg_index = -1;
|
186
|
+
}
|
187
|
+
}
|
188
|
+
}
|
189
|
+
|
190
|
+
static void
|
191
|
+
fill_metadata(GPtrArray *args_metadata)
|
192
|
+
{
|
193
|
+
fill_metadata_inout_argv(args_metadata);
|
194
|
+
fill_metadata_callback(args_metadata);
|
195
|
+
}
|
196
|
+
|
197
|
+
static void
|
198
|
+
callback_data_guard_from_gc(RBGICallbackData *callback_data)
|
199
|
+
{
|
200
|
+
VALUE rb_callbacks;
|
201
|
+
|
202
|
+
rb_callbacks = rb_iv_get(RG_TARGET_NAMESPACE, callbacks_key);
|
203
|
+
callback_data->rb_gc_guard_key = rb_class_new_instance(0, NULL, rb_cObject);
|
204
|
+
rb_hash_aset(rb_callbacks,
|
205
|
+
callback_data->rb_gc_guard_key,
|
206
|
+
callback_data->rb_callback);
|
207
|
+
}
|
208
|
+
|
209
|
+
static void
|
210
|
+
callback_data_unguard_from_gc(RBGICallbackData *callback_data)
|
211
|
+
{
|
212
|
+
VALUE rb_callbacks;
|
213
|
+
|
214
|
+
rb_callbacks = rb_iv_get(RG_TARGET_NAMESPACE, callbacks_key);
|
215
|
+
rb_hash_delete(rb_callbacks, callback_data->rb_gc_guard_key);
|
216
|
+
}
|
217
|
+
|
218
|
+
void
|
219
|
+
rb_gi_callback_data_free(RBGICallbackData *callback_data)
|
220
|
+
{
|
221
|
+
callback_data_unguard_from_gc(callback_data);
|
222
|
+
xfree(callback_data->metadata);
|
223
|
+
xfree(callback_data);
|
224
|
+
}
|
225
|
+
|
226
|
+
static void
|
227
|
+
destroy_notify(gpointer data)
|
228
|
+
{
|
229
|
+
RBGICallbackData *callback_data = data;
|
230
|
+
rb_gi_callback_data_free(callback_data);
|
231
|
+
}
|
232
|
+
|
233
|
+
static gpointer
|
234
|
+
find_callback_function(GIArgInfo *info)
|
235
|
+
{
|
236
|
+
guint i;
|
237
|
+
gpointer callback = NULL;
|
238
|
+
|
239
|
+
for (i = 0; i < callback_finders->len; i++) {
|
240
|
+
RBGICallbackFinderFunc finder = g_ptr_array_index(callback_finders, i);
|
241
|
+
callback = finder(info);
|
242
|
+
if (callback) {
|
243
|
+
break;
|
244
|
+
}
|
245
|
+
}
|
246
|
+
|
247
|
+
return callback;
|
248
|
+
}
|
249
|
+
|
250
|
+
void
|
251
|
+
rb_gi_callback_register_finder(RBGICallbackFinderFunc finder)
|
252
|
+
{
|
253
|
+
g_ptr_array_add(callback_finders, finder);
|
254
|
+
}
|
255
|
+
|
256
|
+
static gboolean
|
257
|
+
source_func_p(GIArgInfo *info)
|
258
|
+
{
|
259
|
+
GITypeInfo type_info;
|
260
|
+
GIBaseInfo *interface_info;
|
261
|
+
GICallableInfo *callback_info;
|
262
|
+
GITypeInfo return_type_info;
|
263
|
+
GIArgInfo first_arg_info;
|
264
|
+
GITypeInfo first_arg_type_info;
|
265
|
+
|
266
|
+
g_arg_info_load_type(info, &type_info);
|
267
|
+
if (g_type_info_get_tag(&type_info) != GI_TYPE_TAG_INTERFACE) {
|
268
|
+
return FALSE;
|
269
|
+
}
|
270
|
+
|
271
|
+
interface_info = g_type_info_get_interface(&type_info);
|
272
|
+
if (g_base_info_get_type(interface_info) != GI_INFO_TYPE_CALLBACK) {
|
273
|
+
g_base_info_unref(interface_info);
|
274
|
+
return FALSE;
|
275
|
+
}
|
276
|
+
|
277
|
+
callback_info = (GICallableInfo *)interface_info;
|
278
|
+
g_callable_info_load_return_type(callback_info, &return_type_info);
|
279
|
+
if (g_type_info_get_tag(&return_type_info) != GI_TYPE_TAG_BOOLEAN) {
|
280
|
+
g_base_info_unref(interface_info);
|
281
|
+
return FALSE;
|
282
|
+
}
|
283
|
+
|
284
|
+
if (g_callable_info_get_n_args(interface_info) != 1) {
|
285
|
+
g_base_info_unref(interface_info);
|
286
|
+
return FALSE;
|
287
|
+
}
|
288
|
+
|
289
|
+
g_callable_info_load_arg(interface_info, 0, &first_arg_info);
|
290
|
+
g_arg_info_load_type(&first_arg_info, &first_arg_type_info);
|
291
|
+
if (g_type_info_get_tag(&first_arg_type_info) != GI_TYPE_TAG_VOID) {
|
292
|
+
g_base_info_unref(interface_info);
|
293
|
+
return FALSE;
|
294
|
+
}
|
295
|
+
|
296
|
+
g_base_info_unref(interface_info);
|
297
|
+
return TRUE;
|
298
|
+
}
|
299
|
+
|
300
|
+
static gboolean
|
301
|
+
source_func_callback(gpointer user_data)
|
302
|
+
{
|
303
|
+
RBGICallbackData *callback_data = user_data;
|
304
|
+
VALUE rb_keep;
|
305
|
+
ID id_call;
|
306
|
+
|
307
|
+
CONST_ID(id_call, "call");
|
308
|
+
rb_keep = rb_funcall(callback_data->rb_callback, id_call, 0);
|
309
|
+
if (callback_data->metadata->scope_type == GI_SCOPE_TYPE_ASYNC) {
|
310
|
+
rb_gi_callback_data_free(callback_data);
|
311
|
+
}
|
312
|
+
return RVAL2CBOOL(rb_keep);
|
313
|
+
}
|
314
|
+
|
315
|
+
static gpointer
|
316
|
+
source_func_callback_finder(GIArgInfo *arg_info)
|
317
|
+
{
|
318
|
+
if (!source_func_p(arg_info)) {
|
319
|
+
return NULL;
|
320
|
+
}
|
321
|
+
return source_func_callback;
|
322
|
+
}
|
323
|
+
|
324
|
+
static void
|
325
|
+
in_callback_argument_from_ruby(RBGIArgMetadata *metadata, VALUE *argv,
|
326
|
+
GArray *in_args)
|
327
|
+
{
|
328
|
+
gpointer callback;
|
329
|
+
GIArgInfo *arg_info;
|
330
|
+
GIArgument *callback_argument;
|
331
|
+
|
332
|
+
arg_info = &(metadata->arg_info);
|
333
|
+
callback = find_callback_function(arg_info);
|
334
|
+
if (!callback) {
|
335
|
+
GITypeInfo type_info;
|
336
|
+
GIBaseInfo *interface_info;
|
337
|
+
VALUE rb_type_name;
|
338
|
+
g_arg_info_load_type(arg_info, &type_info);
|
339
|
+
interface_info = g_type_info_get_interface(&type_info);
|
340
|
+
rb_type_name = CSTR2RVAL(g_base_info_get_name(interface_info));
|
341
|
+
g_base_info_unref(interface_info);
|
342
|
+
rb_raise(rb_eNotImpError,
|
343
|
+
"TODO: <%s>(%s) callback is not supported yet.",
|
344
|
+
RVAL2CSTR(rb_type_name),
|
345
|
+
g_base_info_get_name(arg_info));
|
346
|
+
}
|
347
|
+
|
348
|
+
callback_argument = &(g_array_index(in_args,
|
349
|
+
GIArgument,
|
350
|
+
metadata->in_arg_index));
|
351
|
+
callback_argument->v_pointer = callback;
|
352
|
+
|
353
|
+
if (metadata->closure_in_arg_index != -1) {
|
354
|
+
RBGICallbackData *callback_data;
|
355
|
+
GIArgument *closure_argument;
|
356
|
+
|
357
|
+
callback_data = ALLOC(RBGICallbackData);
|
358
|
+
callback_data->metadata = metadata;
|
359
|
+
callback_data->rb_callback = rb_block_proc();
|
360
|
+
callback_data_guard_from_gc(callback_data);
|
361
|
+
closure_argument = &(g_array_index(in_args,
|
362
|
+
GIArgument,
|
363
|
+
metadata->closure_in_arg_index));
|
364
|
+
closure_argument->v_pointer = callback_data;
|
365
|
+
}
|
366
|
+
|
367
|
+
if (metadata->destroy_in_arg_index != -1) {
|
368
|
+
GIArgument *destroy_argument;
|
369
|
+
destroy_argument = &(g_array_index(in_args,
|
370
|
+
GIArgument,
|
371
|
+
metadata->destroy_in_arg_index));
|
372
|
+
destroy_argument->v_pointer = destroy_notify;
|
373
|
+
}
|
374
|
+
}
|
375
|
+
|
376
|
+
static void
|
377
|
+
in_argument_from_ruby(RBGIArgMetadata *metadata, VALUE *argv, GArray *in_args)
|
378
|
+
{
|
379
|
+
if (metadata->rb_arg_index == -1) {
|
380
|
+
return;
|
381
|
+
}
|
382
|
+
|
383
|
+
if (metadata->callback_p) {
|
384
|
+
in_callback_argument_from_ruby(metadata, argv, in_args);
|
385
|
+
} else {
|
386
|
+
GIArgument *argument;
|
387
|
+
|
388
|
+
argument = &(g_array_index(in_args, GIArgument, metadata->in_arg_index));
|
389
|
+
RVAL2GI_CALL_ARGUMENT(argument,
|
390
|
+
&(metadata->arg_info),
|
391
|
+
argv[metadata->rb_arg_index]);
|
392
|
+
}
|
393
|
+
}
|
394
|
+
|
395
|
+
static void
|
396
|
+
out_argument_from_ruby(RBGIArgMetadata *metadata, GArray *out_args)
|
397
|
+
{
|
398
|
+
GIArgument *argument;
|
399
|
+
|
400
|
+
argument = &(g_array_index(out_args, GIArgument, metadata->out_arg_index));
|
401
|
+
rb_gi_out_argument_init(argument, &(metadata->arg_info));
|
402
|
+
}
|
403
|
+
|
404
|
+
static void
|
405
|
+
arg_metadata_free(gpointer data)
|
406
|
+
{
|
407
|
+
RBGIArgMetadata *metadata = data;
|
408
|
+
if (metadata->scope_type == GI_SCOPE_TYPE_ASYNC ||
|
409
|
+
metadata->scope_type == GI_SCOPE_TYPE_NOTIFIED) {
|
410
|
+
return;
|
411
|
+
}
|
412
|
+
xfree(metadata);
|
413
|
+
}
|
414
|
+
|
415
|
+
static void
|
416
|
+
arguments_from_ruby(GICallableInfo *info,
|
417
|
+
int argc, VALUE *argv,
|
418
|
+
GArray *in_args, GArray *out_args,
|
419
|
+
GPtrArray *args_metadata)
|
420
|
+
{
|
421
|
+
gint i, n_args;
|
422
|
+
|
423
|
+
allocate_arguments(info, in_args, out_args, args_metadata);
|
424
|
+
fill_metadata(args_metadata);
|
425
|
+
|
426
|
+
/* TODO: validate_rb_args(args_metadata); */
|
427
|
+
|
428
|
+
n_args = g_callable_info_get_n_args(info);
|
429
|
+
for (i = 0; i < n_args; i++) {
|
430
|
+
RBGIArgMetadata *metadata;
|
431
|
+
|
432
|
+
metadata = g_ptr_array_index(args_metadata, i);
|
433
|
+
if (metadata->in_arg_index != -1) {
|
434
|
+
in_argument_from_ruby(metadata, argv, in_args);
|
435
|
+
} else {
|
436
|
+
out_argument_from_ruby(metadata, out_args);
|
437
|
+
}
|
438
|
+
}
|
439
|
+
}
|
440
|
+
|
441
|
+
static VALUE
|
442
|
+
inout_argv_argument_to_ruby(GArray *in_args, RBGIArgMetadata *metadata)
|
443
|
+
{
|
444
|
+
GIArgument *inout_argc_argument;
|
445
|
+
GIArgument *inout_argv_argument;
|
446
|
+
gint i, argc;
|
447
|
+
gchar **argv;
|
448
|
+
VALUE rb_argv_argument;
|
449
|
+
|
450
|
+
inout_argc_argument = &g_array_index(in_args, GIArgument,
|
451
|
+
metadata->inout_argc_arg_index);
|
452
|
+
inout_argv_argument = &g_array_index(in_args, GIArgument,
|
453
|
+
metadata->in_arg_index);
|
454
|
+
argc = *((gint *)(inout_argc_argument->v_pointer));
|
455
|
+
argv = *((gchar ***)(inout_argv_argument->v_pointer));
|
456
|
+
rb_argv_argument = rb_ary_new2(argc);
|
457
|
+
for (i = 0; i < argc; i++) {
|
458
|
+
rb_ary_push(rb_argv_argument, CSTR2RVAL(argv[i]));
|
459
|
+
}
|
460
|
+
return rb_argv_argument;
|
461
|
+
}
|
462
|
+
|
463
|
+
static VALUE
|
464
|
+
out_arguments_to_ruby(GICallableInfo *callable_info,
|
465
|
+
GArray *in_args, GArray *out_args,
|
466
|
+
GPtrArray *args_metadata)
|
467
|
+
{
|
468
|
+
gint i, n_args;
|
469
|
+
VALUE rb_out_args;
|
470
|
+
|
471
|
+
rb_out_args = rb_ary_new();
|
472
|
+
n_args = g_callable_info_get_n_args(callable_info);
|
473
|
+
for (i = 0; i < n_args; i++) {
|
474
|
+
RBGIArgMetadata *metadata;
|
475
|
+
GIArgument *argument = NULL;
|
476
|
+
VALUE rb_argument;
|
477
|
+
|
478
|
+
metadata = g_ptr_array_index(args_metadata, i);
|
479
|
+
switch (metadata->direction) {
|
480
|
+
case GI_DIRECTION_IN:
|
481
|
+
break;
|
482
|
+
case GI_DIRECTION_OUT:
|
483
|
+
argument = &g_array_index(out_args, GIArgument,
|
484
|
+
metadata->out_arg_index);
|
485
|
+
break;
|
486
|
+
case GI_DIRECTION_INOUT:
|
487
|
+
argument = &g_array_index(in_args, GIArgument,
|
488
|
+
metadata->in_arg_index);
|
489
|
+
break;
|
490
|
+
default:
|
491
|
+
g_assert_not_reached();
|
492
|
+
break;
|
493
|
+
}
|
494
|
+
|
495
|
+
if (!argument) {
|
496
|
+
continue;
|
497
|
+
}
|
498
|
+
|
499
|
+
if (metadata->inout_argv_p) {
|
500
|
+
rb_argument = inout_argv_argument_to_ruby(in_args, metadata);
|
501
|
+
} else {
|
502
|
+
rb_argument = GI_OUT_ARGUMENT2RVAL(argument, &(metadata->arg_info));
|
503
|
+
}
|
504
|
+
rb_ary_push(rb_out_args, rb_argument);
|
505
|
+
}
|
506
|
+
|
507
|
+
if (RARRAY_LEN(rb_out_args) == 0) {
|
508
|
+
return Qnil;
|
509
|
+
} else {
|
510
|
+
return rb_out_args;
|
511
|
+
}
|
512
|
+
}
|
513
|
+
|
514
|
+
static void
|
515
|
+
arguments_init(GArray **in_args, GArray **out_args, GPtrArray **args_metadata)
|
516
|
+
{
|
517
|
+
*in_args = g_array_new(FALSE, FALSE, sizeof(GIArgument));
|
518
|
+
*out_args = g_array_new(FALSE, FALSE, sizeof(GIArgument));
|
519
|
+
*args_metadata = g_ptr_array_new_with_free_func(arg_metadata_free);
|
520
|
+
}
|
521
|
+
|
522
|
+
static void
|
523
|
+
arguments_free(GArray *in_args, GArray *out_args, GPtrArray *args_metadata)
|
524
|
+
{
|
525
|
+
guint i;
|
526
|
+
|
527
|
+
for (i = 0; i < args_metadata->len; i++) {
|
528
|
+
RBGIArgMetadata *metadata;
|
529
|
+
gint in_arg_index;
|
530
|
+
|
531
|
+
metadata = g_ptr_array_index(args_metadata, i);
|
532
|
+
if (metadata->direction == GI_DIRECTION_IN ||
|
533
|
+
metadata->direction == GI_DIRECTION_INOUT) {
|
534
|
+
in_arg_index = metadata->in_arg_index;
|
535
|
+
if (in_arg_index != -1) {
|
536
|
+
GIArgument *argument;
|
537
|
+
argument = &(g_array_index(in_args, GIArgument, in_arg_index));
|
538
|
+
rb_gi_call_argument_free(argument, &(metadata->arg_info));
|
539
|
+
}
|
540
|
+
} else {
|
541
|
+
GIArgument *argument;
|
542
|
+
argument = &(g_array_index(out_args, GIArgument,
|
543
|
+
metadata->out_arg_index));
|
544
|
+
rb_gi_out_argument_fin(argument, &(metadata->arg_info));
|
545
|
+
}
|
546
|
+
}
|
547
|
+
|
548
|
+
g_array_unref(in_args);
|
549
|
+
g_array_unref(out_args);
|
550
|
+
g_ptr_array_unref(args_metadata);
|
551
|
+
}
|
552
|
+
|
553
|
+
VALUE
|
554
|
+
rb_gi_function_info_invoke_raw(GIFunctionInfo *info, GIArgument *receiver,
|
555
|
+
int argc, VALUE *argv,
|
556
|
+
GIArgument *return_value)
|
557
|
+
{
|
558
|
+
GICallableInfo *callable_info;
|
559
|
+
GArray *in_args, *out_args;
|
560
|
+
GPtrArray *args_metadata;
|
561
|
+
VALUE rb_out_args = Qnil;
|
562
|
+
gboolean succeeded;
|
563
|
+
GError *error = NULL;
|
564
|
+
|
565
|
+
callable_info = (GICallableInfo *)info;
|
566
|
+
arguments_init(&in_args, &out_args, &args_metadata);
|
567
|
+
if (receiver) {
|
568
|
+
g_array_append_val(in_args, *receiver);
|
569
|
+
}
|
570
|
+
arguments_from_ruby(callable_info,
|
571
|
+
argc, argv,
|
572
|
+
in_args, out_args, args_metadata);
|
573
|
+
succeeded = g_function_info_invoke(info,
|
574
|
+
(GIArgument *)(in_args->data),
|
575
|
+
in_args->len,
|
576
|
+
(GIArgument *)(out_args->data),
|
577
|
+
out_args->len,
|
578
|
+
return_value,
|
579
|
+
&error);
|
580
|
+
if (succeeded) {
|
581
|
+
rb_out_args = out_arguments_to_ruby(callable_info,
|
582
|
+
in_args, out_args,
|
583
|
+
args_metadata);
|
584
|
+
}
|
585
|
+
arguments_free(in_args, out_args, args_metadata);
|
586
|
+
if (!succeeded) {
|
587
|
+
RG_RAISE_ERROR(error);
|
588
|
+
}
|
589
|
+
|
590
|
+
if (!NIL_P(rb_out_args) && RARRAY_LEN(rb_out_args) == 1) {
|
591
|
+
VALUE rb_out_arg;
|
592
|
+
rb_out_arg = RARRAY_PTR(rb_out_args)[0];
|
593
|
+
if (rb_obj_is_kind_of(rb_out_arg, rb_cGLibError)) {
|
594
|
+
rb_exc_raise(rb_out_arg);
|
595
|
+
}
|
596
|
+
}
|
597
|
+
|
598
|
+
return rb_out_args;
|
599
|
+
}
|
600
|
+
|
601
|
+
static VALUE
|
602
|
+
rg_invoke(int argc, VALUE *argv, VALUE self)
|
603
|
+
{
|
604
|
+
GIFunctionInfo *info;
|
605
|
+
GICallableInfo *callable_info;
|
606
|
+
GIArgument return_value;
|
607
|
+
VALUE rb_out_args;
|
608
|
+
VALUE rb_return_value;
|
609
|
+
|
610
|
+
info = SELF(self);
|
611
|
+
/* TODO: use rb_protect() */
|
612
|
+
rb_out_args = rb_gi_function_info_invoke_raw(info, NULL, argc, argv,
|
613
|
+
&return_value);
|
614
|
+
|
615
|
+
callable_info = (GICallableInfo *)info;
|
616
|
+
rb_return_value = GI_RETURN_ARGUMENT2RVAL(&return_value, callable_info);
|
617
|
+
|
618
|
+
if (NIL_P(rb_out_args)) {
|
619
|
+
return rb_return_value;
|
620
|
+
} else {
|
621
|
+
GITypeInfo return_value_info;
|
622
|
+
g_callable_info_load_return_type(callable_info, &return_value_info);
|
623
|
+
if (g_type_info_get_tag(&return_value_info) != GI_TYPE_TAG_VOID) {
|
624
|
+
rb_ary_unshift(rb_out_args, rb_return_value);
|
625
|
+
}
|
626
|
+
if (RARRAY_LEN(rb_out_args) == 1) {
|
627
|
+
return RARRAY_PTR(rb_out_args)[0];
|
628
|
+
} else {
|
629
|
+
return rb_out_args;
|
630
|
+
}
|
631
|
+
}
|
632
|
+
}
|
633
|
+
|
634
|
+
void
|
635
|
+
rb_gi_function_info_init(VALUE rb_mGI, VALUE rb_cGICallableInfo)
|
636
|
+
{
|
637
|
+
rb_cGLibError = rb_const_get(mGLib, rb_intern("Error"));
|
638
|
+
|
639
|
+
RG_TARGET_NAMESPACE =
|
640
|
+
G_DEF_CLASS_WITH_PARENT(GI_TYPE_FUNCTION_INFO, "FunctionInfo", rb_mGI,
|
641
|
+
rb_cGICallableInfo);
|
642
|
+
|
643
|
+
rb_iv_set(RG_TARGET_NAMESPACE, callbacks_key, rb_hash_new());
|
644
|
+
|
645
|
+
callback_finders = g_ptr_array_new();
|
646
|
+
rb_gi_callback_register_finder(source_func_callback_finder);
|
647
|
+
|
648
|
+
RG_DEF_METHOD(symbol, 0);
|
649
|
+
RG_DEF_METHOD(flags, 0);
|
650
|
+
RG_DEF_METHOD(property, 0);
|
651
|
+
RG_DEF_METHOD(vfunc, 0);
|
652
|
+
RG_DEF_METHOD(invoke, -1);
|
653
|
+
|
654
|
+
G_DEF_CLASS(G_TYPE_I_FUNCTION_INFO_FLAGS, "FunctionInfoFlags", rb_mGI);
|
655
|
+
|
656
|
+
rb_gi_method_info_init(rb_mGI, RG_TARGET_NAMESPACE);
|
657
|
+
rb_gi_constructor_info_init(rb_mGI, RG_TARGET_NAMESPACE);
|
658
|
+
}
|