gobject-introspection 2.0.2-x86-mingw32 → 2.0.3-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 (119) hide show
  1. checksums.yaml +7 -0
  2. data/Rakefile +5 -2
  3. data/ext/gobject-introspection/rb-gi-argument.c +215 -4
  4. data/ext/gobject-introspection/rb-gi-loader.c +7 -2
  5. data/ext/gobject-introspection/rb-gi-struct-info.c +1 -1
  6. data/lib/1.9/gobject_introspection.so +0 -0
  7. data/lib/2.0/gobject_introspection.so +0 -0
  8. data/test/test-function-info.rb +3 -1
  9. data/vendor/local/bin/g-ir-compiler.exe +0 -0
  10. data/vendor/local/bin/g-ir-generate.exe +0 -0
  11. data/vendor/local/bin/libgirepository-1.0-1.dll +0 -0
  12. data/vendor/local/lib/girepository-1.0/DBus-1.0.typelib +0 -0
  13. data/vendor/local/lib/girepository-1.0/DBusGLib-1.0.typelib +0 -0
  14. data/vendor/local/lib/girepository-1.0/GIRepository-2.0.typelib +0 -0
  15. data/vendor/local/lib/girepository-1.0/GLib-2.0.typelib +0 -0
  16. data/vendor/local/lib/girepository-1.0/GModule-2.0.typelib +0 -0
  17. data/vendor/local/lib/girepository-1.0/GObject-2.0.typelib +0 -0
  18. data/vendor/local/lib/girepository-1.0/Gio-2.0.typelib +0 -0
  19. data/vendor/local/lib/girepository-1.0/win32-1.0.typelib +0 -0
  20. data/vendor/local/lib/gobject-introspection/giscanner/__init__.pyc +0 -0
  21. data/vendor/local/lib/gobject-introspection/giscanner/__init__.pyo +0 -0
  22. data/vendor/local/lib/gobject-introspection/giscanner/annotationmain.py +1 -0
  23. data/vendor/local/lib/gobject-introspection/giscanner/annotationmain.pyc +0 -0
  24. data/vendor/local/lib/gobject-introspection/giscanner/annotationmain.pyo +0 -0
  25. data/vendor/local/lib/gobject-introspection/giscanner/annotationparser.py +52 -47
  26. data/vendor/local/lib/gobject-introspection/giscanner/annotationparser.pyc +0 -0
  27. data/vendor/local/lib/gobject-introspection/giscanner/annotationparser.pyo +0 -0
  28. data/vendor/local/lib/gobject-introspection/giscanner/ast.py +48 -42
  29. data/vendor/local/lib/gobject-introspection/giscanner/ast.pyc +0 -0
  30. data/vendor/local/lib/gobject-introspection/giscanner/ast.pyo +0 -0
  31. data/vendor/local/lib/gobject-introspection/giscanner/cachestore.py +11 -10
  32. data/vendor/local/lib/gobject-introspection/giscanner/cachestore.pyc +0 -0
  33. data/vendor/local/lib/gobject-introspection/giscanner/cachestore.pyo +0 -0
  34. data/vendor/local/lib/gobject-introspection/giscanner/codegen.py +7 -5
  35. data/vendor/local/lib/gobject-introspection/giscanner/codegen.pyc +0 -0
  36. data/vendor/local/lib/gobject-introspection/giscanner/codegen.pyo +0 -0
  37. data/vendor/local/lib/gobject-introspection/giscanner/collections/__init__.py +22 -0
  38. data/vendor/local/lib/gobject-introspection/giscanner/collections/__init__.pyc +0 -0
  39. data/vendor/local/lib/gobject-introspection/giscanner/collections/__init__.pyo +0 -0
  40. data/vendor/local/lib/gobject-introspection/giscanner/collections/ordereddict.py +120 -0
  41. data/vendor/local/lib/gobject-introspection/giscanner/collections/ordereddict.pyc +0 -0
  42. data/vendor/local/lib/gobject-introspection/giscanner/collections/ordereddict.pyo +0 -0
  43. data/vendor/local/lib/gobject-introspection/giscanner/docmain.py +14 -2
  44. data/vendor/local/lib/gobject-introspection/giscanner/docmain.pyc +0 -0
  45. data/vendor/local/lib/gobject-introspection/giscanner/docmain.pyo +0 -0
  46. data/vendor/local/lib/gobject-introspection/giscanner/docwriter.py +19 -10
  47. data/vendor/local/lib/gobject-introspection/giscanner/docwriter.pyc +0 -0
  48. data/vendor/local/lib/gobject-introspection/giscanner/docwriter.pyo +0 -0
  49. data/vendor/local/lib/gobject-introspection/giscanner/dumper.py +18 -11
  50. data/vendor/local/lib/gobject-introspection/giscanner/dumper.pyc +0 -0
  51. data/vendor/local/lib/gobject-introspection/giscanner/dumper.pyo +0 -0
  52. data/vendor/local/lib/gobject-introspection/giscanner/gdumpparser.py +10 -13
  53. data/vendor/local/lib/gobject-introspection/giscanner/gdumpparser.pyc +0 -0
  54. data/vendor/local/lib/gobject-introspection/giscanner/gdumpparser.pyo +0 -0
  55. data/vendor/local/lib/gobject-introspection/giscanner/girparser.py +24 -30
  56. data/vendor/local/lib/gobject-introspection/giscanner/girparser.pyc +0 -0
  57. data/vendor/local/lib/gobject-introspection/giscanner/girparser.pyo +0 -0
  58. data/vendor/local/lib/gobject-introspection/giscanner/girwriter.py +11 -12
  59. data/vendor/local/lib/gobject-introspection/giscanner/girwriter.pyc +0 -0
  60. data/vendor/local/lib/gobject-introspection/giscanner/girwriter.pyo +0 -0
  61. data/vendor/local/lib/gobject-introspection/giscanner/introspectablepass.py +25 -21
  62. data/vendor/local/lib/gobject-introspection/giscanner/introspectablepass.pyc +0 -0
  63. data/vendor/local/lib/gobject-introspection/giscanner/introspectablepass.pyo +0 -0
  64. data/vendor/local/lib/gobject-introspection/giscanner/libtoolimporter.py +1 -1
  65. data/vendor/local/lib/gobject-introspection/giscanner/libtoolimporter.pyc +0 -0
  66. data/vendor/local/lib/gobject-introspection/giscanner/libtoolimporter.pyo +0 -0
  67. data/vendor/local/lib/gobject-introspection/giscanner/maintransformer.py +98 -100
  68. data/vendor/local/lib/gobject-introspection/giscanner/maintransformer.pyc +0 -0
  69. data/vendor/local/lib/gobject-introspection/giscanner/maintransformer.pyo +0 -0
  70. data/vendor/local/lib/gobject-introspection/giscanner/message.py +10 -8
  71. data/vendor/local/lib/gobject-introspection/giscanner/message.pyc +0 -0
  72. data/vendor/local/lib/gobject-introspection/giscanner/message.pyo +0 -0
  73. data/vendor/local/lib/gobject-introspection/giscanner/scannermain.py +28 -16
  74. data/vendor/local/lib/gobject-introspection/giscanner/scannermain.pyc +0 -0
  75. data/vendor/local/lib/gobject-introspection/giscanner/scannermain.pyo +0 -0
  76. data/vendor/local/lib/gobject-introspection/giscanner/sectionparser.py +83 -9
  77. data/vendor/local/lib/gobject-introspection/giscanner/sectionparser.pyc +0 -0
  78. data/vendor/local/lib/gobject-introspection/giscanner/sectionparser.pyo +0 -0
  79. data/vendor/local/lib/gobject-introspection/giscanner/shlibs.py +5 -1
  80. data/vendor/local/lib/gobject-introspection/giscanner/shlibs.pyc +0 -0
  81. data/vendor/local/lib/gobject-introspection/giscanner/shlibs.pyo +0 -0
  82. data/vendor/local/lib/gobject-introspection/giscanner/sourcescanner.py +20 -21
  83. data/vendor/local/lib/gobject-introspection/giscanner/sourcescanner.pyc +0 -0
  84. data/vendor/local/lib/gobject-introspection/giscanner/sourcescanner.pyo +0 -0
  85. data/vendor/local/lib/gobject-introspection/giscanner/testcodegen.py +3 -0
  86. data/vendor/local/lib/gobject-introspection/giscanner/testcodegen.pyc +0 -0
  87. data/vendor/local/lib/gobject-introspection/giscanner/testcodegen.pyo +0 -0
  88. data/vendor/local/lib/gobject-introspection/giscanner/transformer.py +32 -41
  89. data/vendor/local/lib/gobject-introspection/giscanner/transformer.pyc +0 -0
  90. data/vendor/local/lib/gobject-introspection/giscanner/transformer.pyo +0 -0
  91. data/vendor/local/lib/gobject-introspection/giscanner/utils.py +9 -0
  92. data/vendor/local/lib/gobject-introspection/giscanner/utils.pyc +0 -0
  93. data/vendor/local/lib/gobject-introspection/giscanner/utils.pyo +0 -0
  94. data/vendor/local/lib/gobject-introspection/giscanner/xmlwriter.py +9 -11
  95. data/vendor/local/lib/gobject-introspection/giscanner/xmlwriter.pyc +0 -0
  96. data/vendor/local/lib/gobject-introspection/giscanner/xmlwriter.pyo +0 -0
  97. data/vendor/local/lib/libgirepository-1.0.a +0 -0
  98. data/vendor/local/lib/libgirepository-1.0.dll.a +0 -0
  99. data/vendor/local/lib/libgirepository-1.0.la +1 -1
  100. data/vendor/local/lib/pkgconfig/gobject-introspection-1.0.pc +1 -1
  101. data/vendor/local/lib/pkgconfig/gobject-introspection-no-export-1.0.pc +1 -1
  102. data/vendor/local/share/gir-1.0/GIRepository-2.0.gir +691 -691
  103. data/vendor/local/share/gir-1.0/GLib-2.0.gir +6972 -6467
  104. data/vendor/local/share/gir-1.0/GModule-2.0.gir +103 -4
  105. data/vendor/local/share/gir-1.0/GObject-2.0.gir +2085 -1955
  106. data/vendor/local/share/gir-1.0/Gio-2.0.gir +10955 -9269
  107. data/vendor/local/share/gir-1.0/win32-1.0.gir +19 -0
  108. data/vendor/local/share/gobject-introspection-1.0/Makefile.introspection +2 -2
  109. data/vendor/local/share/gobject-introspection-1.0/gdump.c +7 -2
  110. data/vendor/local/share/gobject-introspection-1.0/tests/annotation.c +15 -15
  111. data/vendor/local/share/gobject-introspection-1.0/tests/annotation.h +1 -1
  112. data/vendor/local/share/gobject-introspection-1.0/tests/gimarshallingtests.c +14 -0
  113. data/vendor/local/share/gobject-introspection-1.0/tests/gimarshallingtests.h +2 -2
  114. data/vendor/local/share/gobject-introspection-1.0/tests/regress.c +8 -0
  115. data/vendor/local/share/gobject-introspection-1.0/tests/regress.h +9 -0
  116. metadata +20 -21
  117. data/vendor/local/lib/gobject-introspection/giscanner/odict.py +0 -50
  118. data/vendor/local/lib/gobject-introspection/giscanner/odict.pyc +0 -0
  119. data/vendor/local/lib/gobject-introspection/giscanner/odict.pyo +0 -0
@@ -35,9 +35,8 @@ from .annotationparser import (OPT_ALLOW_NONE, OPT_ARRAY, OPT_ATTRIBUTE,
35
35
  OPT_ARRAY_LENGTH, OPT_ARRAY_ZERO_TERMINATED,
36
36
  OPT_CONSTRUCTOR, OPT_METHOD,
37
37
  OPT_TRANSFER_NONE, OPT_TRANSFER_FLOATING)
38
- from .annotationparser import AnnotationParser
39
- from .transformer import TransformerException
40
- from .utils import to_underscores, to_underscores_noprefix
38
+ from .utils import to_underscores_noprefix
39
+
41
40
 
42
41
  class MainTransformer(object):
43
42
 
@@ -50,12 +49,10 @@ class MainTransformer(object):
50
49
  # Public API
51
50
 
52
51
  def transform(self):
53
- contents = list(self._namespace.itervalues())
54
- if len(contents) == 0:
55
- message.fatal("""Namespace is empty; likely causes are:
56
- * Not including .h files to be scanned
57
- * Broken --identifier-prefix
58
- """)
52
+ if not self._namespace.names:
53
+ message.fatal('Namespace is empty; likely causes are:\n'
54
+ '* Not including .h files to be scanned\n'
55
+ '* Broken --identifier-prefix')
59
56
 
60
57
  # Some initial namespace surgery
61
58
  self._namespace.walk(self._pass_fixup_hidden_fields)
@@ -109,17 +106,14 @@ class MainTransformer(object):
109
106
 
110
107
  def _pass_fixup_hidden_fields(self, node, chain):
111
108
  """Hide all callbacks starting with _; the typical
112
- usage is void (*_gtk_reserved1)(void);"""
113
- if not isinstance(node, (ast.Class, ast.Interface,
114
- ast.Record, ast.Union)):
115
- return True
116
- for field in node.fields:
117
- if field is None:
118
- continue
119
- if (field.name.startswith('_')
109
+ usage is void (*_gtk_reserved1)(void);"""
110
+ if isinstance(node, (ast.Class, ast.Interface, ast.Record, ast.Union)):
111
+ for field in node.fields:
112
+ if (field
113
+ and field.name.startswith('_')
120
114
  and field.anonymous_node is not None
121
115
  and isinstance(field.anonymous_node, ast.Callback)):
122
- field.introspectable = False
116
+ field.introspectable = False
123
117
  return True
124
118
 
125
119
  def _get_validate_parameter_name(self, parent, param_name, origin):
@@ -142,7 +136,7 @@ usage is void (*_gtk_reserved1)(void);"""
142
136
  def _apply_annotation_rename_to(self, node, chain, block):
143
137
  if not block:
144
138
  return
145
- rename_to = block.get_tag(TAG_RENAME_TO)
139
+ rename_to = block.tags.get(TAG_RENAME_TO)
146
140
  if not rename_to:
147
141
  return
148
142
  rename_to = rename_to.value
@@ -211,7 +205,7 @@ usage is void (*_gtk_reserved1)(void);"""
211
205
  if isinstance(node, ast.Function):
212
206
  self._apply_annotations_function(node, chain)
213
207
  if isinstance(node, ast.Callback):
214
- self._apply_annotations_callable(node, chain, block = self._get_block(node))
208
+ self._apply_annotations_callable(node, chain, block=self._get_block(node))
215
209
  if isinstance(node, (ast.Class, ast.Interface, ast.Union, ast.Enum,
216
210
  ast.Bitfield, ast.Callback)):
217
211
  self._apply_annotations_annotated(node, self._get_block(node))
@@ -234,13 +228,13 @@ usage is void (*_gtk_reserved1)(void);"""
234
228
  if isinstance(node, ast.Class):
235
229
  block = self._get_block(node)
236
230
  if block:
237
- tag = block.get_tag(TAG_UNREF_FUNC)
231
+ tag = block.tags.get(TAG_UNREF_FUNC)
238
232
  node.unref_func = tag.value if tag else None
239
- tag = block.get_tag(TAG_REF_FUNC)
233
+ tag = block.tags.get(TAG_REF_FUNC)
240
234
  node.ref_func = tag.value if tag else None
241
- tag = block.get_tag(TAG_SET_VALUE_FUNC)
235
+ tag = block.tags.get(TAG_SET_VALUE_FUNC)
242
236
  node.set_value_func = tag.value if tag else None
243
- tag = block.get_tag(TAG_GET_VALUE_FUNC)
237
+ tag = block.tags.get(TAG_GET_VALUE_FUNC)
244
238
  node.get_value_func = tag.value if tag else None
245
239
  if isinstance(node, ast.Constant):
246
240
  self._apply_annotations_constant(node)
@@ -264,7 +258,7 @@ usage is void (*_gtk_reserved1)(void);"""
264
258
  Use resolver() on each identifier, and combiner() on the parts of
265
259
  each complete type. (top_combiner is used on the top-most type.)"""
266
260
  bits = re.split(r'([,<>()])', type_str, 1)
267
- first, sep, rest = [bits[0], '', ''] if (len(bits)==1) else bits
261
+ first, sep, rest = [bits[0], '', ''] if (len(bits) == 1) else bits
268
262
  args = [resolver(first)]
269
263
  if sep == '<' or sep == '(':
270
264
  lastsep = '>' if (sep == '<') else ')'
@@ -275,9 +269,11 @@ usage is void (*_gtk_reserved1)(void);"""
275
269
  else:
276
270
  rest = sep + rest
277
271
  return top_combiner(*args), rest
272
+
278
273
  def resolver(ident):
279
274
  res = self._transformer.create_type_from_user_string(ident)
280
275
  return res
276
+
281
277
  def combiner(base, *rest):
282
278
  if not rest:
283
279
  return base
@@ -288,6 +284,7 @@ usage is void (*_gtk_reserved1)(void);"""
288
284
  message.warn(
289
285
  "Too many parameters in type specification %r" % (type_str, ))
290
286
  return base
287
+
291
288
  def top_combiner(base, *rest):
292
289
  if type_node is not None and isinstance(type_node, ast.Type):
293
290
  base.is_const = type_node.is_const
@@ -334,24 +331,23 @@ usage is void (*_gtk_reserved1)(void);"""
334
331
  return block.position
335
332
 
336
333
  def _check_array_element_type(self, array, options):
334
+ array_type = array.array_type
335
+ element_type = array.element_type
336
+
337
337
  # GPtrArrays are allowed to contain non basic types
338
338
  # (except enums and flags) or basic types that are
339
339
  # as big as a gpointer
340
- if array.array_type == ast.Array.GLIB_PTRARRAY and \
341
- ((array.element_type in ast.BASIC_GIR_TYPES
342
- and not array.element_type in ast.POINTER_TYPES) or
343
- isinstance(array.element_type, ast.Enum) or
344
- isinstance(array.element_type, ast.Bitfield)):
345
- message.warn("invalid (element-type) for a GPtrArray, "
346
- "must be a pointer", options.position)
340
+ if array_type == ast.Array.GLIB_PTRARRAY:
341
+ if ((element_type in ast.BASIC_GIR_TYPES and not element_type in ast.POINTER_TYPES)
342
+ or isinstance(element_type, (ast.Enum, ast.Bitfield))):
343
+ message.warn("invalid (element-type) for a GPtrArray, "
344
+ "must be a pointer", options.position)
347
345
 
348
346
  # GByteArrays have (element-type) guint8 by default
349
- if array.array_type == ast.Array.GLIB_BYTEARRAY:
350
- if array.element_type == ast.TYPE_ANY:
347
+ if array_type == ast.Array.GLIB_BYTEARRAY:
348
+ if element_type == ast.TYPE_ANY:
351
349
  array.element_type = ast.TYPE_UINT8
352
- elif not array.element_type in [ast.TYPE_UINT8,
353
- ast.TYPE_INT8,
354
- ast.TYPE_CHAR]:
350
+ elif not element_type in [ast.TYPE_UINT8, ast.TYPE_INT8, ast.TYPE_CHAR]:
355
351
  message.warn("invalid (element-type) for a GByteArray, "
356
352
  "must be one of guint8, gint8 or gchar",
357
353
  options.position)
@@ -461,8 +457,8 @@ usage is void (*_gtk_reserved1)(void);"""
461
457
 
462
458
  def _get_transfer_default_returntype_basic(self, typeval):
463
459
  if (typeval.is_equiv(ast.BASIC_GIR_TYPES)
464
- or typeval.is_const
465
- or typeval.is_equiv(ast.TYPE_NONE)):
460
+ or typeval.is_const
461
+ or typeval.is_equiv(ast.TYPE_NONE)):
466
462
  return ast.PARAM_TRANSFER_NONE
467
463
  elif typeval.is_equiv(ast.TYPE_STRING):
468
464
  # Non-const strings default to FULL
@@ -542,8 +538,7 @@ usage is void (*_gtk_reserved1)(void);"""
542
538
 
543
539
  caller_allocates = False
544
540
  annotated_direction = None
545
- if (OPT_INOUT in options or
546
- OPT_INOUT_ALT in options):
541
+ if (OPT_INOUT in options or OPT_INOUT_ALT in options):
547
542
  annotated_direction = ast.PARAM_DIRECTION_INOUT
548
543
  elif OPT_OUT in options:
549
544
  subtype = options[OPT_OUT]
@@ -581,9 +576,9 @@ usage is void (*_gtk_reserved1)(void);"""
581
576
 
582
577
  self._adjust_container_type(parent, node, options)
583
578
 
584
- if (OPT_ALLOW_NONE in options or
585
- node.type.target_giname == 'Gio.AsyncReadyCallback' or
586
- node.type.target_giname == 'Gio.Cancellable'):
579
+ if (OPT_ALLOW_NONE in options
580
+ or node.type.target_giname == 'Gio.AsyncReadyCallback'
581
+ or node.type.target_giname == 'Gio.Cancellable'):
587
582
  node.allow_none = True
588
583
 
589
584
  if tag is not None and tag.comment is not None:
@@ -602,17 +597,17 @@ usage is void (*_gtk_reserved1)(void);"""
602
597
 
603
598
  node.doc = block.comment if block.comment else ''
604
599
 
605
- since_tag = block.get_tag(TAG_SINCE)
600
+ since_tag = block.tags.get(TAG_SINCE)
606
601
  if since_tag is not None:
607
602
  node.version = since_tag.value
608
603
 
609
- deprecated_tag = block.get_tag(TAG_DEPRECATED)
604
+ deprecated_tag = block.tags.get(TAG_DEPRECATED)
610
605
  if deprecated_tag is not None:
611
606
  value = deprecated_tag.value
612
607
  if ': ' in value:
613
608
  colon = value.find(': ')
614
609
  version = value[:colon]
615
- desc = value[colon+2:]
610
+ desc = value[colon + 2:]
616
611
  else:
617
612
  desc = value
618
613
  version = None
@@ -620,7 +615,7 @@ usage is void (*_gtk_reserved1)(void);"""
620
615
  if version is not None:
621
616
  node.deprecated_version = version
622
617
 
623
- stability_tag = block.get_tag(TAG_STABILITY)
618
+ stability_tag = block.tags.get(TAG_STABILITY)
624
619
  if stability_tag is not None:
625
620
  stability = stability_tag.value.capitalize()
626
621
  if stability in ["Stable", "Unstable", "Private", "Internal"]:
@@ -629,7 +624,7 @@ usage is void (*_gtk_reserved1)(void);"""
629
624
  message.warn('unknown value "%s" for Stability tag' % (
630
625
  stability_tag.value), stability_tag.position)
631
626
 
632
- annos_tag = block.get_tag(TAG_ATTRIBUTES)
627
+ annos_tag = block.tags.get(TAG_ATTRIBUTES)
633
628
  if annos_tag is not None:
634
629
  for key, value in annos_tag.options.items():
635
630
  if value:
@@ -691,7 +686,7 @@ usage is void (*_gtk_reserved1)(void);"""
691
686
 
692
687
  def _apply_annotations_return(self, parent, return_, block):
693
688
  if block:
694
- tag = block.get_tag(TAG_RETURNS)
689
+ tag = block.tags.get(TAG_RETURNS)
695
690
  else:
696
691
  tag = None
697
692
  self._apply_annotations_param_ret_common(parent, return_, tag)
@@ -702,7 +697,7 @@ usage is void (*_gtk_reserved1)(void);"""
702
697
  declparams.add(parent.instance_parameter.argname)
703
698
  for param in params:
704
699
  if block:
705
- tag = block.get_param(param.argname)
700
+ tag = block.params.get(param.argname)
706
701
  else:
707
702
  tag = None
708
703
  self._apply_annotations_param(parent, param, tag)
@@ -725,10 +720,9 @@ usage is void (*_gtk_reserved1)(void);"""
725
720
  (param, ) = unused
726
721
  text = ', should be %r' % (param, )
727
722
  else:
728
- text = ', should be one of %s' % (
729
- ', '.join(repr(p) for p in unused), )
723
+ text = ', should be one of %s' % (', '.join(repr(p) for p in unused), )
730
724
 
731
- tag = block.get_param(doc_name)
725
+ tag = block.params.get(doc_name)
732
726
  message.warn(
733
727
  '%s: unknown parameter %r in documentation comment%s' % (
734
728
  block.name, doc_name, text),
@@ -756,7 +750,7 @@ usage is void (*_gtk_reserved1)(void);"""
756
750
  def _apply_annotations_field(self, parent, block, field):
757
751
  if not block:
758
752
  return
759
- tag = block.get_param(field.name)
753
+ tag = block.params.get(field.name)
760
754
  if not tag:
761
755
  return
762
756
  t = tag.options.get(OPT_TYPE)
@@ -774,7 +768,7 @@ usage is void (*_gtk_reserved1)(void);"""
774
768
  self._apply_annotations_annotated(prop, block)
775
769
  if not block:
776
770
  return
777
- transfer_tag = block.get_tag(TAG_TRANSFER)
771
+ transfer_tag = block.tags.get(TAG_TRANSFER)
778
772
  if transfer_tag is not None:
779
773
  transfer = transfer_tag.value
780
774
  if transfer == OPT_TRANSFER_FLOATING:
@@ -782,28 +776,36 @@ usage is void (*_gtk_reserved1)(void);"""
782
776
  prop.transfer = transfer
783
777
  else:
784
778
  prop.transfer = self._get_transfer_default(parent, prop)
785
- type_tag = block.get_tag(TAG_TYPE)
779
+ type_tag = block.tags.get(TAG_TYPE)
786
780
  if type_tag:
787
781
  prop.type = self._resolve_toplevel(type_tag.value, prop.type, prop, parent)
788
782
 
789
783
  def _apply_annotations_signal(self, parent, signal):
784
+ names = []
790
785
  prefix = self._get_annotation_name(parent)
791
786
  block = self._blocks.get('%s::%s' % (prefix, signal.name))
792
- self._apply_annotations_annotated(signal, block)
793
- # We're only attempting to name the signal parameters if
794
- # the number of parameters (@foo) is the same or greater
795
- # than the number of signal parameters
796
- if block and len(block.params) > len(signal.parameters):
797
- names = block.params.items()
798
- # Resolve real parameter names early, so that in later
799
- # phase we can refer to them while resolving annotations.
800
- for i, param in enumerate(signal.parameters):
801
- param.argname, tag = names[i+1]
802
- else:
803
- names = []
787
+
788
+ if block:
789
+ self._apply_annotations_annotated(signal, block)
790
+
791
+ # We're only attempting to name the signal parameters if
792
+ # the number of parameters (@foo) is the same or greater
793
+ # than the number of signal parameters
794
+ if len(block.params) > len(signal.parameters):
795
+ names = block.params.items()
796
+ # Resolve real parameter names early, so that in later
797
+ # phase we can refer to them while resolving annotations.
798
+ for i, param in enumerate(signal.parameters):
799
+ param.argname, tag = names[i + 1]
800
+ elif len(signal.parameters) != 0:
801
+ # Only warn about missing params if there are actually parameters
802
+ # besides implicit self.
803
+ message.warn("incorrect number of parameters in comment block, "
804
+ "parameter annotations will be ignored.", block.position)
805
+
804
806
  for i, param in enumerate(signal.parameters):
805
807
  if names:
806
- name, tag = names[i+1]
808
+ name, tag = names[i + 1]
807
809
  options = getattr(tag, 'options', {})
808
810
  param_type = options.get(OPT_TYPE)
809
811
  if param_type:
@@ -821,7 +823,7 @@ usage is void (*_gtk_reserved1)(void);"""
821
823
 
822
824
  self._apply_annotations_annotated(node, block)
823
825
 
824
- tag = block.get_tag(TAG_VALUE)
826
+ tag = block.tags.get(TAG_VALUE)
825
827
  if tag:
826
828
  node.value = tag.value
827
829
 
@@ -836,34 +838,30 @@ usage is void (*_gtk_reserved1)(void);"""
836
838
 
837
839
  def _pass_read_annotations2(self, node, chain):
838
840
  if isinstance(node, ast.Function):
839
- self._apply_annotations2_function(node, chain)
841
+ block = self._blocks.get(node.symbol)
842
+
843
+ self._apply_annotation_rename_to(node, chain, block)
844
+
845
+ # Handle virtual invokers
846
+ parent = chain[-1] if chain else None
847
+ if (block and parent):
848
+ virtual_annotation = block.tags.get(TAG_VFUNC)
849
+ if virtual_annotation:
850
+ invoker_name = virtual_annotation.value
851
+ matched = False
852
+ for vfunc in parent.virtual_methods:
853
+ if vfunc.name == invoker_name:
854
+ matched = True
855
+ vfunc.invoker = node.name
856
+ # Also merge in annotations
857
+ self._apply_annotations_callable(vfunc, [parent], block)
858
+ break
859
+ if not matched:
860
+ message.warn_node(node,
861
+ "Virtual slot %r not found for %r annotation" % (invoker_name,
862
+ TAG_VFUNC))
840
863
  return True
841
864
 
842
- def _apply_annotations2_function(self, node, chain):
843
- block = self._blocks.get(node.symbol)
844
-
845
- self._apply_annotation_rename_to(node, chain, block)
846
-
847
- # Handle virtual invokers
848
- parent = chain[-1] if chain else None
849
- if not (block and parent):
850
- return
851
- virtual = block.get_tag(TAG_VFUNC)
852
- if not virtual:
853
- return
854
- invoker_name = virtual.value
855
- matched = False
856
- for vfunc in parent.virtual_methods:
857
- if vfunc.name == invoker_name:
858
- matched = True
859
- vfunc.invoker = node.name
860
- # Also merge in annotations
861
- self._apply_annotations_callable(vfunc, [parent], block)
862
- break
863
- if not matched:
864
- message.warn_node(node,
865
- "Virtual slot %r not found for %r annotation" % (invoker_name, TAG_VFUNC))
866
-
867
865
  def _resolve_and_filter_type_list(self, typelist):
868
866
  """Given a list of Type instances, return a new list of types with
869
867
  the ones that failed to resolve removed."""
@@ -1169,9 +1167,9 @@ method or constructor of some type."""
1169
1167
  origin_node = self._get_constructor_class(func, subsymbol)
1170
1168
  if origin_node is None:
1171
1169
  if func.is_constructor:
1172
- message.warn_node(func,
1173
- "Can't find matching type for constructor; symbol=%r" \
1174
- % (func.symbol, ))
1170
+ message.warn_node(
1171
+ func,
1172
+ "Can't find matching type for constructor; symbol=%r" % (func.symbol, ))
1175
1173
  return False
1176
1174
 
1177
1175
  # Some sanity checks; only objects and boxeds can have ctors
@@ -61,7 +61,7 @@ class Position(object):
61
61
  return '%s:' % (filename, )
62
62
 
63
63
  def offset(self, offset):
64
- return Position(self.filename, self.line+offset, self.column)
64
+ return Position(self.filename, self.line + offset, self.column)
65
65
 
66
66
 
67
67
  class MessageLogger(object):
@@ -119,16 +119,14 @@ If the warning is related to a ast.Node type, see log_node()."""
119
119
  elif log_type == FATAL:
120
120
  error_type = "Fatal"
121
121
  if prefix:
122
- text = (
123
- '''%s: %s: %s: %s: %s\n''' % (last_position, error_type, self._namespace.name,
124
- prefix, text))
122
+ text = ('%s: %s: %s: %s: %s\n' % (last_position, error_type,
123
+ self._namespace.name, prefix, text))
125
124
  else:
126
125
  if self._namespace:
127
- text = (
128
- '''%s: %s: %s: %s\n''' % (last_position, error_type, self._namespace.name, text))
126
+ text = ('%s: %s: %s: %s\n' % (last_position, error_type,
127
+ self._namespace.name, text))
129
128
  else:
130
- text = (
131
- '''%s: %s: %s\n''' % (last_position, error_type, text))
129
+ text = ('%s: %s: %s\n' % (last_position, error_type, text))
132
130
 
133
131
  self._output.write(text)
134
132
  if log_type == FATAL:
@@ -169,17 +167,21 @@ def log_node(log_type, node, text, context=None, positions=None):
169
167
  ml = MessageLogger.get()
170
168
  ml.log_node(log_type, node, text, context=context, positions=positions)
171
169
 
170
+
172
171
  def warn(text, positions=None, prefix=None):
173
172
  ml = MessageLogger.get()
174
173
  ml.log(WARNING, text, positions, prefix)
175
174
 
175
+
176
176
  def warn_node(node, text, context=None, positions=None):
177
177
  log_node(WARNING, node, text, context=context, positions=positions)
178
178
 
179
+
179
180
  def warn_symbol(symbol, text):
180
181
  ml = MessageLogger.get()
181
182
  ml.log_symbol(WARNING, symbol, text)
182
183
 
184
+
183
185
  def fatal(text, positions=None, prefix=None):
184
186
  ml = MessageLogger.get()
185
187
  ml.log(FATAL, text, positions, prefix)
@@ -38,18 +38,21 @@ from giscanner.girparser import GIRParser
38
38
  from giscanner.girwriter import GIRWriter
39
39
  from giscanner.maintransformer import MainTransformer
40
40
  from giscanner.shlibs import resolve_shlibs
41
- from giscanner.sourcescanner import SourceScanner
41
+ from giscanner.sourcescanner import SourceScanner, ALL_EXTS
42
42
  from giscanner.transformer import Transformer
43
43
  from . import utils
44
44
 
45
+
45
46
  def process_cflags_begin(option, opt, value, parser):
46
47
  cflags = getattr(parser.values, option.dest)
47
48
  while len(parser.rargs) > 0 and parser.rargs[0] != '--cflags-end':
48
49
  cflags.append(parser.rargs.pop(0))
49
50
 
51
+
50
52
  def process_cflags_end(option, opt, value, parser):
51
53
  pass
52
54
 
55
+
53
56
  def get_preprocessor_option_group(parser):
54
57
  group = optparse.OptionGroup(parser, "Preprocessor options")
55
58
  group.add_option("", "--cflags-begin",
@@ -71,6 +74,7 @@ def get_preprocessor_option_group(parser):
71
74
  group.add_option("-p", dest="", help="Ignored")
72
75
  return group
73
76
 
77
+
74
78
  def get_windows_option_group(parser):
75
79
  group = optparse.OptionGroup(parser, "Machine Dependent Options")
76
80
  group.add_option("-m", help="some machine dependent option",
@@ -79,13 +83,13 @@ def get_windows_option_group(parser):
79
83
 
80
84
  return group
81
85
 
86
+
82
87
  def _get_option_parser():
83
88
  parser = optparse.OptionParser('%prog [options] sources')
84
89
  parser.add_option('', "--quiet",
85
90
  action="store_true", dest="quiet",
86
91
  default=False,
87
- help="If passed, do not print details of normal" \
88
- + " operation")
92
+ help="If passed, do not print details of normal operation")
89
93
  parser.add_option("", "--format",
90
94
  action="store", dest="format",
91
95
  default="gir",
@@ -204,6 +208,7 @@ match the namespace prefix.""")
204
208
  def _error(msg):
205
209
  raise SystemExit('ERROR: %s' % (msg, ))
206
210
 
211
+
207
212
  def passthrough_gir(path, f):
208
213
  parser = GIRParser()
209
214
  parser.parse(path)
@@ -211,6 +216,7 @@ def passthrough_gir(path, f):
211
216
  writer = GIRWriter(parser.get_namespace())
212
217
  f.write(writer.get_xml())
213
218
 
219
+
214
220
  def test_codegen(optstring):
215
221
  (namespace, out_h_filename, out_c_filename) = optstring.split(',')
216
222
  if namespace == 'Everything':
@@ -221,6 +227,7 @@ def test_codegen(optstring):
221
227
  _error("Invaild namespace %r" % (namespace, ))
222
228
  return 0
223
229
 
230
+
224
231
  def process_options(output, allowed_flags):
225
232
  for option in output.split():
226
233
  for flag in allowed_flags:
@@ -229,6 +236,7 @@ def process_options(output, allowed_flags):
229
236
  yield option
230
237
  break
231
238
 
239
+
232
240
  def process_packages(options, packages):
233
241
  args = ['pkg-config', '--cflags']
234
242
  args.extend(packages)
@@ -248,15 +256,13 @@ def process_packages(options, packages):
248
256
  options.cpp_defines.extend(pkg_options.cpp_defines)
249
257
  options.cpp_undefines.extend(pkg_options.cpp_undefines)
250
258
 
259
+
251
260
  def extract_filenames(args):
252
261
  filenames = []
253
262
  for arg in args:
254
263
  # We don't support real C++ parsing yet, but we should be able
255
264
  # to understand C API implemented in C++ files.
256
- if (arg.endswith('.c') or arg.endswith('.cpp') or
257
- arg.endswith('.cc') or arg.endswith('.cxx') or
258
- arg.endswith('.h') or arg.endswith('.hpp') or
259
- arg.endswith('.hxx')):
265
+ if os.path.splitext(arg)[1] in ALL_EXTS:
260
266
  if not os.path.exists(arg):
261
267
  _error('%s: no such a file or directory' % (arg, ))
262
268
  # Make absolute, because we do comparisons inside scannerparser.c
@@ -264,6 +270,7 @@ def extract_filenames(args):
264
270
  filenames.append(os.path.abspath(arg))
265
271
  return filenames
266
272
 
273
+
267
274
  def extract_filelist(options):
268
275
  filenames = []
269
276
  if not os.path.exists(options.filelist):
@@ -274,10 +281,10 @@ def extract_filelist(options):
274
281
  # We don't support real C++ parsing yet, but we should be able
275
282
  # to understand C API implemented in C++ files.
276
283
  filename = line.strip()
277
- if (filename.endswith('.c') or filename.endswith('.cpp') or
278
- filename.endswith('.cc') or filename.endswith('.cxx') or
279
- filename.endswith('.h') or filename.endswith('.hpp') or
280
- filename.endswith('.hxx')):
284
+ if (filename.endswith('.c') or filename.endswith('.cpp')
285
+ or filename.endswith('.cc') or filename.endswith('.cxx')
286
+ or filename.endswith('.h') or filename.endswith('.hpp')
287
+ or filename.endswith('.hxx')):
281
288
  if not os.path.exists(filename):
282
289
  _error('%s: Invalid filelist entry-no such file or directory' % (line, ))
283
290
  # Make absolute, because we do comparisons inside scannerparser.c
@@ -285,6 +292,7 @@ def extract_filelist(options):
285
292
  filenames.append(os.path.abspath(filename))
286
293
  return filenames
287
294
 
295
+
288
296
  def create_namespace(options):
289
297
  if options.strip_prefix:
290
298
  print """g-ir-scanner: warning: Option --strip-prefix has been deprecated;
@@ -313,6 +321,7 @@ see --identifier-prefix and --symbol-prefix."""
313
321
  identifier_prefixes=identifier_prefixes,
314
322
  symbol_prefixes=symbol_prefixes)
315
323
 
324
+
316
325
  def create_transformer(namespace, options):
317
326
  transformer = Transformer(namespace,
318
327
  accept_unprefixed=options.accept_unprefixed)
@@ -334,6 +343,7 @@ def create_transformer(namespace, options):
334
343
 
335
344
  return transformer
336
345
 
346
+
337
347
  def create_binary(transformer, options, args):
338
348
  # Transform the C AST nodes into higher level
339
349
  # GLib/GObject nodes
@@ -344,7 +354,7 @@ def create_binary(transformer, options, args):
344
354
  gdump_parser.init_parse()
345
355
 
346
356
  if options.program:
347
- args=[options.program]
357
+ args = [options.program]
348
358
  args.extend(options.program_args)
349
359
  binary = IntrospectionBinary(args)
350
360
  else:
@@ -357,6 +367,7 @@ def create_binary(transformer, options, args):
357
367
  gdump_parser.parse()
358
368
  return shlibs
359
369
 
370
+
360
371
  def create_source_scanner(options, args):
361
372
  if hasattr(options, 'filelist') and options.filelist:
362
373
  filenames = extract_filelist(options)
@@ -374,6 +385,7 @@ def create_source_scanner(options, args):
374
385
  ss.parse_macros(filenames)
375
386
  return ss
376
387
 
388
+
377
389
  def write_output(data, options):
378
390
  if options.output == "-":
379
391
  output = sys.stdout
@@ -393,7 +405,7 @@ def write_output(data, options):
393
405
  os.unlink(temp_f_name)
394
406
  try:
395
407
  shutil.move(main_f_name, options.output)
396
- except OSError, e:
408
+ except OSError as e:
397
409
  if e.errno == errno.EPERM:
398
410
  os.unlink(main_f_name)
399
411
  return 0
@@ -402,14 +414,15 @@ def write_output(data, options):
402
414
  else:
403
415
  try:
404
416
  output = open(options.output, "w")
405
- except IOError, e:
417
+ except IOError as e:
406
418
  _error("opening output for writing: %s" % (e.strerror, ))
407
419
 
408
420
  try:
409
421
  output.write(data)
410
- except IOError, e:
422
+ except IOError as e:
411
423
  _error("while writing output: %s" % (e.strerror, ))
412
424
 
425
+
413
426
  def scanner_main(args):
414
427
  parser = _get_option_parser()
415
428
  (options, args) = parser.parse_args(args)
@@ -455,7 +468,6 @@ def scanner_main(args):
455
468
  blocks = ap.parse(ss.get_comments())
456
469
 
457
470
  # Transform the C symbols into AST nodes
458
- transformer.set_annotations(blocks)
459
471
  transformer.parse(ss.get_symbols())
460
472
 
461
473
  if not options.header_only: