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
@@ -20,6 +20,7 @@
|
|
20
20
|
|
21
21
|
import os
|
22
22
|
import sys
|
23
|
+
import subprocess
|
23
24
|
|
24
25
|
from . import ast
|
25
26
|
from . import message
|
@@ -49,7 +50,7 @@ if os.name != 'nt':
|
|
49
50
|
class Transformer(object):
|
50
51
|
namespace = property(lambda self: self._namespace)
|
51
52
|
|
52
|
-
def __init__(self, namespace, accept_unprefixed=False):
|
53
|
+
def __init__(self, namespace, accept_unprefixed=False, identifier_filter_cmd=''):
|
53
54
|
self._cachestore = CacheStore()
|
54
55
|
self._accept_unprefixed = accept_unprefixed
|
55
56
|
self._namespace = namespace
|
@@ -58,6 +59,12 @@ class Transformer(object):
|
|
58
59
|
self._parsed_includes = {} # <string namespace -> Namespace>
|
59
60
|
self._includepaths = []
|
60
61
|
self._passthrough_mode = False
|
62
|
+
self._identifier_filter_cmd = identifier_filter_cmd
|
63
|
+
|
64
|
+
# Cache a list of struct/unions in C's "tag namespace". This helps
|
65
|
+
# manage various orderings of typedefs and structs. See:
|
66
|
+
# https://bugzilla.gnome.org/show_bug.cgi?id=581525
|
67
|
+
self._tag_ns = {}
|
61
68
|
|
62
69
|
def get_pkgconfig_packages(self):
|
63
70
|
return self._pkg_config_packages
|
@@ -76,6 +83,12 @@ class Transformer(object):
|
|
76
83
|
# modules will just depend on that.
|
77
84
|
if isinstance(original, ast.Constant) and isinstance(node, ast.Constant):
|
78
85
|
pass
|
86
|
+
elif original is node:
|
87
|
+
# Ignore attempts to add the same node to the namespace. This can
|
88
|
+
# happen when parsing typedefs and structs in particular orderings:
|
89
|
+
# typedef struct _Foo Foo;
|
90
|
+
# struct _Foo {...};
|
91
|
+
pass
|
79
92
|
elif original:
|
80
93
|
positions = set()
|
81
94
|
positions.update(original.file_positions)
|
@@ -91,28 +104,30 @@ class Transformer(object):
|
|
91
104
|
# https://bugzilla.gnome.org/show_bug.cgi?id=550616
|
92
105
|
if symbol.ident in ['gst_g_error_get_type']:
|
93
106
|
continue
|
94
|
-
node = self._traverse_one(symbol)
|
95
|
-
if node:
|
96
|
-
self._append_new_node(node)
|
97
107
|
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
108
|
+
try:
|
109
|
+
node = self._traverse_one(symbol)
|
110
|
+
except TransformerException as e:
|
111
|
+
message.warn_symbol(symbol, e)
|
112
|
+
continue
|
113
|
+
|
114
|
+
if node and node.name:
|
115
|
+
self._append_new_node(node)
|
116
|
+
if isinstance(node, ast.Compound) and node.tag_name and \
|
117
|
+
node.tag_name not in self._tag_ns:
|
118
|
+
self._tag_ns[node.tag_name] = node
|
119
|
+
|
120
|
+
# Run through the tag namespace looking for structs that have not been
|
121
|
+
# promoted into the main namespace. In this case we simply promote them
|
122
|
+
# with their struct tag.
|
123
|
+
for tag_name, struct in self._tag_ns.iteritems():
|
124
|
+
if not struct.name:
|
125
|
+
try:
|
126
|
+
name = self.strip_identifier(tag_name)
|
127
|
+
struct.name = name
|
128
|
+
self._append_new_node(struct)
|
129
|
+
except TransformerException as e:
|
130
|
+
message.warn_node(node, e)
|
116
131
|
|
117
132
|
def set_include_paths(self, paths):
|
118
133
|
self._includepaths = list(paths)
|
@@ -280,6 +295,17 @@ raise ValueError."""
|
|
280
295
|
return matches[-1]
|
281
296
|
|
282
297
|
def strip_identifier(self, ident):
|
298
|
+
if self._identifier_filter_cmd:
|
299
|
+
proc = subprocess.Popen(self._identifier_filter_cmd,
|
300
|
+
stdin=subprocess.PIPE,
|
301
|
+
stdout=subprocess.PIPE,
|
302
|
+
stderr=subprocess.PIPE,
|
303
|
+
shell=True)
|
304
|
+
ident, err = proc.communicate(ident)
|
305
|
+
if proc.returncode:
|
306
|
+
raise ValueError('filter: "%s" exited: %d with error: %s' %
|
307
|
+
(self._identifier_filter_cmd, proc.returncode, err))
|
308
|
+
|
283
309
|
hidden = ident.startswith('_')
|
284
310
|
if hidden:
|
285
311
|
ident = ident[1:]
|
@@ -294,8 +320,7 @@ raise ValueError."""
|
|
294
320
|
return name
|
295
321
|
(ns, name) = matches[-1]
|
296
322
|
raise TransformerException(
|
297
|
-
"Skipping foreign identifier %r from namespace %s" % (
|
298
|
-
ident, ns.name, ))
|
323
|
+
"Skipping foreign identifier %r from namespace %s" % (ident, ns.name, ))
|
299
324
|
return None
|
300
325
|
|
301
326
|
def _strip_symbol(self, symbol):
|
@@ -324,13 +349,13 @@ raise ValueError."""
|
|
324
349
|
elif stype == CSYMBOL_TYPE_TYPEDEF:
|
325
350
|
return self._create_typedef(symbol)
|
326
351
|
elif stype == CSYMBOL_TYPE_STRUCT:
|
327
|
-
return self.
|
352
|
+
return self._create_tag_ns_compound(ast.Record, symbol)
|
328
353
|
elif stype == CSYMBOL_TYPE_ENUM:
|
329
354
|
return self._create_enum(symbol)
|
330
355
|
elif stype == CSYMBOL_TYPE_MEMBER:
|
331
356
|
return self._create_member(symbol, parent_symbol)
|
332
357
|
elif stype == CSYMBOL_TYPE_UNION:
|
333
|
-
return self.
|
358
|
+
return self._create_tag_ns_compound(ast.Union, symbol)
|
334
359
|
elif stype == CSYMBOL_TYPE_CONST:
|
335
360
|
return self._create_const(symbol)
|
336
361
|
# Ignore variable declarations in the header
|
@@ -377,21 +402,13 @@ raise ValueError."""
|
|
377
402
|
# Ok, the enum members don't have a consistent prefix
|
378
403
|
# among them, so let's just remove the global namespace
|
379
404
|
# prefix.
|
380
|
-
|
381
|
-
name = self._strip_symbol(child)
|
382
|
-
except TransformerException as e:
|
383
|
-
message.warn_symbol(symbol, e)
|
384
|
-
return None
|
405
|
+
name = self._strip_symbol(child)
|
385
406
|
members.append(ast.Member(name.lower(),
|
386
407
|
child.const_int,
|
387
408
|
child.ident,
|
388
409
|
None))
|
389
410
|
|
390
|
-
|
391
|
-
enum_name = self.strip_identifier(symbol.ident)
|
392
|
-
except TransformerException as e:
|
393
|
-
message.warn_symbol(symbol, e)
|
394
|
-
return None
|
411
|
+
enum_name = self.strip_identifier(symbol.ident)
|
395
412
|
if symbol.base_type.is_bitfield:
|
396
413
|
klass = ast.Bitfield
|
397
414
|
else:
|
@@ -406,11 +423,7 @@ raise ValueError."""
|
|
406
423
|
return None
|
407
424
|
parameters = list(self._create_parameters(symbol, symbol.base_type))
|
408
425
|
return_ = self._create_return(symbol.base_type.base_type)
|
409
|
-
|
410
|
-
name = self._strip_symbol(symbol)
|
411
|
-
except TransformerException as e:
|
412
|
-
message.warn_symbol(symbol, e)
|
413
|
-
return None
|
426
|
+
name = self._strip_symbol(symbol)
|
414
427
|
func = ast.Function(name, return_, parameters, False, symbol.ident)
|
415
428
|
func.add_symbol_reference(symbol)
|
416
429
|
return func
|
@@ -506,9 +519,9 @@ raise ValueError."""
|
|
506
519
|
and symbol.base_type.base_type.type == CTYPE_FUNCTION):
|
507
520
|
node = self._create_callback(symbol, member=True)
|
508
521
|
elif source_type.type == CTYPE_STRUCT and source_type.name is None:
|
509
|
-
node = self.
|
522
|
+
node = self._create_member_compound(ast.Record, symbol)
|
510
523
|
elif source_type.type == CTYPE_UNION and source_type.name is None:
|
511
|
-
node = self.
|
524
|
+
node = self._create_member_compound(ast.Union, symbol)
|
512
525
|
else:
|
513
526
|
# Special handling for fields; we don't have annotations on them
|
514
527
|
# to apply later, yet.
|
@@ -561,22 +574,18 @@ raise ValueError."""
|
|
561
574
|
if (ctype == CTYPE_POINTER and symbol.base_type.base_type.type == CTYPE_FUNCTION):
|
562
575
|
node = self._create_typedef_callback(symbol)
|
563
576
|
elif (ctype == CTYPE_POINTER and symbol.base_type.base_type.type == CTYPE_STRUCT):
|
564
|
-
node = self.
|
577
|
+
node = self._create_typedef_compound(ast.Record, symbol, disguised=True)
|
565
578
|
elif ctype == CTYPE_STRUCT:
|
566
|
-
node = self.
|
579
|
+
node = self._create_typedef_compound(ast.Record, symbol)
|
567
580
|
elif ctype == CTYPE_UNION:
|
568
|
-
node = self.
|
581
|
+
node = self._create_typedef_compound(ast.Union, symbol)
|
569
582
|
elif ctype == CTYPE_ENUM:
|
570
583
|
return self._create_enum(symbol)
|
571
584
|
elif ctype in (CTYPE_TYPEDEF,
|
572
585
|
CTYPE_POINTER,
|
573
586
|
CTYPE_BASIC_TYPE,
|
574
587
|
CTYPE_VOID):
|
575
|
-
|
576
|
-
name = self.strip_identifier(symbol.ident)
|
577
|
-
except TransformerException as e:
|
578
|
-
message.warn(e)
|
579
|
-
return None
|
588
|
+
name = self.strip_identifier(symbol.ident)
|
580
589
|
if symbol.base_type.name:
|
581
590
|
complete_ctype = self._create_complete_source_type(symbol.base_type)
|
582
591
|
target = self.create_type_from_ctype_string(symbol.base_type.name,
|
@@ -616,20 +625,6 @@ raise ValueError."""
|
|
616
625
|
|
617
626
|
return canonical
|
618
627
|
|
619
|
-
def parse_ctype(self, ctype, is_member=False):
|
620
|
-
canonical = self._canonicalize_ctype(ctype)
|
621
|
-
|
622
|
-
# Remove all pointers - we require standard calling
|
623
|
-
# conventions. For example, an 'int' is always passed by
|
624
|
-
# value (unless it's out or inout).
|
625
|
-
derefed_typename = canonical.replace('*', '')
|
626
|
-
|
627
|
-
# Preserve "pointerness" of struct/union members
|
628
|
-
if (is_member and canonical.endswith('*') and derefed_typename in ast.basic_type_names):
|
629
|
-
return 'gpointer'
|
630
|
-
else:
|
631
|
-
return derefed_typename
|
632
|
-
|
633
628
|
def _create_type_from_base(self, source_type, is_parameter=False, is_return=False):
|
634
629
|
ctype = self._create_source_type(source_type)
|
635
630
|
complete_ctype = self._create_complete_source_type(source_type)
|
@@ -688,18 +683,18 @@ raise ValueError."""
|
|
688
683
|
|
689
684
|
def _create_parameter(self, parent_symbol, index, symbol):
|
690
685
|
if symbol.type == CSYMBOL_TYPE_ELLIPSIS:
|
691
|
-
|
686
|
+
return ast.Parameter('...', ast.Varargs())
|
692
687
|
else:
|
693
688
|
ptype = self._create_type_from_base(symbol.base_type, is_parameter=True)
|
694
689
|
|
695
|
-
|
696
|
-
|
697
|
-
|
698
|
-
|
699
|
-
|
700
|
-
|
690
|
+
if symbol.ident is None:
|
691
|
+
if symbol.base_type and symbol.base_type.type != CTYPE_VOID:
|
692
|
+
message.warn_symbol(parent_symbol, "missing parameter name; undocumentable")
|
693
|
+
ident = 'arg%d' % (index, )
|
694
|
+
else:
|
695
|
+
ident = symbol.ident
|
701
696
|
|
702
|
-
|
697
|
+
return ast.Parameter(ident, ptype)
|
703
698
|
|
704
699
|
def _create_return(self, source_type):
|
705
700
|
typeval = self._create_type_from_base(source_type, is_return=True)
|
@@ -713,11 +708,7 @@ raise ValueError."""
|
|
713
708
|
# http://bugzilla.gnome.org/show_bug.cgi?id=572790
|
714
709
|
if (symbol.source_filename is None or not symbol.source_filename.endswith('.h')):
|
715
710
|
return None
|
716
|
-
|
717
|
-
name = self._strip_symbol(symbol)
|
718
|
-
except TransformerException as e:
|
719
|
-
message.warn_symbol(symbol, e)
|
720
|
-
return None
|
711
|
+
name = self._strip_symbol(symbol)
|
721
712
|
if symbol.const_string is not None:
|
722
713
|
typeval = ast.TYPE_STRING
|
723
714
|
value = unicode(symbol.const_string, 'utf-8')
|
@@ -743,6 +734,9 @@ raise ValueError."""
|
|
743
734
|
value = str(symbol.const_int % 2 ** 16)
|
744
735
|
else:
|
745
736
|
value = str(symbol.const_int)
|
737
|
+
elif symbol.const_boolean is not None:
|
738
|
+
typeval = ast.TYPE_BOOLEAN
|
739
|
+
value = "true" if symbol.const_boolean else "false"
|
746
740
|
elif symbol.const_double is not None:
|
747
741
|
typeval = ast.TYPE_DOUBLE
|
748
742
|
value = '%f' % (symbol.const_double, )
|
@@ -754,35 +748,88 @@ raise ValueError."""
|
|
754
748
|
const.add_symbol_reference(symbol)
|
755
749
|
return const
|
756
750
|
|
757
|
-
def
|
758
|
-
|
759
|
-
|
760
|
-
|
761
|
-
|
762
|
-
|
763
|
-
|
764
|
-
|
765
|
-
struct.
|
766
|
-
self.
|
767
|
-
|
751
|
+
def _create_typedef_compound(self, compound_class, symbol, disguised=False):
|
752
|
+
name = self.strip_identifier(symbol.ident)
|
753
|
+
assert symbol.base_type
|
754
|
+
if symbol.base_type.name:
|
755
|
+
tag_name = symbol.base_type.name
|
756
|
+
else:
|
757
|
+
tag_name = None
|
758
|
+
|
759
|
+
# If the struct already exists in the tag namespace, use it.
|
760
|
+
if tag_name in self._tag_ns:
|
761
|
+
compound = self._tag_ns[tag_name]
|
762
|
+
if compound.name:
|
763
|
+
# If the struct name is set it means the struct has already been
|
764
|
+
# promoted from the tag namespace to the main namespace by a
|
765
|
+
# prior typedef struct. If we get here it means this is another
|
766
|
+
# typedef of that struct. Instead of creating an alias to the
|
767
|
+
# primary typedef that has been promoted, we create a new Record
|
768
|
+
# with shared fields. This handles the case where we want to
|
769
|
+
# give structs like GInitiallyUnowned its own Record:
|
770
|
+
# typedef struct _GObject GObject;
|
771
|
+
# typedef struct _GObject GInitiallyUnowned;
|
772
|
+
# See: http://bugzilla.gnome.org/show_bug.cgi?id=569408
|
773
|
+
new_compound = compound_class(name, symbol.ident, tag_name=tag_name)
|
774
|
+
new_compound.fields = compound.fields
|
775
|
+
new_compound.add_symbol_reference(symbol)
|
776
|
+
return new_compound
|
777
|
+
else:
|
778
|
+
# If the struct does not have its name set, it exists only in
|
779
|
+
# the tag namespace. Set it here and return it which will
|
780
|
+
# promote it to the main namespace. Essentially the first
|
781
|
+
# typedef for a struct clobbers its name and ctype which is what
|
782
|
+
# will be visible to GI.
|
783
|
+
compound.name = name
|
784
|
+
compound.ctype = symbol.ident
|
785
|
+
else:
|
786
|
+
# Create a new struct with a typedef name and tag name when available.
|
787
|
+
# Structs with a typedef name are promoted into the main namespace
|
788
|
+
# by it being returned to the "parse" function and are also added to
|
789
|
+
# the tag namespace if it has a tag_name set.
|
790
|
+
compound = compound_class(name, symbol.ident, disguised=disguised, tag_name=tag_name)
|
791
|
+
if tag_name:
|
792
|
+
# Force the struct as disguised for now since we do not yet know
|
793
|
+
# if it has fields that will be parsed. Note that this is using
|
794
|
+
# an erroneous definition of disguised and we should eventually
|
795
|
+
# only look at the field count when needed.
|
796
|
+
compound.disguised = True
|
797
|
+
else:
|
798
|
+
# Case where we have an anonymous struct which is typedef'd:
|
799
|
+
# typedef struct {...} Struct;
|
800
|
+
# we need to parse the fields because we never get a struct
|
801
|
+
# in the tag namespace which is normally where fields are parsed.
|
802
|
+
self._parse_fields(symbol, compound)
|
768
803
|
|
769
|
-
|
770
|
-
|
771
|
-
|
772
|
-
|
773
|
-
|
774
|
-
|
775
|
-
|
776
|
-
|
777
|
-
|
778
|
-
|
779
|
-
|
804
|
+
compound.add_symbol_reference(symbol)
|
805
|
+
return compound
|
806
|
+
|
807
|
+
def _create_tag_ns_compound(self, compound_class, symbol):
|
808
|
+
# Get or create a struct from C's tag namespace
|
809
|
+
if symbol.ident in self._tag_ns:
|
810
|
+
compound = self._tag_ns[symbol.ident]
|
811
|
+
else:
|
812
|
+
compound = compound_class(None, symbol.ident, tag_name=symbol.ident)
|
813
|
+
|
814
|
+
# Make sure disguised is False as we are now about to parse the
|
815
|
+
# fields of the real struct.
|
816
|
+
compound.disguised = False
|
817
|
+
# Fields may need to be parsed in either of the above cases because the
|
818
|
+
# Record can be created with a typedef prior to the struct definition.
|
819
|
+
self._parse_fields(symbol, compound)
|
820
|
+
compound.add_symbol_reference(symbol)
|
821
|
+
return compound
|
822
|
+
|
823
|
+
def _create_member_compound(self, compound_class, symbol):
|
824
|
+
compound = compound_class(symbol.ident, symbol.ident)
|
825
|
+
self._parse_fields(symbol, compound)
|
826
|
+
compound.add_symbol_reference(symbol)
|
827
|
+
return compound
|
780
828
|
|
781
829
|
def _create_typedef_callback(self, symbol):
|
782
830
|
callback = self._create_callback(symbol)
|
783
831
|
if not callback:
|
784
832
|
return None
|
785
|
-
self._typedefs_ns[callback.name] = callback
|
786
833
|
return callback
|
787
834
|
|
788
835
|
def _parse_fields(self, symbol, compound):
|
@@ -797,41 +844,6 @@ raise ValueError."""
|
|
797
844
|
anonymous_node=child_node)
|
798
845
|
compound.fields.append(field)
|
799
846
|
|
800
|
-
def _create_compound(self, klass, symbol, anonymous):
|
801
|
-
if symbol.ident is None:
|
802
|
-
# the compound is an anonymous member of another union or a struct
|
803
|
-
assert anonymous
|
804
|
-
compound = klass(None, None)
|
805
|
-
else:
|
806
|
-
compound = self._typedefs_ns.get(symbol.ident, None)
|
807
|
-
|
808
|
-
if compound is None:
|
809
|
-
# This is a bit of a hack; really we should try
|
810
|
-
# to resolve through the typedefs to find the real
|
811
|
-
# name
|
812
|
-
if symbol.ident.startswith('_'):
|
813
|
-
compound = self._typedefs_ns.get(symbol.ident[1:], None)
|
814
|
-
if compound is None:
|
815
|
-
if anonymous:
|
816
|
-
name = symbol.ident
|
817
|
-
else:
|
818
|
-
try:
|
819
|
-
name = self.strip_identifier(symbol.ident)
|
820
|
-
except TransformerException as e:
|
821
|
-
message.warn(e)
|
822
|
-
return None
|
823
|
-
compound = klass(name, symbol.ident)
|
824
|
-
|
825
|
-
self._parse_fields(symbol, compound)
|
826
|
-
compound.add_symbol_reference(symbol)
|
827
|
-
return compound
|
828
|
-
|
829
|
-
def _create_struct(self, symbol, anonymous=False):
|
830
|
-
return self._create_compound(ast.Record, symbol, anonymous)
|
831
|
-
|
832
|
-
def _create_union(self, symbol, anonymous=False):
|
833
|
-
return self._create_compound(ast.Union, symbol, anonymous)
|
834
|
-
|
835
847
|
def _create_callback(self, symbol, member=False):
|
836
848
|
parameters = list(self._create_parameters(symbol, symbol.base_type.base_type))
|
837
849
|
retval = self._create_return(symbol.base_type.base_type.base_type)
|
@@ -844,17 +856,9 @@ raise ValueError."""
|
|
844
856
|
if member:
|
845
857
|
name = symbol.ident
|
846
858
|
elif symbol.ident.find('_') > 0:
|
847
|
-
|
848
|
-
name = self._strip_symbol(symbol)
|
849
|
-
except TransformerException as e:
|
850
|
-
message.warn_symbol(symbol, e)
|
851
|
-
return None
|
859
|
+
name = self._strip_symbol(symbol)
|
852
860
|
else:
|
853
|
-
|
854
|
-
name = self.strip_identifier(symbol.ident)
|
855
|
-
except TransformerException as e:
|
856
|
-
message.warn(e)
|
857
|
-
return None
|
861
|
+
name = self.strip_identifier(symbol.ident)
|
858
862
|
callback = ast.Callback(name, retval, parameters, False,
|
859
863
|
ctype=symbol.ident)
|
860
864
|
callback.add_symbol_reference(symbol)
|
@@ -953,29 +957,6 @@ Note that type resolution may not succeed."""
|
|
953
957
|
|
954
958
|
return typeval.resolved
|
955
959
|
|
956
|
-
def _typepair_to_str(self, item):
|
957
|
-
nsname, item = item
|
958
|
-
if nsname is None:
|
959
|
-
return item.name
|
960
|
-
return '%s.%s' % (nsname, item.name)
|
961
|
-
|
962
|
-
def gtypename_to_giname(self, gtname, names):
|
963
|
-
resolved = names.type_names.get(gtname)
|
964
|
-
if resolved:
|
965
|
-
return self._typepair_to_str(resolved)
|
966
|
-
resolved = self._names.type_names.get(gtname)
|
967
|
-
if resolved:
|
968
|
-
return self._typepair_to_str(resolved)
|
969
|
-
raise KeyError("Failed to resolve GType name: %r" % (gtname, ))
|
970
|
-
|
971
|
-
def ctype_of(self, obj):
|
972
|
-
if hasattr(obj, 'ctype'):
|
973
|
-
return obj.ctype
|
974
|
-
elif hasattr(obj, 'symbol'):
|
975
|
-
return obj.symbol
|
976
|
-
else:
|
977
|
-
return None
|
978
|
-
|
979
960
|
def resolve_aliases(self, typenode):
|
980
961
|
"""Removes all aliases from typenode, returns first non-alias
|
981
962
|
in the typenode alias chain. Returns typenode argument if it
|
Binary file
|
Binary file
|
@@ -21,6 +21,7 @@
|
|
21
21
|
import re
|
22
22
|
import os
|
23
23
|
import subprocess
|
24
|
+
import platform
|
24
25
|
|
25
26
|
|
26
27
|
_debugflags = None
|
@@ -88,6 +89,20 @@ def _extract_dlname_field(la_file):
|
|
88
89
|
return None
|
89
90
|
|
90
91
|
|
92
|
+
_libtool_libdir_pat = re.compile("libdir='([^']+)'")
|
93
|
+
|
94
|
+
|
95
|
+
def _extract_libdir_field(la_file):
|
96
|
+
f = open(la_file)
|
97
|
+
data = f.read()
|
98
|
+
f.close()
|
99
|
+
m = _libtool_libdir_pat.search(data)
|
100
|
+
if m:
|
101
|
+
return m.groups()[0]
|
102
|
+
else:
|
103
|
+
return None
|
104
|
+
|
105
|
+
|
91
106
|
# Returns the name that we would pass to dlopen() the library
|
92
107
|
# corresponding to this .la file
|
93
108
|
def extract_libtool_shlib(la_file):
|
@@ -95,6 +110,14 @@ def extract_libtool_shlib(la_file):
|
|
95
110
|
if dlname is None:
|
96
111
|
return None
|
97
112
|
|
113
|
+
# Darwin uses absolute paths where possible; since the libtool files never
|
114
|
+
# contain absolute paths, use the libdir field
|
115
|
+
if platform.system() == 'Darwin':
|
116
|
+
dlbasename = os.path.basename(dlname)
|
117
|
+
libdir = _extract_libdir_field(la_file)
|
118
|
+
if libdir is None:
|
119
|
+
return dlbasename
|
120
|
+
return libdir + '/' + dlbasename
|
98
121
|
# From the comments in extract_libtool(), older libtools had
|
99
122
|
# a path rather than the raw dlname
|
100
123
|
return os.path.basename(dlname)
|
@@ -109,7 +132,7 @@ def extract_libtool(la_file):
|
|
109
132
|
# FIXME: This hackish, but I'm not sure how to do this
|
110
133
|
# in a way which is compatible with both libtool 2.2
|
111
134
|
# and pre-2.2. Johan 2008-10-21
|
112
|
-
libname = libname.replace('.libs/.libs', '.libs')
|
135
|
+
libname = libname.replace('.libs/.libs', '.libs').replace('.libs\\.libs', '.libs')
|
113
136
|
return libname
|
114
137
|
|
115
138
|
|
@@ -127,14 +150,18 @@ def get_libtool_command(options):
|
|
127
150
|
# we simply split().
|
128
151
|
return libtool_path.split(' ')
|
129
152
|
|
153
|
+
libtool_cmd = 'libtool'
|
154
|
+
if platform.system() == 'Darwin':
|
155
|
+
# libtool on OS X is a completely different program written by Apple
|
156
|
+
libtool_cmd = 'glibtool'
|
130
157
|
try:
|
131
|
-
subprocess.check_call([
|
158
|
+
subprocess.check_call([libtool_cmd, '--version'],
|
132
159
|
stdout=open(os.devnull))
|
133
160
|
except (subprocess.CalledProcessError, OSError):
|
134
161
|
# If libtool's not installed, assume we don't need it
|
135
162
|
return None
|
136
163
|
|
137
|
-
return [
|
164
|
+
return [libtool_cmd]
|
138
165
|
|
139
166
|
|
140
167
|
def files_are_identical(path1, path2):
|
@@ -148,3 +175,37 @@ def files_are_identical(path1, path2):
|
|
148
175
|
f1.close()
|
149
176
|
f2.close()
|
150
177
|
return buf1 == buf2
|
178
|
+
|
179
|
+
|
180
|
+
def cflag_real_include_path(cflag):
|
181
|
+
if not cflag.startswith("-I"):
|
182
|
+
return cflag
|
183
|
+
|
184
|
+
return "-I" + os.path.realpath(cflag[2:])
|
185
|
+
|
186
|
+
|
187
|
+
def which(program):
|
188
|
+
def is_exe(fpath):
|
189
|
+
return os.path.isfile(fpath) and os.access(fpath, os.X_OK)
|
190
|
+
|
191
|
+
def is_nt_exe(fpath):
|
192
|
+
return not fpath.lower().endswith('.exe') and \
|
193
|
+
os.path.isfile(fpath + '.exe') and \
|
194
|
+
os.access(fpath + '.exe', os.X_OK)
|
195
|
+
|
196
|
+
fpath, fname = os.path.split(program)
|
197
|
+
if fpath:
|
198
|
+
if is_exe(program):
|
199
|
+
return program
|
200
|
+
if os.name == 'nt' and is_nt_exe(program):
|
201
|
+
return program + '.exe'
|
202
|
+
else:
|
203
|
+
for path in os.environ["PATH"].split(os.pathsep):
|
204
|
+
path = path.strip('"')
|
205
|
+
exe_file = os.path.join(path, program)
|
206
|
+
if is_exe(exe_file):
|
207
|
+
return exe_file
|
208
|
+
if os.name == 'nt' and is_nt_exe(exe_file):
|
209
|
+
return exe_file + '.exe'
|
210
|
+
|
211
|
+
return None
|
Binary file
|
Binary file
|
@@ -24,48 +24,16 @@ import os
|
|
24
24
|
|
25
25
|
from contextlib import contextmanager
|
26
26
|
from cStringIO import StringIO
|
27
|
-
from xml.sax.saxutils import escape
|
27
|
+
from xml.sax.saxutils import escape
|
28
28
|
|
29
29
|
from .libtoolimporter import LibtoolImporter
|
30
30
|
|
31
31
|
|
32
|
-
|
33
|
-
if
|
34
|
-
|
35
|
-
attr_length = 0
|
36
|
-
for attr, value in attributes:
|
37
|
-
# FIXME: actually, if we have attributes with None as value this
|
38
|
-
# should be considered a bug and raise an error. We are just
|
39
|
-
# ignoring them here while we fix GIRParser to create the right
|
40
|
-
# ast with the correct attributes.
|
41
|
-
if value is None:
|
42
|
-
continue
|
43
|
-
attr_length += 2 + len(attr) + len(quoteattr(value))
|
44
|
-
return attr_length + indent + self_indent
|
45
|
-
|
46
|
-
|
47
|
-
def collect_attributes(tag_name, attributes, self_indent, self_indent_char, indent=-1):
|
48
|
-
if not attributes:
|
49
|
-
return ''
|
50
|
-
if _calc_attrs_length(attributes, indent, self_indent) > 79:
|
51
|
-
indent_len = self_indent + len(tag_name) + 1
|
32
|
+
with LibtoolImporter(None, None):
|
33
|
+
if 'UNINSTALLED_INTROSPECTION_SRCDIR' in os.environ:
|
34
|
+
from _giscanner import collect_attributes
|
52
35
|
else:
|
53
|
-
|
54
|
-
first = True
|
55
|
-
attr_value = ''
|
56
|
-
for attr, value in attributes:
|
57
|
-
# FIXME: actually, if we have attributes with None as value this
|
58
|
-
# should be considered a bug and raise an error. We are just
|
59
|
-
# ignoring them here while we fix GIRParser to create the right
|
60
|
-
# ast with the correct attributes.
|
61
|
-
if value is None:
|
62
|
-
continue
|
63
|
-
if indent_len and not first:
|
64
|
-
attr_value += '\n%s' % (self_indent_char * indent_len)
|
65
|
-
attr_value += ' %s=%s' % (attr, quoteattr(value))
|
66
|
-
if first:
|
67
|
-
first = False
|
68
|
-
return attr_value
|
36
|
+
from giscanner._giscanner import collect_attributes
|
69
37
|
|
70
38
|
|
71
39
|
def build_xml_tag(tag_name, attributes=None, data=None, self_indent=0,
|
@@ -87,13 +55,6 @@ def build_xml_tag(tag_name, attributes=None, data=None, self_indent=0,
|
|
87
55
|
return prefix + attrs + suffix
|
88
56
|
|
89
57
|
|
90
|
-
with LibtoolImporter(None, None):
|
91
|
-
if 'UNINSTALLED_INTROSPECTION_SRCDIR' in os.environ:
|
92
|
-
from _giscanner import collect_attributes
|
93
|
-
else:
|
94
|
-
from giscanner._giscanner import collect_attributes
|
95
|
-
|
96
|
-
|
97
58
|
class XMLWriter(object):
|
98
59
|
|
99
60
|
def __init__(self):
|
Binary file
|
Binary file
|
Binary file
|