zeroc-ice 3.6.2 → 3.6.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (209) hide show
  1. checksums.yaml +4 -4
  2. data/bin/slice2rb +0 -0
  3. data/ext/Slice.cpp +32 -39
  4. data/ext/ice/cpp/include/Ice/BasicStream.h +15 -4
  5. data/ext/ice/cpp/include/Ice/BuiltinSequences.h +2 -2
  6. data/ext/ice/cpp/include/Ice/Communicator.h +2 -2
  7. data/ext/ice/cpp/include/Ice/CommunicatorF.h +2 -2
  8. data/ext/ice/cpp/include/Ice/Connection.h +2 -2
  9. data/ext/ice/cpp/include/Ice/ConnectionF.h +2 -2
  10. data/ext/ice/cpp/include/Ice/Current.h +2 -2
  11. data/ext/ice/cpp/include/Ice/Endpoint.h +2 -2
  12. data/ext/ice/cpp/include/Ice/EndpointF.h +2 -2
  13. data/ext/ice/cpp/include/Ice/EndpointTypes.h +2 -2
  14. data/ext/ice/cpp/include/Ice/FacetMap.h +2 -2
  15. data/ext/ice/cpp/include/Ice/Identity.h +2 -2
  16. data/ext/ice/cpp/include/Ice/ImplicitContext.h +2 -2
  17. data/ext/ice/cpp/include/Ice/ImplicitContextF.h +2 -2
  18. data/ext/ice/cpp/include/Ice/Instrumentation.h +2 -2
  19. data/ext/ice/cpp/include/Ice/InstrumentationF.h +2 -2
  20. data/ext/ice/cpp/include/Ice/LocalException.h +2 -2
  21. data/ext/ice/cpp/include/Ice/Locator.h +2 -2
  22. data/ext/ice/cpp/include/Ice/LocatorF.h +2 -2
  23. data/ext/ice/cpp/include/Ice/Logger.h +2 -2
  24. data/ext/ice/cpp/include/Ice/LoggerF.h +2 -2
  25. data/ext/ice/cpp/include/Ice/Metrics.h +2 -2
  26. data/ext/ice/cpp/include/Ice/ObjectAdapter.h +2 -2
  27. data/ext/ice/cpp/include/Ice/ObjectAdapterF.h +2 -2
  28. data/ext/ice/cpp/include/Ice/ObjectFactory.h +2 -2
  29. data/ext/ice/cpp/include/Ice/ObjectFactoryF.h +2 -2
  30. data/ext/ice/cpp/include/Ice/Plugin.h +2 -2
  31. data/ext/ice/cpp/include/Ice/PluginF.h +2 -2
  32. data/ext/ice/cpp/include/Ice/Process.h +2 -2
  33. data/ext/ice/cpp/include/Ice/ProcessF.h +2 -2
  34. data/ext/ice/cpp/include/Ice/Properties.h +2 -2
  35. data/ext/ice/cpp/include/Ice/PropertiesAdmin.h +2 -2
  36. data/ext/ice/cpp/include/Ice/PropertiesF.h +2 -2
  37. data/ext/ice/cpp/include/Ice/RemoteLogger.h +2 -2
  38. data/ext/ice/cpp/include/Ice/Router.h +2 -2
  39. data/ext/ice/cpp/include/Ice/RouterF.h +2 -2
  40. data/ext/ice/cpp/include/Ice/ServantLocator.h +2 -2
  41. data/ext/ice/cpp/include/Ice/ServantLocatorF.h +2 -2
  42. data/ext/ice/cpp/include/Ice/SliceChecksumDict.h +2 -2
  43. data/ext/ice/cpp/include/Ice/SlicedData.h +6 -0
  44. data/ext/ice/cpp/include/Ice/Version.h +2 -2
  45. data/ext/ice/cpp/include/IceSSL/ConnectionInfo.h +2 -2
  46. data/ext/ice/cpp/include/IceSSL/EndpointInfo.h +2 -2
  47. data/ext/ice/cpp/include/IceUtil/Config.h +86 -26
  48. data/ext/ice/cpp/include/IceUtil/IconvStringConverter.h +1 -1
  49. data/ext/ice/cpp/include/IceUtil/Time.h +3 -2
  50. data/ext/ice/cpp/include/Slice/PythonUtil.h +1 -1
  51. data/ext/ice/cpp/include/Slice/RubyUtil.h +1 -1
  52. data/ext/ice/cpp/include/Slice/Util.h +5 -0
  53. data/ext/ice/cpp/src/Ice/BuiltinSequences.cpp +2 -2
  54. data/ext/ice/cpp/src/Ice/Communicator.cpp +2 -2
  55. data/ext/ice/cpp/src/Ice/CommunicatorF.cpp +2 -2
  56. data/ext/ice/cpp/src/Ice/Connection.cpp +2 -2
  57. data/ext/ice/cpp/src/Ice/ConnectionF.cpp +2 -2
  58. data/ext/ice/cpp/src/Ice/ConnectionFactory.cpp +57 -42
  59. data/ext/ice/cpp/src/Ice/ConnectionFactory.h +2 -0
  60. data/ext/ice/cpp/src/Ice/Current.cpp +2 -2
  61. data/ext/ice/cpp/src/Ice/DynamicLibrary.cpp +9 -5
  62. data/ext/ice/cpp/src/Ice/Endpoint.cpp +2 -2
  63. data/ext/ice/cpp/src/Ice/EndpointF.cpp +2 -2
  64. data/ext/ice/cpp/src/Ice/EndpointTypes.cpp +2 -2
  65. data/ext/ice/cpp/src/Ice/FacetMap.cpp +2 -2
  66. data/ext/ice/cpp/src/Ice/Identity.cpp +2 -2
  67. data/ext/ice/cpp/src/Ice/ImplicitContext.cpp +2 -2
  68. data/ext/ice/cpp/src/Ice/ImplicitContextF.cpp +2 -2
  69. data/ext/ice/cpp/src/Ice/Incoming.cpp +11 -4
  70. data/ext/ice/cpp/src/Ice/Instance.cpp +4 -2
  71. data/ext/ice/cpp/src/Ice/Instrumentation.cpp +2 -2
  72. data/ext/ice/cpp/src/Ice/InstrumentationF.cpp +2 -2
  73. data/ext/ice/cpp/src/Ice/InstrumentationI.cpp +1 -3
  74. data/ext/ice/cpp/src/Ice/LocalException.cpp +2 -2
  75. data/ext/ice/cpp/src/Ice/Locator.cpp +2 -2
  76. data/ext/ice/cpp/src/Ice/LocatorF.cpp +2 -2
  77. data/ext/ice/cpp/src/Ice/Logger.cpp +2 -2
  78. data/ext/ice/cpp/src/Ice/LoggerF.cpp +2 -2
  79. data/ext/ice/cpp/src/Ice/LoggerI.cpp +94 -5
  80. data/ext/ice/cpp/src/Ice/LoggerI.h +7 -1
  81. data/ext/ice/cpp/src/Ice/Metrics.cpp +2 -2
  82. data/ext/ice/cpp/src/Ice/Network.cpp +23 -7
  83. data/ext/ice/cpp/src/Ice/Network.h +1 -1
  84. data/ext/ice/cpp/src/Ice/ObjectAdapter.cpp +2 -2
  85. data/ext/ice/cpp/src/Ice/ObjectAdapterF.cpp +2 -2
  86. data/ext/ice/cpp/src/Ice/ObjectFactory.cpp +2 -2
  87. data/ext/ice/cpp/src/Ice/ObjectFactoryF.cpp +2 -2
  88. data/ext/ice/cpp/src/Ice/Plugin.cpp +2 -2
  89. data/ext/ice/cpp/src/Ice/PluginF.cpp +2 -2
  90. data/ext/ice/cpp/src/Ice/PluginManagerI.cpp +5 -0
  91. data/ext/ice/cpp/src/Ice/Process.cpp +2 -2
  92. data/ext/ice/cpp/src/Ice/ProcessF.cpp +2 -2
  93. data/ext/ice/cpp/src/Ice/Properties.cpp +2 -2
  94. data/ext/ice/cpp/src/Ice/PropertiesAdmin.cpp +2 -2
  95. data/ext/ice/cpp/src/Ice/PropertiesF.cpp +2 -2
  96. data/ext/ice/cpp/src/Ice/PropertyNames.cpp +4 -3
  97. data/ext/ice/cpp/src/Ice/PropertyNames.h +1 -1
  98. data/ext/ice/cpp/src/Ice/RemoteLogger.cpp +2 -2
  99. data/ext/ice/cpp/src/Ice/RetryQueue.cpp +1 -1
  100. data/ext/ice/cpp/src/Ice/Router.cpp +2 -2
  101. data/ext/ice/cpp/src/Ice/RouterF.cpp +2 -2
  102. data/ext/ice/cpp/src/Ice/ServantLocator.cpp +2 -2
  103. data/ext/ice/cpp/src/Ice/ServantLocatorF.cpp +2 -2
  104. data/ext/ice/cpp/src/Ice/SliceChecksumDict.cpp +2 -2
  105. data/ext/ice/cpp/src/Ice/StreamSocket.cpp +19 -3
  106. data/ext/ice/cpp/src/Ice/Version.cpp +2 -2
  107. data/ext/ice/cpp/src/Ice/WSConnector.h +2 -2
  108. data/ext/ice/cpp/src/IceDiscovery/IceDiscovery.cpp +2 -2
  109. data/ext/ice/cpp/src/IceDiscovery/IceDiscovery.h +2 -2
  110. data/ext/ice/cpp/src/IceLocatorDiscovery/IceLocatorDiscovery.cpp +2 -2
  111. data/ext/ice/cpp/src/IceLocatorDiscovery/IceLocatorDiscovery.h +2 -2
  112. data/ext/ice/cpp/src/IceSSL/ConnectionInfo.cpp +2 -2
  113. data/ext/ice/cpp/src/IceSSL/EndpointInfo.cpp +2 -2
  114. data/ext/ice/cpp/src/IceSSL/OpenSSLEngine.cpp +54 -39
  115. data/ext/ice/cpp/src/IceSSL/SecureTransportTransceiverI.cpp +5 -8
  116. data/ext/ice/cpp/src/IceSSL/Util.cpp +155 -4
  117. data/ext/ice/cpp/src/IceUtil/Cond.cpp +1 -1
  118. data/ext/ice/cpp/src/IceUtil/FileUtil.cpp +8 -0
  119. data/ext/ice/cpp/src/IceUtil/FileUtil.h +18 -5
  120. data/ext/ice/cpp/src/IceUtil/OutputUtil.cpp +5 -5
  121. data/ext/ice/cpp/src/IceUtil/Time.cpp +25 -17
  122. data/ext/ice/cpp/src/Slice/JavaUtil.cpp +5 -11
  123. data/ext/ice/cpp/src/Slice/Preprocessor.cpp +3 -3
  124. data/ext/ice/cpp/src/Slice/Python.cpp +14 -17
  125. data/ext/ice/cpp/src/Slice/PythonUtil.cpp +183 -48
  126. data/ext/ice/cpp/src/Slice/Ruby.cpp +6 -6
  127. data/ext/ice/cpp/src/Slice/RubyUtil.cpp +0 -10
  128. data/ext/ice/cpp/src/Slice/Util.cpp +28 -3
  129. data/ext/ice/mcpp/Makefile +10 -6
  130. data/ext/ice/mcpp/configed.H +3 -0
  131. data/ext/ice/mcpp/main.c +2 -2
  132. data/ext/ice/mcpp/mcpp.gyp +6 -0
  133. data/ext/ice/mcpp/support.c +1 -1
  134. data/ext/ice/mcpp/system.H +6 -1
  135. data/ext/ice/mcpp/system.c +52 -15
  136. data/ice.gemspec +1 -1
  137. data/lib/Glacier2/Metrics.rb +1 -1
  138. data/lib/Glacier2/PermissionsVerifier.rb +1 -1
  139. data/lib/Glacier2/PermissionsVerifierF.rb +1 -1
  140. data/lib/Glacier2/Router.rb +1 -1
  141. data/lib/Glacier2/RouterF.rb +1 -1
  142. data/lib/Glacier2/SSLInfo.rb +1 -1
  143. data/lib/Glacier2/Session.rb +1 -1
  144. data/lib/Ice/BuiltinSequences.rb +1 -1
  145. data/lib/Ice/Communicator.rb +1 -1
  146. data/lib/Ice/CommunicatorF.rb +1 -1
  147. data/lib/Ice/Connection.rb +1 -1
  148. data/lib/Ice/ConnectionF.rb +1 -1
  149. data/lib/Ice/Current.rb +1 -1
  150. data/lib/Ice/Endpoint.rb +1 -1
  151. data/lib/Ice/EndpointF.rb +1 -1
  152. data/lib/Ice/EndpointTypes.rb +1 -1
  153. data/lib/Ice/FacetMap.rb +1 -1
  154. data/lib/Ice/Identity.rb +1 -1
  155. data/lib/Ice/ImplicitContext.rb +1 -1
  156. data/lib/Ice/ImplicitContextF.rb +1 -1
  157. data/lib/Ice/Instrumentation.rb +1 -1
  158. data/lib/Ice/InstrumentationF.rb +1 -1
  159. data/lib/Ice/LocalException.rb +1 -1
  160. data/lib/Ice/Locator.rb +1 -1
  161. data/lib/Ice/LocatorF.rb +1 -1
  162. data/lib/Ice/Logger.rb +1 -1
  163. data/lib/Ice/LoggerF.rb +1 -1
  164. data/lib/Ice/Metrics.rb +1 -1
  165. data/lib/Ice/ObjectAdapterF.rb +1 -1
  166. data/lib/Ice/ObjectFactory.rb +1 -1
  167. data/lib/Ice/ObjectFactoryF.rb +1 -1
  168. data/lib/Ice/Plugin.rb +1 -1
  169. data/lib/Ice/PluginF.rb +1 -1
  170. data/lib/Ice/Process.rb +1 -1
  171. data/lib/Ice/ProcessF.rb +1 -1
  172. data/lib/Ice/Properties.rb +1 -1
  173. data/lib/Ice/PropertiesAdmin.rb +1 -1
  174. data/lib/Ice/PropertiesF.rb +1 -1
  175. data/lib/Ice/RemoteLogger.rb +1 -1
  176. data/lib/Ice/Router.rb +1 -1
  177. data/lib/Ice/RouterF.rb +1 -1
  178. data/lib/Ice/SliceChecksumDict.rb +1 -1
  179. data/lib/Ice/Version.rb +1 -1
  180. data/lib/IceBox/IceBox.rb +1 -1
  181. data/lib/IceGrid/Admin.rb +1 -1
  182. data/lib/IceGrid/Descriptor.rb +1 -1
  183. data/lib/IceGrid/Exception.rb +1 -1
  184. data/lib/IceGrid/FileParser.rb +1 -1
  185. data/lib/IceGrid/Locator.rb +1 -1
  186. data/lib/IceGrid/Observer.rb +1 -1
  187. data/lib/IceGrid/Query.rb +1 -1
  188. data/lib/IceGrid/Registry.rb +1 -1
  189. data/lib/IceGrid/Session.rb +1 -1
  190. data/lib/IceGrid/UserAccountMapper.rb +1 -1
  191. data/lib/IcePatch2/FileInfo.rb +1 -1
  192. data/lib/IcePatch2/FileServer.rb +1 -1
  193. data/lib/IceStorm/IceStorm.rb +1 -1
  194. data/lib/IceStorm/Metrics.rb +1 -1
  195. data/slice/Glacier2/PermissionsVerifier.ice +0 -3
  196. data/slice/Glacier2/Session.ice +2 -9
  197. data/slice/Ice/Communicator.ice +3 -3
  198. data/slice/Ice/ImplicitContext.ice +4 -5
  199. data/slice/Ice/Instrumentation.ice +26 -26
  200. data/slice/Ice/LocalException.ice +1 -1
  201. data/slice/Ice/Locator.ice +5 -3
  202. data/slice/Ice/Metrics.ice +1 -1
  203. data/slice/Ice/ObjectFactory.ice +0 -2
  204. data/slice/Ice/RemoteLogger.ice +32 -32
  205. data/slice/Ice/Router.ice +3 -0
  206. data/slice/IceGrid/Session.ice +5 -9
  207. data/slice/IceLocatorDiscovery/IceLocatorDiscovery.ice +7 -7
  208. data/slice/IcePatch2/FileServer.ice +28 -34
  209. metadata +30 -30
@@ -332,7 +332,7 @@ IceUtil::Cond::Cond()
332
332
  throw ThreadSyscallException(__FILE__, __LINE__, rc);
333
333
  }
334
334
 
335
- #if !defined(__hpux) && !defined(__APPLE__)
335
+ #if !defined(__hppa) && !defined(__APPLE__) && !defined(__FreeBSD__)
336
336
  rc = pthread_condattr_setclock(&attr, CLOCK_MONOTONIC);
337
337
  if(rc != 0)
338
338
  {
@@ -344,6 +344,14 @@ IceUtilInternal::FileLock::~FileLock()
344
344
  unlink(_path);
345
345
  }
346
346
 
347
+ #ifndef __MINGW32__
348
+ wstring
349
+ IceUtilInternal::streamFilename(const string& filename)
350
+ {
351
+ return stringToWstring(filename, IceUtil::getProcessStringConverter());
352
+ }
353
+ #endif
354
+
347
355
  IceUtilInternal::ifstream::ifstream()
348
356
  {
349
357
  }
@@ -104,14 +104,14 @@ public:
104
104
  // file.
105
105
  //
106
106
  FileLock(const std::string&);
107
-
107
+
108
108
  //
109
109
  // The destructor releases the lock and removes the file.
110
110
  //
111
111
  virtual ~FileLock();
112
-
112
+
113
113
  private:
114
-
114
+
115
115
  #ifdef _WIN32
116
116
  HANDLE _fd;
117
117
  #else
@@ -136,7 +136,7 @@ public:
136
136
 
137
137
  #if defined(_MSC_VER) && (_MSC_VER >= 1900)
138
138
  ifstream(const ifstream&) = delete;
139
- #endif
139
+ #endif
140
140
 
141
141
  private:
142
142
 
@@ -159,7 +159,7 @@ public:
159
159
 
160
160
  #if defined(_MSC_VER) && (_MSC_VER >= 1900)
161
161
  ofstream(const ofstream&) = delete;
162
- #endif
162
+ #endif
163
163
 
164
164
  private:
165
165
 
@@ -168,5 +168,18 @@ private:
168
168
  void open(const char*, std::ios_base::openmode mode = std::ios_base::out);
169
169
  };
170
170
 
171
+ //
172
+ // Use streamFilename to construct the filename given to std stream classes
173
+ // like ifstream and ofstream.
174
+ //
175
+ #if defined(_WIN32) && !defined(__MINGW32__)
176
+ ICE_UTIL_API std::wstring streamFilename(const std::string&);
177
+ #else
178
+ inline std::string streamFilename(const std::string& filename)
179
+ {
180
+ return filename;
181
+ }
182
+ #endif
183
+
171
184
  }
172
185
  #endif
@@ -93,7 +93,7 @@ IceUtilInternal::OutputBase::open(const string& s)
93
93
  // mismatches on case-insensitive OSs.
94
94
  //
95
95
  IceUtilInternal::unlink(s);
96
- _fout.open(s.c_str());
96
+ _fout.open(IceUtilInternal::streamFilename(s).c_str());
97
97
  }
98
98
 
99
99
  void
@@ -170,13 +170,13 @@ IceUtilInternal::OutputBase::currIndent()
170
170
  return _indent;
171
171
  }
172
172
 
173
- void
173
+ void
174
174
  IceUtilInternal::OutputBase::setIndent(int indentSize)
175
175
  {
176
- _indentSize = indentSize;
176
+ _indentSize = indentSize;
177
177
  }
178
178
 
179
- void
179
+ void
180
180
  IceUtilInternal::OutputBase::setUseTab(bool useTab)
181
181
  {
182
182
  _useTab = useTab;
@@ -552,7 +552,7 @@ IceUtilInternal::StartElement::StartElement(const string& name) :
552
552
  _name(name)
553
553
  {
554
554
  }
555
-
555
+
556
556
  const string&
557
557
  IceUtilInternal::StartElement::getName() const
558
558
  {
@@ -63,7 +63,7 @@ InitializeFrequency frequencyInitializer;
63
63
  }
64
64
  #endif
65
65
 
66
- #ifdef __APPLE__
66
+ #if defined(__APPLE__)
67
67
  namespace
68
68
  {
69
69
 
@@ -137,7 +137,7 @@ IceUtil::Time::now(Clock clock)
137
137
  # endif
138
138
  return Time(static_cast<Int64>(tb.time) * ICE_INT64(1000000) + tb.millitm * 1000);
139
139
  }
140
- #elif defined(__hpux)
140
+ #elif defined(__hppa)
141
141
  //
142
142
  // HP does not support CLOCK_MONOTONIC
143
143
  //
@@ -247,22 +247,8 @@ IceUtil::Time::toMicroSecondsDouble() const
247
247
  std::string
248
248
  IceUtil::Time::toDateTime() const
249
249
  {
250
- time_t time = static_cast<long>(_usec / 1000000);
251
-
252
- struct tm* t;
253
- #ifdef _WIN32
254
- t = localtime(&time);
255
- #else
256
- struct tm tr;
257
- localtime_r(&time, &tr);
258
- t = &tr;
259
- #endif
260
-
261
- char buf[32];
262
- strftime(buf, sizeof(buf), "%x %H:%M:%S", t);
263
-
264
250
  std::ostringstream os;
265
- os << buf << ".";
251
+ os << toString("%x %H:%M:%S") << ".";
266
252
  os.fill('0');
267
253
  os.width(3);
268
254
  os << static_cast<long>(_usec % 1000000 / 1000);
@@ -294,6 +280,28 @@ IceUtil::Time::toDuration() const
294
280
  return os.str();
295
281
  }
296
282
 
283
+ std::string
284
+ IceUtil::Time::toString(const std::string& format) const
285
+ {
286
+ time_t time = static_cast<long>(_usec / 1000000);
287
+
288
+ struct tm* t;
289
+ #ifdef _WIN32
290
+ t = localtime(&time);
291
+ #else
292
+ struct tm tr;
293
+ localtime_r(&time, &tr);
294
+ t = &tr;
295
+ #endif
296
+
297
+ char buf[32];
298
+ if(strftime(buf, sizeof(buf), format.c_str(), t) == 0)
299
+ {
300
+ return std::string();
301
+ }
302
+ return std::string(buf);
303
+ }
304
+
297
305
  Time::Time(Int64 usec) :
298
306
  _usec(usec)
299
307
  {
@@ -13,9 +13,9 @@
13
13
  #include <Slice/Util.h>
14
14
  #include <Slice/MD5.h>
15
15
  #include <IceUtil/Functional.h>
16
+ #include <IceUtil/FileUtil.h>
16
17
 
17
18
  #include <sys/types.h>
18
- #include <sys/stat.h>
19
19
  #include <string.h>
20
20
 
21
21
  #ifdef _WIN32
@@ -214,10 +214,8 @@ Slice::JavaOutput::openClass(const string& cls, const string& prefix, const stri
214
214
  path += dir.substr(start);
215
215
  }
216
216
 
217
- struct stat st;
218
- int result;
219
- result = stat(path.c_str(), &st);
220
- if(result == 0)
217
+ IceUtilInternal::structstat st;
218
+ if(!IceUtilInternal::stat(path, &st))
221
219
  {
222
220
  if(!(st.st_mode & S_IFDIR))
223
221
  {
@@ -228,12 +226,8 @@ Slice::JavaOutput::openClass(const string& cls, const string& prefix, const stri
228
226
  }
229
227
  continue;
230
228
  }
231
- #ifdef _WIN32
232
- result = _mkdir(path.c_str());
233
- #else
234
- result = ::mkdir(path.c_str(), S_IRWXU | S_IRWXG | S_IRWXO);
235
- #endif
236
- if(result != 0)
229
+
230
+ if(IceUtilInternal::mkdir(path, 0777) != 0)
237
231
  {
238
232
  ostringstream os;
239
233
  os << "cannot create directory `" << path << "': " << strerror(errno);
@@ -236,10 +236,10 @@ Slice::Preprocessor::preprocess(bool keepComments, const string& extraArgs)
236
236
  // process call _tempnam before any of them call fopen and
237
237
  // they will end up using the same tmp file.
238
238
  //
239
- char* name = _tempnam(0, ("slice-" + IceUtil::generateUUID()).c_str());
239
+ wchar_t* name = _wtempnam(0, IceUtil::stringToWstring("slice-" + IceUtil::generateUUID()).c_str());
240
240
  if(name)
241
241
  {
242
- _cppFile = name;
242
+ _cppFile = IceUtil::wstringToString(name);
243
243
  free(name);
244
244
  _cppHandle = IceUtilInternal::fopen(_cppFile, "w+");
245
245
  }
@@ -725,7 +725,7 @@ Slice::Preprocessor::checkInputFile()
725
725
  return false;
726
726
  }
727
727
 
728
- ifstream test(_fileName.c_str());
728
+ IceUtilInternal::ifstream test(_fileName);
729
729
  if(!test)
730
730
  {
731
731
  getErrorStream() << _path << ": error: cannot open `" << _fileName << "' for reading" << endl;
@@ -187,10 +187,8 @@ PackageVisitor::visitModuleEnd(const ModulePtr& p)
187
187
  void
188
188
  PackageVisitor::createDirectory(const string& dir)
189
189
  {
190
- struct stat st;
191
- int result;
192
- result = stat(dir.c_str(), &st);
193
- if(result == 0)
190
+ IceUtilInternal::structstat st;
191
+ if(!IceUtilInternal::stat(dir, &st))
194
192
  {
195
193
  if(!(st.st_mode & S_IFDIR))
196
194
  {
@@ -201,13 +199,8 @@ PackageVisitor::createDirectory(const string& dir)
201
199
  }
202
200
  return;
203
201
  }
204
- #ifdef _WIN32
205
- result = _mkdir(dir.c_str());
206
- #else
207
- result = mkdir(dir.c_str(), S_IRWXU | S_IRWXG | S_IRWXO);
208
- #endif
209
202
 
210
- if(result != 0)
203
+ if(IceUtilInternal::mkdir(dir, 0777) != 0)
211
204
  {
212
205
  ostringstream os;
213
206
  os << "cannot create directory `" << dir << "': " << strerror(errno);
@@ -254,10 +247,10 @@ PackageVisitor::readInit(const string& dir, StringList& modules, StringList& sub
254
247
  {
255
248
  string initPath = dir + "/__init__.py";
256
249
 
257
- struct stat st;
258
- if(stat(initPath.c_str(), &st) == 0)
250
+ IceUtilInternal::structstat st;
251
+ if(!IceUtilInternal::stat(initPath, &st))
259
252
  {
260
- ifstream in(initPath.c_str());
253
+ IceUtilInternal::ifstream in(initPath);
261
254
  if(!in)
262
255
  {
263
256
  ostringstream os;
@@ -358,7 +351,7 @@ PackageVisitor::writeInit(const string& dir, const string& name, const StringLis
358
351
  {
359
352
  string initPath = dir + "/__init__.py";
360
353
 
361
- ofstream os(initPath.c_str());
354
+ IceUtilInternal::ofstream os(initPath);
362
355
  if(!os)
363
356
  {
364
357
  ostringstream os;
@@ -388,7 +381,7 @@ PackageVisitor::writeInit(const string& dir, const string& name, const StringLis
388
381
  }
389
382
 
390
383
  void
391
- usage(const char* n)
384
+ usage(const string& n)
392
385
  {
393
386
  getErrorStream() << "Usage: " << n << " [options] slice-files...\n";
394
387
  getErrorStream() <<
@@ -416,7 +409,7 @@ usage(const char* n)
416
409
  }
417
410
 
418
411
  int
419
- Slice::Python::compile(int argc, char* argv[])
412
+ Slice::Python::compile(const vector<string>& argv)
420
413
  {
421
414
  IceUtilInternal::Options opts;
422
415
  opts.addOpt("h", "help");
@@ -441,7 +434,7 @@ Slice::Python::compile(int argc, char* argv[])
441
434
  vector<string> args;
442
435
  try
443
436
  {
444
- args = opts.parse(argc, const_cast<const char**>(argv));
437
+ args = opts.parse(argv);
445
438
  }
446
439
  catch(const IceUtilInternal::BadOptException& e)
447
440
  {
@@ -665,6 +658,10 @@ Slice::Python::compile(int argc, char* argv[])
665
658
  }
666
659
  FileTracker::instance()->addFile(file);
667
660
 
661
+ //
662
+ // Python magic comment to set the file encoding, it must be first or second line
663
+ //
664
+ out << "# -*- coding: utf-8 -*-\n";
668
665
  printHeader(out);
669
666
  printGeneratedHeader(out, base + ".ice", "#");
670
667
  //
@@ -196,6 +196,44 @@ private:
196
196
  }
197
197
  }
198
198
 
199
+ string
200
+ u32CodePoint(unsigned int value)
201
+ {
202
+ ostringstream s;
203
+ s << "\\U";
204
+ s << hex;
205
+ s.width(8);
206
+ s.fill('0');
207
+ s << value;
208
+ return s.str();
209
+ }
210
+
211
+ void
212
+ writeU8Buffer(const vector<unsigned char>& u8buffer, ostringstream& out)
213
+ {
214
+ vector<unsigned int> u32buffer;
215
+ IceUtilInternal::ConversionResult result = convertUTF8ToUTF32(u8buffer, u32buffer, IceUtil::lenientConversion);
216
+ switch(result)
217
+ {
218
+ case conversionOK:
219
+ break;
220
+ case sourceExhausted:
221
+ throw IceUtil::IllegalConversionException(__FILE__, __LINE__, "string source exhausted");
222
+ case sourceIllegal:
223
+ throw IceUtil::IllegalConversionException(__FILE__, __LINE__, "string source illegal");
224
+ default:
225
+ {
226
+ assert(0);
227
+ throw IceUtil::IllegalConversionException(__FILE__, __LINE__);
228
+ }
229
+ }
230
+
231
+ for(vector<unsigned int>::const_iterator c = u32buffer.begin(); c != u32buffer.end(); ++c)
232
+ {
233
+ out << u32CodePoint(*c);
234
+ }
235
+ }
236
+
199
237
  static string
200
238
  lookupKwd(const string& name)
201
239
  {
@@ -518,17 +556,7 @@ Slice::Python::CodeVisitor::visitClassDefStart(const ClassDefPtr& p)
518
556
  //
519
557
  ClassList allBases = p->allBases();
520
558
  StringList ids;
521
- #if defined(__IBMCPP__) && defined(NDEBUG)
522
- //
523
- // VisualAge C++ 6.0 does not see that ClassDef is a Contained,
524
- // when inlining is on. The code below issues a warning: better
525
- // than an error!
526
- //
527
- transform(allBases.begin(), allBases.end(), back_inserter(ids),
528
- IceUtil::constMemFun<string,ClassDef>(&Contained::scoped));
529
- #else
530
559
  transform(allBases.begin(), allBases.end(), back_inserter(ids), IceUtil::constMemFun(&Contained::scoped));
531
- #endif
532
560
  StringList other;
533
561
  other.push_back(scoped);
534
562
  other.push_back("::Ice::Object");
@@ -1847,6 +1875,9 @@ Slice::Python::CodeVisitor::writeConstantValue(const TypePtr& type, const Syntax
1847
1875
  }
1848
1876
  case Slice::Builtin::KindString:
1849
1877
  {
1878
+ ostringstream sv2;
1879
+ ostringstream sv3;
1880
+
1850
1881
  //
1851
1882
  // Expand strings into the basic source character set. We can't use isalpha() and the like
1852
1883
  // here because they are sensitive to the current locale.
@@ -1857,8 +1888,6 @@ Slice::Python::CodeVisitor::writeConstantValue(const TypePtr& type, const Syntax
1857
1888
  "_{}[]#()<>%:;.?*+-/^&|~!=, '";
1858
1889
  static const set<char> charSet(basicSourceChars.begin(), basicSourceChars.end());
1859
1890
 
1860
- _out << "\""; // Opening "
1861
-
1862
1891
  for(size_t i = 0; i < value.size();)
1863
1892
  {
1864
1893
  char c = value[i];
@@ -1866,7 +1895,7 @@ Slice::Python::CodeVisitor::writeConstantValue(const TypePtr& type, const Syntax
1866
1895
  {
1867
1896
  case '"':
1868
1897
  {
1869
- _out << "\\\"";
1898
+ sv2 << "\\\"";
1870
1899
  break;
1871
1900
  }
1872
1901
  case '\\':
@@ -1894,7 +1923,7 @@ Slice::Python::CodeVisitor::writeConstantValue(const TypePtr& type, const Syntax
1894
1923
  //
1895
1924
  // Convert codepoint to UTF8 bytes and write the escaped bytes
1896
1925
  //
1897
- _out << s.substr(0, s.size() - 1);
1926
+ sv2 << s.substr(0, s.size() - 1);
1898
1927
 
1899
1928
  size_t sz = value[j] == 'U' ? 8 : 4;
1900
1929
  string codepoint = value.substr(j + 1, sz);
@@ -1931,40 +1960,40 @@ Slice::Python::CodeVisitor::writeConstantValue(const TypePtr& type, const Syntax
1931
1960
  s << oct;
1932
1961
  s << static_cast<unsigned int>(*q);
1933
1962
  }
1934
- _out << s.str();
1963
+ sv2 << s.str();
1935
1964
 
1936
1965
  i = j + 1 + sz;
1937
1966
  }
1938
1967
  else
1939
1968
  {
1940
- _out << s;
1969
+ sv2 << s;
1941
1970
  i = j;
1942
1971
  }
1943
1972
  continue;
1944
1973
  }
1945
1974
  case '\r':
1946
1975
  {
1947
- _out << "\\r";
1976
+ sv2 << "\\r";
1948
1977
  break;
1949
1978
  }
1950
1979
  case '\n':
1951
1980
  {
1952
- _out << "\\n";
1981
+ sv2 << "\\n";
1953
1982
  break;
1954
1983
  }
1955
1984
  case '\t':
1956
1985
  {
1957
- _out << "\\t";
1986
+ sv2 << "\\t";
1958
1987
  break;
1959
1988
  }
1960
1989
  case '\b':
1961
1990
  {
1962
- _out << "\\b";
1991
+ sv2 << "\\b";
1963
1992
  break;
1964
1993
  }
1965
1994
  case '\f':
1966
1995
  {
1967
- _out << "\\f";
1996
+ sv2 << "\\f";
1968
1997
  break;
1969
1998
  }
1970
1999
  default:
@@ -1978,19 +2007,140 @@ Slice::Python::CodeVisitor::writeConstantValue(const TypePtr& type, const Syntax
1978
2007
  s.width(3);
1979
2008
  s.fill('0');
1980
2009
  s << static_cast<unsigned>(uc);
1981
- _out << s.str();
2010
+ sv2 << s.str();
1982
2011
  }
1983
2012
  else
1984
2013
  {
1985
- _out << c; // Print normally if in basic source character set.
2014
+ sv2 << c; // Print normally if in basic source character set.
1986
2015
  }
1987
2016
  break;
1988
2017
  }
1989
2018
  }
1990
2019
  ++i;
1991
2020
  }
2021
+
2022
+ vector<unsigned char> u8buffer; // Buffer to convert multibyte characters
2023
+
2024
+ for(size_t i = 0; i < value.size();)
2025
+ {
2026
+ if(charSet.find(value[i]) == charSet.end())
2027
+ {
2028
+ char c = value[i];
2029
+ if(static_cast<unsigned char>(c) < 128) // Single byte character
2030
+ {
2031
+ //
2032
+ // Print as unicode if not in basic source character set
2033
+ //
2034
+ switch(c)
2035
+ {
2036
+ //
2037
+ // Don't encode this special characters as universal characters
2038
+ //
2039
+ case '\r':
2040
+ {
2041
+ sv3 << "\\r";
2042
+ break;
2043
+ }
2044
+ case '\n':
2045
+ {
2046
+ sv3 << "\\n";
2047
+ break;
2048
+ }
2049
+ case '\\':
2050
+ {
2051
+ sv3 << "\\";
2052
+ break;
2053
+ }
2054
+ default:
2055
+ {
2056
+ sv3 << u32CodePoint(c);
2057
+ break;
2058
+ }
2059
+ }
2060
+ }
2061
+ else
2062
+ {
2063
+ u8buffer.push_back(value[i]);
2064
+ }
2065
+ }
2066
+ else
2067
+ {
2068
+ //
2069
+ // Write any pedding characters in the utf8 buffer
2070
+ //
2071
+ if(!u8buffer.empty())
2072
+ {
2073
+ writeU8Buffer(u8buffer, sv3);
2074
+ u8buffer.clear();
2075
+ }
2076
+ switch(value[i])
2077
+ {
2078
+ case '\\':
2079
+ {
2080
+ string s = "\\";
2081
+ size_t j = i + 1;
2082
+ for(; j < value.size(); ++j)
2083
+ {
2084
+ if(value[j] != '\\')
2085
+ {
2086
+ break;
2087
+ }
2088
+ s += "\\";
2089
+ }
2090
+
2091
+ //
2092
+ // An even number of slash \ will escape the backslash and
2093
+ // the codepoint will be interpreted as its charaters
2094
+ //
2095
+ // \\U00000041 - ['\\', 'U', '0', '0', '0', '0', '0', '0', '4', '1']
2096
+ // \\\U00000041 - ['\\', 'A'] (41 is the codepoint for 'A')
2097
+ //
2098
+ if(s.size() % 2 != 0 && (value[j] == 'U' || value[j] == 'u'))
2099
+ {
2100
+ size_t sz = value[j] == 'U' ? 8 : 4;
2101
+ sv3 << s.substr(0, s.size() - 1);
2102
+ i = j + 1;
2103
+
2104
+ string codepoint = value.substr(j + 1, sz);
2105
+ assert(codepoint.size() == sz);
2106
+
2107
+ IceUtil::Int64 v = IceUtilInternal::strToInt64(codepoint.c_str(), 0, 16);
2108
+ sv3 << u32CodePoint(static_cast<unsigned int>(v));
2109
+ i = j + 1 + sz;
2110
+ }
2111
+ else
2112
+ {
2113
+ sv3 << s;
2114
+ i = j;
2115
+ }
2116
+ continue;
2117
+ }
2118
+ case '"':
2119
+ {
2120
+ sv3 << "\\";
2121
+ break;
2122
+ }
2123
+ }
2124
+ sv3 << value[i]; // Print normally if in basic source character set
2125
+ }
2126
+ i++;
2127
+ }
2128
+
2129
+ //
2130
+ // Write any pedding characters in the utf8 buffer
2131
+ //
2132
+ if(!u8buffer.empty())
2133
+ {
2134
+ writeU8Buffer(u8buffer, sv3);
2135
+ u8buffer.clear();
2136
+ }
2137
+
1992
2138
 
1993
- _out << "\""; // Closing "
2139
+ _out << "\"" << sv2.str() << "\"";
2140
+ if(sv2.str() != sv3.str())
2141
+ {
2142
+ _out << " if _version_info_[0] < 3 else \"" << sv3.str() << "\"";
2143
+ }
1994
2144
  break;
1995
2145
  }
1996
2146
  case Slice::Builtin::KindObject:
@@ -2291,14 +2441,10 @@ Slice::Python::CodeVisitor::writeDocstring(const string& comment, const string&
2291
2441
 
2292
2442
  for(StringVec::const_iterator q = lines.begin(); q != lines.end(); ++q)
2293
2443
  {
2294
- if(q != lines.begin())
2295
- {
2296
- _out << nl;
2297
- }
2298
- _out << *q;
2444
+ _out << nl << *q;
2299
2445
  }
2300
2446
 
2301
- _out << "\"\"\"";
2447
+ _out << nl << "\"\"\"";
2302
2448
  }
2303
2449
 
2304
2450
  void
@@ -2314,11 +2460,7 @@ Slice::Python::CodeVisitor::writeDocstring(const string& comment, const DataMemb
2314
2460
 
2315
2461
  for(StringVec::const_iterator q = lines.begin(); q != lines.end(); ++q)
2316
2462
  {
2317
- if(q != lines.begin())
2318
- {
2319
- _out << nl;
2320
- }
2321
- _out << *q;
2463
+ _out << nl << *q;
2322
2464
  }
2323
2465
 
2324
2466
  if(!members.empty())
@@ -2360,7 +2502,7 @@ Slice::Python::CodeVisitor::writeDocstring(const string& comment, const DataMemb
2360
2502
  }
2361
2503
  }
2362
2504
 
2363
- _out << "\"\"\"";
2505
+ _out << nl << "\"\"\"";
2364
2506
  }
2365
2507
 
2366
2508
  void
@@ -2376,11 +2518,7 @@ Slice::Python::CodeVisitor::writeDocstring(const string& comment, const Enumerat
2376
2518
 
2377
2519
  for(StringVec::const_iterator q = lines.begin(); q != lines.end(); ++q)
2378
2520
  {
2379
- if(q != lines.begin())
2380
- {
2381
- _out << nl;
2382
- }
2383
- _out << *q;
2521
+ _out << nl << *q;
2384
2522
  }
2385
2523
 
2386
2524
  if(!enums.empty())
@@ -2422,7 +2560,7 @@ Slice::Python::CodeVisitor::writeDocstring(const string& comment, const Enumerat
2422
2560
  }
2423
2561
  }
2424
2562
 
2425
- _out << "\"\"\"";
2563
+ _out << nl << "\"\"\"";
2426
2564
  }
2427
2565
 
2428
2566
  bool
@@ -2665,11 +2803,7 @@ Slice::Python::CodeVisitor::writeDocstring(const OperationPtr& op, DocstringMode
2665
2803
  {
2666
2804
  for(StringVec::const_iterator q = comment.description.begin(); q != comment.description.end(); ++q)
2667
2805
  {
2668
- if(q != comment.description.begin())
2669
- {
2670
- _out << nl;
2671
- }
2672
- _out << *q;
2806
+ _out << nl << *q;
2673
2807
  }
2674
2808
  }
2675
2809
 
@@ -2798,7 +2932,7 @@ Slice::Python::CodeVisitor::writeDocstring(const OperationPtr& op, DocstringMode
2798
2932
  _out << nl << r->first << " -- " << r->second;
2799
2933
  }
2800
2934
  }
2801
- _out << "\"\"\"";
2935
+ _out << nl << "\"\"\"";
2802
2936
  }
2803
2937
 
2804
2938
  void
@@ -2807,6 +2941,7 @@ Slice::Python::generate(const UnitPtr& un, bool all, bool checksum, const vector
2807
2941
  Slice::Python::MetaDataVisitor visitor;
2808
2942
  un->visit(&visitor, false);
2809
2943
 
2944
+ out << nl << "from sys import version_info as _version_info_";
2810
2945
  out << nl << "import Ice, IcePy";
2811
2946
 
2812
2947
  if(!all)