gobject-introspection 3.0.7-x86-mingw32 → 3.0.8-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 (126) hide show
  1. checksums.yaml +4 -4
  2. data/Rakefile +2 -2
  3. data/ext/gobject-introspection/extconf.rb +1 -0
  4. data/ext/gobject-introspection/rb-gi-argument.c +123 -26
  5. data/ext/gobject-introspection/rb-gi-function-info.c +558 -19
  6. data/ext/gobject-introspection/rb-gi-repository.c +9 -0
  7. data/ext/gobject-introspection/rb-gobject-introspection.h +3 -0
  8. data/lib/2.2/gobject_introspection.so +0 -0
  9. data/lib/2.3/gobject_introspection.so +0 -0
  10. data/lib/gobject-introspection/loader.rb +1 -1
  11. data/vendor/local/bin/g-ir-compiler.exe +0 -0
  12. data/vendor/local/bin/g-ir-generate.exe +0 -0
  13. data/vendor/local/bin/libgirepository-1.0-1.dll +0 -0
  14. data/vendor/local/include/gobject-introspection-1.0/gistructinfo.h +4 -0
  15. data/vendor/local/lib/girepository-1.0/GIRepository-2.0.typelib +0 -0
  16. data/vendor/local/lib/girepository-1.0/GLib-2.0.typelib +0 -0
  17. data/vendor/local/lib/girepository-1.0/GModule-2.0.typelib +0 -0
  18. data/vendor/local/lib/girepository-1.0/GObject-2.0.typelib +0 -0
  19. data/vendor/local/lib/girepository-1.0/Gio-2.0.typelib +0 -0
  20. data/vendor/local/lib/gobject-introspection/giscanner/__init__.py +1 -1
  21. data/vendor/local/lib/gobject-introspection/giscanner/__init__.pyc +0 -0
  22. data/vendor/local/lib/gobject-introspection/giscanner/__init__.pyo +0 -0
  23. data/vendor/local/lib/gobject-introspection/giscanner/annotationmain.py +39 -11
  24. data/vendor/local/lib/gobject-introspection/giscanner/annotationmain.pyc +0 -0
  25. data/vendor/local/lib/gobject-introspection/giscanner/annotationmain.pyo +0 -0
  26. data/vendor/local/lib/gobject-introspection/giscanner/annotationparser.py +187 -164
  27. data/vendor/local/lib/gobject-introspection/giscanner/annotationparser.pyc +0 -0
  28. data/vendor/local/lib/gobject-introspection/giscanner/annotationparser.pyo +0 -0
  29. data/vendor/local/lib/gobject-introspection/giscanner/ast.py +191 -58
  30. data/vendor/local/lib/gobject-introspection/giscanner/ast.pyc +0 -0
  31. data/vendor/local/lib/gobject-introspection/giscanner/ast.pyo +0 -0
  32. data/vendor/local/lib/gobject-introspection/giscanner/cachestore.py +42 -54
  33. data/vendor/local/lib/gobject-introspection/giscanner/cachestore.pyc +0 -0
  34. data/vendor/local/lib/gobject-introspection/giscanner/cachestore.pyo +0 -0
  35. data/vendor/local/lib/gobject-introspection/giscanner/ccompiler.py +272 -82
  36. data/vendor/local/lib/gobject-introspection/giscanner/ccompiler.pyc +0 -0
  37. data/vendor/local/lib/gobject-introspection/giscanner/ccompiler.pyo +0 -0
  38. data/vendor/local/lib/gobject-introspection/giscanner/codegen.py +18 -11
  39. data/vendor/local/lib/gobject-introspection/giscanner/codegen.pyc +0 -0
  40. data/vendor/local/lib/gobject-introspection/giscanner/codegen.pyo +0 -0
  41. data/vendor/local/lib/gobject-introspection/giscanner/collections/__init__.py +4 -0
  42. data/vendor/local/lib/gobject-introspection/giscanner/collections/__init__.pyc +0 -0
  43. data/vendor/local/lib/gobject-introspection/giscanner/collections/__init__.pyo +0 -0
  44. data/vendor/local/lib/gobject-introspection/giscanner/collections/counter.pyc +0 -0
  45. data/vendor/local/lib/gobject-introspection/giscanner/collections/counter.pyo +0 -0
  46. data/vendor/local/lib/gobject-introspection/giscanner/collections/ordereddict.py +25 -13
  47. data/vendor/local/lib/gobject-introspection/giscanner/collections/ordereddict.pyc +0 -0
  48. data/vendor/local/lib/gobject-introspection/giscanner/collections/ordereddict.pyo +0 -0
  49. data/vendor/local/lib/gobject-introspection/giscanner/docmain.py +21 -19
  50. data/vendor/local/lib/gobject-introspection/giscanner/docmain.pyc +0 -0
  51. data/vendor/local/lib/gobject-introspection/giscanner/docmain.pyo +0 -0
  52. data/vendor/local/lib/gobject-introspection/giscanner/docwriter.py +19 -16
  53. data/vendor/local/lib/gobject-introspection/giscanner/docwriter.pyc +0 -0
  54. data/vendor/local/lib/gobject-introspection/giscanner/docwriter.pyo +0 -0
  55. data/vendor/local/lib/gobject-introspection/giscanner/dumper.py +148 -158
  56. data/vendor/local/lib/gobject-introspection/giscanner/dumper.pyc +0 -0
  57. data/vendor/local/lib/gobject-introspection/giscanner/dumper.pyo +0 -0
  58. data/vendor/local/lib/gobject-introspection/giscanner/gdumpparser.py +31 -21
  59. data/vendor/local/lib/gobject-introspection/giscanner/gdumpparser.pyc +0 -0
  60. data/vendor/local/lib/gobject-introspection/giscanner/gdumpparser.pyo +0 -0
  61. data/vendor/local/lib/gobject-introspection/giscanner/girparser.py +13 -5
  62. data/vendor/local/lib/gobject-introspection/giscanner/girparser.pyc +0 -0
  63. data/vendor/local/lib/gobject-introspection/giscanner/girparser.pyo +0 -0
  64. data/vendor/local/lib/gobject-introspection/giscanner/girwriter.py +12 -13
  65. data/vendor/local/lib/gobject-introspection/giscanner/girwriter.pyc +0 -0
  66. data/vendor/local/lib/gobject-introspection/giscanner/girwriter.pyo +0 -0
  67. data/vendor/local/lib/gobject-introspection/giscanner/introspectablepass.py +5 -1
  68. data/vendor/local/lib/gobject-introspection/giscanner/introspectablepass.pyc +0 -0
  69. data/vendor/local/lib/gobject-introspection/giscanner/introspectablepass.pyo +0 -0
  70. data/vendor/local/lib/gobject-introspection/giscanner/libtoolimporter.py +11 -9
  71. data/vendor/local/lib/gobject-introspection/giscanner/libtoolimporter.pyc +0 -0
  72. data/vendor/local/lib/gobject-introspection/giscanner/libtoolimporter.pyo +0 -0
  73. data/vendor/local/lib/gobject-introspection/giscanner/maintransformer.py +150 -45
  74. data/vendor/local/lib/gobject-introspection/giscanner/maintransformer.pyc +0 -0
  75. data/vendor/local/lib/gobject-introspection/giscanner/maintransformer.pyo +0 -0
  76. data/vendor/local/lib/gobject-introspection/giscanner/message.py +56 -19
  77. data/vendor/local/lib/gobject-introspection/giscanner/message.pyc +0 -0
  78. data/vendor/local/lib/gobject-introspection/giscanner/message.pyo +0 -0
  79. data/vendor/local/lib/gobject-introspection/giscanner/msvccompiler.py +101 -0
  80. data/vendor/local/lib/gobject-introspection/giscanner/msvccompiler.pyc +0 -0
  81. data/vendor/local/lib/gobject-introspection/giscanner/msvccompiler.pyo +0 -0
  82. data/vendor/local/lib/gobject-introspection/giscanner/scannermain.py +41 -22
  83. data/vendor/local/lib/gobject-introspection/giscanner/scannermain.pyc +0 -0
  84. data/vendor/local/lib/gobject-introspection/giscanner/scannermain.pyo +0 -0
  85. data/vendor/local/lib/gobject-introspection/giscanner/sectionparser.py +6 -1
  86. data/vendor/local/lib/gobject-introspection/giscanner/sectionparser.pyc +0 -0
  87. data/vendor/local/lib/gobject-introspection/giscanner/sectionparser.pyo +0 -0
  88. data/vendor/local/lib/gobject-introspection/giscanner/shlibs.py +8 -2
  89. data/vendor/local/lib/gobject-introspection/giscanner/shlibs.pyc +0 -0
  90. data/vendor/local/lib/gobject-introspection/giscanner/shlibs.pyo +0 -0
  91. data/vendor/local/lib/gobject-introspection/giscanner/sourcescanner.py +42 -56
  92. data/vendor/local/lib/gobject-introspection/giscanner/sourcescanner.pyc +0 -0
  93. data/vendor/local/lib/gobject-introspection/giscanner/sourcescanner.pyo +0 -0
  94. data/vendor/local/lib/gobject-introspection/giscanner/testcodegen.py +19 -5
  95. data/vendor/local/lib/gobject-introspection/giscanner/testcodegen.pyc +0 -0
  96. data/vendor/local/lib/gobject-introspection/giscanner/testcodegen.pyo +0 -0
  97. data/vendor/local/lib/gobject-introspection/giscanner/transformer.py +73 -37
  98. data/vendor/local/lib/gobject-introspection/giscanner/transformer.pyc +0 -0
  99. data/vendor/local/lib/gobject-introspection/giscanner/transformer.pyo +0 -0
  100. data/vendor/local/lib/gobject-introspection/giscanner/utils.py +92 -14
  101. data/vendor/local/lib/gobject-introspection/giscanner/utils.pyc +0 -0
  102. data/vendor/local/lib/gobject-introspection/giscanner/utils.pyo +0 -0
  103. data/vendor/local/lib/gobject-introspection/giscanner/xmlwriter.py +30 -11
  104. data/vendor/local/lib/gobject-introspection/giscanner/xmlwriter.pyc +0 -0
  105. data/vendor/local/lib/gobject-introspection/giscanner/xmlwriter.pyo +0 -0
  106. data/vendor/local/lib/libgirepository-1.0.a +0 -0
  107. data/vendor/local/lib/libgirepository-1.0.dll.a +0 -0
  108. data/vendor/local/lib/libgirepository-1.0.la +1 -1
  109. data/vendor/local/lib/pkgconfig/gobject-introspection-1.0.pc +1 -1
  110. data/vendor/local/lib/pkgconfig/gobject-introspection-no-export-1.0.pc +1 -1
  111. data/vendor/local/share/gir-1.0/GIRepository-2.0.gir +57 -13
  112. data/vendor/local/share/gir-1.0/GLib-2.0.gir +2018 -894
  113. data/vendor/local/share/gir-1.0/GModule-2.0.gir +2 -1
  114. data/vendor/local/share/gir-1.0/GObject-2.0.gir +1107 -674
  115. data/vendor/local/share/gir-1.0/Gio-2.0.gir +5589 -1287
  116. data/vendor/local/share/gobject-introspection-1.0/Makefile.introspection +4 -2
  117. data/vendor/local/share/gobject-introspection-1.0/gdump.c +8 -0
  118. data/vendor/local/share/gobject-introspection-1.0/tests/everything.c +273 -323
  119. data/vendor/local/share/gobject-introspection-1.0/tests/everything.h +58 -38
  120. data/vendor/local/share/gobject-introspection-1.0/tests/gimarshallingtests.c +1 -1
  121. data/vendor/local/share/gobject-introspection-1.0/tests/regress.c +177 -23
  122. data/vendor/local/share/gobject-introspection-1.0/tests/regress.h +40 -0
  123. data/vendor/local/share/man/man1/g-ir-compiler.1 +7 -7
  124. metadata +9 -7
  125. data/lib/2.0/gobject_introspection.so +0 -0
  126. data/lib/2.1/gobject_introspection.so +0 -0
@@ -243,6 +243,14 @@ rg_find(int argc, VALUE *argv, VALUE self)
243
243
  return GI_BASE_INFO2RVAL(info);
244
244
  }
245
245
 
246
+ static VALUE
247
+ rg_get_version(VALUE self, VALUE rb_namespace)
248
+ {
249
+ const gchar *version;
250
+ version = g_irepository_get_version(SELF(self), RVAL2CSTR(rb_namespace));
251
+ return CSTR2RVAL(version);
252
+ }
253
+
246
254
  void
247
255
  rb_gi_repository_init(VALUE rb_mGI)
248
256
  {
@@ -259,6 +267,7 @@ rb_gi_repository_init(VALUE rb_mGI)
259
267
  RG_DEF_METHOD(get_n_infos, 1);
260
268
  RG_DEF_METHOD(get_info, 2);
261
269
  RG_DEF_METHOD(find, -1);
270
+ RG_DEF_METHOD(get_version, 1);
262
271
 
263
272
  G_DEF_CLASS(G_TYPE_I_REPOSITORY_LOAD_FLAGS, "RepositoryLoadFlags", rb_mGI);
264
273
  G_DEF_CLASS(G_TYPE_I_REPOSITORY_ERROR, "RepositoryError", rb_mGI);
@@ -28,6 +28,8 @@
28
28
 
29
29
  typedef gpointer (*RBGICallbackFinderFunc)(GIArgInfo *info);
30
30
 
31
+ typedef struct _RBGICallback RBGICallback;
32
+
31
33
  typedef struct
32
34
  {
33
35
  GIArgInfo arg_info;
@@ -49,6 +51,7 @@ typedef struct
49
51
  } RBGIArgMetadata;
50
52
 
51
53
  typedef struct {
54
+ RBGICallback *callback;
52
55
  RBGIArgMetadata *metadata;
53
56
  VALUE rb_gc_guard_key;
54
57
  VALUE rb_callback;
Binary file
Binary file
@@ -100,7 +100,7 @@ module GObjectIntrospection
100
100
 
101
101
  def define_singleton_method(klass, name, info)
102
102
  unlock_gvl = should_unlock_gvl?(info, klass)
103
- prepare = lambda do |arguments|
103
+ prepare = lambda do |arguments, &block|
104
104
  arguments, block = build_arguments(info, arguments, &block)
105
105
  validate_arguments(info, "#{klass}.#{name}", arguments)
106
106
  [arguments, block]
Binary file
Binary file
@@ -48,6 +48,10 @@ GI_AVAILABLE_IN_ALL
48
48
  GIFieldInfo * g_struct_info_get_field (GIStructInfo *info,
49
49
  gint n);
50
50
 
51
+ GI_AVAILABLE_IN_ALL
52
+ GIFieldInfo * g_struct_info_find_field (GIStructInfo *info,
53
+ const gchar *name);
54
+
51
55
  GI_AVAILABLE_IN_ALL
52
56
  gint g_struct_info_get_n_methods (GIStructInfo *info);
53
57
 
@@ -17,7 +17,7 @@
17
17
  # Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18
18
  # Boston, MA 02111-1307, USA.
19
19
  #
20
-
20
+ from __future__ import absolute_import
21
21
  import os
22
22
  builddir = os.environ.get('UNINSTALLED_INTROSPECTION_BUILDDIR')
23
23
  if builddir is not None:
@@ -18,7 +18,15 @@
18
18
  # 02110-1301, USA.
19
19
  #
20
20
 
21
+ from __future__ import absolute_import
22
+ from __future__ import division
23
+ from __future__ import print_function
24
+ from __future__ import unicode_literals
25
+
26
+ import sys
21
27
  import optparse
28
+ import codecs
29
+ from contextlib import contextmanager
22
30
 
23
31
  from giscanner import message
24
32
  from giscanner.annotationparser import GtkDocCommentBlockParser, GtkDocCommentBlockWriter
@@ -27,6 +35,24 @@ from giscanner.scannermain import (get_preprocessor_option_group,
27
35
  process_packages)
28
36
 
29
37
 
38
+ @contextmanager
39
+ def encode_stdout(encoding):
40
+ """Force stdout into a specific encoding."""
41
+ # Python 2 does not encode stdout writes so wrap it with 'encoding' encoded writer.
42
+ # Python 3 uses a io.TextIOBase wrapped stdout with the system default encoding.
43
+ # Re-wrap the underlying buffer with a new writer with the given 'encoding'.
44
+ # See: https://docs.python.org/3/library/sys.html#sys.stdout
45
+ old_stdout = sys.stdout
46
+ if sys.version_info.major < 3:
47
+ binary_stdout = sys.stdout
48
+ else:
49
+ binary_stdout = sys.stdout.buffer
50
+
51
+ sys.stdout = codecs.getwriter(encoding)(binary_stdout)
52
+ yield
53
+ sys.stdout = old_stdout
54
+
55
+
30
56
  def annotation_main(args):
31
57
  parser = optparse.OptionParser('%prog [options] sources')
32
58
 
@@ -61,16 +87,18 @@ def annotation_main(args):
61
87
  parser = GtkDocCommentBlockParser()
62
88
  writer = GtkDocCommentBlockWriter(indent=False)
63
89
  blocks = parser.parse_comment_blocks(ss.get_comments())
64
- print '/' + ('*' * 60) + '/'
65
- print '/* THIS FILE IS GENERATED DO NOT EDIT */'
66
- print '/' + ('*' * 60) + '/'
67
- print
68
- for block in sorted(blocks.values()):
69
- print writer.write(block)
70
- print
71
- print
72
- print '/' + ('*' * 60) + '/'
73
- print '/* THIS FILE IS GENERATED DO NOT EDIT */'
74
- print '/' + ('*' * 60) + '/'
90
+
91
+ with encode_stdout('utf-8'):
92
+ print('/' + ('*' * 60) + '/')
93
+ print('/* THIS FILE IS GENERATED DO NOT EDIT */')
94
+ print('/' + ('*' * 60) + '/')
95
+ print('')
96
+ for block in sorted(blocks.values()):
97
+ print(writer.write(block))
98
+ print('')
99
+ print('')
100
+ print('/' + ('*' * 60) + '/')
101
+ print('/* THIS FILE IS GENERATED DO NOT EDIT */')
102
+ print('/' + ('*' * 60) + '/')
75
103
 
76
104
  return 0
@@ -61,12 +61,12 @@ specific order:
61
61
  comment block which consists of:
62
62
 
63
63
  * a required `identifier_name` field
64
- * an optional `annotations` field
64
+ * an optional `annotations` field, optionally spanning multiple lines
65
65
 
66
66
  #. Zero or more `parameter` parts, each consisting of:
67
67
 
68
68
  * a required `parameter_name` field
69
- * an optional `annotations` field
69
+ * an optional `annotations` field, optionally spanning multiple lines
70
70
  * a required `description` field (can be the empty string)
71
71
 
72
72
  #. One optional `comment block description` part which must begin with at
@@ -75,7 +75,7 @@ specific order:
75
75
  #. Zero or more `tag` parts, each consisting of:
76
76
 
77
77
  * a required `tag_name` field
78
- * an optional `annotations` field
78
+ * an optional `annotations` field, optionally spanning multiple lines
79
79
  * an optional `value` field
80
80
  * a required `description` field (can be the empty string)
81
81
 
@@ -95,6 +95,7 @@ Additionally, the following restrictions are in effect:
95
95
 
96
96
  * the `comment_block_description` part
97
97
  * `parameter description` and `tag description` fields
98
+ * `identifier`, `parameter` and `tag` part `annotations` fields
98
99
 
99
100
  #. Taking the above restrictions into account, spanning multiple paragraphs is
100
101
  limited to the `comment block description` part and `tag description` fields.
@@ -107,9 +108,13 @@ Refer to the `GTK-Doc manual`_ for more detailed usage information.
107
108
 
108
109
 
109
110
  from __future__ import absolute_import
111
+ from __future__ import division
112
+ from __future__ import print_function
113
+ from __future__ import unicode_literals
110
114
 
111
115
  import os
112
116
  import re
117
+ import operator
113
118
 
114
119
  from collections import namedtuple
115
120
  from operator import ne, gt, lt
@@ -203,6 +208,7 @@ ANN_INOUT = 'inout'
203
208
  ANN_METHOD = 'method'
204
209
  ANN_NULLABLE = 'nullable'
205
210
  ANN_OPTIONAL = 'optional'
211
+ ANN_NOT = 'not'
206
212
  ANN_OUT = 'out'
207
213
  ANN_REF_FUNC = 'ref-func'
208
214
  ANN_RENAME_TO = 'rename-to'
@@ -218,6 +224,7 @@ ANN_VALUE = 'value'
218
224
  GI_ANNS = [ANN_ALLOW_NONE,
219
225
  ANN_NULLABLE,
220
226
  ANN_OPTIONAL,
227
+ ANN_NOT,
221
228
  ANN_ARRAY,
222
229
  ANN_ATTRIBUTES,
223
230
  ANN_CLOSURE,
@@ -268,6 +275,11 @@ OPT_OUT_CALLER_ALLOCATES = 'caller-allocates'
268
275
  OUT_OPTIONS = [OPT_OUT_CALLEE_ALLOCATES,
269
276
  OPT_OUT_CALLER_ALLOCATES]
270
277
 
278
+ # (not) annotation options
279
+ OPT_NOT_NULLABLE = 'nullable'
280
+
281
+ NOT_OPTIONS = [OPT_NOT_NULLABLE]
282
+
271
283
  # (scope) annotation options
272
284
  OPT_SCOPE_ASYNC = 'async'
273
285
  OPT_SCOPE_CALL = 'call'
@@ -507,13 +519,16 @@ class GtkDocAnnotations(OrderedDict):
507
519
 
508
520
  __slots__ = ('position')
509
521
 
510
- def __init__(self, position=None):
511
- OrderedDict.__init__(self)
522
+ def __init__(self, position=None, sequence=None):
523
+ OrderedDict.__init__(self, sequence)
512
524
 
513
525
  #: A :class:`giscanner.message.Position` instance specifying the location of the
514
526
  #: annotations in the source file or :const:`None`.
515
527
  self.position = position
516
528
 
529
+ def __copy__(self):
530
+ return GtkDocAnnotations(self.position, self)
531
+
517
532
 
518
533
  class GtkDocAnnotatable(object):
519
534
  '''
@@ -537,7 +552,7 @@ class GtkDocAnnotatable(object):
537
552
  self.annotations = GtkDocAnnotations()
538
553
 
539
554
  def __repr__(self):
540
- return '<GtkDocAnnotatable %r %r>' % (self.annotations, )
555
+ return "<GtkDocAnnotatable '%s' %r>" % (self.annotations, )
541
556
 
542
557
  def validate(self):
543
558
  '''
@@ -560,6 +575,18 @@ class GtkDocAnnotatable(object):
560
575
  # GObject-Instrospection version.
561
576
  warn('unknown annotation: %s' % (ann_name, ), position)
562
577
 
578
+ # Validate that (nullable) and (not nullable) are not both
579
+ # present. Same for (allow-none) and (not nullable).
580
+ if ann_name == ANN_NOT and OPT_NOT_NULLABLE in options:
581
+ if ANN_NULLABLE in self.annotations:
582
+ warn('cannot have both "%s" and "%s" present' %
583
+ (ANN_NOT + ' ' + OPT_NOT_NULLABLE, ANN_NULLABLE),
584
+ position)
585
+ if ANN_ALLOW_NONE in self.annotations:
586
+ warn('cannot have both "%s" and "%s" present' %
587
+ (ANN_NOT + ' ' + OPT_NOT_NULLABLE, ANN_ALLOW_NONE),
588
+ position)
589
+
563
590
  def _validate_options(self, position, ann_name, n_options, expected_n_options, operator,
564
591
  message):
565
592
  '''
@@ -821,6 +848,19 @@ class GtkDocAnnotatable(object):
821
848
 
822
849
  self._validate_annotation(position, ann_name, options, exact_n_options=0)
823
850
 
851
+ def _do_validate_not(self, position, ann_name, options):
852
+ '''
853
+ Validate the ``(not)`` annotation.
854
+
855
+ :param position: :class:`giscanner.message.Position` of the line in the source file
856
+ containing the annotation to be validated
857
+ :param ann_name: name of the annotation holding the options to validate
858
+ :param options: annotation options held by the annotation
859
+ '''
860
+
861
+ self._validate_annotation(position, ann_name, options, exact_n_options=1,
862
+ choices=NOT_OPTIONS)
863
+
824
864
  def _do_validate_out(self, position, ann_name, options):
825
865
  '''
826
866
  Validate the ``(out)`` annotation.
@@ -966,7 +1006,7 @@ class GtkDocParameter(GtkDocAnnotatable):
966
1006
 
967
1007
  valid_annotations = (ANN_ALLOW_NONE, ANN_ARRAY, ANN_ATTRIBUTES, ANN_CLOSURE, ANN_DESTROY,
968
1008
  ANN_ELEMENT_TYPE, ANN_IN, ANN_INOUT, ANN_OUT, ANN_SCOPE, ANN_SKIP,
969
- ANN_TRANSFER, ANN_TYPE, ANN_OPTIONAL, ANN_NULLABLE)
1009
+ ANN_TRANSFER, ANN_TYPE, ANN_OPTIONAL, ANN_NULLABLE, ANN_NOT)
970
1010
 
971
1011
  def __init__(self, name, position=None):
972
1012
  GtkDocAnnotatable.__init__(self, position)
@@ -978,7 +1018,7 @@ class GtkDocParameter(GtkDocAnnotatable):
978
1018
  self.description = None
979
1019
 
980
1020
  def __repr__(self):
981
- return '<GtkDocParameter %r %r>' % (self.name, self.annotations)
1021
+ return "<GtkDocParameter '%s' %r>" % (self.name, self.annotations)
982
1022
 
983
1023
 
984
1024
  class GtkDocTag(GtkDocAnnotatable):
@@ -989,7 +1029,7 @@ class GtkDocTag(GtkDocAnnotatable):
989
1029
  __slots__ = ('name', 'value', 'description')
990
1030
 
991
1031
  valid_annotations = (ANN_ALLOW_NONE, ANN_ARRAY, ANN_ATTRIBUTES, ANN_ELEMENT_TYPE, ANN_SKIP,
992
- ANN_TRANSFER, ANN_TYPE, ANN_NULLABLE, ANN_OPTIONAL)
1032
+ ANN_TRANSFER, ANN_TYPE, ANN_NULLABLE, ANN_OPTIONAL, ANN_NOT)
993
1033
 
994
1034
  def __init__(self, name, position=None):
995
1035
  GtkDocAnnotatable.__init__(self, position)
@@ -1004,7 +1044,7 @@ class GtkDocTag(GtkDocAnnotatable):
1004
1044
  self.description = None
1005
1045
 
1006
1046
  def __repr__(self):
1007
- return '<GtkDocTag %r %r>' % (self.name, self.annotations)
1047
+ return "<GtkDocTag '%s' %r>" % (self.name, self.annotations)
1008
1048
 
1009
1049
 
1010
1050
  class GtkDocCommentBlock(GtkDocAnnotatable):
@@ -1047,14 +1087,35 @@ class GtkDocCommentBlock(GtkDocAnnotatable):
1047
1087
  #: applied to this :class:`GtkDocCommentBlock`.
1048
1088
  self.tags = OrderedDict()
1049
1089
 
1050
- def __cmp__(self, other):
1090
+ def _compare(self, other, op):
1051
1091
  # Note: This is used by g-ir-annotation-tool, which does a ``sorted(blocks.values())``,
1052
1092
  # meaning that keeping this around makes update-glib-annotations.py patches
1053
1093
  # easier to review.
1054
- return cmp(self.name, other.name)
1094
+ return op(self.name, other.name)
1095
+
1096
+ def __lt__(self, other):
1097
+ return self._compare(other, operator.lt)
1098
+
1099
+ def __gt__(self, other):
1100
+ return self._compare(other, operator.gt)
1101
+
1102
+ def __ge__(self, other):
1103
+ return self._compare(other, operator.ge)
1104
+
1105
+ def __le__(self, other):
1106
+ return self._compare(other, operator.le)
1107
+
1108
+ def __eq__(self, other):
1109
+ return self._compare(other, operator.eq)
1110
+
1111
+ def __ne__(self, other):
1112
+ return self._compare(other, operator.ne)
1113
+
1114
+ def __hash__(self):
1115
+ return hash(self.name)
1055
1116
 
1056
1117
  def __repr__(self):
1057
- return '<GtkDocCommentBlock %r %r>' % (self.name, self.annotations)
1118
+ return "<GtkDocCommentBlock '%s' %r>" % (self.name, self.annotations)
1058
1119
 
1059
1120
  def validate(self):
1060
1121
  '''
@@ -1071,10 +1132,12 @@ class GtkDocCommentBlock(GtkDocAnnotatable):
1071
1132
 
1072
1133
 
1073
1134
  #: Result object returned by :class:`GtkDocCommentBlockParser`._parse_annotations()
1074
- _ParseAnnotationsResult = namedtuple('Result', ['success', 'annotations', 'start_pos', 'end_pos'])
1135
+ _ParseAnnotationsResult = namedtuple('Result', ['success', 'annotations', 'annotations_changed',
1136
+ 'start_pos', 'end_pos'])
1075
1137
 
1076
1138
  #: Result object returned by :class:`GtkDocCommentBlockParser`._parse_fields()
1077
- _ParseFieldsResult = namedtuple('Result', ['success', 'annotations', 'description'])
1139
+ _ParseFieldsResult = namedtuple('Result', ['success', 'annotations', 'annotations_changed',
1140
+ 'description'])
1078
1141
 
1079
1142
 
1080
1143
  class GtkDocCommentBlockParser(object):
@@ -1097,14 +1160,11 @@ class GtkDocCommentBlockParser(object):
1097
1160
  * unexpected introspection behavior, for example missing parameters in the
1098
1161
  generated .gir and .typelib files
1099
1162
 
1100
- .. NOTE:: :class:`GtkDocCommentBlockParser` functionality is heavily based on gtkdoc-mkdb's
1101
- `ScanSourceFile()`_ function and is currently in sync with GTK-Doc
1102
- commit `47abcd5`_.
1163
+ .. NOTE:: :class:`GtkDocCommentBlockParser` functionality is based on gtkdoc-mkdb's
1164
+ `ScanSourceFile()`_ function.
1103
1165
 
1104
1166
  .. _ScanSourceFile():
1105
1167
  http://git.gnome.org/browse/gtk-doc/tree/gtkdoc-mkdb.in#n3722
1106
- .. _47abcd5:
1107
- https://git.gnome.org/browse/gtk-doc/commit/?id=47abcd53b8489ebceec9e394676512a181c1f1f6
1108
1168
  '''
1109
1169
 
1110
1170
  def parse_comment_blocks(self, comments):
@@ -1120,9 +1180,10 @@ class GtkDocCommentBlockParser(object):
1120
1180
  for (comment, filename, lineno) in comments:
1121
1181
  try:
1122
1182
  comment_block = self.parse_comment_block(comment, filename, lineno)
1123
- except Exception:
1183
+ except Exception as e:
1124
1184
  error('unrecoverable parse error, please file a GObject-Introspection bug'
1125
- 'report including the complete comment block at the indicated location.',
1185
+ 'report including the complete comment block at the indicated location. %s' %
1186
+ str(e),
1126
1187
  Position(filename, lineno))
1127
1188
  continue
1128
1189
 
@@ -1166,10 +1227,8 @@ class GtkDocCommentBlockParser(object):
1166
1227
  # Skip single line comment blocks
1167
1228
  if comment_lines_len == 1:
1168
1229
  position = Position(filename, lineno)
1169
- marker = ' ' * result.end('code') + '^'
1170
- error('Skipping invalid GTK-Doc comment block:'
1171
- '\n%s\n%s' % (comment_lines[0], marker),
1172
- position)
1230
+ error('Skipping invalid GTK-Doc comment block:',
1231
+ position, None, result.end('code'), comment_lines[0])
1173
1232
  return None
1174
1233
 
1175
1234
  code_before = result.group('code')
@@ -1177,17 +1236,14 @@ class GtkDocCommentBlockParser(object):
1177
1236
 
1178
1237
  if code_before:
1179
1238
  position = Position(filename, lineno)
1180
- marker = ' ' * result.end('code') + '^'
1181
- warn('GTK-Doc comment block start token "/**" should '
1182
- 'not be preceded by code:\n%s\n%s' % (comment_lines[0], marker),
1183
- position)
1239
+ warn('GTK-Doc comment block start token "/**" should not be preceded by code:',
1240
+ position, None, result.end('code'), comment_lines[0])
1184
1241
 
1185
1242
  if comment:
1186
1243
  position = Position(filename, lineno)
1187
- marker = ' ' * result.start('comment') + '^'
1188
1244
  warn('GTK-Doc comment block start token "/**" should '
1189
- 'not be followed by comment text:\n%s\n%s' % (comment_lines[0], marker),
1190
- position)
1245
+ 'not be followed by comment text:',
1246
+ position, None, result.start('comment'), comment_lines[0])
1191
1247
 
1192
1248
  comment_lines[0] = comment
1193
1249
  else:
@@ -1203,17 +1259,15 @@ class GtkDocCommentBlockParser(object):
1203
1259
  comment = result.group('comment')
1204
1260
  if code_after:
1205
1261
  position = Position(filename, lineno + comment_lines_len - 1)
1206
- marker = ' ' * result.end('code') + '^'
1207
1262
  warn('GTK-Doc comment block end token "*/" should '
1208
- 'not be followed by code:\n%s\n%s' % (comment_lines[-1], marker),
1209
- position)
1263
+ 'not be followed by code:',
1264
+ position, None, result.end('code'), comment_lines[-1])
1210
1265
 
1211
1266
  if comment:
1212
1267
  position = Position(filename, lineno + comment_lines_len - 1)
1213
- marker = ' ' * result.end('comment') + '^'
1214
1268
  warn('GTK-Doc comment block end token "*/" should '
1215
- 'not be preceded by comment text:\n%s\n%s' % (comment_lines[-1], marker),
1216
- position)
1269
+ 'not be preceded by comment text:',
1270
+ position, None, result.end('comment'), comment_lines[-1])
1217
1271
 
1218
1272
  comment_lines[-1] = comment
1219
1273
  else:
@@ -1251,10 +1305,8 @@ class GtkDocCommentBlockParser(object):
1251
1305
  if result:
1252
1306
  comment = result.group('comment')
1253
1307
  if comment:
1254
- marker = ' ' * result.start('comment') + '^'
1255
- error('invalid comment text:\n%s\n%s' %
1256
- (original_line, marker),
1257
- position)
1308
+ error('invalid comment text:',
1309
+ position, None, result.start('comment'), original_line)
1258
1310
 
1259
1311
  column_offset = result.end(0)
1260
1312
  line = line[result.end(0):]
@@ -1326,20 +1378,16 @@ class GtkDocCommentBlockParser(object):
1326
1378
  comment_block.annotations = res.annotations
1327
1379
 
1328
1380
  if not identifier_delimiter and res.annotations:
1329
- marker_position = column_offset + result.start('delimiter')
1330
- marker = ' ' * marker_position + '^'
1331
- warn('missing ":" at column %s:\n%s\n%s' %
1332
- (marker_position + 1, original_line, marker),
1333
- position)
1381
+ marker_pos = column_offset + result.start('delimiter')
1382
+ warn('missing ":" at column %s:' % (marker_pos + 1, ),
1383
+ position, None, marker_pos, original_line)
1334
1384
 
1335
1385
  if not result:
1336
1386
  # Emit a single warning when the identifier is not found on the first line
1337
1387
  if not identifier_warned:
1338
1388
  identifier_warned = True
1339
- marker = ' ' * column_offset + '^'
1340
- error('identifier not found on the first line:\n%s\n%s' %
1341
- (original_line, marker),
1342
- position)
1389
+ error('identifier not found on the first line:',
1390
+ position, None, column_offset, original_line)
1343
1391
  continue
1344
1392
 
1345
1393
  ####################################################################
@@ -1352,12 +1400,11 @@ class GtkDocCommentBlockParser(object):
1352
1400
  param_name_lower = param_name.lower()
1353
1401
  param_fields = result.group('fields')
1354
1402
  param_fields_start = result.start('fields')
1355
- marker = ' ' * (result.start('parameter_name') + column_offset) + '^'
1403
+ marker_pos = result.start('parameter_name') + column_offset
1356
1404
 
1357
1405
  if in_part not in [PART_IDENTIFIER, PART_PARAMETERS]:
1358
- warn('"@%s" parameter unexpected at this location:\n%s\n%s' %
1359
- (param_name, original_line, marker),
1360
- position)
1406
+ warn('"@%s" parameter unexpected at this location:' % (param_name, ),
1407
+ position, None, marker_pos, original_line)
1361
1408
 
1362
1409
  in_part = PART_PARAMETERS
1363
1410
 
@@ -1388,15 +1435,15 @@ class GtkDocCommentBlockParser(object):
1388
1435
  elif (param_name == 'Varargs'
1389
1436
  or (param_name.endswith('...') and param_name != '...')):
1390
1437
  # Deprecated @Varargs notation or named __VA_ARGS__ instead of @...
1391
- warn('"@%s" parameter is deprecated, please use "@..." instead:\n%s\n%s' %
1392
- (param_name, original_line, marker),
1393
- position)
1438
+ warn('"@%s" parameter is deprecated, please use "@..." instead:' %
1439
+ (param_name, ),
1440
+ position, None, marker_pos, original_line)
1394
1441
  param_name = '...'
1395
1442
 
1396
1443
  if param_name in comment_block.params.keys():
1397
- error('multiple "@%s" parameters for identifier "%s":\n%s\n%s' %
1398
- (param_name, comment_block.name, original_line, marker),
1399
- position)
1444
+ error('multiple "@%s" parameters for identifier "%s":' %
1445
+ (param_name, comment_block.name),
1446
+ position, None, marker_pos, original_line)
1400
1447
 
1401
1448
  parameter = GtkDocParameter(param_name, position)
1402
1449
 
@@ -1439,7 +1486,7 @@ class GtkDocCommentBlockParser(object):
1439
1486
  tag_name_lower = tag_name.lower()
1440
1487
  tag_fields = result.group('fields')
1441
1488
  tag_fields_start = result.start('fields')
1442
- marker = ' ' * (result.start('tag_name') + column_offset) + '^'
1489
+ marker_pos = result.start('tag_name') + column_offset
1443
1490
 
1444
1491
  if tag_name_lower in DEPRECATED_GI_ANN_TAGS:
1445
1492
  # Deprecated GObject-Introspection specific tags.
@@ -1447,8 +1494,8 @@ class GtkDocCommentBlockParser(object):
1447
1494
  # instead, as agreed upon in http://bugzilla.gnome.org/show_bug.cgi?id=676133
1448
1495
  warn('GObject-Introspection specific GTK-Doc tag "%s" '
1449
1496
  'has been deprecated, please use annotations on the identifier '
1450
- 'instead:\n%s\n%s' % (tag_name, original_line, marker),
1451
- position)
1497
+ 'instead:' % (tag_name, ),
1498
+ position, None, marker_pos, original_line)
1452
1499
 
1453
1500
  # Translate deprecated tag name into corresponding annotation name
1454
1501
  ann_name = tag_name_lower.replace(' ', '-')
@@ -1459,13 +1506,16 @@ class GtkDocCommentBlockParser(object):
1459
1506
  result.start('tag_name') + column_offset,
1460
1507
  line,
1461
1508
  tag_fields.strip(),
1509
+ None,
1462
1510
  False,
1463
1511
  False)
1464
1512
 
1465
1513
  if result.success:
1466
1514
  for annotation in result.annotations:
1467
- ann_options = self._parse_annotation_options_list(position, marker,
1468
- line, annotation)
1515
+ ann_options = self._parse_annotation_options_list(position,
1516
+ marker_pos,
1517
+ line,
1518
+ annotation)
1469
1519
  n_options = len(ann_options)
1470
1520
  if n_options == 1:
1471
1521
  transformed = '%s %s' % (transformed, ann_options[0], )
@@ -1474,9 +1524,8 @@ class GtkDocCommentBlockParser(object):
1474
1524
  ann_options[1])
1475
1525
  else:
1476
1526
  # Malformed Attributes: tag
1477
- error('malformed "Attributes:" tag will be ignored:\n%s\n%s' %
1478
- (original_line, marker),
1479
- position)
1527
+ error('malformed "Attributes:" tag will be ignored:',
1528
+ position, None, marker_pos, original_line)
1480
1529
  transformed = None
1481
1530
 
1482
1531
  if transformed:
@@ -1489,8 +1538,8 @@ class GtkDocCommentBlockParser(object):
1489
1538
  stored_annotation = comment_block.annotations.get('attributes')
1490
1539
  if stored_annotation:
1491
1540
  error('Duplicate "Attributes:" annotation will '
1492
- 'be ignored:\n%s\n%s' % (original_line, marker),
1493
- position)
1541
+ 'be ignored:',
1542
+ position, None, marker_pos, original_line)
1494
1543
  else:
1495
1544
  comment_block.annotations[ann_name] = docannotation
1496
1545
  else:
@@ -1503,9 +1552,8 @@ class GtkDocCommentBlockParser(object):
1503
1552
  continue
1504
1553
  elif tag_name_lower == TAG_DESCRIPTION:
1505
1554
  # Deprecated GTK-Doc Description: tag
1506
- warn('GTK-Doc tag "Description:" has been deprecated:\n%s\n%s' %
1507
- (original_line, marker),
1508
- position)
1555
+ warn('GTK-Doc tag "Description:" has been deprecated:',
1556
+ position, None, marker_pos, original_line)
1509
1557
 
1510
1558
  in_part = PART_DESCRIPTION
1511
1559
 
@@ -1524,9 +1572,8 @@ class GtkDocCommentBlockParser(object):
1524
1572
 
1525
1573
  if in_part != PART_TAGS:
1526
1574
  in_part = PART_TAGS
1527
- warn('"%s:" tag unexpected at this location:\n%s\n%s' %
1528
- (tag_name, original_line, marker),
1529
- position)
1575
+ warn('"%s:" tag unexpected at this location:' % (tag_name, ),
1576
+ position, None, marker_pos, original_line)
1530
1577
 
1531
1578
  if tag_name_lower in [TAG_RETURN, TAG_RETURNS,
1532
1579
  TAG_RETURN_VALUE, TAG_RETURNS_VALUE]:
@@ -1553,9 +1600,9 @@ class GtkDocCommentBlockParser(object):
1553
1600
  continue
1554
1601
  else:
1555
1602
  if tag_name_lower in comment_block.tags.keys():
1556
- error('multiple "%s:" tags for identifier "%s":\n%s\n%s' %
1557
- (tag_name, comment_block.name, original_line, marker),
1558
- position)
1603
+ error('multiple "%s:" tags for identifier "%s":' %
1604
+ (tag_name, comment_block.name),
1605
+ position, None, marker_pos, original_line)
1559
1606
 
1560
1607
  tag = GtkDocTag(tag_name_lower, position)
1561
1608
 
@@ -1592,8 +1639,12 @@ class GtkDocCommentBlockParser(object):
1592
1639
  if in_part in [PART_IDENTIFIER, PART_DESCRIPTION]:
1593
1640
  if not comment_block.description:
1594
1641
  if in_part == PART_IDENTIFIER:
1595
- self._validate_multiline_annotation_continuation(line, original_line,
1596
- column_offset, position)
1642
+ r = self._parse_annotations(position, column_offset, original_line, line,
1643
+ comment_block.annotations)
1644
+
1645
+ if r.success and r.annotations_changed:
1646
+ comment_block.annotations = r.annotations
1647
+ continue
1597
1648
  if comment_block.description is None:
1598
1649
  comment_block.description = line
1599
1650
  else:
@@ -1601,8 +1652,12 @@ class GtkDocCommentBlockParser(object):
1601
1652
  continue
1602
1653
  elif in_part in [PART_PARAMETERS, PART_TAGS]:
1603
1654
  if not current_part.description:
1604
- self._validate_multiline_annotation_continuation(line, original_line,
1605
- column_offset, position)
1655
+ r = self._parse_fields(position, column_offset, original_line, line,
1656
+ current_part.annotations)
1657
+ if r.success and r.annotations_changed:
1658
+ current_part.annotations = r.annotations
1659
+ current_part.description = r.description
1660
+ continue
1606
1661
  if current_part.description is None:
1607
1662
  current_part.description = line
1608
1663
  else:
@@ -1646,34 +1701,6 @@ class GtkDocCommentBlockParser(object):
1646
1701
  else:
1647
1702
  part.description = part.description.strip()
1648
1703
 
1649
- def _validate_multiline_annotation_continuation(self, line, original_line,
1650
- column_offset, position):
1651
- '''
1652
- Validate annotatable parts' source text ensuring annotations don't span multiple lines.
1653
- For example, the following comment block would result in a warning being emitted for
1654
- the forth line::
1655
-
1656
- /**
1657
- * shiny_function:
1658
- * @array_: (out caller-allocates) (array)
1659
- * (element-type utf8) (transfer full): A beautiful array
1660
- */
1661
-
1662
- :param line: line to validate, stripped from ("``*/``") at start of the line.
1663
- :param original_line: original line (including ("``*/``")) being validated
1664
- :param column_offset: number of characters stripped from `line` when ("``*/``")
1665
- was removed
1666
- :param position: :class:`giscanner.message.Position` of `line` in the source file
1667
- '''
1668
-
1669
- result = self._parse_annotations(position, column_offset, original_line, line)
1670
-
1671
- if result.success and result.annotations:
1672
- marker = ' ' * (result.start_pos + column_offset) + '^'
1673
- error('ignoring invalid multiline annotation continuation:\n%s\n%s' %
1674
- (original_line, marker),
1675
- position)
1676
-
1677
1704
  def _parse_annotation_options_list(self, position, column, line, options):
1678
1705
  '''
1679
1706
  Parse annotation options into a list. For example::
@@ -1696,10 +1723,9 @@ class GtkDocCommentBlockParser(object):
1696
1723
  if options:
1697
1724
  result = options.find('=')
1698
1725
  if result >= 0:
1699
- marker = ' ' * (column + result) + '^'
1700
1726
  warn('invalid annotation options: expected a "list" but '
1701
- 'received "key=value pairs":\n%s\n%s' % (line, marker),
1702
- position)
1727
+ 'received "key=value pairs":',
1728
+ position, None, column + result, line)
1703
1729
  parsed = self._parse_annotation_options_unknown(position, column, line, options)
1704
1730
  else:
1705
1731
  parsed = options.split(' ')
@@ -1793,17 +1819,15 @@ class GtkDocCommentBlockParser(object):
1793
1819
  ann_options = parts[1] if len(parts) == 2 else None
1794
1820
 
1795
1821
  if ann_name == ANN_INOUT_ALT:
1796
- marker = ' ' * (column) + '^'
1797
- warn('"%s" annotation has been deprecated, please use "%s" instead:\n%s\n%s' %
1798
- (ANN_INOUT_ALT, ANN_INOUT, line, marker),
1799
- position)
1822
+ warn('"%s" annotation has been deprecated, please use "%s" instead:' %
1823
+ (ANN_INOUT_ALT, ANN_INOUT),
1824
+ position, None, column, line)
1800
1825
 
1801
1826
  ann_name = ANN_INOUT
1802
1827
  elif ann_name == ANN_ATTRIBUTE:
1803
- marker = ' ' * (column) + '^'
1804
- warn('"%s" annotation has been deprecated, please use "%s" instead:\n%s\n%s' %
1805
- (ANN_ATTRIBUTE, ANN_ATTRIBUTES, line, marker),
1806
- position)
1828
+ warn('"%s" annotation has been deprecated, please use "%s" instead:' %
1829
+ (ANN_ATTRIBUTE, ANN_ATTRIBUTES),
1830
+ position, None, column, line)
1807
1831
 
1808
1832
  ann_name = ANN_ATTRIBUTES
1809
1833
  ann_options = self._parse_annotation_options_list(position, column, line, ann_options)
@@ -1813,10 +1837,8 @@ class GtkDocCommentBlockParser(object):
1813
1837
  elif n_options == 2:
1814
1838
  ann_options = '%s=%s' % (ann_options[0], ann_options[1])
1815
1839
  else:
1816
- marker = ' ' * (column) + '^'
1817
- error('malformed "(attribute)" annotation will be ignored:\n%s\n%s' %
1818
- (line, marker),
1819
- position)
1840
+ error('malformed "(attribute)" annotation will be ignored:',
1841
+ position, None, column, line)
1820
1842
  return None, None
1821
1843
 
1822
1844
  column += len(ann_name) + 2
@@ -1831,7 +1853,8 @@ class GtkDocCommentBlockParser(object):
1831
1853
 
1832
1854
  return ann_name, ann_options
1833
1855
 
1834
- def _parse_annotations(self, position, column, line, fields, parse_options=True):
1856
+ def _parse_annotations(self, position, column, line, fields,
1857
+ annotations=None, parse_options=True):
1835
1858
  '''
1836
1859
  Parse annotations into a :class:`GtkDocAnnotations` object.
1837
1860
 
@@ -1839,6 +1862,7 @@ class GtkDocCommentBlockParser(object):
1839
1862
  :param column: start column of the `annotations` in the source file
1840
1863
  :param line: complete source line
1841
1864
  :param fields: string containing the fields to parse
1865
+ :param annotations: a :class:`GtkDocAnnotations` object
1842
1866
  :param parse_options: whether options will be parsed into a :class:`GtkDocAnnotations`
1843
1867
  object or into a :class:`list`
1844
1868
  :returns: if `parse_options` evaluates to True a :class:`GtkDocAnnotations` object,
@@ -1847,10 +1871,15 @@ class GtkDocCommentBlockParser(object):
1847
1871
  '''
1848
1872
 
1849
1873
  if parse_options:
1850
- parsed_annotations = GtkDocAnnotations(position)
1874
+ if annotations is None:
1875
+ parsed_annotations = GtkDocAnnotations(position)
1876
+ else:
1877
+ parsed_annotations = annotations.copy()
1851
1878
  else:
1852
1879
  parsed_annotations = []
1853
1880
 
1881
+ parsed_annotations_changed = False
1882
+
1854
1883
  i = 0
1855
1884
  parens_level = 0
1856
1885
  prev_char = ''
@@ -1868,28 +1897,22 @@ class GtkDocCommentBlockParser(object):
1868
1897
  start_pos = i
1869
1898
 
1870
1899
  if prev_char == ANN_LPAR:
1871
- marker = ' ' * (column + i) + '^'
1872
- error('unexpected parentheses, annotations will be ignored:\n%s\n%s' %
1873
- (line, marker),
1874
- position)
1875
- return _ParseAnnotationsResult(False, None, None, None)
1900
+ error('unexpected parentheses, annotations will be ignored:',
1901
+ position, None, column + i, line)
1902
+ return _ParseAnnotationsResult(False, None, None, None, None)
1876
1903
  elif parens_level > 1:
1877
1904
  char_buffer.append(cur_char)
1878
1905
  elif cur_char == ANN_RPAR:
1879
1906
  parens_level -= 1
1880
1907
 
1881
1908
  if prev_char == ANN_LPAR:
1882
- marker = ' ' * (column + i) + '^'
1883
- error('unexpected parentheses, annotations will be ignored:\n%s\n%s' %
1884
- (line, marker),
1885
- position)
1886
- return _ParseAnnotationsResult(False, None, None, None)
1909
+ error('unexpected parentheses, annotations will be ignored:',
1910
+ position, None, column + i, line)
1911
+ return _ParseAnnotationsResult(False, None, None, None, None)
1887
1912
  elif parens_level < 0:
1888
- marker = ' ' * (column + i) + '^'
1889
- error('unbalanced parentheses, annotations will be ignored:\n%s\n%s' %
1890
- (line, marker),
1891
- position)
1892
- return _ParseAnnotationsResult(False, None, None, None)
1913
+ error('unbalanced parentheses, annotations will be ignored:',
1914
+ position, None, column + i, line)
1915
+ return _ParseAnnotationsResult(False, None, None, None, None)
1893
1916
  elif parens_level == 0:
1894
1917
  end_pos = i + 1
1895
1918
 
@@ -1900,12 +1923,13 @@ class GtkDocCommentBlockParser(object):
1900
1923
  ''.join(char_buffer).strip())
1901
1924
  if name is not None:
1902
1925
  if name in parsed_annotations:
1903
- marker = ' ' * (column + i) + '^'
1904
- error('multiple "%s" annotations:\n%s\n%s' %
1905
- (name, line, marker), position)
1926
+ error('multiple "%s" annotations:' % (name, ),
1927
+ position, None, column + i, line)
1906
1928
  parsed_annotations[name] = options
1929
+ parsed_annotations_changed = True
1907
1930
  else:
1908
1931
  parsed_annotations.append(''.join(char_buffer).strip())
1932
+ parsed_annotations_changed = True
1909
1933
 
1910
1934
  char_buffer = []
1911
1935
  else:
@@ -1922,21 +1946,20 @@ class GtkDocCommentBlockParser(object):
1922
1946
  prev_char = cur_char
1923
1947
 
1924
1948
  if parens_level > 0:
1925
- marker = ' ' * (column + i) + '^'
1926
- error('unbalanced parentheses, annotations will be ignored:\n%s\n%s' %
1927
- (line, marker),
1928
- position)
1929
- return _ParseAnnotationsResult(False, None, None, None)
1949
+ error('unbalanced parentheses, annotations will be ignored:',
1950
+ position, None, column + i, line)
1951
+ return _ParseAnnotationsResult(False, None, None, None, None)
1930
1952
  else:
1931
- return _ParseAnnotationsResult(True, parsed_annotations, start_pos, end_pos)
1953
+ return _ParseAnnotationsResult(True, parsed_annotations, parsed_annotations_changed,
1954
+ start_pos, end_pos)
1932
1955
 
1933
- def _parse_fields(self, position, column, line, fields, parse_options=True,
1934
- validate_description_field=True):
1956
+ def _parse_fields(self, position, column, line, fields, annotations=None,
1957
+ parse_options=True, validate_description_field=True):
1935
1958
  '''
1936
1959
  Parse annotations out of field data. For example::
1937
1960
 
1938
1961
  ┌──────────────────────────────────────────────────────────────┐
1939
- │ '(skip): description of some parameter │ ─▷ source
1962
+ │ '(skip): description of some parameter' │ ─▷ source
1940
1963
  ├──────────────────────────────────────────────────────────────┤
1941
1964
  │ ({'skip': []}, 'description of some parameter') │ ◁─ annotations and
1942
1965
  └──────────────────────────────────────────────────────────────┘ remaining fields
@@ -1953,7 +1976,8 @@ class GtkDocCommentBlockParser(object):
1953
1976
  :const:`None` and a string holding the remaining fields
1954
1977
  '''
1955
1978
  description_field = ''
1956
- result = self._parse_annotations(position, column, line, fields, parse_options)
1979
+ result = self._parse_annotations(position, column, line, fields,
1980
+ annotations, parse_options)
1957
1981
  if result.success:
1958
1982
  description_field = fields[result.end_pos:].strip()
1959
1983
 
@@ -1962,13 +1986,12 @@ class GtkDocCommentBlockParser(object):
1962
1986
  description_field = description_field[1:]
1963
1987
  else:
1964
1988
  if result.end_pos > 0:
1965
- marker_position = column + result.end_pos
1966
- marker = ' ' * marker_position + '^'
1967
- warn('missing ":" at column %s:\n%s\n%s' %
1968
- (marker_position + 1, line, marker),
1969
- position)
1989
+ marker_pos = column + result.end_pos
1990
+ warn('missing ":" at column %s:' % (marker_pos + 1, ),
1991
+ position, None, marker_pos, line)
1970
1992
 
1971
- return _ParseFieldsResult(result.success, result.annotations, description_field)
1993
+ return _ParseFieldsResult(result.success, result.annotations, result.annotations_changed,
1994
+ description_field)
1972
1995
 
1973
1996
 
1974
1997
  class GtkDocCommentBlockWriter(object):