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,10 +20,13 @@
20
20
 
21
21
  import os
22
22
  import subprocess
23
+ import tempfile
24
+
23
25
  import sys
24
26
  import distutils
25
27
 
26
28
  from distutils.msvccompiler import MSVCCompiler
29
+ from distutils.unixccompiler import UnixCCompiler
27
30
  from distutils.cygwinccompiler import Mingw32CCompiler
28
31
  from distutils.sysconfig import customize_compiler
29
32
 
@@ -36,118 +39,260 @@ class CCompiler(object):
36
39
  compiler = None
37
40
  _cflags_no_deprecation_warnings = ''
38
41
 
39
- def __init__(self, compiler_name=None):
40
- pass
41
-
42
- def get_internal_link_flags(self,
43
- args,
44
- libtool,
45
- libraries,
46
- libpaths,
47
- pkgconfig_msvc_flags,
48
- ns,
49
- ns_version):
42
+ def __init__(self,
43
+ environ=os.environ,
44
+ osname=os.name,
45
+ compiler_name=None):
46
+
47
+ if osname == 'nt':
48
+ # The compiler used here on Windows may well not be
49
+ # the same compiler that was used to build Python,
50
+ # as the official Python binaries are built with
51
+ # Visual Studio
52
+ if compiler_name is None:
53
+ if environ.get('MSYSTEM') == 'MINGW32' or environ.get('MSYSTEM') == 'MINGW64':
54
+ compiler_name = 'mingw32'
55
+ else:
56
+ compiler_name = distutils.ccompiler.get_default_compiler()
57
+ if compiler_name != 'msvc' and \
58
+ compiler_name != 'mingw32':
59
+ raise SystemExit('Specified Compiler \'%s\' is unsupported.' % compiler_name)
60
+ else:
61
+ # XXX: Is it common practice to use a non-Unix compiler
62
+ # class instance on non-Windows on platforms g-i supports?
63
+ compiler_name = distutils.ccompiler.get_default_compiler()
64
+
65
+ # Now, create the distutils ccompiler instance based on the info we have.
66
+ if compiler_name == 'msvc':
67
+ # For MSVC, we need to create a instance of a subclass of distutil's
68
+ # MSVC9Compiler class, as it does not provide a preprocess()
69
+ # implementation
70
+ from . import msvccompiler
71
+ self.compiler = msvccompiler.get_msvc_compiler()
72
+
73
+ else:
74
+ self.compiler = distutils.ccompiler.new_compiler(compiler=compiler_name)
75
+ customize_compiler(self.compiler)
76
+
77
+ # customize_compiler() from distutils only does customization
78
+ # for 'unix' compiler type. Also, avoid linking to msvcrxx.dll
79
+ # for MinGW builds as the dumper binary does not link to the
80
+ # Python DLL, but link to msvcrt.dll if necessary.
81
+ if isinstance(self.compiler, Mingw32CCompiler):
82
+ if self.compiler.dll_libraries != ['msvcrt']:
83
+ self.compiler.dll_libraries = []
84
+ if self.compiler.preprocessor is None:
85
+ self.compiler.preprocessor = self.compiler.compiler + ['-E']
86
+
87
+ if self.check_is_msvc():
88
+ # We trick distutils to believe that we are (always) using a
89
+ # compiler supplied by a Windows SDK, so that we avoid launching
90
+ # a new build environment to detect the compiler that is used to
91
+ # build Python itself, which is not desirable, so that we use the
92
+ # compiler commands (and env) as-is.
93
+ os.environ['DISTUTILS_USE_SDK'] = '1'
94
+ if 'MSSdk' not in os.environ:
95
+ if 'WindowsSDKDir' in os.environ:
96
+ os.environ['MSSdk'] = os.environ.get('WindowsSDKDir')
97
+ elif os.environ.get('VCInstallDir'):
98
+ os.environ['MSSdk'] = os.environ.get('VCInstallDir')
99
+
100
+ self.compiler_cmd = 'cl.exe'
101
+
102
+ self._cflags_no_deprecation_warnings = "-wd4996"
103
+ else:
104
+ if (isinstance(self.compiler, Mingw32CCompiler)):
105
+ self.compiler_cmd = self.compiler.compiler[0]
106
+ else:
107
+ self.compiler_cmd = ' '.join(self.compiler.compiler)
108
+
109
+ self._cflags_no_deprecation_warnings = "-Wno-deprecated-declarations"
110
+
111
+ def get_internal_link_flags(self, args, libtool, libraries, libpaths):
50
112
  # An "internal" link is where the library to be introspected
51
113
  # is being built in the current directory.
52
114
 
53
- # Search the current directory first
54
- # (This flag is not supported nor needed for Visual C++)
55
- if pkgconfig_msvc_flags == '':
56
- args.append('-L.')
57
-
58
- # https://bugzilla.gnome.org/show_bug.cgi?id=625195
59
115
  if not libtool:
60
- # We don't have -Wl,-rpath for Visual C++, and that's
61
- # going to cause a problem. Instead, link to internal
62
- # libraries by deducing the .lib file name using
63
- # the namespace name and version
64
- if pkgconfig_msvc_flags:
65
- if ns_version:
66
- args.append(str.lower(ns) +
67
- '-' +
68
- ns_version + '.lib')
69
- else:
70
- args.append(str.lower(ns) + '.lib')
116
+ # non-libtool case: prepare distutils use
117
+ if self.check_is_msvc():
118
+ for library in libraries:
119
+ # MSVC Builds don't use libtool, so no .la libraries,
120
+ # so just add the library directly.
121
+ self.compiler.add_library(library)
122
+ for libpath in libpaths:
123
+ self.compiler.add_library_dir(libpath)
71
124
  else:
72
- args.append('-Wl,-rpath=.')
125
+ # Search the current directory first
126
+ # (This flag is not supported nor needed for Visual C++)
127
+ self.compiler.add_library_dir('.')
128
+ if os.name != 'nt':
129
+ self.compiler.add_runtime_library_dir('.')
73
130
 
74
- # Ensure libraries are always linked as we are going to use ldd to work
75
- # out their names later
76
- if not libtool and pkgconfig_msvc_flags == '':
77
- args.append('-Wl,--no-as-needed')
131
+ # https://bugzilla.gnome.org/show_bug.cgi?id=625195
132
+ args.append('-Wl,-rpath,.')
78
133
 
79
- for library in libraries:
80
- # Visual C++: We have the needed .lib files now, and we need to link
81
- # to .lib files, not the .dll as the --library option specifies the
82
- # .dll(s) the .gir file refers to
83
- if pkgconfig_msvc_flags == '':
134
+ # Ensure libraries are always linked as we are going to use ldd to work
135
+ # out their names later
136
+ if sys.platform != 'darwin':
137
+ args.append('-Wl,--no-as-needed')
138
+
139
+ for library in libraries:
140
+ self.compiler.add_library(library)
141
+ if not self.check_is_msvc():
142
+ for library_path in libpaths:
143
+ args.append('-L' + library_path)
144
+ if os.path.isabs(library_path):
145
+ args.append('-Wl,-rpath,' + library_path)
146
+
147
+ else:
148
+ # libtool case: assemble linker command arguments, like we did before
149
+ args.append('-L.')
150
+ for library in libraries:
84
151
  if library.endswith(".la"): # explicitly specified libtool library
85
152
  args.append(library)
86
153
  else:
87
154
  args.append('-l' + library)
88
155
 
89
- for library_path in libpaths:
90
- # Not used/needed on Visual C++, and -Wl,-rpath options
91
- # will cause grief
92
- if pkgconfig_msvc_flags == '':
156
+ for library_path in libpaths:
93
157
  args.append('-L' + library_path)
94
158
  if os.path.isabs(library_path):
95
- if libtool:
96
- args.append('-rpath')
97
- args.append(library_path)
98
- else:
99
- args.append('-Wl,-rpath=' + library_path)
159
+ args.append('-rpath')
160
+ args.append(library_path)
100
161
 
101
- def get_external_link_flags(self, args, libraries, pkgconfig_msvc_flags):
162
+ def get_external_link_flags(self, args, libtool, libraries):
102
163
  # An "external" link is where the library to be introspected
103
164
  # is installed on the system; this case is used for the scanning
104
165
  # of GLib in gobject-introspection itself.
105
166
 
106
167
  for library in libraries:
107
- # The --library option on Windows pass in the .dll file(s) the
108
- # .gir files refer to, so don't link to them on Visual C++
109
- if pkgconfig_msvc_flags == '':
168
+ if not libtool:
169
+ self.compiler.add_library(library)
170
+ else:
110
171
  if library.endswith(".la"): # explicitly specified libtool library
111
172
  args.append(library)
112
173
  else:
113
174
  args.append('-l' + library)
114
175
 
176
+ def preprocess(self, source, output, cpp_options):
177
+ extra_postargs = ['-C']
178
+ (include_paths, macros, postargs) = self._set_cpp_options(cpp_options)
179
+
180
+ # We always want to include the current path
181
+ include_dirs = ['.']
182
+
183
+ include_dirs.extend(include_paths)
184
+ extra_postargs.extend(postargs)
185
+
186
+ # Define these macros when using Visual C++ to silence many warnings,
187
+ # and prevent stepping on many Visual Studio-specific items, so that
188
+ # we don't have to handle them specifically in scannerlexer.l
189
+ if self.check_is_msvc():
190
+ macros.append(('_USE_DECLSPECS_FOR_SAL', None))
191
+ macros.append(('_CRT_SECURE_NO_WARNINGS', None))
192
+ macros.append(('_CRT_NONSTDC_NO_WARNINGS', None))
193
+ macros.append(('SAL_NO_ATTRIBUTE_DECLARATIONS', None))
194
+
195
+ self.compiler.preprocess(source=source,
196
+ output_file=output,
197
+ macros=macros,
198
+ include_dirs=include_dirs,
199
+ extra_postargs=extra_postargs)
200
+
201
+ def compile(self, pkg_config_cflags, cpp_includes, source, init_sections):
202
+ extra_postargs = []
203
+ includes = []
204
+ source_str = ''.join(source)
205
+ tmpdir_idx = source_str.rfind(os.sep, 0, source_str.rfind(os.sep))
206
+ (include_paths, macros, extra_args) = \
207
+ self._set_cpp_options(pkg_config_cflags)
208
+
209
+ for include in cpp_includes:
210
+ includes.append(include)
211
+
212
+ if isinstance(self.compiler, UnixCCompiler):
213
+ # This is to handle the case where macros are defined in CFLAGS
214
+ cflags = os.environ.get('CFLAGS')
215
+ if cflags:
216
+ for i, cflag in enumerate(cflags.split()):
217
+ if cflag.startswith('-D'):
218
+ stridx = cflag.find('=')
219
+ if stridx > -1:
220
+ macroset = (cflag[2:stridx],
221
+ cflag[stridx + 1:])
222
+ else:
223
+ macroset = (cflag[2:], None)
224
+ if macroset not in macros:
225
+ macros.append(macroset)
226
+
227
+ # Do not add -Wall when using init code as we do not include any
228
+ # header of the library being introspected
229
+ if self.compiler_cmd == 'gcc' and not init_sections:
230
+ extra_postargs.append('-Wall')
231
+ extra_postargs.append(self._cflags_no_deprecation_warnings)
232
+
233
+ includes.extend(include_paths)
234
+ extra_postargs.extend(extra_args)
235
+
236
+ return self.compiler.compile(sources=source,
237
+ macros=macros,
238
+ include_dirs=includes,
239
+ extra_postargs=extra_postargs,
240
+ output_dir=str(source_str[tmpdir_idx + 1:
241
+ source_str.rfind(os.sep)]))
242
+
243
+ def link(self, output, objects, lib_args):
244
+ # Note: This is used for non-libtool builds only!
245
+ extra_preargs = []
246
+ extra_postargs = []
247
+ library_dirs = []
248
+ libraries = []
249
+
250
+ for arg in lib_args:
251
+ extra_postargs.append(arg)
252
+
253
+ self.compiler.link(target_desc=self.compiler.EXECUTABLE,
254
+ objects=objects,
255
+ output_filename=output,
256
+ extra_preargs=extra_preargs,
257
+ extra_postargs=extra_postargs)
258
+
115
259
  def resolve_windows_libs(self, libraries, options):
116
260
  args = []
117
- compiler_cmd = os.environ.get('CC', 'cc')
118
261
  libsearch = []
119
262
 
120
263
  # When we are using Visual C++...
121
- if 'cl.exe' in compiler_cmd or 'cl' in compiler_cmd:
264
+ if self.check_is_msvc():
122
265
  # The search path of the .lib's on Visual C++
123
266
  # is dependent on the LIB environmental variable,
124
267
  # so just query for that
125
- is_msvc = True
126
268
  libpath = os.environ.get('LIB')
127
269
  libsearch = libpath.split(';')
128
270
 
129
271
  # Use the dumpbin utility that's included in
130
272
  # every Visual C++ installation to find out which
131
- # DLL the library gets linked to
273
+ # DLL the .lib gets linked to.
274
+ # dumpbin -symbols something.lib gives the
275
+ # filename of DLL without the '.dll' extension that something.lib
276
+ # links to, in the line that contains
277
+ # __IMPORT_DESCRIPTOR_<dll_filename_that_something.lib_links_to>
132
278
  args.append('dumpbin.exe')
133
279
  args.append('-symbols')
134
280
 
135
281
  # When we are not using Visual C++ (i.e. we are using GCC)...
136
282
  else:
137
- is_msvc = False
138
283
  libtool = utils.get_libtool_command(options)
139
284
  if libtool:
140
- args.append(utils.which(os.environ.get('SHELL', 'sh.exe')))
285
+ if os.name == 'nt':
286
+ args.append(utils.which(os.environ.get('SHELL', 'sh.exe')))
141
287
  args.extend(libtool)
142
288
  args.append('--mode=execute')
143
- # FIXME: it could have prefix (i686-w64-mingw32-dlltool.exe)
144
- args.extend(['dlltool.exe', '--identify'])
145
- proc = subprocess.Popen([compiler_cmd, '-print-search-dirs'],
289
+ args.extend([os.environ.get('DLLTOOL', 'dlltool.exe'), '--identify'])
290
+ proc = subprocess.Popen([self.compiler_cmd, '-print-search-dirs'],
146
291
  stdout=subprocess.PIPE)
147
292
  o, e = proc.communicate()
148
- for line in o.splitlines():
293
+ for line in o.decode('ascii').splitlines():
149
294
  if line.startswith('libraries: '):
150
- libsearch = line[len('libraries: '):].split(';')
295
+ libsearch = line[len('libraries: '):].split(os.pathsep)
151
296
 
152
297
  shlibs = []
153
298
  not_resolved = []
@@ -170,26 +315,36 @@ class CCompiler(object):
170
315
  break
171
316
  implib = os.path.join(l, c)
172
317
  if os.path.exists(implib):
173
- proc = subprocess.Popen(args + [implib],
174
- stdout=subprocess.PIPE)
175
- o, e = proc.communicate()
176
- for line in o.splitlines():
177
- if is_msvc:
178
- # On Visual Studio, dumpbin -symbols something.lib gives the
179
- # filename of DLL without the '.dll' extension that something.lib
180
- # links to, in the line that contains
181
- # __IMPORT_DESCRIPTOR_<dll_filename_that_something.lib_links_to>
182
-
183
- if '__IMPORT_DESCRIPTOR_' in line:
184
- line_tokens = line.split()
185
- for item in line_tokens:
186
- if item.startswith('__IMPORT_DESCRIPTOR_'):
187
- shlibs.append(item[20:] + '.dll')
188
- found = True
189
- break
190
- if found:
191
- break
192
- else:
318
+ if self.check_is_msvc():
319
+ tmp_fd, tmp_filename = \
320
+ tempfile.mkstemp(prefix='g-ir-win32-resolve-lib-')
321
+
322
+ # This is dumb, but it is life... Windows does not like one
323
+ # trying to write to a file when its FD is not closed first,
324
+ # when we use a flag in a program to do so. So, close,
325
+ # write to temp file with dumpbin and *then* re-open the
326
+ # file for reading.
327
+ os.close(tmp_fd)
328
+ output_flag = ['-out:' + tmp_filename]
329
+ proc = subprocess.call(args + [implib] + output_flag,
330
+ stdout=subprocess.PIPE)
331
+ with open(tmp_filename, 'r') as tmp_fileobj:
332
+ for line in tmp_fileobj.read().splitlines():
333
+
334
+ if '__IMPORT_DESCRIPTOR_' in line:
335
+ line_tokens = line.split()
336
+ for item in line_tokens:
337
+ if item.startswith('__IMPORT_DESCRIPTOR_'):
338
+ shlibs.append(item[20:] + '.dll')
339
+ found = True
340
+ break
341
+ tmp_fileobj.close()
342
+ os.unlink(tmp_filename)
343
+ else:
344
+ proc = subprocess.Popen(args + [implib],
345
+ stdout=subprocess.PIPE)
346
+ o, e = proc.communicate()
347
+ for line in o.decode('ascii').splitlines():
193
348
  shlibs.append(line)
194
349
  found = True
195
350
  break
@@ -200,3 +355,38 @@ class CCompiler(object):
200
355
  "ERROR: can't resolve libraries to shared libraries: " +
201
356
  ", ".join(not_resolved))
202
357
  return shlibs
358
+
359
+ def check_is_msvc(self):
360
+ if isinstance(self.compiler, MSVCCompiler):
361
+ return True
362
+ else:
363
+ return False
364
+
365
+ # Private APIs
366
+ def _set_cpp_options(self, options):
367
+ includes = []
368
+ macros = []
369
+ other_options = []
370
+
371
+ for o in options:
372
+ option = utils.cflag_real_include_path(o)
373
+ if option.startswith('-I'):
374
+ includes.append(option[len('-I'):])
375
+ elif option.startswith('-D'):
376
+ macro = option[len('-D'):]
377
+ macro_index = macro.find('=')
378
+ if macro_index == -1:
379
+ macro_name = macro
380
+ macro_value = None
381
+ else:
382
+ macro_name = macro[:macro_index]
383
+ macro_value = macro[macro_index + 1:]
384
+ macros.append((macro_name, macro_value))
385
+ elif option.startswith('-U'):
386
+ macros.append((option[len('-U'):],))
387
+ else:
388
+ # We expect the preprocessor to remove macros. If debugging is turned
389
+ # up high enough that won't happen, so don't add those flags. Bug #720504
390
+ if option not in ['-g3', '-ggdb3', '-gstabs3', '-gcoff3', '-gxcoff3', '-gvms3']:
391
+ other_options.append(option)
392
+ return (includes, macros, other_options)
@@ -19,6 +19,10 @@
19
19
  #
20
20
 
21
21
  from __future__ import with_statement
22
+ from __future__ import absolute_import
23
+ from __future__ import division
24
+ from __future__ import print_function
25
+ from __future__ import unicode_literals
22
26
 
23
27
  from contextlib import contextmanager
24
28
 
@@ -84,28 +88,31 @@ class CCodeGenerator(object):
84
88
  self._write_prelude(self.out_h, func)
85
89
  self.out_h.write(";\n\n")
86
90
 
87
- def _write_annotation_transfer(self, transfer):
88
- self.out_c.write("(transfer %s)" % (transfer, ))
91
+ def _write_annotation_transfer(self, node):
92
+ if (node.type not in ast.BASIC_TYPES or
93
+ node.type.ctype.endswith('*')):
94
+ self.out_c.write(" (transfer %s)" % (node.transfer, ))
89
95
 
90
96
  def _write_docs(self, func):
91
97
  self.out_c.write("/**\n * %s:\n" % (func.symbol, ))
92
98
  for param in func.parameters:
93
- self.out_c.write(" * @%s: " % (param.argname, ))
99
+ self.out_c.write(" * @%s" % (param.argname, ))
94
100
  if param.direction in (ast.PARAM_DIRECTION_OUT,
95
101
  ast.PARAM_DIRECTION_INOUT):
96
102
  if param.caller_allocates:
97
103
  allocate_string = ' caller-allocates'
98
104
  else:
99
105
  allocate_string = ''
100
- self.out_c.write("(%s%s) " % (param.direction,
101
- allocate_string))
102
- self._write_annotation_transfer(param.transfer)
106
+ self.out_c.write(": (%s%s) " % (param.direction,
107
+ allocate_string))
108
+ self._write_annotation_transfer(param)
103
109
  self.out_c.write(":\n")
104
110
  self.out_c.write(' *\n')
105
- self.out_c.write(' * Undocumented.\n')
106
- self.out_c.write(' *\n')
107
- self.out_c.write(' * Returns: ')
108
- self._write_annotation_transfer(func.retval.transfer)
111
+ self.out_c.write(' * Undocumented.')
112
+ if func.retval.type != ast.TYPE_NONE:
113
+ self.out_c.write('\n *\n')
114
+ self.out_c.write(' * Returns: ')
115
+ self._write_annotation_transfer(func.retval)
109
116
  self.out_c.write('\n */')
110
117
 
111
118
  @contextmanager
@@ -162,7 +169,7 @@ class CCodeGenerator(object):
162
169
 
163
170
  self._codegen_start()
164
171
 
165
- for node in self.namespace.itervalues():
172
+ for node in self.namespace.values():
166
173
  if isinstance(node, ast.Function):
167
174
  with self._function(node):
168
175
  body = self._function_bodies.get(node)