gobject-introspection 2.0.0-x86-mingw32

Sign up to get free protection for your applications and to get access to all the features.
Files changed (268) hide show
  1. data/Rakefile +118 -0
  2. data/ext/gobject-introspection/depend +10 -0
  3. data/ext/gobject-introspection/extconf.rb +97 -0
  4. data/ext/gobject-introspection/gobject_introspection.def +5 -0
  5. data/ext/gobject-introspection/rb-gi-arg-info.c +151 -0
  6. data/ext/gobject-introspection/rb-gi-argument.c +1015 -0
  7. data/ext/gobject-introspection/rb-gi-base-info.c +218 -0
  8. data/ext/gobject-introspection/rb-gi-boxed-info.c +48 -0
  9. data/ext/gobject-introspection/rb-gi-callable-info.c +104 -0
  10. data/ext/gobject-introspection/rb-gi-callback-info.c +48 -0
  11. data/ext/gobject-introspection/rb-gi-constant-info.c +77 -0
  12. data/ext/gobject-introspection/rb-gi-constructor-info.c +120 -0
  13. data/ext/gobject-introspection/rb-gi-conversions.h +116 -0
  14. data/ext/gobject-introspection/rb-gi-enum-info.c +145 -0
  15. data/ext/gobject-introspection/rb-gi-field-info.c +153 -0
  16. data/ext/gobject-introspection/rb-gi-flags-info.c +48 -0
  17. data/ext/gobject-introspection/rb-gi-function-info.c +658 -0
  18. data/ext/gobject-introspection/rb-gi-interface-info.c +222 -0
  19. data/ext/gobject-introspection/rb-gi-loader.c +162 -0
  20. data/ext/gobject-introspection/rb-gi-method-info.c +109 -0
  21. data/ext/gobject-introspection/rb-gi-object-info.c +345 -0
  22. data/ext/gobject-introspection/rb-gi-private.h +110 -0
  23. data/ext/gobject-introspection/rb-gi-property-info.c +77 -0
  24. data/ext/gobject-introspection/rb-gi-registered-type-info.c +86 -0
  25. data/ext/gobject-introspection/rb-gi-repository.c +164 -0
  26. data/ext/gobject-introspection/rb-gi-signal-info.c +77 -0
  27. data/ext/gobject-introspection/rb-gi-struct-info.c +190 -0
  28. data/ext/gobject-introspection/rb-gi-type-info.c +143 -0
  29. data/ext/gobject-introspection/rb-gi-type-tag.c +43 -0
  30. data/ext/gobject-introspection/rb-gi-types.h +71 -0
  31. data/ext/gobject-introspection/rb-gi-union-info.c +206 -0
  32. data/ext/gobject-introspection/rb-gi-unresolved-info.c +48 -0
  33. data/ext/gobject-introspection/rb-gi-value-info.c +57 -0
  34. data/ext/gobject-introspection/rb-gi-vfunc-info.c +91 -0
  35. data/ext/gobject-introspection/rb-gobject-introspection.c +44 -0
  36. data/ext/gobject-introspection/rb-gobject-introspection.h +57 -0
  37. data/extconf.rb +71 -0
  38. data/lib/1.9/gobject_introspection.so +0 -0
  39. data/lib/2.0/gobject_introspection.so +0 -0
  40. data/lib/gobject-introspection.rb +52 -0
  41. data/lib/gobject-introspection/callable-info.rb +91 -0
  42. data/lib/gobject-introspection/collection-reader.rb +34 -0
  43. data/lib/gobject-introspection/interface-info.rb +32 -0
  44. data/lib/gobject-introspection/loader.rb +328 -0
  45. data/lib/gobject-introspection/object-info.rb +33 -0
  46. data/lib/gobject-introspection/repository.rb +32 -0
  47. data/lib/gobject-introspection/struct-info.rb +28 -0
  48. data/lib/gobject-introspection/union-info.rb +28 -0
  49. data/test/gobject-introspection-test-utils.rb +26 -0
  50. data/test/run-test.rb +45 -0
  51. data/test/test-arg-info.rb +68 -0
  52. data/test/test-base-info.rb +31 -0
  53. data/test/test-boxed-info.rb +21 -0
  54. data/test/test-callable-info.rb +49 -0
  55. data/test/test-callback-info.rb +29 -0
  56. data/test/test-constant-info.rb +24 -0
  57. data/test/test-enum-info.rb +56 -0
  58. data/test/test-field-type.rb +42 -0
  59. data/test/test-flags-info.rb +27 -0
  60. data/test/test-function-info.rb +37 -0
  61. data/test/test-interface-info.rb +97 -0
  62. data/test/test-loader.rb +30 -0
  63. data/test/test-object-info.rb +131 -0
  64. data/test/test-property-info.rb +38 -0
  65. data/test/test-registered-type-info.rb +35 -0
  66. data/test/test-repository.rb +59 -0
  67. data/test/test-signal-info.rb +37 -0
  68. data/test/test-struct-info.rb +57 -0
  69. data/test/test-type-info.rb +62 -0
  70. data/test/test-type-tag.rb +29 -0
  71. data/test/test-union-info.rb +21 -0
  72. data/test/test-value-info.rb +28 -0
  73. data/test/test-vfunc-info.rb +42 -0
  74. data/vendor/local/bin/g-ir-compiler.exe +0 -0
  75. data/vendor/local/bin/g-ir-generate.exe +0 -0
  76. data/vendor/local/bin/libgirepository-1.0-1.dll +0 -0
  77. data/vendor/local/include/gobject-introspection-1.0/giarginfo.h +52 -0
  78. data/vendor/local/include/gobject-introspection-1.0/gibaseinfo.h +89 -0
  79. data/vendor/local/include/gobject-introspection-1.0/gicallableinfo.h +74 -0
  80. data/vendor/local/include/gobject-introspection-1.0/giconstantinfo.h +46 -0
  81. data/vendor/local/include/gobject-introspection-1.0/gienuminfo.h +56 -0
  82. data/vendor/local/include/gobject-introspection-1.0/gifieldinfo.h +52 -0
  83. data/vendor/local/include/gobject-introspection-1.0/gifunctioninfo.h +77 -0
  84. data/vendor/local/include/gobject-introspection-1.0/giinterfaceinfo.h +68 -0
  85. data/vendor/local/include/gobject-introspection-1.0/giobjectinfo.h +137 -0
  86. data/vendor/local/include/gobject-introspection-1.0/gipropertyinfo.h +44 -0
  87. data/vendor/local/include/gobject-introspection-1.0/giregisteredtypeinfo.h +53 -0
  88. data/vendor/local/include/gobject-introspection-1.0/girepository.h +179 -0
  89. data/vendor/local/include/gobject-introspection-1.0/girffi.h +80 -0
  90. data/vendor/local/include/gobject-introspection-1.0/gisignalinfo.h +45 -0
  91. data/vendor/local/include/gobject-introspection-1.0/gistructinfo.h +53 -0
  92. data/vendor/local/include/gobject-introspection-1.0/gitypeinfo.h +56 -0
  93. data/vendor/local/include/gobject-introspection-1.0/gitypelib.h +55 -0
  94. data/vendor/local/include/gobject-introspection-1.0/gitypes.h +453 -0
  95. data/vendor/local/include/gobject-introspection-1.0/giunioninfo.h +57 -0
  96. data/vendor/local/include/gobject-introspection-1.0/givfuncinfo.h +56 -0
  97. data/vendor/local/lib/girepository-1.0/DBus-1.0.typelib +0 -0
  98. data/vendor/local/lib/girepository-1.0/DBusGLib-1.0.typelib +0 -0
  99. data/vendor/local/lib/girepository-1.0/GIRepository-2.0.typelib +0 -0
  100. data/vendor/local/lib/girepository-1.0/GL-1.0.typelib +0 -0
  101. data/vendor/local/lib/girepository-1.0/GLib-2.0.typelib +0 -0
  102. data/vendor/local/lib/girepository-1.0/GModule-2.0.typelib +0 -0
  103. data/vendor/local/lib/girepository-1.0/GObject-2.0.typelib +0 -0
  104. data/vendor/local/lib/girepository-1.0/Gio-2.0.typelib +0 -0
  105. data/vendor/local/lib/girepository-1.0/cairo-1.0.typelib +0 -0
  106. data/vendor/local/lib/girepository-1.0/fontconfig-2.0.typelib +0 -0
  107. data/vendor/local/lib/girepository-1.0/freetype2-2.0.typelib +0 -0
  108. data/vendor/local/lib/girepository-1.0/libxml2-2.0.typelib +0 -0
  109. data/vendor/local/lib/girepository-1.0/xfixes-4.0.typelib +0 -0
  110. data/vendor/local/lib/girepository-1.0/xft-2.0.typelib +0 -0
  111. data/vendor/local/lib/girepository-1.0/xlib-2.0.typelib +0 -0
  112. data/vendor/local/lib/girepository-1.0/xrandr-1.3.typelib +0 -0
  113. data/vendor/local/lib/gobject-introspection/giscanner/__init__.py +24 -0
  114. data/vendor/local/lib/gobject-introspection/giscanner/__init__.pyc +0 -0
  115. data/vendor/local/lib/gobject-introspection/giscanner/__init__.pyo +0 -0
  116. data/vendor/local/lib/gobject-introspection/giscanner/annotationmain.py +74 -0
  117. data/vendor/local/lib/gobject-introspection/giscanner/annotationmain.pyc +0 -0
  118. data/vendor/local/lib/gobject-introspection/giscanner/annotationmain.pyo +0 -0
  119. data/vendor/local/lib/gobject-introspection/giscanner/annotationparser.py +1204 -0
  120. data/vendor/local/lib/gobject-introspection/giscanner/annotationparser.pyc +0 -0
  121. data/vendor/local/lib/gobject-introspection/giscanner/annotationparser.pyo +0 -0
  122. data/vendor/local/lib/gobject-introspection/giscanner/ast.py +1100 -0
  123. data/vendor/local/lib/gobject-introspection/giscanner/ast.pyc +0 -0
  124. data/vendor/local/lib/gobject-introspection/giscanner/ast.pyo +0 -0
  125. data/vendor/local/lib/gobject-introspection/giscanner/cachestore.py +196 -0
  126. data/vendor/local/lib/gobject-introspection/giscanner/cachestore.pyc +0 -0
  127. data/vendor/local/lib/gobject-introspection/giscanner/cachestore.pyo +0 -0
  128. data/vendor/local/lib/gobject-introspection/giscanner/codegen.py +140 -0
  129. data/vendor/local/lib/gobject-introspection/giscanner/codegen.pyc +0 -0
  130. data/vendor/local/lib/gobject-introspection/giscanner/codegen.pyo +0 -0
  131. data/vendor/local/lib/gobject-introspection/giscanner/docmain.py +60 -0
  132. data/vendor/local/lib/gobject-introspection/giscanner/docmain.pyc +0 -0
  133. data/vendor/local/lib/gobject-introspection/giscanner/docmain.pyo +0 -0
  134. data/vendor/local/lib/gobject-introspection/giscanner/doctemplates/C/class.tmpl +2 -0
  135. data/vendor/local/lib/gobject-introspection/giscanner/doctemplates/C/constructor.tmpl +1 -0
  136. data/vendor/local/lib/gobject-introspection/giscanner/doctemplates/C/default.tmpl +1 -0
  137. data/vendor/local/lib/gobject-introspection/giscanner/doctemplates/C/enum.tmpl +2 -0
  138. data/vendor/local/lib/gobject-introspection/giscanner/doctemplates/C/function.tmpl +61 -0
  139. data/vendor/local/lib/gobject-introspection/giscanner/doctemplates/C/method.tmpl +1 -0
  140. data/vendor/local/lib/gobject-introspection/giscanner/doctemplates/C/namespace.tmpl +1 -0
  141. data/vendor/local/lib/gobject-introspection/giscanner/doctemplates/C/property.tmpl +5 -0
  142. data/vendor/local/lib/gobject-introspection/giscanner/doctemplates/C/record.tmpl +1 -0
  143. data/vendor/local/lib/gobject-introspection/giscanner/doctemplates/C/signal.tmpl +5 -0
  144. data/vendor/local/lib/gobject-introspection/giscanner/doctemplates/C/vfunc.tmpl +4 -0
  145. data/vendor/local/lib/gobject-introspection/giscanner/doctemplates/Gjs/class.tmpl +18 -0
  146. data/vendor/local/lib/gobject-introspection/giscanner/doctemplates/Gjs/constructor.tmpl +1 -0
  147. data/vendor/local/lib/gobject-introspection/giscanner/doctemplates/Gjs/default.tmpl +1 -0
  148. data/vendor/local/lib/gobject-introspection/giscanner/doctemplates/Gjs/enum.tmpl +13 -0
  149. data/vendor/local/lib/gobject-introspection/giscanner/doctemplates/Gjs/function.tmpl +48 -0
  150. data/vendor/local/lib/gobject-introspection/giscanner/doctemplates/Gjs/method.tmpl +1 -0
  151. data/vendor/local/lib/gobject-introspection/giscanner/doctemplates/Gjs/namespace.tmpl +2 -0
  152. data/vendor/local/lib/gobject-introspection/giscanner/doctemplates/Gjs/property.tmpl +10 -0
  153. data/vendor/local/lib/gobject-introspection/giscanner/doctemplates/Gjs/record.tmpl +2 -0
  154. data/vendor/local/lib/gobject-introspection/giscanner/doctemplates/Gjs/signal.tmpl +37 -0
  155. data/vendor/local/lib/gobject-introspection/giscanner/doctemplates/Gjs/vfunc.tmpl +27 -0
  156. data/vendor/local/lib/gobject-introspection/giscanner/doctemplates/Python/class.tmpl +17 -0
  157. data/vendor/local/lib/gobject-introspection/giscanner/doctemplates/Python/constructor.tmpl +1 -0
  158. data/vendor/local/lib/gobject-introspection/giscanner/doctemplates/Python/default.tmpl +1 -0
  159. data/vendor/local/lib/gobject-introspection/giscanner/doctemplates/Python/enum.tmpl +13 -0
  160. data/vendor/local/lib/gobject-introspection/giscanner/doctemplates/Python/function.tmpl +53 -0
  161. data/vendor/local/lib/gobject-introspection/giscanner/doctemplates/Python/method.tmpl +1 -0
  162. data/vendor/local/lib/gobject-introspection/giscanner/doctemplates/Python/namespace.tmpl +2 -0
  163. data/vendor/local/lib/gobject-introspection/giscanner/doctemplates/Python/property.tmpl +10 -0
  164. data/vendor/local/lib/gobject-introspection/giscanner/doctemplates/Python/record.tmpl +2 -0
  165. data/vendor/local/lib/gobject-introspection/giscanner/doctemplates/Python/signal.tmpl +42 -0
  166. data/vendor/local/lib/gobject-introspection/giscanner/doctemplates/Python/vfunc.tmpl +33 -0
  167. data/vendor/local/lib/gobject-introspection/giscanner/doctemplates/base.tmpl +29 -0
  168. data/vendor/local/lib/gobject-introspection/giscanner/doctemplates/class.tmpl +40 -0
  169. data/vendor/local/lib/gobject-introspection/giscanner/doctemplates/namespace.tmpl +19 -0
  170. data/vendor/local/lib/gobject-introspection/giscanner/docwriter.py +635 -0
  171. data/vendor/local/lib/gobject-introspection/giscanner/docwriter.pyc +0 -0
  172. data/vendor/local/lib/gobject-introspection/giscanner/docwriter.pyo +0 -0
  173. data/vendor/local/lib/gobject-introspection/giscanner/dumper.py +363 -0
  174. data/vendor/local/lib/gobject-introspection/giscanner/dumper.pyc +0 -0
  175. data/vendor/local/lib/gobject-introspection/giscanner/dumper.pyo +0 -0
  176. data/vendor/local/lib/gobject-introspection/giscanner/gdumpparser.py +551 -0
  177. data/vendor/local/lib/gobject-introspection/giscanner/gdumpparser.pyc +0 -0
  178. data/vendor/local/lib/gobject-introspection/giscanner/gdumpparser.pyo +0 -0
  179. data/vendor/local/lib/gobject-introspection/giscanner/girparser.py +581 -0
  180. data/vendor/local/lib/gobject-introspection/giscanner/girparser.pyc +0 -0
  181. data/vendor/local/lib/gobject-introspection/giscanner/girparser.pyo +0 -0
  182. data/vendor/local/lib/gobject-introspection/giscanner/girwriter.py +584 -0
  183. data/vendor/local/lib/gobject-introspection/giscanner/girwriter.pyc +0 -0
  184. data/vendor/local/lib/gobject-introspection/giscanner/girwriter.pyo +0 -0
  185. data/vendor/local/lib/gobject-introspection/giscanner/introspectablepass.py +236 -0
  186. data/vendor/local/lib/gobject-introspection/giscanner/introspectablepass.pyc +0 -0
  187. data/vendor/local/lib/gobject-introspection/giscanner/introspectablepass.pyo +0 -0
  188. data/vendor/local/lib/gobject-introspection/giscanner/libtoolimporter.py +76 -0
  189. data/vendor/local/lib/gobject-introspection/giscanner/libtoolimporter.pyc +0 -0
  190. data/vendor/local/lib/gobject-introspection/giscanner/libtoolimporter.pyo +0 -0
  191. data/vendor/local/lib/gobject-introspection/giscanner/maintransformer.py +1337 -0
  192. data/vendor/local/lib/gobject-introspection/giscanner/maintransformer.pyc +0 -0
  193. data/vendor/local/lib/gobject-introspection/giscanner/maintransformer.pyo +0 -0
  194. data/vendor/local/lib/gobject-introspection/giscanner/message.py +185 -0
  195. data/vendor/local/lib/gobject-introspection/giscanner/message.pyc +0 -0
  196. data/vendor/local/lib/gobject-introspection/giscanner/message.pyo +0 -0
  197. data/vendor/local/lib/gobject-introspection/giscanner/odict.py +50 -0
  198. data/vendor/local/lib/gobject-introspection/giscanner/odict.pyc +0 -0
  199. data/vendor/local/lib/gobject-introspection/giscanner/odict.pyo +0 -0
  200. data/vendor/local/lib/gobject-introspection/giscanner/scannermain.py +497 -0
  201. data/vendor/local/lib/gobject-introspection/giscanner/scannermain.pyc +0 -0
  202. data/vendor/local/lib/gobject-introspection/giscanner/scannermain.pyo +0 -0
  203. data/vendor/local/lib/gobject-introspection/giscanner/sectionparser.py +78 -0
  204. data/vendor/local/lib/gobject-introspection/giscanner/sectionparser.pyc +0 -0
  205. data/vendor/local/lib/gobject-introspection/giscanner/sectionparser.pyo +0 -0
  206. data/vendor/local/lib/gobject-introspection/giscanner/shlibs.py +132 -0
  207. data/vendor/local/lib/gobject-introspection/giscanner/shlibs.pyc +0 -0
  208. data/vendor/local/lib/gobject-introspection/giscanner/shlibs.pyo +0 -0
  209. data/vendor/local/lib/gobject-introspection/giscanner/sourcescanner.py +324 -0
  210. data/vendor/local/lib/gobject-introspection/giscanner/sourcescanner.pyc +0 -0
  211. data/vendor/local/lib/gobject-introspection/giscanner/sourcescanner.pyo +0 -0
  212. data/vendor/local/lib/gobject-introspection/giscanner/testcodegen.py +119 -0
  213. data/vendor/local/lib/gobject-introspection/giscanner/testcodegen.pyc +0 -0
  214. data/vendor/local/lib/gobject-introspection/giscanner/testcodegen.pyo +0 -0
  215. data/vendor/local/lib/gobject-introspection/giscanner/transformer.py +999 -0
  216. data/vendor/local/lib/gobject-introspection/giscanner/transformer.pyc +0 -0
  217. data/vendor/local/lib/gobject-introspection/giscanner/transformer.pyo +0 -0
  218. data/vendor/local/lib/gobject-introspection/giscanner/utils.py +141 -0
  219. data/vendor/local/lib/gobject-introspection/giscanner/utils.pyc +0 -0
  220. data/vendor/local/lib/gobject-introspection/giscanner/utils.pyo +0 -0
  221. data/vendor/local/lib/gobject-introspection/giscanner/xmlwriter.py +197 -0
  222. data/vendor/local/lib/gobject-introspection/giscanner/xmlwriter.pyc +0 -0
  223. data/vendor/local/lib/gobject-introspection/giscanner/xmlwriter.pyo +0 -0
  224. data/vendor/local/lib/libgirepository-1.0.a +0 -0
  225. data/vendor/local/lib/libgirepository-1.0.dll.a +0 -0
  226. data/vendor/local/lib/libgirepository-1.0.la +41 -0
  227. data/vendor/local/lib/pkgconfig/gobject-introspection-1.0.pc +26 -0
  228. data/vendor/local/lib/pkgconfig/gobject-introspection-no-export-1.0.pc +23 -0
  229. data/vendor/local/share/aclocal/introspection.m4 +96 -0
  230. data/vendor/local/share/gir-1.0/DBus-1.0.gir +32 -0
  231. data/vendor/local/share/gir-1.0/DBusGLib-1.0.gir +18 -0
  232. data/vendor/local/share/gir-1.0/GIRepository-2.0.gir +3833 -0
  233. data/vendor/local/share/gir-1.0/GL-1.0.gir +31 -0
  234. data/vendor/local/share/gir-1.0/GLib-2.0.gir +44304 -0
  235. data/vendor/local/share/gir-1.0/GModule-2.0.gir +184 -0
  236. data/vendor/local/share/gir-1.0/GObject-2.0.gir +13947 -0
  237. data/vendor/local/share/gir-1.0/Gio-2.0.gir +73619 -0
  238. data/vendor/local/share/gir-1.0/cairo-1.0.gir +70 -0
  239. data/vendor/local/share/gir-1.0/fontconfig-2.0.gir +18 -0
  240. data/vendor/local/share/gir-1.0/freetype2-2.0.gir +22 -0
  241. data/vendor/local/share/gir-1.0/libxml2-2.0.gir +25 -0
  242. data/vendor/local/share/gir-1.0/xfixes-4.0.gir +10 -0
  243. data/vendor/local/share/gir-1.0/xft-2.0.gir +23 -0
  244. data/vendor/local/share/gir-1.0/xlib-2.0.gir +67 -0
  245. data/vendor/local/share/gir-1.0/xrandr-1.3.gir +16 -0
  246. data/vendor/local/share/gobject-introspection-1.0/Makefile.introspection +166 -0
  247. data/vendor/local/share/gobject-introspection-1.0/gdump.c +564 -0
  248. data/vendor/local/share/gobject-introspection-1.0/tests/annotation.c +835 -0
  249. data/vendor/local/share/gobject-introspection-1.0/tests/annotation.h +198 -0
  250. data/vendor/local/share/gobject-introspection-1.0/tests/drawable.c +55 -0
  251. data/vendor/local/share/gobject-introspection-1.0/tests/drawable.h +33 -0
  252. data/vendor/local/share/gobject-introspection-1.0/tests/everything.c +1473 -0
  253. data/vendor/local/share/gobject-introspection-1.0/tests/everything.h +428 -0
  254. data/vendor/local/share/gobject-introspection-1.0/tests/foo.c +790 -0
  255. data/vendor/local/share/gobject-introspection-1.0/tests/foo.h +437 -0
  256. data/vendor/local/share/gobject-introspection-1.0/tests/gimarshallingtests.c +5256 -0
  257. data/vendor/local/share/gobject-introspection-1.0/tests/gimarshallingtests.h +1158 -0
  258. data/vendor/local/share/gobject-introspection-1.0/tests/regress.c +4009 -0
  259. data/vendor/local/share/gobject-introspection-1.0/tests/regress.h +944 -0
  260. data/vendor/local/share/gobject-introspection-1.0/tests/utility.c +45 -0
  261. data/vendor/local/share/gobject-introspection-1.0/tests/utility.h +95 -0
  262. data/vendor/local/share/gobject-introspection-1.0/tests/warnlib.c +33 -0
  263. data/vendor/local/share/gobject-introspection-1.0/tests/warnlib.h +36 -0
  264. data/vendor/local/share/license/gobject-introspection/AUTHORS +9 -0
  265. data/vendor/local/share/license/gobject-introspection/COPYING +12 -0
  266. data/vendor/local/share/man/man1/g-ir-compiler.1 +51 -0
  267. data/vendor/local/share/man/man1/g-ir-generate.1 +29 -0
  268. metadata +343 -0
@@ -0,0 +1,4009 @@
1
+ /* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
2
+ #include <string.h>
3
+ #include <stdlib.h>
4
+ #include <glib-object.h>
5
+ #include <gobject/gvaluecollector.h>
6
+
7
+ #include "regress.h"
8
+
9
+ static gboolean abort_on_error = TRUE;
10
+
11
+ #define ASSERT_VALUE(condition) \
12
+ if (abort_on_error) \
13
+ g_assert (condition); \
14
+ else \
15
+ g_warn_if_fail (condition); \
16
+
17
+ void
18
+ regress_set_abort_on_error (gboolean in)
19
+ {
20
+ abort_on_error = in;
21
+ }
22
+
23
+ /* basic types */
24
+ gboolean
25
+ regress_test_boolean (gboolean in)
26
+ {
27
+ return in;
28
+ }
29
+
30
+ gboolean
31
+ regress_test_boolean_true (gboolean in)
32
+ {
33
+ ASSERT_VALUE (in == TRUE);
34
+ return in;
35
+ }
36
+
37
+ gboolean
38
+ regress_test_boolean_false (gboolean in)
39
+ {
40
+ ASSERT_VALUE (in == FALSE);
41
+ return in;
42
+ }
43
+
44
+ gint8
45
+ regress_test_int8 (gint8 in)
46
+ {
47
+ return in;
48
+ }
49
+
50
+ guint8
51
+ regress_test_uint8 (guint8 in)
52
+ {
53
+ return in;
54
+ }
55
+
56
+ gint16
57
+ regress_test_int16 (gint16 in)
58
+ {
59
+ return in;
60
+ }
61
+
62
+ guint16
63
+ regress_test_uint16 (guint16 in)
64
+ {
65
+ return in;
66
+ }
67
+
68
+ gint32
69
+ regress_test_int32 (gint32 in)
70
+ {
71
+ return in;
72
+ }
73
+
74
+ guint32
75
+ regress_test_uint32 (guint32 in)
76
+ {
77
+ return in;
78
+ }
79
+
80
+ gint64
81
+ regress_test_int64 (gint64 in)
82
+ {
83
+ return in;
84
+ }
85
+
86
+ guint64
87
+ regress_test_uint64 (guint64 in)
88
+ {
89
+ return in;
90
+ }
91
+
92
+ gshort
93
+ regress_test_short (gshort in)
94
+ {
95
+ return in;
96
+ }
97
+
98
+ gushort
99
+ regress_test_ushort (gushort in)
100
+ {
101
+ return in;
102
+ }
103
+
104
+ gint
105
+ regress_test_int (gint in)
106
+ {
107
+ return in;
108
+ }
109
+
110
+ guint
111
+ regress_test_uint (guint in)
112
+ {
113
+ return in;
114
+ }
115
+
116
+ glong
117
+ regress_test_long (glong in)
118
+ {
119
+ return in;
120
+ }
121
+
122
+ gulong
123
+ regress_test_ulong (gulong in)
124
+ {
125
+ return in;
126
+ }
127
+
128
+ gssize
129
+ regress_test_ssize (gssize in)
130
+ {
131
+ return in;
132
+ }
133
+
134
+ gsize
135
+ regress_test_size (gsize in)
136
+ {
137
+ return in;
138
+ }
139
+
140
+ gfloat
141
+ regress_test_float (gfloat in)
142
+ {
143
+ return in;
144
+ }
145
+
146
+ gdouble
147
+ regress_test_double (gdouble in)
148
+ {
149
+ return in;
150
+ }
151
+
152
+ gunichar
153
+ regress_test_unichar (gunichar in)
154
+ {
155
+ return in;
156
+ }
157
+
158
+ time_t
159
+ regress_test_timet (time_t in)
160
+ {
161
+ return in;
162
+ }
163
+
164
+ GType
165
+ regress_test_gtype (GType in)
166
+ {
167
+ return in;
168
+ }
169
+
170
+ int
171
+ regress_test_closure (GClosure *closure)
172
+ {
173
+ GValue return_value = {0, };
174
+ int ret;
175
+
176
+ g_value_init (&return_value, G_TYPE_INT);
177
+
178
+ g_closure_invoke (closure,
179
+ &return_value,
180
+ 0, NULL,
181
+ NULL);
182
+
183
+ ret = g_value_get_int (&return_value);
184
+
185
+ g_value_unset(&return_value);
186
+
187
+ return ret;
188
+ }
189
+
190
+ int
191
+ regress_test_closure_one_arg (GClosure *closure, int arg)
192
+ {
193
+ GValue return_value = {0, };
194
+ GValue arguments[1];
195
+ int ret;
196
+
197
+ g_value_init (&return_value, G_TYPE_INT);
198
+
199
+ memset (&arguments[0], 0, sizeof (arguments));
200
+ g_value_init (&arguments[0], G_TYPE_INT);
201
+ g_value_set_int (&arguments[0], arg);
202
+
203
+ g_closure_invoke (closure,
204
+ &return_value,
205
+ 1, arguments,
206
+ NULL);
207
+
208
+ ret = g_value_get_int (&return_value);
209
+
210
+ g_value_unset(&return_value);
211
+ g_value_unset(&arguments[0]);
212
+
213
+ return ret;
214
+ }
215
+
216
+ /**
217
+ * regress_test_closure_variant:
218
+ * @closure: GClosure which takes one GVariant and returns a GVariant
219
+ * @arg: (allow-none) (transfer none): a GVariant passed as argument to @closure
220
+ *
221
+ * Return value: (transfer full): the return value of @closure
222
+ */
223
+ GVariant*
224
+ regress_test_closure_variant (GClosure *closure, GVariant* arg)
225
+ {
226
+ GValue return_value = {0, };
227
+ GValue arguments[1] = {{0,} };
228
+ GVariant *ret;
229
+
230
+ g_value_init (&return_value, G_TYPE_VARIANT);
231
+
232
+ g_value_init (&arguments[0], G_TYPE_VARIANT);
233
+ g_value_set_variant (&arguments[0], arg);
234
+
235
+ g_closure_invoke (closure,
236
+ &return_value,
237
+ 1, arguments,
238
+ NULL);
239
+
240
+ ret = g_value_get_variant (&return_value);
241
+ if (ret != NULL)
242
+ g_variant_ref (ret);
243
+
244
+ g_value_unset (&return_value);
245
+ g_value_unset (&arguments[0]);
246
+
247
+ return ret;
248
+ }
249
+
250
+ /**
251
+ * regress_test_value_arg:
252
+ * @v: (transfer none): a GValue expected to contain an int
253
+ *
254
+ * Return value: the int contained in the GValue.
255
+ */
256
+ int
257
+ regress_test_int_value_arg(const GValue *v)
258
+ {
259
+ int i;
260
+
261
+ i = g_value_get_int (v);
262
+
263
+ return i;
264
+ }
265
+
266
+ static GValue value;
267
+ /**
268
+ * regress_test_value_return:
269
+ * @i: an int
270
+ *
271
+ * Return value: (transfer none): the int wrapped in a GValue.
272
+ */
273
+ const GValue *
274
+ regress_test_value_return(int i)
275
+ {
276
+ memset(&value, '\0', sizeof(GValue));
277
+
278
+ g_value_init (&value, G_TYPE_INT);
279
+ g_value_set_int (&value, i);
280
+
281
+ return &value;
282
+ }
283
+
284
+ /************************************************************************/
285
+ /* foreign structs */
286
+
287
+ #ifndef _GI_DISABLE_CAIRO
288
+ /**
289
+ * regress_test_cairo_context_full_return:
290
+ *
291
+ * Returns: (transfer full):
292
+ */
293
+ cairo_t *
294
+ regress_test_cairo_context_full_return (void)
295
+ {
296
+ cairo_surface_t *surface;
297
+ cairo_t *cr;
298
+ surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, 10, 10);
299
+ cr = cairo_create (surface);
300
+ cairo_surface_destroy (surface);
301
+ return cr;
302
+ }
303
+
304
+ /**
305
+ * regress_test_cairo_context_none_in:
306
+ * @context: (transfer none):
307
+ */
308
+ void
309
+ regress_test_cairo_context_none_in (cairo_t *context)
310
+ {
311
+ cairo_surface_t *surface = cairo_get_target (context);
312
+
313
+ g_assert (cairo_image_surface_get_format (surface) == CAIRO_FORMAT_ARGB32);
314
+ g_assert (cairo_image_surface_get_width (surface) == 10);
315
+ g_assert (cairo_image_surface_get_height (surface) == 10);
316
+ }
317
+
318
+
319
+ /**
320
+ * regress_test_cairo_surface_none_return:
321
+ *
322
+ * Returns: (transfer none):
323
+ */
324
+ cairo_surface_t *
325
+ regress_test_cairo_surface_none_return (void)
326
+ {
327
+ static cairo_surface_t *surface;
328
+
329
+ if (surface == NULL) {
330
+ surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, 10, 10);
331
+ }
332
+
333
+ return surface;
334
+ }
335
+
336
+ /**
337
+ * regress_test_cairo_surface_full_return:
338
+ *
339
+ * Returns: (transfer full):
340
+ */
341
+ cairo_surface_t *
342
+ regress_test_cairo_surface_full_return (void)
343
+ {
344
+ return cairo_image_surface_create (CAIRO_FORMAT_ARGB32, 10, 10);
345
+ }
346
+
347
+ /**
348
+ * regress_test_cairo_surface_none_in:
349
+ * @surface: (transfer none):
350
+ */
351
+ void
352
+ regress_test_cairo_surface_none_in (cairo_surface_t *surface)
353
+ {
354
+ g_assert (cairo_image_surface_get_format (surface) == CAIRO_FORMAT_ARGB32);
355
+ g_assert (cairo_image_surface_get_width (surface) == 10);
356
+ g_assert (cairo_image_surface_get_height (surface) == 10);
357
+ }
358
+
359
+ /**
360
+ * regress_test_cairo_surface_full_out:
361
+ * @surface: (out) (transfer full):
362
+ */
363
+ void
364
+ regress_test_cairo_surface_full_out (cairo_surface_t **surface)
365
+ {
366
+ *surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, 10, 10);
367
+ }
368
+ #endif
369
+
370
+ /**
371
+ * regress_test_gvariant_i:
372
+ *
373
+ * Returns: (transfer none): New variant
374
+ */
375
+ GVariant *
376
+ regress_test_gvariant_i (void)
377
+ {
378
+ return g_variant_new_int32 (1);
379
+ }
380
+
381
+ /**
382
+ * regress_test_gvariant_s:
383
+ *
384
+ * Returns: (transfer none): New variant
385
+ */
386
+ GVariant *
387
+ regress_test_gvariant_s (void)
388
+ {
389
+ return g_variant_new_string ("one");
390
+ }
391
+
392
+ /**
393
+ * regress_test_gvariant_asv:
394
+ *
395
+ * Returns: (transfer none): New variant
396
+ */
397
+ GVariant *
398
+ regress_test_gvariant_asv (void)
399
+ {
400
+ GVariantBuilder b;
401
+
402
+ g_variant_builder_init (&b, G_VARIANT_TYPE ("a{sv}"));
403
+
404
+ g_variant_builder_add (&b, "{sv}", "name", g_variant_new_string ("foo"));
405
+ g_variant_builder_add (&b, "{sv}", "timeout", g_variant_new_int32 (10));
406
+
407
+ return g_variant_builder_end (&b);
408
+ }
409
+
410
+ /**
411
+ * regress_test_gvariant_v:
412
+ *
413
+ * Returns: (transfer none): New variant
414
+ */
415
+ GVariant *
416
+ regress_test_gvariant_v (void)
417
+ {
418
+ return g_variant_new_variant (g_variant_new_string ("contents"));
419
+ }
420
+
421
+ /**
422
+ * regress_test_gvariant_as:
423
+ *
424
+ * Returns: (transfer none): New variant
425
+ */
426
+ GVariant *
427
+ regress_test_gvariant_as (void)
428
+ {
429
+ const char *as[] = { "one", "two", "three", NULL };
430
+
431
+ return g_variant_new_strv (as, -1);
432
+ }
433
+
434
+ /************************************************************************/
435
+ /* utf8 */
436
+ /* insert BLACK HEART SUIT to ensure UTF-8 doesn't get mangled */
437
+ static const char utf8_const[] = "const \xe2\x99\xa5 utf8";
438
+ static const char utf8_nonconst[] = "nonconst \xe2\x99\xa5 utf8";
439
+
440
+ /**
441
+ * regress_test_utf8_const_return:
442
+ *
443
+ * Return value: UTF-8 string
444
+ */
445
+ const char *
446
+ regress_test_utf8_const_return (void)
447
+ {
448
+ /* transfer mode none */
449
+ return utf8_const;
450
+ }
451
+
452
+ /**
453
+ * regress_test_utf8_nonconst_return:
454
+ *
455
+ * Return value: (transfer full): UTF-8 string
456
+ */
457
+ char *
458
+ regress_test_utf8_nonconst_return (void)
459
+ {
460
+ return g_strdup (utf8_nonconst);
461
+ }
462
+
463
+ /**
464
+ * regress_test_utf8_const_in:
465
+ *
466
+ */
467
+ void
468
+ regress_test_utf8_const_in (const char *in)
469
+ {
470
+ /* transfer mode none */
471
+ g_assert (strcmp (in, utf8_const) == 0);
472
+ }
473
+
474
+ /**
475
+ * regress_test_utf8_out:
476
+ * @out: (out) (transfer full):
477
+ */
478
+ void
479
+ regress_test_utf8_out (char **out)
480
+ {
481
+ /* out parameter, transfer mode full */
482
+ *out = g_strdup (utf8_nonconst);
483
+ }
484
+
485
+ /**
486
+ * regress_test_utf8_inout:
487
+ * @inout: (inout) (transfer full):
488
+ */
489
+ void
490
+ regress_test_utf8_inout (char **inout)
491
+ {
492
+ /* inout parameter, transfer mode full */
493
+ g_assert (strcmp (*inout, utf8_const) == 0);
494
+ *inout = g_strdup (utf8_nonconst);
495
+ }
496
+
497
+ /**
498
+ * regress_test_filename_return:
499
+ *
500
+ * Return value: (element-type filename) (transfer full): list of strings
501
+ */
502
+ GSList *
503
+ regress_test_filename_return (void)
504
+ {
505
+ GSList *filenames = NULL;
506
+ filenames = g_slist_prepend (filenames, g_filename_from_utf8("/etc/fstab", -1, NULL, NULL, NULL));
507
+ filenames = g_slist_prepend (filenames, g_filename_from_utf8("åäö", -1, NULL, NULL, NULL));
508
+ return filenames;
509
+ }
510
+
511
+ /* in arguments after out arguments */
512
+
513
+ /**
514
+ * regress_test_int_out_utf8:
515
+ * @length: (out):
516
+ * @in:
517
+ */
518
+ void
519
+ regress_test_int_out_utf8 (int *length, const char *in)
520
+ {
521
+ *length = g_utf8_strlen(in, -1);
522
+ }
523
+
524
+
525
+ /* multiple output arguments */
526
+
527
+ /**
528
+ * regress_test_multi_double_args:
529
+ * @in:
530
+ * @one: (out):
531
+ * @two: (out):
532
+ */
533
+ void
534
+ regress_test_multi_double_args (gdouble in, gdouble *one, gdouble *two)
535
+ {
536
+ *one = in * 2;
537
+ *two = in * 3;
538
+ }
539
+
540
+ /**
541
+ * regress_test_utf8_out_out:
542
+ * @out0: (out) (transfer full): a copy of "first"
543
+ * @out1: (out) (transfer full): a copy of "second"
544
+ */
545
+ void
546
+ regress_test_utf8_out_out (char **out0, char **out1)
547
+ {
548
+ *out0 = g_strdup ("first");
549
+ *out1 = g_strdup ("second");
550
+ }
551
+
552
+ /**
553
+ * regress_test_utf8_out_nonconst_return:
554
+ * @out: (out) (transfer full): a copy of "second"
555
+ *
556
+ * Returns: (transfer full): a copy of "first"
557
+ */
558
+ char *
559
+ regress_test_utf8_out_nonconst_return (char **out)
560
+ {
561
+ *out = g_strdup ("second");
562
+ return g_strdup ("first");
563
+ }
564
+
565
+ /**
566
+ * regress_test_utf8_null_in:
567
+ * @in: (allow-none):
568
+ */
569
+ void
570
+ regress_test_utf8_null_in (char *in)
571
+ {
572
+ g_assert (in == NULL);
573
+ }
574
+
575
+ /**
576
+ * regress_test_utf8_null_out:
577
+ * @char_out: (allow-none) (out):
578
+ */
579
+ void regress_test_utf8_null_out (char **char_out)
580
+ {
581
+ *char_out = NULL;
582
+ }
583
+
584
+
585
+ /* non-basic-types */
586
+
587
+ static const char *test_sequence[] = {"1", "2", "3"};
588
+
589
+ /* array */
590
+
591
+ /**
592
+ * regress_test_array_int_in:
593
+ * @n_ints:
594
+ * @ints: (array length=n_ints): List of ints
595
+ */
596
+ int
597
+ regress_test_array_int_in (int n_ints, int *ints)
598
+ {
599
+ int i, sum = 0;
600
+ for (i = 0; i < n_ints; i++)
601
+ sum += ints[i];
602
+ return sum;
603
+ }
604
+
605
+ /**
606
+ * regress_test_array_int_out:
607
+ * @n_ints: (out): the length of @ints
608
+ * @ints: (out) (array length=n_ints) (transfer full): a list of 5 integers, from 0 to 4 in consecutive order
609
+ */
610
+ void
611
+ regress_test_array_int_out (int *n_ints, int **ints)
612
+ {
613
+ int i;
614
+ *n_ints = 5;
615
+ *ints = g_malloc0(sizeof(**ints) * *n_ints);
616
+ for (i = 1; i < *n_ints; i++)
617
+ (*ints)[i] = (*ints)[i-1] + 1;
618
+ }
619
+
620
+ /**
621
+ * regress_test_array_int_inout:
622
+ * @n_ints: (inout): the length of @ints
623
+ * @ints: (inout) (array length=n_ints) (transfer full): a list of integers whose items will be increased by 1, except the first that will be dropped
624
+ */
625
+ void
626
+ regress_test_array_int_inout (int *n_ints, int **ints)
627
+ {
628
+ int i;
629
+ int *new_ints;
630
+
631
+ if (0 < *n_ints)
632
+ {
633
+ *n_ints -= 1;
634
+ new_ints = g_malloc(sizeof(**ints) * *n_ints);
635
+ for (i = 0; i < *n_ints; i++)
636
+ new_ints[i] = (*ints)[i + 1] + 1;
637
+ *ints = new_ints;
638
+ }
639
+ }
640
+
641
+ /**
642
+ * regress_test_array_gint8_in:
643
+ * @n_ints:
644
+ * @ints: (array length=n_ints): List of ints
645
+ */
646
+ int
647
+ regress_test_array_gint8_in (int n_ints, gint8 *ints)
648
+ {
649
+ int i, sum = 0;
650
+ for (i = 0; i < n_ints; i++)
651
+ sum += ints[i];
652
+ return sum;
653
+ }
654
+
655
+ /**
656
+ * regress_test_array_gint16_in:
657
+ * @n_ints:
658
+ * @ints: (array length=n_ints): List of ints
659
+ */
660
+ int
661
+ regress_test_array_gint16_in (int n_ints, gint16 *ints)
662
+ {
663
+ int i, sum = 0;
664
+ for (i = 0; i < n_ints; i++)
665
+ sum += ints[i];
666
+ return sum;
667
+ }
668
+
669
+ /**
670
+ * regress_test_array_gint32_in:
671
+ * @n_ints:
672
+ * @ints: (array length=n_ints): List of ints
673
+ */
674
+ gint32
675
+ regress_test_array_gint32_in (int n_ints, gint32 *ints)
676
+ {
677
+ int i;
678
+ gint32 sum = 0;
679
+ for (i = 0; i < n_ints; i++)
680
+ sum += ints[i];
681
+ return sum;
682
+ }
683
+
684
+ /**
685
+ * regress_test_array_gint64_in:
686
+ * @n_ints:
687
+ * @ints: (array length=n_ints): List of ints
688
+ */
689
+ gint64
690
+ regress_test_array_gint64_in (int n_ints, gint64 *ints)
691
+ {
692
+ int i;
693
+ gint64 sum = 0;
694
+ for (i = 0; i < n_ints; i++)
695
+ sum += ints[i];
696
+ return sum;
697
+ }
698
+
699
+ /**
700
+ * regress_test_strv_in:
701
+ * @arr: (array zero-terminated=1) (transfer none):
702
+ */
703
+ gboolean
704
+ regress_test_strv_in (char **arr)
705
+ {
706
+ if (g_strv_length (arr) != 3)
707
+ return FALSE;
708
+ if (strcmp (arr[0], "1") != 0)
709
+ return FALSE;
710
+ if (strcmp (arr[1], "2") != 0)
711
+ return FALSE;
712
+ if (strcmp (arr[2], "3") != 0)
713
+ return FALSE;
714
+ return TRUE;
715
+ }
716
+
717
+ /**
718
+ * regress_test_array_gtype_in:
719
+ * @n_types:
720
+ * @types: (array length=n_types): List of types
721
+ *
722
+ * Return value: (transfer full): string representation of provided types
723
+ */
724
+ char *
725
+ regress_test_array_gtype_in (int n_types, GType *types)
726
+ {
727
+ GString *string;
728
+ int i;
729
+
730
+ string = g_string_new ("[");
731
+ for (i = 0; i < n_types; i++)
732
+ {
733
+ g_string_append (string, g_type_name (types[i]));
734
+ g_string_append_c (string, ',');
735
+ }
736
+ g_string_append_c (string, ']');
737
+ return g_string_free (string, FALSE);
738
+ }
739
+
740
+ /**
741
+ * regress_test_strv_out:
742
+ *
743
+ * Returns: (transfer full):
744
+ */
745
+ char **
746
+ regress_test_strv_out (void)
747
+ {
748
+ int i = 0;
749
+ int n = 6;
750
+ char **ret = g_new (char *, n);
751
+ ret[i++] = g_strdup ("thanks");
752
+ ret[i++] = g_strdup ("for");
753
+ ret[i++] = g_strdup ("all");
754
+ ret[i++] = g_strdup ("the");
755
+ ret[i++] = g_strdup ("fish");
756
+ ret[i++] = NULL;
757
+ g_assert (i == n);
758
+ return ret;
759
+ }
760
+
761
+ /**
762
+ * regress_test_strv_out_container:
763
+ *
764
+ * Return value: (array zero-terminated=1) (transfer container):
765
+ */
766
+ char **
767
+ regress_test_strv_out_container (void)
768
+ {
769
+ char **ret = g_new (char *, 4);
770
+ ret[0] = "1";
771
+ ret[1] = "2";
772
+ ret[2] = "3";
773
+ ret[3] = NULL;
774
+ return ret;
775
+ }
776
+
777
+ /**
778
+ * regress_test_strv_outarg:
779
+ * @retp: (array zero-terminated=1) (out) (transfer container):
780
+ */
781
+ void
782
+ regress_test_strv_outarg (char ***retp)
783
+ {
784
+ char **ret = g_new (char *, 4);
785
+ ret[0] = "1";
786
+ ret[1] = "2";
787
+ ret[2] = "3";
788
+ ret[3] = NULL;
789
+ *retp = ret;
790
+ }
791
+
792
+ /**
793
+ * regress_test_array_fixed_size_int_in:
794
+ * @ints: (array fixed-size=5): a list of 5 integers
795
+ *
796
+ * Returns: the sum of the items in @ints
797
+ */
798
+ int
799
+ regress_test_array_fixed_size_int_in (int *ints)
800
+ {
801
+ int i, sum = 0;
802
+ for (i = 0; i < 5; i++)
803
+ sum += ints[i];
804
+ return sum;
805
+ }
806
+
807
+ /**
808
+ * regress_test_array_fixed_size_int_out:
809
+ * @ints: (out) (array fixed-size=5) (transfer full): a list of 5 integers ranging from 0 to 4
810
+ */
811
+ void
812
+ regress_test_array_fixed_size_int_out (int **ints)
813
+ {
814
+ int i;
815
+ *ints = g_malloc0(sizeof(**ints) * 5);
816
+ for (i = 1; i < 5; i++)
817
+ (*ints)[i] = (*ints)[i-1] + 1;
818
+ }
819
+
820
+ /**
821
+ * regress_test_array_fixed_size_int_return:
822
+ *
823
+ * Returns: (array fixed-size=5) (transfer full): a list of 5 integers ranging from 0 to 4
824
+ */
825
+ int *
826
+ regress_test_array_fixed_size_int_return (void)
827
+ {
828
+ int i, *ints;
829
+ ints = g_malloc0(sizeof(*ints) * 5);
830
+ for (i = 1; i < 5; i++)
831
+ ints[i] = ints[i-1] + 1;
832
+ return ints;
833
+ }
834
+
835
+ /**
836
+ * regress_test_strv_out_c:
837
+ *
838
+ * Returns: (transfer none):
839
+ */
840
+ const char * const*
841
+ regress_test_strv_out_c (void)
842
+ {
843
+ static char **ret = NULL;
844
+
845
+ if (ret == NULL)
846
+ ret = regress_test_strv_out ();
847
+
848
+ return (const char * const *) ret;
849
+ }
850
+
851
+ /**
852
+ * regress_test_array_int_full_out:
853
+ * @len: length of the returned array.
854
+ *
855
+ * Returns: (array length=len) (transfer full): a new array of integers.
856
+ */
857
+ int *
858
+ regress_test_array_int_full_out(int *len)
859
+ {
860
+ int *result, i;
861
+ *len = 5;
862
+ result = g_malloc0(sizeof(*result) * (*len));
863
+ for (i=1; i < (*len); i++)
864
+ result[i] = result[i-1] + 1;
865
+ return result;
866
+ }
867
+
868
+ /**
869
+ * regress_test_array_int_none_out:
870
+ * @len: length of the returned array.
871
+ *
872
+ * Returns: (array length=len) (transfer none): a static array of integers.
873
+ */
874
+ int *
875
+ regress_test_array_int_none_out(int *len)
876
+ {
877
+ static int result[5] = { 1, 2, 3, 4, 5 };
878
+ *len = 5;
879
+ return result;
880
+ }
881
+
882
+ /**
883
+ * regress_test_array_int_null_in:
884
+ * @arr: (array length=len) (allow-none):
885
+ * @len: length
886
+ */
887
+ void
888
+ regress_test_array_int_null_in (int *arr, int len)
889
+ {
890
+ g_assert (arr == NULL);
891
+ }
892
+
893
+ /**
894
+ * regress_test_array_int_null_out:
895
+ * @arr: (out) (array length=len) (allow-none):
896
+ * @len: (out) : length
897
+ */
898
+ void
899
+ regress_test_array_int_null_out (int **arr, int *len)
900
+ {
901
+ *arr = NULL;
902
+ *len = 0;
903
+ }
904
+
905
+ /* interface */
906
+
907
+ /************************************************************************/
908
+ /* GList */
909
+
910
+ static /*const*/ GList *
911
+ regress_test_sequence_list (void)
912
+ {
913
+ static GList *list = NULL;
914
+ if (!list) {
915
+ gsize i;
916
+ for (i = 0; i < G_N_ELEMENTS(test_sequence); ++i) {
917
+ list = g_list_prepend (list, (gpointer)test_sequence[i]);
918
+ }
919
+ list = g_list_reverse (list);
920
+ }
921
+ return list;
922
+ }
923
+
924
+ /**
925
+ * regress_test_glist_nothing_return:
926
+ *
927
+ * Return value: (element-type utf8) (transfer none):
928
+ */
929
+ const GList *
930
+ regress_test_glist_nothing_return (void)
931
+ {
932
+ return regress_test_sequence_list ();
933
+ }
934
+
935
+ /**
936
+ * regress_test_glist_nothing_return2:
937
+ *
938
+ * Return value: (element-type utf8) (transfer none):
939
+ */
940
+ GList *
941
+ regress_test_glist_nothing_return2 (void)
942
+ {
943
+ return regress_test_sequence_list ();
944
+ }
945
+
946
+ /**
947
+ * regress_test_glist_container_return:
948
+ *
949
+ * Return value: (element-type utf8) (transfer container):
950
+ */
951
+ GList *
952
+ regress_test_glist_container_return (void)
953
+ {
954
+ return g_list_copy (regress_test_sequence_list ());
955
+ }
956
+
957
+ /**
958
+ * regress_test_glist_everything_return:
959
+ *
960
+ * Return value: (element-type utf8) (transfer full):
961
+ */
962
+ GList *
963
+ regress_test_glist_everything_return (void)
964
+ {
965
+ GList *list;
966
+ GList *l;
967
+
968
+ list = g_list_copy (regress_test_sequence_list ());
969
+ for (l = list; l != NULL; l = l->next)
970
+ l->data = g_strdup (l->data);
971
+ return list;
972
+ }
973
+
974
+ static void
975
+ regress_assert_test_sequence_list (const GList *in)
976
+ {
977
+ const GList *l;
978
+ gsize i;
979
+
980
+ for (i = 0, l = in; l != NULL; ++i, l = l->next) {
981
+ g_assert (i < G_N_ELEMENTS(test_sequence));
982
+ g_assert (strcmp (l->data, test_sequence[i]) == 0);
983
+ }
984
+ g_assert (i == G_N_ELEMENTS(test_sequence));
985
+ }
986
+
987
+ /**
988
+ * regress_test_glist_nothing_in:
989
+ * @in: (element-type utf8):
990
+ */
991
+ void
992
+ regress_test_glist_nothing_in (const GList *in)
993
+ {
994
+ regress_assert_test_sequence_list (in);
995
+ }
996
+
997
+ /**
998
+ * regress_test_glist_nothing_in2:
999
+ * @in: (element-type utf8):
1000
+ */
1001
+ void
1002
+ regress_test_glist_nothing_in2 (GList *in)
1003
+ {
1004
+ regress_assert_test_sequence_list (in);
1005
+ }
1006
+
1007
+ /**
1008
+ * regress_test_glist_null_in:
1009
+ * @in: (element-type utf8) (allow-none):
1010
+ */
1011
+ void
1012
+ regress_test_glist_null_in (GSList *in)
1013
+ {
1014
+ g_assert (in == NULL);
1015
+ }
1016
+
1017
+ /**
1018
+ * regress_test_glist_null_out:
1019
+ * @out_list: (out) (element-type utf8) (allow-none):
1020
+ */
1021
+ void
1022
+ regress_test_glist_null_out (GSList **out_list)
1023
+ {
1024
+ *out_list = NULL;
1025
+ }
1026
+
1027
+
1028
+ /************************************************************************/
1029
+ /* GSList */
1030
+
1031
+ static /*const*/ GSList *
1032
+ regress_test_sequence_slist (void)
1033
+ {
1034
+ static GSList *list = NULL;
1035
+ if (!list) {
1036
+ gsize i;
1037
+ for (i = 0; i < G_N_ELEMENTS(test_sequence); ++i) {
1038
+ list = g_slist_prepend (list, (gpointer)test_sequence[i]);
1039
+ }
1040
+ list = g_slist_reverse (list);
1041
+ }
1042
+ return list;
1043
+ }
1044
+
1045
+ /**
1046
+ * regress_test_gslist_nothing_return:
1047
+ *
1048
+ * Return value: (element-type utf8) (transfer none):
1049
+ */
1050
+ const GSList *
1051
+ regress_test_gslist_nothing_return (void)
1052
+ {
1053
+ return regress_test_sequence_slist ();
1054
+ }
1055
+
1056
+ /**
1057
+ * regress_test_gslist_nothing_return2:
1058
+ *
1059
+ * Return value: (element-type utf8) (transfer none):
1060
+ */
1061
+ GSList *
1062
+ regress_test_gslist_nothing_return2 (void)
1063
+ {
1064
+ return regress_test_sequence_slist ();
1065
+ }
1066
+
1067
+ /**
1068
+ * regress_test_gslist_container_return:
1069
+ *
1070
+ * Return value: (element-type utf8) (transfer container):
1071
+ */
1072
+ GSList *
1073
+ regress_test_gslist_container_return (void)
1074
+ {
1075
+ return g_slist_copy (regress_test_sequence_slist ());
1076
+ }
1077
+
1078
+ /**
1079
+ * regress_test_gslist_everything_return:
1080
+ *
1081
+ * Return value: (element-type utf8) (transfer full):
1082
+ */
1083
+ GSList *
1084
+ regress_test_gslist_everything_return (void)
1085
+ {
1086
+ GSList *list;
1087
+ GSList *l;
1088
+
1089
+ list = g_slist_copy (regress_test_sequence_slist ());
1090
+ for (l = list; l != NULL; l = l->next)
1091
+ l->data = g_strdup (l->data);
1092
+ return list;
1093
+ }
1094
+
1095
+ static void
1096
+ regress_assert_test_sequence_slist (const GSList *in)
1097
+ {
1098
+ const GSList *l;
1099
+ gsize i;
1100
+
1101
+ for (i = 0, l = in; l != NULL; ++i, l = l->next) {
1102
+ g_assert (i < G_N_ELEMENTS(test_sequence));
1103
+ g_assert (strcmp (l->data, test_sequence[i]) == 0);
1104
+ }
1105
+ g_assert (i == G_N_ELEMENTS(test_sequence));
1106
+ }
1107
+
1108
+ /**
1109
+ * regress_test_gslist_nothing_in:
1110
+ * @in: (element-type utf8):
1111
+ */
1112
+ void
1113
+ regress_test_gslist_nothing_in (const GSList *in)
1114
+ {
1115
+ regress_assert_test_sequence_slist (in);
1116
+ }
1117
+
1118
+ /**
1119
+ * regress_test_gslist_nothing_in2:
1120
+ * @in: (element-type utf8):
1121
+ */
1122
+ void
1123
+ regress_test_gslist_nothing_in2 (GSList *in)
1124
+ {
1125
+ regress_assert_test_sequence_slist (in);
1126
+ }
1127
+
1128
+ /**
1129
+ * regress_test_gslist_null_in:
1130
+ * @in: (element-type utf8) (allow-none):
1131
+ */
1132
+ void
1133
+ regress_test_gslist_null_in (GSList *in)
1134
+ {
1135
+ g_assert (in == NULL);
1136
+ }
1137
+
1138
+ /**
1139
+ * regress_test_gslist_null_out:
1140
+ * @out_list: (out) (element-type utf8) (allow-none):
1141
+ */
1142
+ void
1143
+ regress_test_gslist_null_out (GSList **out_list)
1144
+ {
1145
+ *out_list = NULL;
1146
+ }
1147
+
1148
+ /************************************************************************/
1149
+ /* GHash */
1150
+
1151
+ static char *table_data[3][2] = {
1152
+ { "foo", "bar" }, { "baz", "bat" }, { "qux", "quux" }
1153
+ };
1154
+
1155
+ static GHashTable *
1156
+ regress_test_table_ghash_new_container (void)
1157
+ {
1158
+ GHashTable *hash;
1159
+ int i;
1160
+ hash = g_hash_table_new(g_str_hash, g_str_equal);
1161
+ for (i=0; i<3; i++)
1162
+ g_hash_table_insert(hash, table_data[i][0], table_data[i][1]);
1163
+ return hash;
1164
+ }
1165
+
1166
+ static GHashTable *
1167
+ regress_test_table_ghash_new_full (void)
1168
+ {
1169
+ GHashTable *hash;
1170
+ int i;
1171
+ hash = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_free);
1172
+ for (i=0; i<3; i++)
1173
+ g_hash_table_insert(hash,
1174
+ g_strdup(table_data[i][0]),
1175
+ g_strdup(table_data[i][1]));
1176
+ return hash;
1177
+ }
1178
+
1179
+ static /*const*/ GHashTable *
1180
+ regress_test_table_ghash_const (void)
1181
+ {
1182
+ static GHashTable *hash = NULL;
1183
+ if (!hash) {
1184
+ hash = regress_test_table_ghash_new_container();
1185
+ }
1186
+ return hash;
1187
+ }
1188
+
1189
+ /**
1190
+ * regress_test_ghash_null_return:
1191
+ *
1192
+ * Return value: (element-type utf8 utf8) (transfer none) (allow-none):
1193
+ */
1194
+ const GHashTable *
1195
+ regress_test_ghash_null_return (void)
1196
+ {
1197
+ return NULL;
1198
+ }
1199
+
1200
+ /**
1201
+ * regress_test_ghash_nothing_return:
1202
+ *
1203
+ * Return value: (element-type utf8 utf8) (transfer none):
1204
+ */
1205
+ const GHashTable *
1206
+ regress_test_ghash_nothing_return (void)
1207
+ {
1208
+ return regress_test_table_ghash_const ();
1209
+ }
1210
+
1211
+ /**
1212
+ * regress_test_ghash_nothing_return2:
1213
+ *
1214
+ * Return value: (element-type utf8 utf8) (transfer none):
1215
+ */
1216
+ GHashTable *
1217
+ regress_test_ghash_nothing_return2 (void)
1218
+ {
1219
+ return regress_test_table_ghash_const ();
1220
+ }
1221
+
1222
+ static GValue *
1223
+ g_value_new (GType type)
1224
+ {
1225
+ GValue *value = g_slice_new0(GValue);
1226
+ g_value_init(value, type);
1227
+ return value;
1228
+ }
1229
+
1230
+ static void
1231
+ g_value_free (GValue *value)
1232
+ {
1233
+ g_value_unset(value);
1234
+ g_slice_free(GValue, value);
1235
+ }
1236
+
1237
+ static const gchar *string_array[] = {
1238
+ "first",
1239
+ "second",
1240
+ "third",
1241
+ NULL
1242
+ };
1243
+
1244
+ /**
1245
+ * regress_test_ghash_gvalue_return:
1246
+ *
1247
+ * Return value: (element-type utf8 GValue) (transfer none):
1248
+ */
1249
+ GHashTable *
1250
+ regress_test_ghash_gvalue_return (void)
1251
+ {
1252
+ GHashTable *hash;
1253
+ GValue *value;
1254
+ hash = g_hash_table_new_full(g_str_hash, g_str_equal,
1255
+ g_free, (GDestroyNotify)g_value_free);
1256
+
1257
+ value = g_value_new(G_TYPE_INT);
1258
+ g_value_set_int(value, 12);
1259
+ g_hash_table_insert(hash, g_strdup("integer"), value);
1260
+
1261
+ value = g_value_new(G_TYPE_BOOLEAN);
1262
+ g_value_set_boolean(value, TRUE);
1263
+ g_hash_table_insert(hash, g_strdup("boolean"), value);
1264
+
1265
+ value = g_value_new(G_TYPE_STRING);
1266
+ g_value_set_string(value, "some text");
1267
+ g_hash_table_insert(hash, g_strdup("string"), value);
1268
+
1269
+ value = g_value_new(G_TYPE_STRV);
1270
+ g_value_set_boxed(value, string_array);
1271
+ g_hash_table_insert(hash, g_strdup("strings"), value);
1272
+
1273
+ value = g_value_new(REGRESS_TEST_TYPE_FLAGS);
1274
+ g_value_set_flags(value, REGRESS_TEST_FLAG1 | REGRESS_TEST_FLAG3);
1275
+ g_hash_table_insert(hash, g_strdup("flags"), value);
1276
+
1277
+ value = g_value_new(regress_test_enum_get_type());
1278
+ g_value_set_enum(value, REGRESS_TEST_VALUE2);
1279
+ g_hash_table_insert(hash, g_strdup("enum"), value);
1280
+
1281
+ return hash;
1282
+ }
1283
+
1284
+ /**
1285
+ * regress_test_ghash_gvalue_in:
1286
+ * @hash: (element-type utf8 GValue): the hash table returned by
1287
+ * regress_test_ghash_gvalue_return().
1288
+ */
1289
+ void
1290
+ regress_test_ghash_gvalue_in (GHashTable *hash)
1291
+ {
1292
+ GValue *value;
1293
+ const gchar **strings;
1294
+ int i;
1295
+
1296
+ g_assert(hash != NULL);
1297
+
1298
+ value = g_hash_table_lookup(hash, "integer");
1299
+ g_assert(value != NULL);
1300
+ g_assert(G_VALUE_HOLDS_INT(value));
1301
+ g_assert(g_value_get_int(value) == 12);
1302
+
1303
+ value = g_hash_table_lookup(hash, "boolean");
1304
+ g_assert(value != NULL);
1305
+ g_assert(G_VALUE_HOLDS_BOOLEAN(value));
1306
+ g_assert(g_value_get_boolean(value) == TRUE);
1307
+
1308
+ value = g_hash_table_lookup(hash, "string");
1309
+ g_assert(value != NULL);
1310
+ g_assert(G_VALUE_HOLDS_STRING(value));
1311
+ g_assert(strcmp(g_value_get_string(value), "some text") == 0);
1312
+
1313
+ value = g_hash_table_lookup(hash, "strings");
1314
+ g_assert(value != NULL);
1315
+ g_assert(G_VALUE_HOLDS(value, G_TYPE_STRV));
1316
+ strings = g_value_get_boxed(value);
1317
+ g_assert(strings != NULL);
1318
+ for (i = 0; string_array[i] != NULL; i++)
1319
+ g_assert(strcmp(strings[i], string_array[i]) == 0);
1320
+
1321
+ value = g_hash_table_lookup(hash, "flags");
1322
+ g_assert(value != NULL);
1323
+ g_assert(G_VALUE_HOLDS_FLAGS(value));
1324
+ g_assert(g_value_get_flags(value) == (REGRESS_TEST_FLAG1 | REGRESS_TEST_FLAG3));
1325
+
1326
+ value = g_hash_table_lookup(hash, "enum");
1327
+ g_assert(value != NULL);
1328
+ g_assert(G_VALUE_HOLDS_ENUM(value));
1329
+ g_assert(g_value_get_enum(value) == REGRESS_TEST_VALUE2);
1330
+ }
1331
+
1332
+ /**
1333
+ * regress_test_ghash_container_return:
1334
+ *
1335
+ * Return value: (element-type utf8 utf8) (transfer container):
1336
+ */
1337
+ GHashTable *
1338
+ regress_test_ghash_container_return (void)
1339
+ {
1340
+ return regress_test_table_ghash_new_container ();
1341
+ }
1342
+
1343
+ /**
1344
+ * regress_test_ghash_everything_return:
1345
+ *
1346
+ * Return value: (element-type utf8 utf8) (transfer full):
1347
+ */
1348
+ GHashTable *
1349
+ regress_test_ghash_everything_return (void)
1350
+ {
1351
+ return regress_test_table_ghash_new_full ();
1352
+ }
1353
+
1354
+ static void
1355
+ assert_test_table_ghash (const GHashTable *in)
1356
+ {
1357
+ GHashTable *h = regress_test_table_ghash_const();
1358
+ GHashTableIter iter;
1359
+ gpointer key, value;
1360
+
1361
+ g_assert(g_hash_table_size(h) ==
1362
+ g_hash_table_size((GHashTable*)in));
1363
+
1364
+ g_hash_table_iter_init(&iter, (GHashTable*)in);
1365
+ while (g_hash_table_iter_next (&iter, &key, &value))
1366
+ g_assert( strcmp(g_hash_table_lookup(h, (char*)key), (char*)value) == 0);
1367
+ }
1368
+
1369
+ /**
1370
+ * regress_test_ghash_null_in:
1371
+ * @in: (element-type utf8 utf8) (allow-none):
1372
+ */
1373
+ void
1374
+ regress_test_ghash_null_in (const GHashTable *in)
1375
+ {
1376
+ g_assert (in == NULL);
1377
+ }
1378
+
1379
+ /**
1380
+ * regress_test_ghash_null_out:
1381
+ * @out: (element-type utf8 utf8) (allow-none) (out):
1382
+ */
1383
+ void
1384
+ regress_test_ghash_null_out (const GHashTable **out)
1385
+ {
1386
+ *out = NULL;
1387
+ }
1388
+
1389
+ /**
1390
+ * regress_test_ghash_nothing_in:
1391
+ * @in: (element-type utf8 utf8):
1392
+ */
1393
+ void
1394
+ regress_test_ghash_nothing_in (const GHashTable *in)
1395
+ {
1396
+ assert_test_table_ghash (in);
1397
+ }
1398
+
1399
+ /**
1400
+ * regress_test_ghash_nothing_in2:
1401
+ * @in: (element-type utf8 utf8):
1402
+ */
1403
+ void
1404
+ regress_test_ghash_nothing_in2 (GHashTable *in)
1405
+ {
1406
+ assert_test_table_ghash (in);
1407
+ }
1408
+
1409
+ /* Nested collection types */
1410
+
1411
+ /**
1412
+ * regress_test_ghash_nested_everything_return:
1413
+ *
1414
+ * Specify nested parameterized types directly with the (type ) annotation.
1415
+ *
1416
+ * Return value: (type GLib.HashTable<utf8,GLib.HashTable<utf8,utf8>>) (transfer full):
1417
+ */
1418
+ GHashTable *
1419
+ regress_test_ghash_nested_everything_return (void)
1420
+ {
1421
+ GHashTable *hash;
1422
+ hash = g_hash_table_new_full(g_str_hash, g_str_equal, g_free,
1423
+ (void (*) (gpointer)) g_hash_table_destroy);
1424
+ g_hash_table_insert(hash, g_strdup("wibble"), regress_test_table_ghash_new_full());
1425
+ return hash;
1426
+ }
1427
+
1428
+ /**
1429
+ * regress_test_ghash_nested_everything_return2:
1430
+ *
1431
+ * Another way of specifying nested parameterized types: using the
1432
+ * element-type annotation.
1433
+ *
1434
+ * Return value: (element-type utf8 GLib.HashTable<utf8,utf8>) (transfer full):
1435
+ */
1436
+ GHashTable *
1437
+ regress_test_ghash_nested_everything_return2 (void)
1438
+ {
1439
+ return regress_test_ghash_nested_everything_return();
1440
+ }
1441
+
1442
+ /************************************************************************/
1443
+
1444
+ /**
1445
+ * regress_test_garray_container_return:
1446
+ *
1447
+ * Returns: (transfer container) (type GLib.PtrArray) (element-type utf8):
1448
+ */
1449
+ GPtrArray *
1450
+ regress_test_garray_container_return (void)
1451
+ {
1452
+ GPtrArray *array;
1453
+
1454
+ array = g_ptr_array_new_with_free_func (g_free);
1455
+ g_ptr_array_add (array, g_strdup ("regress"));
1456
+
1457
+ return array;
1458
+ }
1459
+
1460
+ /**
1461
+ * regress_test_garray_full_return:
1462
+ *
1463
+ * Returns: (transfer full) (type GLib.PtrArray) (element-type utf8):
1464
+ */
1465
+ GPtrArray *
1466
+ regress_test_garray_full_return (void)
1467
+ {
1468
+ GPtrArray *array;
1469
+
1470
+ array = g_ptr_array_new ();
1471
+ g_ptr_array_add (array, g_strdup ("regress"));
1472
+
1473
+ return array;
1474
+ }
1475
+
1476
+ /************************************************************************/
1477
+
1478
+ /* error? */
1479
+
1480
+ /* enums / flags */
1481
+
1482
+ /**
1483
+ * NUM_REGRESS_FOO: (skip)
1484
+ *
1485
+ * num of elements in RegressFoo
1486
+ */
1487
+
1488
+ GType
1489
+ regress_test_enum_get_type (void)
1490
+ {
1491
+ static GType etype = 0;
1492
+ if (G_UNLIKELY(etype == 0)) {
1493
+ static const GEnumValue values[] = {
1494
+ { REGRESS_TEST_VALUE1, "REGRESS_TEST_VALUE1", "value1" },
1495
+ { REGRESS_TEST_VALUE2, "REGRESS_TEST_VALUE2", "value2" },
1496
+ { REGRESS_TEST_VALUE3, "REGRESS_TEST_VALUE3", "value3" },
1497
+ { REGRESS_TEST_VALUE4, "REGRESS_TEST_VALUE4", "value4" },
1498
+ { 0, NULL, NULL }
1499
+ };
1500
+ etype = g_enum_register_static (g_intern_static_string ("RegressTestEnum"), values);
1501
+ }
1502
+
1503
+ return etype;
1504
+ }
1505
+
1506
+ GType
1507
+ regress_test_enum_unsigned_get_type (void)
1508
+ {
1509
+ static GType etype = 0;
1510
+ if (G_UNLIKELY(etype == 0)) {
1511
+ static const GEnumValue values[] = {
1512
+ { REGRESS_TEST_UNSIGNED_VALUE1, "REGRESS_TEST_UNSIGNED_VALUE1", "value1" },
1513
+ { REGRESS_TEST_UNSIGNED_VALUE2, "REGRESS_TEST_UNSIGNED_VALUE2", "value2" },
1514
+ { 0, NULL, NULL }
1515
+ };
1516
+ etype = g_enum_register_static (g_intern_static_string ("RegressTestEnumUnsigned"), values);
1517
+ }
1518
+
1519
+ return etype;
1520
+ }
1521
+
1522
+ GType
1523
+ regress_test_flags_get_type (void)
1524
+ {
1525
+ static GType etype = 0;
1526
+ if (G_UNLIKELY(etype == 0)) {
1527
+ static const GFlagsValue values[] = {
1528
+ { REGRESS_TEST_FLAG1, "TEST_FLAG1", "flag1" },
1529
+ { REGRESS_TEST_FLAG2, "TEST_FLAG2", "flag2" },
1530
+ { REGRESS_TEST_FLAG3, "TEST_FLAG3", "flag3" },
1531
+ { 0, NULL, NULL }
1532
+ };
1533
+ etype = g_flags_register_static (g_intern_static_string ("RegressTestFlags"), values);
1534
+ }
1535
+
1536
+ return etype;
1537
+ }
1538
+
1539
+ const gchar *
1540
+ regress_test_enum_param(RegressTestEnum e)
1541
+ {
1542
+ GEnumValue *ev;
1543
+ GEnumClass *ec;
1544
+
1545
+ ec = g_type_class_ref (regress_test_enum_get_type ());
1546
+ ev = g_enum_get_value (ec, e);
1547
+ g_type_class_unref (ec);
1548
+
1549
+ return ev->value_nick;
1550
+ }
1551
+
1552
+ const gchar *
1553
+ regress_test_unsigned_enum_param(RegressTestEnumUnsigned e)
1554
+ {
1555
+ GEnumValue *ev;
1556
+ GEnumClass *ec;
1557
+
1558
+ ec = g_type_class_ref (regress_test_enum_unsigned_get_type ());
1559
+ ev = g_enum_get_value (ec, e);
1560
+ g_type_class_unref (ec);
1561
+
1562
+ return ev->value_nick;
1563
+ }
1564
+
1565
+ /**
1566
+ * regress_global_get_flags_out:
1567
+ * @v: (out): A flags value
1568
+ *
1569
+ */
1570
+ void
1571
+ regress_global_get_flags_out (RegressTestFlags *v)
1572
+ {
1573
+ *v = REGRESS_TEST_FLAG1 | REGRESS_TEST_FLAG3;
1574
+ }
1575
+
1576
+ /* error domains */
1577
+
1578
+ GType
1579
+ regress_test_error_get_type (void)
1580
+ {
1581
+ static GType etype = 0;
1582
+ if (G_UNLIKELY(etype == 0)) {
1583
+ static const GEnumValue values[] = {
1584
+ { REGRESS_TEST_ERROR_CODE1, "REGRESS_TEST_ERROR_CODE1", "code1" },
1585
+ { REGRESS_TEST_ERROR_CODE2, "REGRESS_TEST_ERROR_CODE2", "code2" },
1586
+ { REGRESS_TEST_ERROR_CODE3, "REGRESS_TEST_ERROR_CODE3", "code3" },
1587
+ { 0, NULL, NULL }
1588
+ };
1589
+ etype = g_enum_register_static (g_intern_static_string ("RegressTestError"), values);
1590
+ }
1591
+
1592
+ return etype;
1593
+ }
1594
+
1595
+ GQuark
1596
+ regress_test_error_quark (void)
1597
+ {
1598
+ return g_quark_from_static_string ("regress-test-error");
1599
+ }
1600
+
1601
+ GType
1602
+ regress_test_abc_error_get_type (void)
1603
+ {
1604
+ static GType etype = 0;
1605
+ if (G_UNLIKELY(etype == 0)) {
1606
+ static const GEnumValue values[] = {
1607
+ { REGRESS_TEST_ABC_ERROR_CODE1, "REGRESS_TEST_ABC_ERROR_CODE1", "code1" },
1608
+ { REGRESS_TEST_ABC_ERROR_CODE2, "REGRESS_TEST_ABC_ERROR_CODE2", "code2" },
1609
+ { REGRESS_TEST_ABC_ERROR_CODE3, "REGRESS_TEST_ABC_ERROR_CODE3", "code3" },
1610
+ { 0, NULL, NULL }
1611
+ };
1612
+ etype = g_enum_register_static (g_intern_static_string ("RegressTestABCError"), values);
1613
+ }
1614
+
1615
+ return etype;
1616
+ }
1617
+
1618
+ GQuark
1619
+ regress_test_abc_error_quark (void)
1620
+ {
1621
+ return g_quark_from_static_string ("regress-test-abc-error");
1622
+ }
1623
+
1624
+ GType
1625
+ regress_test_unconventional_error_get_type (void)
1626
+ {
1627
+ static GType etype = 0;
1628
+ if (G_UNLIKELY(etype == 0)) {
1629
+ static const GEnumValue values[] = {
1630
+ { REGRESS_TEST_OTHER_ERROR_CODE1, "REGRESS_TEST_OTHER_ERROR_CODE1", "code1" },
1631
+ { REGRESS_TEST_OTHER_ERROR_CODE2, "REGRESS_TEST_OTHER_ERROR_CODE2", "code2" },
1632
+ { REGRESS_TEST_OTHER_ERROR_CODE3, "REGRESS_TEST_OTHER_ERROR_CODE3", "code3" },
1633
+ { 0, NULL, NULL }
1634
+ };
1635
+ etype = g_enum_register_static (g_intern_static_string ("RegressTestOtherError"), values);
1636
+ }
1637
+
1638
+ return etype;
1639
+ }
1640
+
1641
+ GQuark
1642
+ regress_test_unconventional_error_quark (void)
1643
+ {
1644
+ return g_quark_from_static_string ("regress-test-other-error");
1645
+ }
1646
+
1647
+
1648
+ GQuark
1649
+ regress_test_def_error_quark (void)
1650
+ {
1651
+ return g_quark_from_static_string ("regress-test-def-error");
1652
+ }
1653
+
1654
+ GQuark
1655
+ regress_atest_error_quark (void)
1656
+ {
1657
+ return g_quark_from_static_string ("regress-atest-error");
1658
+ }
1659
+
1660
+ /* structures */
1661
+
1662
+ /**
1663
+ * regress_test_struct_a_clone:
1664
+ * @a: the structure
1665
+ * @a_out: (out caller-allocates): the cloned structure
1666
+ *
1667
+ * Make a copy of a RegressTestStructA
1668
+ */
1669
+ void
1670
+ regress_test_struct_a_clone (RegressTestStructA *a,
1671
+ RegressTestStructA *a_out)
1672
+ {
1673
+ *a_out = *a;
1674
+ }
1675
+
1676
+ /**
1677
+ * regress_test_struct_a_parse:
1678
+ * @a_out: (out caller-allocates): the structure that is to be filled
1679
+ * @string: ignored
1680
+ */
1681
+ void
1682
+ regress_test_struct_a_parse (RegressTestStructA *a_out,
1683
+ const gchar *string)
1684
+ {
1685
+ a_out->some_int = 23;
1686
+ }
1687
+
1688
+ /**
1689
+ * regress_test_struct_b_clone:
1690
+ * @b: the structure
1691
+ * @b_out: (out): the cloned structure
1692
+ *
1693
+ * Make a copy of a RegressTestStructB
1694
+ */
1695
+ void
1696
+ regress_test_struct_b_clone (RegressTestStructB *b,
1697
+ RegressTestStructB *b_out)
1698
+ {
1699
+ *b_out = *b;
1700
+ }
1701
+
1702
+ /* plain-old-data boxed types */
1703
+
1704
+ RegressTestSimpleBoxedA *
1705
+ regress_test_simple_boxed_a_copy (RegressTestSimpleBoxedA *a)
1706
+ {
1707
+ RegressTestSimpleBoxedA *new_a = g_slice_new (RegressTestSimpleBoxedA);
1708
+
1709
+ *new_a = *a;
1710
+
1711
+ return new_a;
1712
+ }
1713
+
1714
+ static void
1715
+ regress_test_simple_boxed_a_free (RegressTestSimpleBoxedA *a)
1716
+ {
1717
+ g_slice_free (RegressTestSimpleBoxedA, a);
1718
+ }
1719
+
1720
+ GType
1721
+ regress_test_simple_boxed_a_get_gtype (void)
1722
+ {
1723
+ static GType our_type = 0;
1724
+
1725
+ if (our_type == 0)
1726
+ our_type = g_boxed_type_register_static (g_intern_static_string ("RegressTestSimpleBoxedA"),
1727
+ (GBoxedCopyFunc)regress_test_simple_boxed_a_copy,
1728
+ (GBoxedFreeFunc)regress_test_simple_boxed_a_free);
1729
+ return our_type;
1730
+ }
1731
+
1732
+ RegressTestSimpleBoxedB *
1733
+ regress_test_simple_boxed_b_copy (RegressTestSimpleBoxedB *b)
1734
+ {
1735
+ RegressTestSimpleBoxedB *new_b = g_slice_new (RegressTestSimpleBoxedB);
1736
+
1737
+ *new_b = *b;
1738
+
1739
+ return new_b;
1740
+ }
1741
+
1742
+ gboolean
1743
+ regress_test_simple_boxed_a_equals (RegressTestSimpleBoxedA *a,
1744
+ RegressTestSimpleBoxedA *other_a)
1745
+ {
1746
+ return (a->some_int == other_a->some_int &&
1747
+ a->some_int8 == other_a->some_int8 &&
1748
+ a->some_double == other_a->some_double);
1749
+ }
1750
+
1751
+ const RegressTestSimpleBoxedA*
1752
+ regress_test_simple_boxed_a_const_return (void)
1753
+ {
1754
+ static RegressTestSimpleBoxedA simple_a = {
1755
+ 5, 6, 7.0
1756
+ };
1757
+
1758
+ return &simple_a;
1759
+ }
1760
+
1761
+ static void
1762
+ regress_test_simple_boxed_b_free (RegressTestSimpleBoxedB *a)
1763
+ {
1764
+ g_slice_free (RegressTestSimpleBoxedB, a);
1765
+ }
1766
+
1767
+ GType
1768
+ regress_test_simple_boxed_b_get_type (void)
1769
+ {
1770
+ static GType our_type = 0;
1771
+
1772
+ if (our_type == 0)
1773
+ our_type = g_boxed_type_register_static (g_intern_static_string ("RegressTestSimpleBoxedB"),
1774
+ (GBoxedCopyFunc)regress_test_simple_boxed_b_copy,
1775
+ (GBoxedFreeFunc)regress_test_simple_boxed_b_free);
1776
+ return our_type;
1777
+ }
1778
+
1779
+ /* opaque boxed */
1780
+
1781
+ struct _RegressTestBoxedPrivate
1782
+ {
1783
+ guint magic;
1784
+ };
1785
+
1786
+ /**
1787
+ * regress_test_boxed_new:
1788
+ *
1789
+ * Returns: (transfer full):
1790
+ */
1791
+ RegressTestBoxed *
1792
+ regress_test_boxed_new (void)
1793
+ {
1794
+ RegressTestBoxed *boxed = g_slice_new0(RegressTestBoxed);
1795
+ boxed->priv = g_slice_new0(RegressTestBoxedPrivate);
1796
+ boxed->priv->magic = 0xdeadbeef;
1797
+
1798
+ return boxed;
1799
+ }
1800
+
1801
+ /**
1802
+ * regress_test_boxed_new_alternative_constructor1:
1803
+ *
1804
+ * Returns: (transfer full):
1805
+ */
1806
+ RegressTestBoxed *
1807
+ regress_test_boxed_new_alternative_constructor1 (int i)
1808
+ {
1809
+ RegressTestBoxed *boxed = g_slice_new0(RegressTestBoxed);
1810
+ boxed->priv = g_slice_new0(RegressTestBoxedPrivate);
1811
+ boxed->priv->magic = 0xdeadbeef;
1812
+ boxed->some_int8 = i;
1813
+
1814
+ return boxed;
1815
+ }
1816
+
1817
+ /**
1818
+ * regress_test_boxed_new_alternative_constructor2:
1819
+ *
1820
+ * Returns: (transfer full):
1821
+ */
1822
+ RegressTestBoxed *
1823
+ regress_test_boxed_new_alternative_constructor2 (int i, int j)
1824
+ {
1825
+ RegressTestBoxed *boxed = g_slice_new0(RegressTestBoxed);
1826
+ boxed->priv = g_slice_new0(RegressTestBoxedPrivate);
1827
+ boxed->priv->magic = 0xdeadbeef;
1828
+ boxed->some_int8 = i + j;
1829
+
1830
+ return boxed;
1831
+ }
1832
+
1833
+ /**
1834
+ * regress_test_boxed_new_alternative_constructor3:
1835
+ *
1836
+ * Returns: (transfer full):
1837
+ */
1838
+ RegressTestBoxed *
1839
+ regress_test_boxed_new_alternative_constructor3 (char *s)
1840
+ {
1841
+ RegressTestBoxed *boxed = g_slice_new0(RegressTestBoxed);
1842
+ boxed->priv = g_slice_new0(RegressTestBoxedPrivate);
1843
+ boxed->priv->magic = 0xdeadbeef;
1844
+ boxed->some_int8 = atoi(s);
1845
+
1846
+ return boxed;
1847
+ }
1848
+
1849
+ /**
1850
+ * regress_test_boxed_copy:
1851
+ *
1852
+ * Returns: (transfer full):
1853
+ */
1854
+ RegressTestBoxed *
1855
+ regress_test_boxed_copy (RegressTestBoxed *boxed)
1856
+ {
1857
+ RegressTestBoxed *new_boxed = regress_test_boxed_new();
1858
+ RegressTestBoxedPrivate *save;
1859
+
1860
+ save = new_boxed->priv;
1861
+ *new_boxed = *boxed;
1862
+ new_boxed->priv = save;
1863
+
1864
+ return new_boxed;
1865
+ }
1866
+
1867
+ gboolean
1868
+ regress_test_boxed_equals (RegressTestBoxed *boxed,
1869
+ RegressTestBoxed *other)
1870
+ {
1871
+ return (other->some_int8 == boxed->some_int8 &&
1872
+ regress_test_simple_boxed_a_equals(&other->nested_a, &boxed->nested_a));
1873
+ }
1874
+
1875
+ static void
1876
+ regress_test_boxed_free (RegressTestBoxed *boxed)
1877
+ {
1878
+ g_assert (boxed->priv->magic == 0xdeadbeef);
1879
+
1880
+ g_slice_free (RegressTestBoxedPrivate, boxed->priv);
1881
+ g_slice_free (RegressTestBoxed, boxed);
1882
+ }
1883
+
1884
+ GType
1885
+ regress_test_boxed_get_type (void)
1886
+ {
1887
+ static GType our_type = 0;
1888
+
1889
+ if (our_type == 0)
1890
+ our_type = g_boxed_type_register_static (g_intern_static_string ("RegressTestBoxed"),
1891
+ (GBoxedCopyFunc)regress_test_boxed_copy,
1892
+ (GBoxedFreeFunc)regress_test_boxed_free);
1893
+ return our_type;
1894
+ }
1895
+
1896
+ RegressTestBoxedB *
1897
+ regress_test_boxed_b_new (gint8 some_int8, glong some_long)
1898
+ {
1899
+ RegressTestBoxedB *boxed;
1900
+
1901
+ boxed = g_slice_new (RegressTestBoxedB);
1902
+ boxed->some_int8 = some_int8;
1903
+ boxed->some_long = some_long;
1904
+
1905
+ return boxed;
1906
+ }
1907
+
1908
+ RegressTestBoxedB *
1909
+ regress_test_boxed_b_copy (RegressTestBoxedB *boxed)
1910
+ {
1911
+ return regress_test_boxed_b_new (boxed->some_int8, boxed->some_long);
1912
+ }
1913
+
1914
+ static void
1915
+ regress_test_boxed_b_free (RegressTestBoxedB *boxed)
1916
+ {
1917
+ g_slice_free (RegressTestBoxedB, boxed);
1918
+ }
1919
+
1920
+ G_DEFINE_BOXED_TYPE(RegressTestBoxedB,
1921
+ regress_test_boxed_b,
1922
+ regress_test_boxed_b_copy,
1923
+ regress_test_boxed_b_free);
1924
+
1925
+ RegressTestBoxedC *
1926
+ regress_test_boxed_c_new (void)
1927
+ {
1928
+ RegressTestBoxedC *boxed;
1929
+
1930
+ boxed = g_slice_new (RegressTestBoxedC);
1931
+ boxed->refcount = 1;
1932
+ boxed->another_thing = 42; /* what else */
1933
+
1934
+ return boxed;
1935
+ }
1936
+
1937
+ static RegressTestBoxedC *
1938
+ regress_test_boxed_c_ref (RegressTestBoxedC *boxed)
1939
+ {
1940
+ g_atomic_int_inc (&boxed->refcount);
1941
+ return boxed;
1942
+ }
1943
+
1944
+ static void
1945
+ regress_test_boxed_c_unref (RegressTestBoxedC *boxed)
1946
+ {
1947
+ if (g_atomic_int_dec_and_test (&boxed->refcount)) {
1948
+ g_slice_free (RegressTestBoxedC, boxed);
1949
+ }
1950
+ }
1951
+
1952
+ G_DEFINE_BOXED_TYPE(RegressTestBoxedC,
1953
+ regress_test_boxed_c,
1954
+ regress_test_boxed_c_ref,
1955
+ regress_test_boxed_c_unref);
1956
+
1957
+ struct _RegressTestBoxedD {
1958
+ char *a_string;
1959
+ gint a_int;
1960
+ };
1961
+
1962
+ RegressTestBoxedD *
1963
+ regress_test_boxed_d_new (const char *a_string, int a_int)
1964
+ {
1965
+ RegressTestBoxedD *boxed;
1966
+
1967
+ boxed = g_slice_new (RegressTestBoxedD);
1968
+ boxed->a_string = g_strdup (a_string);
1969
+ boxed->a_int = a_int;
1970
+
1971
+ return boxed;
1972
+ }
1973
+
1974
+ RegressTestBoxedD *
1975
+ regress_test_boxed_d_copy (RegressTestBoxedD *boxed)
1976
+ {
1977
+ RegressTestBoxedD *ret;
1978
+
1979
+ ret = g_slice_new (RegressTestBoxedD);
1980
+ ret->a_string = g_strdup (boxed->a_string);
1981
+ ret->a_int = boxed->a_int;
1982
+
1983
+ return ret;
1984
+ }
1985
+
1986
+ void
1987
+ regress_test_boxed_d_free (RegressTestBoxedD *boxed)
1988
+ {
1989
+ g_free (boxed->a_string);
1990
+ g_slice_free (RegressTestBoxedD, boxed);
1991
+ }
1992
+
1993
+ int
1994
+ regress_test_boxed_d_get_magic (RegressTestBoxedD *boxed)
1995
+ {
1996
+ return strlen (boxed->a_string) + boxed->a_int;
1997
+ }
1998
+
1999
+ G_DEFINE_BOXED_TYPE(RegressTestBoxedD,
2000
+ regress_test_boxed_d,
2001
+ regress_test_boxed_d_copy,
2002
+ regress_test_boxed_d_free);
2003
+
2004
+ G_DEFINE_TYPE(RegressTestObj, regress_test_obj, G_TYPE_OBJECT);
2005
+
2006
+ enum
2007
+ {
2008
+ PROP_TEST_OBJ_BARE = 1,
2009
+ PROP_TEST_OBJ_BOXED,
2010
+ PROP_TEST_OBJ_HASH_TABLE,
2011
+ PROP_TEST_OBJ_LIST,
2012
+ PROP_TEST_OBJ_HASH_TABLE_OLD,
2013
+ PROP_TEST_OBJ_LIST_OLD,
2014
+ PROP_TEST_OBJ_INT,
2015
+ PROP_TEST_OBJ_FLOAT,
2016
+ PROP_TEST_OBJ_DOUBLE,
2017
+ PROP_TEST_OBJ_STRING,
2018
+ PROP_TEST_OBJ_GTYPE
2019
+ };
2020
+
2021
+ static void
2022
+ regress_test_obj_set_property (GObject *object,
2023
+ guint property_id,
2024
+ const GValue *value,
2025
+ GParamSpec *pspec)
2026
+ {
2027
+ RegressTestObj *self = REGRESS_TEST_OBJECT (object);
2028
+ GList *list;
2029
+
2030
+ switch (property_id)
2031
+ {
2032
+ case PROP_TEST_OBJ_BARE:
2033
+ regress_test_obj_set_bare (self, g_value_get_object (value));
2034
+ break;
2035
+
2036
+ case PROP_TEST_OBJ_BOXED:
2037
+ if (self->boxed)
2038
+ regress_test_boxed_free (self->boxed);
2039
+ self->boxed = g_value_dup_boxed (value);
2040
+ break;
2041
+
2042
+ case PROP_TEST_OBJ_HASH_TABLE:
2043
+ case PROP_TEST_OBJ_HASH_TABLE_OLD:
2044
+ if (self->hash_table)
2045
+ g_hash_table_unref (self->hash_table);
2046
+ self->hash_table = g_hash_table_ref (g_value_get_boxed (value));
2047
+ break;
2048
+
2049
+ case PROP_TEST_OBJ_LIST:
2050
+ case PROP_TEST_OBJ_LIST_OLD:
2051
+ if (self->list != NULL)
2052
+ {
2053
+ for (list = self->list; list != NULL; list = g_list_next (list))
2054
+ g_free (list->data);
2055
+ g_list_free (self->list);
2056
+ }
2057
+ self->list = NULL;
2058
+ for (list = g_value_get_pointer (value); list != NULL; list = g_list_next (list))
2059
+ self->list = g_list_append (self->list, g_strdup (list->data));
2060
+ break;
2061
+
2062
+ case PROP_TEST_OBJ_INT:
2063
+ self->some_int8 = g_value_get_int (value);
2064
+ break;
2065
+
2066
+ case PROP_TEST_OBJ_FLOAT:
2067
+ self->some_float = g_value_get_float (value);
2068
+ break;
2069
+
2070
+ case PROP_TEST_OBJ_DOUBLE:
2071
+ self->some_double = g_value_get_double (value);
2072
+ break;
2073
+
2074
+ case PROP_TEST_OBJ_STRING:
2075
+ self->string = g_value_dup_string (value);
2076
+ break;
2077
+
2078
+ case PROP_TEST_OBJ_GTYPE:
2079
+ self->gtype = g_value_get_gtype (value);
2080
+ break;
2081
+
2082
+ default:
2083
+ /* We don't have any other property... */
2084
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
2085
+ break;
2086
+ }
2087
+ }
2088
+
2089
+ static void
2090
+ regress_test_obj_get_property (GObject *object,
2091
+ guint property_id,
2092
+ GValue *value,
2093
+ GParamSpec *pspec)
2094
+ {
2095
+ RegressTestObj *self = REGRESS_TEST_OBJECT (object);
2096
+
2097
+ switch (property_id)
2098
+ {
2099
+ case PROP_TEST_OBJ_BARE:
2100
+ g_value_set_object (value, self->bare);
2101
+ break;
2102
+
2103
+ case PROP_TEST_OBJ_BOXED:
2104
+ g_value_set_boxed (value, self->boxed);
2105
+ break;
2106
+
2107
+ case PROP_TEST_OBJ_HASH_TABLE:
2108
+ case PROP_TEST_OBJ_HASH_TABLE_OLD:
2109
+ if (self->hash_table != NULL)
2110
+ g_hash_table_ref (self->hash_table);
2111
+ g_value_set_boxed (value, self->hash_table);
2112
+ break;
2113
+
2114
+ case PROP_TEST_OBJ_LIST:
2115
+ case PROP_TEST_OBJ_LIST_OLD:
2116
+ g_value_set_pointer (value, self->list);
2117
+ break;
2118
+
2119
+ case PROP_TEST_OBJ_INT:
2120
+ g_value_set_int (value, self->some_int8);
2121
+ break;
2122
+
2123
+ case PROP_TEST_OBJ_FLOAT:
2124
+ g_value_set_float (value, self->some_float);
2125
+ break;
2126
+
2127
+ case PROP_TEST_OBJ_DOUBLE:
2128
+ g_value_set_double (value, self->some_double);
2129
+ break;
2130
+
2131
+ case PROP_TEST_OBJ_STRING:
2132
+ g_value_set_string (value, self->string);
2133
+ break;
2134
+
2135
+ case PROP_TEST_OBJ_GTYPE:
2136
+ g_value_set_gtype (value, self->gtype);
2137
+ break;
2138
+
2139
+ default:
2140
+ /* We don't have any other property... */
2141
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
2142
+ break;
2143
+ }
2144
+ }
2145
+
2146
+ static void
2147
+ regress_test_obj_dispose (GObject *gobject)
2148
+ {
2149
+ RegressTestObj *self = REGRESS_TEST_OBJECT (gobject);
2150
+
2151
+ if (self->bare)
2152
+ {
2153
+ g_object_unref (self->bare);
2154
+
2155
+ self->bare = NULL;
2156
+ }
2157
+
2158
+ if (self->boxed)
2159
+ {
2160
+ regress_test_boxed_free (self->boxed);
2161
+ self->boxed = NULL;
2162
+ }
2163
+
2164
+ /* Chain up to the parent class */
2165
+ G_OBJECT_CLASS (regress_test_obj_parent_class)->dispose (gobject);
2166
+ }
2167
+
2168
+ static int
2169
+ regress_test_obj_default_matrix (RegressTestObj *obj, const char *somestr)
2170
+ {
2171
+ return 42;
2172
+ }
2173
+
2174
+ enum {
2175
+ REGRESS_TEST_OBJ_SIGNAL_SIG_NEW_WITH_ARRAY_PROP,
2176
+ REGRESS_TEST_OBJ_SIGNAL_SIG_NEW_WITH_ARRAY_LEN_PROP,
2177
+ REGRESS_TEST_OBJ_SIGNAL_SIG_WITH_HASH_PROP,
2178
+ REGRESS_TEST_OBJ_SIGNAL_SIG_WITH_STRV,
2179
+ REGRESS_TEST_OBJ_SIGNAL_SIG_WITH_OBJ,
2180
+ REGRESS_TEST_OBJ_SIGNAL_SIG_WITH_FOREIGN_STRUCT,
2181
+ REGRESS_TEST_OBJ_SIGNAL_FIRST,
2182
+ REGRESS_TEST_OBJ_SIGNAL_CLEANUP,
2183
+ REGRESS_TEST_OBJ_SIGNAL_ALL,
2184
+ REGRESS_TEST_OBJ_SIGNAL_SIG_WITH_INT64_PROP,
2185
+ REGRESS_TEST_OBJ_SIGNAL_SIG_WITH_UINT64_PROP,
2186
+ REGRESS_TEST_OBJ_SIGNAL_SIG_WITH_INTARRAY_RET,
2187
+ N_REGRESS_TEST_OBJ_SIGNALS
2188
+ };
2189
+
2190
+ static guint regress_test_obj_signals[N_REGRESS_TEST_OBJ_SIGNALS] = { 0 };
2191
+
2192
+ static void
2193
+ regress_test_obj_class_init (RegressTestObjClass *klass)
2194
+ {
2195
+ GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
2196
+ GParamSpec *pspec;
2197
+ GType param_types[1];
2198
+
2199
+ klass->test_signal =
2200
+ g_signal_newv ("test",
2201
+ G_TYPE_FROM_CLASS (gobject_class),
2202
+ G_SIGNAL_RUN_LAST | G_SIGNAL_NO_RECURSE | G_SIGNAL_NO_HOOKS,
2203
+ NULL /* closure */,
2204
+ NULL /* accumulator */,
2205
+ NULL /* accumulator data */,
2206
+ g_cclosure_marshal_VOID__VOID,
2207
+ G_TYPE_NONE /* return_type */,
2208
+ 0 /* n_params */,
2209
+ NULL /* param_types */);
2210
+
2211
+ param_types[0] = regress_test_simple_boxed_a_get_gtype() | G_SIGNAL_TYPE_STATIC_SCOPE;
2212
+ klass->test_signal_with_static_scope_arg =
2213
+ g_signal_newv ("test-with-static-scope-arg",
2214
+ G_TYPE_FROM_CLASS (gobject_class),
2215
+ G_SIGNAL_RUN_LAST | G_SIGNAL_NO_RECURSE | G_SIGNAL_NO_HOOKS,
2216
+ NULL /* closure */,
2217
+ NULL /* accumulator */,
2218
+ NULL /* accumulator data */,
2219
+ g_cclosure_marshal_VOID__BOXED,
2220
+ G_TYPE_NONE /* return_type */,
2221
+ 1 /* n_params */,
2222
+ param_types);
2223
+
2224
+ /**
2225
+ * RegressTestObj::sig-with-array-prop:
2226
+ * @self: an object
2227
+ * @arr: (type GArray) (element-type uint): numbers
2228
+ *
2229
+ * This test signal is like TelepathyGlib's
2230
+ * TpChannel:: group-members-changed-detailed:
2231
+ */
2232
+ regress_test_obj_signals[REGRESS_TEST_OBJ_SIGNAL_SIG_NEW_WITH_ARRAY_PROP] =
2233
+ g_signal_new ("sig-with-array-prop",
2234
+ G_TYPE_FROM_CLASS (gobject_class),
2235
+ G_SIGNAL_RUN_LAST,
2236
+ 0,
2237
+ NULL,
2238
+ NULL,
2239
+ g_cclosure_marshal_VOID__BOXED,
2240
+ G_TYPE_NONE,
2241
+ 1,
2242
+ G_TYPE_ARRAY);
2243
+
2244
+ /**
2245
+ * RegressTestObj::sig-with-array-len-prop:
2246
+ * @self: an object
2247
+ * @arr: (array length=len) (element-type uint) (allow-none): numbers, or %NULL
2248
+ * @len: length of @arr, or 0
2249
+ *
2250
+ * This test signal similar to GSettings::change-event
2251
+ */
2252
+ regress_test_obj_signals[REGRESS_TEST_OBJ_SIGNAL_SIG_NEW_WITH_ARRAY_LEN_PROP] =
2253
+ g_signal_new ("sig-with-array-len-prop",
2254
+ G_TYPE_FROM_CLASS (gobject_class),
2255
+ G_SIGNAL_RUN_LAST,
2256
+ 0,
2257
+ NULL,
2258
+ NULL,
2259
+ NULL,
2260
+ G_TYPE_NONE,
2261
+ 2,
2262
+ G_TYPE_POINTER,
2263
+ G_TYPE_INT);
2264
+
2265
+ /**
2266
+ * RegressTestObj::sig-with-hash-prop:
2267
+ * @self: an object
2268
+ * @hash: (element-type utf8 GObject.Value):
2269
+ *
2270
+ * This test signal is like TelepathyGlib's
2271
+ * TpAccount::status-changed
2272
+ */
2273
+ regress_test_obj_signals[REGRESS_TEST_OBJ_SIGNAL_SIG_WITH_HASH_PROP] =
2274
+ g_signal_new ("sig-with-hash-prop",
2275
+ G_TYPE_FROM_CLASS (gobject_class),
2276
+ G_SIGNAL_RUN_LAST,
2277
+ 0,
2278
+ NULL,
2279
+ NULL,
2280
+ g_cclosure_marshal_VOID__BOXED,
2281
+ G_TYPE_NONE,
2282
+ 1,
2283
+ G_TYPE_HASH_TABLE);
2284
+
2285
+ /**
2286
+ * RegressTestObj::sig-with-strv:
2287
+ * @self: an object
2288
+ * @strs: strings
2289
+ *
2290
+ * Test GStrv as a param.
2291
+ */
2292
+ regress_test_obj_signals[REGRESS_TEST_OBJ_SIGNAL_SIG_WITH_STRV] =
2293
+ g_signal_new ("sig-with-strv",
2294
+ G_TYPE_FROM_CLASS (gobject_class),
2295
+ G_SIGNAL_RUN_LAST,
2296
+ 0,
2297
+ NULL,
2298
+ NULL,
2299
+ g_cclosure_marshal_VOID__BOXED,
2300
+ G_TYPE_NONE,
2301
+ 1,
2302
+ G_TYPE_STRV);
2303
+
2304
+ /**
2305
+ * RegressTestObj::sig-with-obj:
2306
+ * @self: an object
2307
+ * @obj: (transfer none): A newly created RegressTestObj
2308
+ *
2309
+ * Test transfer none GObject as a param (tests refcounting).
2310
+ * Use with regress_test_obj_emit_sig_with_obj
2311
+ */
2312
+ regress_test_obj_signals[REGRESS_TEST_OBJ_SIGNAL_SIG_WITH_OBJ] =
2313
+ g_signal_new ("sig-with-obj",
2314
+ G_TYPE_FROM_CLASS (gobject_class),
2315
+ G_SIGNAL_RUN_LAST,
2316
+ 0,
2317
+ NULL,
2318
+ NULL,
2319
+ g_cclosure_marshal_VOID__OBJECT,
2320
+ G_TYPE_NONE,
2321
+ 1,
2322
+ G_TYPE_OBJECT);
2323
+
2324
+ #ifndef _GI_DISABLE_CAIRO
2325
+ /**
2326
+ * RegressTestObj::sig-with-foreign-struct:
2327
+ * @self: an object
2328
+ * @cr: (transfer none): A cairo context.
2329
+ */
2330
+ regress_test_obj_signals[REGRESS_TEST_OBJ_SIGNAL_SIG_WITH_FOREIGN_STRUCT] =
2331
+ g_signal_new ("sig-with-foreign-struct",
2332
+ G_TYPE_FROM_CLASS (gobject_class),
2333
+ G_SIGNAL_RUN_LAST,
2334
+ 0,
2335
+ NULL,
2336
+ NULL,
2337
+ NULL,
2338
+ G_TYPE_NONE,
2339
+ 1,
2340
+ CAIRO_GOBJECT_TYPE_CONTEXT);
2341
+ #endif
2342
+
2343
+ regress_test_obj_signals[REGRESS_TEST_OBJ_SIGNAL_FIRST] =
2344
+ g_signal_new ("first",
2345
+ G_TYPE_FROM_CLASS (gobject_class),
2346
+ G_SIGNAL_RUN_FIRST,
2347
+ 0,
2348
+ NULL,
2349
+ NULL,
2350
+ g_cclosure_marshal_VOID__VOID,
2351
+ G_TYPE_NONE,
2352
+ 0);
2353
+
2354
+ regress_test_obj_signals[REGRESS_TEST_OBJ_SIGNAL_CLEANUP] =
2355
+ g_signal_new ("cleanup",
2356
+ G_TYPE_FROM_CLASS (gobject_class),
2357
+ G_SIGNAL_RUN_CLEANUP,
2358
+ 0,
2359
+ NULL,
2360
+ NULL,
2361
+ g_cclosure_marshal_VOID__VOID,
2362
+ G_TYPE_NONE,
2363
+ 0);
2364
+
2365
+ regress_test_obj_signals[REGRESS_TEST_OBJ_SIGNAL_ALL] =
2366
+ g_signal_new ("all",
2367
+ G_TYPE_FROM_CLASS (gobject_class),
2368
+ G_SIGNAL_RUN_FIRST | G_SIGNAL_NO_RECURSE | G_SIGNAL_DETAILED | G_SIGNAL_ACTION | G_SIGNAL_NO_HOOKS,
2369
+ 0,
2370
+ NULL,
2371
+ NULL,
2372
+ g_cclosure_marshal_VOID__VOID,
2373
+ G_TYPE_NONE,
2374
+ 0);
2375
+
2376
+ /**
2377
+ * RegressTestObj::sig-with-int64-prop:
2378
+ * @self: an object
2379
+ * @i: an integer
2380
+ *
2381
+ * You can use this with regress_test_obj_emit_sig_with_int64, or raise from
2382
+ * the introspection client langage.
2383
+ */
2384
+ regress_test_obj_signals[REGRESS_TEST_OBJ_SIGNAL_SIG_WITH_INT64_PROP] =
2385
+ g_signal_new ("sig-with-int64-prop",
2386
+ G_TYPE_FROM_CLASS (gobject_class),
2387
+ G_SIGNAL_RUN_LAST,
2388
+ 0,
2389
+ NULL,
2390
+ NULL,
2391
+ g_cclosure_marshal_VOID__BOXED,
2392
+ G_TYPE_INT64,
2393
+ 1,
2394
+ G_TYPE_INT64);
2395
+
2396
+ /**
2397
+ * RegressTestObj::sig-with-uint64-prop:
2398
+ * @self: an object
2399
+ * @i: an integer
2400
+ *
2401
+ * You can use this with regress_test_obj_emit_sig_with_uint64, or raise from
2402
+ * the introspection client langage.
2403
+ */
2404
+ regress_test_obj_signals[REGRESS_TEST_OBJ_SIGNAL_SIG_WITH_UINT64_PROP] =
2405
+ g_signal_new ("sig-with-uint64-prop",
2406
+ G_TYPE_FROM_CLASS (gobject_class),
2407
+ G_SIGNAL_RUN_LAST,
2408
+ 0,
2409
+ NULL,
2410
+ NULL,
2411
+ g_cclosure_marshal_VOID__BOXED,
2412
+ G_TYPE_UINT64,
2413
+ 1,
2414
+ G_TYPE_UINT64);
2415
+
2416
+ /**
2417
+ * RegressTestObj::sig-with-intarray-ret:
2418
+ * @self: an object
2419
+ * @i: an integer
2420
+ *
2421
+ * Returns: (array zero-terminated=1) (element-type gint) (transfer full):
2422
+ */
2423
+ regress_test_obj_signals[REGRESS_TEST_OBJ_SIGNAL_SIG_WITH_INTARRAY_RET] =
2424
+ g_signal_new ("sig-with-intarray-ret",
2425
+ G_TYPE_FROM_CLASS (gobject_class),
2426
+ G_SIGNAL_RUN_LAST,
2427
+ 0,
2428
+ NULL,
2429
+ NULL,
2430
+ g_cclosure_marshal_VOID__BOXED,
2431
+ G_TYPE_ARRAY,
2432
+ 1,
2433
+ G_TYPE_INT);
2434
+
2435
+ gobject_class->set_property = regress_test_obj_set_property;
2436
+ gobject_class->get_property = regress_test_obj_get_property;
2437
+ gobject_class->dispose = regress_test_obj_dispose;
2438
+
2439
+ pspec = g_param_spec_object ("bare",
2440
+ "Bare property",
2441
+ "A contained object",
2442
+ G_TYPE_OBJECT,
2443
+ G_PARAM_READWRITE);
2444
+ g_object_class_install_property (gobject_class,
2445
+ PROP_TEST_OBJ_BARE,
2446
+ pspec);
2447
+
2448
+ pspec = g_param_spec_boxed ("boxed",
2449
+ "Boxed property",
2450
+ "A contained boxed struct",
2451
+ REGRESS_TEST_TYPE_BOXED,
2452
+ G_PARAM_READWRITE);
2453
+ g_object_class_install_property (gobject_class,
2454
+ PROP_TEST_OBJ_BOXED,
2455
+ pspec);
2456
+
2457
+ /**
2458
+ * RegressTestObj:hash-table:
2459
+ *
2460
+ * Type: GLib.HashTable(utf8,gint8)
2461
+ * Transfer: container
2462
+ */
2463
+ pspec = g_param_spec_boxed ("hash-table",
2464
+ "GHashTable property",
2465
+ "A contained GHashTable",
2466
+ G_TYPE_HASH_TABLE,
2467
+ G_PARAM_READWRITE);
2468
+ g_object_class_install_property (gobject_class,
2469
+ PROP_TEST_OBJ_HASH_TABLE,
2470
+ pspec);
2471
+
2472
+ /**
2473
+ * RegressTestObj:list:
2474
+ *
2475
+ * Type: GLib.List(utf8)
2476
+ * Transfer: none
2477
+ */
2478
+ pspec = g_param_spec_pointer ("list",
2479
+ "GList property",
2480
+ "A contained GList",
2481
+ G_PARAM_READWRITE);
2482
+ g_object_class_install_property (gobject_class,
2483
+ PROP_TEST_OBJ_LIST,
2484
+ pspec);
2485
+
2486
+ /**
2487
+ * RegressTestObj:hash-table-old:
2488
+ *
2489
+ * Type: GLib.HashTable<utf8,gint8>
2490
+ * Transfer: container
2491
+ */
2492
+ pspec = g_param_spec_boxed ("hash-table-old",
2493
+ "GHashTable property with <>",
2494
+ "A contained GHashTable with <>",
2495
+ G_TYPE_HASH_TABLE,
2496
+ G_PARAM_READWRITE);
2497
+ g_object_class_install_property (gobject_class,
2498
+ PROP_TEST_OBJ_HASH_TABLE_OLD,
2499
+ pspec);
2500
+
2501
+ /**
2502
+ * RegressTestObj:list-old:
2503
+ *
2504
+ * Type: GLib.List<utf8>
2505
+ * Transfer: none
2506
+ */
2507
+ pspec = g_param_spec_pointer ("list-old",
2508
+ "GList property with ()",
2509
+ "A contained GList with <>",
2510
+ G_PARAM_READWRITE);
2511
+ g_object_class_install_property (gobject_class,
2512
+ PROP_TEST_OBJ_LIST_OLD,
2513
+ pspec);
2514
+
2515
+
2516
+
2517
+ /**
2518
+ * TestObj:int:
2519
+ */
2520
+ pspec = g_param_spec_int ("int",
2521
+ "int property",
2522
+ "A contained int",
2523
+ G_MININT,
2524
+ G_MAXINT,
2525
+ 0,
2526
+ G_PARAM_READWRITE);
2527
+ g_object_class_install_property (gobject_class,
2528
+ PROP_TEST_OBJ_INT,
2529
+ pspec);
2530
+
2531
+ /**
2532
+ * TestObj:float:
2533
+ */
2534
+ pspec = g_param_spec_float ("float",
2535
+ "float property",
2536
+ "A contained float",
2537
+ G_MINFLOAT,
2538
+ G_MAXFLOAT,
2539
+ 1.0f,
2540
+ G_PARAM_READWRITE);
2541
+ g_object_class_install_property (gobject_class,
2542
+ PROP_TEST_OBJ_FLOAT,
2543
+ pspec);
2544
+
2545
+ /**
2546
+ * TestObj:double:
2547
+ */
2548
+ pspec = g_param_spec_double ("double",
2549
+ "double property",
2550
+ "A contained double",
2551
+ G_MINDOUBLE,
2552
+ G_MAXDOUBLE,
2553
+ 1.0f,
2554
+ G_PARAM_READWRITE);
2555
+ g_object_class_install_property (gobject_class,
2556
+ PROP_TEST_OBJ_DOUBLE,
2557
+ pspec);
2558
+
2559
+ /**
2560
+ * TestObj:string:
2561
+ */
2562
+ pspec = g_param_spec_string ("string",
2563
+ "string property",
2564
+ "A contained string",
2565
+ NULL,
2566
+ G_PARAM_READWRITE);
2567
+ g_object_class_install_property (gobject_class,
2568
+ PROP_TEST_OBJ_STRING,
2569
+ pspec);
2570
+
2571
+
2572
+ /**
2573
+ * TestObj:gtype:
2574
+ */
2575
+ pspec = g_param_spec_gtype ("gtype",
2576
+ "GType property",
2577
+ "A GType property",
2578
+ G_TYPE_NONE,
2579
+ G_PARAM_READWRITE);
2580
+ g_object_class_install_property (gobject_class,
2581
+ PROP_TEST_OBJ_GTYPE,
2582
+ pspec);
2583
+
2584
+ klass->matrix = regress_test_obj_default_matrix;
2585
+ }
2586
+
2587
+ static void
2588
+ regress_test_obj_init (RegressTestObj *obj)
2589
+ {
2590
+ obj->bare = NULL;
2591
+ obj->boxed = NULL;
2592
+ obj->hash_table = NULL;
2593
+ obj->gtype = G_TYPE_INVALID;
2594
+ }
2595
+
2596
+ /**
2597
+ * regress_test_obj_new: (constructor)
2598
+ * @obj: A #RegressTestObj
2599
+ */
2600
+ RegressTestObj *
2601
+ regress_test_obj_new (RegressTestObj *obj)
2602
+ {
2603
+ return g_object_new (REGRESS_TEST_TYPE_OBJ, NULL);
2604
+ }
2605
+
2606
+ /**
2607
+ * regress_constructor: (constructor)
2608
+ *
2609
+ */
2610
+ RegressTestObj *
2611
+ regress_constructor (void)
2612
+ {
2613
+ return g_object_new (REGRESS_TEST_TYPE_OBJ, NULL);
2614
+ }
2615
+
2616
+ /**
2617
+ * regress_test_obj_new_from_file:
2618
+ */
2619
+ RegressTestObj *
2620
+ regress_test_obj_new_from_file (const char *x, GError **error)
2621
+ {
2622
+ return g_object_new (REGRESS_TEST_TYPE_OBJ, NULL);
2623
+ }
2624
+
2625
+ /**
2626
+ * regress_test_obj_set_bare:
2627
+ * @bare: (allow-none):
2628
+ */
2629
+ void
2630
+ regress_test_obj_set_bare (RegressTestObj *obj, GObject *bare)
2631
+ {
2632
+ if (obj->bare)
2633
+ g_object_unref (obj->bare);
2634
+ obj->bare = bare;
2635
+ if (obj->bare)
2636
+ g_object_ref (obj->bare);
2637
+ }
2638
+
2639
+ void
2640
+ regress_test_obj_emit_sig_with_obj (RegressTestObj *obj)
2641
+ {
2642
+ RegressTestObj *obj_param = regress_constructor ();
2643
+ g_object_set (obj_param, "int", 3, NULL);
2644
+ g_signal_emit_by_name (obj, "sig-with-obj", obj_param);
2645
+ g_object_unref (obj_param);
2646
+ }
2647
+
2648
+ #ifndef _GI_DISABLE_CAIRO
2649
+ void
2650
+ regress_test_obj_emit_sig_with_foreign_struct (RegressTestObj *obj)
2651
+ {
2652
+ cairo_t *cr = regress_test_cairo_context_full_return ();
2653
+ g_signal_emit_by_name (obj, "sig-with-foreign-struct", cr);
2654
+ cairo_destroy (cr);
2655
+ }
2656
+ #endif
2657
+
2658
+ void
2659
+ regress_test_obj_emit_sig_with_int64 (RegressTestObj *obj)
2660
+ {
2661
+ gint64 ret = 0;
2662
+ RegressTestObj *obj_param = regress_constructor ();
2663
+ g_signal_emit_by_name (obj, "sig-with-int64-prop", G_MAXINT64, &ret);
2664
+ g_object_unref (obj_param);
2665
+ g_assert (ret == G_MAXINT64);
2666
+ }
2667
+
2668
+ void
2669
+ regress_test_obj_emit_sig_with_uint64 (RegressTestObj *obj)
2670
+ {
2671
+ guint64 ret = 0;
2672
+ RegressTestObj *obj_param = regress_constructor ();
2673
+ g_signal_emit_by_name (obj, "sig-with-uint64-prop", G_MAXUINT64, &ret);
2674
+ g_object_unref (obj_param);
2675
+ g_assert (ret == G_MAXUINT64);
2676
+ }
2677
+
2678
+ int
2679
+ regress_test_obj_instance_method (RegressTestObj *obj)
2680
+ {
2681
+ return -1;
2682
+ }
2683
+
2684
+ double
2685
+ regress_test_obj_static_method (int x)
2686
+ {
2687
+ return x;
2688
+ }
2689
+
2690
+ /**
2691
+ * regress_forced_method: (method)
2692
+ * @obj: A #RegressTestObj
2693
+ *
2694
+ */
2695
+ void
2696
+ regress_forced_method (RegressTestObj *obj)
2697
+ {
2698
+ }
2699
+
2700
+ /**
2701
+ * regress_test_obj_torture_signature_0:
2702
+ * @obj: A #RegressTestObj
2703
+ * @x:
2704
+ * @y: (out):
2705
+ * @z: (out):
2706
+ * @foo:
2707
+ * @q: (out):
2708
+ * @m:
2709
+ *
2710
+ */
2711
+ void
2712
+ regress_test_obj_torture_signature_0 (RegressTestObj *obj,
2713
+ int x,
2714
+ double *y,
2715
+ int *z,
2716
+ const char *foo,
2717
+ int *q,
2718
+ guint m)
2719
+ {
2720
+ *y = x;
2721
+ *z = x * 2;
2722
+ *q = g_utf8_strlen (foo, -1) + m;
2723
+ }
2724
+
2725
+ /**
2726
+ * regress_test_obj_torture_signature_1:
2727
+ * @obj: A #RegressTestObj
2728
+ * @x:
2729
+ * @y: (out):
2730
+ * @z: (out):
2731
+ * @foo:
2732
+ * @q: (out):
2733
+ * @m:
2734
+ * @error: A #GError
2735
+ *
2736
+ * This function throws an error if m is odd.
2737
+ */
2738
+ gboolean
2739
+ regress_test_obj_torture_signature_1 (RegressTestObj *obj,
2740
+ int x,
2741
+ double *y,
2742
+ int *z,
2743
+ const char *foo,
2744
+ int *q,
2745
+ guint m,
2746
+ GError **error)
2747
+ {
2748
+ *y = x;
2749
+ *z = x * 2;
2750
+ *q = g_utf8_strlen (foo, -1) + m;
2751
+ if (m % 2 == 0)
2752
+ return TRUE;
2753
+ g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED, "m is odd");
2754
+ return FALSE;
2755
+ }
2756
+
2757
+ /**
2758
+ * regress_test_obj_skip_return_val:
2759
+ * @obj: a #RegressTestObj
2760
+ * @a: Parameter.
2761
+ * @out_b: (out): A return value.
2762
+ * @c: Other parameter.
2763
+ * @inout_d: (inout): Will be incremented.
2764
+ * @out_sum: (out): Return value.
2765
+ * @num1: Number.
2766
+ * @num2: Number.
2767
+ * @error: Return location for error.
2768
+ *
2769
+ * Check that the return value is skipped
2770
+ *
2771
+ * Returns: (skip): %TRUE if the call succeeds, %FALSE if @error is set.
2772
+ */
2773
+ gboolean
2774
+ regress_test_obj_skip_return_val (RegressTestObj *obj,
2775
+ gint a,
2776
+ gint *out_b,
2777
+ gdouble c,
2778
+ gint *inout_d,
2779
+ gint *out_sum,
2780
+ gint num1,
2781
+ gint num2,
2782
+ GError **error)
2783
+ {
2784
+ if (out_b != NULL)
2785
+ *out_b = a + 1;
2786
+ if (inout_d != NULL)
2787
+ *inout_d = *inout_d + 1;
2788
+ if (out_sum != NULL)
2789
+ *out_sum = num1 + 10*num2;
2790
+ return TRUE;
2791
+ }
2792
+
2793
+ /**
2794
+ * regress_test_obj_skip_return_val_no_out:
2795
+ * @obj: a #RegressTestObj
2796
+ * @a: Parameter.
2797
+ * @error: Return location for error.
2798
+ *
2799
+ * Check that the return value is skipped. Succeed if a is nonzero, otherwise
2800
+ * raise an error.
2801
+ *
2802
+ * Returns: (skip): %TRUE if the call succeeds, %FALSE if @error is set.
2803
+ */
2804
+ gboolean
2805
+ regress_test_obj_skip_return_val_no_out (RegressTestObj *obj,
2806
+ gint a,
2807
+ GError **error)
2808
+ {
2809
+ if (a == 0) {
2810
+ g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED, "a is zero");
2811
+ return FALSE;
2812
+ } else {
2813
+ return TRUE;
2814
+ }
2815
+ }
2816
+
2817
+ /**
2818
+ * regress_test_obj_skip_param:
2819
+ * @obj: A #RegressTestObj.
2820
+ * @a: Parameter.
2821
+ * @out_b: (out): Return value.
2822
+ * @c: (skip): Other parameter.
2823
+ * @inout_d: (inout): Will be incremented.
2824
+ * @out_sum: (out): Return value.
2825
+ * @num1: Number.
2826
+ * @num2: Number.
2827
+ * @error: Return location for error.
2828
+ *
2829
+ * Check that a parameter is skipped
2830
+ *
2831
+ * Returns: %TRUE if the call succeeds, %FALSE if @error is set.
2832
+ */
2833
+ gboolean
2834
+ regress_test_obj_skip_param (RegressTestObj *obj,
2835
+ gint a,
2836
+ gint *out_b,
2837
+ gdouble c,
2838
+ gint *inout_d,
2839
+ gint *out_sum,
2840
+ gint num1,
2841
+ gint num2,
2842
+ GError **error)
2843
+ {
2844
+ if (out_b != NULL)
2845
+ *out_b = a + 1;
2846
+ if (inout_d != NULL)
2847
+ *inout_d = *inout_d + 1;
2848
+ if (out_sum != NULL)
2849
+ *out_sum = num1 + 10*num2;
2850
+ return TRUE;
2851
+ }
2852
+
2853
+ /**
2854
+ * regress_test_obj_skip_out_param:
2855
+ * @obj: A #RegressTestObj.
2856
+ * @a: Parameter.
2857
+ * @out_b: (out) (skip): Return value.
2858
+ * @c: Other parameter.
2859
+ * @inout_d: (inout): Will be incremented.
2860
+ * @out_sum: (out): Return value.
2861
+ * @num1: Number.
2862
+ * @num2: Number.
2863
+ * @error: Return location for error.
2864
+ *
2865
+ * Check that the out value is skipped
2866
+ *
2867
+ * Returns: %TRUE if the call succeeds, %FALSE if @error is set.
2868
+ */
2869
+ gboolean
2870
+ regress_test_obj_skip_out_param (RegressTestObj *obj,
2871
+ gint a,
2872
+ gint *out_b,
2873
+ gdouble c,
2874
+ gint *inout_d,
2875
+ gint *out_sum,
2876
+ gint num1,
2877
+ gint num2,
2878
+ GError **error)
2879
+ {
2880
+ if (out_b != NULL)
2881
+ *out_b = a + 1;
2882
+ if (inout_d != NULL)
2883
+ *inout_d = *inout_d + 1;
2884
+ if (out_sum != NULL)
2885
+ *out_sum = num1 + 10*num2;
2886
+ return TRUE;
2887
+ }
2888
+
2889
+ /**
2890
+ * regress_test_obj_skip_inout_param:
2891
+ * @obj: A #RegressTestObj.
2892
+ * @a: Parameter.
2893
+ * @out_b: (out): Return value.
2894
+ * @c: Other parameter.
2895
+ * @inout_d: (inout) (skip): Will be incremented.
2896
+ * @out_sum: (out): Return value.
2897
+ * @num1: Number.
2898
+ * @num2: Number.
2899
+ * @error: Return location for error.
2900
+ *
2901
+ * Check that the out value is skipped
2902
+ *
2903
+ * Returns: %TRUE if the call succeeds, %FALSE if @error is set.
2904
+ */
2905
+ gboolean
2906
+ regress_test_obj_skip_inout_param (RegressTestObj *obj,
2907
+ gint a,
2908
+ gint *out_b,
2909
+ gdouble c,
2910
+ gint *inout_d,
2911
+ gint *out_sum,
2912
+ gint num1,
2913
+ gint num2,
2914
+ GError **error)
2915
+ {
2916
+ if (out_b != NULL)
2917
+ *out_b = a + 1;
2918
+ if (inout_d != NULL)
2919
+ *inout_d = *inout_d + 1;
2920
+ if (out_sum != NULL)
2921
+ *out_sum = num1 + 10*num2;
2922
+ return TRUE;
2923
+ }
2924
+
2925
+ /**
2926
+ * regress_test_obj_do_matrix:
2927
+ * @obj: A #RegressTestObj
2928
+ * @somestr: Meaningless string
2929
+ *
2930
+ * This method is virtual. Notably its name differs from the virtual
2931
+ * slot name, which makes it useful for testing bindings handle this
2932
+ * case.
2933
+ *
2934
+ * Virtual: matrix
2935
+ */
2936
+ int
2937
+ regress_test_obj_do_matrix (RegressTestObj *obj, const char *somestr)
2938
+ {
2939
+ return REGRESS_TEST_OBJ_GET_CLASS (obj)->matrix (obj, somestr);
2940
+ }
2941
+
2942
+ /**
2943
+ * regress_func_obj_null_in:
2944
+ * @obj: (allow-none): A #RegressTestObj
2945
+ */
2946
+ void
2947
+ regress_func_obj_null_in (RegressTestObj *obj)
2948
+ {
2949
+ }
2950
+
2951
+ /**
2952
+ * regress_test_obj_null_out:
2953
+ * @obj: (allow-none) (out): A #RegressTestObj
2954
+ */
2955
+ void
2956
+ regress_test_obj_null_out (RegressTestObj **obj)
2957
+ {
2958
+ if (obj)
2959
+ *obj = NULL;
2960
+ }
2961
+
2962
+ /**
2963
+ * regress_test_array_fixed_out_objects:
2964
+ * @objs: (out) (array fixed-size=2) (transfer full): An array of #RegressTestObj
2965
+ */
2966
+ void
2967
+ regress_test_array_fixed_out_objects (RegressTestObj ***objs)
2968
+ {
2969
+ RegressTestObj **values = (RegressTestObj**)g_new(gpointer, 2);
2970
+
2971
+ values[0] = regress_constructor();
2972
+ values[1] = regress_constructor();
2973
+
2974
+ *objs = values;
2975
+ }
2976
+
2977
+ typedef struct _CallbackInfo CallbackInfo;
2978
+
2979
+ struct _CallbackInfo
2980
+ {
2981
+ RegressTestCallbackUserData callback;
2982
+ GDestroyNotify notify;
2983
+ gpointer user_data;
2984
+ };
2985
+
2986
+
2987
+ G_DEFINE_TYPE(RegressTestSubObj, regress_test_sub_obj, REGRESS_TEST_TYPE_OBJ);
2988
+
2989
+ static void
2990
+ regress_test_sub_obj_class_init (RegressTestSubObjClass *klass)
2991
+ {
2992
+ }
2993
+
2994
+ static void
2995
+ regress_test_sub_obj_init (RegressTestSubObj *obj)
2996
+ {
2997
+ }
2998
+
2999
+ RegressTestObj*
3000
+ regress_test_sub_obj_new ()
3001
+ {
3002
+ return g_object_new (REGRESS_TEST_TYPE_SUB_OBJ, NULL);
3003
+ }
3004
+
3005
+ int
3006
+ regress_test_sub_obj_instance_method (RegressTestSubObj *obj)
3007
+ {
3008
+ return 0;
3009
+ }
3010
+
3011
+ void
3012
+ regress_test_sub_obj_unset_bare (RegressTestSubObj *obj)
3013
+ {
3014
+ regress_test_obj_set_bare(REGRESS_TEST_OBJECT(obj), NULL);
3015
+ }
3016
+
3017
+ /* RegressTestFundamental */
3018
+
3019
+ /**
3020
+ * regress_test_fundamental_object_ref:
3021
+ *
3022
+ * Returns: (transfer full): A new #RegressTestFundamentalObject
3023
+ */
3024
+ RegressTestFundamentalObject *
3025
+ regress_test_fundamental_object_ref (RegressTestFundamentalObject * fundamental_object)
3026
+ {
3027
+ g_return_val_if_fail (fundamental_object != NULL, NULL);
3028
+ g_atomic_int_inc (&fundamental_object->refcount);
3029
+
3030
+ return fundamental_object;
3031
+ }
3032
+
3033
+ static void
3034
+ regress_test_fundamental_object_free (RegressTestFundamentalObject * fundamental_object)
3035
+ {
3036
+ RegressTestFundamentalObjectClass *mo_class;
3037
+ regress_test_fundamental_object_ref (fundamental_object);
3038
+
3039
+ mo_class = REGRESS_TEST_FUNDAMENTAL_OBJECT_GET_CLASS (fundamental_object);
3040
+ mo_class->finalize (fundamental_object);
3041
+
3042
+ if (G_LIKELY (g_atomic_int_dec_and_test (&fundamental_object->refcount))) {
3043
+ g_type_free_instance ((GTypeInstance *) fundamental_object);
3044
+ }
3045
+ }
3046
+
3047
+ void
3048
+ regress_test_fundamental_object_unref (RegressTestFundamentalObject * fundamental_object)
3049
+ {
3050
+ g_return_if_fail (fundamental_object != NULL);
3051
+ g_return_if_fail (fundamental_object->refcount > 0);
3052
+
3053
+ if (G_UNLIKELY (g_atomic_int_dec_and_test (&fundamental_object->refcount))) {
3054
+ regress_test_fundamental_object_free (fundamental_object);
3055
+ }
3056
+ }
3057
+
3058
+ static void
3059
+ regress_test_fundamental_object_replace (RegressTestFundamentalObject ** olddata, RegressTestFundamentalObject * newdata)
3060
+ {
3061
+ RegressTestFundamentalObject *olddata_val;
3062
+
3063
+ g_return_if_fail (olddata != NULL);
3064
+
3065
+ olddata_val = g_atomic_pointer_get ((gpointer *) olddata);
3066
+
3067
+ if (olddata_val == newdata)
3068
+ return;
3069
+
3070
+ if (newdata)
3071
+ regress_test_fundamental_object_ref (newdata);
3072
+
3073
+ while (!g_atomic_pointer_compare_and_exchange ((gpointer *) olddata,
3074
+ olddata_val, newdata)) {
3075
+ olddata_val = g_atomic_pointer_get ((gpointer *) olddata);
3076
+ }
3077
+
3078
+ if (olddata_val)
3079
+ regress_test_fundamental_object_unref (olddata_val);
3080
+ }
3081
+
3082
+ static void
3083
+ regress_test_value_fundamental_object_init (GValue * value)
3084
+ {
3085
+ value->data[0].v_pointer = NULL;
3086
+ }
3087
+
3088
+ static void
3089
+ regress_test_value_fundamental_object_free (GValue * value)
3090
+ {
3091
+ if (value->data[0].v_pointer) {
3092
+ regress_test_fundamental_object_unref (REGRESS_TEST_FUNDAMENTAL_OBJECT_CAST (value->data[0].v_pointer));
3093
+ }
3094
+ }
3095
+
3096
+ static void
3097
+ regress_test_value_fundamental_object_copy (const GValue * src_value, GValue * dest_value)
3098
+ {
3099
+ if (src_value->data[0].v_pointer) {
3100
+ dest_value->data[0].v_pointer =
3101
+ regress_test_fundamental_object_ref (REGRESS_TEST_FUNDAMENTAL_OBJECT_CAST (src_value->data[0].
3102
+ v_pointer));
3103
+ } else {
3104
+ dest_value->data[0].v_pointer = NULL;
3105
+ }
3106
+ }
3107
+
3108
+ static gpointer
3109
+ regress_test_value_fundamental_object_peek_pointer (const GValue * value)
3110
+ {
3111
+ return value->data[0].v_pointer;
3112
+ }
3113
+
3114
+ static gchar *
3115
+ regress_test_value_fundamental_object_collect (GValue * value,
3116
+ guint n_collect_values,
3117
+ GTypeCValue * collect_values,
3118
+ guint collect_flags)
3119
+ {
3120
+ if (collect_values[0].v_pointer) {
3121
+ value->data[0].v_pointer =
3122
+ regress_test_fundamental_object_ref (collect_values[0].v_pointer);
3123
+ } else {
3124
+ value->data[0].v_pointer = NULL;
3125
+ }
3126
+
3127
+ return NULL;
3128
+ }
3129
+
3130
+ static gchar *
3131
+ regress_test_value_fundamental_object_lcopy (const GValue * value,
3132
+ guint n_collect_values,
3133
+ GTypeCValue * collect_values,
3134
+ guint collect_flags)
3135
+ {
3136
+ gpointer *fundamental_object_p = collect_values[0].v_pointer;
3137
+
3138
+ if (!fundamental_object_p) {
3139
+ return g_strdup_printf ("value location for '%s' passed as NULL",
3140
+ G_VALUE_TYPE_NAME (value));
3141
+ }
3142
+
3143
+ if (!value->data[0].v_pointer)
3144
+ *fundamental_object_p = NULL;
3145
+ else if (collect_flags & G_VALUE_NOCOPY_CONTENTS)
3146
+ *fundamental_object_p = value->data[0].v_pointer;
3147
+ else
3148
+ *fundamental_object_p = regress_test_fundamental_object_ref (value->data[0].v_pointer);
3149
+
3150
+ return NULL;
3151
+ }
3152
+
3153
+ static void
3154
+ regress_test_fundamental_object_finalize (RegressTestFundamentalObject * obj)
3155
+ {
3156
+
3157
+ }
3158
+
3159
+ static RegressTestFundamentalObject *
3160
+ regress_test_fundamental_object_copy_default (const RegressTestFundamentalObject * obj)
3161
+ {
3162
+ g_warning ("RegressTestFundamentalObject classes must implement RegressTestFundamentalObject::copy");
3163
+ return NULL;
3164
+ }
3165
+
3166
+ static void
3167
+ regress_test_fundamental_object_class_init (gpointer g_class, gpointer class_data)
3168
+ {
3169
+ RegressTestFundamentalObjectClass *mo_class = REGRESS_TEST_FUNDAMENTAL_OBJECT_CLASS (g_class);
3170
+
3171
+ mo_class->copy = regress_test_fundamental_object_copy_default;
3172
+ mo_class->finalize = regress_test_fundamental_object_finalize;
3173
+ }
3174
+
3175
+ static void
3176
+ regress_test_fundamental_object_init (GTypeInstance * instance, gpointer klass)
3177
+ {
3178
+ RegressTestFundamentalObject *fundamental_object = REGRESS_TEST_FUNDAMENTAL_OBJECT_CAST (instance);
3179
+
3180
+ fundamental_object->refcount = 1;
3181
+ }
3182
+
3183
+ /**
3184
+ * RegressTestFundamentalObject:
3185
+ *
3186
+ * Ref Func: regress_test_fundamental_object_ref
3187
+ * Unref Func: regress_test_fundamental_object_unref
3188
+ * Set Value Func: regress_test_value_set_fundamental_object
3189
+ * Get Value Func: regress_test_value_get_fundamental_object
3190
+ */
3191
+
3192
+ GType
3193
+ regress_test_fundamental_object_get_type (void)
3194
+ {
3195
+ static GType _test_fundamental_object_type = 0;
3196
+
3197
+ if (G_UNLIKELY (_test_fundamental_object_type == 0)) {
3198
+ static const GTypeValueTable value_table = {
3199
+ regress_test_value_fundamental_object_init,
3200
+ regress_test_value_fundamental_object_free,
3201
+ regress_test_value_fundamental_object_copy,
3202
+ regress_test_value_fundamental_object_peek_pointer,
3203
+ (char *) "p",
3204
+ regress_test_value_fundamental_object_collect,
3205
+ (char *) "p",
3206
+ regress_test_value_fundamental_object_lcopy
3207
+ };
3208
+ static const GTypeInfo fundamental_object_info = {
3209
+ sizeof (RegressTestFundamentalObjectClass),
3210
+ NULL, NULL,
3211
+ regress_test_fundamental_object_class_init,
3212
+ NULL,
3213
+ NULL,
3214
+ sizeof (RegressTestFundamentalObject),
3215
+ 0,
3216
+ (GInstanceInitFunc) regress_test_fundamental_object_init,
3217
+ &value_table
3218
+ };
3219
+ static const GTypeFundamentalInfo fundamental_object_fundamental_info = {
3220
+ (G_TYPE_FLAG_CLASSED | G_TYPE_FLAG_INSTANTIATABLE |
3221
+ G_TYPE_FLAG_DERIVABLE | G_TYPE_FLAG_DEEP_DERIVABLE)
3222
+ };
3223
+
3224
+ _test_fundamental_object_type = g_type_fundamental_next ();
3225
+ g_type_register_fundamental (_test_fundamental_object_type, "RegressTestFundamentalObject",
3226
+ &fundamental_object_info, &fundamental_object_fundamental_info, G_TYPE_FLAG_ABSTRACT);
3227
+
3228
+ }
3229
+
3230
+ return _test_fundamental_object_type;
3231
+ }
3232
+
3233
+ /**
3234
+ * regress_test_value_set_fundamental_object: (skip)
3235
+ * @value:
3236
+ * @fundamental_object:
3237
+ */
3238
+ void
3239
+ regress_test_value_set_fundamental_object (GValue * value, RegressTestFundamentalObject * fundamental_object)
3240
+ {
3241
+ gpointer *pointer_p;
3242
+
3243
+ g_return_if_fail (REGRESS_TEST_VALUE_HOLDS_FUNDAMENTAL_OBJECT (value));
3244
+ g_return_if_fail (fundamental_object == NULL || REGRESS_TEST_IS_FUNDAMENTAL_OBJECT (fundamental_object));
3245
+
3246
+ pointer_p = &value->data[0].v_pointer;
3247
+
3248
+ regress_test_fundamental_object_replace ((RegressTestFundamentalObject **) pointer_p, fundamental_object);
3249
+ }
3250
+
3251
+ /**
3252
+ * regress_test_value_get_fundamental_object: (skip)
3253
+ * @value:
3254
+ */
3255
+ RegressTestFundamentalObject *
3256
+ regress_test_value_get_fundamental_object (const GValue * value)
3257
+ {
3258
+ g_return_val_if_fail (REGRESS_TEST_VALUE_HOLDS_FUNDAMENTAL_OBJECT (value), NULL);
3259
+
3260
+ return value->data[0].v_pointer;
3261
+ }
3262
+
3263
+ static RegressTestFundamentalObjectClass *parent_class = NULL;
3264
+
3265
+ G_DEFINE_TYPE (RegressTestFundamentalSubObject, regress_test_fundamental_sub_object, REGRESS_TEST_TYPE_FUNDAMENTAL_OBJECT);
3266
+
3267
+ static RegressTestFundamentalSubObject *
3268
+ _regress_test_fundamental_sub_object_copy (RegressTestFundamentalSubObject * fundamental_sub_object)
3269
+ {
3270
+ RegressTestFundamentalSubObject *copy;
3271
+
3272
+ copy = regress_test_fundamental_sub_object_new(NULL);
3273
+ copy->data = g_strdup(fundamental_sub_object->data);
3274
+ return copy;
3275
+ }
3276
+
3277
+ static void
3278
+ regress_test_fundamental_sub_object_finalize (RegressTestFundamentalSubObject * fundamental_sub_object)
3279
+ {
3280
+ g_return_if_fail (fundamental_sub_object != NULL);
3281
+
3282
+ g_free(fundamental_sub_object->data);
3283
+ regress_test_fundamental_object_finalize (REGRESS_TEST_FUNDAMENTAL_OBJECT (fundamental_sub_object));
3284
+ }
3285
+
3286
+ static void
3287
+ regress_test_fundamental_sub_object_class_init (RegressTestFundamentalSubObjectClass * klass)
3288
+ {
3289
+ parent_class = g_type_class_peek_parent (klass);
3290
+
3291
+ klass->fundamental_object_class.copy = (RegressTestFundamentalObjectCopyFunction) _regress_test_fundamental_sub_object_copy;
3292
+ klass->fundamental_object_class.finalize =
3293
+ (RegressTestFundamentalObjectFinalizeFunction) regress_test_fundamental_sub_object_finalize;
3294
+ }
3295
+
3296
+ static void
3297
+ regress_test_fundamental_sub_object_init(RegressTestFundamentalSubObject *object)
3298
+ {
3299
+
3300
+ }
3301
+
3302
+ /**
3303
+ * regress_test_fundamental_sub_object_new:
3304
+ */
3305
+ RegressTestFundamentalSubObject *
3306
+ regress_test_fundamental_sub_object_new (const char * data)
3307
+ {
3308
+ RegressTestFundamentalSubObject *object;
3309
+
3310
+ object = (RegressTestFundamentalSubObject *) g_type_create_instance (regress_test_fundamental_sub_object_get_type());
3311
+ object->data = g_strdup(data);
3312
+ return object;
3313
+ }
3314
+
3315
+
3316
+ /**
3317
+ * regress_test_callback:
3318
+ * @callback: (scope call) (allow-none):
3319
+ *
3320
+ **/
3321
+ int
3322
+ regress_test_callback (RegressTestCallback callback)
3323
+ {
3324
+ if (callback != NULL)
3325
+ return callback();
3326
+ return 0;
3327
+ }
3328
+
3329
+ /**
3330
+ * regress_test_multi_callback:
3331
+ * @callback: (scope call) (allow-none):
3332
+ *
3333
+ **/
3334
+ int
3335
+ regress_test_multi_callback (RegressTestCallback callback)
3336
+ {
3337
+ int sum = 0;
3338
+ if (callback != NULL) {
3339
+ sum += callback();
3340
+ sum += callback();
3341
+ }
3342
+
3343
+ return sum;
3344
+ }
3345
+
3346
+ /**
3347
+ * regress_test_array_callback:
3348
+ * @callback: (scope call):
3349
+ *
3350
+ **/
3351
+ int regress_test_array_callback (RegressTestCallbackArray callback)
3352
+ {
3353
+ static const char *strings[] = { "one", "two", "three" };
3354
+ static int ints[] = { -1, 0, 1, 2 };
3355
+ int sum = 0;
3356
+
3357
+ sum += callback(ints, 4, strings, 3);
3358
+ sum += callback(ints, 4, strings, 3);
3359
+
3360
+ return sum;
3361
+ }
3362
+
3363
+ /**
3364
+ * regress_test_simple_callback:
3365
+ * @callback: (scope call) (allow-none):
3366
+ *
3367
+ **/
3368
+ void
3369
+ regress_test_simple_callback (RegressTestSimpleCallback callback)
3370
+ {
3371
+ if (callback != NULL)
3372
+ callback();
3373
+
3374
+ return;
3375
+ }
3376
+
3377
+ /**
3378
+ * regress_test_callback_user_data:
3379
+ * @callback: (scope call):
3380
+ *
3381
+ * Call - callback parameter persists for the duration of the method
3382
+ * call and can be released on return.
3383
+ **/
3384
+ int
3385
+ regress_test_callback_user_data (RegressTestCallbackUserData callback,
3386
+ gpointer user_data)
3387
+ {
3388
+ return callback(user_data);
3389
+ }
3390
+
3391
+ static GSList *notified_callbacks = NULL;
3392
+
3393
+ /**
3394
+ * regress_test_callback_destroy_notify:
3395
+ * @callback: (scope notified):
3396
+ *
3397
+ * Notified - callback persists until a DestroyNotify delegate
3398
+ * is invoked.
3399
+ **/
3400
+ int
3401
+ regress_test_callback_destroy_notify (RegressTestCallbackUserData callback,
3402
+ gpointer user_data,
3403
+ GDestroyNotify notify)
3404
+ {
3405
+ int retval;
3406
+ CallbackInfo *info;
3407
+
3408
+ retval = callback(user_data);
3409
+
3410
+ info = g_slice_new(CallbackInfo);
3411
+ info->callback = callback;
3412
+ info->notify = notify;
3413
+ info->user_data = user_data;
3414
+
3415
+ notified_callbacks = g_slist_prepend(notified_callbacks, info);
3416
+
3417
+ return retval;
3418
+ }
3419
+
3420
+ /**
3421
+ * regress_test_callback_destroy_notify_no_user_data:
3422
+ * @callback: (scope notified):
3423
+ *
3424
+ * Adds a scope notified callback with no user data. This can invoke an error
3425
+ * condition in bindings which needs to be tested.
3426
+ **/
3427
+ int
3428
+ regress_test_callback_destroy_notify_no_user_data (RegressTestCallbackUserData callback,
3429
+ GDestroyNotify notify)
3430
+ {
3431
+ return regress_test_callback_destroy_notify(callback, NULL, notify);
3432
+ }
3433
+
3434
+ /**
3435
+ * regress_test_callback_thaw_notifications:
3436
+ *
3437
+ * Invokes all callbacks installed by #test_callback_destroy_notify(),
3438
+ * adding up their return values, and removes them, invoking the
3439
+ * corresponding destroy notfications.
3440
+ *
3441
+ * Return value: Sum of the return values of the invoked callbacks.
3442
+ */
3443
+ int
3444
+ regress_test_callback_thaw_notifications (void)
3445
+ {
3446
+ int retval = 0;
3447
+ GSList *node;
3448
+
3449
+ for (node = notified_callbacks; node != NULL; node = node->next)
3450
+ {
3451
+ CallbackInfo *info = node->data;
3452
+ retval += info->callback (info->user_data);
3453
+ if (info->notify)
3454
+ info->notify (info->user_data);
3455
+ g_slice_free (CallbackInfo, info);
3456
+ }
3457
+
3458
+ g_slist_free (notified_callbacks);
3459
+ notified_callbacks = NULL;
3460
+
3461
+ return retval;
3462
+ }
3463
+
3464
+ static GSList *async_callbacks = NULL;
3465
+
3466
+ /**
3467
+ * regress_test_callback_async:
3468
+ * @callback: (scope async):
3469
+ *
3470
+ **/
3471
+ void
3472
+ regress_test_callback_async (RegressTestCallbackUserData callback,
3473
+ gpointer user_data)
3474
+ {
3475
+ CallbackInfo *info;
3476
+
3477
+ info = g_slice_new(CallbackInfo);
3478
+ info->callback = callback;
3479
+ info->user_data = user_data;
3480
+
3481
+ async_callbacks = g_slist_prepend(async_callbacks, info);
3482
+ }
3483
+
3484
+ /**
3485
+ * regress_test_callback_thaw_async:
3486
+ */
3487
+ int
3488
+ regress_test_callback_thaw_async (void)
3489
+ {
3490
+ int retval = 0;
3491
+ GSList *node;
3492
+
3493
+ for (node = async_callbacks; node != NULL; node = node->next)
3494
+ {
3495
+ CallbackInfo *info = node->data;
3496
+ retval = info->callback (info->user_data);
3497
+ g_slice_free (CallbackInfo, info);
3498
+ }
3499
+
3500
+ g_slist_free (async_callbacks);
3501
+ async_callbacks = NULL;
3502
+ return retval;
3503
+ }
3504
+
3505
+ void
3506
+ regress_test_async_ready_callback (GAsyncReadyCallback callback)
3507
+ {
3508
+ GSimpleAsyncResult *result = g_simple_async_result_new (NULL, callback, NULL,
3509
+ regress_test_async_ready_callback);
3510
+ g_simple_async_result_complete_in_idle (result);
3511
+ }
3512
+
3513
+ /**
3514
+ * regress_test_obj_instance_method_callback:
3515
+ * @callback: (scope call) (allow-none):
3516
+ *
3517
+ **/
3518
+ void
3519
+ regress_test_obj_instance_method_callback (RegressTestObj *obj, RegressTestCallback callback)
3520
+ {
3521
+ if (callback != NULL)
3522
+ callback();
3523
+ }
3524
+
3525
+ /**
3526
+ * regress_test_obj_static_method_callback:
3527
+ * @callback: (scope call) (allow-none):
3528
+ *
3529
+ **/
3530
+ void
3531
+ regress_test_obj_static_method_callback (RegressTestCallback callback)
3532
+ {
3533
+ if (callback != NULL)
3534
+ callback();
3535
+ }
3536
+
3537
+ /**
3538
+ * regress_test_obj_new_callback:
3539
+ * @callback: (scope notified):
3540
+ **/
3541
+ RegressTestObj *
3542
+ regress_test_obj_new_callback (RegressTestCallbackUserData callback, gpointer user_data,
3543
+ GDestroyNotify notify)
3544
+ {
3545
+ CallbackInfo *info;
3546
+
3547
+ callback(user_data);
3548
+
3549
+ info = g_slice_new(CallbackInfo);
3550
+ info->callback = callback;
3551
+ info->notify = notify;
3552
+ info->user_data = user_data;
3553
+
3554
+ notified_callbacks = g_slist_prepend(notified_callbacks, info);
3555
+
3556
+ return g_object_new (REGRESS_TEST_TYPE_OBJ, NULL);
3557
+ }
3558
+
3559
+ /**
3560
+ * regress_test_hash_table_callback:
3561
+ * @data: (element-type utf8 gint): GHashTable that gets passed to callback
3562
+ * @callback: (scope call):
3563
+ **/
3564
+ void
3565
+ regress_test_hash_table_callback (GHashTable *data, RegressTestCallbackHashtable callback)
3566
+ {
3567
+ callback (data);
3568
+ }
3569
+
3570
+ /**
3571
+ * regress_test_gerror_callback:
3572
+ * @callback: (scope call):
3573
+ **/
3574
+ void
3575
+ regress_test_gerror_callback (RegressTestCallbackGError callback)
3576
+ {
3577
+ GError *error;
3578
+
3579
+ error = g_error_new_literal (G_IO_ERROR,
3580
+ G_IO_ERROR_NOT_SUPPORTED,
3581
+ "regression test error");
3582
+ callback (error);
3583
+ g_error_free (error);
3584
+ }
3585
+
3586
+ /**
3587
+ * regress_test_null_gerror_callback:
3588
+ * @callback: (scope call):
3589
+ **/
3590
+ void
3591
+ regress_test_null_gerror_callback (RegressTestCallbackGError callback)
3592
+ {
3593
+ callback (NULL);
3594
+ }
3595
+
3596
+ /**
3597
+ * regress_test_owned_gerror_callback:
3598
+ * @callback: (scope call):
3599
+ **/
3600
+ void
3601
+ regress_test_owned_gerror_callback (RegressTestCallbackOwnedGError callback)
3602
+ {
3603
+ GError *error;
3604
+
3605
+ error = g_error_new_literal (G_IO_ERROR,
3606
+ G_IO_ERROR_PERMISSION_DENIED,
3607
+ "regression test owned error");
3608
+ callback (error);
3609
+ }
3610
+
3611
+ /**
3612
+ * regress_test_skip_unannotated_callback: (skip)
3613
+ * @callback: No annotation here
3614
+ *
3615
+ * Should not emit a warning:
3616
+ * https://bugzilla.gnome.org/show_bug.cgi?id=685399
3617
+ */
3618
+ void
3619
+ regress_test_skip_unannotated_callback (RegressTestCallback callback)
3620
+ {
3621
+ }
3622
+
3623
+ /* interface */
3624
+
3625
+ static void
3626
+ regress_test_interface_default_init(RegressTestInterfaceIface *iface)
3627
+ {
3628
+ }
3629
+
3630
+ typedef RegressTestInterfaceIface RegressTestInterfaceInterface;
3631
+ G_DEFINE_INTERFACE (RegressTestInterface, regress_test_interface, G_TYPE_OBJECT)
3632
+
3633
+
3634
+ /* gobject with non-standard prefix */
3635
+ G_DEFINE_TYPE(RegressTestWi8021x, regress_test_wi_802_1x, G_TYPE_OBJECT);
3636
+
3637
+ enum
3638
+ {
3639
+ PROP_TEST_WI_802_1X_TESTBOOL = 1
3640
+ };
3641
+
3642
+ static void
3643
+ regress_test_wi_802_1x_set_property (GObject *object,
3644
+ guint property_id,
3645
+ const GValue *value,
3646
+ GParamSpec *pspec)
3647
+ {
3648
+ RegressTestWi8021x *self = REGRESS_TEST_WI_802_1X (object);
3649
+
3650
+ switch (property_id)
3651
+ {
3652
+ case PROP_TEST_WI_802_1X_TESTBOOL:
3653
+ regress_test_wi_802_1x_set_testbool (self, g_value_get_boolean (value));
3654
+ break;
3655
+
3656
+ default:
3657
+ /* We don't have any other property... */
3658
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
3659
+ break;
3660
+ }
3661
+ }
3662
+
3663
+ static void
3664
+ regress_test_wi_802_1x_get_property (GObject *object,
3665
+ guint property_id,
3666
+ GValue *value,
3667
+ GParamSpec *pspec)
3668
+ {
3669
+ RegressTestWi8021x *self = REGRESS_TEST_WI_802_1X (object);
3670
+
3671
+ switch (property_id)
3672
+ {
3673
+ case PROP_TEST_WI_802_1X_TESTBOOL:
3674
+ g_value_set_boolean (value, regress_test_wi_802_1x_get_testbool (self));
3675
+ break;
3676
+
3677
+ default:
3678
+ /* We don't have any other property... */
3679
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
3680
+ break;
3681
+ }
3682
+ }
3683
+
3684
+ static void
3685
+ regress_test_wi_802_1x_dispose (GObject *gobject)
3686
+ {
3687
+ /* Chain up to the parent class */
3688
+ G_OBJECT_CLASS (regress_test_wi_802_1x_parent_class)->dispose (gobject);
3689
+ }
3690
+
3691
+ static void
3692
+ regress_test_wi_802_1x_class_init (RegressTestWi8021xClass *klass)
3693
+ {
3694
+ GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
3695
+ GParamSpec *pspec;
3696
+
3697
+ gobject_class->set_property = regress_test_wi_802_1x_set_property;
3698
+ gobject_class->get_property = regress_test_wi_802_1x_get_property;
3699
+ gobject_class->dispose = regress_test_wi_802_1x_dispose;
3700
+
3701
+ pspec = g_param_spec_boolean ("testbool",
3702
+ "Nick for testbool",
3703
+ "Blurb for testbool",
3704
+ TRUE,
3705
+ G_PARAM_READWRITE);
3706
+ g_object_class_install_property (gobject_class,
3707
+ PROP_TEST_WI_802_1X_TESTBOOL,
3708
+ pspec);
3709
+ }
3710
+
3711
+ static void
3712
+ regress_test_wi_802_1x_init (RegressTestWi8021x *obj)
3713
+ {
3714
+ obj->testbool = TRUE;
3715
+ }
3716
+
3717
+ RegressTestWi8021x *
3718
+ regress_test_wi_802_1x_new (void)
3719
+ {
3720
+ return g_object_new (REGRESS_TEST_TYPE_WI_802_1X, NULL);
3721
+ }
3722
+
3723
+ void
3724
+ regress_test_wi_802_1x_set_testbool (RegressTestWi8021x *obj, gboolean val)
3725
+ {
3726
+ obj->testbool = val;
3727
+ }
3728
+
3729
+ gboolean
3730
+ regress_test_wi_802_1x_get_testbool (RegressTestWi8021x *obj)
3731
+ {
3732
+ return obj->testbool;
3733
+ }
3734
+
3735
+ int
3736
+ regress_test_wi_802_1x_static_method (int x)
3737
+ {
3738
+ return 2*x;
3739
+ }
3740
+
3741
+ /* floating gobject */
3742
+ G_DEFINE_TYPE(RegressTestFloating, regress_test_floating, G_TYPE_INITIALLY_UNOWNED);
3743
+
3744
+ static void
3745
+ regress_test_floating_finalize(GObject *object)
3746
+ {
3747
+ g_assert(!g_object_is_floating (object));
3748
+
3749
+ G_OBJECT_CLASS(regress_test_floating_parent_class)->finalize(object);
3750
+ }
3751
+
3752
+ static void
3753
+ regress_test_floating_class_init (RegressTestFloatingClass *klass)
3754
+ {
3755
+ GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
3756
+ gobject_class->finalize = regress_test_floating_finalize;
3757
+ }
3758
+
3759
+ static void
3760
+ regress_test_floating_init (RegressTestFloating *obj)
3761
+ {
3762
+ }
3763
+
3764
+ /**
3765
+ * regress_test_floating_new:
3766
+ *
3767
+ * Returns:: A new floating #RegressTestFloating
3768
+ */
3769
+ RegressTestFloating *
3770
+ regress_test_floating_new (void)
3771
+ {
3772
+ return g_object_new (REGRESS_TEST_TYPE_FLOATING, NULL);
3773
+ }
3774
+
3775
+
3776
+ /**
3777
+ * regress_test_torture_signature_0:
3778
+ * @x:
3779
+ * @y: (out):
3780
+ * @z: (out):
3781
+ * @foo:
3782
+ * @q: (out):
3783
+ * @m:
3784
+ *
3785
+ */
3786
+ void
3787
+ regress_test_torture_signature_0 (int x,
3788
+ double *y,
3789
+ int *z,
3790
+ const char *foo,
3791
+ int *q,
3792
+ guint m)
3793
+ {
3794
+ *y = x;
3795
+ *z = x * 2;
3796
+ *q = g_utf8_strlen (foo, -1) + m;
3797
+ }
3798
+
3799
+ /**
3800
+ * regress_test_torture_signature_1:
3801
+ * @x:
3802
+ * @y: (out):
3803
+ * @z: (out):
3804
+ * @foo:
3805
+ * @q: (out):
3806
+ * @m:
3807
+ * @error: A #GError
3808
+ *
3809
+ * This function throws an error if m is odd.
3810
+ */
3811
+ gboolean
3812
+ regress_test_torture_signature_1 (int x,
3813
+ double *y,
3814
+ int *z,
3815
+ const char *foo,
3816
+ int *q,
3817
+ guint m,
3818
+ GError **error)
3819
+ {
3820
+ *y = x;
3821
+ *z = x * 2;
3822
+ *q = g_utf8_strlen (foo, -1) + m;
3823
+ if (m % 2 == 0)
3824
+ return TRUE;
3825
+ g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED, "m is odd");
3826
+ return FALSE;
3827
+ }
3828
+
3829
+ /**
3830
+ * regress_test_torture_signature_2:
3831
+ * @x:
3832
+ * @callback:
3833
+ * @user_data:
3834
+ * @notify:
3835
+ * @y: (out):
3836
+ * @z: (out):
3837
+ * @foo:
3838
+ * @q: (out):
3839
+ * @m:
3840
+ *
3841
+ */
3842
+ void
3843
+ regress_test_torture_signature_2 (int x,
3844
+ RegressTestCallbackUserData callback,
3845
+ gpointer user_data,
3846
+ GDestroyNotify notify,
3847
+ double *y,
3848
+ int *z,
3849
+ const char *foo,
3850
+ int *q,
3851
+ guint m)
3852
+ {
3853
+ *y = x;
3854
+ *z = x * 2;
3855
+ *q = g_utf8_strlen (foo, -1) + m;
3856
+ notify (user_data);
3857
+ }
3858
+
3859
+ /**
3860
+ * regress_test_date_in_gvalue:
3861
+ *
3862
+ * Returns: (transfer full):
3863
+ */
3864
+ GValue *
3865
+ regress_test_date_in_gvalue (void)
3866
+ {
3867
+ GValue *value = g_new0 (GValue, 1);
3868
+ GDate *date = g_date_new_dmy (5, 12, 1984);
3869
+
3870
+ g_value_init (value, G_TYPE_DATE);
3871
+ g_value_take_boxed (value, date);
3872
+
3873
+ return value;
3874
+ }
3875
+
3876
+ /**
3877
+ * regress_test_strv_in_gvalue:
3878
+ *
3879
+ * Returns: (transfer full):
3880
+ */
3881
+ GValue *
3882
+ regress_test_strv_in_gvalue (void)
3883
+ {
3884
+ GValue *value = g_new0 (GValue, 1);
3885
+ const char *strv[] = { "one", "two", "three", NULL };
3886
+
3887
+ g_value_init (value, G_TYPE_STRV);
3888
+ g_value_set_boxed (value, strv);
3889
+
3890
+ return value;
3891
+ }
3892
+
3893
+ /**
3894
+ * regress_test_multiline_doc_comments:
3895
+ *
3896
+ * This is a function.
3897
+ *
3898
+ * It has multiple lines in the documentation.
3899
+ *
3900
+ * The sky is blue.
3901
+ *
3902
+ * You will give me your credit card number.
3903
+ */
3904
+ void
3905
+ regress_test_multiline_doc_comments (void)
3906
+ {
3907
+ }
3908
+
3909
+ /**
3910
+ * regress_test_nested_parameter:
3911
+ * @a: An integer
3912
+ *
3913
+ * <informaltable>
3914
+ * <tgroup cols="3">
3915
+ * <thead>
3916
+ * <row>
3917
+ * <entry>Syntax</entry>
3918
+ * <entry>Explanation</entry>
3919
+ * <entry>Examples</entry>
3920
+ * </row>
3921
+ * </thead>
3922
+ * <tbody>
3923
+ * <row>
3924
+ * <entry>rgb(@r, @g, @b)</entry>
3925
+ * <entry>An opaque color; @r, @g, @b can be either integers between
3926
+ * 0 and 255 or percentages</entry>
3927
+ * <entry><literallayout>rgb(128, 10, 54)
3928
+ * rgb(20%, 30%, 0%)</literallayout></entry>
3929
+ * </row>
3930
+ * <row>
3931
+ * <entry>rgba(@r, @g, @b, @a)</entry>
3932
+ * <entry>A translucent color; @r, @g, @b are as in the previous row,
3933
+ * @a is a floating point number between 0 and 1</entry>
3934
+ * <entry><literallayout>rgba(255, 255, 0, 0.5)</literallayout></entry>
3935
+ * </row>
3936
+ * </tbody>
3937
+ * </tgroup>
3938
+ * </informaltable>
3939
+ *
3940
+ * What we're testing here is that the scanner ignores the @a nested inside XML.
3941
+ */
3942
+ void
3943
+ regress_test_nested_parameter (int a)
3944
+ {
3945
+ }
3946
+
3947
+ /**
3948
+ * regress_introspectable_via_alias:
3949
+ *
3950
+ */
3951
+ void
3952
+ regress_introspectable_via_alias (RegressPtrArrayAlias *data)
3953
+ {
3954
+ }
3955
+
3956
+ /**
3957
+ * regress_not_introspectable_via_alias:
3958
+ *
3959
+ */
3960
+ void
3961
+ regress_not_introspectable_via_alias (RegressVaListAlias ok)
3962
+ {
3963
+ }
3964
+
3965
+ /**
3966
+ * regress_aliased_caller_alloc:
3967
+ * @boxed: (out):
3968
+ */
3969
+ void regress_aliased_caller_alloc (RegressAliasedTestBoxed *boxed)
3970
+ {
3971
+ boxed->priv = g_slice_new0 (RegressTestBoxedPrivate);
3972
+ boxed->priv->magic = 0xdeadbeef;
3973
+ }
3974
+
3975
+ void
3976
+ regress_test_struct_fixed_array_frob (RegressTestStructFixedArray *str)
3977
+ {
3978
+ guint i;
3979
+ str->just_int = 7;
3980
+
3981
+ for (i = 0; i < G_N_ELEMENTS(str->array); i++)
3982
+ str->array[i] = 42 + i;
3983
+ }
3984
+
3985
+ /**
3986
+ * regress_has_parameter_named_attrs:
3987
+ * @foo: some int
3988
+ * @attributes: (type guint32) (array fixed-size=32): list of attributes
3989
+ *
3990
+ * This test case mirrors GnomeKeyringPasswordSchema from
3991
+ * libgnome-keyring.
3992
+ */
3993
+ void
3994
+ regress_has_parameter_named_attrs (int foo,
3995
+ gpointer attributes)
3996
+ {
3997
+ }
3998
+
3999
+ /**
4000
+ * regress_test_versioning:
4001
+ *
4002
+ * Since: 1.32.1
4003
+ * Deprecated: 1.33.3: Use foobar instead
4004
+ * Stability: Unstable
4005
+ */
4006
+ void
4007
+ regress_test_versioning (void)
4008
+ {
4009
+ }