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

Sign up to get free protection for your applications and to get access to all the features.
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
@@ -42,13 +42,18 @@ def make_page_id(node, recursive=False):
42
42
  if hasattr(node, '_chain') and node._chain:
43
43
  parent = node._chain[-1]
44
44
  else:
45
- parent = None
45
+ parent = getattr(node, 'parent', None)
46
46
 
47
47
  if parent is None:
48
- return '%s.%s' % (node.namespace.name, node.name)
48
+ if isinstance(node, ast.Function) and node.shadows:
49
+ return '%s.%s' % (node.namespace.name, node.shadows)
50
+ else:
51
+ return '%s.%s' % (node.namespace.name, node.name)
49
52
 
50
- if isinstance(node, (ast.Property, ast.Signal, ast.VFunction)):
53
+ if isinstance(node, (ast.Property, ast.Signal, ast.VFunction, ast.Field)):
51
54
  return '%s-%s' % (make_page_id(parent, recursive=True), node.name)
55
+ elif isinstance(node, ast.Function) and node.shadows:
56
+ return '%s.%s' % (make_page_id(parent, recursive=True), node.shadows)
52
57
  else:
53
58
  return '%s.%s' % (make_page_id(parent, recursive=True), node.name)
54
59
 
@@ -56,8 +61,10 @@ def make_page_id(node, recursive=False):
56
61
  def get_node_kind(node):
57
62
  if isinstance(node, ast.Namespace):
58
63
  node_kind = 'namespace'
59
- elif isinstance(node, (ast.Class, ast.Interface)):
64
+ elif isinstance(node, (ast.Class, ast.Boxed, ast.Compound)):
60
65
  node_kind = 'class'
66
+ elif isinstance(node, ast.Interface):
67
+ node_kind = 'interface'
61
68
  elif isinstance(node, ast.Record):
62
69
  node_kind = 'record'
63
70
  elif isinstance(node, ast.Function):
@@ -67,7 +74,7 @@ def get_node_kind(node):
67
74
  node_kind = 'constructor'
68
75
  else:
69
76
  node_kind = 'function'
70
- elif isinstance(node, ast.Enum):
77
+ elif isinstance(node, (ast.Enum, ast.Bitfield)):
71
78
  node_kind = 'enum'
72
79
  elif isinstance(node, ast.Property) and node.parent is not None:
73
80
  node_kind = 'property'
@@ -75,6 +82,10 @@ def get_node_kind(node):
75
82
  node_kind = 'signal'
76
83
  elif isinstance(node, ast.VFunction) and node.parent is not None:
77
84
  node_kind = 'vfunc'
85
+ elif isinstance(node, ast.Callable):
86
+ node_kind = 'callback'
87
+ elif isinstance(node, ast.Field):
88
+ node_kind = 'field'
78
89
  else:
79
90
  node_kind = 'default'
80
91
 
@@ -170,7 +181,15 @@ class DocFormatter(object):
170
181
  return saxutils.escape(text)
171
182
 
172
183
  def should_render_node(self, node):
173
- if isinstance(node, ast.Constant):
184
+ if getattr(node, "private", False):
185
+ return False
186
+ # Nodes without namespace are AST bugs really
187
+ # They are used for structs and unions declared
188
+ # inline inside other structs, but they are not
189
+ # even picked up by g-ir-compiler, because they
190
+ # don't create a <type/> element.
191
+ # So just ignore them.
192
+ if isinstance(node, ast.Node) and node.namespace is None:
174
193
  return False
175
194
 
176
195
  return True
@@ -181,7 +200,7 @@ class DocFormatter(object):
181
200
 
182
201
  result = ''
183
202
  for para in doc.split('\n\n'):
184
- result += '<p>'
203
+ result += ' <p>'
185
204
  result += self.format_inline(node, para)
186
205
  result += '</p>'
187
206
  return result
@@ -292,7 +311,7 @@ class DocFormatter(object):
292
311
 
293
312
  return dispatch[kind](node, match, props)
294
313
 
295
- def get_parameters(self, node):
314
+ def get_in_parameters(self, node):
296
315
  raise NotImplementedError
297
316
 
298
317
  def format_inline(self, node, para):
@@ -309,12 +328,12 @@ class DocFormatter(object):
309
328
  def format_function_name(self, func):
310
329
  raise NotImplementedError
311
330
 
312
- def format_type(self, type_):
331
+ def format_type(self, type_, link=False):
313
332
  raise NotImplementedError
314
333
 
315
334
  def format_page_name(self, node):
316
335
  if isinstance(node, ast.Namespace):
317
- return 'Index'
336
+ return node.name
318
337
  elif isinstance(node, ast.Function):
319
338
  return self.format_function_name(node)
320
339
  elif isinstance(node, ast.Property) and node.parent is not None:
@@ -323,39 +342,74 @@ class DocFormatter(object):
323
342
  return '%s::%s' % (self.format_page_name(node.parent), node.name)
324
343
  elif isinstance(node, ast.VFunction) and node.parent is not None:
325
344
  return '%s::%s' % (self.format_page_name(node.parent), node.name)
345
+ elif isinstance(node, ast.Field) and node.parent is not None:
346
+ return '%s->%s' % (self.format_page_name(node.parent), node.name)
326
347
  else:
327
348
  return make_page_id(node)
328
349
 
329
350
  def format_xref(self, node, **attrdict):
330
- if node is None:
351
+ if node is None or not hasattr(node, 'namespace'):
331
352
  attrs = [('xref', 'index')] + attrdict.items()
332
353
  return xmlwriter.build_xml_tag('link', attrs)
333
354
  elif isinstance(node, ast.Member):
334
355
  # Enum/BitField members are linked to the main enum page.
335
356
  return self.format_xref(node.parent, **attrdict) + '.' + node.name
357
+ elif node.namespace is self._transformer.namespace:
358
+ return self.format_internal_xref(node, attrdict)
336
359
  else:
337
- attrs = [('xref', make_page_id(node))] + attrdict.items()
338
- return xmlwriter.build_xml_tag('link', attrs)
360
+ return self.format_external_xref(node, attrdict)
361
+
362
+ def format_internal_xref(self, node, attrdict):
363
+ attrs = [('xref', make_page_id(node))] + attrdict.items()
364
+ return xmlwriter.build_xml_tag('link', attrs)
365
+
366
+ def format_external_xref(self, node, attrdict):
367
+ ns = node.namespace
368
+ attrs = [('href', '../%s-%s/%s.html' % (ns.name, str(ns.version),
369
+ make_page_id(node)))]
370
+ attrs += attrdict.items()
371
+ return xmlwriter.build_xml_tag('link', attrs, self.format_page_name(node))
372
+
373
+ def field_is_writable(self, field):
374
+ return True
339
375
 
340
376
  def format_property_flags(self, property_, construct_only=False):
341
377
  flags = []
378
+
342
379
  if property_.readable and not construct_only:
343
380
  flags.append("Read")
344
- if property_.writable and not construct_only:
381
+ if property_.writable and not construct_only and \
382
+ self.field_is_writable(property_):
345
383
  flags.append("Write")
346
- if property_.construct:
347
- flags.append("Construct")
348
- if property_.construct_only:
349
- flags.append("Construct Only")
384
+ if isinstance(property_, ast.Property):
385
+ if property_.construct:
386
+ flags.append("Construct")
387
+ if property_.construct_only:
388
+ flags.append("Construct Only")
350
389
 
351
390
  return " / ".join(flags)
352
391
 
353
- def to_underscores(self, string):
354
- return to_underscores(string)
392
+ def to_underscores(self, node):
393
+ if isinstance(node, ast.Property):
394
+ return node.name.replace('-', '_')
395
+ elif node.name:
396
+ return to_underscores(node.name)
397
+ elif isinstance(node, ast.Callback):
398
+ return 'callback'
399
+ elif isinstance(node, ast.Union):
400
+ return 'anonymous_union'
401
+ elif isinstance(node, ast.Field):
402
+ return 'anonymous field'
403
+ else:
404
+ raise Exception('invalid node')
405
+
406
+ def to_lower_camel_case(self, string):
407
+ return string[0].lower() + string[1:]
355
408
 
356
409
  def get_class_hierarchy(self, node):
357
- parent_chain = [node]
410
+ assert isinstance(node, ast.Class)
358
411
 
412
+ parent_chain = [node]
359
413
  while node.parent_type:
360
414
  node = self._transformer.lookup_typenode(node.parent_type)
361
415
  parent_chain.append(node)
@@ -363,6 +417,42 @@ class DocFormatter(object):
363
417
  parent_chain.reverse()
364
418
  return parent_chain
365
419
 
420
+ def format_prerequisites(self, node):
421
+ assert isinstance(node, ast.Interface)
422
+
423
+ if len(node.prerequisites) > 0:
424
+ if len(node.prerequisites) > 1:
425
+ return ', '.join(node.prerequisites[:-1]) + \
426
+ ' and ' + node.prerequisites[-1]
427
+ else:
428
+ return node.prerequisites[0]
429
+ else:
430
+ return 'GObject.Object'
431
+
432
+ def format_known_implementations(self, node):
433
+ assert isinstance(node, ast.Interface)
434
+
435
+ node_name = node.namespace.name + '.' + node.name
436
+ impl = []
437
+
438
+ for c in node.namespace.itervalues():
439
+ if not isinstance(c, ast.Class):
440
+ continue
441
+ for implemented in c.interfaces:
442
+ if implemented.target_giname == node_name:
443
+ impl.append(c)
444
+ break
445
+
446
+ if len(impl) == 0:
447
+ return 'None'
448
+ else:
449
+ out = '%s is implemented by ' % (node.name,)
450
+ if len(impl) == 1:
451
+ return out + impl[0].name
452
+ else:
453
+ return out + ', '.join(i.name for i in impl[:-1]) + \
454
+ ' and ' + impl[-1].name
455
+
366
456
 
367
457
  class DocFormatterC(DocFormatter):
368
458
  language = "C"
@@ -374,7 +464,7 @@ class DocFormatterC(DocFormatter):
374
464
  "NULL": "NULL",
375
465
  }
376
466
 
377
- def format_type(self, type_):
467
+ def format_type(self, type_, link=False):
378
468
  if isinstance(type_, ast.Array):
379
469
  return self.format_type(type_.element_type) + '*'
380
470
  elif type_.ctype is not None:
@@ -391,7 +481,7 @@ class DocFormatterC(DocFormatter):
391
481
  else:
392
482
  return func.name
393
483
 
394
- def get_parameters(self, node):
484
+ def get_in_parameters(self, node):
395
485
  return node.all_parameters
396
486
 
397
487
 
@@ -403,6 +493,9 @@ class DocFormatterIntrospectableBase(DocFormatter):
403
493
  if not getattr(node, "introspectable", True):
404
494
  return False
405
495
 
496
+ if isinstance(node, ast.Function) and node.shadowed_by is not None:
497
+ return False
498
+
406
499
  return super(DocFormatterIntrospectableBase, self).should_render_node(node)
407
500
 
408
501
 
@@ -463,7 +556,7 @@ class DocFormatterPython(DocFormatterIntrospectableBase):
463
556
 
464
557
  return fundamental_types.get(name, name)
465
558
 
466
- def format_type(self, type_):
559
+ def format_type(self, type_, link=False):
467
560
  if isinstance(type_, (ast.List, ast.Array)):
468
561
  return '[' + self.format_type(type_.element_type) + ']'
469
562
  elif isinstance(type_, ast.Map):
@@ -480,7 +573,7 @@ class DocFormatterPython(DocFormatterIntrospectableBase):
480
573
  else:
481
574
  return func.name
482
575
 
483
- def get_parameters(self, node):
576
+ def get_in_parameters(self, node):
484
577
  return node.all_parameters
485
578
 
486
579
 
@@ -503,61 +596,165 @@ class DocFormatterGjs(DocFormatterIntrospectableBase):
503
596
 
504
597
  return False
505
598
 
599
+ def resolve_gboxed_constructor(self, node):
600
+ zero_args_constructor = None
601
+ default_constructor = None
602
+
603
+ introspectable_constructors = \
604
+ filter(lambda c: getattr(c, 'introspectable', True),
605
+ node.constructors)
606
+ for c in introspectable_constructors:
607
+ if zero_args_constructor is None and \
608
+ len(c.parameters) == 0:
609
+ zero_args_constructor = c
610
+ if default_constructor is None and \
611
+ c.name == 'new':
612
+ default_constructor = c
613
+ if default_constructor is None:
614
+ default_constructor = zero_args_constructor
615
+ if default_constructor is None and \
616
+ len(introspectable_constructors) > 0:
617
+ default_constructor = introspectable_constructors[0]
618
+
619
+ node.gjs_default_constructor = default_constructor
620
+ node.gjs_zero_args_constructor = zero_args_constructor
621
+
622
+ def should_render_node(self, node):
623
+ if isinstance(node, (ast.Compound, ast.Boxed)):
624
+ self.resolve_gboxed_constructor(node)
625
+
626
+ if isinstance(node, ast.Compound) and node.disguised and \
627
+ len(node.methods) == len(node.static_methods) == len(node.constructors) == 0:
628
+ return False
629
+
630
+ if isinstance(node, ast.ErrorQuarkFunction):
631
+ return False
632
+ if isinstance(node, ast.Field):
633
+ if node.type is None:
634
+ return False
635
+ if isinstance(node.parent, (ast.Class, ast.Union)):
636
+ return False
637
+ if isinstance(node, ast.Union) and node.name is None:
638
+ return False
639
+ if isinstance(node, ast.Class):
640
+ is_gparam_subclass = False
641
+ if node.parent_type:
642
+ parent = self._transformer.lookup_typenode(node.parent_type)
643
+ while parent:
644
+ if parent.namespace.name == 'GObject' and \
645
+ parent.name == 'ParamSpec':
646
+ is_gparam_subclass = True
647
+ break
648
+ if parent.parent_type is None:
649
+ break
650
+ parent = self._transformer.lookup_typenode(parent.parent_type)
651
+ if is_gparam_subclass:
652
+ return False
653
+
654
+ return super(DocFormatterGjs, self).should_render_node(node)
655
+
506
656
  def format_fundamental_type(self, name):
507
657
  fundamental_types = {
658
+ "none": "void",
659
+ "gpointer": "void",
660
+ "gboolean": "Boolean",
661
+ "gint8": "Number(gint8)",
662
+ "guint8": "Number(guint8)",
663
+ "gint16": "Number(gint16)",
664
+ "guint16": "Number(guint16)",
665
+ "gint32": "Number(gint32)",
666
+ "guint32": "Number(guint32)",
667
+ "gchar": "Number(gchar)",
668
+ "guchar": "Number(guchar)",
669
+ "gshort": "Number(gshort)",
670
+ "gint": "Number(gint)",
671
+ "guint": "Number(guint)",
672
+ "gfloat": "Number(gfloat)",
673
+ "gdouble": "Number(gdouble)",
508
674
  "utf8": "String",
509
675
  "gunichar": "String",
510
- "gchar": "String",
511
- "guchar": "String",
512
- "gboolean": "Boolean",
513
- "gint": "Number",
514
- "guint": "Number",
515
- "glong": "Number",
516
- "gulong": "Number",
517
- "gint64": "Number",
518
- "guint64": "Number",
519
- "gfloat": "Number",
520
- "gdouble": "Number",
521
- "gchararray": "String",
522
- "GParam": "GLib.Param",
523
- "PyObject": "Object",
524
- "GStrv": "[String]",
525
- "GVariant": "GLib.Variant"}
676
+ "filename": "String",
677
+ "GType": "GObject.Type",
678
+ "GVariant": "GLib.Variant",
679
+ # These cannot be fully represented in gjs
680
+ "gsize": "Number(gsize)",
681
+ "gssize": "Number(gssize)",
682
+ "gintptr": "Number(gintptr)",
683
+ "guintptr": "Number(guintptr)",
684
+ "glong": "Number(glong)",
685
+ "gulong": "Number(gulong)",
686
+ "gint64": "Number(gint64)",
687
+ "guint64": "Number(guint64)",
688
+ "long double": "Number(long double)",
689
+ "long long": "Number(long long)",
690
+ "unsigned long long": "Number(unsigned long long)"}
526
691
 
527
692
  return fundamental_types.get(name, name)
528
693
 
529
- def format_type(self, type_):
530
- if isinstance(type_, (ast.List, ast.Array)):
531
- return '[' + self.format_type(type_.element_type) + ']'
694
+ def format_type(self, type_, link=False):
695
+ if isinstance(type_, ast.Array) and \
696
+ type_.element_type.target_fundamental in ('gint8', 'guint8'):
697
+ return 'ByteArray'
698
+ elif isinstance(type_, (ast.List, ast.Array)):
699
+ return 'Array(' + self.format_type(type_.element_type, link) + ')'
532
700
  elif isinstance(type_, ast.Map):
533
- return '{%s: %s}' % (self.format_type(type_.key_type),
534
- self.format_type(type_.value_type))
535
- elif type_.target_fundamental == "none":
701
+ return '{%s: %s}' % (self.format_type(type_.key_type, link),
702
+ self.format_type(type_.value_type, link))
703
+ elif not type_ or type_.target_fundamental == "none":
536
704
  return "void"
537
705
  elif type_.target_giname is not None:
538
- return type_.target_giname
706
+ giname = type_.target_giname
707
+ if giname in ('GLib.ByteArray', 'GLib.Bytes'):
708
+ return 'ByteArray'
709
+ if giname == 'GObject.Value':
710
+ return 'Any'
711
+ if giname == 'GObject.Closure':
712
+ return 'Function'
713
+ if link:
714
+ nsname = self._transformer.namespace.name
715
+ if giname.startswith(nsname + '.'):
716
+ return '<link xref="%s">%s</link>' % (giname, giname)
717
+ else:
718
+ resolved = self._transformer.lookup_typenode(type_)
719
+ if resolved:
720
+ return self.format_xref(resolved)
721
+ return giname
539
722
  else:
540
723
  return self.format_fundamental_type(type_.target_fundamental)
541
724
 
542
725
  def format_function_name(self, func):
726
+ name = func.name
727
+ if func.shadows:
728
+ name = func.shadows
729
+
543
730
  if func.is_method:
544
- return "%s.prototype.%s" % (self.format_page_name(func.parent), func.name)
545
- elif func.is_constructor:
546
- return "%s.%s" % (self.format_page_name(func.parent), func.name)
731
+ return "%s.prototype.%s" % (self.format_page_name(func.parent), name)
732
+ elif func.parent is not None:
733
+ return "%s.%s" % (self.format_page_name(func.parent), name)
547
734
  else:
548
- return func.name
735
+ return name
736
+
737
+ def format_page_name(self, node):
738
+ if isinstance(node, (ast.Field, ast.Property)):
739
+ return '%s.%s' % (self.format_page_name(node.parent), self.to_underscores(node))
740
+ else:
741
+ return DocFormatterIntrospectableBase.format_page_name(self, node)
742
+
743
+ def has_any_parameters(self, node):
744
+ return len(node.parameters) > 0 or \
745
+ node.retval.type.target_fundamental != 'none'
549
746
 
550
- def get_parameters(self, node):
551
- skip = []
747
+ def get_in_parameters(self, node):
748
+ skip = set()
552
749
  for param in node.parameters:
553
750
  if param.direction == ast.PARAM_DIRECTION_OUT:
554
- skip.append(param)
751
+ skip.add(param)
555
752
  if param.closure_name is not None:
556
- skip.append(node.get_parameter(param.closure_name))
753
+ skip.add(node.get_parameter(param.closure_name))
557
754
  if param.destroy_name is not None:
558
- skip.append(node.get_parameter(param.destroy_name))
755
+ skip.add(node.get_parameter(param.destroy_name))
559
756
  if isinstance(param.type, ast.Array) and param.type.length_param_name is not None:
560
- skip.append(node.get_parameter(param.type.length_param_name))
757
+ skip.add(node.get_parameter(param.type.length_param_name))
561
758
 
562
759
  params = []
563
760
  for param in node.parameters:
@@ -565,6 +762,116 @@ class DocFormatterGjs(DocFormatterIntrospectableBase):
565
762
  params.append(param)
566
763
  return params
567
764
 
765
+ def get_out_parameters(self, node):
766
+ skip = set()
767
+ for param in node.parameters:
768
+ if param.direction == ast.PARAM_DIRECTION_IN:
769
+ skip.add(param)
770
+ if param.closure_name is not None:
771
+ skip.add(node.get_parameter(param.closure_name))
772
+ if param.destroy_name is not None:
773
+ skip.add(node.get_parameter(param.destroy_name))
774
+ if isinstance(param.type, ast.Array) and param.type.length_param_name is not None:
775
+ skip.add(node.get_parameter(param.type.length_param_name))
776
+
777
+ params = []
778
+ if node.retval.type.target_fundamental != 'none':
779
+ name = 'return_value'
780
+ if node.retval.type.target_fundamental == 'gboolean':
781
+ name = 'ok'
782
+
783
+ ret_param = ast.Parameter(name, node.retval.type,
784
+ ast.PARAM_DIRECTION_OUT)
785
+ ret_param.doc = node.retval.doc
786
+ params.append(ret_param)
787
+ for param in node.parameters:
788
+ if param not in skip:
789
+ params.append(param)
790
+
791
+ if len(params) == 1:
792
+ params[0].argname = 'Returns'
793
+
794
+ return params
795
+
796
+ def format_in_parameters(self, node):
797
+ in_params = self.get_in_parameters(node)
798
+ return ', '.join(('%s: %s' % (p.argname, self.format_type(p.type, True)))
799
+ for p in in_params)
800
+
801
+ def format_out_parameters(self, node):
802
+ out_params = self.get_out_parameters(node)
803
+
804
+ if len(out_params) == 0:
805
+ return 'void'
806
+ elif len(out_params) == 1:
807
+ return self.format_type(out_params[0].type, True)
808
+ else:
809
+ return '[' + ', '.join(('%s: %s' % (p.argname, self.format_type(p.type, True)))
810
+ for p in out_params) + ']'
811
+
812
+ def field_is_writable(self, node):
813
+ if isinstance(node, ast.Field):
814
+ if node.type is None:
815
+ return False
816
+ if node.private:
817
+ return False
818
+ if isinstance(node.parent, ast.Union):
819
+ return False
820
+ if node.type.target_fundamental not in \
821
+ (None, 'none', 'gpointer', 'utf8', 'filename', 'va_list'):
822
+ return True
823
+
824
+ resolved = self._transformer.lookup_typenode(node.type)
825
+ if resolved:
826
+ if isinstance(resolved, ast.Compound) and node.type.ctype[-1] != '*':
827
+ return self._struct_is_simple(resolved)
828
+ elif isinstance(resolved, (ast.Enum, ast.Bitfield)):
829
+ return True
830
+ return False
831
+ else:
832
+ return True
833
+
834
+ def _struct_is_simple(self, node):
835
+ if node.disguised or len(node.fields) == 0:
836
+ return False
837
+
838
+ for f in node.fields:
839
+ if not self.field_is_writable(f):
840
+ return False
841
+ return True
842
+
843
+ def format_gboxed_constructor(self, node):
844
+ if node.namespace.name == 'GLib' and node.name == 'Variant':
845
+ return 'signature: String, value: Any'
846
+
847
+ zero_args_constructor = node.gjs_zero_args_constructor
848
+ default_constructor = node.gjs_default_constructor
849
+
850
+ can_allocate = zero_args_constructor is not None
851
+ if not can_allocate and isinstance(node, ast.Record):
852
+ can_allocate = self._struct_is_simple(node)
853
+
854
+ # Small lie: if can_allocate is False, and
855
+ # default_constructor is None, then you cannot
856
+ # construct the boxed in any way. But let's
857
+ # pretend you can with the regular constructor
858
+ if can_allocate or default_constructor is None:
859
+ if isinstance(node, ast.Compound):
860
+ fields = filter(self.field_is_writable, node.fields)
861
+ out = ''
862
+ if len(fields) > 0:
863
+ out += "{\n"
864
+ for f in fields:
865
+ out += " <link xref='%s.%s-%s'>%s</link>: value\n" % \
866
+ (node.namespace.name, node.name, f.name, f.name)
867
+ out += "}"
868
+ return out
869
+ else:
870
+ return ''
871
+ else:
872
+ construct_params = self.get_in_parameters(default_constructor)
873
+ return ', '.join(('%s: %s' % (p.argname, self.format_type(p.type)))
874
+ for p in construct_params)
568
875
 
569
876
  LANGUAGES = {
570
877
  "c": DocFormatterC,
@@ -613,10 +920,16 @@ class DocWriter(object):
613
920
  def _walk_node(self, output, node, chain):
614
921
  if isinstance(node, ast.Function) and node.moved_to is not None:
615
922
  return False
616
- if getattr(node, 'disguised', False):
617
- return False
618
923
  if self._formatter.should_render_node(node):
619
924
  self._render_node(node, chain, output)
925
+
926
+ # hack: fields are not Nodes in the ast, so we don't
927
+ # see them in the visit. Handle them manually here
928
+ if isinstance(node, (ast.Compound, ast.Class)):
929
+ chain.append(node)
930
+ for f in node.fields:
931
+ self._walk_node(output, f, chain)
932
+ chain.pop()
620
933
  return True
621
934
  return False
622
935
 
@@ -635,7 +948,8 @@ class DocWriter(object):
635
948
  node=node,
636
949
  page_id=page_id,
637
950
  page_kind=page_kind,
638
- formatter=self._formatter)
951
+ formatter=self._formatter,
952
+ ast=ast)
639
953
 
640
954
  output_file_name = os.path.join(os.path.abspath(output),
641
955
  page_id + '.page')