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