gobject-introspection 3.0.7-x64-mingw32 → 3.0.8-x64-mingw32

Sign up to get free protection for your applications and to get access to all the features.
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 +2017 -893
  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
@@ -20,8 +20,14 @@
20
20
  # 02110-1301, USA.
21
21
  #
22
22
 
23
+ from __future__ import absolute_import
24
+ from __future__ import division
25
+ from __future__ import print_function
26
+ from __future__ import unicode_literals
27
+
23
28
  import os
24
29
  import sys
30
+ import operator
25
31
 
26
32
  from . import utils
27
33
 
@@ -43,12 +49,34 @@ class Position(object):
43
49
  self.line = line
44
50
  self.column = column
45
51
 
46
- def __cmp__(self, other):
47
- return cmp((self.filename, self.line, self.column),
48
- (other.filename, other.line, other.column))
52
+ def _compare(self, other, op):
53
+ return op((self.filename, self.line, self.column),
54
+ (other.filename, other.line, other.column))
55
+
56
+ def __lt__(self, other):
57
+ return self._compare(other, operator.lt)
58
+
59
+ def __gt__(self, other):
60
+ return self._compare(other, operator.gt)
61
+
62
+ def __ge__(self, other):
63
+ return self._compare(other, operator.ge)
64
+
65
+ def __le__(self, other):
66
+ return self._compare(other, operator.le)
67
+
68
+ def __eq__(self, other):
69
+ return self._compare(other, operator.eq)
70
+
71
+ def __ne__(self, other):
72
+ return self._compare(other, operator.ne)
73
+
74
+ def __hash__(self):
75
+ return hash((self.filename, self.line, self.column))
49
76
 
50
77
  def __repr__(self):
51
- return '<Position %s:%d:%d>' % (os.path.basename(self.filename), self.line or -1,
78
+ return '<Position %s:%d:%d>' % (os.path.basename(self.filename),
79
+ self.line or -1,
52
80
  self.column or -1)
53
81
 
54
82
  def format(self, cwd):
@@ -69,7 +97,7 @@ class Position(object):
69
97
  class MessageLogger(object):
70
98
  _instance = None
71
99
 
72
- def __init__(self, namespace, output=None):
100
+ def __init__(self, namespace=None, output=None):
73
101
  if output is None:
74
102
  output = sys.stderr
75
103
  self._cwd = os.getcwd()
@@ -94,7 +122,7 @@ class MessageLogger(object):
94
122
  def get_error_count(self):
95
123
  return self._error_count
96
124
 
97
- def log(self, log_type, text, positions=None, prefix=None):
125
+ def log(self, log_type, text, positions=None, prefix=None, marker_pos=None, marker_line=None):
98
126
  """
99
127
  Log a warning, using optional file positioning information.
100
128
  If the warning is related to a ast.Node type, see log_node().
@@ -103,7 +131,7 @@ class MessageLogger(object):
103
131
 
104
132
  self._warning_count += 1
105
133
 
106
- if not log_type in self._enable_warnings:
134
+ if log_type not in self._enable_warnings:
107
135
  return
108
136
 
109
137
  if type(positions) == set:
@@ -126,9 +154,16 @@ class MessageLogger(object):
126
154
  elif log_type == FATAL:
127
155
  error_type = "Fatal"
128
156
 
157
+ if marker_pos is not None and marker_line is not None:
158
+ text = '%s\n%s\n%s' % (text, marker_line, ' ' * marker_pos + '^')
159
+
129
160
  if prefix:
130
- text = ('%s: %s: %s: %s: %s\n' % (last_position, error_type,
131
- self._namespace.name, prefix, text))
161
+ if self._namespace:
162
+ text = ('%s: %s: %s: %s: %s\n' % (last_position, error_type,
163
+ self._namespace.name, prefix, text))
164
+ else:
165
+ text = ('%s: %s: %s: %s\n' % (last_position, error_type,
166
+ prefix, text))
132
167
  else:
133
168
  if self._namespace:
134
169
  text = ('%s: %s: %s: %s\n' % (last_position, error_type,
@@ -157,9 +192,7 @@ class MessageLogger(object):
157
192
  elif context and context.file_positions:
158
193
  positions = context.file_positions
159
194
  else:
160
- positions = []
161
- if not context:
162
- text = "context=%r %s" % (node, text)
195
+ positions = set()
163
196
 
164
197
  if context:
165
198
  text = "%s: %s" % (getattr(context, 'symbol', context.name), text)
@@ -171,7 +204,7 @@ class MessageLogger(object):
171
204
  def log_symbol(self, log_type, symbol, text):
172
205
  """Log a warning in the context of the given symbol."""
173
206
  self.log(log_type, text, symbol.position,
174
- prefix="symbol=%r" % (symbol.ident, ))
207
+ prefix="symbol='%s'" % (symbol.ident, ))
175
208
 
176
209
 
177
210
  def log_node(log_type, node, text, context=None, positions=None):
@@ -179,25 +212,29 @@ def log_node(log_type, node, text, context=None, positions=None):
179
212
  ml.log_node(log_type, node, text, context=context, positions=positions)
180
213
 
181
214
 
182
- def warn(text, positions=None, prefix=None):
215
+ def warn(text, positions=None, prefix=None, marker_pos=None, marker_line=None):
183
216
  ml = MessageLogger.get()
184
- ml.log(WARNING, text, positions, prefix)
217
+ ml.log(WARNING, text, positions, prefix, marker_pos, marker_line)
185
218
 
186
219
 
187
220
  def warn_node(node, text, context=None, positions=None):
188
221
  log_node(WARNING, node, text, context=context, positions=positions)
189
222
 
190
223
 
224
+ def error_node(node, text, context=None, positions=None):
225
+ log_node(ERROR, node, text, context=context, positions=positions)
226
+
227
+
191
228
  def warn_symbol(symbol, text):
192
229
  ml = MessageLogger.get()
193
230
  ml.log_symbol(WARNING, symbol, text)
194
231
 
195
232
 
196
- def error(text, positions=None, prefix=None):
233
+ def error(text, positions=None, prefix=None, marker_pos=None, marker_line=None):
197
234
  ml = MessageLogger.get()
198
- ml.log(ERROR, text, positions, prefix)
235
+ ml.log(ERROR, text, positions, prefix, marker_pos, marker_line)
199
236
 
200
237
 
201
- def fatal(text, positions=None, prefix=None):
238
+ def fatal(text, positions=None, prefix=None, marker_pos=None, marker_line=None):
202
239
  ml = MessageLogger.get()
203
- ml.log(FATAL, text, positions, prefix)
240
+ ml.log(FATAL, text, positions, prefix, marker_pos, marker_line)
@@ -0,0 +1,101 @@
1
+ # -*- Mode: Python -*-
2
+ # GObject-Introspection - a framework for introspecting GObject libraries
3
+ # Copyright (C) 2014 Chun-wei Fan
4
+ #
5
+ # This library is free software; you can redistribute it and/or
6
+ # modify it under the terms of the GNU Lesser General Public
7
+ # License as published by the Free Software Foundation; either
8
+ # version 2 of the License, or (at your option) any later version.
9
+ #
10
+ # This library is distributed in the hope that it will be useful,
11
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13
+ # Lesser General Public License for more details.
14
+ #
15
+ # You should have received a copy of the GNU Lesser General Public
16
+ # License along with this library; if not, write to the
17
+ # Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18
+ # Boston, MA 02111-1307, USA.
19
+ #
20
+
21
+ import os
22
+ import distutils
23
+
24
+ from distutils.errors import (DistutilsExecError, CompileError, LibError,
25
+ LinkError, UnknownFileError)
26
+ from distutils.ccompiler import CCompiler, gen_preprocess_options
27
+ from distutils.dep_util import newer
28
+
29
+ # Distutil's MSVCCompiler does not provide a preprocess()
30
+ # Implementation, so do our own here.
31
+
32
+
33
+ def get_msvc_compiler():
34
+ return MSVCCompiler()
35
+
36
+
37
+ class MSVCCompiler(distutils.msvccompiler.MSVCCompiler):
38
+
39
+ def __init__(self, verbose=0, dry_run=0, force=0):
40
+ CCompiler.__init__(self, verbose, dry_run, force)
41
+ self.__paths = []
42
+ self.__arch = None # deprecated name
43
+ if os.name == 'nt':
44
+ if isinstance(self, distutils.msvc9compiler.MSVCCompiler):
45
+ self.__version = distutils.msvc9compiler.VERSION
46
+ self.initialized = False
47
+ self.preprocess_options = None
48
+
49
+ def preprocess(self,
50
+ source,
51
+ output_file=None,
52
+ macros=None,
53
+ include_dirs=None,
54
+ extra_preargs=None,
55
+ extra_postargs=None):
56
+ if self.initialized is False:
57
+ self.initialize()
58
+
59
+ (_, macros, include_dirs) = \
60
+ self._fix_compile_args(None, macros, include_dirs)
61
+ pp_opts = gen_preprocess_options(macros, include_dirs)
62
+ preprocess_options = ['-E']
63
+ source_basename = None
64
+
65
+ if output_file is not None:
66
+ preprocess_options.append('-P')
67
+ source_basename = self._get_file_basename(source)
68
+ cpp_args = self.cc.split()
69
+ if extra_preargs is not None:
70
+ cpp_args[:0] = extra_preargs
71
+ if extra_postargs is not None:
72
+ preprocess_options.extend(extra_postargs)
73
+ cpp_args.extend(preprocess_options)
74
+ cpp_args.extend(pp_opts)
75
+ cpp_args.append(source)
76
+
77
+ # We need to preprocess: either we're being forced to, or the
78
+ # source file is newer than the target (or the target doesn't
79
+ # exist).
80
+ if self.force or output_file is None or newer(source, output_file):
81
+ try:
82
+ self.spawn(cpp_args)
83
+ except DistutilsExecError as msg:
84
+ print(msg)
85
+ raise CompileError
86
+
87
+ # The /P option for the MSVC preprocessor will output the results
88
+ # of the preprocessor to a file, as <source_without_extension>.i,
89
+ # so in order to output the specified filename, we need to rename
90
+ # that file
91
+ if output_file is not None:
92
+ if output_file != source_basename + '.i':
93
+ os.rename(source_basename + '.i', output_file)
94
+
95
+ def _get_file_basename(self, filename):
96
+ if filename is None:
97
+ return None
98
+ if filename.rfind('.') == -1:
99
+ return filename[filename.rfind('\\') + 1:]
100
+ else:
101
+ return filename[filename.rfind('\\') + 1:filename.rfind('.')]
@@ -20,10 +20,16 @@
20
20
  # 02110-1301, USA.
21
21
  #
22
22
 
23
+ from __future__ import absolute_import
24
+ from __future__ import division
25
+ from __future__ import print_function
26
+ from __future__ import unicode_literals
27
+
23
28
  import errno
24
29
  import optparse
25
30
  import os
26
31
  import shutil
32
+ import stat
27
33
  import subprocess
28
34
  import sys
29
35
  import tempfile
@@ -164,6 +170,11 @@ the latter is not specified.""")
164
170
  parser.add_option("", "--symbol-prefix",
165
171
  action="append", dest="symbol_prefixes", default=[],
166
172
  help="Remove this prefix from C symbols (function names)")
173
+ parser.add_option("", "--symbol-filter-cmd",
174
+ action="store", dest="symbol_filter_cmd", default='',
175
+ help='Filter symbols (function names) through the given '
176
+ 'shell command which will receive the symbol name as input '
177
+ 'to stdin and is expected to output the filtered results to stdout.')
167
178
  parser.add_option("", "--accept-unprefixed",
168
179
  action="store_true", dest="accept_unprefixed", default=False,
169
180
  help="""If specified, accept symbols and identifiers that do not
@@ -245,7 +256,7 @@ def passthrough_gir(path, f):
245
256
  parser.parse(path)
246
257
 
247
258
  writer = GIRWriter(parser.get_namespace())
248
- f.write(writer.get_xml())
259
+ f.write(writer.get_encoded_xml())
249
260
 
250
261
 
251
262
  def test_codegen(optstring,
@@ -266,7 +277,7 @@ def test_codegen(optstring,
266
277
  include_last_src)
267
278
  gen.write()
268
279
  else:
269
- _error("Invaild namespace %r" % (namespace, ))
280
+ _error("Invaild namespace '%s'" % (namespace, ))
270
281
  return 0
271
282
 
272
283
 
@@ -288,6 +299,7 @@ def process_packages(options, packages):
288
299
  # the error output should have already appeared on our stderr,
289
300
  # so we just exit
290
301
  return 1
302
+ output = output.decode('ascii')
291
303
  # Some pkg-config files on Windows have options we don't understand,
292
304
  # so we explicitly filter to only the ones we need.
293
305
  options_whitelist = ['-I', '-D', '-U', '-l', '-L']
@@ -317,8 +329,8 @@ def extract_filelist(options):
317
329
  filenames = []
318
330
  if not os.path.exists(options.filelist):
319
331
  _error('%s: no such filelist file' % (options.filelist, ))
320
- filelist_file = open(options.filelist, "r")
321
- lines = filelist_file.readlines()
332
+ with open(options.filelist, "r") as filelist_file:
333
+ lines = filelist_file.readlines()
322
334
  for line in lines:
323
335
  # We don't support real C++ parsing yet, but we should be able
324
336
  # to understand C API implemented in C++ files.
@@ -337,8 +349,8 @@ def extract_filelist(options):
337
349
 
338
350
  def create_namespace(options):
339
351
  if options.strip_prefix:
340
- print """g-ir-scanner: warning: Option --strip-prefix has been deprecated;
341
- see --identifier-prefix and --symbol-prefix."""
352
+ print("""g-ir-scanner: warning: Option --strip-prefix has been deprecated;
353
+ see --identifier-prefix and --symbol-prefix.""")
342
354
  options.identifier_prefixes.append(options.strip_prefix)
343
355
 
344
356
  # We do this dance because the empty list has different semantics from
@@ -367,19 +379,20 @@ see --identifier-prefix and --symbol-prefix."""
367
379
  def create_transformer(namespace, options):
368
380
  transformer = Transformer(namespace,
369
381
  accept_unprefixed=options.accept_unprefixed,
370
- identifier_filter_cmd=options.identifier_filter_cmd)
382
+ identifier_filter_cmd=options.identifier_filter_cmd,
383
+ symbol_filter_cmd=options.symbol_filter_cmd)
371
384
  transformer.set_include_paths(options.include_paths)
372
- if options.passthrough_gir:
385
+ if options.passthrough_gir or options.reparse_validate_gir:
373
386
  transformer.disable_cache()
374
387
  transformer.set_passthrough_mode()
375
388
 
376
389
  for include in options.includes:
377
390
  if os.sep in include:
378
- _error("Invalid include path %r" % (include, ))
391
+ _error("Invalid include path '%s'" % (include, ))
379
392
  try:
380
393
  include_obj = Include.from_string(include)
381
394
  except:
382
- _error("Malformed include %r\n" % (include, ))
395
+ _error("Malformed include '%s'\n" % (include, ))
383
396
  transformer.register_include(include_obj)
384
397
  for include_path in options.includes_uninstalled:
385
398
  transformer.register_include_uninstalled(include_path)
@@ -433,20 +446,26 @@ def create_source_scanner(options, args):
433
446
 
434
447
 
435
448
  def write_output(data, options):
449
+ """Write encoded XML 'data' to the filename specified in 'options'."""
436
450
  if options.output == "-":
437
451
  output = sys.stdout
438
452
  elif options.reparse_validate_gir:
439
453
  main_f, main_f_name = tempfile.mkstemp(suffix='.gir')
440
- main_f = os.fdopen(main_f, 'w')
441
- main_f.write(data)
442
- main_f.close()
454
+
455
+ if (os.path.isfile(options.output)):
456
+ shutil.copystat(options.output, main_f_name)
457
+ else:
458
+ os.chmod(main_f_name,
459
+ stat.S_IWUSR | stat.S_IRUSR | stat.S_IRGRP | stat.S_IROTH)
460
+
461
+ with os.fdopen(main_f, 'wb') as main_f:
462
+ main_f.write(data)
443
463
 
444
464
  temp_f, temp_f_name = tempfile.mkstemp(suffix='.gir')
445
- temp_f = os.fdopen(temp_f, 'w')
446
- passthrough_gir(main_f_name, temp_f)
447
- temp_f.close()
465
+ with os.fdopen(temp_f, 'wb') as temp_f:
466
+ passthrough_gir(main_f_name, temp_f)
448
467
  if not utils.files_are_identical(main_f_name, temp_f_name):
449
- _error("Failed to re-parse gir file; scanned=%r passthrough=%r" % (
468
+ _error("Failed to re-parse gir file; scanned='%s' passthrough='%s'" % (
450
469
  main_f_name, temp_f_name))
451
470
  os.unlink(temp_f_name)
452
471
  try:
@@ -454,12 +473,11 @@ def write_output(data, options):
454
473
  except OSError as e:
455
474
  if e.errno == errno.EPERM:
456
475
  os.unlink(main_f_name)
457
- return 0
458
476
  raise
459
477
  return 0
460
478
  else:
461
479
  try:
462
- output = open(options.output, "w")
480
+ output = open(options.output, 'wb')
463
481
  except IOError as e:
464
482
  _error("opening output for writing: %s" % (e.strerror, ))
465
483
 
@@ -542,8 +560,9 @@ def scanner_main(args):
542
560
  message.fatal("warnings configured as fatal")
543
561
  return 1
544
562
  elif warning_count > 0 and options.warn_all is False:
545
- print ("g-ir-scanner: %s: warning: %d warnings suppressed (use --warn-all to see them)"
546
- % (transformer.namespace.name, warning_count, ))
563
+ print("g-ir-scanner: %s: warning: %d warnings suppressed "
564
+ "(use --warn-all to see them)" %
565
+ (transformer.namespace.name, warning_count, ))
547
566
 
548
567
  # Write out AST
549
568
  if options.packages_export:
@@ -554,7 +573,7 @@ def scanner_main(args):
554
573
  transformer.namespace.c_includes = options.c_includes
555
574
  transformer.namespace.exported_packages = exported_packages
556
575
  writer = Writer(transformer.namespace)
557
- data = writer.get_xml()
576
+ data = writer.get_encoded_xml()
558
577
 
559
578
  write_output(data, options)
560
579
 
@@ -17,6 +17,11 @@
17
17
  # Boston, MA 02111-1307, USA.
18
18
  #
19
19
 
20
+ from __future__ import absolute_import
21
+ from __future__ import division
22
+ from __future__ import print_function
23
+ from __future__ import unicode_literals
24
+
20
25
  import re
21
26
  from . import ast
22
27
  from .utils import to_underscores
@@ -134,7 +139,7 @@ def generate_sections_file(transformer):
134
139
 
135
140
  general_section = new_section("main", "Main")
136
141
 
137
- for node in ns.itervalues():
142
+ for node in ns.values():
138
143
  if isinstance(node, ast.Function):
139
144
  append_symbol(general_section, node.symbol)
140
145
  elif isinstance(node, (ast.Class, ast.Interface)):