gobject-introspection 2.2.4-x64-mingw32

Sign up to get free protection for your applications and to get access to all the features.
Files changed (294) hide show
  1. checksums.yaml +7 -0
  2. data/Rakefile +129 -0
  3. data/ext/gobject-introspection/depend +10 -0
  4. data/ext/gobject-introspection/extconf.rb +94 -0
  5. data/ext/gobject-introspection/gobject_introspection.def +5 -0
  6. data/ext/gobject-introspection/rb-gi-arg-info.c +151 -0
  7. data/ext/gobject-introspection/rb-gi-argument.c +2053 -0
  8. data/ext/gobject-introspection/rb-gi-base-info.c +218 -0
  9. data/ext/gobject-introspection/rb-gi-boxed-info.c +48 -0
  10. data/ext/gobject-introspection/rb-gi-callable-info.c +104 -0
  11. data/ext/gobject-introspection/rb-gi-callback-info.c +48 -0
  12. data/ext/gobject-introspection/rb-gi-constant-info.c +77 -0
  13. data/ext/gobject-introspection/rb-gi-constructor-info.c +133 -0
  14. data/ext/gobject-introspection/rb-gi-conversions.h +145 -0
  15. data/ext/gobject-introspection/rb-gi-enum-info.c +155 -0
  16. data/ext/gobject-introspection/rb-gi-field-info.c +153 -0
  17. data/ext/gobject-introspection/rb-gi-flags-info.c +48 -0
  18. data/ext/gobject-introspection/rb-gi-function-info.c +841 -0
  19. data/ext/gobject-introspection/rb-gi-interface-info.c +222 -0
  20. data/ext/gobject-introspection/rb-gi-loader.c +224 -0
  21. data/ext/gobject-introspection/rb-gi-method-info.c +83 -0
  22. data/ext/gobject-introspection/rb-gi-object-info.c +345 -0
  23. data/ext/gobject-introspection/rb-gi-private.h +105 -0
  24. data/ext/gobject-introspection/rb-gi-property-info.c +77 -0
  25. data/ext/gobject-introspection/rb-gi-registered-type-info.c +86 -0
  26. data/ext/gobject-introspection/rb-gi-repository.c +246 -0
  27. data/ext/gobject-introspection/rb-gi-signal-info.c +77 -0
  28. data/ext/gobject-introspection/rb-gi-struct-info.c +202 -0
  29. data/ext/gobject-introspection/rb-gi-type-info.c +143 -0
  30. data/ext/gobject-introspection/rb-gi-type-tag.c +43 -0
  31. data/ext/gobject-introspection/rb-gi-types.h +71 -0
  32. data/ext/gobject-introspection/rb-gi-union-info.c +206 -0
  33. data/ext/gobject-introspection/rb-gi-unresolved-info.c +48 -0
  34. data/ext/gobject-introspection/rb-gi-value-info.c +57 -0
  35. data/ext/gobject-introspection/rb-gi-vfunc-info.c +91 -0
  36. data/ext/gobject-introspection/rb-gobject-introspection.c +44 -0
  37. data/ext/gobject-introspection/rb-gobject-introspection.h +60 -0
  38. data/extconf.rb +71 -0
  39. data/lib/2.0/gobject_introspection.so +0 -0
  40. data/lib/2.1/gobject_introspection.so +0 -0
  41. data/lib/2.2/gobject_introspection.so +0 -0
  42. data/lib/gobject-introspection.rb +53 -0
  43. data/lib/gobject-introspection/boxed-info.rb +28 -0
  44. data/lib/gobject-introspection/callable-info.rb +100 -0
  45. data/lib/gobject-introspection/collection-reader.rb +34 -0
  46. data/lib/gobject-introspection/interface-info.rb +32 -0
  47. data/lib/gobject-introspection/loader.rb +465 -0
  48. data/lib/gobject-introspection/object-info.rb +33 -0
  49. data/lib/gobject-introspection/repository.rb +32 -0
  50. data/lib/gobject-introspection/struct-info.rb +28 -0
  51. data/lib/gobject-introspection/union-info.rb +28 -0
  52. data/test/gobject-introspection-test-utils.rb +26 -0
  53. data/test/run-test.rb +45 -0
  54. data/test/test-arg-info.rb +68 -0
  55. data/test/test-base-info.rb +31 -0
  56. data/test/test-boxed-info.rb +21 -0
  57. data/test/test-callable-info.rb +49 -0
  58. data/test/test-callback-info.rb +29 -0
  59. data/test/test-constant-info.rb +24 -0
  60. data/test/test-enum-info.rb +61 -0
  61. data/test/test-field-type.rb +42 -0
  62. data/test/test-flags-info.rb +27 -0
  63. data/test/test-function-info.rb +39 -0
  64. data/test/test-interface-info.rb +97 -0
  65. data/test/test-loader.rb +30 -0
  66. data/test/test-object-info.rb +131 -0
  67. data/test/test-property-info.rb +38 -0
  68. data/test/test-registered-type-info.rb +35 -0
  69. data/test/test-repository.rb +62 -0
  70. data/test/test-signal-info.rb +40 -0
  71. data/test/test-struct-info.rb +57 -0
  72. data/test/test-type-info.rb +62 -0
  73. data/test/test-type-tag.rb +29 -0
  74. data/test/test-union-info.rb +21 -0
  75. data/test/test-value-info.rb +28 -0
  76. data/test/test-vfunc-info.rb +42 -0
  77. data/vendor/local/bin/g-ir-compiler.exe +0 -0
  78. data/vendor/local/bin/g-ir-generate.exe +0 -0
  79. data/vendor/local/bin/libgirepository-1.0-1.dll +0 -0
  80. data/vendor/local/include/gobject-introspection-1.0/giarginfo.h +82 -0
  81. data/vendor/local/include/gobject-introspection-1.0/gibaseinfo.h +120 -0
  82. data/vendor/local/include/gobject-introspection-1.0/gicallableinfo.h +110 -0
  83. data/vendor/local/include/gobject-introspection-1.0/giconstantinfo.h +58 -0
  84. data/vendor/local/include/gobject-introspection-1.0/gienuminfo.h +82 -0
  85. data/vendor/local/include/gobject-introspection-1.0/gifieldinfo.h +71 -0
  86. data/vendor/local/include/gobject-introspection-1.0/gifunctioninfo.h +100 -0
  87. data/vendor/local/include/gobject-introspection-1.0/giinterfaceinfo.h +106 -0
  88. data/vendor/local/include/gobject-introspection-1.0/giobjectinfo.h +207 -0
  89. data/vendor/local/include/gobject-introspection-1.0/gipropertyinfo.h +56 -0
  90. data/vendor/local/include/gobject-introspection-1.0/giregisteredtypeinfo.h +64 -0
  91. data/vendor/local/include/gobject-introspection-1.0/girepository.h +239 -0
  92. data/vendor/local/include/gobject-introspection-1.0/girffi.h +104 -0
  93. data/vendor/local/include/gobject-introspection-1.0/gisignalinfo.h +57 -0
  94. data/vendor/local/include/gobject-introspection-1.0/gistructinfo.h +77 -0
  95. data/vendor/local/include/gobject-introspection-1.0/gitypeinfo.h +87 -0
  96. data/vendor/local/include/gobject-introspection-1.0/gitypelib.h +80 -0
  97. data/vendor/local/include/gobject-introspection-1.0/gitypes.h +524 -0
  98. data/vendor/local/include/gobject-introspection-1.0/giunioninfo.h +84 -0
  99. data/vendor/local/include/gobject-introspection-1.0/giversionmacros.h +128 -0
  100. data/vendor/local/include/gobject-introspection-1.0/givfuncinfo.h +73 -0
  101. data/vendor/local/lib/girepository-1.0/DBus-1.0.typelib +0 -0
  102. data/vendor/local/lib/girepository-1.0/DBusGLib-1.0.typelib +0 -0
  103. data/vendor/local/lib/girepository-1.0/GIRepository-2.0.typelib +0 -0
  104. data/vendor/local/lib/girepository-1.0/GL-1.0.typelib +0 -0
  105. data/vendor/local/lib/girepository-1.0/GLib-2.0.typelib +0 -0
  106. data/vendor/local/lib/girepository-1.0/GModule-2.0.typelib +0 -0
  107. data/vendor/local/lib/girepository-1.0/GObject-2.0.typelib +0 -0
  108. data/vendor/local/lib/girepository-1.0/Gio-2.0.typelib +0 -0
  109. data/vendor/local/lib/girepository-1.0/cairo-1.0.typelib +0 -0
  110. data/vendor/local/lib/girepository-1.0/fontconfig-2.0.typelib +0 -0
  111. data/vendor/local/lib/girepository-1.0/freetype2-2.0.typelib +0 -0
  112. data/vendor/local/lib/girepository-1.0/libxml2-2.0.typelib +0 -0
  113. data/vendor/local/lib/girepository-1.0/win32-1.0.typelib +0 -0
  114. data/vendor/local/lib/girepository-1.0/xfixes-4.0.typelib +0 -0
  115. data/vendor/local/lib/girepository-1.0/xft-2.0.typelib +0 -0
  116. data/vendor/local/lib/girepository-1.0/xlib-2.0.typelib +0 -0
  117. data/vendor/local/lib/girepository-1.0/xrandr-1.3.typelib +0 -0
  118. data/vendor/local/lib/gobject-introspection/giscanner/__init__.py +24 -0
  119. data/vendor/local/lib/gobject-introspection/giscanner/__init__.pyc +0 -0
  120. data/vendor/local/lib/gobject-introspection/giscanner/__init__.pyo +0 -0
  121. data/vendor/local/lib/gobject-introspection/giscanner/annotationmain.py +76 -0
  122. data/vendor/local/lib/gobject-introspection/giscanner/annotationmain.pyc +0 -0
  123. data/vendor/local/lib/gobject-introspection/giscanner/annotationmain.pyo +0 -0
  124. data/vendor/local/lib/gobject-introspection/giscanner/annotationparser.py +2161 -0
  125. data/vendor/local/lib/gobject-introspection/giscanner/annotationparser.pyc +0 -0
  126. data/vendor/local/lib/gobject-introspection/giscanner/annotationparser.pyo +0 -0
  127. data/vendor/local/lib/gobject-introspection/giscanner/ast.py +1139 -0
  128. data/vendor/local/lib/gobject-introspection/giscanner/ast.pyc +0 -0
  129. data/vendor/local/lib/gobject-introspection/giscanner/ast.pyo +0 -0
  130. data/vendor/local/lib/gobject-introspection/giscanner/cachestore.py +203 -0
  131. data/vendor/local/lib/gobject-introspection/giscanner/cachestore.pyc +0 -0
  132. data/vendor/local/lib/gobject-introspection/giscanner/cachestore.pyo +0 -0
  133. data/vendor/local/lib/gobject-introspection/giscanner/ccompiler.py +202 -0
  134. data/vendor/local/lib/gobject-introspection/giscanner/ccompiler.pyc +0 -0
  135. data/vendor/local/lib/gobject-introspection/giscanner/ccompiler.pyo +0 -0
  136. data/vendor/local/lib/gobject-introspection/giscanner/codegen.py +173 -0
  137. data/vendor/local/lib/gobject-introspection/giscanner/codegen.pyc +0 -0
  138. data/vendor/local/lib/gobject-introspection/giscanner/codegen.pyo +0 -0
  139. data/vendor/local/lib/gobject-introspection/giscanner/collections/__init__.py +23 -0
  140. data/vendor/local/lib/gobject-introspection/giscanner/collections/__init__.pyc +0 -0
  141. data/vendor/local/lib/gobject-introspection/giscanner/collections/__init__.pyo +0 -0
  142. data/vendor/local/lib/gobject-introspection/giscanner/collections/counter.py +305 -0
  143. data/vendor/local/lib/gobject-introspection/giscanner/collections/counter.pyc +0 -0
  144. data/vendor/local/lib/gobject-introspection/giscanner/collections/counter.pyo +0 -0
  145. data/vendor/local/lib/gobject-introspection/giscanner/collections/ordereddict.py +120 -0
  146. data/vendor/local/lib/gobject-introspection/giscanner/collections/ordereddict.pyc +0 -0
  147. data/vendor/local/lib/gobject-introspection/giscanner/collections/ordereddict.pyo +0 -0
  148. data/vendor/local/lib/gobject-introspection/giscanner/docmain.py +72 -0
  149. data/vendor/local/lib/gobject-introspection/giscanner/docmain.pyc +0 -0
  150. data/vendor/local/lib/gobject-introspection/giscanner/docmain.pyo +0 -0
  151. data/vendor/local/lib/gobject-introspection/giscanner/doctemplates/C/callback.tmpl +4 -0
  152. data/vendor/local/lib/gobject-introspection/giscanner/doctemplates/C/class.tmpl +2 -0
  153. data/vendor/local/lib/gobject-introspection/giscanner/doctemplates/C/constructor.tmpl +1 -0
  154. data/vendor/local/lib/gobject-introspection/giscanner/doctemplates/C/default.tmpl +1 -0
  155. data/vendor/local/lib/gobject-introspection/giscanner/doctemplates/C/enum.tmpl +2 -0
  156. data/vendor/local/lib/gobject-introspection/giscanner/doctemplates/C/field.tmpl +1 -0
  157. data/vendor/local/lib/gobject-introspection/giscanner/doctemplates/C/function.tmpl +60 -0
  158. data/vendor/local/lib/gobject-introspection/giscanner/doctemplates/C/interface.tmpl +2 -0
  159. data/vendor/local/lib/gobject-introspection/giscanner/doctemplates/C/method.tmpl +1 -0
  160. data/vendor/local/lib/gobject-introspection/giscanner/doctemplates/C/namespace.tmpl +1 -0
  161. data/vendor/local/lib/gobject-introspection/giscanner/doctemplates/C/property.tmpl +5 -0
  162. data/vendor/local/lib/gobject-introspection/giscanner/doctemplates/C/record.tmpl +1 -0
  163. data/vendor/local/lib/gobject-introspection/giscanner/doctemplates/C/signal.tmpl +5 -0
  164. data/vendor/local/lib/gobject-introspection/giscanner/doctemplates/C/vfunc.tmpl +4 -0
  165. data/vendor/local/lib/gobject-introspection/giscanner/doctemplates/Gjs/callback.tmpl +27 -0
  166. data/vendor/local/lib/gobject-introspection/giscanner/doctemplates/Gjs/class.tmpl +30 -0
  167. data/vendor/local/lib/gobject-introspection/giscanner/doctemplates/Gjs/constructor.tmpl +1 -0
  168. data/vendor/local/lib/gobject-introspection/giscanner/doctemplates/Gjs/default.tmpl +1 -0
  169. data/vendor/local/lib/gobject-introspection/giscanner/doctemplates/Gjs/enum.tmpl +21 -0
  170. data/vendor/local/lib/gobject-introspection/giscanner/doctemplates/Gjs/field.tmpl +9 -0
  171. data/vendor/local/lib/gobject-introspection/giscanner/doctemplates/Gjs/function.tmpl +47 -0
  172. data/vendor/local/lib/gobject-introspection/giscanner/doctemplates/Gjs/interface.tmpl +17 -0
  173. data/vendor/local/lib/gobject-introspection/giscanner/doctemplates/Gjs/method.tmpl +1 -0
  174. data/vendor/local/lib/gobject-introspection/giscanner/doctemplates/Gjs/namespace.tmpl +2 -0
  175. data/vendor/local/lib/gobject-introspection/giscanner/doctemplates/Gjs/property.tmpl +9 -0
  176. data/vendor/local/lib/gobject-introspection/giscanner/doctemplates/Gjs/record.tmpl +2 -0
  177. data/vendor/local/lib/gobject-introspection/giscanner/doctemplates/Gjs/signal.tmpl +38 -0
  178. data/vendor/local/lib/gobject-introspection/giscanner/doctemplates/Gjs/vfunc.tmpl +27 -0
  179. data/vendor/local/lib/gobject-introspection/giscanner/doctemplates/Python/callback.tmpl +27 -0
  180. data/vendor/local/lib/gobject-introspection/giscanner/doctemplates/Python/class.tmpl +18 -0
  181. data/vendor/local/lib/gobject-introspection/giscanner/doctemplates/Python/constructor.tmpl +1 -0
  182. data/vendor/local/lib/gobject-introspection/giscanner/doctemplates/Python/default.tmpl +1 -0
  183. data/vendor/local/lib/gobject-introspection/giscanner/doctemplates/Python/enum.tmpl +13 -0
  184. data/vendor/local/lib/gobject-introspection/giscanner/doctemplates/Python/field.tmpl +1 -0
  185. data/vendor/local/lib/gobject-introspection/giscanner/doctemplates/Python/function.tmpl +47 -0
  186. data/vendor/local/lib/gobject-introspection/giscanner/doctemplates/Python/interface.tmpl +16 -0
  187. data/vendor/local/lib/gobject-introspection/giscanner/doctemplates/Python/method.tmpl +1 -0
  188. data/vendor/local/lib/gobject-introspection/giscanner/doctemplates/Python/namespace.tmpl +2 -0
  189. data/vendor/local/lib/gobject-introspection/giscanner/doctemplates/Python/property.tmpl +9 -0
  190. data/vendor/local/lib/gobject-introspection/giscanner/doctemplates/Python/record.tmpl +2 -0
  191. data/vendor/local/lib/gobject-introspection/giscanner/doctemplates/Python/signal.tmpl +41 -0
  192. data/vendor/local/lib/gobject-introspection/giscanner/doctemplates/Python/vfunc.tmpl +27 -0
  193. data/vendor/local/lib/gobject-introspection/giscanner/doctemplates/base.tmpl +20 -0
  194. data/vendor/local/lib/gobject-introspection/giscanner/doctemplates/class.tmpl +61 -0
  195. data/vendor/local/lib/gobject-introspection/giscanner/doctemplates/namespace.tmpl +16 -0
  196. data/vendor/local/lib/gobject-introspection/giscanner/docwriter.py +958 -0
  197. data/vendor/local/lib/gobject-introspection/giscanner/docwriter.pyc +0 -0
  198. data/vendor/local/lib/gobject-introspection/giscanner/docwriter.pyo +0 -0
  199. data/vendor/local/lib/gobject-introspection/giscanner/dumper.py +338 -0
  200. data/vendor/local/lib/gobject-introspection/giscanner/dumper.pyc +0 -0
  201. data/vendor/local/lib/gobject-introspection/giscanner/dumper.pyo +0 -0
  202. data/vendor/local/lib/gobject-introspection/giscanner/gdumpparser.py +529 -0
  203. data/vendor/local/lib/gobject-introspection/giscanner/gdumpparser.pyc +0 -0
  204. data/vendor/local/lib/gobject-introspection/giscanner/gdumpparser.pyo +0 -0
  205. data/vendor/local/lib/gobject-introspection/giscanner/girparser.py +593 -0
  206. data/vendor/local/lib/gobject-introspection/giscanner/girparser.pyc +0 -0
  207. data/vendor/local/lib/gobject-introspection/giscanner/girparser.pyo +0 -0
  208. data/vendor/local/lib/gobject-introspection/giscanner/girwriter.py +612 -0
  209. data/vendor/local/lib/gobject-introspection/giscanner/girwriter.pyc +0 -0
  210. data/vendor/local/lib/gobject-introspection/giscanner/girwriter.pyo +0 -0
  211. data/vendor/local/lib/gobject-introspection/giscanner/introspectablepass.py +240 -0
  212. data/vendor/local/lib/gobject-introspection/giscanner/introspectablepass.pyc +0 -0
  213. data/vendor/local/lib/gobject-introspection/giscanner/introspectablepass.pyo +0 -0
  214. data/vendor/local/lib/gobject-introspection/giscanner/libtoolimporter.py +76 -0
  215. data/vendor/local/lib/gobject-introspection/giscanner/libtoolimporter.pyc +0 -0
  216. data/vendor/local/lib/gobject-introspection/giscanner/libtoolimporter.pyo +0 -0
  217. data/vendor/local/lib/gobject-introspection/giscanner/maintransformer.py +1366 -0
  218. data/vendor/local/lib/gobject-introspection/giscanner/maintransformer.pyc +0 -0
  219. data/vendor/local/lib/gobject-introspection/giscanner/maintransformer.pyo +0 -0
  220. data/vendor/local/lib/gobject-introspection/giscanner/message.py +203 -0
  221. data/vendor/local/lib/gobject-introspection/giscanner/message.pyc +0 -0
  222. data/vendor/local/lib/gobject-introspection/giscanner/message.pyo +0 -0
  223. data/vendor/local/lib/gobject-introspection/giscanner/scannermain.py +561 -0
  224. data/vendor/local/lib/gobject-introspection/giscanner/scannermain.pyc +0 -0
  225. data/vendor/local/lib/gobject-introspection/giscanner/scannermain.pyo +0 -0
  226. data/vendor/local/lib/gobject-introspection/giscanner/sectionparser.py +152 -0
  227. data/vendor/local/lib/gobject-introspection/giscanner/sectionparser.pyc +0 -0
  228. data/vendor/local/lib/gobject-introspection/giscanner/sectionparser.pyo +0 -0
  229. data/vendor/local/lib/gobject-introspection/giscanner/shlibs.py +140 -0
  230. data/vendor/local/lib/gobject-introspection/giscanner/shlibs.pyc +0 -0
  231. data/vendor/local/lib/gobject-introspection/giscanner/shlibs.pyo +0 -0
  232. data/vendor/local/lib/gobject-introspection/giscanner/sourcescanner.py +329 -0
  233. data/vendor/local/lib/gobject-introspection/giscanner/sourcescanner.pyc +0 -0
  234. data/vendor/local/lib/gobject-introspection/giscanner/sourcescanner.pyo +0 -0
  235. data/vendor/local/lib/gobject-introspection/giscanner/testcodegen.py +136 -0
  236. data/vendor/local/lib/gobject-introspection/giscanner/testcodegen.pyc +0 -0
  237. data/vendor/local/lib/gobject-introspection/giscanner/testcodegen.pyo +0 -0
  238. data/vendor/local/lib/gobject-introspection/giscanner/transformer.py +971 -0
  239. data/vendor/local/lib/gobject-introspection/giscanner/transformer.pyc +0 -0
  240. data/vendor/local/lib/gobject-introspection/giscanner/transformer.pyo +0 -0
  241. data/vendor/local/lib/gobject-introspection/giscanner/utils.py +211 -0
  242. data/vendor/local/lib/gobject-introspection/giscanner/utils.pyc +0 -0
  243. data/vendor/local/lib/gobject-introspection/giscanner/utils.pyo +0 -0
  244. data/vendor/local/lib/gobject-introspection/giscanner/xmlwriter.py +156 -0
  245. data/vendor/local/lib/gobject-introspection/giscanner/xmlwriter.pyc +0 -0
  246. data/vendor/local/lib/gobject-introspection/giscanner/xmlwriter.pyo +0 -0
  247. data/vendor/local/lib/libgirepository-1.0.a +0 -0
  248. data/vendor/local/lib/libgirepository-1.0.dll.a +0 -0
  249. data/vendor/local/lib/libgirepository-1.0.la +41 -0
  250. data/vendor/local/lib/pkgconfig/gobject-introspection-1.0.pc +26 -0
  251. data/vendor/local/lib/pkgconfig/gobject-introspection-no-export-1.0.pc +23 -0
  252. data/vendor/local/lib/pkgconfig/patched +0 -0
  253. data/vendor/local/share/aclocal/introspection.m4 +96 -0
  254. data/vendor/local/share/gir-1.0/DBus-1.0.gir +32 -0
  255. data/vendor/local/share/gir-1.0/DBusGLib-1.0.gir +18 -0
  256. data/vendor/local/share/gir-1.0/GIRepository-2.0.gir +4042 -0
  257. data/vendor/local/share/gir-1.0/GL-1.0.gir +31 -0
  258. data/vendor/local/share/gir-1.0/GLib-2.0.gir +47221 -0
  259. data/vendor/local/share/gir-1.0/GModule-2.0.gir +301 -0
  260. data/vendor/local/share/gir-1.0/GObject-2.0.gir +14733 -0
  261. data/vendor/local/share/gir-1.0/Gio-2.0.gir +82459 -0
  262. data/vendor/local/share/gir-1.0/cairo-1.0.gir +70 -0
  263. data/vendor/local/share/gir-1.0/fontconfig-2.0.gir +18 -0
  264. data/vendor/local/share/gir-1.0/freetype2-2.0.gir +22 -0
  265. data/vendor/local/share/gir-1.0/libxml2-2.0.gir +25 -0
  266. data/vendor/local/share/gir-1.0/win32-1.0.gir +19 -0
  267. data/vendor/local/share/gir-1.0/xfixes-4.0.gir +10 -0
  268. data/vendor/local/share/gir-1.0/xft-2.0.gir +23 -0
  269. data/vendor/local/share/gir-1.0/xlib-2.0.gir +67 -0
  270. data/vendor/local/share/gir-1.0/xrandr-1.3.gir +16 -0
  271. data/vendor/local/share/gobject-introspection-1.0/Makefile.introspection +166 -0
  272. data/vendor/local/share/gobject-introspection-1.0/gdump.c +569 -0
  273. data/vendor/local/share/gobject-introspection-1.0/tests/annotation.c +831 -0
  274. data/vendor/local/share/gobject-introspection-1.0/tests/annotation.h +301 -0
  275. data/vendor/local/share/gobject-introspection-1.0/tests/drawable.c +57 -0
  276. data/vendor/local/share/gobject-introspection-1.0/tests/drawable.h +44 -0
  277. data/vendor/local/share/gobject-introspection-1.0/tests/everything.c +1579 -0
  278. data/vendor/local/share/gobject-introspection-1.0/tests/everything.h +535 -0
  279. data/vendor/local/share/gobject-introspection-1.0/tests/foo.c +790 -0
  280. data/vendor/local/share/gobject-introspection-1.0/tests/foo.h +582 -0
  281. data/vendor/local/share/gobject-introspection-1.0/tests/gimarshallingtests.c +5426 -0
  282. data/vendor/local/share/gobject-introspection-1.0/tests/gimarshallingtests.h +1948 -0
  283. data/vendor/local/share/gobject-introspection-1.0/tests/gitestmacros.h +10 -0
  284. data/vendor/local/share/gobject-introspection-1.0/tests/regress.c +4068 -0
  285. data/vendor/local/share/gobject-introspection-1.0/tests/regress.h +1415 -0
  286. data/vendor/local/share/gobject-introspection-1.0/tests/utility.c +47 -0
  287. data/vendor/local/share/gobject-introspection-1.0/tests/utility.h +102 -0
  288. data/vendor/local/share/gobject-introspection-1.0/tests/warnlib.c +47 -0
  289. data/vendor/local/share/gobject-introspection-1.0/tests/warnlib.h +46 -0
  290. data/vendor/local/share/license/gobject-introspection/AUTHORS +9 -0
  291. data/vendor/local/share/license/gobject-introspection/COPYING +12 -0
  292. data/vendor/local/share/man/man1/g-ir-compiler.1 +42 -0
  293. data/vendor/local/share/man/man1/g-ir-generate.1 +29 -0
  294. metadata +363 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 5ac86431d8e6872f44f50373d870afb1cf7286be
4
+ data.tar.gz: 96a0794ae8433de268fcd5f59890d93597d63fb5
5
+ SHA512:
6
+ metadata.gz: 549c684b2efe7c8f1cb3702e788fabc20e802ac625d641b1211b5ad146b0a0669c8db0a071756c7509e73b8715a179ee294b451d3d71d4d25bce0b2ef234d2f6
7
+ data.tar.gz: 82a58801b3ea056458b12baac918a5db45238f702629451d1403c6be5121e2e490c735a0bcadadb4427e24bb887f76eee98fab837cf850c63fcd629c3711eeef
data/Rakefile ADDED
@@ -0,0 +1,129 @@
1
+ # -*- ruby -*-
2
+ #
3
+ # Copyright (C) 2012-2014 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, MA 02110-1301 USA
18
+
19
+ $LOAD_PATH.unshift("./../glib2/lib")
20
+ require "gnome2/rake/package-task"
21
+
22
+ package_task = GNOME2::Rake::PackageTask.new do |package|
23
+ package.summary = "Ruby/GObjectIntrospection is a Ruby binding of GObjectIntrospection."
24
+ package.description = "Ruby/GObjectIntrospection is a Ruby binding of GObjectIntrospection."
25
+ package.dependency.gem.runtime = ["glib2"]
26
+ package.dependency.gem.development = [["test-unit", ">= 2"]]
27
+ package.windows.packages = []
28
+ package.windows.dependencies = []
29
+ package.windows.build_dependencies = ["glib2"]
30
+ package.external_packages = [
31
+ {
32
+ :name => "glib",
33
+ :download_site => :gnome,
34
+ :label => "GLib",
35
+ :version => "2.42.1",
36
+ :compression_method => "xz",
37
+ :windows => {
38
+ :build => false,
39
+ },
40
+ :native => {
41
+ :build => true,
42
+ :need_autoreconf => true,
43
+ :built_file => "lib/libglib-2.0.so",
44
+ },
45
+ },
46
+ {
47
+ :name => "gobject-introspection",
48
+ :download_site => :gnome,
49
+ :label => "gobject-introspection",
50
+ :version => "1.42.0",
51
+ :compression_method => "xz",
52
+ :windows => {
53
+ :configure_args => [
54
+ "--with-g-ir-scanner=#{package.native.absolute_binary_dir}/bin/g-ir-scanner",
55
+ "--disable-tests",
56
+ ],
57
+ :patches => [
58
+ "support-external-g-ir-scanner.diff",
59
+ ],
60
+ :need_autoreconf => true,
61
+ :built_file => "bin/libgirepository-1.0-1.dll",
62
+ },
63
+ :native => {
64
+ :build => true,
65
+ :patches => [
66
+ # "cross-compilable-g-ir-scanner.diff",
67
+ ],
68
+ :built_file => "bin/g-ir-scanner",
69
+ }
70
+ },
71
+ ]
72
+ end
73
+ package_task.define
74
+
75
+ namespace :native do
76
+ namespace :"gobject-introspection" do
77
+ g_ir_scanner_dir = package_task.native.absolute_binary_dir
78
+ g_ir_scanner_dir += "lib/gobject-introspection/giscanner"
79
+ patched_path = g_ir_scanner_dir + "patched"
80
+ file patched_path.to_s do
81
+ Dir.chdir(g_ir_scanner_dir.to_s) do
82
+ patch = "#{package_task.package.patches_dir}/cross-g-ir-scanner.diff"
83
+ sh("patch -p2 < #{patch}")
84
+ rm_f(Dir.glob("*.{pyc,pyo}"))
85
+ end
86
+ touch(patched_path)
87
+ end
88
+
89
+ desc "Make g-ir-scanner workable for Windows on non Windows"
90
+ task :cross => patched_path
91
+ end
92
+
93
+ namespace :builder do
94
+ task :after => "native:gobject-introspection:cross"
95
+ end
96
+ end
97
+
98
+ namespace :windows do
99
+ namespace :"gobject-introspection" do
100
+ pkg_config_dir = package_task.windows.absolute_binary_dir + "lib/pkgconfig"
101
+ pc_path = pkg_config_dir + "gobject-introspection-1.0.pc"
102
+ patched_path = pkg_config_dir + "patched"
103
+ file patched_path.to_s do
104
+ original_pc = pc_path.read
105
+ new_pc = ""
106
+ new_pc << "native_prefix=#{package_task.native.absolute_binary_dir}\n"
107
+ new_pc << "native_bindir=${native_prefix}/bin\n"
108
+ original_pc.each_line do |line|
109
+ case line
110
+ when /\Ag_ir_(scanner|compiler)=/
111
+ new_pc << line.gsub(/\${bindir}/, "${native_bindir}").gsub(/\.exe/, "")
112
+ else
113
+ new_pc << line
114
+ end
115
+ end
116
+ pc_path.open("w") do |pc_file|
117
+ pc_file.write(new_pc)
118
+ end
119
+ touch(patched_path)
120
+ end
121
+
122
+ desc "Use native tools"
123
+ task :cross => patched_path.to_s
124
+ end
125
+
126
+ namespace :builder do
127
+ task :after => "windows:gobject-introspection:cross"
128
+ end
129
+ end
@@ -0,0 +1,10 @@
1
+ install-so: install-headers
2
+ install-headers:
3
+ $(INSTALL_DATA) $(srcdir)/rb-gobject-introspection.h $(RUBYARCHDIR)
4
+
5
+ install: install-pc
6
+ install-pc:
7
+ if test -n "$(pkgconfigdir)"; then \
8
+ $(MAKEDIRS) $(pkgconfigdir); \
9
+ $(INSTALL_DATA) ruby-gobject-introspection.pc $(pkgconfigdir);\
10
+ fi
@@ -0,0 +1,94 @@
1
+ #!/usr/bin/env ruby
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, MA 02110-1301 USA
18
+
19
+ require "pathname"
20
+
21
+ source_dir = Pathname(__FILE__).dirname
22
+ base_dir = source_dir.parent.parent.expand_path
23
+ top_dir = base_dir.parent.expand_path
24
+ top_build_dir = Pathname(".").parent.parent.parent.expand_path
25
+
26
+ mkmf_gnome2_dir = top_dir + "glib2" + "lib"
27
+ version_suffix = ""
28
+ unless mkmf_gnome2_dir.exist?
29
+ if /(-\d+\.\d+\.\d+)(?:\.\d+)?\z/ =~ base_dir.basename.to_s
30
+ version_suffix = $1
31
+ mkmf_gnome2_dir = top_dir + "glib2#{version_suffix}" + "lib"
32
+ end
33
+ end
34
+
35
+ $LOAD_PATH.unshift(mkmf_gnome2_dir.to_s)
36
+
37
+ module_name = "gobject_introspection"
38
+ package_id = "gobject-introspection-1.0"
39
+
40
+ begin
41
+ require "mkmf-gnome2"
42
+ rescue LoadError
43
+ require "rubygems"
44
+ gem "glib2"
45
+ require "mkmf-gnome2"
46
+ end
47
+
48
+ ["glib2"].each do |package|
49
+ directory = "#{package}#{version_suffix}"
50
+ build_dir = "#{directory}/tmp/#{RUBY_PLATFORM}/#{package}/#{RUBY_VERSION}"
51
+ add_depend_package(package, "#{directory}/ext/#{package}",
52
+ top_dir.to_s,
53
+ :top_build_dir => top_build_dir.to_s,
54
+ :target_build_dir => build_dir)
55
+ end
56
+
57
+ setup_windows(module_name, base_dir)
58
+
59
+ unless required_pkg_config_package(package_id,
60
+ :debian => "libgirepository1.0-dev",
61
+ :fedora => "gobject-introspection-devel",
62
+ :homebrew => "gobject-introspection",
63
+ :macports => "gobject-introspection")
64
+ exit(false)
65
+ end
66
+
67
+ make_version_header("GI", package_id, ".")
68
+
69
+ gi_headers = ["girepository.h"]
70
+ have_func("g_interface_info_find_signal", gi_headers)
71
+
72
+ enum_type_prefix = "gobject-introspection-enum-types"
73
+ include_paths = PKGConfig.cflags_only_I(package_id)
74
+ headers = include_paths.split.inject([]) do |result, path|
75
+ result + Dir.glob(File.join(path.sub(/^-I/, ""), "gi{repository,types}.h"))
76
+ end
77
+ glib_mkenums(enum_type_prefix, headers, "G_TYPE_", ["girepository.h"])
78
+
79
+ create_pkg_config_file("Ruby/GObjectIntrospection",
80
+ package_id, ruby_gnome2_version,
81
+ "ruby-gobject-introspection.pc")
82
+
83
+ ensure_objs
84
+
85
+ $defs << "-DRUBY_GOBJECT_INTROSPECTION_COMPILATION"
86
+ create_makefile(module_name)
87
+
88
+ pkg_config_dir = with_config("pkg-config-dir")
89
+ if pkg_config_dir.is_a?(String)
90
+ File.open("Makefile", "ab") do |makefile|
91
+ makefile.puts
92
+ makefile.puts("pkgconfigdir=#{pkg_config_dir}")
93
+ end
94
+ end
@@ -0,0 +1,5 @@
1
+ EXPORTS
2
+ Init_gobject_introspection
3
+
4
+ rb_gi_callback_data_free
5
+ rb_gi_callback_register_finder
@@ -0,0 +1,151 @@
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_cGIArgInfo
24
+ #define SELF(self) (RVAL2GI_ARG_INFO(self))
25
+
26
+ GType
27
+ gi_arg_info_get_type(void)
28
+ {
29
+ static GType type = 0;
30
+ if (type == 0) {
31
+ type = g_boxed_type_register_static("GIArgInfo",
32
+ (GBoxedCopyFunc)g_base_info_ref,
33
+ (GBoxedFreeFunc)g_base_info_unref);
34
+ }
35
+ return type;
36
+ }
37
+
38
+ static VALUE
39
+ rg_direction(VALUE self)
40
+ {
41
+ GIArgInfo *info;
42
+
43
+ info = SELF(self);
44
+ return GI_DIRECTION2RVAL(g_arg_info_get_direction(info));
45
+ }
46
+
47
+ static VALUE
48
+ rg_caller_allocates_p(VALUE self)
49
+ {
50
+ GIArgInfo *info;
51
+
52
+ info = SELF(self);
53
+ return CBOOL2RVAL(g_arg_info_is_caller_allocates(info));
54
+ }
55
+
56
+ static VALUE
57
+ rg_return_value_p(VALUE self)
58
+ {
59
+ GIArgInfo *info;
60
+
61
+ info = SELF(self);
62
+ return CBOOL2RVAL(g_arg_info_is_return_value(info));
63
+ }
64
+
65
+ static VALUE
66
+ rg_optional_p(VALUE self)
67
+ {
68
+ GIArgInfo *info;
69
+
70
+ info = SELF(self);
71
+ return CBOOL2RVAL(g_arg_info_is_optional(info));
72
+ }
73
+
74
+ static VALUE
75
+ rg_may_be_null_p(VALUE self)
76
+ {
77
+ GIArgInfo *info;
78
+
79
+ info = SELF(self);
80
+ return CBOOL2RVAL(g_arg_info_may_be_null(info));
81
+ }
82
+
83
+ static VALUE
84
+ rg_ownership_transfer(VALUE self)
85
+ {
86
+ GIArgInfo *info;
87
+
88
+ info = SELF(self);
89
+ return GI_TRANSFER2RVAL(g_arg_info_get_ownership_transfer(info));
90
+ }
91
+
92
+ static VALUE
93
+ rg_scope(VALUE self)
94
+ {
95
+ GIArgInfo *info;
96
+
97
+ info = SELF(self);
98
+ return GI_SCOPE_TYPE2RVAL(g_arg_info_get_scope(info));
99
+ }
100
+
101
+ static VALUE
102
+ rg_closure(VALUE self)
103
+ {
104
+ GIArgInfo *info;
105
+
106
+ info = SELF(self);
107
+ return INT2NUM(g_arg_info_get_closure(info));
108
+ }
109
+
110
+ static VALUE
111
+ rg_destroy(VALUE self)
112
+ {
113
+ GIArgInfo *info;
114
+
115
+ info = SELF(self);
116
+ return INT2NUM(g_arg_info_get_destroy(info));
117
+ }
118
+
119
+ static VALUE
120
+ rg_type(VALUE self)
121
+ {
122
+ GIArgInfo *info;
123
+
124
+ info = SELF(self);
125
+ return GI_BASE_INFO2RVAL_WITH_UNREF(g_arg_info_get_type(info));
126
+ }
127
+
128
+ void
129
+ rb_gi_arg_info_init(VALUE rb_mGI, VALUE rb_cGIBaseInfo)
130
+ {
131
+ VALUE RG_TARGET_NAMESPACE;
132
+
133
+ RG_TARGET_NAMESPACE =
134
+ G_DEF_CLASS_WITH_PARENT(GI_TYPE_ARG_INFO, "ArgInfo", rb_mGI,
135
+ rb_cGIBaseInfo);
136
+
137
+ RG_DEF_METHOD(direction, 0);
138
+ RG_DEF_METHOD_P(caller_allocates, 0);
139
+ RG_DEF_METHOD_P(return_value, 0);
140
+ RG_DEF_METHOD_P(optional, 0);
141
+ RG_DEF_METHOD_P(may_be_null, 0);
142
+ RG_DEF_METHOD(ownership_transfer, 0);
143
+ RG_DEF_METHOD(scope, 0);
144
+ RG_DEF_METHOD(closure, 0);
145
+ RG_DEF_METHOD(destroy, 0);
146
+ RG_DEF_METHOD(type, 0);
147
+
148
+ G_DEF_CLASS(G_TYPE_I_DIRECTION, "Direction", rb_mGI);
149
+ G_DEF_CLASS(G_TYPE_I_SCOPE_TYPE, "ScopeType", rb_mGI);
150
+ G_DEF_CLASS(G_TYPE_I_TRANSFER, "Transfer", rb_mGI);
151
+ }
@@ -0,0 +1,2053 @@
1
+ /* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */
2
+ /*
3
+ * Copyright (C) 2012-2014 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
+ static VALUE rb_cGLibValue = Qnil;
24
+
25
+ static void
26
+ array_c_to_ruby(GIArgument *array, GITypeInfo *type_info, gint64 n_elements,
27
+ VALUE rb_array)
28
+ {
29
+ const gchar **elements;
30
+ gboolean fixed_size_p;
31
+ gboolean zero_terminated_p;
32
+
33
+ elements = array->v_pointer;
34
+ if (!elements) {
35
+ return;
36
+ }
37
+
38
+ fixed_size_p = g_type_info_get_array_fixed_size(type_info);
39
+ zero_terminated_p = g_type_info_is_zero_terminated(type_info);
40
+ if (n_elements != -1) {
41
+ gint64 i;
42
+ for (i = 0; i < n_elements; i++) {
43
+ rb_ary_push(rb_array, CSTR2RVAL(elements[i]));
44
+ }
45
+ } else if (zero_terminated_p) {
46
+ for (; *elements; elements++) {
47
+ rb_ary_push(rb_array, CSTR2RVAL(*elements));
48
+ }
49
+ } else {
50
+ rb_raise(rb_eNotImpError,
51
+ "TODO: GIArgument(array)[c] -> Ruby: "
52
+ "zero-terminated: %s "
53
+ "fixed-size: %s "
54
+ "length: %" G_GINT64_FORMAT,
55
+ zero_terminated_p ? "true" : "false",
56
+ fixed_size_p ? "true" : "false",
57
+ n_elements);
58
+ }
59
+ }
60
+
61
+ static gint64
62
+ get_array_length(GIArgument *argument, GITypeInfo *type_info)
63
+ {
64
+ GITypeTag type_tag;
65
+ gint64 length = -1;
66
+
67
+ if (!argument) {
68
+ return length;
69
+ }
70
+
71
+ type_tag = g_type_info_get_tag(type_info);
72
+ switch (type_tag) {
73
+ case GI_TYPE_TAG_VOID:
74
+ case GI_TYPE_TAG_BOOLEAN:
75
+ rb_raise(rb_eNotImpError,
76
+ "TODO: invalid array length argument?: <%s>",
77
+ g_type_tag_to_string(type_tag));
78
+ break;
79
+ case GI_TYPE_TAG_INT8:
80
+ length = argument->v_int8;
81
+ break;
82
+ case GI_TYPE_TAG_UINT8:
83
+ length = argument->v_uint8;
84
+ break;
85
+ case GI_TYPE_TAG_INT16:
86
+ length = argument->v_int16;
87
+ break;
88
+ case GI_TYPE_TAG_UINT16:
89
+ length = argument->v_uint16;
90
+ break;
91
+ case GI_TYPE_TAG_INT32:
92
+ length = argument->v_int32;
93
+ break;
94
+ case GI_TYPE_TAG_UINT32:
95
+ length = argument->v_uint32;
96
+ break;
97
+ case GI_TYPE_TAG_INT64:
98
+ length = argument->v_int64;
99
+ break;
100
+ case GI_TYPE_TAG_UINT64:
101
+ length = argument->v_uint64;
102
+ break;
103
+ case GI_TYPE_TAG_FLOAT:
104
+ case GI_TYPE_TAG_DOUBLE:
105
+ case GI_TYPE_TAG_GTYPE:
106
+ case GI_TYPE_TAG_UTF8:
107
+ case GI_TYPE_TAG_FILENAME:
108
+ case GI_TYPE_TAG_ARRAY:
109
+ case GI_TYPE_TAG_INTERFACE:
110
+ case GI_TYPE_TAG_GLIST:
111
+ case GI_TYPE_TAG_GSLIST:
112
+ case GI_TYPE_TAG_GHASH:
113
+ case GI_TYPE_TAG_ERROR:
114
+ case GI_TYPE_TAG_UNICHAR:
115
+ rb_raise(rb_eNotImpError,
116
+ "TODO: invalid array length argument?: <%s>",
117
+ g_type_tag_to_string(type_tag));
118
+ break;
119
+ default:
120
+ g_assert_not_reached();
121
+ break;
122
+ }
123
+
124
+ return length;
125
+ }
126
+
127
+ VALUE
128
+ rb_gi_array_argument_to_ruby(GIArgument *array_argument,
129
+ GIArgument *length_argument,
130
+ GITypeInfo *array_type_info,
131
+ GITypeInfo *length_type_info)
132
+ {
133
+ VALUE rb_array;
134
+ GIArrayType array_type;
135
+ gint n_elements;
136
+
137
+ array_type = g_type_info_get_array_type(array_type_info);
138
+ n_elements = get_array_length(length_argument, length_type_info);
139
+ if (n_elements == -1) {
140
+ rb_array = rb_ary_new();
141
+ } else {
142
+ rb_array = rb_ary_new2(n_elements);
143
+ }
144
+ switch (array_type) {
145
+ case GI_ARRAY_TYPE_C:
146
+ array_c_to_ruby(array_argument, array_type_info, n_elements, rb_array);
147
+ break;
148
+ case GI_ARRAY_TYPE_ARRAY:
149
+ rb_raise(rb_eNotImpError, "TODO: GIArgument(array)[array] -> Ruby");
150
+ break;
151
+ case GI_ARRAY_TYPE_PTR_ARRAY:
152
+ rb_raise(rb_eNotImpError, "TODO: GIArgument(array)[ptr-array] -> Ruby");
153
+ break;
154
+ case GI_ARRAY_TYPE_BYTE_ARRAY:
155
+ rb_raise(rb_eNotImpError, "TODO: GIArgument(array)[byte-array] -> Ruby");
156
+ break;
157
+ default:
158
+ g_assert_not_reached();
159
+ break;
160
+ }
161
+
162
+ return rb_array;
163
+ }
164
+
165
+ static VALUE
166
+ interface_to_ruby(GIArgument *argument, GITypeInfo *type_info)
167
+ {
168
+ VALUE rb_interface;
169
+ GIBaseInfo *interface_info;
170
+ GIInfoType interface_type;
171
+ GType gtype;
172
+
173
+ interface_info = g_type_info_get_interface(type_info);
174
+ interface_type = g_base_info_get_type(interface_info);
175
+
176
+ gtype = g_registered_type_info_get_g_type(interface_info);
177
+ switch (interface_type) {
178
+ case GI_INFO_TYPE_INVALID:
179
+ rb_raise(rb_eNotImpError,
180
+ "TODO: GIArgument(interface)[invalid] -> Ruby");
181
+ break;
182
+ case GI_INFO_TYPE_FUNCTION:
183
+ rb_raise(rb_eNotImpError,
184
+ "TODO: GIArgument(interface)[function] -> Ruby");
185
+ break;
186
+ case GI_INFO_TYPE_CALLBACK:
187
+ rb_raise(rb_eNotImpError,
188
+ "TODO: GIArgument(interface)[callback] -> Ruby");
189
+ break;
190
+ case GI_INFO_TYPE_STRUCT:
191
+ if (gtype == G_TYPE_BYTES) {
192
+ GBytes *bytes = argument->v_pointer;
193
+ gconstpointer data;
194
+ gsize size;
195
+ data = g_bytes_get_data(bytes, &size);
196
+ rb_interface = rb_enc_str_new(data, size, rb_ascii8bit_encoding());
197
+ } else {
198
+ rb_interface = BOXED2RVAL(argument->v_pointer, gtype);
199
+ }
200
+ break;
201
+ case GI_INFO_TYPE_BOXED:
202
+ rb_raise(rb_eNotImpError,
203
+ "TODO: GIArgument(interface)[boxed] -> Ruby");
204
+ break;
205
+ case GI_INFO_TYPE_ENUM:
206
+ if (gtype == G_TYPE_NONE) {
207
+ rb_interface = INT2NUM(argument->v_int32);
208
+ } else {
209
+ rb_interface = GENUM2RVAL(argument->v_int32, gtype);
210
+ }
211
+ break;
212
+ case GI_INFO_TYPE_FLAGS:
213
+ if (gtype == G_TYPE_NONE) {
214
+ rb_interface = INT2NUM(argument->v_int32);
215
+ } else {
216
+ rb_interface = GFLAGS2RVAL(argument->v_int32, gtype);
217
+ }
218
+ break;
219
+ case GI_INFO_TYPE_OBJECT:
220
+ rb_interface = GOBJ2RVAL(argument->v_pointer);
221
+ break;
222
+ case GI_INFO_TYPE_INTERFACE:
223
+ rb_interface = GOBJ2RVAL(argument->v_pointer);
224
+ break;
225
+ case GI_INFO_TYPE_CONSTANT:
226
+ rb_raise(rb_eNotImpError,
227
+ "TODO: GIArgument(interface)[constant] -> Ruby");
228
+ break;
229
+ case GI_INFO_TYPE_INVALID_0:
230
+ g_assert_not_reached();
231
+ break;
232
+ case GI_INFO_TYPE_UNION:
233
+ rb_interface = BOXED2RVAL(argument->v_pointer, gtype);
234
+ break;
235
+ case GI_INFO_TYPE_VALUE:
236
+ rb_raise(rb_eNotImpError,
237
+ "TODO: GIArgument(interface)[value] -> Ruby");
238
+ break;
239
+ case GI_INFO_TYPE_SIGNAL:
240
+ rb_raise(rb_eNotImpError,
241
+ "TODO: GIArgument(interface)[signal] -> Ruby");
242
+ break;
243
+ case GI_INFO_TYPE_VFUNC:
244
+ rb_raise(rb_eNotImpError,
245
+ "TODO: GIArgument(interface)[vfunc] -> Ruby");
246
+ break;
247
+ case GI_INFO_TYPE_PROPERTY:
248
+ rb_raise(rb_eNotImpError,
249
+ "TODO: GIArgument(interface)[property] -> Ruby");
250
+ break;
251
+ case GI_INFO_TYPE_FIELD:
252
+ rb_raise(rb_eNotImpError,
253
+ "TODO: GIArgument(interface)[field] -> Ruby");
254
+ break;
255
+ case GI_INFO_TYPE_ARG:
256
+ rb_raise(rb_eNotImpError,
257
+ "TODO: GIArgument(interface)[arg] -> Ruby");
258
+ break;
259
+ case GI_INFO_TYPE_TYPE:
260
+ rb_raise(rb_eNotImpError,
261
+ "TODO: GIArgument(interface)[type] -> Ruby");
262
+ break;
263
+ case GI_INFO_TYPE_UNRESOLVED:
264
+ rb_raise(rb_eNotImpError,
265
+ "TODO: GIArgument(interface)[unresolved] -> Ruby");
266
+ break;
267
+ default:
268
+ g_assert_not_reached();
269
+ break;
270
+ }
271
+
272
+ g_base_info_unref(interface_info);
273
+
274
+ return rb_interface;
275
+ }
276
+
277
+ static VALUE
278
+ rb_gi_argument_to_ruby_glist(GIArgument *argument, GITypeInfo *type_info)
279
+ {
280
+ VALUE rb_argument;
281
+ GITypeInfo *element_type_info;
282
+ GITypeTag element_type_tag;
283
+
284
+ element_type_info = g_type_info_get_param_type(type_info, 0);
285
+ element_type_tag = g_type_info_get_tag(element_type_info);
286
+ g_base_info_unref(element_type_info);
287
+
288
+ switch (element_type_tag) {
289
+ case GI_TYPE_TAG_VOID:
290
+ case GI_TYPE_TAG_BOOLEAN:
291
+ case GI_TYPE_TAG_INT8:
292
+ case GI_TYPE_TAG_UINT8:
293
+ case GI_TYPE_TAG_INT16:
294
+ case GI_TYPE_TAG_UINT16:
295
+ case GI_TYPE_TAG_INT32:
296
+ case GI_TYPE_TAG_UINT32:
297
+ case GI_TYPE_TAG_INT64:
298
+ case GI_TYPE_TAG_UINT64:
299
+ case GI_TYPE_TAG_FLOAT:
300
+ case GI_TYPE_TAG_DOUBLE:
301
+ case GI_TYPE_TAG_GTYPE:
302
+ rb_raise(rb_eNotImpError,
303
+ "TODO: GIArgument(GList)[%s] -> Ruby",
304
+ g_type_tag_to_string(element_type_tag));
305
+ break;
306
+ case GI_TYPE_TAG_UTF8:
307
+ rb_argument = CSTRGLIST2RVAL(argument->v_pointer);
308
+ break;
309
+ case GI_TYPE_TAG_FILENAME:
310
+ case GI_TYPE_TAG_ARRAY:
311
+ rb_raise(rb_eNotImpError,
312
+ "TODO: GIArgument(GList)[%s] -> Ruby",
313
+ g_type_tag_to_string(element_type_tag));
314
+ break;
315
+ case GI_TYPE_TAG_INTERFACE:
316
+ GOBJGLIST2RVAL(argument->v_pointer);
317
+ break;
318
+ case GI_TYPE_TAG_GLIST:
319
+ case GI_TYPE_TAG_GSLIST:
320
+ case GI_TYPE_TAG_GHASH:
321
+ case GI_TYPE_TAG_ERROR:
322
+ case GI_TYPE_TAG_UNICHAR:
323
+ rb_raise(rb_eNotImpError,
324
+ "TODO: GIArgument(GList)[%s] -> Ruby",
325
+ g_type_tag_to_string(element_type_tag));
326
+ break;
327
+ default:
328
+ g_assert_not_reached();
329
+ break;
330
+ }
331
+
332
+ return rb_argument;
333
+ }
334
+
335
+
336
+ VALUE
337
+ rb_gi_argument_to_ruby(GIArgument *argument, GITypeInfo *type_info)
338
+ {
339
+ VALUE rb_argument = Qnil;
340
+ GITypeTag type_tag;
341
+
342
+ type_tag = g_type_info_get_tag(type_info);
343
+ switch (type_tag) {
344
+ case GI_TYPE_TAG_VOID:
345
+ if (g_type_info_is_pointer(type_info)) {
346
+ rb_argument = ULONG2NUM(GPOINTER_TO_UINT(argument->v_pointer));
347
+ } else {
348
+ rb_argument = Qnil;
349
+ }
350
+ break;
351
+ case GI_TYPE_TAG_BOOLEAN:
352
+ rb_argument = CBOOL2RVAL(argument->v_boolean);
353
+ break;
354
+ case GI_TYPE_TAG_INT8:
355
+ rb_argument = INT2NUM(argument->v_int8);
356
+ break;
357
+ case GI_TYPE_TAG_UINT8:
358
+ rb_argument = UINT2NUM(argument->v_uint8);
359
+ break;
360
+ case GI_TYPE_TAG_INT16:
361
+ rb_argument = INT2NUM(argument->v_int16);
362
+ break;
363
+ case GI_TYPE_TAG_UINT16:
364
+ rb_argument = UINT2NUM(argument->v_uint16);
365
+ break;
366
+ case GI_TYPE_TAG_INT32:
367
+ rb_argument = INT2NUM(argument->v_int32);
368
+ break;
369
+ case GI_TYPE_TAG_UINT32:
370
+ rb_argument = UINT2NUM(argument->v_uint32);
371
+ break;
372
+ case GI_TYPE_TAG_INT64:
373
+ rb_argument = LONG2NUM(argument->v_int64);
374
+ break;
375
+ case GI_TYPE_TAG_UINT64:
376
+ rb_argument = ULONG2NUM(argument->v_uint64);
377
+ break;
378
+ case GI_TYPE_TAG_FLOAT:
379
+ rb_argument = DBL2NUM(argument->v_float);
380
+ break;
381
+ case GI_TYPE_TAG_DOUBLE:
382
+ rb_argument = DBL2NUM(argument->v_double);
383
+ break;
384
+ case GI_TYPE_TAG_GTYPE:
385
+ rb_argument = rbgobj_gtype_new(argument->v_size);
386
+ break;
387
+ case GI_TYPE_TAG_UTF8:
388
+ rb_argument = CSTR2RVAL(argument->v_string);
389
+ break;
390
+ case GI_TYPE_TAG_FILENAME:
391
+ /* TODO: set encoding */
392
+ rb_argument = CSTR2RVAL(argument->v_string);
393
+ break;
394
+ case GI_TYPE_TAG_ARRAY:
395
+ rb_argument = rb_gi_array_argument_to_ruby(argument, NULL,
396
+ type_info, NULL);
397
+ break;
398
+ case GI_TYPE_TAG_INTERFACE:
399
+ rb_argument = interface_to_ruby(argument, type_info);
400
+ break;
401
+ case GI_TYPE_TAG_GLIST:
402
+ rb_argument = rb_gi_argument_to_ruby_glist(argument, type_info);
403
+ break;
404
+ case GI_TYPE_TAG_GSLIST:
405
+ case GI_TYPE_TAG_GHASH:
406
+ rb_raise(rb_eNotImpError,
407
+ "TODO: GIArgument(%s) -> Ruby",
408
+ g_type_tag_to_string(type_tag));
409
+ break;
410
+ case GI_TYPE_TAG_ERROR:
411
+ rb_argument = GERROR2RVAL(argument->v_pointer);
412
+ break;
413
+ case GI_TYPE_TAG_UNICHAR:
414
+ rb_raise(rb_eNotImpError,
415
+ "TODO: GIArgument(%s) -> Ruby",
416
+ g_type_tag_to_string(type_tag));
417
+ break;
418
+ default:
419
+ g_assert_not_reached();
420
+ break;
421
+ }
422
+
423
+ return rb_argument;
424
+ }
425
+
426
+ static void
427
+ rb_gi_out_argument_init_interface(GIArgument *argument, GIArgInfo *arg_info,
428
+ GITypeInfo *type_info)
429
+ {
430
+ GIBaseInfo *interface_info;
431
+ GIInfoType interface_type;
432
+
433
+ if (!g_arg_info_is_caller_allocates(arg_info)) {
434
+ argument->v_pointer = ALLOC(gpointer);
435
+ return;
436
+ }
437
+
438
+ interface_info = g_type_info_get_interface(type_info);
439
+ interface_type = g_base_info_get_type(interface_info);
440
+
441
+ switch (interface_type) {
442
+ case GI_INFO_TYPE_INVALID:
443
+ case GI_INFO_TYPE_FUNCTION:
444
+ case GI_INFO_TYPE_CALLBACK:
445
+ rb_raise(rb_eNotImpError,
446
+ "TODO: allocates GIArgument(interface)[%s] for output",
447
+ g_info_type_to_string(interface_type));
448
+ break;
449
+ case GI_INFO_TYPE_STRUCT:
450
+ {
451
+ gsize struct_size;
452
+
453
+ struct_size = g_struct_info_get_size(interface_info);
454
+ argument->v_pointer = xmalloc(struct_size);
455
+ memset(argument->v_pointer, 0, struct_size);
456
+ }
457
+ break;
458
+ case GI_INFO_TYPE_BOXED:
459
+ case GI_INFO_TYPE_ENUM:
460
+ case GI_INFO_TYPE_FLAGS:
461
+ case GI_INFO_TYPE_OBJECT:
462
+ case GI_INFO_TYPE_INTERFACE:
463
+ case GI_INFO_TYPE_CONSTANT:
464
+ case GI_INFO_TYPE_INVALID_0:
465
+ case GI_INFO_TYPE_UNION:
466
+ case GI_INFO_TYPE_VALUE:
467
+ case GI_INFO_TYPE_SIGNAL:
468
+ case GI_INFO_TYPE_VFUNC:
469
+ case GI_INFO_TYPE_PROPERTY:
470
+ case GI_INFO_TYPE_FIELD:
471
+ case GI_INFO_TYPE_ARG:
472
+ case GI_INFO_TYPE_TYPE:
473
+ case GI_INFO_TYPE_UNRESOLVED:
474
+ rb_raise(rb_eNotImpError,
475
+ "TODO: allocates GIArgument(interface)[%s] for output",
476
+ g_info_type_to_string(interface_type));
477
+ break;
478
+ default:
479
+ g_assert_not_reached();
480
+ break;
481
+ }
482
+
483
+ g_base_info_unref(interface_info);
484
+ }
485
+
486
+ void
487
+ rb_gi_out_argument_init(GIArgument *argument, GIArgInfo *arg_info)
488
+ {
489
+ GITypeInfo type_info;
490
+ GITypeTag type_tag;
491
+
492
+ memset(argument, 0, sizeof(GIArgument));
493
+
494
+ g_arg_info_load_type(arg_info, &type_info);
495
+ type_tag = g_type_info_get_tag(&type_info);
496
+ switch (type_tag) {
497
+ case GI_TYPE_TAG_VOID:
498
+ break;
499
+ case GI_TYPE_TAG_BOOLEAN:
500
+ argument->v_pointer = ALLOC(gboolean);
501
+ break;
502
+ case GI_TYPE_TAG_INT8:
503
+ argument->v_pointer = ALLOC(gint8);
504
+ break;
505
+ case GI_TYPE_TAG_UINT8:
506
+ argument->v_pointer = ALLOC(guint8);
507
+ break;
508
+ case GI_TYPE_TAG_INT16:
509
+ argument->v_pointer = ALLOC(gint16);
510
+ break;
511
+ case GI_TYPE_TAG_UINT16:
512
+ argument->v_pointer = ALLOC(guint16);
513
+ break;
514
+ case GI_TYPE_TAG_INT32:
515
+ argument->v_pointer = ALLOC(gint32);
516
+ break;
517
+ case GI_TYPE_TAG_UINT32:
518
+ argument->v_pointer = ALLOC(guint32);
519
+ break;
520
+ case GI_TYPE_TAG_INT64:
521
+ argument->v_pointer = ALLOC(gint64);
522
+ break;
523
+ case GI_TYPE_TAG_UINT64:
524
+ argument->v_pointer = ALLOC(guint64);
525
+ break;
526
+ case GI_TYPE_TAG_FLOAT:
527
+ argument->v_pointer = ALLOC(gfloat);
528
+ break;
529
+ case GI_TYPE_TAG_DOUBLE:
530
+ argument->v_pointer = ALLOC(gdouble);
531
+ break;
532
+ case GI_TYPE_TAG_GTYPE:
533
+ argument->v_pointer = ALLOC(GType);
534
+ break;
535
+ case GI_TYPE_TAG_UTF8:
536
+ case GI_TYPE_TAG_FILENAME:
537
+ argument->v_pointer = ALLOC(gchar *);
538
+ break;
539
+ case GI_TYPE_TAG_ARRAY:
540
+ argument->v_pointer = ALLOC(gpointer);
541
+ break;
542
+ case GI_TYPE_TAG_INTERFACE:
543
+ rb_gi_out_argument_init_interface(argument, arg_info, &type_info);
544
+ break;
545
+ case GI_TYPE_TAG_GLIST:
546
+ case GI_TYPE_TAG_GSLIST:
547
+ case GI_TYPE_TAG_GHASH:
548
+ argument->v_pointer = ALLOC(gpointer);
549
+ break;
550
+ case GI_TYPE_TAG_ERROR:
551
+ argument->v_pointer = ALLOC(GError *);
552
+ memset(argument->v_pointer, 0, sizeof(GError *));
553
+ break;
554
+ case GI_TYPE_TAG_UNICHAR:
555
+ argument->v_pointer = ALLOC(gunichar);
556
+ break;
557
+ default:
558
+ g_assert_not_reached();
559
+ break;
560
+ }
561
+ }
562
+
563
+ VALUE
564
+ rb_gi_out_argument_to_ruby(GIArgument *argument, GIArgInfo *arg_info)
565
+ {
566
+ GIArgument normalized_argument;
567
+ GITypeInfo type_info;
568
+ GITypeTag type_tag;
569
+
570
+ memset(&normalized_argument, 0, sizeof(GIArgument));
571
+ g_arg_info_load_type(arg_info, &type_info);
572
+ type_tag = g_type_info_get_tag(&type_info);
573
+ switch (type_tag) {
574
+ case GI_TYPE_TAG_VOID:
575
+ break;
576
+ case GI_TYPE_TAG_BOOLEAN:
577
+ normalized_argument.v_boolean = *((gboolean *)(argument->v_pointer));
578
+ break;
579
+ case GI_TYPE_TAG_INT8:
580
+ normalized_argument.v_int8 = *((gint8 *)(argument->v_pointer));
581
+ break;
582
+ case GI_TYPE_TAG_UINT8:
583
+ normalized_argument.v_uint8 = *((guint8 *)(argument->v_pointer));
584
+ break;
585
+ case GI_TYPE_TAG_INT16:
586
+ normalized_argument.v_int16 = *((gint16 *)(argument->v_pointer));
587
+ break;
588
+ case GI_TYPE_TAG_UINT16:
589
+ normalized_argument.v_uint16 = *((guint16 *)(argument->v_pointer));
590
+ break;
591
+ case GI_TYPE_TAG_INT32:
592
+ normalized_argument.v_int32 = *((gint32 *)(argument->v_pointer));
593
+ break;
594
+ case GI_TYPE_TAG_UINT32:
595
+ normalized_argument.v_uint32 = *((guint32 *)(argument->v_pointer));
596
+ break;
597
+ case GI_TYPE_TAG_INT64:
598
+ normalized_argument.v_int64 = *((gint64 *)(argument->v_pointer));
599
+ break;
600
+ case GI_TYPE_TAG_UINT64:
601
+ normalized_argument.v_uint64 = *((guint64 *)(argument->v_pointer));
602
+ break;
603
+ case GI_TYPE_TAG_FLOAT:
604
+ normalized_argument.v_float = *((gfloat *)(argument->v_pointer));
605
+ break;
606
+ case GI_TYPE_TAG_DOUBLE:
607
+ normalized_argument.v_double = *((gdouble *)(argument->v_pointer));
608
+ break;
609
+ case GI_TYPE_TAG_GTYPE:
610
+ normalized_argument.v_size = *((GType *)(argument->v_pointer));
611
+ break;
612
+ case GI_TYPE_TAG_UTF8:
613
+ case GI_TYPE_TAG_FILENAME:
614
+ normalized_argument.v_string = *((gchar **)(argument->v_pointer));
615
+ break;
616
+ case GI_TYPE_TAG_ARRAY:
617
+ case GI_TYPE_TAG_INTERFACE:
618
+ case GI_TYPE_TAG_GLIST:
619
+ case GI_TYPE_TAG_GSLIST:
620
+ case GI_TYPE_TAG_GHASH:
621
+ if (g_arg_info_is_caller_allocates(arg_info)) {
622
+ normalized_argument.v_pointer = argument->v_pointer;
623
+ } else {
624
+ normalized_argument.v_pointer = *((gpointer *)(argument->v_pointer));
625
+ }
626
+ break;
627
+ case GI_TYPE_TAG_ERROR:
628
+ normalized_argument.v_pointer = *((GError **)(argument->v_pointer));
629
+ break;
630
+ case GI_TYPE_TAG_UNICHAR:
631
+ normalized_argument.v_uint32 = *((guint32 *)(argument->v_pointer));
632
+ break;
633
+ default:
634
+ g_assert_not_reached();
635
+ break;
636
+ }
637
+
638
+ return rb_gi_argument_to_ruby(&normalized_argument, &type_info);
639
+ }
640
+
641
+ static void
642
+ normalize_out_array_length(GIArgument *normalized_argument,
643
+ GIArgument *argument,
644
+ GITypeInfo *type_info)
645
+ {
646
+ GITypeTag type_tag;
647
+
648
+ type_tag = g_type_info_get_tag(type_info);
649
+ switch (type_tag) {
650
+ case GI_TYPE_TAG_VOID:
651
+ case GI_TYPE_TAG_BOOLEAN:
652
+ rb_raise(rb_eNotImpError,
653
+ "TODO: invalid out array length argument?: <%s>",
654
+ g_type_tag_to_string(type_tag));
655
+ break;
656
+ case GI_TYPE_TAG_INT8:
657
+ normalized_argument->v_int8 = *((gint8 *)argument->v_pointer);
658
+ break;
659
+ case GI_TYPE_TAG_UINT8:
660
+ normalized_argument->v_uint8 = *((guint8 *)argument->v_pointer);
661
+ break;
662
+ case GI_TYPE_TAG_INT16:
663
+ normalized_argument->v_int16 = *((gint16 *)argument->v_pointer);
664
+ break;
665
+ case GI_TYPE_TAG_UINT16:
666
+ normalized_argument->v_uint16 = *((guint16 *)argument->v_pointer);
667
+ break;
668
+ case GI_TYPE_TAG_INT32:
669
+ normalized_argument->v_int32 = *((gint32 *)argument->v_pointer);
670
+ break;
671
+ case GI_TYPE_TAG_UINT32:
672
+ normalized_argument->v_uint32 = *((guint32 *)argument->v_pointer);
673
+ break;
674
+ case GI_TYPE_TAG_INT64:
675
+ normalized_argument->v_int64 = *((gint64 *)argument->v_pointer);
676
+ break;
677
+ case GI_TYPE_TAG_UINT64:
678
+ normalized_argument->v_uint64 = *((guint64 *)argument->v_pointer);
679
+ break;
680
+ case GI_TYPE_TAG_FLOAT:
681
+ case GI_TYPE_TAG_DOUBLE:
682
+ case GI_TYPE_TAG_GTYPE:
683
+ case GI_TYPE_TAG_UTF8:
684
+ case GI_TYPE_TAG_FILENAME:
685
+ case GI_TYPE_TAG_ARRAY:
686
+ case GI_TYPE_TAG_INTERFACE:
687
+ case GI_TYPE_TAG_GLIST:
688
+ case GI_TYPE_TAG_GSLIST:
689
+ case GI_TYPE_TAG_GHASH:
690
+ case GI_TYPE_TAG_ERROR:
691
+ case GI_TYPE_TAG_UNICHAR:
692
+ rb_raise(rb_eNotImpError,
693
+ "TODO: invalid out array length argument?: <%s>",
694
+ g_type_tag_to_string(type_tag));
695
+ break;
696
+ default:
697
+ g_assert_not_reached();
698
+ break;
699
+ }
700
+ }
701
+
702
+ VALUE
703
+ rb_gi_out_array_argument_to_ruby(GIArgument *array_argument,
704
+ GIArgument *length_argument,
705
+ GIArgInfo *array_arg_info,
706
+ GIArgInfo *length_arg_info)
707
+ {
708
+ VALUE rb_array;
709
+ GIArgument normalized_array_argument;
710
+ GITypeInfo array_type_info;
711
+
712
+ normalized_array_argument.v_pointer =
713
+ *((gpointer *)(array_argument->v_pointer));
714
+ g_arg_info_load_type(array_arg_info, &array_type_info);
715
+ if (length_argument) {
716
+ GITypeInfo length_type_info;
717
+ GIArgument normalized_length_argument;
718
+
719
+ g_arg_info_load_type(length_arg_info, &length_type_info);
720
+ normalize_out_array_length(&normalized_length_argument,
721
+ length_argument,
722
+ &length_type_info);
723
+ rb_array = rb_gi_array_argument_to_ruby(&normalized_array_argument,
724
+ &normalized_length_argument,
725
+ &array_type_info,
726
+ &length_type_info);
727
+ } else {
728
+ rb_array = rb_gi_array_argument_to_ruby(&normalized_array_argument,
729
+ NULL,
730
+ &array_type_info,
731
+ NULL);
732
+ }
733
+
734
+ return rb_array;
735
+ }
736
+
737
+ void
738
+ rb_gi_out_argument_fin(GIArgument *argument, GIArgInfo *arg_info)
739
+ {
740
+ GITypeInfo type_info;
741
+
742
+ if (g_arg_info_get_direction(arg_info) != GI_DIRECTION_OUT) {
743
+ return;
744
+ }
745
+
746
+ g_arg_info_load_type(arg_info, &type_info);
747
+ xfree(argument->v_pointer);
748
+ }
749
+
750
+ static void
751
+ rb_gi_return_argument_free_container(G_GNUC_UNUSED GIArgument *argument,
752
+ GITypeInfo *type_info)
753
+ {
754
+ GITypeTag type_tag;
755
+
756
+ type_tag = g_type_info_get_tag(type_info);
757
+
758
+ rb_raise(rb_eNotImpError,
759
+ "TODO: free GIArgument(%s) as container",
760
+ g_type_tag_to_string(type_tag));
761
+ }
762
+
763
+ static void
764
+ rb_gi_return_argument_free_everything_array(GIArgument *argument,
765
+ GITypeInfo *type_info)
766
+ {
767
+ switch (g_type_info_get_array_type(type_info)) {
768
+ case GI_ARRAY_TYPE_C:
769
+ g_strfreev(argument->v_pointer);
770
+ break;
771
+ case GI_ARRAY_TYPE_ARRAY:
772
+ g_array_free(argument->v_pointer, TRUE);
773
+ break;
774
+ case GI_ARRAY_TYPE_PTR_ARRAY:
775
+ g_ptr_array_free(argument->v_pointer, TRUE);
776
+ break;
777
+ case GI_ARRAY_TYPE_BYTE_ARRAY:
778
+ g_ptr_array_free(argument->v_pointer, TRUE);
779
+ break;
780
+ default:
781
+ g_assert_not_reached();
782
+ break;
783
+ }
784
+ }
785
+
786
+ static void
787
+ rb_gi_return_argument_free_everything_interface_struct(GIArgument *argument,
788
+ GType gtype)
789
+ {
790
+ if (!argument->v_pointer) {
791
+ return;
792
+ }
793
+
794
+ if (!gtype) {
795
+ xfree(argument->v_pointer);
796
+ }
797
+
798
+ if (G_TYPE_IS_BOXED(gtype)) {
799
+ g_boxed_free(gtype, argument->v_pointer);
800
+ } else {
801
+ rbgobj_instance_unref(argument->v_pointer);
802
+ }
803
+ }
804
+
805
+ static void
806
+ rb_gi_return_argument_free_everything_interface(GIArgument *argument,
807
+ GITypeInfo *type_info)
808
+ {
809
+ GIBaseInfo *interface_info;
810
+ GIInfoType interface_type;
811
+ GType gtype;
812
+
813
+ interface_info = g_type_info_get_interface(type_info);
814
+ interface_type = g_base_info_get_type(interface_info);
815
+ gtype = g_registered_type_info_get_g_type(interface_info);
816
+ g_base_info_unref(interface_info);
817
+
818
+ switch (interface_type) {
819
+ case GI_INFO_TYPE_INVALID:
820
+ rb_raise(rb_eNotImpError,
821
+ "TODO: free GIArgument(interface)[invalid] everything");
822
+ break;
823
+ case GI_INFO_TYPE_FUNCTION:
824
+ rb_raise(rb_eNotImpError,
825
+ "TODO: free GIArgument(interface)[function] everything");
826
+ break;
827
+ case GI_INFO_TYPE_CALLBACK:
828
+ rb_raise(rb_eNotImpError,
829
+ "TODO: free GIArgument(interface)[callback] everything");
830
+ break;
831
+ case GI_INFO_TYPE_STRUCT:
832
+ rb_gi_return_argument_free_everything_interface_struct(argument, gtype);
833
+ break;
834
+ case GI_INFO_TYPE_BOXED:
835
+ rb_raise(rb_eNotImpError,
836
+ "TODO: free GIArgument(interface)[boxed] everything");
837
+ break;
838
+ case GI_INFO_TYPE_ENUM:
839
+ rb_raise(rb_eNotImpError,
840
+ "TODO: free GIArgument(interface)[enum] everything");
841
+ break;
842
+ case GI_INFO_TYPE_FLAGS:
843
+ rb_raise(rb_eNotImpError,
844
+ "TODO: free GIArgument(interface)[flags] everything");
845
+ break;
846
+ case GI_INFO_TYPE_OBJECT:
847
+ if (argument->v_pointer) {
848
+ g_object_unref(argument->v_pointer);
849
+ }
850
+ break;
851
+ case GI_INFO_TYPE_INTERFACE:
852
+ if (argument->v_pointer) {
853
+ g_object_unref(argument->v_pointer);
854
+ }
855
+ break;
856
+ case GI_INFO_TYPE_CONSTANT:
857
+ rb_raise(rb_eNotImpError,
858
+ "TODO: free GIArgument(interface)[constant] everything");
859
+ break;
860
+ case GI_INFO_TYPE_INVALID_0:
861
+ g_assert_not_reached();
862
+ break;
863
+ case GI_INFO_TYPE_UNION:
864
+ rb_raise(rb_eNotImpError,
865
+ "TODO: free GIArgument(interface)[union] everything");
866
+ break;
867
+ case GI_INFO_TYPE_VALUE:
868
+ rb_raise(rb_eNotImpError,
869
+ "TODO: free GIArgument(interface)[value] everything");
870
+ break;
871
+ case GI_INFO_TYPE_SIGNAL:
872
+ rb_raise(rb_eNotImpError,
873
+ "TODO: free GIArgument(interface)[signal] everything");
874
+ break;
875
+ case GI_INFO_TYPE_VFUNC:
876
+ rb_raise(rb_eNotImpError,
877
+ "TODO: free GIArgument(interface)[vfunc] everything");
878
+ break;
879
+ case GI_INFO_TYPE_PROPERTY:
880
+ rb_raise(rb_eNotImpError,
881
+ "TODO: free GIArgument(interface)[property] everything");
882
+ break;
883
+ case GI_INFO_TYPE_FIELD:
884
+ rb_raise(rb_eNotImpError,
885
+ "TODO: free GIArgument(interface)[field] everything");
886
+ break;
887
+ case GI_INFO_TYPE_ARG:
888
+ rb_raise(rb_eNotImpError,
889
+ "TODO: free GIArgument(interface)[arg] everything");
890
+ break;
891
+ case GI_INFO_TYPE_TYPE:
892
+ rb_raise(rb_eNotImpError,
893
+ "TODO: free GIArgument(interface)[type] everything");
894
+ break;
895
+ case GI_INFO_TYPE_UNRESOLVED:
896
+ rb_raise(rb_eNotImpError,
897
+ "TODO: free GIArgument(interface)[unresolved] everything");
898
+ break;
899
+ default:
900
+ g_assert_not_reached();
901
+ break;
902
+ }
903
+ }
904
+
905
+ static void
906
+ rb_gi_return_argument_free_everything_glist(GIArgument *argument,
907
+ GITypeInfo *type_info)
908
+ {
909
+ GITypeInfo *element_type_info;
910
+ GITypeTag element_type_tag;
911
+
912
+ element_type_info = g_type_info_get_param_type(type_info, 0);
913
+ element_type_tag = g_type_info_get_tag(element_type_info);
914
+ g_base_info_unref(element_type_info);
915
+
916
+ switch (element_type_tag) {
917
+ case GI_TYPE_TAG_VOID:
918
+ case GI_TYPE_TAG_BOOLEAN:
919
+ case GI_TYPE_TAG_INT8:
920
+ case GI_TYPE_TAG_UINT8:
921
+ case GI_TYPE_TAG_INT16:
922
+ case GI_TYPE_TAG_UINT16:
923
+ case GI_TYPE_TAG_INT32:
924
+ case GI_TYPE_TAG_UINT32:
925
+ case GI_TYPE_TAG_INT64:
926
+ case GI_TYPE_TAG_UINT64:
927
+ case GI_TYPE_TAG_FLOAT:
928
+ case GI_TYPE_TAG_DOUBLE:
929
+ case GI_TYPE_TAG_GTYPE:
930
+ rb_raise(rb_eNotImpError,
931
+ "TODO: free GIArgument(GList)[%s] everything",
932
+ g_type_tag_to_string(element_type_tag));
933
+ break;
934
+ case GI_TYPE_TAG_UTF8:
935
+ g_list_foreach(argument->v_pointer, (GFunc)g_free, NULL);
936
+ g_list_free(argument->v_pointer);
937
+ break;
938
+ case GI_TYPE_TAG_FILENAME:
939
+ case GI_TYPE_TAG_ARRAY:
940
+ rb_raise(rb_eNotImpError,
941
+ "TODO: free GIArgument(GList)[%s] everything",
942
+ g_type_tag_to_string(element_type_tag));
943
+ break;
944
+ case GI_TYPE_TAG_INTERFACE:
945
+ g_list_foreach(argument->v_pointer, (GFunc)g_object_unref, NULL);
946
+ g_list_free(argument->v_pointer);
947
+ break;
948
+ case GI_TYPE_TAG_GLIST:
949
+ case GI_TYPE_TAG_GSLIST:
950
+ case GI_TYPE_TAG_GHASH:
951
+ case GI_TYPE_TAG_ERROR:
952
+ case GI_TYPE_TAG_UNICHAR:
953
+ rb_raise(rb_eNotImpError,
954
+ "TODO: free GIArgument(GList)[%s] everything",
955
+ g_type_tag_to_string(element_type_tag));
956
+ break;
957
+ default:
958
+ g_assert_not_reached();
959
+ break;
960
+ }
961
+ }
962
+
963
+ static void
964
+ rb_gi_return_argument_free_everything(GIArgument *argument,
965
+ GITypeInfo *type_info)
966
+ {
967
+ GITypeTag type_tag;
968
+
969
+ type_tag = g_type_info_get_tag(type_info);
970
+ switch (type_tag) {
971
+ case GI_TYPE_TAG_VOID:
972
+ case GI_TYPE_TAG_BOOLEAN:
973
+ case GI_TYPE_TAG_INT8:
974
+ case GI_TYPE_TAG_UINT8:
975
+ case GI_TYPE_TAG_INT16:
976
+ case GI_TYPE_TAG_UINT16:
977
+ case GI_TYPE_TAG_INT32:
978
+ case GI_TYPE_TAG_UINT32:
979
+ case GI_TYPE_TAG_INT64:
980
+ case GI_TYPE_TAG_UINT64:
981
+ case GI_TYPE_TAG_FLOAT:
982
+ case GI_TYPE_TAG_DOUBLE:
983
+ case GI_TYPE_TAG_GTYPE:
984
+ rb_raise(rb_eNotImpError,
985
+ "TODO: free GIArgument(%s) everything",
986
+ g_type_tag_to_string(type_tag));
987
+ break;
988
+ case GI_TYPE_TAG_UTF8:
989
+ g_free(argument->v_string);
990
+ break;
991
+ case GI_TYPE_TAG_FILENAME:
992
+ rb_raise(rb_eNotImpError,
993
+ "TODO: free GIArgument(%s) everything",
994
+ g_type_tag_to_string(type_tag));
995
+ break;
996
+ case GI_TYPE_TAG_ARRAY:
997
+ rb_gi_return_argument_free_everything_array(argument, type_info);
998
+ break;
999
+ case GI_TYPE_TAG_INTERFACE:
1000
+ rb_gi_return_argument_free_everything_interface(argument, type_info);
1001
+ break;
1002
+ case GI_TYPE_TAG_GLIST:
1003
+ rb_gi_return_argument_free_everything_glist(argument, type_info);
1004
+ break;
1005
+ case GI_TYPE_TAG_GSLIST:
1006
+ case GI_TYPE_TAG_GHASH:
1007
+ case GI_TYPE_TAG_ERROR:
1008
+ case GI_TYPE_TAG_UNICHAR:
1009
+ rb_raise(rb_eNotImpError,
1010
+ "TODO: free GIArgument(%s) everything",
1011
+ g_type_tag_to_string(type_tag));
1012
+ break;
1013
+ default:
1014
+ g_assert_not_reached();
1015
+ break;
1016
+ }
1017
+ }
1018
+
1019
+ VALUE
1020
+ rb_gi_return_argument_to_ruby(GIArgument *argument,
1021
+ GICallableInfo *callable_info)
1022
+ {
1023
+ VALUE rb_argument;
1024
+ gboolean may_return_null;
1025
+ GITypeInfo return_value_info;
1026
+
1027
+ may_return_null = g_callable_info_may_return_null(callable_info);
1028
+ if (may_return_null && !argument->v_pointer) {
1029
+ return Qnil;
1030
+ }
1031
+
1032
+ g_callable_info_load_return_type(callable_info, &return_value_info);
1033
+ rb_argument = rb_gi_argument_to_ruby(argument, &return_value_info);
1034
+ switch (g_callable_info_get_caller_owns(callable_info)) {
1035
+ case GI_TRANSFER_NOTHING:
1036
+ break;
1037
+ case GI_TRANSFER_CONTAINER:
1038
+ rb_gi_return_argument_free_container(argument, &return_value_info);
1039
+ break;
1040
+ case GI_TRANSFER_EVERYTHING:
1041
+ rb_gi_return_argument_free_everything(argument, &return_value_info);
1042
+ break;
1043
+ default:
1044
+ g_assert_not_reached();
1045
+ break;
1046
+ }
1047
+ return rb_argument;
1048
+ }
1049
+
1050
+ static void
1051
+ rb_gi_argument_from_ruby_interface(GIArgument *argument, GITypeInfo *type_info,
1052
+ VALUE rb_argument)
1053
+ {
1054
+ GIBaseInfo *interface_info;
1055
+ GIInfoType interface_type;
1056
+ GType gtype;
1057
+
1058
+ interface_info = g_type_info_get_interface(type_info);
1059
+ interface_type = g_base_info_get_type(interface_info);
1060
+
1061
+ gtype = g_registered_type_info_get_g_type(interface_info);
1062
+ switch (interface_type) {
1063
+ case GI_INFO_TYPE_INVALID:
1064
+ case GI_INFO_TYPE_FUNCTION:
1065
+ case GI_INFO_TYPE_CALLBACK:
1066
+ rb_raise(rb_eNotImpError,
1067
+ "TODO: Ruby -> GIArgument(interface)[%s]: <%s>",
1068
+ g_info_type_to_string(interface_type),
1069
+ g_base_info_get_name(interface_info));
1070
+ break;
1071
+ case GI_INFO_TYPE_STRUCT:
1072
+ if (gtype == G_TYPE_NONE) {
1073
+ argument->v_pointer = DATA_PTR(rb_argument);
1074
+ } else if (gtype == G_TYPE_VALUE) {
1075
+ GValue *gvalue;
1076
+ gvalue = ALLOC(GValue);
1077
+ memset(gvalue, 0, sizeof(GValue));
1078
+ if (rb_obj_is_kind_of(rb_argument, rb_cGLibValue)) {
1079
+ GValue *source_gvalue;
1080
+ source_gvalue = RVAL2BOXED(rb_argument, G_TYPE_VALUE);
1081
+ g_value_init(gvalue, source_gvalue->g_type);
1082
+ g_value_copy(source_gvalue, gvalue);
1083
+ } else {
1084
+ rbgobj_initialize_gvalue(gvalue, rb_argument);
1085
+ }
1086
+ argument->v_pointer = gvalue;
1087
+ } else {
1088
+ argument->v_pointer = RVAL2BOXED(rb_argument, gtype);
1089
+ }
1090
+ break;
1091
+ case GI_INFO_TYPE_BOXED:
1092
+ rb_raise(rb_eNotImpError,
1093
+ "TODO: Ruby -> GIArgument(interface)[%s]: <%s>",
1094
+ g_info_type_to_string(interface_type),
1095
+ g_base_info_get_name(interface_info));
1096
+ break;
1097
+ case GI_INFO_TYPE_ENUM:
1098
+ if (gtype == G_TYPE_NONE) {
1099
+ argument->v_int32 = NUM2INT(rb_argument);
1100
+ } else {
1101
+ argument->v_int32 = RVAL2GENUM(rb_argument, gtype);
1102
+ }
1103
+ break;
1104
+ case GI_INFO_TYPE_FLAGS:
1105
+ if (gtype == G_TYPE_NONE) {
1106
+ argument->v_int32 = NUM2INT(rb_argument);
1107
+ } else {
1108
+ argument->v_int32 = RVAL2GFLAGS(rb_argument, gtype);
1109
+ }
1110
+ break;
1111
+ case GI_INFO_TYPE_OBJECT:
1112
+ case GI_INFO_TYPE_INTERFACE:
1113
+ argument->v_pointer = RVAL2GOBJ(rb_argument);
1114
+ break;
1115
+ case GI_INFO_TYPE_CONSTANT:
1116
+ rb_raise(rb_eNotImpError,
1117
+ "TODO: Ruby -> GIArgument(interface)[%s]: <%s>",
1118
+ g_info_type_to_string(interface_type),
1119
+ g_base_info_get_name(interface_info));
1120
+ break;
1121
+ case GI_INFO_TYPE_INVALID_0:
1122
+ g_assert_not_reached();
1123
+ break;
1124
+ case GI_INFO_TYPE_UNION:
1125
+ case GI_INFO_TYPE_VALUE:
1126
+ case GI_INFO_TYPE_SIGNAL:
1127
+ case GI_INFO_TYPE_VFUNC:
1128
+ case GI_INFO_TYPE_PROPERTY:
1129
+ case GI_INFO_TYPE_FIELD:
1130
+ case GI_INFO_TYPE_ARG:
1131
+ case GI_INFO_TYPE_TYPE:
1132
+ case GI_INFO_TYPE_UNRESOLVED:
1133
+ default:
1134
+ rb_raise(rb_eNotImpError,
1135
+ "TODO: Ruby -> GIArgument(interface)[%s]: <%s>",
1136
+ g_info_type_to_string(interface_type),
1137
+ g_base_info_get_name(interface_info));
1138
+ break;
1139
+ }
1140
+
1141
+ g_base_info_unref(interface_info);
1142
+ }
1143
+
1144
+ static void
1145
+ rb_gi_value_argument_from_ruby_void(GIArgument *argument, GITypeInfo *type_info,
1146
+ VALUE rb_argument)
1147
+ {
1148
+ if (!g_type_info_is_pointer(type_info)) {
1149
+ return;
1150
+ }
1151
+
1152
+ if (RB_TYPE_P(rb_argument, RUBY_T_STRING)) {
1153
+ argument->v_pointer = RSTRING_PTR(rb_argument);
1154
+ } else {
1155
+ argument->v_pointer = GUINT_TO_POINTER(NUM2ULONG(rb_argument));
1156
+ }
1157
+ }
1158
+
1159
+ GIArgument *
1160
+ rb_gi_value_argument_from_ruby(GIArgument *argument, GITypeInfo *type_info,
1161
+ VALUE rb_argument)
1162
+ {
1163
+ GITypeTag type_tag;
1164
+
1165
+ memset(argument, 0, sizeof(GIArgument));
1166
+
1167
+ type_tag = g_type_info_get_tag(type_info);
1168
+ switch (type_tag) {
1169
+ case GI_TYPE_TAG_VOID:
1170
+ rb_gi_value_argument_from_ruby_void(argument, type_info, rb_argument);
1171
+ break;
1172
+ case GI_TYPE_TAG_BOOLEAN:
1173
+ argument->v_boolean = RVAL2CBOOL(rb_argument);
1174
+ break;
1175
+ case GI_TYPE_TAG_INT8:
1176
+ argument->v_int8 = NUM2INT(rb_argument);
1177
+ break;
1178
+ case GI_TYPE_TAG_UINT8:
1179
+ argument->v_uint8 = NUM2UINT(rb_argument);
1180
+ break;
1181
+ case GI_TYPE_TAG_INT16:
1182
+ argument->v_int16 = NUM2INT(rb_argument);
1183
+ break;
1184
+ case GI_TYPE_TAG_UINT16:
1185
+ argument->v_uint16 = NUM2UINT(rb_argument);
1186
+ break;
1187
+ case GI_TYPE_TAG_INT32:
1188
+ argument->v_int32 = NUM2INT(rb_argument);
1189
+ break;
1190
+ case GI_TYPE_TAG_UINT32:
1191
+ argument->v_uint32 = NUM2UINT(rb_argument);
1192
+ break;
1193
+ case GI_TYPE_TAG_INT64:
1194
+ argument->v_int64 = NUM2LONG(rb_argument);
1195
+ break;
1196
+ case GI_TYPE_TAG_UINT64:
1197
+ argument->v_uint64 = NUM2ULONG(rb_argument);
1198
+ break;
1199
+ case GI_TYPE_TAG_FLOAT:
1200
+ argument->v_float = NUM2DBL(rb_argument);
1201
+ break;
1202
+ case GI_TYPE_TAG_DOUBLE:
1203
+ argument->v_double = NUM2DBL(rb_argument);
1204
+ break;
1205
+ case GI_TYPE_TAG_GTYPE:
1206
+ /* TODO: support GLib::Type and String as GType name. */
1207
+ argument->v_size = NUM2ULONG(rb_argument);
1208
+ break;
1209
+ case GI_TYPE_TAG_UTF8:
1210
+ /* TODO: support UTF-8 convert like rb_argument.encode("UTF-8"). */
1211
+ argument->v_string = (gchar *)RVAL2CSTR(rb_argument);
1212
+ break;
1213
+ case GI_TYPE_TAG_FILENAME:
1214
+ argument->v_string = (gchar *)RVAL2CSTR(rb_argument);
1215
+ break;
1216
+ case GI_TYPE_TAG_ARRAY:
1217
+ rb_raise(rb_eNotImpError,
1218
+ "should not be reached: Ruby -> GIArgument(%s)",
1219
+ g_type_tag_to_string(type_tag));
1220
+ break;
1221
+ case GI_TYPE_TAG_INTERFACE:
1222
+ rb_gi_argument_from_ruby_interface(argument, type_info, rb_argument);
1223
+ break;
1224
+ case GI_TYPE_TAG_GLIST:
1225
+ case GI_TYPE_TAG_GSLIST:
1226
+ case GI_TYPE_TAG_GHASH:
1227
+ case GI_TYPE_TAG_ERROR:
1228
+ case GI_TYPE_TAG_UNICHAR:
1229
+ rb_raise(rb_eNotImpError,
1230
+ "TODO: Ruby -> GIArgument(%s)",
1231
+ g_type_tag_to_string(type_tag));
1232
+ break;
1233
+ default:
1234
+ g_assert_not_reached();
1235
+ break;
1236
+ }
1237
+
1238
+ return argument;
1239
+ }
1240
+
1241
+ static void
1242
+ rb_gi_inout_argument_from_ruby(GIArgument *argument,
1243
+ G_GNUC_UNUSED GIArgInfo *arg_info,
1244
+ GITypeInfo *type_info, VALUE rb_argument)
1245
+ {
1246
+ GIArgument in_argument;
1247
+ GITypeTag type_tag;
1248
+
1249
+ rb_gi_value_argument_from_ruby(&in_argument, type_info, rb_argument);
1250
+
1251
+ type_tag = g_type_info_get_tag(type_info);
1252
+ switch (type_tag) {
1253
+ case GI_TYPE_TAG_VOID:
1254
+ break;
1255
+ case GI_TYPE_TAG_BOOLEAN:
1256
+ argument->v_pointer = ALLOC(gboolean);
1257
+ *((gboolean *)argument->v_pointer) = in_argument.v_boolean;
1258
+ break;
1259
+ case GI_TYPE_TAG_INT8:
1260
+ argument->v_pointer = ALLOC(gint8);
1261
+ *((gint8 *)argument->v_pointer) = in_argument.v_int8;
1262
+ break;
1263
+ case GI_TYPE_TAG_UINT8:
1264
+ argument->v_pointer = ALLOC(guint8);
1265
+ *((guint8 *)argument->v_pointer) = in_argument.v_uint8;
1266
+ break;
1267
+ case GI_TYPE_TAG_INT16:
1268
+ argument->v_pointer = ALLOC(gint16);
1269
+ *((gint16 *)argument->v_pointer) = in_argument.v_int16;
1270
+ break;
1271
+ case GI_TYPE_TAG_UINT16:
1272
+ argument->v_pointer = ALLOC(guint16);
1273
+ *((guint16 *)argument->v_pointer) = in_argument.v_uint16;
1274
+ break;
1275
+ case GI_TYPE_TAG_INT32:
1276
+ argument->v_pointer = ALLOC(gint32);
1277
+ *((gint32 *)argument->v_pointer) = in_argument.v_int32;
1278
+ break;
1279
+ case GI_TYPE_TAG_UINT32:
1280
+ argument->v_pointer = ALLOC(guint32);
1281
+ *((guint32 *)argument->v_pointer) = in_argument.v_uint32;
1282
+ break;
1283
+ case GI_TYPE_TAG_INT64:
1284
+ argument->v_pointer = ALLOC(gint64);
1285
+ *((gint64 *)argument->v_pointer) = in_argument.v_int64;
1286
+ break;
1287
+ case GI_TYPE_TAG_UINT64:
1288
+ argument->v_pointer = ALLOC(guint64);
1289
+ *((guint64 *)argument->v_pointer) = in_argument.v_uint64;
1290
+ break;
1291
+ case GI_TYPE_TAG_FLOAT:
1292
+ argument->v_pointer = ALLOC(gfloat);
1293
+ *((gfloat *)argument->v_pointer) = in_argument.v_float;
1294
+ break;
1295
+ case GI_TYPE_TAG_DOUBLE:
1296
+ argument->v_pointer = ALLOC(gdouble);
1297
+ *((gdouble *)argument->v_pointer) = in_argument.v_double;
1298
+ break;
1299
+ case GI_TYPE_TAG_GTYPE:
1300
+ argument->v_pointer = ALLOC(gsize);
1301
+ *((gsize *)argument->v_pointer) = in_argument.v_size;
1302
+ break;
1303
+ case GI_TYPE_TAG_UTF8:
1304
+ case GI_TYPE_TAG_FILENAME:
1305
+ argument->v_pointer = ALLOC(gchar *);
1306
+ *((gchar **)argument->v_pointer) = in_argument.v_string;
1307
+ break;
1308
+ case GI_TYPE_TAG_ARRAY:
1309
+ rb_raise(rb_eNotImpError,
1310
+ "should not be reached: Ruby -> GIArgument(%s)",
1311
+ g_type_tag_to_string(type_tag));
1312
+ break;
1313
+ case GI_TYPE_TAG_INTERFACE:
1314
+ case GI_TYPE_TAG_GLIST:
1315
+ case GI_TYPE_TAG_GSLIST:
1316
+ case GI_TYPE_TAG_GHASH:
1317
+ argument->v_pointer = ALLOC(gpointer);
1318
+ *((gpointer *)argument->v_pointer) = in_argument.v_pointer;
1319
+ break;
1320
+ case GI_TYPE_TAG_ERROR:
1321
+ argument->v_pointer = ALLOC(GError *);
1322
+ *((GError **)argument->v_pointer) = in_argument.v_pointer;
1323
+ break;
1324
+ case GI_TYPE_TAG_UNICHAR:
1325
+ argument->v_pointer = ALLOC(gunichar);
1326
+ *((gunichar *)argument->v_pointer) = in_argument.v_uint32;
1327
+ break;
1328
+ default:
1329
+ g_assert_not_reached();
1330
+ break;
1331
+ }
1332
+ }
1333
+
1334
+ static void
1335
+ rb_gi_in_argument_transfer_interface(GIArgument *argument,
1336
+ G_GNUC_UNUSED GITransfer transfer,
1337
+ GITypeInfo *type_info,
1338
+ G_GNUC_UNUSED VALUE rb_argument)
1339
+ {
1340
+ GIBaseInfo *interface_info;
1341
+ GIInfoType interface_type;
1342
+ G_GNUC_UNUSED GType gtype;
1343
+
1344
+ interface_info = g_type_info_get_interface(type_info);
1345
+ interface_type = g_base_info_get_type(interface_info);
1346
+ gtype = g_registered_type_info_get_g_type(interface_info);
1347
+ g_base_info_unref(interface_info);
1348
+
1349
+ switch (interface_type) {
1350
+ case GI_INFO_TYPE_INVALID:
1351
+ case GI_INFO_TYPE_FUNCTION:
1352
+ case GI_INFO_TYPE_CALLBACK:
1353
+ rb_raise(rb_eNotImpError,
1354
+ "TODO: in transfer (interface) [%s]",
1355
+ g_info_type_to_string(interface_type));
1356
+ break;
1357
+ case GI_INFO_TYPE_STRUCT:
1358
+ rbgobj_boxed_unown(rb_argument);
1359
+ break;
1360
+ case GI_INFO_TYPE_BOXED:
1361
+ case GI_INFO_TYPE_ENUM:
1362
+ case GI_INFO_TYPE_FLAGS:
1363
+ rb_raise(rb_eNotImpError,
1364
+ "TODO: in transfer (interface) [%s]",
1365
+ g_info_type_to_string(interface_type));
1366
+ break;
1367
+ case GI_INFO_TYPE_OBJECT:
1368
+ g_object_ref(argument->v_pointer);
1369
+ break;
1370
+ case GI_INFO_TYPE_INTERFACE:
1371
+ case GI_INFO_TYPE_CONSTANT:
1372
+ rb_raise(rb_eNotImpError,
1373
+ "TODO: in transfer (interface) [%s]",
1374
+ g_info_type_to_string(interface_type));
1375
+ break;
1376
+ case GI_INFO_TYPE_INVALID_0:
1377
+ g_assert_not_reached();
1378
+ break;
1379
+ case GI_INFO_TYPE_UNION:
1380
+ case GI_INFO_TYPE_VALUE:
1381
+ case GI_INFO_TYPE_SIGNAL:
1382
+ case GI_INFO_TYPE_VFUNC:
1383
+ case GI_INFO_TYPE_PROPERTY:
1384
+ case GI_INFO_TYPE_FIELD:
1385
+ case GI_INFO_TYPE_ARG:
1386
+ case GI_INFO_TYPE_TYPE:
1387
+ case GI_INFO_TYPE_UNRESOLVED:
1388
+ rb_raise(rb_eNotImpError,
1389
+ "TODO: in transfer (interface) [%s]",
1390
+ g_info_type_to_string(interface_type));
1391
+ break;
1392
+ default:
1393
+ g_assert_not_reached();
1394
+ break;
1395
+ }
1396
+ }
1397
+
1398
+ static void
1399
+ rb_gi_in_argument_transfer(GIArgument *argument, GITransfer transfer,
1400
+ GITypeInfo *type_info, VALUE rb_argument)
1401
+ {
1402
+ GITypeTag type_tag;
1403
+
1404
+ if (transfer == GI_TRANSFER_NOTHING) {
1405
+ return;
1406
+ }
1407
+
1408
+ type_tag = g_type_info_get_tag(type_info);
1409
+ switch (type_tag) {
1410
+ case GI_TYPE_TAG_VOID:
1411
+ case GI_TYPE_TAG_BOOLEAN:
1412
+ case GI_TYPE_TAG_INT8:
1413
+ case GI_TYPE_TAG_UINT8:
1414
+ case GI_TYPE_TAG_INT16:
1415
+ case GI_TYPE_TAG_UINT16:
1416
+ case GI_TYPE_TAG_INT32:
1417
+ case GI_TYPE_TAG_UINT32:
1418
+ case GI_TYPE_TAG_INT64:
1419
+ case GI_TYPE_TAG_UINT64:
1420
+ case GI_TYPE_TAG_FLOAT:
1421
+ case GI_TYPE_TAG_DOUBLE:
1422
+ case GI_TYPE_TAG_GTYPE:
1423
+ break;
1424
+ case GI_TYPE_TAG_UTF8:
1425
+ case GI_TYPE_TAG_FILENAME:
1426
+ case GI_TYPE_TAG_ARRAY:
1427
+ rb_raise(rb_eNotImpError,
1428
+ "TODO: in transfer (%s)",
1429
+ g_type_tag_to_string(type_tag));
1430
+ break;
1431
+ case GI_TYPE_TAG_INTERFACE:
1432
+ rb_gi_in_argument_transfer_interface(argument, transfer,
1433
+ type_info, rb_argument);
1434
+ break;
1435
+ case GI_TYPE_TAG_GLIST:
1436
+ case GI_TYPE_TAG_GSLIST:
1437
+ case GI_TYPE_TAG_GHASH:
1438
+ case GI_TYPE_TAG_ERROR:
1439
+ case GI_TYPE_TAG_UNICHAR:
1440
+ rb_raise(rb_eNotImpError,
1441
+ "TODO: in transfer (%s)",
1442
+ g_type_tag_to_string(type_tag));
1443
+ default:
1444
+ g_assert_not_reached();
1445
+ break;
1446
+ }
1447
+ }
1448
+
1449
+ GIArgument *
1450
+ rb_gi_in_argument_from_ruby(GIArgument *argument, GIArgInfo *arg_info,
1451
+ VALUE rb_argument)
1452
+ {
1453
+ GITypeInfo type_info;
1454
+
1455
+ if (g_arg_info_may_be_null(arg_info) && NIL_P(rb_argument)) {
1456
+ memset(argument, 0, sizeof(GIArgument));
1457
+ return argument;
1458
+ }
1459
+
1460
+ g_arg_info_load_type(arg_info, &type_info);
1461
+ if (g_arg_info_get_direction(arg_info) == GI_DIRECTION_INOUT) {
1462
+ rb_gi_inout_argument_from_ruby(argument, arg_info, &type_info,
1463
+ rb_argument);
1464
+ } else {
1465
+ rb_gi_value_argument_from_ruby(argument, &type_info, rb_argument);
1466
+ rb_gi_in_argument_transfer(argument,
1467
+ g_arg_info_get_ownership_transfer(arg_info),
1468
+ &type_info,
1469
+ rb_argument);
1470
+ }
1471
+
1472
+ return argument;
1473
+ }
1474
+
1475
+ static void
1476
+ set_in_array_length_argument(GIArgument *argument,
1477
+ GITypeInfo *type_info,
1478
+ gint64 length)
1479
+ {
1480
+ GITypeTag type_tag;
1481
+
1482
+ if (!argument) {
1483
+ return;
1484
+ }
1485
+
1486
+ type_tag = g_type_info_get_tag(type_info);
1487
+ switch (type_tag) {
1488
+ case GI_TYPE_TAG_VOID:
1489
+ case GI_TYPE_TAG_BOOLEAN:
1490
+ rb_raise(rb_eNotImpError,
1491
+ "TODO: invalid argument?: length[%s]",
1492
+ g_type_tag_to_string(type_tag));
1493
+ break;
1494
+ case GI_TYPE_TAG_INT8:
1495
+ argument->v_int8 = length;
1496
+ break;
1497
+ case GI_TYPE_TAG_UINT8:
1498
+ argument->v_uint8 = length;
1499
+ break;
1500
+ case GI_TYPE_TAG_INT16:
1501
+ argument->v_int16 = length;
1502
+ break;
1503
+ case GI_TYPE_TAG_UINT16:
1504
+ argument->v_uint16 = length;
1505
+ break;
1506
+ case GI_TYPE_TAG_INT32:
1507
+ argument->v_int32 = length;
1508
+ break;
1509
+ case GI_TYPE_TAG_UINT32:
1510
+ argument->v_uint32 = length;
1511
+ break;
1512
+ case GI_TYPE_TAG_INT64:
1513
+ argument->v_int64 = length;
1514
+ break;
1515
+ case GI_TYPE_TAG_UINT64:
1516
+ argument->v_uint64 = length;
1517
+ break;
1518
+ case GI_TYPE_TAG_FLOAT:
1519
+ case GI_TYPE_TAG_DOUBLE:
1520
+ case GI_TYPE_TAG_GTYPE:
1521
+ case GI_TYPE_TAG_UTF8:
1522
+ case GI_TYPE_TAG_FILENAME:
1523
+ case GI_TYPE_TAG_ARRAY:
1524
+ case GI_TYPE_TAG_INTERFACE:
1525
+ case GI_TYPE_TAG_GLIST:
1526
+ case GI_TYPE_TAG_GSLIST:
1527
+ case GI_TYPE_TAG_GHASH:
1528
+ case GI_TYPE_TAG_ERROR:
1529
+ case GI_TYPE_TAG_UNICHAR:
1530
+ rb_raise(rb_eNotImpError,
1531
+ "TODO: invalid argument?: length[%s]",
1532
+ g_type_tag_to_string(type_tag));
1533
+ break;
1534
+ default:
1535
+ g_assert_not_reached();
1536
+ break;
1537
+ }
1538
+ }
1539
+
1540
+ static void
1541
+ set_in_array_gtype_arguments_from_ruby(GIArgument *array_argument,
1542
+ VALUE rb_class_array)
1543
+ {
1544
+ GType *types;
1545
+ gint i, n_args;
1546
+
1547
+ n_args = RARRAY_LEN(rb_class_array);
1548
+ types = ALLOC_N(GType, n_args);
1549
+ for (i = 0; i < n_args; i++) {
1550
+ types[i] = CLASS2GTYPE(RARRAY_PTR(rb_class_array)[i]);
1551
+ }
1552
+
1553
+ array_argument->v_pointer = types;
1554
+ }
1555
+
1556
+ static void
1557
+ in_array_c_argument_from_ruby(GIArgument *array_argument,
1558
+ GIArgument *length_argument,
1559
+ G_GNUC_UNUSED GITypeInfo *array_type_info,
1560
+ GITypeInfo *length_type_info,
1561
+ GITypeInfo *element_type_info,
1562
+ VALUE rb_argument)
1563
+ {
1564
+ GITypeTag element_type_tag;
1565
+
1566
+ element_type_tag = g_type_info_get_tag(element_type_info);
1567
+ switch (element_type_tag) {
1568
+ case GI_TYPE_TAG_VOID:
1569
+ case GI_TYPE_TAG_BOOLEAN:
1570
+ rb_raise(rb_eNotImpError,
1571
+ "TODO: Ruby -> GIArgument(array)[%s]",
1572
+ g_type_tag_to_string(element_type_tag));
1573
+ break;
1574
+ case GI_TYPE_TAG_INT8:
1575
+ case GI_TYPE_TAG_UINT8:
1576
+ array_argument->v_pointer = RSTRING_PTR(rb_argument);
1577
+ set_in_array_length_argument(length_argument, length_type_info,
1578
+ RSTRING_LEN(rb_argument));
1579
+ break;
1580
+ case GI_TYPE_TAG_INT16:
1581
+ case GI_TYPE_TAG_UINT16:
1582
+ case GI_TYPE_TAG_INT32:
1583
+ case GI_TYPE_TAG_UINT32:
1584
+ case GI_TYPE_TAG_INT64:
1585
+ case GI_TYPE_TAG_UINT64:
1586
+ case GI_TYPE_TAG_FLOAT:
1587
+ case GI_TYPE_TAG_DOUBLE:
1588
+ rb_raise(rb_eNotImpError,
1589
+ "TODO: Ruby -> GIArgument(array)[%s]",
1590
+ g_type_tag_to_string(element_type_tag));
1591
+ break;
1592
+ case GI_TYPE_TAG_GTYPE:
1593
+ set_in_array_gtype_arguments_from_ruby(array_argument,
1594
+ rb_argument);
1595
+ set_in_array_length_argument(length_argument, length_type_info,
1596
+ RARRAY_LEN(rb_argument));
1597
+ break;
1598
+ case GI_TYPE_TAG_UTF8:
1599
+ case GI_TYPE_TAG_FILENAME:
1600
+ array_argument->v_pointer = RVAL2STRV(rb_argument);
1601
+ set_in_array_length_argument(length_argument, length_type_info,
1602
+ RARRAY_LEN(rb_argument));
1603
+ break;
1604
+ case GI_TYPE_TAG_ARRAY:
1605
+ case GI_TYPE_TAG_INTERFACE:
1606
+ case GI_TYPE_TAG_GLIST:
1607
+ case GI_TYPE_TAG_GSLIST:
1608
+ case GI_TYPE_TAG_GHASH:
1609
+ case GI_TYPE_TAG_ERROR:
1610
+ case GI_TYPE_TAG_UNICHAR:
1611
+ rb_raise(rb_eNotImpError,
1612
+ "TODO: Ruby -> GIArgument(array)[%s]",
1613
+ g_type_tag_to_string(element_type_tag));
1614
+ break;
1615
+ default:
1616
+ g_assert_not_reached();
1617
+ break;
1618
+ }
1619
+ }
1620
+
1621
+ static void
1622
+ in_array_argument_from_ruby(GIArgument *array_argument,
1623
+ GIArgument *length_argument,
1624
+ GITypeInfo *array_type_info,
1625
+ GITypeInfo *length_type_info,
1626
+ VALUE rb_argument)
1627
+ {
1628
+ GIArrayType array_type;
1629
+ GITypeInfo *element_type_info;
1630
+
1631
+ array_type = g_type_info_get_array_type(array_type_info);
1632
+ element_type_info = g_type_info_get_param_type(array_type_info, 0);
1633
+ switch (array_type) {
1634
+ case GI_ARRAY_TYPE_C:
1635
+ in_array_c_argument_from_ruby(array_argument,
1636
+ length_argument,
1637
+ array_type_info,
1638
+ length_type_info,
1639
+ element_type_info,
1640
+ rb_argument);
1641
+ break;
1642
+ case GI_ARRAY_TYPE_ARRAY:
1643
+ case GI_ARRAY_TYPE_PTR_ARRAY:
1644
+ case GI_ARRAY_TYPE_BYTE_ARRAY:
1645
+ rb_raise(rb_eNotImpError,
1646
+ "TODO: Ruby -> GIArgument(array)[%s]",
1647
+ g_type_tag_to_string(g_type_info_get_tag(element_type_info)));
1648
+ break;
1649
+ default:
1650
+ g_assert_not_reached();
1651
+ break;
1652
+ }
1653
+ g_base_info_unref(element_type_info);
1654
+ }
1655
+
1656
+ static void
1657
+ set_inout_array_length_argument(GIArgument *argument,
1658
+ GITypeInfo *type_info,
1659
+ GIArgument *length)
1660
+ {
1661
+ GITypeTag type_tag;
1662
+
1663
+ if (!argument) {
1664
+ return;
1665
+ }
1666
+
1667
+ type_tag = g_type_info_get_tag(type_info);
1668
+ switch (type_tag) {
1669
+ case GI_TYPE_TAG_VOID:
1670
+ case GI_TYPE_TAG_BOOLEAN:
1671
+ rb_raise(rb_eNotImpError,
1672
+ "TODO: invalid argument?: length[%s]",
1673
+ g_type_tag_to_string(type_tag));
1674
+ break;
1675
+ case GI_TYPE_TAG_INT8:
1676
+ argument->v_pointer = ALLOC(gint8);
1677
+ *((gint8 *)argument->v_pointer) = length->v_int8;
1678
+ break;
1679
+ case GI_TYPE_TAG_UINT8:
1680
+ argument->v_pointer = ALLOC(guint8);
1681
+ *((guint8 *)argument->v_pointer) = length->v_uint8;
1682
+ break;
1683
+ case GI_TYPE_TAG_INT16:
1684
+ argument->v_pointer = ALLOC(gint16);
1685
+ *((gint16 *)argument->v_pointer) = length->v_int16;
1686
+ break;
1687
+ case GI_TYPE_TAG_UINT16:
1688
+ argument->v_pointer = ALLOC(guint16);
1689
+ *((guint16 *)argument->v_pointer) = length->v_uint16;
1690
+ break;
1691
+ case GI_TYPE_TAG_INT32:
1692
+ argument->v_pointer = ALLOC(gint32);
1693
+ *((gint32 *)argument->v_pointer) = length->v_int32;
1694
+ break;
1695
+ case GI_TYPE_TAG_UINT32:
1696
+ argument->v_pointer = ALLOC(guint32);
1697
+ *((guint32 *)argument->v_pointer) = length->v_uint32;
1698
+ break;
1699
+ case GI_TYPE_TAG_INT64:
1700
+ argument->v_pointer = ALLOC(gint64);
1701
+ *((gint64 *)argument->v_pointer) = length->v_int64;
1702
+ break;
1703
+ case GI_TYPE_TAG_UINT64:
1704
+ argument->v_pointer = ALLOC(guint64);
1705
+ *((guint64 *)argument->v_pointer) = length->v_uint64;
1706
+ break;
1707
+ case GI_TYPE_TAG_FLOAT:
1708
+ case GI_TYPE_TAG_DOUBLE:
1709
+ case GI_TYPE_TAG_GTYPE:
1710
+ case GI_TYPE_TAG_UTF8:
1711
+ case GI_TYPE_TAG_FILENAME:
1712
+ case GI_TYPE_TAG_ARRAY:
1713
+ case GI_TYPE_TAG_INTERFACE:
1714
+ case GI_TYPE_TAG_GLIST:
1715
+ case GI_TYPE_TAG_GSLIST:
1716
+ case GI_TYPE_TAG_GHASH:
1717
+ case GI_TYPE_TAG_ERROR:
1718
+ case GI_TYPE_TAG_UNICHAR:
1719
+ rb_raise(rb_eNotImpError,
1720
+ "TODO: invalid argument?: length[%s]",
1721
+ g_type_tag_to_string(type_tag));
1722
+ break;
1723
+ default:
1724
+ g_assert_not_reached();
1725
+ break;
1726
+ }
1727
+ }
1728
+
1729
+ static void
1730
+ inout_array_argument_from_ruby(GIArgument *array_argument,
1731
+ GIArgument *length_argument,
1732
+ GITypeInfo *array_type_info,
1733
+ GITypeInfo *length_type_info,
1734
+ VALUE rb_argument)
1735
+ {
1736
+ GIArgument in_array_argument;
1737
+ GIArgument in_length_argument;
1738
+
1739
+ in_array_argument_from_ruby(&in_array_argument,
1740
+ &in_length_argument,
1741
+ array_type_info,
1742
+ length_type_info,
1743
+ rb_argument);
1744
+
1745
+ array_argument->v_pointer = ALLOC(gpointer);
1746
+ *((gpointer *)array_argument->v_pointer) = in_array_argument.v_pointer;
1747
+ set_inout_array_length_argument(length_argument,
1748
+ length_type_info,
1749
+ &in_length_argument);
1750
+ }
1751
+
1752
+ GIArgument *
1753
+ rb_gi_in_array_argument_from_ruby(GIArgument *array_argument,
1754
+ GIArgument *length_argument,
1755
+ GIArgInfo *array_arg_info,
1756
+ GIArgInfo *length_arg_info,
1757
+ VALUE rb_argument)
1758
+ {
1759
+ GITypeInfo array_type_info;
1760
+ GITypeInfo length_type_info;
1761
+ GITypeInfo *length_type_info_arg = NULL;
1762
+
1763
+ if (g_arg_info_may_be_null(array_arg_info) && NIL_P(rb_argument)) {
1764
+ memset(array_argument, 0, sizeof(GIArgument));
1765
+ if (length_argument) {
1766
+ memset(length_argument, 0, sizeof(GIArgument));
1767
+ }
1768
+ return array_argument;
1769
+ }
1770
+
1771
+ g_arg_info_load_type(array_arg_info, &array_type_info);
1772
+ if (length_arg_info) {
1773
+ g_arg_info_load_type(length_arg_info, &length_type_info);
1774
+ length_type_info_arg = &length_type_info;
1775
+ }
1776
+ if (g_arg_info_get_direction(array_arg_info) == GI_DIRECTION_INOUT) {
1777
+ inout_array_argument_from_ruby(array_argument,
1778
+ length_argument,
1779
+ &array_type_info,
1780
+ length_type_info_arg,
1781
+ rb_argument);
1782
+ } else {
1783
+ GITransfer transfer;
1784
+
1785
+ in_array_argument_from_ruby(array_argument,
1786
+ length_argument,
1787
+ &array_type_info,
1788
+ length_type_info_arg,
1789
+ rb_argument);
1790
+ transfer = g_arg_info_get_ownership_transfer(array_arg_info);
1791
+ rb_gi_in_argument_transfer(array_argument,
1792
+ transfer,
1793
+ &array_type_info,
1794
+ rb_argument);
1795
+ }
1796
+
1797
+ return array_argument;
1798
+ }
1799
+
1800
+ static void
1801
+ rb_gi_value_argument_free_array_c(GIArgument *argument,
1802
+ G_GNUC_UNUSED GITypeInfo *type_info,
1803
+ GITypeInfo *element_type_info)
1804
+ {
1805
+ GITypeTag element_type_tag;
1806
+
1807
+ element_type_tag = g_type_info_get_tag(element_type_info);
1808
+ switch (element_type_tag) {
1809
+ case GI_TYPE_TAG_VOID:
1810
+ case GI_TYPE_TAG_BOOLEAN:
1811
+ rb_raise(rb_eNotImpError,
1812
+ "TODO: free GIArgument(array)[%s]",
1813
+ g_type_tag_to_string(element_type_tag));
1814
+ break;
1815
+ case GI_TYPE_TAG_INT8:
1816
+ case GI_TYPE_TAG_UINT8:
1817
+ /* Do nothing */
1818
+ break;
1819
+ case GI_TYPE_TAG_INT16:
1820
+ case GI_TYPE_TAG_UINT16:
1821
+ case GI_TYPE_TAG_INT32:
1822
+ case GI_TYPE_TAG_UINT32:
1823
+ case GI_TYPE_TAG_INT64:
1824
+ case GI_TYPE_TAG_UINT64:
1825
+ case GI_TYPE_TAG_FLOAT:
1826
+ case GI_TYPE_TAG_DOUBLE:
1827
+ rb_raise(rb_eNotImpError,
1828
+ "TODO: free GIArgument(array)[%s]",
1829
+ g_type_tag_to_string(element_type_tag));
1830
+ break;
1831
+ case GI_TYPE_TAG_GTYPE:
1832
+ xfree(argument->v_pointer);
1833
+ break;
1834
+ case GI_TYPE_TAG_UTF8:
1835
+ case GI_TYPE_TAG_FILENAME:
1836
+ g_free(argument->v_pointer);
1837
+ break;
1838
+ case GI_TYPE_TAG_ARRAY:
1839
+ case GI_TYPE_TAG_INTERFACE:
1840
+ case GI_TYPE_TAG_GLIST:
1841
+ case GI_TYPE_TAG_GSLIST:
1842
+ case GI_TYPE_TAG_GHASH:
1843
+ case GI_TYPE_TAG_ERROR:
1844
+ case GI_TYPE_TAG_UNICHAR:
1845
+ rb_raise(rb_eNotImpError,
1846
+ "TODO: free GIArgument(array)[%s]",
1847
+ g_type_tag_to_string(element_type_tag));
1848
+ break;
1849
+ default:
1850
+ g_assert_not_reached();
1851
+ break;
1852
+ }
1853
+ }
1854
+
1855
+ static void
1856
+ rb_gi_value_argument_free_array(GIArgument *argument, GITypeInfo *type_info)
1857
+ {
1858
+ GIArrayType array_type;
1859
+ GITypeInfo *element_type_info;
1860
+
1861
+ array_type = g_type_info_get_array_type(type_info);
1862
+ element_type_info = g_type_info_get_param_type(type_info, 0);
1863
+ switch (array_type) {
1864
+ case GI_ARRAY_TYPE_C:
1865
+ rb_gi_value_argument_free_array_c(argument,
1866
+ type_info,
1867
+ element_type_info);
1868
+ break;
1869
+ case GI_ARRAY_TYPE_ARRAY:
1870
+ case GI_ARRAY_TYPE_PTR_ARRAY:
1871
+ case GI_ARRAY_TYPE_BYTE_ARRAY:
1872
+ break;
1873
+ default:
1874
+ g_assert_not_reached();
1875
+ break;
1876
+ }
1877
+ g_base_info_unref(element_type_info);
1878
+ }
1879
+
1880
+ static void
1881
+ rb_gi_value_argument_free_interface(GIArgument *argument, GITypeInfo *type_info)
1882
+ {
1883
+ GIBaseInfo *interface_info;
1884
+ GIInfoType interface_type;
1885
+
1886
+ interface_info = g_type_info_get_interface(type_info);
1887
+ interface_type = g_base_info_get_type(interface_info);
1888
+
1889
+ if (interface_type == GI_INFO_TYPE_STRUCT) {
1890
+ GType gtype;
1891
+ gtype = g_registered_type_info_get_g_type(interface_info);
1892
+
1893
+ if (gtype == G_TYPE_VALUE) {
1894
+ GValue *gvalue = argument->v_pointer;
1895
+ g_value_unset(gvalue);
1896
+ xfree(argument->v_pointer);
1897
+ }
1898
+ }
1899
+
1900
+ g_base_info_unref(interface_info);
1901
+ }
1902
+
1903
+ void
1904
+ rb_gi_value_argument_free(GIArgument *argument, GITypeInfo *type_info)
1905
+ {
1906
+ GITypeTag type_tag;
1907
+
1908
+ type_tag = g_type_info_get_tag(type_info);
1909
+ switch (type_tag) {
1910
+ case GI_TYPE_TAG_VOID:
1911
+ case GI_TYPE_TAG_BOOLEAN:
1912
+ case GI_TYPE_TAG_INT8:
1913
+ case GI_TYPE_TAG_UINT8:
1914
+ case GI_TYPE_TAG_INT16:
1915
+ case GI_TYPE_TAG_UINT16:
1916
+ case GI_TYPE_TAG_INT32:
1917
+ case GI_TYPE_TAG_UINT32:
1918
+ case GI_TYPE_TAG_INT64:
1919
+ case GI_TYPE_TAG_UINT64:
1920
+ case GI_TYPE_TAG_FLOAT:
1921
+ case GI_TYPE_TAG_DOUBLE:
1922
+ case GI_TYPE_TAG_GTYPE:
1923
+ case GI_TYPE_TAG_UTF8:
1924
+ case GI_TYPE_TAG_FILENAME:
1925
+ break;
1926
+ case GI_TYPE_TAG_ARRAY:
1927
+ rb_gi_value_argument_free_array(argument, type_info);
1928
+ break;
1929
+ case GI_TYPE_TAG_INTERFACE:
1930
+ rb_gi_value_argument_free_interface(argument, type_info);
1931
+ break;
1932
+ case GI_TYPE_TAG_GLIST:
1933
+ case GI_TYPE_TAG_GSLIST:
1934
+ case GI_TYPE_TAG_GHASH:
1935
+ case GI_TYPE_TAG_ERROR:
1936
+ case GI_TYPE_TAG_UNICHAR:
1937
+ break;
1938
+ default:
1939
+ g_assert_not_reached();
1940
+ break;
1941
+ }
1942
+ }
1943
+
1944
+ static void
1945
+ rb_gi_inout_argument_free(GIArgument *argument, GITypeInfo *type_info)
1946
+ {
1947
+ GIArgument in_argument;
1948
+ GITypeTag type_tag;
1949
+
1950
+ memset(&in_argument, 0, sizeof(GIArgument));
1951
+ type_tag = g_type_info_get_tag(type_info);
1952
+ switch (type_tag) {
1953
+ case GI_TYPE_TAG_VOID:
1954
+ break;
1955
+ case GI_TYPE_TAG_BOOLEAN:
1956
+ in_argument.v_boolean = *((gboolean *)(argument->v_pointer));
1957
+ break;
1958
+ case GI_TYPE_TAG_INT8:
1959
+ in_argument.v_int8 = *((gint8 *)(argument->v_pointer));
1960
+ break;
1961
+ case GI_TYPE_TAG_UINT8:
1962
+ /* TODO!!! */
1963
+ in_argument.v_uint8 = *((guint8 *)(argument->v_pointer));
1964
+ argument->v_pointer = ALLOC(guint8);
1965
+ *((guint8 *)argument->v_pointer) = in_argument.v_uint8;
1966
+ break;
1967
+ case GI_TYPE_TAG_INT16:
1968
+ in_argument.v_int16 = *((gint16 *)(argument->v_pointer));
1969
+ argument->v_pointer = ALLOC(gint16);
1970
+ *((gint16 *)argument->v_pointer) = in_argument.v_int16;
1971
+ break;
1972
+ case GI_TYPE_TAG_UINT16:
1973
+ in_argument.v_uint16 = *((guint16 *)(argument->v_pointer));
1974
+ argument->v_pointer = ALLOC(guint16);
1975
+ *((guint16 *)argument->v_pointer) = in_argument.v_uint16;
1976
+ break;
1977
+ case GI_TYPE_TAG_INT32:
1978
+ in_argument.v_int32 = *((gint32 *)(argument->v_pointer));
1979
+ argument->v_pointer = ALLOC(gint32);
1980
+ *((gint32 *)argument->v_pointer) = in_argument.v_int32;
1981
+ break;
1982
+ case GI_TYPE_TAG_UINT32:
1983
+ in_argument.v_uint32 = *((guint32 *)(argument->v_pointer));
1984
+ argument->v_pointer = ALLOC(guint32);
1985
+ *((guint32 *)argument->v_pointer) = in_argument.v_uint32;
1986
+ break;
1987
+ case GI_TYPE_TAG_INT64:
1988
+ in_argument.v_int64 = *((gint64 *)(argument->v_pointer));
1989
+ argument->v_pointer = ALLOC(gint64);
1990
+ *((gint64 *)argument->v_pointer) = in_argument.v_int64;
1991
+ break;
1992
+ case GI_TYPE_TAG_UINT64:
1993
+ in_argument.v_uint64 = *((guint64 *)(argument->v_pointer));
1994
+ argument->v_pointer = ALLOC(guint64);
1995
+ *((guint64 *)argument->v_pointer) = in_argument.v_uint64;
1996
+ break;
1997
+ case GI_TYPE_TAG_FLOAT:
1998
+ in_argument.v_float = *((gfloat *)(argument->v_pointer));
1999
+ argument->v_pointer = ALLOC(gfloat);
2000
+ *((gfloat *)argument->v_pointer) = in_argument.v_float;
2001
+ break;
2002
+ case GI_TYPE_TAG_DOUBLE:
2003
+ in_argument.v_double = *((gdouble *)(argument->v_pointer));
2004
+ argument->v_pointer = ALLOC(gdouble);
2005
+ *((gdouble *)argument->v_pointer) = in_argument.v_double;
2006
+ break;
2007
+ case GI_TYPE_TAG_GTYPE:
2008
+ in_argument.v_size = *((gsize *)(argument->v_pointer));
2009
+ break;
2010
+ case GI_TYPE_TAG_UTF8:
2011
+ case GI_TYPE_TAG_FILENAME:
2012
+ in_argument.v_string = *((gchar **)(argument->v_pointer));
2013
+ break;
2014
+ case GI_TYPE_TAG_ARRAY:
2015
+ case GI_TYPE_TAG_INTERFACE:
2016
+ case GI_TYPE_TAG_GLIST:
2017
+ case GI_TYPE_TAG_GSLIST:
2018
+ case GI_TYPE_TAG_GHASH:
2019
+ in_argument.v_pointer = *((gpointer *)(argument->v_pointer));
2020
+ break;
2021
+ case GI_TYPE_TAG_ERROR:
2022
+ in_argument.v_pointer = *((GError **)(argument->v_pointer));
2023
+ break;
2024
+ case GI_TYPE_TAG_UNICHAR:
2025
+ in_argument.v_uint32 = *((gunichar *)(argument->v_pointer));
2026
+ break;
2027
+ default:
2028
+ g_assert_not_reached();
2029
+ break;
2030
+ }
2031
+
2032
+ rb_gi_value_argument_free(&in_argument, type_info);
2033
+ xfree(argument->v_pointer);
2034
+ }
2035
+
2036
+ void
2037
+ rb_gi_in_argument_free(GIArgument *argument, GIArgInfo *arg_info)
2038
+ {
2039
+ GITypeInfo type_info;
2040
+
2041
+ g_arg_info_load_type(arg_info, &type_info);
2042
+ if (g_arg_info_get_direction(arg_info) == GI_DIRECTION_INOUT) {
2043
+ rb_gi_inout_argument_free(argument, &type_info);
2044
+ } else {
2045
+ rb_gi_value_argument_free(argument, &type_info);
2046
+ }
2047
+ }
2048
+
2049
+ void
2050
+ rb_gi_argument_init(void)
2051
+ {
2052
+ rb_cGLibValue = rb_const_get(mGLib, rb_intern("Value"));
2053
+ }