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
@@ -0,0 +1,240 @@
1
+ # -*- Mode: Python -*-
2
+ # Copyright (C) 2010 Red Hat, Inc.
3
+ #
4
+ # This library is free software; you can redistribute it and/or
5
+ # modify it under the terms of the GNU Lesser General Public
6
+ # License as published by the Free Software Foundation; either
7
+ # version 2 of the License, or (at your option) any later version.
8
+ #
9
+ # This library is distributed in the hope that it will be useful,
10
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
11
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12
+ # Lesser General Public License for more details.
13
+ #
14
+ # You should have received a copy of the GNU Lesser General Public
15
+ # License along with this library; if not, write to the
16
+ # Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17
+ # Boston, MA 02111-1307, USA.
18
+ #
19
+
20
+ from . import ast
21
+ from . import message
22
+ from .annotationparser import TAG_RETURNS
23
+
24
+
25
+ class IntrospectablePass(object):
26
+
27
+ def __init__(self, transformer, blocks):
28
+ self._transformer = transformer
29
+ self._namespace = transformer.namespace
30
+ self._blocks = blocks
31
+
32
+ # Public API
33
+
34
+ def validate(self):
35
+ self._namespace.walk(self._introspectable_alias_analysis)
36
+ self._namespace.walk(self._propagate_callable_skips)
37
+ self._namespace.walk(self._analyze_node)
38
+ self._namespace.walk(self._introspectable_callable_analysis)
39
+ self._namespace.walk(self._introspectable_callable_analysis)
40
+ self._namespace.walk(self._introspectable_pass3)
41
+ self._namespace.walk(self._remove_non_reachable_backcompat_copies)
42
+
43
+ def _parameter_warning(self, parent, param, text, position=None):
44
+ # Suppress VFunctions and Callbacks warnings for now
45
+ # they cause more problems then they are worth
46
+ if isinstance(parent, (ast.VFunction, ast.Callback)):
47
+ return
48
+
49
+ block = None
50
+ if hasattr(parent, 'symbol'):
51
+ prefix = '%s: ' % (parent.symbol, )
52
+ block = self._blocks.get(parent.symbol)
53
+ if block:
54
+ position = block.position
55
+ else:
56
+ prefix = ''
57
+ if isinstance(param, ast.Parameter):
58
+ context = "argument %s: " % (param.argname, )
59
+ else:
60
+ context = "return value: "
61
+ if block:
62
+ return_tag = block.tags.get(TAG_RETURNS)
63
+ if return_tag:
64
+ position = return_tag.position
65
+ message.warn_node(parent, prefix + context + text,
66
+ positions=position)
67
+
68
+ def _introspectable_param_analysis(self, parent, node):
69
+ is_return = isinstance(node, ast.Return)
70
+ is_parameter = isinstance(node, ast.Parameter)
71
+ assert is_return or is_parameter
72
+
73
+ if node.type.target_giname is not None:
74
+ target = self._transformer.lookup_typenode(node.type)
75
+ else:
76
+ target = None
77
+
78
+ if node.skip:
79
+ return
80
+
81
+ if not node.type.resolved:
82
+ self._parameter_warning(parent, node,
83
+ "Unresolved type: %r" % (node.type.unresolved_string, ))
84
+ parent.introspectable = False
85
+ return
86
+
87
+ if isinstance(node.type, ast.Varargs):
88
+ parent.introspectable = False
89
+ return
90
+
91
+ if (isinstance(node.type, (ast.List, ast.Array))
92
+ and node.type.element_type == ast.TYPE_ANY):
93
+ self._parameter_warning(parent, node, "Missing (element-type) annotation")
94
+ parent.introspectable = False
95
+ return
96
+
97
+ if (is_parameter
98
+ and isinstance(target, ast.Callback)
99
+ and not node.type.target_giname in ('GLib.DestroyNotify', 'Gio.AsyncReadyCallback')
100
+ and node.scope is None):
101
+ self._parameter_warning(
102
+ parent,
103
+ node,
104
+ "Missing (scope) annotation for callback without "
105
+ "GDestroyNotify (valid: %s, %s)" % (ast.PARAM_SCOPE_CALL, ast.PARAM_SCOPE_ASYNC))
106
+
107
+ parent.introspectable = False
108
+ return
109
+
110
+ if is_return and isinstance(target, ast.Callback):
111
+ self._parameter_warning(parent, node, "Callbacks cannot be return values; use (skip)")
112
+ parent.introspectable = False
113
+ return
114
+
115
+ if (is_return
116
+ and isinstance(target, (ast.Record, ast.Union))
117
+ and target.get_type is None
118
+ and not target.foreign):
119
+ if node.transfer != ast.PARAM_TRANSFER_NONE:
120
+ self._parameter_warning(
121
+ parent, node,
122
+ "Invalid non-constant return of bare structure or union; "
123
+ "register as boxed type or (skip)")
124
+ parent.introspectable = False
125
+ return
126
+
127
+ if node.transfer is None:
128
+ self._parameter_warning(parent, node, "Missing (transfer) annotation")
129
+ parent.introspectable = False
130
+ return
131
+
132
+ def _type_is_introspectable(self, typeval, warn=False):
133
+ if not typeval.resolved:
134
+ return False
135
+ if isinstance(typeval, ast.TypeUnknown):
136
+ return False
137
+ if isinstance(typeval, (ast.Array, ast.List)):
138
+ return self._type_is_introspectable(typeval.element_type)
139
+ elif isinstance(typeval, ast.Map):
140
+ return (self._type_is_introspectable(typeval.key_type)
141
+ and self._type_is_introspectable(typeval.value_type))
142
+ if typeval.target_foreign:
143
+ return True
144
+ if typeval.target_fundamental:
145
+ if typeval.is_equiv(ast.TYPE_VALIST):
146
+ return False
147
+ # These are not introspectable pending us adding
148
+ # larger type tags to the typelib (in theory these could
149
+ # be 128 bit or larger)
150
+ elif typeval.is_equiv((ast.TYPE_LONG_LONG, ast.TYPE_LONG_ULONG, ast.TYPE_LONG_DOUBLE)):
151
+ return False
152
+ else:
153
+ return True
154
+ target = self._transformer.lookup_typenode(typeval)
155
+ if not target:
156
+ return False
157
+ return target.introspectable and (not target.skip)
158
+
159
+ def _propagate_parameter_skip(self, parent, node):
160
+ if node.type.target_giname is not None:
161
+ target = self._transformer.lookup_typenode(node.type)
162
+ if target is None:
163
+ return
164
+ else:
165
+ return
166
+
167
+ if target.skip:
168
+ parent.skip = True
169
+
170
+ def _introspectable_alias_analysis(self, obj, stack):
171
+ if isinstance(obj, ast.Alias):
172
+ if not self._type_is_introspectable(obj.target):
173
+ obj.introspectable = False
174
+ return True
175
+
176
+ def _propagate_callable_skips(self, obj, stack):
177
+ if isinstance(obj, ast.Callable):
178
+ for param in obj.parameters:
179
+ self._propagate_parameter_skip(obj, param)
180
+ self._propagate_parameter_skip(obj, obj.retval)
181
+ return True
182
+
183
+ def _analyze_node(self, obj, stack):
184
+ if obj.skip:
185
+ return False
186
+ # Our first pass for scriptability
187
+ if isinstance(obj, ast.Callable):
188
+ for param in obj.parameters:
189
+ self._introspectable_param_analysis(obj, param)
190
+ self._introspectable_param_analysis(obj, obj.retval)
191
+ if isinstance(obj, (ast.Class, ast.Interface, ast.Record, ast.Union)):
192
+ for field in obj.fields:
193
+ if field.type:
194
+ if not self._type_is_introspectable(field.type):
195
+ field.introspectable = False
196
+ return True
197
+
198
+ def _introspectable_callable_analysis(self, obj, stack):
199
+ if obj.skip:
200
+ return False
201
+ # Propagate introspectability of parameters to entire functions
202
+ if isinstance(obj, ast.Callable):
203
+ for param in obj.parameters:
204
+ if not self._type_is_introspectable(param.type):
205
+ obj.introspectable = False
206
+ return True
207
+ if not self._type_is_introspectable(obj.retval.type):
208
+ obj.introspectable = False
209
+ return True
210
+ return True
211
+
212
+ def _introspectable_pass3(self, obj, stack):
213
+ if obj.skip:
214
+ return False
215
+ # Propagate introspectability for fields
216
+ if isinstance(obj, (ast.Class, ast.Interface, ast.Record, ast.Union)):
217
+ for field in obj.fields:
218
+ if field.anonymous_node:
219
+ if not field.anonymous_node.introspectable:
220
+ field.introspectable = False
221
+ else:
222
+ if not self._type_is_introspectable(field.type):
223
+ field.introspectable = False
224
+ # Propagate introspectability for properties
225
+ if isinstance(obj, (ast.Class, ast.Interface)):
226
+ for prop in obj.properties:
227
+ if not self._type_is_introspectable(prop.type):
228
+ prop.introspectable = False
229
+ for sig in obj.signals:
230
+ self._introspectable_callable_analysis(sig, [obj])
231
+ return True
232
+
233
+ def _remove_non_reachable_backcompat_copies(self, obj, stack):
234
+ if obj.skip:
235
+ return False
236
+ if (isinstance(obj, ast.Function) and obj.moved_to is not None):
237
+ # remove functions that are not introspectable
238
+ if not obj.introspectable:
239
+ obj.internal_skipped = True
240
+ return True
@@ -0,0 +1,76 @@
1
+ # -*- Mode: Python -*-
2
+ # GObject-Introspection - a framework for introspecting GObject libraries
3
+ # Copyright (C) 2008 Johan Dahlin
4
+ #
5
+ # This library is free software; you can redistribute it and/or
6
+ # modify it under the terms of the GNU Lesser General Public
7
+ # License as published by the Free Software Foundation; either
8
+ # version 2 of the License, or (at your option) any later version.
9
+ #
10
+ # This library is distributed in the hope that it will be useful,
11
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13
+ # Lesser General Public License for more details.
14
+ #
15
+ # You should have received a copy of the GNU Lesser General Public
16
+ # License along with this library; if not, write to the
17
+ # Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18
+ # Boston, MA 02111-1307, USA.
19
+ #
20
+
21
+ import imp
22
+ import os
23
+ import platform
24
+ import sys
25
+
26
+ from .utils import extract_libtool
27
+
28
+
29
+ class LibtoolImporter(object):
30
+
31
+ def __init__(self, name, path):
32
+ self.name = name
33
+ self.path = path
34
+
35
+ @classmethod
36
+ def find_module(cls, name, packagepath=None):
37
+ modparts = name.split('.')
38
+ filename = modparts.pop() + '.la'
39
+
40
+ # Given some.package.module 'path' is where subpackages of some.package
41
+ # should be looked for. See if we can find a ".libs/module.la" relative
42
+ # to those directories and failing that look for file
43
+ # "some/package/.libs/module.la" relative to sys.path
44
+ if len(modparts) > 0:
45
+ modprefix = os.path.join(*modparts)
46
+ modprefix = os.path.join(modprefix, '.libs')
47
+ else:
48
+ modprefix = '.libs'
49
+
50
+ for path in sys.path:
51
+ full = os.path.join(path, modprefix, filename)
52
+ if os.path.exists(full):
53
+ return cls(name, full)
54
+
55
+ def load_module(self, name):
56
+ realpath = extract_libtool(self.path)
57
+ platform_system = platform.system()
58
+
59
+ if platform_system == 'Darwin':
60
+ extension = '.dylib'
61
+ elif platform_system == 'Windows':
62
+ extension = '.dll'
63
+ else:
64
+ extension = '.so'
65
+
66
+ mod = imp.load_module(name, open(realpath), realpath, (extension, 'rb', 3))
67
+ mod.__loader__ = self
68
+ return mod
69
+
70
+ @classmethod
71
+ def __enter__(cls):
72
+ sys.meta_path.append(cls)
73
+
74
+ @classmethod
75
+ def __exit__(cls, exc_type, exc_val, exc_tb):
76
+ sys.meta_path.remove(cls)
@@ -0,0 +1,1366 @@
1
+ # -*- Mode: Python -*-
2
+ # Copyright (C) 2010 Red Hat, Inc.
3
+ #
4
+ # This library is free software; you can redistribute it and/or
5
+ # modify it under the terms of the GNU Lesser General Public
6
+ # License as published by the Free Software Foundation; either
7
+ # version 2 of the License, or (at your option) any later version.
8
+ #
9
+ # This library is distributed in the hope that it will be useful,
10
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
11
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12
+ # Lesser General Public License for more details.
13
+ #
14
+ # You should have received a copy of the GNU Lesser General Public
15
+ # License along with this library; if not, write to the
16
+ # Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17
+ # Boston, MA 02111-1307, USA.
18
+ #
19
+
20
+ import re
21
+
22
+ from . import ast
23
+ from . import message
24
+ from .annotationparser import (TAG_DEPRECATED, TAG_SINCE, TAG_STABILITY, TAG_RETURNS)
25
+ from .annotationparser import (ANN_ALLOW_NONE, ANN_ARRAY, ANN_ATTRIBUTES, ANN_CLOSURE,
26
+ ANN_CONSTRUCTOR, ANN_DESTROY, ANN_ELEMENT_TYPE, ANN_FOREIGN,
27
+ ANN_GET_VALUE_FUNC, ANN_IN, ANN_INOUT, ANN_METHOD, ANN_OUT,
28
+ ANN_REF_FUNC, ANN_RENAME_TO, ANN_SCOPE, ANN_SET_VALUE_FUNC,
29
+ ANN_SKIP, ANN_TRANSFER, ANN_TYPE, ANN_UNREF_FUNC, ANN_VALUE,
30
+ ANN_VFUNC, ANN_NULLABLE, ANN_OPTIONAL)
31
+ from .annotationparser import (OPT_ARRAY_FIXED_SIZE, OPT_ARRAY_LENGTH, OPT_ARRAY_ZERO_TERMINATED,
32
+ OPT_OUT_CALLEE_ALLOCATES, OPT_OUT_CALLER_ALLOCATES,
33
+ OPT_TRANSFER_FLOATING, OPT_TRANSFER_NONE)
34
+
35
+ from .utils import to_underscores_noprefix
36
+
37
+
38
+ class MainTransformer(object):
39
+
40
+ def __init__(self, transformer, blocks):
41
+ self._transformer = transformer
42
+ self._blocks = blocks
43
+ self._namespace = transformer.namespace
44
+ self._uscore_type_names = {}
45
+
46
+ # Public API
47
+
48
+ def transform(self):
49
+ if not self._namespace.names:
50
+ message.fatal('Namespace is empty; likely causes are:\n'
51
+ '* Not including .h files to be scanned\n'
52
+ '* Broken --identifier-prefix')
53
+
54
+ # Some initial namespace surgery
55
+ self._namespace.walk(self._pass_fixup_hidden_fields)
56
+
57
+ # We have a rough tree which should have most of of the types
58
+ # we know about. Let's attempt closure; walk over all of the
59
+ # Type() types and see if they match up with something.
60
+ self._namespace.walk(self._pass_type_resolution)
61
+
62
+ # Read in annotations needed early
63
+ self._namespace.walk(self._pass_read_annotations_early)
64
+
65
+ # Determine some default values for transfer etc.
66
+ # based on the current tree.
67
+ self._namespace.walk(self._pass_callable_defaults)
68
+
69
+ # Read in most annotations now.
70
+ self._namespace.walk(self._pass_read_annotations)
71
+
72
+ # Now that we've possibly seen more types from annotations,
73
+ # do another type resolution pass.
74
+ self._namespace.walk(self._pass_type_resolution)
75
+
76
+ # Generate a reverse mapping "bar_baz" -> BarBaz
77
+ for node in self._namespace.itervalues():
78
+ if isinstance(node, ast.Registered) and node.get_type is not None:
79
+ self._uscore_type_names[node.c_symbol_prefix] = node
80
+ elif isinstance(node, (ast.Record, ast.Union)):
81
+ uscored = to_underscores_noprefix(node.name).lower()
82
+ self._uscore_type_names[uscored] = node
83
+
84
+ for node in list(self._namespace.itervalues()):
85
+ if isinstance(node, ast.Function):
86
+ # Discover which toplevel functions are actually methods
87
+ self._pair_function(node)
88
+ if isinstance(node, (ast.Class, ast.Interface)):
89
+ self._pair_class_virtuals(node)
90
+
91
+ # Some annotations need to be post function pairing
92
+ self._namespace.walk(self._pass_read_annotations2)
93
+
94
+ # Another type resolution pass after we've parsed virtuals, etc.
95
+ self._namespace.walk(self._pass_type_resolution)
96
+
97
+ self._namespace.walk(self._pass3)
98
+
99
+ # TODO - merge into pass3
100
+ self._pair_quarks_with_enums()
101
+
102
+ # Private
103
+
104
+ def _pass_fixup_hidden_fields(self, node, chain):
105
+ """Hide all callbacks starting with _; the typical
106
+ usage is void (*_gtk_reserved1)(void);"""
107
+ if isinstance(node, (ast.Class, ast.Interface, ast.Record, ast.Union)):
108
+ for field in node.fields:
109
+ if (field
110
+ and field.name is not None
111
+ and field.name.startswith('_')
112
+ and field.anonymous_node is not None
113
+ and isinstance(field.anonymous_node, ast.Callback)):
114
+ field.introspectable = False
115
+ return True
116
+
117
+ def _get_validate_parameter_name(self, parent, param_name, origin):
118
+ try:
119
+ param = parent.get_parameter(param_name)
120
+ except ValueError:
121
+ param = None
122
+ if param is None:
123
+ if isinstance(origin, ast.Parameter):
124
+ origin_name = 'parameter %s' % (origin.argname, )
125
+ else:
126
+ origin_name = 'return value'
127
+ message.log_node(
128
+ message.FATAL, parent,
129
+ "can't find parameter %s referenced by %s of %r"
130
+ % (param_name, origin_name, parent.name))
131
+
132
+ return param.argname
133
+
134
+ def _get_validate_field_name(self, parent, field_name, origin):
135
+ try:
136
+ field = parent.get_field(field_name)
137
+ except ValueError:
138
+ field = None
139
+ if field is None:
140
+ origin_name = 'field %s' % (origin.name, )
141
+ message.log_node(
142
+ message.FATAL, parent,
143
+ "can't find field %s referenced by %s of %r"
144
+ % (field_name, origin_name, parent.name))
145
+
146
+ return field.name
147
+
148
+ def _apply_annotation_rename_to(self, node, chain, block):
149
+ if not block:
150
+ return
151
+ rename_to = block.annotations.get(ANN_RENAME_TO)
152
+ if not rename_to:
153
+ return
154
+ rename_to = rename_to[0]
155
+ target = self._namespace.get_by_symbol(rename_to)
156
+ if not target:
157
+ message.warn_node(node,
158
+ "Can't find symbol %r referenced by \"rename-to\" annotation" % (rename_to, ))
159
+ elif target.shadowed_by:
160
+ message.warn_node(node,
161
+ "Function %r already shadowed by %r, can't overwrite "
162
+ "with %r" % (target.symbol,
163
+ target.shadowed_by,
164
+ rename_to))
165
+ elif target.shadows:
166
+ message.warn_node(node,
167
+ "Function %r already shadows %r, can't multiply shadow "
168
+ "with %r" % (target.symbol,
169
+ target.shadows,
170
+ rename_to))
171
+ else:
172
+ target.shadowed_by = node.name
173
+ node.shadows = target.name
174
+
175
+ def _apply_annotations_function(self, node, chain):
176
+ block = self._blocks.get(node.symbol)
177
+ self._apply_annotations_callable(node, chain, block)
178
+
179
+ def _pass_read_annotations_early(self, node, chain):
180
+ if isinstance(node, ast.Record):
181
+ if node.ctype is not None:
182
+ block = self._blocks.get(node.ctype)
183
+ else:
184
+ block = self._blocks.get(node.c_name)
185
+ self._apply_annotations_annotated(node, block)
186
+ return True
187
+
188
+ def _pass_callable_defaults(self, node, chain):
189
+ if isinstance(node, (ast.Callable, ast.Signal)):
190
+ for param in node.parameters:
191
+ if param.transfer is None:
192
+ param.transfer = self._get_transfer_default(node, param)
193
+ if node.retval.transfer is None:
194
+ node.retval.transfer = self._get_transfer_default(node, node.retval)
195
+ return True
196
+
197
+ def _get_annotation_name(self, node):
198
+ if isinstance(node, (ast.Class, ast.Interface, ast.Record,
199
+ ast.Union, ast.Enum, ast.Bitfield,
200
+ ast.Callback, ast.Alias, ast.Constant)):
201
+ if node.ctype is not None:
202
+ return node.ctype
203
+ elif isinstance(node, ast.Registered) and node.gtype_name is not None:
204
+ return node.gtype_name
205
+ return node.c_name
206
+ raise AssertionError("Unhandled node %r" % (node, ))
207
+
208
+ def _get_block(self, node):
209
+ return self._blocks.get(self._get_annotation_name(node))
210
+
211
+ def _pass_read_annotations(self, node, chain):
212
+ if not node.namespace:
213
+ return False
214
+ if isinstance(node, ast.Alias):
215
+ self._apply_annotations_alias(node, chain)
216
+ if isinstance(node, ast.Function):
217
+ self._apply_annotations_function(node, chain)
218
+ if isinstance(node, ast.Callback):
219
+ self._apply_annotations_callable(node, chain, block=self._get_block(node))
220
+ if isinstance(node, (ast.Class, ast.Interface, ast.Union, ast.Enum,
221
+ ast.Bitfield, ast.Callback)):
222
+ self._apply_annotations_annotated(node, self._get_block(node))
223
+ if isinstance(node, (ast.Enum, ast.Bitfield)):
224
+ self._apply_annotations_enum_members(node, self._get_block(node))
225
+ if isinstance(node, (ast.Class, ast.Interface, ast.Record, ast.Union)):
226
+ block = self._get_block(node)
227
+ for field in node.fields:
228
+ self._apply_annotations_field(node, block, field)
229
+ name = self._get_annotation_name(node)
230
+ section_name = 'SECTION:%s' % (name.lower(), )
231
+ block = self._blocks.get(section_name)
232
+ if block and block.description:
233
+ node.doc = block.description
234
+ if isinstance(node, (ast.Class, ast.Interface)):
235
+ for prop in node.properties:
236
+ self._apply_annotations_property(node, prop)
237
+ for sig in node.signals:
238
+ self._apply_annotations_signal(node, sig)
239
+ if isinstance(node, ast.Class):
240
+ block = self._get_block(node)
241
+ if block:
242
+ annotation = block.annotations.get(ANN_UNREF_FUNC)
243
+ node.unref_func = annotation[0] if annotation else None
244
+ annotation = block.annotations.get(ANN_REF_FUNC)
245
+ node.ref_func = annotation[0] if annotation else None
246
+ annotation = block.annotations.get(ANN_SET_VALUE_FUNC)
247
+ node.set_value_func = annotation[0] if annotation else None
248
+ annotation = block.annotations.get(ANN_GET_VALUE_FUNC)
249
+ node.get_value_func = annotation[0] if annotation else None
250
+ if isinstance(node, ast.Constant):
251
+ self._apply_annotations_constant(node)
252
+ return True
253
+
254
+ def _adjust_container_type(self, parent, node, annotations):
255
+ if ANN_ARRAY in annotations:
256
+ self._apply_annotations_array(parent, node, annotations)
257
+ elif ANN_ELEMENT_TYPE in annotations:
258
+ self._apply_annotations_element_type(parent, node, annotations)
259
+
260
+ if isinstance(node.type, ast.Array):
261
+ self._check_array_element_type(node.type, annotations)
262
+
263
+ def _resolve(self, type_str, type_node=None, node=None, parent=None):
264
+ def grab_one(type_str, resolver, top_combiner, combiner):
265
+ """Return a complete type, and the trailing string part after it.
266
+ Use resolver() on each identifier, and combiner() on the parts of
267
+ each complete type. (top_combiner is used on the top-most type.)"""
268
+ bits = re.split(r'([,<>()])', type_str, 1)
269
+ first, sep, rest = [bits[0], '', ''] if (len(bits) == 1) else bits
270
+ args = [resolver(first)]
271
+ if sep == '<' or sep == '(':
272
+ lastsep = '>' if (sep == '<') else ')'
273
+ while sep != lastsep:
274
+ next, rest = grab_one(rest, resolver, combiner, combiner)
275
+ args.append(next)
276
+ sep, rest = rest[0], rest[1:]
277
+ else:
278
+ rest = sep + rest
279
+ return top_combiner(*args), rest
280
+
281
+ def resolver(ident):
282
+ res = self._transformer.create_type_from_user_string(ident)
283
+ return res
284
+
285
+ def combiner(base, *rest):
286
+ if not rest:
287
+ return base
288
+ if isinstance(base, ast.List) and len(rest) == 1:
289
+ return ast.List(base.name, *rest)
290
+ elif isinstance(base, ast.Array) and len(rest) == 1:
291
+ base.element_type = rest[0]
292
+ return base
293
+ elif isinstance(base, ast.Map) and len(rest) == 2:
294
+ return ast.Map(*rest)
295
+ message.warn(
296
+ "Too many parameters in type specification %r" % (type_str, ))
297
+ return base
298
+
299
+ def top_combiner(base, *rest):
300
+ if type_node is not None and isinstance(type_node, ast.Type):
301
+ base.is_const = type_node.is_const
302
+ return combiner(base, *rest)
303
+
304
+ result, rest = grab_one(type_str, resolver, top_combiner, combiner)
305
+ if rest:
306
+ message.warn("Trailing components in type specification %r" % (
307
+ type_str, ))
308
+
309
+ if not result.resolved:
310
+ position = None
311
+ if parent is not None and isinstance(parent, ast.Function):
312
+ text = parent.symbol
313
+ position = self._get_position(parent, node)
314
+ else:
315
+ text = type_str
316
+ message.warn_node(parent, "%s: Unknown type: %r" %
317
+ (text, type_str), positions=position)
318
+ return result
319
+
320
+ def _resolve_toplevel(self, type_str, type_node=None, node=None, parent=None):
321
+ """Like _resolve(), but attempt to preserve more attributes of original type."""
322
+ result = self._resolve(type_str, type_node=type_node, node=node, parent=parent)
323
+ # If we replace a node with a new type (such as an annotated) we
324
+ # might lose the ctype from the original node.
325
+ if type_node is not None:
326
+ result.ctype = type_node.ctype
327
+ return result
328
+
329
+ def _get_position(self, func, param):
330
+ block = self._blocks.get(func.symbol)
331
+ if block:
332
+ if isinstance(param, ast.Parameter):
333
+ part = block.params.get(param.argname)
334
+ elif isinstance(param, ast.Return):
335
+ part = block.tags.get(TAG_RETURNS)
336
+ else:
337
+ part = None
338
+
339
+ if part.position:
340
+ return part.position
341
+
342
+ return block.position
343
+
344
+ def _check_array_element_type(self, array, annotations):
345
+ array_type = array.array_type
346
+ element_type = array.element_type
347
+
348
+ # GPtrArrays are allowed to contain non basic types
349
+ # (except enums and flags) or basic types that are
350
+ # as big as a gpointer
351
+ if array_type == ast.Array.GLIB_PTRARRAY:
352
+ if ((element_type in ast.BASIC_GIR_TYPES and not element_type in ast.POINTER_TYPES)
353
+ or isinstance(element_type, (ast.Enum, ast.Bitfield))):
354
+ message.warn("invalid (element-type) for a GPtrArray, "
355
+ "must be a pointer", annotations.position)
356
+
357
+ # GByteArrays have (element-type) guint8 by default
358
+ if array_type == ast.Array.GLIB_BYTEARRAY:
359
+ if element_type == ast.TYPE_ANY:
360
+ array.element_type = ast.TYPE_UINT8
361
+ elif not element_type in [ast.TYPE_UINT8, ast.TYPE_INT8, ast.TYPE_CHAR]:
362
+ message.warn("invalid (element-type) for a GByteArray, "
363
+ "must be one of guint8, gint8 or gchar",
364
+ annotations.position)
365
+
366
+ def _apply_annotations_array(self, parent, node, annotations):
367
+ element_type_options = annotations.get(ANN_ELEMENT_TYPE)
368
+ if element_type_options:
369
+ element_type_node = self._resolve(element_type_options[0],
370
+ node.type, node, parent)
371
+ elif isinstance(node.type, ast.Array):
372
+ element_type_node = node.type.element_type
373
+ else:
374
+ # We're assuming here that Foo* with an (array) annotation
375
+ # and no (element-type) means array of Foo
376
+ element_type_node = node.type.clone()
377
+ # The element's ctype is the array's dereferenced
378
+ if element_type_node.ctype is not None and element_type_node.ctype.endswith('*'):
379
+ element_type_node.ctype = element_type_node.ctype[:-1]
380
+
381
+ if isinstance(node.type, ast.Array):
382
+ array_type = node.type.array_type
383
+ else:
384
+ array_type = None
385
+
386
+ array_options = annotations.get(ANN_ARRAY)
387
+ container_type = ast.Array(array_type, element_type_node, ctype=node.type.ctype,
388
+ is_const=node.type.is_const)
389
+ if OPT_ARRAY_ZERO_TERMINATED in array_options:
390
+ container_type.zeroterminated = array_options.get(OPT_ARRAY_ZERO_TERMINATED) == '1'
391
+ else:
392
+ container_type.zeroterminated = False
393
+
394
+ length = array_options.get(OPT_ARRAY_LENGTH)
395
+ if length:
396
+ if isinstance(parent, ast.Compound):
397
+ paramname = self._get_validate_field_name(parent, length, node)
398
+ else:
399
+ paramname = self._get_validate_parameter_name(parent, length, node)
400
+ if paramname:
401
+ param = parent.get_parameter(paramname)
402
+ param.direction = node.direction
403
+ if param.direction == ast.PARAM_DIRECTION_OUT:
404
+ param.transfer = ast.PARAM_TRANSFER_FULL
405
+ if paramname:
406
+ container_type.length_param_name = paramname
407
+ fixed = array_options.get(OPT_ARRAY_FIXED_SIZE)
408
+ if fixed:
409
+ try:
410
+ container_type.size = int(fixed)
411
+ except (TypeError, ValueError):
412
+ # Already warned in annotationparser.py
413
+ return
414
+ node.type = container_type
415
+
416
+ def _apply_annotations_element_type(self, parent, node, annotations):
417
+ element_type_options = annotations.get(ANN_ELEMENT_TYPE)
418
+ if element_type_options is None:
419
+ return
420
+
421
+ if isinstance(node.type, ast.List):
422
+ if len(element_type_options) != 1:
423
+ message.warn(
424
+ '"element-type" annotation for a list must have exactly '
425
+ 'one option, not %d options' % (len(element_type_options), ),
426
+ annotations.position)
427
+ return
428
+ node.type.element_type = self._resolve(element_type_options[0],
429
+ node.type, node, parent)
430
+ elif isinstance(node.type, ast.Map):
431
+ if len(element_type_options) != 2:
432
+ message.warn(
433
+ '"element-type" annotation for a hash table must have exactly '
434
+ 'two options, not %d option(s)' % (len(element_type_options), ),
435
+ annotations.position)
436
+ return
437
+ node.type.key_type = self._resolve(element_type_options[0],
438
+ node.type, node, parent)
439
+ node.type.value_type = self._resolve(element_type_options[1],
440
+ node.type, node, parent)
441
+ elif isinstance(node.type, ast.Array):
442
+ if len(element_type_options) != 1:
443
+ message.warn(
444
+ '"element-type" annotation for an array must have exactly '
445
+ 'one option, not %d options' % (len(element_type_options), ),
446
+ annotations.position)
447
+ return
448
+ node.type.element_type = self._resolve(element_type_options[0],
449
+ node.type, node, parent)
450
+ else:
451
+ message.warn(
452
+ "Unknown container %r for element-type annotation" % (node.type, ),
453
+ annotations.position)
454
+
455
+ def _get_transfer_default_param(self, parent, node):
456
+ if node.direction in [ast.PARAM_DIRECTION_INOUT,
457
+ ast.PARAM_DIRECTION_OUT]:
458
+ if node.caller_allocates:
459
+ return ast.PARAM_TRANSFER_NONE
460
+ return ast.PARAM_TRANSFER_FULL
461
+ return ast.PARAM_TRANSFER_NONE
462
+
463
+ def _get_transfer_default_returntype_basic(self, typeval):
464
+ if (typeval.is_equiv(ast.BASIC_GIR_TYPES)
465
+ or typeval.is_const
466
+ or typeval.is_equiv(ast.TYPE_NONE)):
467
+ return ast.PARAM_TRANSFER_NONE
468
+ elif typeval.is_equiv(ast.TYPE_STRING):
469
+ # Non-const strings default to FULL
470
+ return ast.PARAM_TRANSFER_FULL
471
+ elif typeval.target_fundamental:
472
+ # This looks like just GType right now
473
+ return None
474
+ return None
475
+
476
+ def _is_gi_subclass(self, typeval, supercls_type):
477
+ cls = self._transformer.lookup_typenode(typeval)
478
+ assert cls, str(typeval)
479
+ supercls = self._transformer.lookup_typenode(supercls_type)
480
+ assert supercls
481
+ if cls is supercls:
482
+ return True
483
+ if cls.parent_type and cls.parent_type.target_giname != 'GObject.Object':
484
+ return self._is_gi_subclass(cls.parent_type, supercls_type)
485
+ return False
486
+
487
+ def _get_transfer_default_return(self, parent, node):
488
+ typeval = node.type
489
+ basic = self._get_transfer_default_returntype_basic(typeval)
490
+ if basic:
491
+ return basic
492
+ if not typeval.target_giname:
493
+ return None
494
+ target = self._transformer.lookup_typenode(typeval)
495
+ if isinstance(target, ast.Alias):
496
+ return self._get_transfer_default_returntype_basic(target.target)
497
+ elif (isinstance(target, ast.Boxed)
498
+ or (isinstance(target, (ast.Record, ast.Union))
499
+ and (target.gtype_name is not None or target.foreign))):
500
+ return ast.PARAM_TRANSFER_FULL
501
+ elif isinstance(target, (ast.Enum, ast.Bitfield)):
502
+ return ast.PARAM_TRANSFER_NONE
503
+ # Handle constructors specially here
504
+ elif isinstance(parent, ast.Function) and parent.is_constructor:
505
+ if isinstance(target, ast.Class):
506
+ initially_unowned_type = ast.Type(target_giname='GObject.InitiallyUnowned')
507
+ initially_unowned = self._transformer.lookup_typenode(initially_unowned_type)
508
+ if initially_unowned and self._is_gi_subclass(typeval, initially_unowned_type):
509
+ return ast.PARAM_TRANSFER_NONE
510
+ else:
511
+ return ast.PARAM_TRANSFER_FULL
512
+ elif isinstance(target, (ast.Record, ast.Union)):
513
+ return ast.PARAM_TRANSFER_FULL
514
+ else:
515
+ raise AssertionError("Invalid constructor")
516
+ elif isinstance(target, (ast.Class, ast.Record, ast.Union)):
517
+ # Explicitly no default for these
518
+ return None
519
+ else:
520
+ return None
521
+
522
+ def _get_transfer_default(self, parent, node):
523
+ if node.type.is_equiv(ast.TYPE_NONE) or isinstance(node.type, ast.Varargs):
524
+ return ast.PARAM_TRANSFER_NONE
525
+ elif isinstance(node, ast.Parameter):
526
+ return self._get_transfer_default_param(parent, node)
527
+ elif isinstance(node, ast.Return):
528
+ return self._get_transfer_default_return(parent, node)
529
+ elif isinstance(node, ast.Field):
530
+ return ast.PARAM_TRANSFER_NONE
531
+ elif isinstance(node, ast.Property):
532
+ return ast.PARAM_TRANSFER_NONE
533
+ else:
534
+ raise AssertionError(node)
535
+
536
+ def _apply_annotations_param_ret_common(self, parent, node, tag):
537
+ annotations = tag.annotations if tag else {}
538
+
539
+ type_annotation = annotations.get(ANN_TYPE)
540
+ if type_annotation:
541
+ node.type = self._resolve_toplevel(type_annotation[0],
542
+ node.type, node, parent)
543
+
544
+ caller_allocates = False
545
+ annotated_direction = None
546
+ if ANN_INOUT in annotations:
547
+ annotated_direction = ast.PARAM_DIRECTION_INOUT
548
+ elif ANN_OUT in annotations:
549
+ annotated_direction = ast.PARAM_DIRECTION_OUT
550
+
551
+ options = annotations[ANN_OUT]
552
+ if len(options) == 0:
553
+ if node.type.target_giname and node.type.ctype:
554
+ target = self._transformer.lookup_giname(node.type.target_giname)
555
+ target = self._transformer.resolve_aliases(target)
556
+ has_double_indirection = '**' in node.type.ctype
557
+ is_structure_or_union = isinstance(target, (ast.Record, ast.Union))
558
+ caller_allocates = (not has_double_indirection and is_structure_or_union)
559
+ else:
560
+ caller_allocates = False
561
+ else:
562
+ option = options[0]
563
+ if option == OPT_OUT_CALLER_ALLOCATES:
564
+ caller_allocates = True
565
+ elif option == OPT_OUT_CALLEE_ALLOCATES:
566
+ caller_allocates = False
567
+ elif ANN_IN in annotations:
568
+ annotated_direction = ast.PARAM_DIRECTION_IN
569
+
570
+ if (annotated_direction is not None) and (annotated_direction != node.direction):
571
+ node.direction = annotated_direction
572
+ node.caller_allocates = caller_allocates
573
+ # Also reset the transfer default if we're toggling direction
574
+ node.transfer = self._get_transfer_default(parent, node)
575
+
576
+ transfer_annotation = annotations.get(ANN_TRANSFER)
577
+ if transfer_annotation and len(transfer_annotation) == 1:
578
+ transfer = transfer_annotation[0]
579
+ if transfer == OPT_TRANSFER_FLOATING:
580
+ transfer = OPT_TRANSFER_NONE
581
+ node.transfer = transfer
582
+
583
+ self._adjust_container_type(parent, node, annotations)
584
+
585
+ if ANN_NULLABLE in annotations:
586
+ node.nullable = True
587
+
588
+ if ANN_OPTIONAL in annotations:
589
+ node.optional = True
590
+
591
+ if ANN_ALLOW_NONE in annotations:
592
+ if node.direction == ast.PARAM_DIRECTION_OUT:
593
+ node.optional = True
594
+ else:
595
+ node.nullable = True
596
+
597
+ if (node.direction != ast.PARAM_DIRECTION_OUT and
598
+ (node.type.target_giname == 'Gio.AsyncReadyCallback' or
599
+ node.type.target_giname == 'Gio.Cancellable')):
600
+ node.nullable = True
601
+
602
+ if tag and tag.description:
603
+ node.doc = tag.description
604
+
605
+ if ANN_SKIP in annotations:
606
+ node.skip = True
607
+
608
+ if annotations:
609
+ attributes_annotation = annotations.get(ANN_ATTRIBUTES)
610
+ if attributes_annotation is not None:
611
+ for key, value in attributes_annotation.items():
612
+ if value:
613
+ node.attributes[key] = value
614
+
615
+ def _apply_annotations_annotated(self, node, block):
616
+ if block is None:
617
+ return
618
+
619
+ if block.description:
620
+ node.doc = block.description
621
+
622
+ since_tag = block.tags.get(TAG_SINCE)
623
+ if since_tag is not None:
624
+ if since_tag.value:
625
+ node.version = since_tag.value
626
+ if since_tag.description:
627
+ node.version_doc = since_tag.description
628
+
629
+ deprecated_tag = block.tags.get(TAG_DEPRECATED)
630
+ if deprecated_tag is not None:
631
+ if deprecated_tag.value:
632
+ node.deprecated = deprecated_tag.value
633
+ if deprecated_tag.description:
634
+ node.deprecated_doc = deprecated_tag.description
635
+
636
+ stability_tag = block.tags.get(TAG_STABILITY)
637
+ if stability_tag is not None:
638
+ if stability_tag.value:
639
+ node.stability = stability_tag.value
640
+ if stability_tag.description:
641
+ node.stability_doc = stability_tag.description
642
+
643
+ attributes_annotation = block.annotations.get(ANN_ATTRIBUTES)
644
+ if attributes_annotation is not None:
645
+ for key, value in attributes_annotation.items():
646
+ if value:
647
+ node.attributes[key] = value
648
+
649
+ if ANN_SKIP in block.annotations:
650
+ node.skip = True
651
+
652
+ if ANN_FOREIGN in block.annotations:
653
+ node.foreign = True
654
+
655
+ if ANN_CONSTRUCTOR in block.annotations and isinstance(node, ast.Function):
656
+ node.is_constructor = True
657
+
658
+ if ANN_METHOD in block.annotations:
659
+ node.is_method = True
660
+
661
+ def _apply_annotations_alias(self, node, chain):
662
+ block = self._get_block(node)
663
+ self._apply_annotations_annotated(node, block)
664
+
665
+ def _apply_annotations_param(self, parent, param, tag):
666
+ annotations = tag.annotations if tag else {}
667
+
668
+ if isinstance(parent, (ast.Function, ast.VFunction)):
669
+ scope_annotation = annotations.get(ANN_SCOPE)
670
+ if scope_annotation and len(scope_annotation) == 1:
671
+ param.scope = scope_annotation[0]
672
+ param.transfer = ast.PARAM_TRANSFER_NONE
673
+
674
+ destroy_annotation = annotations.get(ANN_DESTROY)
675
+ if destroy_annotation:
676
+ param.destroy_name = self._get_validate_parameter_name(parent,
677
+ destroy_annotation[0],
678
+ param)
679
+ if param.destroy_name is not None:
680
+ param.scope = ast.PARAM_SCOPE_NOTIFIED
681
+ destroy_param = parent.get_parameter(param.destroy_name)
682
+ # This is technically bogus; we're setting the scope on the destroy
683
+ # itself. But this helps avoid tripping a warning from finaltransformer,
684
+ # since we don't have a way right now to flag this callback a destroy.
685
+ destroy_param.scope = ast.PARAM_SCOPE_NOTIFIED
686
+
687
+ closure_annotation = annotations.get(ANN_CLOSURE)
688
+ if closure_annotation and len(closure_annotation) == 1:
689
+ param.closure_name = self._get_validate_parameter_name(parent,
690
+ closure_annotation[0],
691
+ param)
692
+ elif isinstance(parent, ast.Callback):
693
+ if ANN_CLOSURE in annotations:
694
+ # For callbacks, (closure) appears without an
695
+ # argument, and tags a parameter that is a closure. We
696
+ # represent it (weirdly) in the gir and typelib by
697
+ # setting param.closure_name to itself.
698
+ param.closure_name = param.argname
699
+
700
+ self._apply_annotations_param_ret_common(parent, param, tag)
701
+
702
+ def _apply_annotations_return(self, parent, return_, block):
703
+ if block:
704
+ tag = block.tags.get(TAG_RETURNS)
705
+ else:
706
+ tag = None
707
+ self._apply_annotations_param_ret_common(parent, return_, tag)
708
+
709
+ def _apply_annotations_params(self, parent, params, block):
710
+ declparams = set([])
711
+ if parent.instance_parameter:
712
+ if block:
713
+ doc_param = block.params.get(parent.instance_parameter.argname)
714
+ else:
715
+ doc_param = None
716
+ self._apply_annotations_param(parent, parent.instance_parameter, doc_param)
717
+ declparams.add(parent.instance_parameter.argname)
718
+
719
+ for param in params:
720
+ if block:
721
+ doc_param = block.params.get(param.argname)
722
+ else:
723
+ doc_param = None
724
+ self._apply_annotations_param(parent, param, doc_param)
725
+ declparams.add(param.argname)
726
+
727
+ if not block:
728
+ return
729
+ docparams = set(block.params)
730
+
731
+ unknown = docparams - declparams
732
+ unused = declparams - docparams
733
+
734
+ for doc_name in unknown:
735
+ if len(unused) == 0:
736
+ text = ''
737
+ elif len(unused) == 1:
738
+ (param, ) = unused
739
+ text = ', should be %r' % (param, )
740
+ else:
741
+ text = ', should be one of %s' % (', '.join(repr(p) for p in unused), )
742
+
743
+ param = block.params.get(doc_name)
744
+ message.warn('%s: unknown parameter %r in documentation '
745
+ 'comment%s' % (block.name, doc_name, text),
746
+ param.position)
747
+
748
+ def _apply_annotations_callable(self, node, chain, block):
749
+ self._apply_annotations_annotated(node, block)
750
+ self._apply_annotations_params(node, node.parameters, block)
751
+ self._apply_annotations_return(node, node.retval, block)
752
+
753
+ def _apply_annotations_field(self, parent, block, field):
754
+ if not block:
755
+ return
756
+ tag = block.params.get(field.name)
757
+ if not tag:
758
+ return
759
+ type_annotation = tag.annotations.get(ANN_TYPE)
760
+ if type_annotation:
761
+ field.type = self._transformer.create_type_from_user_string(type_annotation[0])
762
+ field.doc = tag.description
763
+ try:
764
+ self._adjust_container_type(parent, field, tag.annotations)
765
+ except AttributeError as ex:
766
+ print ex
767
+
768
+ def _apply_annotations_property(self, parent, prop):
769
+ prefix = self._get_annotation_name(parent)
770
+ block = self._blocks.get('%s:%s' % (prefix, prop.name))
771
+ self._apply_annotations_annotated(prop, block)
772
+ if not block:
773
+ return
774
+ transfer_annotation = block.annotations.get(ANN_TRANSFER)
775
+ if transfer_annotation is not None:
776
+ transfer = transfer_annotation[0]
777
+ if transfer == OPT_TRANSFER_FLOATING:
778
+ transfer = OPT_TRANSFER_NONE
779
+ prop.transfer = transfer
780
+ else:
781
+ prop.transfer = self._get_transfer_default(parent, prop)
782
+ type_annotation = block.annotations.get(ANN_TYPE)
783
+ if type_annotation:
784
+ prop.type = self._resolve_toplevel(type_annotation[0], prop.type, prop, parent)
785
+
786
+ def _apply_annotations_signal(self, parent, signal):
787
+ names = []
788
+ prefix = self._get_annotation_name(parent)
789
+ block = self._blocks.get('%s::%s' % (prefix, signal.name))
790
+
791
+ if block:
792
+ self._apply_annotations_annotated(signal, block)
793
+
794
+ # We're only attempting to name the signal parameters if
795
+ # the number of parameters (@foo) is the same or greater
796
+ # than the number of signal parameters
797
+ if len(block.params) > len(signal.parameters):
798
+ names = block.params.items()
799
+ # Resolve real parameter names early, so that in later
800
+ # phase we can refer to them while resolving annotations.
801
+ for i, param in enumerate(signal.parameters):
802
+ param.argname, tag = names[i + 1]
803
+ elif len(signal.parameters) != 0:
804
+ # Only warn about missing params if there are actually parameters
805
+ # besides implicit self.
806
+ message.warn("incorrect number of parameters in comment block, "
807
+ "parameter annotations will be ignored.", block.position)
808
+
809
+ for i, param in enumerate(signal.parameters):
810
+ if names:
811
+ name, tag = names[i + 1]
812
+ if tag:
813
+ type_annotation = tag.annotations.get(ANN_TYPE)
814
+ if type_annotation:
815
+ param.type = self._resolve_toplevel(type_annotation[0], param.type,
816
+ param, parent)
817
+ else:
818
+ tag = None
819
+ self._apply_annotations_param(signal, param, tag)
820
+ self._apply_annotations_return(signal, signal.retval, block)
821
+
822
+ def _apply_annotations_constant(self, node):
823
+ block = self._get_block(node)
824
+ if block is None:
825
+ return
826
+
827
+ self._apply_annotations_annotated(node, block)
828
+
829
+ value_annotation = block.annotations.get(ANN_VALUE)
830
+ if value_annotation:
831
+ node.value = value_annotation[0]
832
+
833
+ def _apply_annotations_enum_members(self, node, block):
834
+ if block is None:
835
+ return
836
+
837
+ for m in node.members:
838
+ param = block.params.get(m.symbol, None)
839
+ if param and param.description:
840
+ m.doc = param.description
841
+
842
+ def _pass_read_annotations2(self, node, chain):
843
+ if isinstance(node, ast.Function):
844
+ block = self._blocks.get(node.symbol)
845
+
846
+ self._apply_annotation_rename_to(node, chain, block)
847
+
848
+ # Handle virtual invokers
849
+ parent = chain[-1] if chain else None
850
+ if (block and parent):
851
+ virtual_annotation = block.annotations.get(ANN_VFUNC)
852
+ if virtual_annotation:
853
+ invoker_name = virtual_annotation[0]
854
+ matched = False
855
+ for vfunc in parent.virtual_methods:
856
+ if vfunc.name == invoker_name:
857
+ matched = True
858
+ vfunc.invoker = node.name
859
+ # Also merge in annotations
860
+ self._apply_annotations_callable(vfunc, [parent], block)
861
+ break
862
+ if not matched:
863
+ message.warn_node(node,
864
+ "Virtual slot %r not found for %r annotation" % (invoker_name,
865
+ ANN_VFUNC))
866
+ return True
867
+
868
+ def _resolve_and_filter_type_list(self, typelist):
869
+ """Given a list of Type instances, return a new list of types with
870
+ the ones that failed to resolve removed."""
871
+ # Create a copy we'll modify
872
+ new_typelist = list(typelist)
873
+ for typeval in typelist:
874
+ resolved = self._transformer.resolve_type(typeval)
875
+ if not resolved:
876
+ new_typelist.remove(typeval)
877
+ return new_typelist
878
+
879
+ def _pass_type_resolution(self, node, chain):
880
+ if isinstance(node, ast.Alias):
881
+ self._transformer.resolve_type(node.target)
882
+ if isinstance(node, ast.Callable):
883
+ for parameter in node.parameters:
884
+ self._transformer.resolve_type(parameter.type)
885
+ self._transformer.resolve_type(node.retval.type)
886
+ if isinstance(node, ast.Constant):
887
+ self._transformer.resolve_type(node.value_type)
888
+ if isinstance(node, (ast.Class, ast.Interface, ast.Record, ast.Union)):
889
+ for field in node.fields:
890
+ if field.anonymous_node:
891
+ pass
892
+ else:
893
+ self._transformer.resolve_type(field.type)
894
+ if isinstance(node, (ast.Class, ast.Interface)):
895
+ for parent in node.parent_chain:
896
+ try:
897
+ self._transformer.resolve_type(parent)
898
+ except ValueError:
899
+ continue
900
+ target = self._transformer.lookup_typenode(parent)
901
+ if target:
902
+ node.parent_type = parent
903
+ break
904
+ else:
905
+ if isinstance(node, ast.Interface):
906
+ node.parent_type = ast.Type(target_giname='GObject.Object')
907
+ for prop in node.properties:
908
+ self._transformer.resolve_type(prop.type)
909
+ for sig in node.signals:
910
+ for param in sig.parameters:
911
+ self._transformer.resolve_type(param.type)
912
+ if isinstance(node, ast.Class):
913
+ node.interfaces = self._resolve_and_filter_type_list(node.interfaces)
914
+ if isinstance(node, ast.Interface):
915
+ node.prerequisites = self._resolve_and_filter_type_list(node.prerequisites)
916
+ return True
917
+
918
+ def _pair_quarks_with_enums(self):
919
+ # self._uscore_type_names is an authoritative mapping of types
920
+ # to underscored versions, since it is based on get_type() methods;
921
+ # but only covers enums that are registered as GObject enums.
922
+ # Create a fallback mapping based on all known enums in this module.
923
+ uscore_enums = {}
924
+ for enum in self._namespace.itervalues():
925
+ if not isinstance(enum, ast.Enum):
926
+ continue
927
+ uscored = to_underscores_noprefix(enum.name).lower()
928
+ uscore_enums[uscored] = enum
929
+ uscore_enums[enum.name] = enum
930
+
931
+ for node in self._namespace.itervalues():
932
+ if not isinstance(node, ast.ErrorQuarkFunction):
933
+ continue
934
+ full = node.symbol[:-len('_quark')]
935
+ ns, short = self._transformer.split_csymbol(node.symbol)
936
+ short = short[:-len('_quark')]
937
+ if full == "g_io_error":
938
+ # Special case; GIOError was already taken forcing GIOErrorEnum
939
+ assert self._namespace.name == 'Gio'
940
+ enum = self._namespace.get('IOErrorEnum')
941
+ else:
942
+ enum = self._uscore_type_names.get(short)
943
+ if enum is None:
944
+ enum = uscore_enums.get(short)
945
+ if enum is not None:
946
+ enum.error_domain = node.error_domain
947
+ else:
948
+ message.warn_node(node,
949
+ """%s: Couldn't find corresponding enumeration""" % (node.symbol, ))
950
+
951
+ def _split_uscored_by_type(self, uscored):
952
+ """'uscored' should be an un-prefixed uscore string. This
953
+ function searches through the namespace for the longest type which
954
+ prefixes uscored, and returns (type, suffix). Example, assuming
955
+ namespace Gtk, type is TextBuffer:
956
+
957
+ _split_uscored_by_type(text_buffer_try_new) -> (ast.Class(TextBuffer), 'try_new')"""
958
+ node = None
959
+ count = 0
960
+ prev_split_count = -1
961
+ while True:
962
+ components = uscored.rsplit('_', count)
963
+ if len(components) == prev_split_count:
964
+ return None
965
+ prev_split_count = len(components)
966
+ type_string = components[0]
967
+ node = self._uscore_type_names.get(type_string)
968
+ if node:
969
+ return (node, '_'.join(components[1:]))
970
+ count += 1
971
+
972
+ def _pair_function(self, func):
973
+ """Check to see whether a toplevel function should be a
974
+ method or constructor of some type."""
975
+
976
+ # Ignore internal symbols and type metadata functions
977
+ if func.symbol.startswith('_') or func.is_type_meta_function():
978
+ return
979
+
980
+ (ns, subsymbol) = self._transformer.split_csymbol(func.symbol)
981
+ assert ns == self._namespace
982
+ if self._is_constructor(func, subsymbol):
983
+ self._set_up_constructor(func, subsymbol)
984
+ return
985
+ elif self._is_method(func, subsymbol):
986
+ self._setup_method(func, subsymbol)
987
+ return
988
+ elif self._pair_static_method(func, subsymbol):
989
+ return
990
+
991
+ def _uscored_identifier_for_type(self, typeval):
992
+ """Given a Type(target_giname='Foo.BarBaz'), return 'bar_baz'."""
993
+ name = typeval.get_giname()
994
+ return to_underscores_noprefix(name).lower()
995
+
996
+ def _is_method(self, func, subsymbol):
997
+ if not func.parameters:
998
+ if func.is_method:
999
+ message.warn_node(func,
1000
+ '%s: Methods must have parameters' % (func.symbol, ))
1001
+ return False
1002
+ first = func.parameters[0]
1003
+ target = self._transformer.lookup_typenode(first.type)
1004
+ if not isinstance(target, (ast.Class, ast.Interface,
1005
+ ast.Record, ast.Union,
1006
+ ast.Boxed)):
1007
+ if func.is_method:
1008
+ message.warn_node(func,
1009
+ '%s: Methods must have a pointer as their first '
1010
+ 'parameter' % (func.symbol, ))
1011
+ return False
1012
+ if target.namespace != self._namespace:
1013
+ if func.is_method:
1014
+ message.warn_node(func,
1015
+ '%s: Methods must belong to the same namespace as the '
1016
+ 'class they belong to' % (func.symbol, ))
1017
+ return False
1018
+ if first.direction == ast.PARAM_DIRECTION_OUT:
1019
+ if func.is_method:
1020
+ message.warn_node(func,
1021
+ '%s: The first argument of methods cannot be an '
1022
+ 'out-argument' % (func.symbol, ))
1023
+ return False
1024
+
1025
+ # A quick hack here...in the future we should catch C signature/GI signature
1026
+ # mismatches in a general way in finaltransformer
1027
+ if first.type.ctype is not None and first.type.ctype.count('*') > 1:
1028
+ return False
1029
+
1030
+ if not func.is_method:
1031
+ uscored_prefix = self._get_uscored_prefix(func, subsymbol)
1032
+ if not subsymbol.startswith(uscored_prefix):
1033
+ return False
1034
+
1035
+ return True
1036
+
1037
+ def _setup_method(self, func, subsymbol):
1038
+ uscored_prefix = self._get_uscored_prefix(func, subsymbol)
1039
+ target = self._transformer.lookup_typenode(func.parameters[0].type)
1040
+
1041
+ if not func.is_method and not subsymbol.startswith(uscored_prefix + '_'):
1042
+ # Uh oh! This function starts with uscored_prefix, but not
1043
+ # uscored_prefix + '_', so if we split, we're splitting on something
1044
+ # which is not _
1045
+ # Examples of this are g_resources_register() (splits as
1046
+ # g_resource + _register) and gdk_events_get_angle() (splits as
1047
+ # gdk_event + _get_angle).
1048
+ # As the C name suggests, these are not methods, but for backward
1049
+ # compatibility reasons we need to create a method with the old
1050
+ # name, and a moved-to annotation pointing to the new variant.
1051
+
1052
+ newfunc = func.clone()
1053
+ newfunc.moved_to = func.name
1054
+ newfunc.instance_parameter = newfunc.parameters.pop(0)
1055
+ subsym_idx = func.symbol.find(subsymbol)
1056
+ newfunc.name = func.symbol[(subsym_idx + len(uscored_prefix) + 1):]
1057
+ newfunc.is_method = True
1058
+
1059
+ target.methods.append(newfunc)
1060
+ else:
1061
+ func.instance_parameter = func.parameters.pop(0)
1062
+ self._namespace.float(func)
1063
+
1064
+ if not func.is_method:
1065
+ subsym_idx = func.symbol.find(subsymbol)
1066
+ func.name = func.symbol[(subsym_idx + len(uscored_prefix) + 1):]
1067
+ func.is_method = True
1068
+
1069
+ target.methods.append(func)
1070
+
1071
+ def _get_uscored_prefix(self, func, subsymbol):
1072
+ # Here we check both the c_symbol_prefix and (if that fails),
1073
+ # attempt to do a default uscoring of the type. The reason we
1074
+ # look at a default underscore transformation is for
1075
+ # gdk_window_object_get_type(), which says to us that the
1076
+ # prefix is "gdk_window_object", when really it's just
1077
+ # "gdk_window". Possibly need an annotation to override this.
1078
+ prefix_matches = False
1079
+ uscored_prefix = None
1080
+ first_arg = func.parameters[0]
1081
+ target = self._transformer.lookup_typenode(first_arg.type)
1082
+ if hasattr(target, 'c_symbol_prefix') and target.c_symbol_prefix is not None:
1083
+ prefix_matches = subsymbol.startswith(target.c_symbol_prefix)
1084
+ if prefix_matches:
1085
+ uscored_prefix = target.c_symbol_prefix
1086
+ if not prefix_matches:
1087
+ uscored_prefix = self._uscored_identifier_for_type(first_arg.type)
1088
+
1089
+ return uscored_prefix
1090
+
1091
+ def _pair_static_method(self, func, subsymbol):
1092
+ split = self._split_uscored_by_type(subsymbol)
1093
+ if split is None:
1094
+ return False
1095
+ (node, funcname) = split
1096
+ if funcname == '':
1097
+ return False
1098
+
1099
+ if isinstance(node, ast.Class):
1100
+ self._namespace.float(func)
1101
+ func.name = funcname
1102
+ node.static_methods.append(func)
1103
+ return True
1104
+ elif isinstance(node, (ast.Interface, ast.Record, ast.Union,
1105
+ ast.Boxed, ast.Enum, ast.Bitfield)):
1106
+ # prior to the introduction of this part of the code, only
1107
+ # ast.Class could have static methods. so for backwards
1108
+ # compatibility, instead of removing the func from the namespace,
1109
+ # leave it there and get a copy instead. modify the copy and push
1110
+ # it onto static_methods. we need to copy the parameters list
1111
+ # separately, because in the third pass functions are flagged as
1112
+ # 'throws' depending on the presence of a GError parameter which is
1113
+ # then removed from the parameters list. without the explicit
1114
+ # copy, only one of the two functions would thus get flagged as
1115
+ # 'throws'. clone() does this for us.
1116
+ new_func = func.clone()
1117
+ new_func.name = funcname
1118
+ node.static_methods.append(new_func)
1119
+ # flag the func as a backwards-comptability kludge (thus it will
1120
+ # get pruned in the introspectable pass if introspectable=0).
1121
+ func.moved_to = node.name + '.' + new_func.name
1122
+ return True
1123
+
1124
+ return False
1125
+
1126
+ def _set_up_constructor(self, func, subsymbol):
1127
+ self._namespace.float(func)
1128
+
1129
+ func.name = self._get_constructor_name(func, subsymbol)
1130
+
1131
+ origin_node = self._get_constructor_class(func, subsymbol)
1132
+ origin_node.constructors.append(func)
1133
+
1134
+ func.is_constructor = True
1135
+
1136
+ # Constructors have default return semantics
1137
+ if not func.retval.transfer:
1138
+ func.retval.transfer = self._get_transfer_default_return(func,
1139
+ func.retval)
1140
+
1141
+ def _get_constructor_class(self, func, subsymbol):
1142
+ origin_node = None
1143
+ split = self._split_uscored_by_type(subsymbol)
1144
+ if split is None:
1145
+ if func.is_constructor:
1146
+ origin_node = self._transformer.lookup_typenode(func.retval.type)
1147
+ else:
1148
+ origin_node, _ = split
1149
+
1150
+ return origin_node
1151
+
1152
+ def _get_constructor_name(self, func, subsymbol):
1153
+ name = None
1154
+ split = self._split_uscored_by_type(subsymbol)
1155
+ if split is None:
1156
+ if func.is_constructor:
1157
+ name = func.name
1158
+ else:
1159
+ _, name = split
1160
+
1161
+ return name
1162
+
1163
+ def _guess_constructor_by_name(self, symbol):
1164
+ # Normal constructors, gtk_button_new etc
1165
+ if symbol.endswith('_new'):
1166
+ return True
1167
+ # Alternative constructor, gtk_button_new_with_label
1168
+ if '_new_' in symbol:
1169
+ return True
1170
+ # gtk_list_store_newv,gtk_tree_store_newv etc
1171
+ if symbol.endswith('_newv'):
1172
+ return True
1173
+ return False
1174
+
1175
+ def _is_constructor(self, func, subsymbol):
1176
+ # func.is_constructor will be True if we have a (constructor) annotation
1177
+ if not func.is_constructor:
1178
+ if not self._guess_constructor_by_name(func.symbol):
1179
+ return False
1180
+ target = self._transformer.lookup_typenode(func.retval.type)
1181
+ if not (isinstance(target, ast.Class)
1182
+ or (isinstance(target, (ast.Record, ast.Union, ast.Boxed))
1183
+ and (target.get_type is not None or target.foreign))):
1184
+ if func.is_constructor:
1185
+ message.warn_node(func,
1186
+ '%s: Constructors must return an instance of their class'
1187
+ % (func.symbol, ))
1188
+ return False
1189
+
1190
+ origin_node = self._get_constructor_class(func, subsymbol)
1191
+ if origin_node is None:
1192
+ if func.is_constructor:
1193
+ message.warn_node(
1194
+ func,
1195
+ "Can't find matching type for constructor; symbol=%r" % (func.symbol, ))
1196
+ return False
1197
+
1198
+ # Some sanity checks; only objects and boxeds can have ctors
1199
+ if not (isinstance(origin_node, ast.Class)
1200
+ or (isinstance(origin_node, (ast.Record, ast.Union, ast.Boxed))
1201
+ and (origin_node.get_type is not None or origin_node.foreign))):
1202
+ return False
1203
+ # Verify the namespace - don't want to append to foreign namespaces!
1204
+ if origin_node.namespace != self._namespace:
1205
+ if func.is_constructor:
1206
+ message.warn_node(func,
1207
+ '%s: Constructors must belong to the same namespace as the '
1208
+ 'class they belong to' % (func.symbol, ))
1209
+ return False
1210
+ # If it takes the object as a first arg, guess it's not a constructor
1211
+ if not func.is_constructor and len(func.parameters) > 0:
1212
+ first_arg = self._transformer.lookup_typenode(func.parameters[0].type)
1213
+ if (first_arg is not None) and first_arg.gi_name == origin_node.gi_name:
1214
+ return False
1215
+
1216
+ if isinstance(target, ast.Class):
1217
+ parent = origin_node
1218
+ while parent and (not parent.gi_name == 'GObject.Object'):
1219
+ if parent == target:
1220
+ break
1221
+ if parent.parent_type:
1222
+ parent = self._transformer.lookup_typenode(parent.parent_type)
1223
+ else:
1224
+ parent = None
1225
+ if parent is None:
1226
+ message.warn_node(func,
1227
+ "Return value is not superclass for constructor; "
1228
+ "symbol=%r constructed=%r return=%r" %
1229
+ (func.symbol,
1230
+ str(origin_node.create_type()),
1231
+ str(func.retval.type)))
1232
+ return False
1233
+ else:
1234
+ if origin_node != target:
1235
+ message.warn_node(func,
1236
+ "Constructor return type mismatch symbol=%r "
1237
+ "constructed=%r return=%r" %
1238
+ (func.symbol,
1239
+ str(origin_node.create_type()),
1240
+ str(func.retval.type)))
1241
+ return False
1242
+
1243
+ return True
1244
+
1245
+ def _pair_class_virtuals(self, node):
1246
+ """Look for virtual methods from the class structure."""
1247
+ if not node.glib_type_struct:
1248
+ # https://bugzilla.gnome.org/show_bug.cgi?id=629080
1249
+ #message.warn_node(node,
1250
+ # "Failed to find class structure for %r" % (node.name, ))
1251
+ return
1252
+
1253
+ node_type = node.create_type()
1254
+ class_struct = self._transformer.lookup_typenode(node.glib_type_struct)
1255
+
1256
+ # Object class fields are assumed to be read-only
1257
+ # (see also _introspect_object and transformer.py)
1258
+ for field in class_struct.fields:
1259
+ if isinstance(field, ast.Field):
1260
+ field.writable = False
1261
+
1262
+ for field in class_struct.fields:
1263
+ callback = None
1264
+
1265
+ if isinstance(field.anonymous_node, ast.Callback):
1266
+ callback = field.anonymous_node
1267
+ elif field.type is not None:
1268
+ callback = self._transformer.lookup_typenode(field.type)
1269
+ if not isinstance(callback, ast.Callback):
1270
+ continue
1271
+ else:
1272
+ continue
1273
+
1274
+ # Check the first parameter is the object
1275
+ if len(callback.parameters) == 0:
1276
+ continue
1277
+ firstparam_type = callback.parameters[0].type
1278
+ if firstparam_type != node_type:
1279
+ continue
1280
+ vfunc = ast.VFunction.from_callback(field.name, callback)
1281
+ vfunc.instance_parameter = callback.parameters[0]
1282
+ vfunc.inherit_file_positions(callback)
1283
+
1284
+ prefix = self._get_annotation_name(class_struct)
1285
+ block = self._blocks.get('%s::%s' % (prefix, vfunc.name))
1286
+ self._apply_annotations_callable(vfunc, [node], block)
1287
+ node.virtual_methods.append(vfunc)
1288
+
1289
+ # Take the set of virtual methods we found, and try
1290
+ # to pair up with any matching methods using the
1291
+ # name+signature.
1292
+ for vfunc in node.virtual_methods:
1293
+ for method in node.methods:
1294
+ if method.name != vfunc.name:
1295
+ continue
1296
+ if method.retval.type != vfunc.retval.type:
1297
+ continue
1298
+ if len(method.parameters) != len(vfunc.parameters):
1299
+ continue
1300
+ for i in range(len(method.parameters)):
1301
+ m_type = method.parameters[i].type
1302
+ v_type = vfunc.parameters[i].type
1303
+ if m_type != v_type:
1304
+ continue
1305
+ vfunc.invoker = method.name
1306
+ # Apply any annotations we have from the invoker to
1307
+ # the vfunc
1308
+ block = self._blocks.get(method.symbol)
1309
+ self._apply_annotations_callable(vfunc, [], block)
1310
+ break
1311
+
1312
+ def _pass3(self, node, chain):
1313
+ """Pass 3 is after we've loaded GType data and performed type
1314
+ closure."""
1315
+ if isinstance(node, ast.Callable):
1316
+ self._pass3_callable_callbacks(node)
1317
+ self._pass3_callable_throws(node)
1318
+ return True
1319
+
1320
+ def _pass3_callable_callbacks(self, node):
1321
+ """Check to see if we have anything that looks like a
1322
+ callback+user_data+GDestroyNotify set."""
1323
+
1324
+ params = node.parameters
1325
+
1326
+ # First, do defaults for well-known callback types
1327
+ for param in params:
1328
+ argnode = self._transformer.lookup_typenode(param.type)
1329
+ if isinstance(argnode, ast.Callback):
1330
+ if param.type.target_giname in ('Gio.AsyncReadyCallback',
1331
+ 'GLib.DestroyNotify'):
1332
+ param.scope = ast.PARAM_SCOPE_ASYNC
1333
+ param.transfer = ast.PARAM_TRANSFER_NONE
1334
+
1335
+ callback_param = None
1336
+ for param in params:
1337
+ argnode = self._transformer.lookup_typenode(param.type)
1338
+ is_destroynotify = False
1339
+ if isinstance(argnode, ast.Callback):
1340
+ if param.type.target_giname == 'GLib.DestroyNotify':
1341
+ is_destroynotify = True
1342
+ else:
1343
+ callback_param = param
1344
+ continue
1345
+ if callback_param is None:
1346
+ continue
1347
+ if is_destroynotify:
1348
+ callback_param.destroy_name = param.argname
1349
+ callback_param.scope = ast.PARAM_SCOPE_NOTIFIED
1350
+ callback_param.transfer = ast.PARAM_TRANSFER_NONE
1351
+ elif (param.type.is_equiv(ast.TYPE_ANY) and
1352
+ param.argname is not None and
1353
+ param.argname.endswith('data')):
1354
+ callback_param.closure_name = param.argname
1355
+
1356
+ def _pass3_callable_throws(self, node):
1357
+ """Check to see if we have anything that looks like a
1358
+ callback+user_data+GDestroyNotify set."""
1359
+ if not node.parameters:
1360
+ return
1361
+ last_param = node.parameters[-1]
1362
+ # Checking type.name=='GLib.Error' generates false positives
1363
+ # on methods that take a 'GError *'
1364
+ if last_param.type.ctype == 'GError**':
1365
+ node.parameters.pop()
1366
+ node.throws = True