gobject-introspection 2.2.0-x86-mingw32 → 2.2.1-x86-mingw32

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (176) hide show
  1. checksums.yaml +4 -4
  2. data/Rakefile +7 -7
  3. data/ext/gobject-introspection/rb-gi-argument.c +28 -3
  4. data/ext/gobject-introspection/rb-gi-constructor-info.c +6 -1
  5. data/ext/gobject-introspection/rb-gi-function-info.c +29 -4
  6. data/ext/gobject-introspection/rb-gi-loader.c +19 -3
  7. data/ext/gobject-introspection/rb-gi-struct-info.c +28 -16
  8. data/lib/2.0/gobject_introspection.so +0 -0
  9. data/lib/gobject-introspection/callable-info.rb +16 -7
  10. data/lib/gobject-introspection/loader.rb +47 -19
  11. data/test/test-object-info.rb +1 -1
  12. data/test/test-signal-info.rb +2 -2
  13. data/test/test-struct-info.rb +1 -1
  14. data/vendor/local/bin/g-ir-compiler.exe +0 -0
  15. data/vendor/local/bin/g-ir-generate.exe +0 -0
  16. data/vendor/local/bin/libgirepository-1.0-1.dll +0 -0
  17. data/vendor/local/include/gobject-introspection-1.0/giarginfo.h +30 -0
  18. data/vendor/local/include/gobject-introspection-1.0/gibaseinfo.h +31 -0
  19. data/vendor/local/include/gobject-introspection-1.0/gicallableinfo.h +36 -0
  20. data/vendor/local/include/gobject-introspection-1.0/giconstantinfo.h +12 -0
  21. data/vendor/local/include/gobject-introspection-1.0/gienuminfo.h +26 -0
  22. data/vendor/local/include/gobject-introspection-1.0/gifieldinfo.h +19 -0
  23. data/vendor/local/include/gobject-introspection-1.0/gifunctioninfo.h +23 -0
  24. data/vendor/local/include/gobject-introspection-1.0/giinterfaceinfo.h +38 -0
  25. data/vendor/local/include/gobject-introspection-1.0/giobjectinfo.h +72 -2
  26. data/vendor/local/include/gobject-introspection-1.0/gipropertyinfo.h +12 -0
  27. data/vendor/local/include/gobject-introspection-1.0/giregisteredtypeinfo.h +11 -0
  28. data/vendor/local/include/gobject-introspection-1.0/girepository.h +68 -8
  29. data/vendor/local/include/gobject-introspection-1.0/girffi.h +25 -1
  30. data/vendor/local/include/gobject-introspection-1.0/gisignalinfo.h +12 -0
  31. data/vendor/local/include/gobject-introspection-1.0/gistructinfo.h +24 -0
  32. data/vendor/local/include/gobject-introspection-1.0/gitypeinfo.h +31 -0
  33. data/vendor/local/include/gobject-introspection-1.0/gitypelib.h +25 -0
  34. data/vendor/local/include/gobject-introspection-1.0/gitypes.h +84 -13
  35. data/vendor/local/include/gobject-introspection-1.0/giunioninfo.h +27 -0
  36. data/vendor/local/include/gobject-introspection-1.0/giversionmacros.h +128 -0
  37. data/vendor/local/include/gobject-introspection-1.0/givfuncinfo.h +17 -0
  38. data/vendor/local/lib/girepository-1.0/GIRepository-2.0.typelib +0 -0
  39. data/vendor/local/lib/girepository-1.0/GLib-2.0.typelib +0 -0
  40. data/vendor/local/lib/girepository-1.0/GObject-2.0.typelib +0 -0
  41. data/vendor/local/lib/girepository-1.0/Gio-2.0.typelib +0 -0
  42. data/vendor/local/lib/girepository-1.0/libxml2-2.0.typelib +0 -0
  43. data/vendor/local/lib/girepository-1.0/win32-1.0.typelib +0 -0
  44. data/vendor/local/lib/gobject-introspection/giscanner/__init__.pyc +0 -0
  45. data/vendor/local/lib/gobject-introspection/giscanner/__init__.pyo +0 -0
  46. data/vendor/local/lib/gobject-introspection/giscanner/annotationmain.py +5 -4
  47. data/vendor/local/lib/gobject-introspection/giscanner/annotationmain.pyc +0 -0
  48. data/vendor/local/lib/gobject-introspection/giscanner/annotationmain.pyo +0 -0
  49. data/vendor/local/lib/gobject-introspection/giscanner/annotationparser.py +1865 -913
  50. data/vendor/local/lib/gobject-introspection/giscanner/annotationparser.pyc +0 -0
  51. data/vendor/local/lib/gobject-introspection/giscanner/annotationparser.pyo +0 -0
  52. data/vendor/local/lib/gobject-introspection/giscanner/ast.py +49 -16
  53. data/vendor/local/lib/gobject-introspection/giscanner/ast.pyc +0 -0
  54. data/vendor/local/lib/gobject-introspection/giscanner/ast.pyo +0 -0
  55. data/vendor/local/lib/gobject-introspection/giscanner/cachestore.py +10 -4
  56. data/vendor/local/lib/gobject-introspection/giscanner/cachestore.pyc +0 -0
  57. data/vendor/local/lib/gobject-introspection/giscanner/cachestore.pyo +0 -0
  58. data/vendor/local/lib/gobject-introspection/giscanner/ccompiler.py +202 -0
  59. data/vendor/local/lib/gobject-introspection/giscanner/ccompiler.pyc +0 -0
  60. data/vendor/local/lib/gobject-introspection/giscanner/ccompiler.pyo +0 -0
  61. data/vendor/local/lib/gobject-introspection/giscanner/codegen.py +32 -1
  62. data/vendor/local/lib/gobject-introspection/giscanner/codegen.pyc +0 -0
  63. data/vendor/local/lib/gobject-introspection/giscanner/codegen.pyo +0 -0
  64. data/vendor/local/lib/gobject-introspection/giscanner/collections/__init__.py +1 -0
  65. data/vendor/local/lib/gobject-introspection/giscanner/collections/__init__.pyc +0 -0
  66. data/vendor/local/lib/gobject-introspection/giscanner/collections/__init__.pyo +0 -0
  67. data/vendor/local/lib/gobject-introspection/giscanner/collections/counter.py +305 -0
  68. data/vendor/local/lib/gobject-introspection/giscanner/collections/counter.pyc +0 -0
  69. data/vendor/local/lib/gobject-introspection/giscanner/collections/counter.pyo +0 -0
  70. data/vendor/local/lib/gobject-introspection/giscanner/collections/ordereddict.pyc +0 -0
  71. data/vendor/local/lib/gobject-introspection/giscanner/collections/ordereddict.pyo +0 -0
  72. data/vendor/local/lib/gobject-introspection/giscanner/docmain.pyc +0 -0
  73. data/vendor/local/lib/gobject-introspection/giscanner/docmain.pyo +0 -0
  74. data/vendor/local/lib/gobject-introspection/giscanner/doctemplates/C/callback.tmpl +4 -0
  75. data/vendor/local/lib/gobject-introspection/giscanner/doctemplates/C/field.tmpl +1 -0
  76. data/vendor/local/lib/gobject-introspection/giscanner/doctemplates/C/function.tmpl +8 -9
  77. data/vendor/local/lib/gobject-introspection/giscanner/doctemplates/C/interface.tmpl +2 -0
  78. data/vendor/local/lib/gobject-introspection/giscanner/doctemplates/Gjs/callback.tmpl +27 -0
  79. data/vendor/local/lib/gobject-introspection/giscanner/doctemplates/Gjs/class.tmpl +17 -5
  80. data/vendor/local/lib/gobject-introspection/giscanner/doctemplates/Gjs/enum.tmpl +8 -0
  81. data/vendor/local/lib/gobject-introspection/giscanner/doctemplates/Gjs/field.tmpl +9 -0
  82. data/vendor/local/lib/gobject-introspection/giscanner/doctemplates/Gjs/function.tmpl +12 -13
  83. data/vendor/local/lib/gobject-introspection/giscanner/doctemplates/Gjs/interface.tmpl +17 -0
  84. data/vendor/local/lib/gobject-introspection/giscanner/doctemplates/Gjs/property.tmpl +3 -4
  85. data/vendor/local/lib/gobject-introspection/giscanner/doctemplates/Gjs/signal.tmpl +10 -9
  86. data/vendor/local/lib/gobject-introspection/giscanner/doctemplates/Gjs/vfunc.tmpl +7 -7
  87. data/vendor/local/lib/gobject-introspection/giscanner/doctemplates/Python/callback.tmpl +27 -0
  88. data/vendor/local/lib/gobject-introspection/giscanner/doctemplates/Python/class.tmpl +5 -4
  89. data/vendor/local/lib/gobject-introspection/giscanner/doctemplates/Python/field.tmpl +1 -0
  90. data/vendor/local/lib/gobject-introspection/giscanner/doctemplates/Python/function.tmpl +8 -14
  91. data/vendor/local/lib/gobject-introspection/giscanner/doctemplates/Python/interface.tmpl +16 -0
  92. data/vendor/local/lib/gobject-introspection/giscanner/doctemplates/Python/property.tmpl +2 -3
  93. data/vendor/local/lib/gobject-introspection/giscanner/doctemplates/Python/signal.tmpl +6 -7
  94. data/vendor/local/lib/gobject-introspection/giscanner/doctemplates/Python/vfunc.tmpl +7 -13
  95. data/vendor/local/lib/gobject-introspection/giscanner/doctemplates/base.tmpl +10 -19
  96. data/vendor/local/lib/gobject-introspection/giscanner/doctemplates/class.tmpl +24 -3
  97. data/vendor/local/lib/gobject-introspection/giscanner/doctemplates/namespace.tmpl +4 -7
  98. data/vendor/local/lib/gobject-introspection/giscanner/docwriter.py +375 -61
  99. data/vendor/local/lib/gobject-introspection/giscanner/docwriter.pyc +0 -0
  100. data/vendor/local/lib/gobject-introspection/giscanner/docwriter.pyo +0 -0
  101. data/vendor/local/lib/gobject-introspection/giscanner/dumper.py +43 -75
  102. data/vendor/local/lib/gobject-introspection/giscanner/dumper.pyc +0 -0
  103. data/vendor/local/lib/gobject-introspection/giscanner/dumper.pyo +0 -0
  104. data/vendor/local/lib/gobject-introspection/giscanner/gdumpparser.py +1 -20
  105. data/vendor/local/lib/gobject-introspection/giscanner/gdumpparser.pyc +0 -0
  106. data/vendor/local/lib/gobject-introspection/giscanner/gdumpparser.pyo +0 -0
  107. data/vendor/local/lib/gobject-introspection/giscanner/girparser.py +33 -15
  108. data/vendor/local/lib/gobject-introspection/giscanner/girparser.pyc +0 -0
  109. data/vendor/local/lib/gobject-introspection/giscanner/girparser.pyo +0 -0
  110. data/vendor/local/lib/gobject-introspection/giscanner/girwriter.py +51 -22
  111. data/vendor/local/lib/gobject-introspection/giscanner/girwriter.pyc +0 -0
  112. data/vendor/local/lib/gobject-introspection/giscanner/girwriter.pyo +0 -0
  113. data/vendor/local/lib/gobject-introspection/giscanner/introspectablepass.pyc +0 -0
  114. data/vendor/local/lib/gobject-introspection/giscanner/introspectablepass.pyo +0 -0
  115. data/vendor/local/lib/gobject-introspection/giscanner/libtoolimporter.pyc +0 -0
  116. data/vendor/local/lib/gobject-introspection/giscanner/libtoolimporter.pyo +0 -0
  117. data/vendor/local/lib/gobject-introspection/giscanner/maintransformer.py +285 -254
  118. data/vendor/local/lib/gobject-introspection/giscanner/maintransformer.pyc +0 -0
  119. data/vendor/local/lib/gobject-introspection/giscanner/maintransformer.pyo +0 -0
  120. data/vendor/local/lib/gobject-introspection/giscanner/message.py +41 -25
  121. data/vendor/local/lib/gobject-introspection/giscanner/message.pyc +0 -0
  122. data/vendor/local/lib/gobject-introspection/giscanner/message.pyo +0 -0
  123. data/vendor/local/lib/gobject-introspection/giscanner/scannermain.py +67 -15
  124. data/vendor/local/lib/gobject-introspection/giscanner/scannermain.pyc +0 -0
  125. data/vendor/local/lib/gobject-introspection/giscanner/scannermain.pyo +0 -0
  126. data/vendor/local/lib/gobject-introspection/giscanner/sectionparser.pyc +0 -0
  127. data/vendor/local/lib/gobject-introspection/giscanner/sectionparser.pyo +0 -0
  128. data/vendor/local/lib/gobject-introspection/giscanner/shlibs.py +10 -6
  129. data/vendor/local/lib/gobject-introspection/giscanner/shlibs.pyc +0 -0
  130. data/vendor/local/lib/gobject-introspection/giscanner/shlibs.pyo +0 -0
  131. data/vendor/local/lib/gobject-introspection/giscanner/sourcescanner.py +14 -8
  132. data/vendor/local/lib/gobject-introspection/giscanner/sourcescanner.pyc +0 -0
  133. data/vendor/local/lib/gobject-introspection/giscanner/sourcescanner.pyo +0 -0
  134. data/vendor/local/lib/gobject-introspection/giscanner/testcodegen.py +16 -2
  135. data/vendor/local/lib/gobject-introspection/giscanner/testcodegen.pyc +0 -0
  136. data/vendor/local/lib/gobject-introspection/giscanner/testcodegen.pyo +0 -0
  137. data/vendor/local/lib/gobject-introspection/giscanner/transformer.py +150 -169
  138. data/vendor/local/lib/gobject-introspection/giscanner/transformer.pyc +0 -0
  139. data/vendor/local/lib/gobject-introspection/giscanner/transformer.pyo +0 -0
  140. data/vendor/local/lib/gobject-introspection/giscanner/utils.py +64 -3
  141. data/vendor/local/lib/gobject-introspection/giscanner/utils.pyc +0 -0
  142. data/vendor/local/lib/gobject-introspection/giscanner/utils.pyo +0 -0
  143. data/vendor/local/lib/gobject-introspection/giscanner/xmlwriter.py +5 -44
  144. data/vendor/local/lib/gobject-introspection/giscanner/xmlwriter.pyc +0 -0
  145. data/vendor/local/lib/gobject-introspection/giscanner/xmlwriter.pyo +0 -0
  146. data/vendor/local/lib/libgirepository-1.0.a +0 -0
  147. data/vendor/local/lib/libgirepository-1.0.dll.a +0 -0
  148. data/vendor/local/lib/libgirepository-1.0.la +1 -1
  149. data/vendor/local/lib/pkgconfig/gobject-introspection-1.0.pc +4 -4
  150. data/vendor/local/lib/pkgconfig/gobject-introspection-no-export-1.0.pc +5 -5
  151. data/vendor/local/share/gir-1.0/GIRepository-2.0.gir +352 -143
  152. data/vendor/local/share/gir-1.0/GLib-2.0.gir +6402 -3872
  153. data/vendor/local/share/gir-1.0/GModule-2.0.gir +42 -24
  154. data/vendor/local/share/gir-1.0/GObject-2.0.gir +1543 -887
  155. data/vendor/local/share/gir-1.0/Gio-2.0.gir +10859 -3705
  156. data/vendor/local/share/gobject-introspection-1.0/tests/annotation.c +10 -14
  157. data/vendor/local/share/gobject-introspection-1.0/tests/annotation.h +112 -9
  158. data/vendor/local/share/gobject-introspection-1.0/tests/drawable.c +2 -0
  159. data/vendor/local/share/gobject-introspection-1.0/tests/drawable.h +11 -0
  160. data/vendor/local/share/gobject-introspection-1.0/tests/everything.c +106 -0
  161. data/vendor/local/share/gobject-introspection-1.0/tests/everything.h +107 -0
  162. data/vendor/local/share/gobject-introspection-1.0/tests/foo.c +3 -3
  163. data/vendor/local/share/gobject-introspection-1.0/tests/foo.h +145 -0
  164. data/vendor/local/share/gobject-introspection-1.0/tests/gimarshallingtests.c +166 -10
  165. data/vendor/local/share/gobject-introspection-1.0/tests/gimarshallingtests.h +790 -0
  166. data/vendor/local/share/gobject-introspection-1.0/tests/gitestmacros.h +10 -0
  167. data/vendor/local/share/gobject-introspection-1.0/tests/regress.c +79 -28
  168. data/vendor/local/share/gobject-introspection-1.0/tests/regress.h +462 -0
  169. data/vendor/local/share/gobject-introspection-1.0/tests/utility.c +2 -0
  170. data/vendor/local/share/gobject-introspection-1.0/tests/utility.h +7 -0
  171. data/vendor/local/share/gobject-introspection-1.0/tests/warnlib.c +14 -0
  172. data/vendor/local/share/gobject-introspection-1.0/tests/warnlib.h +10 -0
  173. data/vendor/local/share/man/man1/g-ir-compiler.1 +1 -10
  174. metadata +38 -23
  175. data/lib/1.9/gobject_introspection.so +0 -0
  176. data/lib/2.1/gobject_introspection.so +0 -0
@@ -21,20 +21,17 @@ import re
21
21
 
22
22
  from . import ast
23
23
  from . import message
24
- from .annotationparser import (TAG_VFUNC, TAG_SINCE, TAG_DEPRECATED, TAG_RETURNS,
25
- TAG_ATTRIBUTES, TAG_RENAME_TO, TAG_TYPE,
26
- TAG_UNREF_FUNC, TAG_REF_FUNC, TAG_SET_VALUE_FUNC,
27
- TAG_GET_VALUE_FUNC, TAG_VALUE, TAG_TRANSFER,
28
- TAG_STABILITY)
29
- from .annotationparser import (OPT_ALLOW_NONE, OPT_ARRAY, OPT_ATTRIBUTE,
30
- OPT_ELEMENT_TYPE, OPT_IN, OPT_INOUT,
31
- OPT_INOUT_ALT, OPT_OUT, OPT_SCOPE,
32
- OPT_OUT_CALLER_ALLOCATES, OPT_OUT_CALLEE_ALLOCATES,
33
- OPT_TYPE, OPT_CLOSURE, OPT_DESTROY, OPT_TRANSFER, OPT_SKIP,
34
- OPT_FOREIGN, OPT_ARRAY_FIXED_SIZE,
35
- OPT_ARRAY_LENGTH, OPT_ARRAY_ZERO_TERMINATED,
36
- OPT_CONSTRUCTOR, OPT_METHOD,
37
- OPT_TRANSFER_NONE, OPT_TRANSFER_FLOATING)
24
+ from .annotationparser import (TAG_DEPRECATED, TAG_SINCE, TAG_STABILITY, TAG_RETURNS)
25
+ from .annotationparser import (ANN_ALLOW_NONE, ANN_ARRAY, ANN_ATTRIBUTES, ANN_CLOSURE,
26
+ ANN_CONSTRUCTOR, ANN_DESTROY, ANN_ELEMENT_TYPE, ANN_FOREIGN,
27
+ ANN_GET_VALUE_FUNC, ANN_IN, ANN_INOUT, ANN_METHOD, ANN_OUT,
28
+ ANN_REF_FUNC, ANN_RENAME_TO, ANN_SCOPE, ANN_SET_VALUE_FUNC,
29
+ ANN_SKIP, ANN_TRANSFER, ANN_TYPE, ANN_UNREF_FUNC, ANN_VALUE,
30
+ ANN_VFUNC, ANN_NULLABLE, ANN_OPTIONAL)
31
+ from .annotationparser import (OPT_ARRAY_FIXED_SIZE, OPT_ARRAY_LENGTH, OPT_ARRAY_ZERO_TERMINATED,
32
+ OPT_OUT_CALLEE_ALLOCATES, OPT_OUT_CALLER_ALLOCATES,
33
+ OPT_TRANSFER_FLOATING, OPT_TRANSFER_NONE)
34
+
38
35
  from .utils import to_underscores_noprefix
39
36
 
40
37
 
@@ -110,6 +107,7 @@ class MainTransformer(object):
110
107
  if isinstance(node, (ast.Class, ast.Interface, ast.Record, ast.Union)):
111
108
  for field in node.fields:
112
109
  if (field
110
+ and field.name is not None
113
111
  and field.name.startswith('_')
114
112
  and field.anonymous_node is not None
115
113
  and isinstance(field.anonymous_node, ast.Callback)):
@@ -133,30 +131,43 @@ class MainTransformer(object):
133
131
 
134
132
  return param.argname
135
133
 
134
+ def _get_validate_field_name(self, parent, field_name, origin):
135
+ try:
136
+ field = parent.get_field(field_name)
137
+ except ValueError:
138
+ field = None
139
+ if field is None:
140
+ origin_name = 'field %s' % (origin.name, )
141
+ message.log_node(
142
+ message.FATAL, parent,
143
+ "can't find field %s referenced by %s of %r"
144
+ % (field_name, origin_name, parent.name))
145
+
146
+ return field.name
147
+
136
148
  def _apply_annotation_rename_to(self, node, chain, block):
137
149
  if not block:
138
150
  return
139
- rename_to = block.tags.get(TAG_RENAME_TO)
151
+ rename_to = block.annotations.get(ANN_RENAME_TO)
140
152
  if not rename_to:
141
153
  return
142
- rename_to = rename_to.value
154
+ rename_to = rename_to[0]
143
155
  target = self._namespace.get_by_symbol(rename_to)
144
156
  if not target:
145
157
  message.warn_node(node,
146
- "Can't find symbol %r referenced by Rename annotation" % (
147
- rename_to, ))
158
+ "Can't find symbol %r referenced by \"rename-to\" annotation" % (rename_to, ))
148
159
  elif target.shadowed_by:
149
160
  message.warn_node(node,
150
- "Function %r already shadowed by %r, can't overwrite with %r" % (
151
- target.symbol,
152
- target.shadowed_by,
153
- rename_to))
161
+ "Function %r already shadowed by %r, can't overwrite "
162
+ "with %r" % (target.symbol,
163
+ target.shadowed_by,
164
+ rename_to))
154
165
  elif target.shadows:
155
166
  message.warn_node(node,
156
- "Function %r already shadows %r, can't multiply shadow with %r" % (
157
- target.symbol,
158
- target.shadows,
159
- rename_to))
167
+ "Function %r already shadows %r, can't multiply shadow "
168
+ "with %r" % (target.symbol,
169
+ target.shadows,
170
+ rename_to))
160
171
  else:
161
172
  target.shadowed_by = node.name
162
173
  node.shadows = target.name
@@ -216,10 +227,10 @@ class MainTransformer(object):
216
227
  for field in node.fields:
217
228
  self._apply_annotations_field(node, block, field)
218
229
  name = self._get_annotation_name(node)
219
- section_name = 'SECTION:' + name.lower()
230
+ section_name = 'SECTION:%s' % (name.lower(), )
220
231
  block = self._blocks.get(section_name)
221
- if block:
222
- node.doc = block.comment if block.comment else ''
232
+ if block and block.description:
233
+ node.doc = block.description
223
234
  if isinstance(node, (ast.Class, ast.Interface)):
224
235
  for prop in node.properties:
225
236
  self._apply_annotations_property(node, prop)
@@ -228,29 +239,26 @@ class MainTransformer(object):
228
239
  if isinstance(node, ast.Class):
229
240
  block = self._get_block(node)
230
241
  if block:
231
- tag = block.tags.get(TAG_UNREF_FUNC)
232
- node.unref_func = tag.value if tag else None
233
- tag = block.tags.get(TAG_REF_FUNC)
234
- node.ref_func = tag.value if tag else None
235
- tag = block.tags.get(TAG_SET_VALUE_FUNC)
236
- node.set_value_func = tag.value if tag else None
237
- tag = block.tags.get(TAG_GET_VALUE_FUNC)
238
- node.get_value_func = tag.value if tag else None
242
+ annotation = block.annotations.get(ANN_UNREF_FUNC)
243
+ node.unref_func = annotation[0] if annotation else None
244
+ annotation = block.annotations.get(ANN_REF_FUNC)
245
+ node.ref_func = annotation[0] if annotation else None
246
+ annotation = block.annotations.get(ANN_SET_VALUE_FUNC)
247
+ node.set_value_func = annotation[0] if annotation else None
248
+ annotation = block.annotations.get(ANN_GET_VALUE_FUNC)
249
+ node.get_value_func = annotation[0] if annotation else None
239
250
  if isinstance(node, ast.Constant):
240
251
  self._apply_annotations_constant(node)
241
252
  return True
242
253
 
243
- def _adjust_container_type(self, parent, node, options):
244
- has_element_type = OPT_ELEMENT_TYPE in options
245
- has_array = OPT_ARRAY in options
246
-
247
- if has_array:
248
- self._apply_annotations_array(parent, node, options)
249
- elif has_element_type:
250
- self._apply_annotations_element_type(parent, node, options)
254
+ def _adjust_container_type(self, parent, node, annotations):
255
+ if ANN_ARRAY in annotations:
256
+ self._apply_annotations_array(parent, node, annotations)
257
+ elif ANN_ELEMENT_TYPE in annotations:
258
+ self._apply_annotations_element_type(parent, node, annotations)
251
259
 
252
260
  if isinstance(node.type, ast.Array):
253
- self._check_array_element_type(node.type, options)
261
+ self._check_array_element_type(node.type, annotations)
254
262
 
255
263
  def _resolve(self, type_str, type_node=None, node=None, parent=None):
256
264
  def grab_one(type_str, resolver, top_combiner, combiner):
@@ -279,7 +287,10 @@ class MainTransformer(object):
279
287
  return base
280
288
  if isinstance(base, ast.List) and len(rest) == 1:
281
289
  return ast.List(base.name, *rest)
282
- if isinstance(base, ast.Map) and len(rest) == 2:
290
+ elif isinstance(base, ast.Array) and len(rest) == 1:
291
+ base.element_type = rest[0]
292
+ return base
293
+ elif isinstance(base, ast.Map) and len(rest) == 2:
283
294
  return ast.Map(*rest)
284
295
  message.warn(
285
296
  "Too many parameters in type specification %r" % (type_str, ))
@@ -319,18 +330,18 @@ class MainTransformer(object):
319
330
  block = self._blocks.get(func.symbol)
320
331
  if block:
321
332
  if isinstance(param, ast.Parameter):
322
- tag = block.params.get(param.argname)
333
+ part = block.params.get(param.argname)
323
334
  elif isinstance(param, ast.Return):
324
- tag = block.tags.get(TAG_RETURNS)
335
+ part = block.tags.get(TAG_RETURNS)
325
336
  else:
326
- tag = None
337
+ part = None
327
338
 
328
- if tag.position:
329
- return tag.position
339
+ if part.position:
340
+ return part.position
330
341
 
331
342
  return block.position
332
343
 
333
- def _check_array_element_type(self, array, options):
344
+ def _check_array_element_type(self, array, annotations):
334
345
  array_type = array.array_type
335
346
  element_type = array.element_type
336
347
 
@@ -341,7 +352,7 @@ class MainTransformer(object):
341
352
  if ((element_type in ast.BASIC_GIR_TYPES and not element_type in ast.POINTER_TYPES)
342
353
  or isinstance(element_type, (ast.Enum, ast.Bitfield))):
343
354
  message.warn("invalid (element-type) for a GPtrArray, "
344
- "must be a pointer", options.position)
355
+ "must be a pointer", annotations.position)
345
356
 
346
357
  # GByteArrays have (element-type) guint8 by default
347
358
  if array_type == ast.Array.GLIB_BYTEARRAY:
@@ -350,18 +361,12 @@ class MainTransformer(object):
350
361
  elif not element_type in [ast.TYPE_UINT8, ast.TYPE_INT8, ast.TYPE_CHAR]:
351
362
  message.warn("invalid (element-type) for a GByteArray, "
352
363
  "must be one of guint8, gint8 or gchar",
353
- options.position)
364
+ annotations.position)
354
365
 
355
- def _apply_annotations_array(self, parent, node, options):
356
- array_opt = options.get(OPT_ARRAY)
357
- if array_opt:
358
- array_values = array_opt.all()
359
- else:
360
- array_values = {}
361
-
362
- element_type = options.get(OPT_ELEMENT_TYPE)
363
- if element_type is not None:
364
- element_type_node = self._resolve(element_type.one(),
366
+ def _apply_annotations_array(self, parent, node, annotations):
367
+ element_type_options = annotations.get(ANN_ELEMENT_TYPE)
368
+ if element_type_options:
369
+ element_type_node = self._resolve(element_type_options[0],
365
370
  node.type, node, parent)
366
371
  elif isinstance(node.type, ast.Array):
367
372
  element_type_node = node.type.element_type
@@ -370,82 +375,82 @@ class MainTransformer(object):
370
375
  # and no (element-type) means array of Foo
371
376
  element_type_node = node.type.clone()
372
377
  # The element's ctype is the array's dereferenced
373
- if element_type_node.ctype is not None and \
374
- element_type_node.ctype.endswith('*'):
378
+ if element_type_node.ctype is not None and element_type_node.ctype.endswith('*'):
375
379
  element_type_node.ctype = element_type_node.ctype[:-1]
376
380
 
377
381
  if isinstance(node.type, ast.Array):
378
382
  array_type = node.type.array_type
379
383
  else:
380
384
  array_type = None
381
- container_type = ast.Array(array_type, element_type_node,
382
- ctype=node.type.ctype,
383
- is_const=node.type.is_const)
384
- if OPT_ARRAY_ZERO_TERMINATED in array_values:
385
- container_type.zeroterminated = array_values.get(
386
- OPT_ARRAY_ZERO_TERMINATED) == '1'
385
+
386
+ array_options = annotations.get(ANN_ARRAY)
387
+ container_type = ast.Array(array_type, element_type_node, ctype=node.type.ctype,
388
+ is_const=node.type.is_const)
389
+ if OPT_ARRAY_ZERO_TERMINATED in array_options:
390
+ container_type.zeroterminated = array_options.get(OPT_ARRAY_ZERO_TERMINATED) == '1'
387
391
  else:
388
392
  container_type.zeroterminated = False
389
- length = array_values.get(OPT_ARRAY_LENGTH)
390
- if length is not None:
391
- paramname = self._get_validate_parameter_name(parent, length, node)
393
+
394
+ length = array_options.get(OPT_ARRAY_LENGTH)
395
+ if length:
396
+ if isinstance(parent, ast.Compound):
397
+ paramname = self._get_validate_field_name(parent, length, node)
398
+ else:
399
+ paramname = self._get_validate_parameter_name(parent, length, node)
400
+ if paramname:
401
+ param = parent.get_parameter(paramname)
402
+ param.direction = node.direction
403
+ if param.direction == ast.PARAM_DIRECTION_OUT:
404
+ param.transfer = ast.PARAM_TRANSFER_FULL
392
405
  if paramname:
393
- param = parent.get_parameter(paramname)
394
- param.direction = node.direction
395
- if param.direction == ast.PARAM_DIRECTION_OUT:
396
- param.transfer = ast.PARAM_TRANSFER_FULL
397
- container_type.length_param_name = param.argname
398
- fixed = array_values.get(OPT_ARRAY_FIXED_SIZE)
406
+ container_type.length_param_name = paramname
407
+ fixed = array_options.get(OPT_ARRAY_FIXED_SIZE)
399
408
  if fixed:
400
409
  try:
401
410
  container_type.size = int(fixed)
402
- except ValueError:
411
+ except (TypeError, ValueError):
403
412
  # Already warned in annotationparser.py
404
413
  return
405
414
  node.type = container_type
406
415
 
407
- def _apply_annotations_element_type(self, parent, node, options):
408
- element_type_opt = options.get(OPT_ELEMENT_TYPE)
409
- if element_type_opt is None:
410
- message.warn(
411
- 'element-type annotation takes at least one option, '
412
- 'none given',
413
- options.position)
416
+ def _apply_annotations_element_type(self, parent, node, annotations):
417
+ element_type_options = annotations.get(ANN_ELEMENT_TYPE)
418
+ if element_type_options is None:
414
419
  return
415
420
 
416
421
  if isinstance(node.type, ast.List):
417
- if element_type_opt.length() != 1:
422
+ if len(element_type_options) != 1:
418
423
  message.warn(
419
- 'element-type annotation for a list must have exactly '
420
- 'one option, not %d options' % (element_type_opt.length(), ),
421
- options.position)
424
+ '"element-type" annotation for a list must have exactly '
425
+ 'one option, not %d options' % (len(element_type_options), ),
426
+ annotations.position)
422
427
  return
423
- node.type.element_type = self._resolve(element_type_opt.one(),
428
+ node.type.element_type = self._resolve(element_type_options[0],
424
429
  node.type, node, parent)
425
430
  elif isinstance(node.type, ast.Map):
426
- if element_type_opt.length() != 2:
431
+ if len(element_type_options) != 2:
427
432
  message.warn(
428
- 'element-type annotation for a hash table must have exactly '
429
- 'two options, not %d option(s)' % (element_type_opt.length(), ),
430
- options.position)
433
+ '"element-type" annotation for a hash table must have exactly '
434
+ 'two options, not %d option(s)' % (len(element_type_options), ),
435
+ annotations.position)
431
436
  return
432
- element_type = element_type_opt.flat()
433
- node.type.key_type = self._resolve(element_type[0],
437
+ node.type.key_type = self._resolve(element_type_options[0],
434
438
  node.type, node, parent)
435
- node.type.value_type = self._resolve(element_type[1],
439
+ node.type.value_type = self._resolve(element_type_options[1],
436
440
  node.type, node, parent)
437
441
  elif isinstance(node.type, ast.Array):
438
- if element_type_opt.length() != 1:
442
+ if len(element_type_options) != 1:
439
443
  message.warn(
440
- 'element-type annotation for an array must have exactly '
441
- 'one option, not %d options' % (element_type_opt.length(), ),
442
- options.position)
444
+ '"element-type" annotation for an array must have exactly '
445
+ 'one option, not %d options' % (len(element_type_options), ),
446
+ annotations.position)
443
447
  return
444
- node.type.element_type = self._resolve(element_type_opt.one(),
448
+ node.type.element_type = self._resolve(element_type_options[0],
445
449
  node.type, node, parent)
446
450
  else:
447
- message.warn_node(parent,
448
- "Unknown container %r for element-type annotation" % (node.type, ))
451
+ message.warn(
452
+ "Unknown container %r for element-type annotation" % (node.type, ),
453
+ annotations.position)
449
454
 
450
455
  def _get_transfer_default_param(self, parent, node):
451
456
  if node.direction in [ast.PARAM_DIRECTION_INOUT,
@@ -529,23 +534,22 @@ class MainTransformer(object):
529
534
  raise AssertionError(node)
530
535
 
531
536
  def _apply_annotations_param_ret_common(self, parent, node, tag):
532
- options = getattr(tag, 'options', {})
537
+ annotations = tag.annotations if tag else {}
533
538
 
534
- param_type = options.get(OPT_TYPE)
535
- if param_type:
536
- node.type = self._resolve_toplevel(param_type.one(),
539
+ type_annotation = annotations.get(ANN_TYPE)
540
+ if type_annotation:
541
+ node.type = self._resolve_toplevel(type_annotation[0],
537
542
  node.type, node, parent)
538
543
 
539
544
  caller_allocates = False
540
545
  annotated_direction = None
541
- if (OPT_INOUT in options or OPT_INOUT_ALT in options):
546
+ if ANN_INOUT in annotations:
542
547
  annotated_direction = ast.PARAM_DIRECTION_INOUT
543
- elif OPT_OUT in options:
544
- subtype = options[OPT_OUT]
545
- if subtype is not None:
546
- subtype = subtype.one()
548
+ elif ANN_OUT in annotations:
547
549
  annotated_direction = ast.PARAM_DIRECTION_OUT
548
- if subtype in (None, ''):
550
+
551
+ options = annotations[ANN_OUT]
552
+ if len(options) == 0:
549
553
  if node.type.target_giname and node.type.ctype:
550
554
  target = self._transformer.lookup_giname(node.type.target_giname)
551
555
  target = self._transformer.resolve_aliases(target)
@@ -554,11 +558,13 @@ class MainTransformer(object):
554
558
  caller_allocates = (not has_double_indirection and is_structure_or_union)
555
559
  else:
556
560
  caller_allocates = False
557
- elif subtype == OPT_OUT_CALLER_ALLOCATES:
558
- caller_allocates = True
559
- elif subtype == OPT_OUT_CALLEE_ALLOCATES:
560
- caller_allocates = False
561
- elif OPT_IN in options:
561
+ else:
562
+ option = options[0]
563
+ if option == OPT_OUT_CALLER_ALLOCATES:
564
+ caller_allocates = True
565
+ elif option == OPT_OUT_CALLEE_ALLOCATES:
566
+ caller_allocates = False
567
+ elif ANN_IN in annotations:
562
568
  annotated_direction = ast.PARAM_DIRECTION_IN
563
569
 
564
570
  if (annotated_direction is not None) and (annotated_direction != node.direction):
@@ -567,79 +573,89 @@ class MainTransformer(object):
567
573
  # Also reset the transfer default if we're toggling direction
568
574
  node.transfer = self._get_transfer_default(parent, node)
569
575
 
570
- transfer_tag = options.get(OPT_TRANSFER)
571
- if transfer_tag and transfer_tag.length() == 1:
572
- transfer = transfer_tag.one()
576
+ transfer_annotation = annotations.get(ANN_TRANSFER)
577
+ if transfer_annotation and len(transfer_annotation) == 1:
578
+ transfer = transfer_annotation[0]
573
579
  if transfer == OPT_TRANSFER_FLOATING:
574
580
  transfer = OPT_TRANSFER_NONE
575
581
  node.transfer = transfer
576
582
 
577
- self._adjust_container_type(parent, node, options)
583
+ self._adjust_container_type(parent, node, annotations)
584
+
585
+ if ANN_NULLABLE in annotations:
586
+ node.nullable = True
578
587
 
579
- if (OPT_ALLOW_NONE in options
580
- or node.type.target_giname == 'Gio.AsyncReadyCallback'
581
- or node.type.target_giname == 'Gio.Cancellable'):
582
- node.allow_none = True
588
+ if ANN_OPTIONAL in annotations:
589
+ node.optional = True
583
590
 
584
- if tag is not None and tag.comment is not None:
585
- node.doc = tag.comment
591
+ if ANN_ALLOW_NONE in annotations:
592
+ if node.direction == ast.PARAM_DIRECTION_OUT:
593
+ node.optional = True
594
+ else:
595
+ node.nullable = True
596
+
597
+ if (node.direction != ast.PARAM_DIRECTION_OUT and
598
+ (node.type.target_giname == 'Gio.AsyncReadyCallback' or
599
+ node.type.target_giname == 'Gio.Cancellable')):
600
+ node.nullable = True
586
601
 
587
- if OPT_SKIP in options:
602
+ if tag and tag.description:
603
+ node.doc = tag.description
604
+
605
+ if ANN_SKIP in annotations:
588
606
  node.skip = True
589
607
 
590
- if options:
591
- for attribute in options.getall(OPT_ATTRIBUTE):
592
- node.attributes.append(attribute.flat())
608
+ if annotations:
609
+ attributes_annotation = annotations.get(ANN_ATTRIBUTES)
610
+ if attributes_annotation is not None:
611
+ for key, value in attributes_annotation.items():
612
+ if value:
613
+ node.attributes[key] = value
593
614
 
594
615
  def _apply_annotations_annotated(self, node, block):
595
616
  if block is None:
596
617
  return
597
618
 
598
- node.doc = block.comment if block.comment else ''
619
+ if block.description:
620
+ node.doc = block.description
599
621
 
600
622
  since_tag = block.tags.get(TAG_SINCE)
601
623
  if since_tag is not None:
602
- node.version = since_tag.value
624
+ if since_tag.value:
625
+ node.version = since_tag.value
626
+ if since_tag.description:
627
+ node.version_doc = since_tag.description
603
628
 
604
629
  deprecated_tag = block.tags.get(TAG_DEPRECATED)
605
630
  if deprecated_tag is not None:
606
- value = deprecated_tag.value
607
- if ': ' in value:
608
- colon = value.find(': ')
609
- version = value[:colon]
610
- desc = value[colon + 2:]
611
- else:
612
- desc = value
613
- version = None
614
- node.deprecated = desc
615
- if version is not None:
616
- node.deprecated_version = version
631
+ if deprecated_tag.value:
632
+ node.deprecated = deprecated_tag.value
633
+ if deprecated_tag.description:
634
+ node.deprecated_doc = deprecated_tag.description
617
635
 
618
636
  stability_tag = block.tags.get(TAG_STABILITY)
619
637
  if stability_tag is not None:
620
- stability = stability_tag.value.capitalize()
621
- if stability in ["Stable", "Unstable", "Private", "Internal"]:
622
- node.stability = stability
623
- else:
624
- message.warn('unknown value "%s" for Stability tag' % (
625
- stability_tag.value), stability_tag.position)
626
-
627
- annos_tag = block.tags.get(TAG_ATTRIBUTES)
628
- if annos_tag is not None:
629
- for key, value in annos_tag.options.items():
638
+ if stability_tag.value:
639
+ node.stability = stability_tag.value
640
+ if stability_tag.description:
641
+ node.stability_doc = stability_tag.description
642
+
643
+ attributes_annotation = block.annotations.get(ANN_ATTRIBUTES)
644
+ if attributes_annotation is not None:
645
+ for key, value in attributes_annotation.items():
630
646
  if value:
631
- node.attributes.append((key, value.one()))
647
+ node.attributes[key] = value
632
648
 
633
- if OPT_SKIP in block.options:
649
+ if ANN_SKIP in block.annotations:
634
650
  node.skip = True
635
651
 
636
- if OPT_FOREIGN in block.options:
652
+ if ANN_FOREIGN in block.annotations:
637
653
  node.foreign = True
638
654
 
639
- if OPT_CONSTRUCTOR in block.options and isinstance(node, ast.Function):
655
+ if ANN_CONSTRUCTOR in block.annotations and isinstance(node, ast.Function):
640
656
  node.is_constructor = True
641
657
 
642
- if OPT_METHOD in block.options:
658
+ if ANN_METHOD in block.annotations:
643
659
  node.is_method = True
644
660
 
645
661
  def _apply_annotations_alias(self, node, chain):
@@ -647,20 +663,18 @@ class MainTransformer(object):
647
663
  self._apply_annotations_annotated(node, block)
648
664
 
649
665
  def _apply_annotations_param(self, parent, param, tag):
650
- if tag:
651
- options = tag.options
652
- else:
653
- options = {}
666
+ annotations = tag.annotations if tag else {}
667
+
654
668
  if isinstance(parent, (ast.Function, ast.VFunction)):
655
- scope = options.get(OPT_SCOPE)
656
- if scope and scope.length() == 1:
657
- param.scope = scope.one()
669
+ scope_annotation = annotations.get(ANN_SCOPE)
670
+ if scope_annotation and len(scope_annotation) == 1:
671
+ param.scope = scope_annotation[0]
658
672
  param.transfer = ast.PARAM_TRANSFER_NONE
659
673
 
660
- destroy = options.get(OPT_DESTROY)
661
- if destroy:
674
+ destroy_annotation = annotations.get(ANN_DESTROY)
675
+ if destroy_annotation:
662
676
  param.destroy_name = self._get_validate_parameter_name(parent,
663
- destroy.one(),
677
+ destroy_annotation[0],
664
678
  param)
665
679
  if param.destroy_name is not None:
666
680
  param.scope = ast.PARAM_SCOPE_NOTIFIED
@@ -669,13 +683,14 @@ class MainTransformer(object):
669
683
  # itself. But this helps avoid tripping a warning from finaltransformer,
670
684
  # since we don't have a way right now to flag this callback a destroy.
671
685
  destroy_param.scope = ast.PARAM_SCOPE_NOTIFIED
672
- closure = options.get(OPT_CLOSURE)
673
- if closure and closure.length() == 1:
686
+
687
+ closure_annotation = annotations.get(ANN_CLOSURE)
688
+ if closure_annotation and len(closure_annotation) == 1:
674
689
  param.closure_name = self._get_validate_parameter_name(parent,
675
- closure.one(),
676
- param)
690
+ closure_annotation[0],
691
+ param)
677
692
  elif isinstance(parent, ast.Callback):
678
- if OPT_CLOSURE in options:
693
+ if ANN_CLOSURE in annotations:
679
694
  # For callbacks, (closure) appears without an
680
695
  # argument, and tags a parameter that is a closure. We
681
696
  # represent it (weirdly) in the gir and typelib by
@@ -694,13 +709,19 @@ class MainTransformer(object):
694
709
  def _apply_annotations_params(self, parent, params, block):
695
710
  declparams = set([])
696
711
  if parent.instance_parameter:
712
+ if block:
713
+ doc_param = block.params.get(parent.instance_parameter.argname)
714
+ else:
715
+ doc_param = None
716
+ self._apply_annotations_param(parent, parent.instance_parameter, doc_param)
697
717
  declparams.add(parent.instance_parameter.argname)
718
+
698
719
  for param in params:
699
720
  if block:
700
- tag = block.params.get(param.argname)
721
+ doc_param = block.params.get(param.argname)
701
722
  else:
702
- tag = None
703
- self._apply_annotations_param(parent, param, tag)
723
+ doc_param = None
724
+ self._apply_annotations_param(parent, param, doc_param)
704
725
  declparams.add(param.argname)
705
726
 
706
727
  if not block:
@@ -711,9 +732,6 @@ class MainTransformer(object):
711
732
  unused = declparams - docparams
712
733
 
713
734
  for doc_name in unknown:
714
- # Skip varargs, see #629759
715
- if doc_name.lower() in ['...', 'varargs', TAG_RETURNS]:
716
- continue
717
735
  if len(unused) == 0:
718
736
  text = ''
719
737
  elif len(unused) == 1:
@@ -722,45 +740,30 @@ class MainTransformer(object):
722
740
  else:
723
741
  text = ', should be one of %s' % (', '.join(repr(p) for p in unused), )
724
742
 
725
- tag = block.params.get(doc_name)
726
- message.warn(
727
- '%s: unknown parameter %r in documentation comment%s' % (
728
- block.name, doc_name, text),
729
- tag.position)
743
+ param = block.params.get(doc_name)
744
+ message.warn('%s: unknown parameter %r in documentation '
745
+ 'comment%s' % (block.name, doc_name, text),
746
+ param.position)
730
747
 
731
748
  def _apply_annotations_callable(self, node, chain, block):
732
749
  self._apply_annotations_annotated(node, block)
733
750
  self._apply_annotations_params(node, node.parameters, block)
734
751
  self._apply_annotations_return(node, node.retval, block)
735
752
 
736
- def _check_arg_annotations(self, parent, params, block):
737
- if block is None:
738
- return
739
- for tag in block.tags.keys():
740
- if tag == TAG_RETURNS:
741
- continue
742
- for param in params:
743
- if param.argname == tag:
744
- break
745
- else:
746
- message.warn(
747
- "Annotation for '%s' refers to unknown argument '%s'"
748
- % (parent.name, tag))
749
-
750
753
  def _apply_annotations_field(self, parent, block, field):
751
754
  if not block:
752
755
  return
753
756
  tag = block.params.get(field.name)
754
757
  if not tag:
755
758
  return
756
- t = tag.options.get(OPT_TYPE)
757
- if t:
758
- field.type = self._transformer.create_type_from_user_string(t.one())
759
-
759
+ type_annotation = tag.annotations.get(ANN_TYPE)
760
+ if type_annotation:
761
+ field.type = self._transformer.create_type_from_user_string(type_annotation[0])
762
+ field.doc = tag.description
760
763
  try:
761
- self._adjust_container_type(parent, field, tag.options)
762
- except AttributeError:
763
- pass
764
+ self._adjust_container_type(parent, field, tag.annotations)
765
+ except AttributeError as ex:
766
+ print ex
764
767
 
765
768
  def _apply_annotations_property(self, parent, prop):
766
769
  prefix = self._get_annotation_name(parent)
@@ -768,17 +771,17 @@ class MainTransformer(object):
768
771
  self._apply_annotations_annotated(prop, block)
769
772
  if not block:
770
773
  return
771
- transfer_tag = block.tags.get(TAG_TRANSFER)
772
- if transfer_tag is not None:
773
- transfer = transfer_tag.value
774
+ transfer_annotation = block.annotations.get(ANN_TRANSFER)
775
+ if transfer_annotation is not None:
776
+ transfer = transfer_annotation[0]
774
777
  if transfer == OPT_TRANSFER_FLOATING:
775
778
  transfer = OPT_TRANSFER_NONE
776
779
  prop.transfer = transfer
777
780
  else:
778
781
  prop.transfer = self._get_transfer_default(parent, prop)
779
- type_tag = block.tags.get(TAG_TYPE)
780
- if type_tag:
781
- prop.type = self._resolve_toplevel(type_tag.value, prop.type, prop, parent)
782
+ type_annotation = block.annotations.get(ANN_TYPE)
783
+ if type_annotation:
784
+ prop.type = self._resolve_toplevel(type_annotation[0], prop.type, prop, parent)
782
785
 
783
786
  def _apply_annotations_signal(self, parent, signal):
784
787
  names = []
@@ -806,11 +809,11 @@ class MainTransformer(object):
806
809
  for i, param in enumerate(signal.parameters):
807
810
  if names:
808
811
  name, tag = names[i + 1]
809
- options = getattr(tag, 'options', {})
810
- param_type = options.get(OPT_TYPE)
811
- if param_type:
812
- param.type = self._resolve_toplevel(param_type.one(), param.type,
813
- param, parent)
812
+ if tag:
813
+ type_annotation = tag.annotations.get(ANN_TYPE)
814
+ if type_annotation:
815
+ param.type = self._resolve_toplevel(type_annotation[0], param.type,
816
+ param, parent)
814
817
  else:
815
818
  tag = None
816
819
  self._apply_annotations_param(signal, param, tag)
@@ -823,18 +826,18 @@ class MainTransformer(object):
823
826
 
824
827
  self._apply_annotations_annotated(node, block)
825
828
 
826
- tag = block.tags.get(TAG_VALUE)
827
- if tag:
828
- node.value = tag.value
829
+ value_annotation = block.annotations.get(ANN_VALUE)
830
+ if value_annotation:
831
+ node.value = value_annotation[0]
829
832
 
830
833
  def _apply_annotations_enum_members(self, node, block):
831
834
  if block is None:
832
835
  return
833
836
 
834
837
  for m in node.members:
835
- tag = block.params.get(m.symbol, None)
836
- if tag is not None:
837
- m.doc = tag.comment
838
+ param = block.params.get(m.symbol, None)
839
+ if param and param.description:
840
+ m.doc = param.description
838
841
 
839
842
  def _pass_read_annotations2(self, node, chain):
840
843
  if isinstance(node, ast.Function):
@@ -845,9 +848,9 @@ class MainTransformer(object):
845
848
  # Handle virtual invokers
846
849
  parent = chain[-1] if chain else None
847
850
  if (block and parent):
848
- virtual_annotation = block.tags.get(TAG_VFUNC)
851
+ virtual_annotation = block.annotations.get(ANN_VFUNC)
849
852
  if virtual_annotation:
850
- invoker_name = virtual_annotation.value
853
+ invoker_name = virtual_annotation[0]
851
854
  matched = False
852
855
  for vfunc in parent.virtual_methods:
853
856
  if vfunc.name == invoker_name:
@@ -859,7 +862,7 @@ class MainTransformer(object):
859
862
  if not matched:
860
863
  message.warn_node(node,
861
864
  "Virtual slot %r not found for %r annotation" % (invoker_name,
862
- TAG_VFUNC))
865
+ ANN_VFUNC))
863
866
  return True
864
867
 
865
868
  def _resolve_and_filter_type_list(self, typelist):
@@ -1035,15 +1038,35 @@ method or constructor of some type."""
1035
1038
  uscored_prefix = self._get_uscored_prefix(func, subsymbol)
1036
1039
  target = self._transformer.lookup_typenode(func.parameters[0].type)
1037
1040
 
1038
- func.instance_parameter = func.parameters.pop(0)
1039
- self._namespace.float(func)
1040
-
1041
- if not func.is_method:
1041
+ if not func.is_method and not subsymbol.startswith(uscored_prefix + '_'):
1042
+ # Uh oh! This function starts with uscored_prefix, but not
1043
+ # uscored_prefix + '_', so if we split, we're splitting on something
1044
+ # which is not _
1045
+ # Examples of this are g_resources_register() (splits as
1046
+ # g_resource + _register) and gdk_events_get_angle() (splits as
1047
+ # gdk_event + _get_angle).
1048
+ # As the C name suggests, these are not methods, but for backward
1049
+ # compatibility reasons we need to create a method with the old
1050
+ # name, and a moved-to annotation pointing to the new variant.
1051
+
1052
+ newfunc = func.clone()
1053
+ newfunc.moved_to = func.name
1054
+ newfunc.instance_parameter = newfunc.parameters.pop(0)
1042
1055
  subsym_idx = func.symbol.find(subsymbol)
1043
- func.name = func.symbol[(subsym_idx + len(uscored_prefix) + 1):]
1044
- func.is_method = True
1056
+ newfunc.name = func.symbol[(subsym_idx + len(uscored_prefix) + 1):]
1057
+ newfunc.is_method = True
1058
+
1059
+ target.methods.append(newfunc)
1060
+ else:
1061
+ func.instance_parameter = func.parameters.pop(0)
1062
+ self._namespace.float(func)
1045
1063
 
1046
- target.methods.append(func)
1064
+ if not func.is_method:
1065
+ subsym_idx = func.symbol.find(subsymbol)
1066
+ func.name = func.symbol[(subsym_idx + len(uscored_prefix) + 1):]
1067
+ func.is_method = True
1068
+
1069
+ target.methods.append(func)
1047
1070
 
1048
1071
  def _get_uscored_prefix(self, func, subsymbol):
1049
1072
  # Here we check both the c_symbol_prefix and (if that fails),
@@ -1201,20 +1224,20 @@ method or constructor of some type."""
1201
1224
  parent = None
1202
1225
  if parent is None:
1203
1226
  message.warn_node(func,
1204
- "Return value is not superclass for constructor; "
1205
- "symbol=%r constructed=%r return=%r" % (
1206
- func.symbol,
1207
- str(origin_node.create_type()),
1208
- str(func.retval.type)))
1227
+ "Return value is not superclass for constructor; "
1228
+ "symbol=%r constructed=%r return=%r" %
1229
+ (func.symbol,
1230
+ str(origin_node.create_type()),
1231
+ str(func.retval.type)))
1209
1232
  return False
1210
1233
  else:
1211
1234
  if origin_node != target:
1212
1235
  message.warn_node(func,
1213
- "Constructor return type mismatch symbol=%r "
1214
- "constructed=%r return=%r" % (
1215
- func.symbol,
1216
- str(origin_node.create_type()),
1217
- str(func.retval.type)))
1236
+ "Constructor return type mismatch symbol=%r "
1237
+ "constructed=%r return=%r" %
1238
+ (func.symbol,
1239
+ str(origin_node.create_type()),
1240
+ str(func.retval.type)))
1218
1241
  return False
1219
1242
 
1220
1243
  return True
@@ -1237,16 +1260,24 @@ method or constructor of some type."""
1237
1260
  field.writable = False
1238
1261
 
1239
1262
  for field in class_struct.fields:
1240
- if not isinstance(field.anonymous_node, ast.Callback):
1263
+ callback = None
1264
+
1265
+ if isinstance(field.anonymous_node, ast.Callback):
1266
+ callback = field.anonymous_node
1267
+ elif field.type is not None:
1268
+ callback = self._transformer.lookup_typenode(field.type)
1269
+ if not isinstance(callback, ast.Callback):
1270
+ continue
1271
+ else:
1241
1272
  continue
1242
- callback = field.anonymous_node
1273
+
1243
1274
  # Check the first parameter is the object
1244
1275
  if len(callback.parameters) == 0:
1245
1276
  continue
1246
1277
  firstparam_type = callback.parameters[0].type
1247
1278
  if firstparam_type != node_type:
1248
1279
  continue
1249
- vfunc = ast.VFunction.from_callback(callback)
1280
+ vfunc = ast.VFunction.from_callback(field.name, callback)
1250
1281
  vfunc.instance_parameter = callback.parameters[0]
1251
1282
  vfunc.inherit_file_positions(callback)
1252
1283
 
@@ -1266,7 +1297,7 @@ method or constructor of some type."""
1266
1297
  continue
1267
1298
  if len(method.parameters) != len(vfunc.parameters):
1268
1299
  continue
1269
- for i in xrange(len(method.parameters)):
1300
+ for i in range(len(method.parameters)):
1270
1301
  m_type = method.parameters[i].type
1271
1302
  v_type = vfunc.parameters[i].type
1272
1303
  if m_type != v_type: