zeroc-ice 3.6.5 → 3.7.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (777) hide show
  1. checksums.yaml +5 -5
  2. data/ICE_LICENSE +17 -17
  3. data/LICENSE +12 -12
  4. data/bin/slice2rb +1 -6
  5. data/ext/Communicator.cpp +223 -61
  6. data/ext/Communicator.h +1 -6
  7. data/ext/Config.h +23 -7
  8. data/ext/Connection.cpp +108 -76
  9. data/ext/Connection.h +4 -6
  10. data/ext/Endpoint.cpp +16 -54
  11. data/ext/Endpoint.h +1 -6
  12. data/ext/ImplicitContext.cpp +1 -10
  13. data/ext/ImplicitContext.h +1 -6
  14. data/ext/Init.cpp +4 -6
  15. data/ext/Logger.cpp +1 -6
  16. data/ext/Logger.h +1 -6
  17. data/ext/Operation.cpp +38 -54
  18. data/ext/Operation.h +1 -6
  19. data/ext/Properties.cpp +3 -8
  20. data/ext/Properties.h +1 -6
  21. data/ext/Proxy.cpp +111 -70
  22. data/ext/Proxy.h +1 -6
  23. data/ext/Slice.cpp +5 -20
  24. data/ext/Slice.h +1 -6
  25. data/ext/Types.cpp +313 -224
  26. data/ext/Types.h +118 -71
  27. data/ext/Util.cpp +69 -36
  28. data/ext/Util.h +117 -42
  29. data/ext/ValueFactoryManager.cpp +440 -0
  30. data/ext/ValueFactoryManager.h +95 -0
  31. data/ext/extconf.rb +52 -48
  32. data/ext/ice/cpp/include/Ice/Application.h +275 -105
  33. data/ext/ice/cpp/include/Ice/AsyncResult.h +124 -337
  34. data/ext/ice/cpp/include/Ice/AsyncResultF.h +4 -7
  35. data/ext/ice/cpp/include/Ice/BatchRequestInterceptor.h +39 -16
  36. data/ext/ice/cpp/include/Ice/BatchRequestQueueF.h +1 -6
  37. data/ext/ice/cpp/include/Ice/Buffer.h +10 -15
  38. data/ext/ice/cpp/include/Ice/CommunicatorAsync.h +56 -17
  39. data/ext/ice/cpp/include/Ice/Comparable.h +205 -0
  40. data/ext/ice/cpp/include/Ice/Config.h +16 -39
  41. data/ext/ice/cpp/include/Ice/ConnectionAsync.h +203 -16
  42. data/ext/ice/cpp/include/Ice/ConnectionIF.h +7 -6
  43. data/ext/ice/cpp/include/Ice/ConsoleUtil.h +23 -0
  44. data/ext/ice/cpp/include/Ice/DefaultValueFactory.h +57 -0
  45. data/ext/ice/cpp/include/Ice/DispatchInterceptor.h +20 -12
  46. data/ext/ice/cpp/include/Ice/Dispatcher.h +35 -19
  47. data/ext/ice/cpp/include/Ice/DynamicLibrary.h +7 -10
  48. data/ext/ice/cpp/include/Ice/DynamicLibraryF.h +1 -6
  49. data/ext/ice/cpp/include/Ice/Exception.h +110 -63
  50. data/ext/ice/cpp/include/Ice/ExceptionHelpers.h +74 -0
  51. data/ext/ice/cpp/include/Ice/FactoryTable.h +22 -18
  52. data/ext/ice/cpp/include/Ice/FactoryTableInit.h +28 -31
  53. data/ext/ice/cpp/include/Ice/Format.h +17 -18
  54. data/ext/ice/cpp/include/Ice/Functional.h +38 -38
  55. data/ext/ice/cpp/include/Ice/GCObject.h +9 -10
  56. data/ext/ice/cpp/include/Ice/Handle.h +6 -16
  57. data/ext/ice/cpp/include/Ice/Ice.h +9 -10
  58. data/ext/ice/cpp/include/Ice/IconvStringConverter.h +377 -0
  59. data/ext/ice/cpp/include/Ice/Incoming.h +132 -38
  60. data/ext/ice/cpp/include/Ice/IncomingAsync.h +109 -31
  61. data/ext/ice/cpp/include/Ice/IncomingAsyncF.h +7 -6
  62. data/ext/ice/cpp/include/Ice/Initialize.h +872 -60
  63. data/ext/ice/cpp/include/Ice/InputStream.h +1514 -0
  64. data/ext/ice/cpp/include/Ice/InstanceF.h +1 -7
  65. data/ext/ice/cpp/include/Ice/InterfaceByValue.h +57 -0
  66. data/ext/ice/cpp/include/Ice/LocalObject.h +13 -14
  67. data/ext/ice/cpp/include/Ice/LocalObjectF.h +1 -6
  68. data/ext/ice/cpp/include/Ice/LoggerUtil.h +56 -24
  69. data/ext/ice/cpp/include/Ice/MetricsAdminI.h +124 -71
  70. data/ext/ice/cpp/include/Ice/MetricsFunctional.h +25 -10
  71. data/ext/ice/cpp/include/Ice/MetricsObserverI.h +116 -32
  72. data/ext/ice/cpp/include/Ice/NativePropertiesAdmin.h +61 -30
  73. data/ext/ice/cpp/include/Ice/Object.h +413 -78
  74. data/ext/ice/cpp/include/Ice/ObjectF.h +12 -8
  75. data/ext/ice/cpp/include/Ice/ObserverHelper.h +18 -13
  76. data/ext/ice/cpp/include/Ice/Optional.h +1114 -0
  77. data/ext/ice/cpp/include/Ice/OutgoingAsync.h +684 -89
  78. data/ext/ice/cpp/include/Ice/OutgoingAsyncF.h +12 -11
  79. data/ext/ice/cpp/include/Ice/OutputStream.h +1092 -0
  80. data/ext/ice/cpp/include/Ice/Protocol.h +49 -17
  81. data/ext/ice/cpp/include/Ice/Proxy.h +3438 -745
  82. data/ext/ice/cpp/include/Ice/ProxyF.h +13 -38
  83. data/ext/ice/cpp/include/Ice/ProxyFactoryF.h +1 -6
  84. data/ext/ice/cpp/include/Ice/ProxyHandle.h +43 -55
  85. data/ext/ice/cpp/include/Ice/ReferenceF.h +1 -6
  86. data/ext/ice/cpp/include/Ice/RegisterPlugins.h +84 -12
  87. data/ext/ice/cpp/include/Ice/RequestHandlerF.h +10 -9
  88. data/ext/ice/cpp/include/Ice/ResponseHandlerF.h +6 -6
  89. data/ext/ice/cpp/include/Ice/SHA1.h +42 -0
  90. data/ext/ice/cpp/include/Ice/ServantManagerF.h +1 -6
  91. data/ext/ice/cpp/include/Ice/Service.h +273 -154
  92. data/ext/ice/cpp/include/Ice/SliceChecksums.h +5 -6
  93. data/ext/ice/cpp/include/Ice/SlicedData.h +121 -53
  94. data/ext/ice/cpp/include/Ice/SlicedDataF.h +17 -11
  95. data/ext/ice/cpp/include/Ice/StreamHelpers.h +453 -140
  96. data/ext/ice/cpp/include/Ice/StringConverter.h +78 -0
  97. data/ext/ice/cpp/include/Ice/ThreadPoolF.h +1 -6
  98. data/ext/ice/cpp/include/Ice/UUID.h +19 -0
  99. data/ext/ice/cpp/include/{IceUtil → Ice}/UniquePtr.h +22 -28
  100. data/ext/ice/cpp/include/Ice/UniqueRef.h +97 -0
  101. data/ext/ice/cpp/include/Ice/UserExceptionFactory.h +45 -13
  102. data/ext/ice/cpp/include/Ice/Value.h +139 -0
  103. data/ext/ice/cpp/include/Ice/ValueF.h +21 -0
  104. data/ext/ice/cpp/include/IceSSL/Config.h +8 -28
  105. data/ext/ice/cpp/include/IceSSL/IceSSL.h +17 -11
  106. data/ext/ice/cpp/include/IceSSL/OpenSSL.h +147 -0
  107. data/ext/ice/cpp/include/IceSSL/Plugin.h +461 -448
  108. data/ext/ice/cpp/include/IceSSL/SChannel.h +72 -0
  109. data/ext/ice/cpp/include/IceSSL/SecureTransport.h +72 -0
  110. data/ext/ice/cpp/include/IceSSL/UWP.h +62 -0
  111. data/ext/ice/cpp/include/IceUtil/Atomic.h +7 -14
  112. data/ext/ice/cpp/include/IceUtil/Cond.h +17 -23
  113. data/ext/ice/cpp/include/IceUtil/Config.h +166 -46
  114. data/ext/ice/cpp/include/IceUtil/ConsoleUtil.h +92 -0
  115. data/ext/ice/cpp/include/IceUtil/CountDownLatch.h +5 -10
  116. data/ext/ice/cpp/include/IceUtil/CtrlCHandler.h +63 -41
  117. data/ext/ice/cpp/include/IceUtil/DisableWarnings.h +5 -13
  118. data/ext/ice/cpp/include/IceUtil/Exception.h +284 -75
  119. data/ext/ice/cpp/include/IceUtil/FileUtil.h +143 -0
  120. data/ext/ice/cpp/include/IceUtil/Functional.h +4 -6
  121. data/ext/ice/cpp/include/IceUtil/Handle.h +11 -16
  122. data/ext/ice/cpp/include/IceUtil/IceUtil.h +4 -15
  123. data/ext/ice/cpp/include/IceUtil/InputUtil.h +3 -8
  124. data/ext/ice/cpp/include/IceUtil/Iterator.h +2 -7
  125. data/ext/ice/cpp/include/IceUtil/Lock.h +8 -15
  126. data/ext/ice/cpp/include/IceUtil/Monitor.h +1 -7
  127. data/ext/ice/cpp/include/IceUtil/Mutex.h +19 -23
  128. data/ext/ice/cpp/include/IceUtil/MutexProtocol.h +2 -7
  129. data/ext/ice/cpp/include/IceUtil/MutexPtrLock.h +4 -9
  130. data/ext/ice/cpp/include/IceUtil/MutexPtrTryLock.h +4 -9
  131. data/ext/ice/cpp/include/IceUtil/Optional.h +134 -23
  132. data/ext/ice/cpp/include/IceUtil/Options.h +17 -23
  133. data/ext/ice/cpp/include/IceUtil/OutputUtil.h +61 -37
  134. data/ext/ice/cpp/include/IceUtil/PopDisableWarnings.h +6 -11
  135. data/ext/ice/cpp/include/IceUtil/PushDisableWarnings.h +18 -15
  136. data/ext/ice/cpp/include/IceUtil/Random.h +39 -8
  137. data/ext/ice/cpp/include/IceUtil/RecMutex.h +7 -13
  138. data/ext/ice/cpp/include/IceUtil/ResourceConfig.h +53 -0
  139. data/ext/ice/cpp/include/IceUtil/ScannerConfig.h +10 -15
  140. data/ext/ice/cpp/include/IceUtil/ScopedArray.h +8 -7
  141. data/ext/ice/cpp/include/IceUtil/Shared.h +5 -12
  142. data/ext/ice/cpp/{src → include}/IceUtil/StopWatch.h +2 -7
  143. data/ext/ice/cpp/include/IceUtil/StringConverter.h +146 -126
  144. data/ext/ice/cpp/include/IceUtil/StringUtil.h +32 -26
  145. data/ext/ice/cpp/include/IceUtil/Thread.h +10 -17
  146. data/ext/ice/cpp/include/IceUtil/ThreadException.h +33 -47
  147. data/ext/ice/cpp/include/IceUtil/Time.h +3 -8
  148. data/ext/ice/cpp/include/IceUtil/Timer.h +18 -18
  149. data/ext/ice/cpp/include/IceUtil/UUID.h +6 -7
  150. data/ext/ice/cpp/include/IceUtil/UndefSysMacros.h +1 -6
  151. data/ext/ice/cpp/include/generated/Ice/BuiltinSequences.h +170 -0
  152. data/ext/ice/cpp/include/generated/Ice/Communicator.h +1156 -0
  153. data/ext/ice/cpp/include/{Ice → generated/Ice}/CommunicatorF.h +51 -16
  154. data/ext/ice/cpp/include/generated/Ice/Connection.h +1660 -0
  155. data/ext/ice/cpp/include/generated/Ice/ConnectionF.h +119 -0
  156. data/ext/ice/cpp/include/generated/Ice/Current.h +322 -0
  157. data/ext/ice/cpp/include/generated/Ice/Endpoint.h +943 -0
  158. data/ext/ice/cpp/include/generated/Ice/EndpointF.h +166 -0
  159. data/ext/ice/cpp/include/generated/Ice/EndpointTypes.h +118 -0
  160. data/ext/ice/cpp/include/{Ice → generated/Ice}/FacetMap.h +31 -15
  161. data/ext/ice/cpp/include/generated/Ice/Identity.h +264 -0
  162. data/ext/ice/cpp/include/generated/Ice/ImplicitContext.h +278 -0
  163. data/ext/ice/cpp/include/{Ice → generated/Ice}/ImplicitContextF.h +51 -16
  164. data/ext/ice/cpp/include/generated/Ice/Instrumentation.h +1143 -0
  165. data/ext/ice/cpp/include/generated/Ice/InstrumentationF.h +128 -0
  166. data/ext/ice/cpp/include/generated/Ice/LocalException.h +7041 -0
  167. data/ext/ice/cpp/include/generated/Ice/Locator.h +3850 -0
  168. data/ext/ice/cpp/include/generated/Ice/LocatorF.h +147 -0
  169. data/ext/ice/cpp/include/generated/Ice/Logger.h +231 -0
  170. data/ext/ice/cpp/include/{Ice → generated/Ice}/LoggerF.h +51 -16
  171. data/ext/ice/cpp/include/generated/Ice/Metrics.h +4717 -0
  172. data/ext/ice/cpp/include/generated/Ice/ObjectAdapter.h +1175 -0
  173. data/ext/ice/cpp/include/{Ice → generated/Ice}/ObjectAdapterF.h +51 -16
  174. data/ext/ice/cpp/include/generated/Ice/ObjectFactory.h +197 -0
  175. data/ext/ice/cpp/include/generated/Ice/Plugin.h +306 -0
  176. data/ext/ice/cpp/include/generated/Ice/PluginF.h +110 -0
  177. data/ext/ice/cpp/include/generated/Ice/Process.h +971 -0
  178. data/ext/ice/cpp/include/generated/Ice/ProcessF.h +125 -0
  179. data/ext/ice/cpp/include/generated/Ice/Properties.h +446 -0
  180. data/ext/ice/cpp/include/generated/Ice/PropertiesAdmin.h +1360 -0
  181. data/ext/ice/cpp/include/generated/Ice/PropertiesF.h +134 -0
  182. data/ext/ice/cpp/include/generated/Ice/RemoteLogger.h +2689 -0
  183. data/ext/ice/cpp/include/generated/Ice/Router.h +1838 -0
  184. data/ext/ice/cpp/include/generated/Ice/RouterF.h +125 -0
  185. data/ext/ice/cpp/include/generated/Ice/ServantLocator.h +299 -0
  186. data/ext/ice/cpp/include/{Ice → generated/Ice}/ServantLocatorF.h +51 -16
  187. data/ext/ice/cpp/include/{Ice → generated/Ice}/SliceChecksumDict.h +34 -14
  188. data/ext/ice/cpp/include/generated/Ice/ValueFactory.h +318 -0
  189. data/ext/ice/cpp/include/generated/Ice/Version.h +357 -0
  190. data/ext/ice/cpp/include/generated/IceSSL/ConnectionInfo.h +223 -0
  191. data/ext/ice/cpp/include/generated/IceSSL/ConnectionInfoF.h +101 -0
  192. data/ext/ice/cpp/include/generated/IceSSL/EndpointInfo.h +181 -0
  193. data/ext/ice/cpp/src/Ice/ACM.cpp +38 -27
  194. data/ext/ice/cpp/src/Ice/ACM.h +9 -7
  195. data/ext/ice/cpp/src/Ice/ACMF.h +30 -0
  196. data/ext/ice/cpp/src/Ice/Acceptor.cpp +6 -6
  197. data/ext/ice/cpp/src/Ice/Acceptor.h +4 -8
  198. data/ext/ice/cpp/src/Ice/AcceptorF.h +1 -6
  199. data/ext/ice/cpp/src/Ice/ArgVector.cpp +59 -0
  200. data/ext/ice/cpp/src/Ice/ArgVector.h +36 -0
  201. data/ext/ice/cpp/src/Ice/AsyncResult.cpp +15 -544
  202. data/ext/ice/cpp/src/Ice/Base64.cpp +22 -28
  203. data/ext/ice/cpp/src/Ice/Base64.h +1 -6
  204. data/ext/ice/cpp/src/Ice/BatchRequestQueue.cpp +41 -18
  205. data/ext/ice/cpp/src/Ice/BatchRequestQueue.h +15 -15
  206. data/ext/ice/cpp/src/Ice/Buffer.cpp +75 -18
  207. data/ext/ice/cpp/src/Ice/BuiltinSequences.cpp +21 -12
  208. data/ext/ice/cpp/src/Ice/CollocatedRequestHandler.cpp +86 -197
  209. data/ext/ice/cpp/src/Ice/CollocatedRequestHandler.h +17 -23
  210. data/ext/ice/cpp/src/Ice/Communicator.cpp +43 -15
  211. data/ext/ice/cpp/src/Ice/CommunicatorF.cpp +28 -11
  212. data/ext/ice/cpp/src/Ice/CommunicatorI.cpp +318 -117
  213. data/ext/ice/cpp/src/Ice/CommunicatorI.h +95 -40
  214. data/ext/ice/cpp/src/{IceUtil → Ice}/Cond.cpp +3 -8
  215. data/ext/ice/cpp/src/Ice/ConnectRequestHandler.cpp +55 -122
  216. data/ext/ice/cpp/src/Ice/ConnectRequestHandler.h +15 -31
  217. data/ext/ice/cpp/src/Ice/ConnectRequestHandlerF.h +6 -7
  218. data/ext/ice/cpp/src/Ice/Connection.cpp +111 -20
  219. data/ext/ice/cpp/src/Ice/ConnectionF.cpp +28 -11
  220. data/ext/ice/cpp/src/Ice/ConnectionFactory.cpp +300 -107
  221. data/ext/ice/cpp/src/Ice/ConnectionFactory.h +44 -28
  222. data/ext/ice/cpp/src/Ice/ConnectionFactoryF.h +30 -0
  223. data/ext/ice/cpp/src/Ice/ConnectionI.cpp +785 -713
  224. data/ext/ice/cpp/src/Ice/ConnectionI.h +105 -80
  225. data/ext/ice/cpp/src/Ice/ConnectionRequestHandler.cpp +2 -20
  226. data/ext/ice/cpp/src/Ice/ConnectionRequestHandler.h +5 -9
  227. data/ext/ice/cpp/src/Ice/Connector.cpp +6 -6
  228. data/ext/ice/cpp/src/Ice/Connector.h +4 -8
  229. data/ext/ice/cpp/src/Ice/ConnectorF.h +1 -6
  230. data/ext/ice/cpp/src/{IceUtil → Ice}/CountDownLatch.cpp +4 -9
  231. data/ext/ice/cpp/src/Ice/Current.cpp +30 -12
  232. data/ext/ice/cpp/src/Ice/DefaultsAndOverrides.cpp +10 -16
  233. data/ext/ice/cpp/src/Ice/DefaultsAndOverrides.h +1 -6
  234. data/ext/ice/cpp/src/Ice/DefaultsAndOverridesF.h +1 -6
  235. data/ext/ice/cpp/src/Ice/DispatchInterceptor.cpp +13 -25
  236. data/ext/ice/cpp/src/Ice/DynamicLibrary.cpp +34 -28
  237. data/ext/ice/cpp/src/Ice/Endpoint.cpp +107 -19
  238. data/ext/ice/cpp/src/Ice/EndpointF.cpp +28 -11
  239. data/ext/ice/cpp/src/Ice/EndpointFactory.cpp +152 -6
  240. data/ext/ice/cpp/src/Ice/EndpointFactory.h +72 -11
  241. data/ext/ice/cpp/src/Ice/EndpointFactoryF.h +1 -6
  242. data/ext/ice/cpp/src/Ice/EndpointFactoryManager.cpp +41 -36
  243. data/ext/ice/cpp/src/Ice/EndpointFactoryManager.h +10 -9
  244. data/ext/ice/cpp/src/Ice/EndpointFactoryManagerF.h +1 -6
  245. data/ext/ice/cpp/src/Ice/EndpointI.cpp +18 -7
  246. data/ext/ice/cpp/src/Ice/EndpointI.h +39 -18
  247. data/ext/ice/cpp/src/Ice/EndpointIF.h +18 -10
  248. data/ext/ice/cpp/src/Ice/EndpointTypes.cpp +19 -12
  249. data/ext/ice/cpp/src/Ice/EventHandler.cpp +6 -9
  250. data/ext/ice/cpp/src/Ice/EventHandler.h +13 -13
  251. data/ext/ice/cpp/src/Ice/EventHandlerF.h +5 -7
  252. data/ext/ice/cpp/src/Ice/Exception.cpp +102 -98
  253. data/ext/ice/cpp/src/Ice/FacetMap.cpp +21 -12
  254. data/ext/ice/cpp/src/Ice/FactoryTable.cpp +37 -33
  255. data/ext/ice/cpp/src/Ice/FactoryTableInit.cpp +2 -9
  256. data/ext/ice/cpp/src/Ice/GCObject.cpp +29 -31
  257. data/ext/ice/cpp/src/Ice/HashUtil.h +3 -9
  258. data/ext/ice/cpp/src/Ice/HttpParser.cpp +1 -7
  259. data/ext/ice/cpp/src/Ice/HttpParser.h +1 -6
  260. data/ext/ice/cpp/src/Ice/IPEndpointI.cpp +128 -111
  261. data/ext/ice/cpp/src/Ice/IPEndpointI.h +23 -19
  262. data/ext/ice/cpp/src/Ice/IPEndpointIF.h +6 -7
  263. data/ext/ice/cpp/src/Ice/IconvStringConverter.cpp +51 -0
  264. data/ext/ice/cpp/src/Ice/Identity.cpp +25 -16
  265. data/ext/ice/cpp/src/Ice/ImplicitContext.cpp +41 -13
  266. data/ext/ice/cpp/src/Ice/ImplicitContextF.cpp +28 -11
  267. data/ext/ice/cpp/src/Ice/ImplicitContextI.cpp +11 -28
  268. data/ext/ice/cpp/src/Ice/ImplicitContextI.h +7 -10
  269. data/ext/ice/cpp/src/Ice/Incoming.cpp +284 -255
  270. data/ext/ice/cpp/src/Ice/IncomingAsync.cpp +104 -214
  271. data/ext/ice/cpp/src/Ice/IncomingRequest.h +5 -9
  272. data/ext/ice/cpp/src/Ice/Initialize.cpp +309 -193
  273. data/ext/ice/cpp/src/Ice/InputStream.cpp +2726 -0
  274. data/ext/ice/cpp/src/Ice/Instance.cpp +243 -262
  275. data/ext/ice/cpp/src/Ice/Instance.h +30 -23
  276. data/ext/ice/cpp/src/Ice/Instrumentation.cpp +137 -23
  277. data/ext/ice/cpp/src/Ice/InstrumentationF.cpp +28 -11
  278. data/ext/ice/cpp/src/Ice/InstrumentationI.cpp +118 -105
  279. data/ext/ice/cpp/src/Ice/InstrumentationI.h +30 -36
  280. data/ext/ice/cpp/src/Ice/LocalException.cpp +1191 -422
  281. data/ext/ice/cpp/src/Ice/LocalObject.cpp +1 -7
  282. data/ext/ice/cpp/src/Ice/Locator.cpp +1282 -1222
  283. data/ext/ice/cpp/src/Ice/LocatorF.cpp +30 -12
  284. data/ext/ice/cpp/src/Ice/LocatorInfo.cpp +150 -186
  285. data/ext/ice/cpp/src/Ice/LocatorInfo.h +31 -36
  286. data/ext/ice/cpp/src/Ice/LocatorInfoF.h +1 -6
  287. data/ext/ice/cpp/src/Ice/Logger.cpp +39 -12
  288. data/ext/ice/cpp/src/Ice/LoggerAdminI.cpp +182 -88
  289. data/ext/ice/cpp/src/Ice/LoggerAdminI.h +4 -9
  290. data/ext/ice/cpp/src/Ice/LoggerF.cpp +28 -11
  291. data/ext/ice/cpp/src/Ice/LoggerI.cpp +26 -55
  292. data/ext/ice/cpp/src/Ice/LoggerI.h +7 -18
  293. data/ext/ice/cpp/src/Ice/LoggerUtil.cpp +10 -17
  294. data/ext/ice/cpp/src/Ice/Metrics.cpp +1280 -1107
  295. data/ext/ice/cpp/src/Ice/MetricsAdminI.cpp +58 -33
  296. data/ext/ice/cpp/src/Ice/MetricsObserverI.cpp +1 -7
  297. data/ext/ice/cpp/src/Ice/Network.cpp +753 -408
  298. data/ext/ice/cpp/src/Ice/Network.h +99 -36
  299. data/ext/ice/cpp/src/Ice/NetworkF.h +2 -7
  300. data/ext/ice/cpp/src/Ice/NetworkProxy.cpp +20 -19
  301. data/ext/ice/cpp/src/Ice/NetworkProxy.h +5 -7
  302. data/ext/ice/cpp/src/Ice/NetworkProxyF.h +1 -6
  303. data/ext/ice/cpp/src/Ice/OSLogLoggerI.cpp +57 -0
  304. data/ext/ice/cpp/src/Ice/OSLogLoggerI.h +40 -0
  305. data/ext/ice/cpp/src/Ice/Object.cpp +227 -232
  306. data/ext/ice/cpp/src/Ice/ObjectAdapter.cpp +45 -13
  307. data/ext/ice/cpp/src/Ice/ObjectAdapterF.cpp +28 -11
  308. data/ext/ice/cpp/src/Ice/ObjectAdapterFactory.cpp +83 -33
  309. data/ext/ice/cpp/src/Ice/ObjectAdapterFactory.h +13 -12
  310. data/ext/ice/cpp/src/Ice/ObjectAdapterFactoryF.h +25 -0
  311. data/ext/ice/cpp/src/Ice/ObjectAdapterI.cpp +298 -191
  312. data/ext/ice/cpp/src/Ice/ObjectAdapterI.h +44 -39
  313. data/ext/ice/cpp/src/Ice/ObjectFactory.cpp +41 -13
  314. data/ext/ice/cpp/src/Ice/ObserverHelper.cpp +9 -37
  315. data/ext/ice/cpp/src/Ice/OpaqueEndpointI.cpp +67 -67
  316. data/ext/ice/cpp/src/Ice/OpaqueEndpointI.h +15 -11
  317. data/ext/ice/cpp/src/Ice/OutgoingAsync.cpp +801 -366
  318. data/ext/ice/cpp/src/Ice/OutputStream.cpp +1367 -0
  319. data/ext/ice/cpp/src/Ice/Plugin.cpp +52 -14
  320. data/ext/ice/cpp/src/Ice/PluginF.cpp +28 -11
  321. data/ext/ice/cpp/src/Ice/PluginManagerI.cpp +27 -51
  322. data/ext/ice/cpp/src/Ice/PluginManagerI.h +7 -13
  323. data/ext/ice/cpp/src/Ice/Process.cpp +294 -128
  324. data/ext/ice/cpp/src/Ice/ProcessF.cpp +30 -12
  325. data/ext/ice/cpp/src/Ice/Properties.cpp +42 -15
  326. data/ext/ice/cpp/src/Ice/PropertiesAdmin.cpp +382 -340
  327. data/ext/ice/cpp/src/Ice/PropertiesAdminI.cpp +83 -24
  328. data/ext/ice/cpp/src/Ice/PropertiesAdminI.h +29 -10
  329. data/ext/ice/cpp/src/Ice/PropertiesF.cpp +30 -12
  330. data/ext/ice/cpp/src/Ice/PropertiesI.cpp +46 -57
  331. data/ext/ice/cpp/src/Ice/PropertiesI.h +18 -26
  332. data/ext/ice/cpp/src/Ice/PropertyNames.cpp +112 -19
  333. data/ext/ice/cpp/src/Ice/PropertyNames.h +4 -7
  334. data/ext/ice/cpp/src/Ice/Protocol.cpp +6 -19
  335. data/ext/ice/cpp/src/Ice/ProtocolInstance.cpp +37 -7
  336. data/ext/ice/cpp/src/Ice/ProtocolInstance.h +9 -25
  337. data/ext/ice/cpp/src/Ice/ProtocolInstanceF.h +1 -6
  338. data/ext/ice/cpp/src/Ice/ProtocolPluginFacade.cpp +6 -6
  339. data/ext/ice/cpp/src/Ice/ProtocolPluginFacade.h +3 -6
  340. data/ext/ice/cpp/src/Ice/ProtocolPluginFacadeF.h +1 -6
  341. data/ext/ice/cpp/src/Ice/Proxy.cpp +729 -957
  342. data/ext/ice/cpp/src/Ice/ProxyFactory.cpp +33 -38
  343. data/ext/ice/cpp/src/Ice/ProxyFactory.h +16 -16
  344. data/ext/ice/cpp/src/Ice/Reference.cpp +190 -106
  345. data/ext/ice/cpp/src/Ice/Reference.h +39 -28
  346. data/ext/ice/cpp/src/Ice/ReferenceFactory.cpp +69 -118
  347. data/ext/ice/cpp/src/Ice/ReferenceFactory.h +12 -17
  348. data/ext/ice/cpp/src/Ice/ReferenceFactoryF.h +1 -6
  349. data/ext/ice/cpp/src/Ice/RegisterPluginsInit.cpp +19 -9
  350. data/ext/ice/cpp/src/Ice/RegisterPluginsInit.h +1 -6
  351. data/ext/ice/cpp/src/Ice/RemoteLogger.cpp +766 -565
  352. data/ext/ice/cpp/src/Ice/ReplyStatus.h +1 -6
  353. data/ext/ice/cpp/src/Ice/RequestHandler.cpp +5 -8
  354. data/ext/ice/cpp/src/Ice/RequestHandler.h +10 -18
  355. data/ext/ice/cpp/src/Ice/RequestHandlerFactory.cpp +10 -11
  356. data/ext/ice/cpp/src/Ice/RequestHandlerFactory.h +2 -7
  357. data/ext/ice/cpp/src/Ice/ResponseHandler.cpp +3 -11
  358. data/ext/ice/cpp/src/Ice/ResponseHandler.h +16 -12
  359. data/ext/ice/cpp/src/Ice/RetryQueue.cpp +12 -20
  360. data/ext/ice/cpp/src/Ice/RetryQueue.h +7 -11
  361. data/ext/ice/cpp/src/Ice/RetryQueueF.h +1 -6
  362. data/ext/ice/cpp/src/Ice/Router.cpp +614 -492
  363. data/ext/ice/cpp/src/Ice/RouterF.cpp +30 -12
  364. data/ext/ice/cpp/src/Ice/RouterInfo.cpp +93 -99
  365. data/ext/ice/cpp/src/Ice/RouterInfo.h +42 -38
  366. data/ext/ice/cpp/src/Ice/RouterInfoF.h +1 -6
  367. data/ext/ice/cpp/src/{IceUtil → Ice}/SHA1.cpp +23 -28
  368. data/ext/ice/cpp/src/Ice/Selector.cpp +948 -855
  369. data/ext/ice/cpp/src/Ice/Selector.h +100 -152
  370. data/ext/ice/cpp/src/Ice/ServantLocator.cpp +41 -13
  371. data/ext/ice/cpp/src/Ice/ServantLocatorF.cpp +28 -11
  372. data/ext/ice/cpp/src/Ice/ServantManager.cpp +24 -45
  373. data/ext/ice/cpp/src/Ice/ServantManager.h +1 -6
  374. data/ext/ice/cpp/src/Ice/SharedContext.h +2 -7
  375. data/ext/ice/cpp/src/Ice/SliceChecksumDict.cpp +21 -12
  376. data/ext/ice/cpp/src/Ice/SliceChecksums.cpp +2 -7
  377. data/ext/ice/cpp/src/Ice/SlicedData.cpp +72 -25
  378. data/ext/ice/cpp/src/Ice/StreamSocket.cpp +208 -76
  379. data/ext/ice/cpp/src/Ice/StreamSocket.h +13 -9
  380. data/ext/ice/cpp/src/Ice/StringConverterPlugin.cpp +57 -22
  381. data/ext/ice/cpp/src/Ice/StringUtil.h +30 -0
  382. data/ext/ice/cpp/src/Ice/SysLoggerI.cpp +6 -7
  383. data/ext/ice/cpp/src/Ice/SysLoggerI.h +2 -8
  384. data/ext/ice/cpp/src/Ice/SystemdJournalI.cpp +66 -0
  385. data/ext/ice/cpp/src/Ice/SystemdJournalI.h +39 -0
  386. data/ext/ice/cpp/src/Ice/TcpAcceptor.cpp +169 -49
  387. data/ext/ice/cpp/src/Ice/TcpAcceptor.h +12 -10
  388. data/ext/ice/cpp/src/Ice/TcpConnector.cpp +6 -12
  389. data/ext/ice/cpp/src/Ice/TcpConnector.h +1 -7
  390. data/ext/ice/cpp/src/Ice/TcpEndpointI.cpp +51 -46
  391. data/ext/ice/cpp/src/Ice/TcpEndpointI.h +12 -14
  392. data/ext/ice/cpp/src/Ice/TcpTransceiver.cpp +17 -32
  393. data/ext/ice/cpp/src/Ice/TcpTransceiver.h +7 -15
  394. data/ext/ice/cpp/src/{IceUtil → Ice}/Thread.cpp +41 -54
  395. data/ext/ice/cpp/src/Ice/ThreadPool.cpp +242 -274
  396. data/ext/ice/cpp/src/Ice/ThreadPool.h +46 -48
  397. data/ext/ice/cpp/src/{IceUtil → Ice}/Timer.cpp +38 -26
  398. data/ext/ice/cpp/src/Ice/TraceLevels.cpp +2 -7
  399. data/ext/ice/cpp/src/Ice/TraceLevels.h +1 -6
  400. data/ext/ice/cpp/src/Ice/TraceLevelsF.h +2 -7
  401. data/ext/ice/cpp/src/Ice/TraceUtil.cpp +53 -36
  402. data/ext/ice/cpp/src/Ice/TraceUtil.h +13 -11
  403. data/ext/ice/cpp/src/Ice/Transceiver.cpp +1 -7
  404. data/ext/ice/cpp/src/Ice/Transceiver.h +8 -12
  405. data/ext/ice/cpp/src/Ice/TransceiverF.h +3 -8
  406. data/ext/ice/cpp/src/Ice/UdpConnector.cpp +5 -13
  407. data/ext/ice/cpp/src/Ice/UdpConnector.h +1 -7
  408. data/ext/ice/cpp/src/Ice/UdpEndpointI.cpp +118 -60
  409. data/ext/ice/cpp/src/Ice/UdpEndpointI.h +13 -10
  410. data/ext/ice/cpp/src/Ice/UdpTransceiver.cpp +177 -236
  411. data/ext/ice/cpp/src/Ice/UdpTransceiver.h +15 -22
  412. data/ext/ice/cpp/src/Ice/Value.cpp +76 -0
  413. data/ext/ice/cpp/src/Ice/ValueFactory.cpp +83 -0
  414. data/ext/ice/cpp/src/Ice/ValueFactoryManagerI.cpp +61 -0
  415. data/ext/ice/cpp/src/Ice/ValueFactoryManagerI.h +37 -0
  416. data/ext/ice/cpp/src/Ice/Version.cpp +25 -20
  417. data/ext/ice/cpp/src/Ice/VirtualShared.h +38 -0
  418. data/ext/ice/cpp/src/Ice/WSAcceptor.cpp +3 -14
  419. data/ext/ice/cpp/src/Ice/WSAcceptor.h +3 -12
  420. data/ext/ice/cpp/src/Ice/WSConnector.cpp +5 -16
  421. data/ext/ice/cpp/src/Ice/WSConnector.h +3 -11
  422. data/ext/ice/cpp/src/Ice/WSEndpoint.cpp +188 -89
  423. data/ext/ice/cpp/src/Ice/WSEndpoint.h +22 -37
  424. data/ext/ice/cpp/src/Ice/WSTransceiver.cpp +65 -66
  425. data/ext/ice/cpp/src/Ice/WSTransceiver.h +7 -27
  426. data/ext/ice/cpp/src/IceDiscovery/IceDiscovery.cpp +596 -281
  427. data/ext/ice/cpp/src/IceDiscovery/IceDiscovery.h +1383 -543
  428. data/ext/ice/cpp/src/IceDiscovery/LocatorI.cpp +89 -32
  429. data/ext/ice/cpp/src/IceDiscovery/LocatorI.h +59 -28
  430. data/ext/ice/cpp/src/IceDiscovery/LookupI.cpp +315 -66
  431. data/ext/ice/cpp/src/IceDiscovery/LookupI.h +83 -41
  432. data/ext/ice/cpp/src/IceDiscovery/PluginI.cpp +57 -64
  433. data/ext/ice/cpp/src/IceDiscovery/PluginI.h +3 -8
  434. data/ext/ice/cpp/src/IceLocatorDiscovery/IceLocatorDiscovery.cpp +450 -172
  435. data/ext/ice/cpp/src/IceLocatorDiscovery/IceLocatorDiscovery.h +863 -406
  436. data/ext/ice/cpp/src/IceLocatorDiscovery/Plugin.h +47 -0
  437. data/ext/ice/cpp/src/IceLocatorDiscovery/PluginI.cpp +636 -144
  438. data/ext/ice/cpp/src/IceSSL/AcceptorI.cpp +20 -173
  439. data/ext/ice/cpp/src/IceSSL/AcceptorI.h +8 -22
  440. data/ext/ice/cpp/src/IceSSL/CertificateI.cpp +279 -0
  441. data/ext/ice/cpp/src/IceSSL/CertificateI.h +64 -0
  442. data/ext/ice/cpp/src/IceSSL/ConnectionInfo.cpp +42 -17
  443. data/ext/ice/cpp/src/IceSSL/ConnectionInfoF.cpp +61 -0
  444. data/ext/ice/cpp/src/IceSSL/ConnectorI.cpp +15 -64
  445. data/ext/ice/cpp/src/IceSSL/ConnectorI.h +6 -18
  446. data/ext/ice/cpp/src/IceSSL/EndpointI.cpp +207 -204
  447. data/ext/ice/cpp/src/IceSSL/EndpointI.h +43 -40
  448. data/ext/ice/cpp/src/IceSSL/EndpointInfo.cpp +42 -16
  449. data/ext/ice/cpp/src/IceSSL/Instance.cpp +1 -11
  450. data/ext/ice/cpp/src/IceSSL/Instance.h +7 -12
  451. data/ext/ice/cpp/src/IceSSL/InstanceF.h +11 -12
  452. data/ext/ice/cpp/src/IceSSL/OpenSSLCertificateI.cpp +583 -0
  453. data/ext/ice/cpp/src/IceSSL/OpenSSLEngine.cpp +134 -115
  454. data/ext/ice/cpp/src/IceSSL/OpenSSLEngine.h +59 -0
  455. data/ext/ice/cpp/src/IceSSL/OpenSSLEngineF.h +27 -0
  456. data/ext/ice/cpp/src/IceSSL/OpenSSLPluginI.cpp +127 -0
  457. data/ext/ice/cpp/src/IceSSL/OpenSSLTransceiverI.cpp +477 -182
  458. data/ext/ice/cpp/src/IceSSL/OpenSSLTransceiverI.h +32 -26
  459. data/ext/ice/cpp/src/IceSSL/OpenSSLUtil.cpp +286 -0
  460. data/ext/ice/cpp/src/IceSSL/OpenSSLUtil.h +58 -0
  461. data/ext/ice/cpp/src/IceSSL/PluginI.cpp +71 -46
  462. data/ext/ice/cpp/src/IceSSL/PluginI.h +13 -23
  463. data/ext/ice/cpp/src/IceSSL/RFC2253.cpp +9 -60
  464. data/ext/ice/cpp/src/IceSSL/RFC2253.h +7 -12
  465. data/ext/ice/cpp/src/IceSSL/SChannelCertificateI.cpp +580 -0
  466. data/ext/ice/cpp/src/IceSSL/SChannelEngine.cpp +523 -74
  467. data/ext/ice/cpp/src/IceSSL/SChannelEngine.h +123 -0
  468. data/ext/ice/cpp/src/IceSSL/SChannelEngineF.h +31 -0
  469. data/ext/ice/cpp/src/IceSSL/SChannelPluginI.cpp +73 -0
  470. data/ext/ice/cpp/src/IceSSL/SChannelTransceiverI.cpp +187 -221
  471. data/ext/ice/cpp/src/IceSSL/SChannelTransceiverI.h +24 -26
  472. data/ext/ice/cpp/src/IceSSL/SSLEngine.cpp +97 -94
  473. data/ext/ice/cpp/src/IceSSL/SSLEngine.h +26 -192
  474. data/ext/ice/cpp/src/IceSSL/SSLEngineF.h +4 -24
  475. data/ext/ice/cpp/src/IceSSL/SecureTransportCertificateI.cpp +868 -0
  476. data/ext/ice/cpp/src/IceSSL/SecureTransportEngine.cpp +69 -201
  477. data/ext/ice/cpp/src/IceSSL/SecureTransportEngine.h +59 -0
  478. data/ext/ice/cpp/src/IceSSL/SecureTransportEngineF.h +29 -0
  479. data/ext/ice/cpp/src/IceSSL/SecureTransportPluginI.cpp +75 -0
  480. data/ext/ice/cpp/src/IceSSL/SecureTransportTransceiverI.cpp +174 -161
  481. data/ext/ice/cpp/src/IceSSL/SecureTransportTransceiverI.h +29 -33
  482. data/ext/ice/cpp/src/IceSSL/SecureTransportUtil.cpp +864 -0
  483. data/ext/ice/cpp/src/IceSSL/SecureTransportUtil.h +45 -0
  484. data/ext/ice/cpp/src/IceSSL/TrustManager.cpp +12 -22
  485. data/ext/ice/cpp/src/IceSSL/TrustManager.h +4 -9
  486. data/ext/ice/cpp/src/IceSSL/TrustManagerF.h +3 -8
  487. data/ext/ice/cpp/src/IceSSL/UWPCertificateI.cpp +266 -0
  488. data/ext/ice/cpp/src/IceSSL/UWPEngine.cpp +338 -0
  489. data/ext/ice/cpp/src/IceSSL/UWPEngine.h +41 -0
  490. data/ext/ice/cpp/src/IceSSL/UWPEngineF.h +26 -0
  491. data/ext/ice/cpp/src/IceSSL/UWPPluginI.cpp +89 -0
  492. data/ext/ice/cpp/src/IceSSL/UWPTransceiverI.cpp +383 -0
  493. data/ext/ice/cpp/src/IceSSL/UWPTransceiverI.h +71 -0
  494. data/ext/ice/cpp/src/IceSSL/Util.cpp +71 -1260
  495. data/ext/ice/cpp/src/IceSSL/Util.h +48 -142
  496. data/ext/ice/cpp/src/IceUtil/ConsoleUtil.cpp +157 -0
  497. data/ext/ice/cpp/src/IceUtil/ConvertUTF.cpp +22 -27
  498. data/ext/ice/cpp/src/IceUtil/ConvertUTF.h +34 -31
  499. data/ext/ice/cpp/src/IceUtil/CtrlCHandler.cpp +22 -36
  500. data/ext/ice/cpp/src/IceUtil/FileUtil.cpp +30 -126
  501. data/ext/ice/cpp/src/IceUtil/InputUtil.cpp +1 -6
  502. data/ext/ice/cpp/src/IceUtil/MutexProtocol.cpp +1 -6
  503. data/ext/ice/cpp/src/IceUtil/Options.cpp +20 -33
  504. data/ext/ice/cpp/src/IceUtil/OutputUtil.cpp +47 -21
  505. data/ext/ice/cpp/src/IceUtil/Random.cpp +15 -20
  506. data/ext/ice/cpp/src/IceUtil/RecMutex.cpp +4 -19
  507. data/ext/ice/cpp/src/IceUtil/Shared.cpp +8 -8
  508. data/ext/ice/cpp/src/IceUtil/StringConverter.cpp +501 -269
  509. data/ext/ice/cpp/src/IceUtil/StringUtil.cpp +582 -244
  510. data/ext/ice/cpp/src/IceUtil/ThreadException.cpp +37 -79
  511. data/ext/ice/cpp/src/IceUtil/Time.cpp +6 -11
  512. data/ext/ice/cpp/src/IceUtil/UUID.cpp +17 -22
  513. data/ext/ice/cpp/src/IceUtil/Unicode.cpp +97 -101
  514. data/ext/ice/cpp/src/IceUtil/Unicode.h +21 -40
  515. data/ext/ice/cpp/src/IceUtil/UtilException.cpp +839 -0
  516. data/ext/ice/cpp/src/Slice/CPlusPlusUtil.cpp +894 -234
  517. data/ext/ice/cpp/src/Slice/CPlusPlusUtil.h +72 -0
  518. data/ext/ice/cpp/src/Slice/Checksum.cpp +2 -7
  519. data/ext/ice/cpp/src/Slice/Checksum.h +21 -0
  520. data/ext/ice/cpp/src/Slice/FileTracker.cpp +25 -83
  521. data/ext/ice/cpp/{include → src}/Slice/FileTracker.h +9 -14
  522. data/ext/ice/cpp/src/Slice/Grammar.cpp +1981 -1944
  523. data/ext/ice/cpp/src/Slice/Grammar.h +39 -19
  524. data/ext/ice/cpp/src/Slice/GrammarUtil.h +14 -20
  525. data/ext/ice/cpp/src/Slice/JavaUtil.cpp +2752 -1948
  526. data/ext/ice/cpp/src/Slice/JavaUtil.h +398 -0
  527. data/ext/ice/cpp/src/Slice/MD5.cpp +1 -6
  528. data/ext/ice/cpp/src/Slice/MD5.h +1 -6
  529. data/ext/ice/cpp/src/Slice/MD5I.cpp +8 -1
  530. data/ext/ice/cpp/src/Slice/MD5I.h +1 -1
  531. data/ext/ice/cpp/src/Slice/PHPUtil.cpp +17 -20
  532. data/ext/ice/cpp/src/Slice/PHPUtil.h +36 -0
  533. data/ext/ice/cpp/src/Slice/Parser.cpp +1190 -426
  534. data/ext/ice/cpp/{include → src}/Slice/Parser.h +143 -91
  535. data/ext/ice/cpp/src/Slice/Preprocessor.cpp +67 -36
  536. data/ext/ice/cpp/{include → src}/Slice/Preprocessor.h +8 -18
  537. data/ext/ice/cpp/src/Slice/Python.cpp +218 -111
  538. data/ext/ice/cpp/src/Slice/PythonUtil.cpp +787 -699
  539. data/ext/ice/cpp/src/Slice/PythonUtil.h +70 -0
  540. data/ext/ice/cpp/src/Slice/Ruby.cpp +42 -43
  541. data/ext/ice/cpp/src/Slice/RubyUtil.cpp +175 -445
  542. data/ext/ice/cpp/{include → src}/Slice/RubyUtil.h +6 -11
  543. data/ext/ice/cpp/src/Slice/Scanner.cpp +390 -399
  544. data/ext/ice/cpp/src/Slice/{Util.cpp → SliceUtil.cpp} +36 -69
  545. data/ext/ice/cpp/src/Slice/StringLiteralUtil.cpp +456 -0
  546. data/ext/ice/cpp/src/Slice/Util.h +50 -0
  547. data/ice.gemspec +2 -9
  548. data/lib/Glacier2.rb +1 -6
  549. data/lib/Glacier2/Metrics.rb +6 -50
  550. data/lib/Glacier2/PermissionsVerifier.rb +23 -99
  551. data/lib/Glacier2/PermissionsVerifierF.rb +2 -7
  552. data/lib/Glacier2/Router.rb +31 -78
  553. data/lib/Glacier2/RouterF.rb +2 -7
  554. data/lib/Glacier2/SSLInfo.rb +3 -11
  555. data/lib/Glacier2/Session.rb +87 -311
  556. data/lib/Ice.rb +84 -58
  557. data/lib/Ice/BuiltinSequences.rb +3 -8
  558. data/lib/Ice/Communicator.rb +54 -61
  559. data/lib/Ice/CommunicatorF.rb +2 -7
  560. data/lib/Ice/Connection.rb +152 -166
  561. data/lib/Ice/ConnectionF.rb +2 -7
  562. data/lib/Ice/Current.rb +3 -15
  563. data/lib/Ice/Endpoint.rb +56 -137
  564. data/lib/Ice/EndpointF.rb +2 -7
  565. data/lib/Ice/EndpointTypes.rb +2 -11
  566. data/lib/Ice/FacetMap.rb +3 -8
  567. data/lib/Ice/Identity.rb +4 -12
  568. data/lib/Ice/ImplicitContext.rb +4 -38
  569. data/lib/Ice/ImplicitContextF.rb +2 -7
  570. data/lib/Ice/Instrumentation.rb +22 -279
  571. data/lib/Ice/InstrumentationF.rb +2 -7
  572. data/lib/Ice/LocalException.rb +94 -145
  573. data/lib/Ice/Locator.rb +50 -169
  574. data/lib/Ice/LocatorF.rb +2 -7
  575. data/lib/Ice/Logger.rb +4 -38
  576. data/lib/Ice/LoggerF.rb +2 -7
  577. data/lib/Ice/Metrics.rb +60 -420
  578. data/lib/Ice/ObjectAdapter.rb +29 -0
  579. data/lib/Ice/ObjectAdapterF.rb +2 -7
  580. data/lib/Ice/ObjectFactory.rb +4 -34
  581. data/lib/Ice/Plugin.rb +6 -64
  582. data/lib/Ice/PluginF.rb +2 -7
  583. data/lib/Ice/Process.rb +15 -56
  584. data/lib/Ice/ProcessF.rb +2 -7
  585. data/lib/Ice/Properties.rb +4 -45
  586. data/lib/Ice/PropertiesAdmin.rb +18 -60
  587. data/lib/Ice/PropertiesF.rb +2 -7
  588. data/lib/Ice/RemoteLogger.rb +33 -119
  589. data/lib/Ice/Router.rb +28 -105
  590. data/lib/Ice/RouterF.rb +2 -7
  591. data/lib/Ice/ServantLocator.rb +26 -0
  592. data/lib/Ice/ServantLocatorF.rb +24 -0
  593. data/lib/Ice/SliceChecksumDict.rb +2 -7
  594. data/lib/Ice/ValueFactory.rb +28 -0
  595. data/lib/Ice/Version.rb +4 -15
  596. data/lib/IceBox.rb +1 -6
  597. data/lib/IceBox/IceBox.rb +43 -152
  598. data/lib/IceGrid.rb +1 -9
  599. data/lib/IceGrid/Admin.rb +550 -431
  600. data/lib/IceGrid/Descriptor.rb +61 -533
  601. data/lib/IceGrid/Exception.rb +23 -49
  602. data/lib/IceGrid/FileParser.rb +13 -54
  603. data/lib/IceGrid/PluginFacade.rb +35 -0
  604. data/lib/IceGrid/Registry.rb +150 -62
  605. data/lib/IceGrid/Session.rb +24 -68
  606. data/lib/IceGrid/UserAccountMapper.rb +13 -54
  607. data/lib/IcePatch2.rb +1 -6
  608. data/lib/IcePatch2/FileInfo.rb +4 -15
  609. data/lib/IcePatch2/FileServer.rb +32 -80
  610. data/lib/IceStorm.rb +1 -6
  611. data/lib/IceStorm/IceStorm.rb +78 -210
  612. data/lib/IceStorm/Metrics.rb +10 -93
  613. data/slice/Glacier2/Metrics.ice +20 -10
  614. data/slice/Glacier2/PermissionsVerifier.ice +19 -12
  615. data/slice/Glacier2/PermissionsVerifierF.ice +16 -9
  616. data/slice/Glacier2/Router.ice +19 -13
  617. data/slice/Glacier2/RouterF.ice +16 -9
  618. data/slice/Glacier2/SSLInfo.ice +17 -10
  619. data/slice/Glacier2/Session.ice +24 -18
  620. data/slice/Ice/BuiltinSequences.ice +18 -9
  621. data/slice/Ice/Communicator.ice +180 -64
  622. data/slice/Ice/CommunicatorF.ice +18 -9
  623. data/slice/Ice/Connection.ice +208 -75
  624. data/slice/Ice/ConnectionF.ice +18 -9
  625. data/slice/Ice/Current.ice +37 -28
  626. data/slice/Ice/Endpoint.ice +73 -21
  627. data/slice/Ice/EndpointF.ice +19 -10
  628. data/slice/Ice/EndpointTypes.ice +21 -13
  629. data/slice/Ice/FacetMap.ice +19 -10
  630. data/slice/Ice/Identity.ice +24 -10
  631. data/slice/Ice/ImplicitContext.ice +41 -33
  632. data/slice/Ice/ImplicitContextF.ice +17 -9
  633. data/slice/Ice/Instrumentation.ice +37 -30
  634. data/slice/Ice/InstrumentationF.ice +19 -10
  635. data/slice/Ice/LocalException.ice +118 -112
  636. data/slice/Ice/Locator.ice +28 -21
  637. data/slice/Ice/LocatorF.ice +18 -9
  638. data/slice/Ice/Logger.ice +26 -18
  639. data/slice/Ice/LoggerF.ice +18 -9
  640. data/slice/Ice/Metrics.ice +42 -30
  641. data/slice/Ice/ObjectAdapter.ice +88 -53
  642. data/slice/Ice/ObjectAdapterF.ice +18 -9
  643. data/slice/Ice/ObjectFactory.ice +28 -17
  644. data/slice/Ice/Plugin.ice +25 -13
  645. data/slice/Ice/PluginF.ice +22 -9
  646. data/slice/Ice/Process.ice +20 -11
  647. data/slice/Ice/ProcessF.ice +18 -9
  648. data/slice/Ice/Properties.ice +42 -28
  649. data/slice/Ice/PropertiesAdmin.ice +20 -10
  650. data/slice/Ice/PropertiesF.ice +18 -9
  651. data/slice/Ice/RemoteLogger.ice +23 -19
  652. data/slice/Ice/Router.ice +28 -13
  653. data/slice/Ice/RouterF.ice +18 -9
  654. data/slice/Ice/ServantLocator.ice +40 -29
  655. data/slice/Ice/ServantLocatorF.ice +18 -9
  656. data/slice/Ice/SliceChecksumDict.ice +18 -9
  657. data/slice/Ice/ValueFactory.ice +132 -0
  658. data/slice/Ice/Version.ice +20 -10
  659. data/slice/IceBT/ConnectionInfo.ice +58 -0
  660. data/slice/IceBT/EndpointInfo.ice +56 -0
  661. data/slice/IceBT/Types.ice +44 -0
  662. data/slice/IceBox/IceBox.ice +45 -27
  663. data/slice/IceDiscovery/IceDiscovery.ice +75 -10
  664. data/slice/IceGrid/Admin.ice +410 -44
  665. data/slice/IceGrid/Descriptor.ice +47 -34
  666. data/slice/IceGrid/Exception.ice +43 -32
  667. data/slice/IceGrid/FileParser.ice +21 -12
  668. data/slice/IceGrid/PluginFacade.ice +26 -18
  669. data/slice/IceGrid/Registry.ice +150 -21
  670. data/slice/IceGrid/Session.ice +25 -17
  671. data/slice/IceGrid/UserAccountMapper.ice +23 -14
  672. data/slice/IceIAP/ConnectionInfo.ice +73 -0
  673. data/slice/IceIAP/EndpointInfo.ice +67 -0
  674. data/slice/IceLocatorDiscovery/IceLocatorDiscovery.ice +19 -12
  675. data/slice/IcePatch2/FileInfo.ice +19 -13
  676. data/slice/IcePatch2/FileServer.ice +27 -18
  677. data/slice/IceSSL/ConnectionInfo.ice +27 -23
  678. data/slice/IceSSL/ConnectionInfoF.ice +30 -0
  679. data/slice/IceSSL/EndpointInfo.ice +21 -36
  680. data/slice/IceStorm/IceStorm.ice +33 -24
  681. data/slice/IceStorm/Metrics.ice +19 -11
  682. metadata +148 -120
  683. data/ext/ObjectFactory.cpp +0 -140
  684. data/ext/ObjectFactory.h +0 -50
  685. data/ext/ice/cpp/include/Ice/ACMF.h +0 -30
  686. data/ext/ice/cpp/include/Ice/BasicStream.h +0 -1335
  687. data/ext/ice/cpp/include/Ice/BuiltinSequences.h +0 -82
  688. data/ext/ice/cpp/include/Ice/Communicator.h +0 -200
  689. data/ext/ice/cpp/include/Ice/Connection.h +0 -497
  690. data/ext/ice/cpp/include/Ice/ConnectionF.h +0 -74
  691. data/ext/ice/cpp/include/Ice/ConnectionFactoryF.h +0 -30
  692. data/ext/ice/cpp/include/Ice/Current.h +0 -102
  693. data/ext/ice/cpp/include/Ice/DefaultObjectFactory.h +0 -48
  694. data/ext/ice/cpp/include/Ice/DeprecatedStringConverter.h +0 -62
  695. data/ext/ice/cpp/include/Ice/Endpoint.h +0 -341
  696. data/ext/ice/cpp/include/Ice/EndpointF.h +0 -93
  697. data/ext/ice/cpp/include/Ice/EndpointTypes.h +0 -82
  698. data/ext/ice/cpp/include/Ice/Identity.h +0 -168
  699. data/ext/ice/cpp/include/Ice/ImplicitContext.h +0 -102
  700. data/ext/ice/cpp/include/Ice/Instrumentation.h +0 -365
  701. data/ext/ice/cpp/include/Ice/InstrumentationF.h +0 -75
  702. data/ext/ice/cpp/include/Ice/LocalException.h +0 -1030
  703. data/ext/ice/cpp/include/Ice/Locator.h +0 -2193
  704. data/ext/ice/cpp/include/Ice/LocatorF.h +0 -93
  705. data/ext/ice/cpp/include/Ice/Logger.h +0 -100
  706. data/ext/ice/cpp/include/Ice/Metrics.h +0 -2974
  707. data/ext/ice/cpp/include/Ice/ObjectAdapter.h +0 -168
  708. data/ext/ice/cpp/include/Ice/ObjectAdapterFactoryF.h +0 -26
  709. data/ext/ice/cpp/include/Ice/ObjectFactory.h +0 -92
  710. data/ext/ice/cpp/include/Ice/ObjectFactoryF.h +0 -66
  711. data/ext/ice/cpp/include/Ice/ObjectFactoryManagerF.h +0 -26
  712. data/ext/ice/cpp/include/Ice/Outgoing.h +0 -225
  713. data/ext/ice/cpp/include/Ice/Plugin.h +0 -125
  714. data/ext/ice/cpp/include/Ice/PluginF.h +0 -70
  715. data/ext/ice/cpp/include/Ice/Process.h +0 -574
  716. data/ext/ice/cpp/include/Ice/ProcessF.h +0 -83
  717. data/ext/ice/cpp/include/Ice/Properties.h +0 -136
  718. data/ext/ice/cpp/include/Ice/PropertiesAdmin.h +0 -830
  719. data/ext/ice/cpp/include/Ice/PropertiesF.h +0 -87
  720. data/ext/ice/cpp/include/Ice/RemoteLogger.h +0 -1500
  721. data/ext/ice/cpp/include/Ice/Router.h +0 -1159
  722. data/ext/ice/cpp/include/Ice/RouterF.h +0 -83
  723. data/ext/ice/cpp/include/Ice/ServantLocator.h +0 -96
  724. data/ext/ice/cpp/include/Ice/Stream.h +0 -447
  725. data/ext/ice/cpp/include/Ice/StreamF.h +0 -30
  726. data/ext/ice/cpp/include/Ice/Version.h +0 -262
  727. data/ext/ice/cpp/include/IceSSL/ConnectionInfo.h +0 -158
  728. data/ext/ice/cpp/include/IceSSL/EndpointInfo.h +0 -142
  729. data/ext/ice/cpp/include/IceUtil/AbstractMutex.h +0 -119
  730. data/ext/ice/cpp/include/IceUtil/Cache.h +0 -362
  731. data/ext/ice/cpp/include/IceUtil/IconvStringConverter.h +0 -302
  732. data/ext/ice/cpp/include/IceUtil/SHA1.h +0 -47
  733. data/ext/ice/cpp/include/Slice/CPlusPlusUtil.h +0 -65
  734. data/ext/ice/cpp/include/Slice/Checksum.h +0 -26
  735. data/ext/ice/cpp/include/Slice/CsUtil.h +0 -92
  736. data/ext/ice/cpp/include/Slice/DotNetNames.h +0 -34
  737. data/ext/ice/cpp/include/Slice/JavaUtil.h +0 -279
  738. data/ext/ice/cpp/include/Slice/ObjCUtil.h +0 -127
  739. data/ext/ice/cpp/include/Slice/PHPUtil.h +0 -50
  740. data/ext/ice/cpp/include/Slice/PythonUtil.h +0 -64
  741. data/ext/ice/cpp/include/Slice/Util.h +0 -56
  742. data/ext/ice/cpp/src/Ice/BasicStream.cpp +0 -3428
  743. data/ext/ice/cpp/src/Ice/DeprecatedStringConverter.cpp +0 -62
  744. data/ext/ice/cpp/src/Ice/ObjectFactoryF.cpp +0 -44
  745. data/ext/ice/cpp/src/Ice/ObjectFactoryManager.cpp +0 -139
  746. data/ext/ice/cpp/src/Ice/ObjectFactoryManager.h +0 -43
  747. data/ext/ice/cpp/src/Ice/Outgoing.cpp +0 -694
  748. data/ext/ice/cpp/src/Ice/Stream.cpp +0 -53
  749. data/ext/ice/cpp/src/Ice/StreamI.cpp +0 -832
  750. data/ext/ice/cpp/src/Ice/StreamI.h +0 -198
  751. data/ext/ice/cpp/src/IceSSL/Certificate.cpp +0 -1336
  752. data/ext/ice/cpp/src/IceUtil/ArgVector.cpp +0 -64
  753. data/ext/ice/cpp/src/IceUtil/ArgVector.h +0 -41
  754. data/ext/ice/cpp/src/IceUtil/Exception.cpp +0 -792
  755. data/ext/ice/cpp/src/IceUtil/FileUtil.h +0 -185
  756. data/ext/ice/cpp/src/Slice/CsUtil.cpp +0 -2660
  757. data/ext/ice/cpp/src/Slice/DotNetNames.cpp +0 -146
  758. data/ext/ice/cpp/src/Slice/ObjCUtil.cpp +0 -1310
  759. data/lib/Ice/ObjectFactoryF.rb +0 -29
  760. data/lib/IceGrid/Locator.rb +0 -106
  761. data/lib/IceGrid/Observer.rb +0 -572
  762. data/lib/IceGrid/Query.rb +0 -169
  763. data/slice/Freeze/BackgroundSaveEvictor.ice +0 -111
  764. data/slice/Freeze/CatalogData.ice +0 -49
  765. data/slice/Freeze/Connection.ice +0 -121
  766. data/slice/Freeze/ConnectionF.ice +0 -20
  767. data/slice/Freeze/DB.ice +0 -37
  768. data/slice/Freeze/Evictor.ice +0 -346
  769. data/slice/Freeze/EvictorF.ice +0 -22
  770. data/slice/Freeze/EvictorStorage.ice +0 -72
  771. data/slice/Freeze/Exception.ice +0 -100
  772. data/slice/Freeze/Transaction.ice +0 -58
  773. data/slice/Freeze/TransactionalEvictor.ice +0 -50
  774. data/slice/Ice/ObjectFactoryF.ice +0 -21
  775. data/slice/IceGrid/Locator.ice +0 -57
  776. data/slice/IceGrid/Observer.ice +0 -395
  777. data/slice/IceGrid/Query.ice +0 -131
@@ -1,64 +0,0 @@
1
- // **********************************************************************
2
- //
3
- // Copyright (c) 2003-2018 ZeroC, Inc. All rights reserved.
4
- //
5
- // This copy of Ice is licensed to you under the terms described in the
6
- // ICE_LICENSE file included in this distribution.
7
- //
8
- // **********************************************************************
9
-
10
- #ifndef SLICE_PYTHON_UTIL_H
11
- #define SLICE_PYTHON_UTIL_H
12
-
13
- #include <Slice/Parser.h>
14
- #include <IceUtil/OutputUtil.h>
15
-
16
- namespace Slice
17
- {
18
- namespace Python
19
- {
20
-
21
- //
22
- // Generate Python code for a translation unit.
23
- //
24
- SLICE_API void generate(const Slice::UnitPtr&, bool, bool, const std::vector<std::string>&, IceUtilInternal::Output&);
25
-
26
- //
27
- // Convert a scoped name into a Python name.
28
- //
29
- SLICE_API std::string scopedToName(const std::string&);
30
-
31
- //
32
- // Check the given identifier against Python's list of reserved words. If it matches
33
- // a reserved word, then an escaped version is returned with a leading underscore.
34
- //
35
- SLICE_API std::string fixIdent(const std::string&);
36
-
37
- //
38
- // Return the package specified in the global metadata for the given definition,
39
- // or an empty string if no metadata was found.
40
- //
41
- SLICE_API std::string getPackageMetadata(const Slice::ContainedPtr&);
42
-
43
- //
44
- // Get the fully-qualified name of the given definition, including any
45
- // package defined via metadata. If a suffix is provided, it is
46
- // prepended to the definition's unqualified name. If the nameSuffix
47
- // is provided, it is appended to the containers name.
48
- //
49
- // COMPILERFIX: MSVC 6 seems to have a problem with const std::string
50
- // = std::string(), const std::string = std::string().
51
- //
52
- SLICE_API std::string getAbsolute(const Slice::ContainedPtr&, const std::string& = "", const std::string& = "");
53
-
54
- //
55
- // Emit a comment header.
56
- //
57
- SLICE_API void printHeader(IceUtilInternal::Output&);
58
-
59
- SLICE_API int compile(const std::vector<std::string>&);
60
-
61
- }
62
- }
63
-
64
- #endif
@@ -1,56 +0,0 @@
1
- // **********************************************************************
2
- //
3
- // Copyright (c) 2003-2018 ZeroC, Inc. All rights reserved.
4
- //
5
- // This copy of Ice is licensed to you under the terms described in the
6
- // ICE_LICENSE file included in this distribution.
7
- //
8
- // **********************************************************************
9
-
10
- #ifndef SLICE_UTIL_H
11
- #define SLICE_UTIL_H
12
-
13
- #include <Slice/Parser.h>
14
- #include <IceUtil/OutputUtil.h>
15
-
16
- #include <ostream>
17
- #include <fstream>
18
-
19
- namespace Slice
20
- {
21
-
22
- SLICE_API std::string fullPath(const std::string&);
23
- SLICE_API std::string changeInclude(const std::string&, const std::vector<std::string>&);
24
- SLICE_API void setErrorStream(std::ostream&);
25
- SLICE_API std::ostream& getErrorStream();
26
- SLICE_API void emitError(const std::string&, int, const std::string&);
27
- SLICE_API void emitWarning(const std::string&, int, const std::string&);
28
- SLICE_API void emitError(const std::string&, const std::string&, const std::string&);
29
- SLICE_API void emitWarning(const std::string&, const std::string&, const std::string&);
30
- SLICE_API void emitRaw(const char*);
31
- SLICE_API std::vector<std::string> filterMcppWarnings(const std::string&);
32
- SLICE_API void printGeneratedHeader(IceUtilInternal::Output& out, const std::string&, const std::string& commentStyle = "//");
33
- #ifdef _WIN32
34
- SLICE_API std::vector<std::string> argvToArgs(int argc, wchar_t* argv[]);
35
- #else
36
- SLICE_API std::vector<std::string> argvToArgs(int argc, char* argv[]);
37
- #endif
38
-
39
- class SLICE_API DependOutputUtil : IceUtil::noncopyable
40
- {
41
- public:
42
-
43
- DependOutputUtil(std::string& file);
44
- ~DependOutputUtil();
45
- void cleanup();
46
- std::ostream& os();
47
-
48
- private:
49
-
50
- const std::string _file;
51
- std::ofstream _os;
52
- };
53
-
54
- }
55
-
56
- #endif
@@ -1,3428 +0,0 @@
1
- // **********************************************************************
2
- //
3
- // Copyright (c) 2003-2018 ZeroC, Inc. All rights reserved.
4
- //
5
- // This copy of Ice is licensed to you under the terms described in the
6
- // ICE_LICENSE file included in this distribution.
7
- //
8
- // **********************************************************************
9
-
10
- #include <IceUtil/DisableWarnings.h>
11
- #include <Ice/BasicStream.h>
12
- #include <Ice/DefaultsAndOverrides.h>
13
- #include <Ice/Instance.h>
14
- #include <Ice/Object.h>
15
- #include <Ice/Proxy.h>
16
- #include <Ice/ProxyFactory.h>
17
- #include <Ice/ObjectFactory.h>
18
- #include <Ice/ObjectFactoryManager.h>
19
- #include <Ice/UserExceptionFactory.h>
20
- #include <Ice/LocalException.h>
21
- #include <Ice/Protocol.h>
22
- #include <Ice/FactoryTableInit.h>
23
- #include <Ice/TraceUtil.h>
24
- #include <Ice/TraceLevels.h>
25
- #include <Ice/LoggerUtil.h>
26
- #include <Ice/SlicedData.h>
27
- #include <IceUtil/StringConverter.h>
28
- #include <iterator>
29
-
30
- using namespace std;
31
- using namespace Ice;
32
- using namespace IceInternal;
33
-
34
- namespace
35
- {
36
-
37
- class StreamUTF8BufferI : public IceUtil::UTF8Buffer
38
- {
39
- public:
40
-
41
- StreamUTF8BufferI(BasicStream& stream) :
42
- _stream(stream)
43
- {
44
- }
45
-
46
- Ice::Byte*
47
- getMoreBytes(size_t howMany, Ice::Byte* firstUnused)
48
- {
49
- assert(howMany > 0);
50
-
51
- if(firstUnused != 0)
52
- {
53
- //
54
- // Return unused bytes
55
- //
56
- _stream.resize(firstUnused - _stream.b.begin());
57
- }
58
-
59
- //
60
- // Index of first unused byte
61
- //
62
- Buffer::Container::size_type pos = _stream.b.size();
63
-
64
- //
65
- // Since resize may reallocate the buffer, when firstUnused != 0, the
66
- // return value can be != firstUnused
67
- //
68
- _stream.resize(pos + howMany);
69
-
70
- return &_stream.b[pos];
71
- }
72
-
73
- private:
74
-
75
- BasicStream& _stream;
76
- };
77
-
78
- const Byte OPTIONAL_END_MARKER = 0xFF;
79
-
80
- const Byte FLAG_HAS_TYPE_ID_STRING = (1<<0);
81
- const Byte FLAG_HAS_TYPE_ID_INDEX = (1<<1);
82
- const Byte FLAG_HAS_TYPE_ID_COMPACT = (1<<0) | (1<<1);
83
- const Byte FLAG_HAS_OPTIONAL_MEMBERS = (1<<2);
84
- const Byte FLAG_HAS_INDIRECTION_TABLE = (1<<3);
85
- const Byte FLAG_HAS_SLICE_SIZE = (1<<4);
86
- const Byte FLAG_IS_LAST_SLICE = (1<<5);
87
-
88
- }
89
-
90
- IceInternal::BasicStream::BasicStream(Instance* instance, const EncodingVersion& encoding) :
91
- _instance(instance),
92
- _closure(0),
93
- _encoding(encoding),
94
- _currentReadEncaps(0),
95
- _currentWriteEncaps(0),
96
- _sliceObjects(true),
97
- _stringConverter(instance->getStringConverter()),
98
- _wstringConverter(instance->getWstringConverter()),
99
- _startSeq(-1),
100
- _minSeqSize(0)
101
- {
102
- //
103
- // Initialize the encoding members of our pre-allocated encapsulations, in case
104
- // this stream is used without an explicit encapsulation.
105
- //
106
- _preAllocatedReadEncaps.encoding = encoding;
107
- _preAllocatedWriteEncaps.encoding = encoding;
108
- }
109
-
110
- IceInternal::BasicStream::BasicStream(Instance* instance, const EncodingVersion& encoding, const Byte* begin,
111
- const Byte* end) :
112
- IceInternal::Buffer(begin, end),
113
- _instance(instance),
114
- _closure(0),
115
- _encoding(encoding),
116
- _currentReadEncaps(0),
117
- _currentWriteEncaps(0),
118
- _sliceObjects(true),
119
- _stringConverter(instance->getStringConverter()),
120
- _wstringConverter(instance->getWstringConverter()),
121
- _startSeq(-1),
122
- _minSeqSize(0)
123
- {
124
- //
125
- // Initialize the encoding members of our pre-allocated encapsulations, in case
126
- // this stream is used without an explicit encapsulation.
127
- //
128
- _preAllocatedReadEncaps.encoding = encoding;
129
- _preAllocatedWriteEncaps.encoding = encoding;
130
- }
131
-
132
- void
133
- IceInternal::BasicStream::clear()
134
- {
135
- while(_currentReadEncaps && _currentReadEncaps != &_preAllocatedReadEncaps)
136
- {
137
- ReadEncaps* oldEncaps = _currentReadEncaps;
138
- _currentReadEncaps = _currentReadEncaps->previous;
139
- delete oldEncaps;
140
- }
141
-
142
- while(_currentWriteEncaps && _currentWriteEncaps != &_preAllocatedWriteEncaps)
143
- {
144
- WriteEncaps* oldEncaps = _currentWriteEncaps;
145
- _currentWriteEncaps = _currentWriteEncaps->previous;
146
- delete oldEncaps;
147
- }
148
-
149
- _startSeq = -1;
150
- _sliceObjects = true;
151
- }
152
-
153
- void*
154
- IceInternal::BasicStream::closure() const
155
- {
156
- return _closure;
157
- }
158
-
159
- void*
160
- IceInternal::BasicStream::closure(void* p)
161
- {
162
- void* prev = _closure;
163
- _closure = p;
164
- return prev;
165
- }
166
-
167
- void
168
- IceInternal::BasicStream::swap(BasicStream& other)
169
- {
170
- assert(_instance == other._instance);
171
-
172
- swapBuffer(other);
173
-
174
- std::swap(_closure, other._closure);
175
-
176
- //
177
- // Swap is never called for BasicStreams that have encapsulations being read/write. However,
178
- // encapsulations might still be set in case marhsalling or un-marhsalling failed. We just
179
- // reset the encapsulations if there are still some set.
180
- //
181
- resetEncaps();
182
- other.resetEncaps();
183
-
184
- std::swap(_startSeq, other._startSeq);
185
- std::swap(_minSeqSize, other._minSeqSize);
186
- }
187
-
188
- void
189
- IceInternal::BasicStream::resetEncaps()
190
- {
191
- while(_currentReadEncaps && _currentReadEncaps != &_preAllocatedReadEncaps)
192
- {
193
- ReadEncaps* oldEncaps = _currentReadEncaps;
194
- _currentReadEncaps = _currentReadEncaps->previous;
195
- delete oldEncaps;
196
- }
197
-
198
- while(_currentWriteEncaps && _currentWriteEncaps != &_preAllocatedWriteEncaps)
199
- {
200
- WriteEncaps* oldEncaps = _currentWriteEncaps;
201
- _currentWriteEncaps = _currentWriteEncaps->previous;
202
- delete oldEncaps;
203
- }
204
-
205
- _preAllocatedReadEncaps.reset();
206
- _preAllocatedWriteEncaps.reset();
207
- }
208
-
209
- void
210
- IceInternal::BasicStream::startWriteEncaps()
211
- {
212
- //
213
- // If no encoding version is specified, use the current write
214
- // encapsulation encoding version if there's a current write
215
- // encapsulation, otherwise, use the stream encoding version.
216
- //
217
-
218
- if(_currentWriteEncaps)
219
- {
220
- startWriteEncaps(_currentWriteEncaps->encoding, _currentWriteEncaps->format);
221
- }
222
- else
223
- {
224
- startWriteEncaps(_encoding, Ice::DefaultFormat);
225
- }
226
- }
227
-
228
- void
229
- IceInternal::BasicStream::endWriteEncapsChecked()
230
- {
231
- if(!_currentWriteEncaps)
232
- {
233
- throw EncapsulationException(__FILE__, __LINE__, "not in an encapsulation");
234
- }
235
- endWriteEncaps();
236
- }
237
-
238
- void
239
- IceInternal::BasicStream::endReadEncapsChecked()
240
- {
241
- if(!_currentReadEncaps)
242
- {
243
- throw EncapsulationException(__FILE__, __LINE__, "not in an encapsulation");
244
- }
245
- endReadEncaps();
246
- }
247
-
248
- Int
249
- IceInternal::BasicStream::getReadEncapsSize()
250
- {
251
- assert(_currentReadEncaps);
252
- return _currentReadEncaps->sz - static_cast<Int>(sizeof(Int)) - 2;
253
- }
254
-
255
- EncodingVersion
256
- IceInternal::BasicStream::skipEncaps()
257
- {
258
- Int sz;
259
- read(sz);
260
- if(sz < 6)
261
- {
262
- throw UnmarshalOutOfBoundsException(__FILE__, __LINE__);
263
- }
264
- if(i - sizeof(Int) + sz > b.end())
265
- {
266
- throw UnmarshalOutOfBoundsException(__FILE__, __LINE__);
267
- }
268
- EncodingVersion encoding;
269
- read(encoding.major);
270
- read(encoding.minor);
271
- i += sz - sizeof(Int) - 2;
272
- return encoding;
273
- }
274
-
275
- void
276
- IceInternal::BasicStream::readPendingObjects()
277
- {
278
- if(_currentReadEncaps && _currentReadEncaps->decoder)
279
- {
280
- _currentReadEncaps->decoder->readPendingObjects();
281
- }
282
- else if(getReadEncoding() == Ice::Encoding_1_0)
283
- {
284
- //
285
- // If using the 1.0 encoding and no objects were read, we
286
- // still read an empty sequence of pending objects if
287
- // requested (i.e.: if this is called).
288
- //
289
- // This is required by the 1.0 encoding, even if no objects
290
- // are written we do marshal an empty sequence if marshaled
291
- // data types use classes.
292
- //
293
- skipSize();
294
- }
295
- }
296
-
297
- void
298
- IceInternal::BasicStream::writePendingObjects()
299
- {
300
- if(_currentWriteEncaps && _currentWriteEncaps->encoder)
301
- {
302
- _currentWriteEncaps->encoder->writePendingObjects();
303
- }
304
- else if(getWriteEncoding() == Ice::Encoding_1_0)
305
- {
306
- //
307
- // If using the 1.0 encoding and no objects were written, we
308
- // still write an empty sequence for pending objects if
309
- // requested (i.e.: if this is called).
310
- //
311
- // This is required by the 1.0 encoding, even if no objects
312
- // are written we do marshal an empty sequence if marshaled
313
- // data types use classes.
314
- //
315
- writeSize(0);
316
- }
317
- }
318
-
319
- Int
320
- IceInternal::BasicStream::readAndCheckSeqSize(int minSize)
321
- {
322
- Int sz = readSize();
323
-
324
- if(sz == 0)
325
- {
326
- return sz;
327
- }
328
-
329
- //
330
- // The _startSeq variable points to the start of the sequence for which
331
- // we expect to read at least _minSeqSize bytes from the stream.
332
- //
333
- // If not initialized or if we already read more data than _minSeqSize,
334
- // we reset _startSeq and _minSeqSize for this sequence (possibly a
335
- // top-level sequence or enclosed sequence it doesn't really matter).
336
- //
337
- // Otherwise, we are reading an enclosed sequence and we have to bump
338
- // _minSeqSize by the minimum size that this sequence will require on
339
- // the stream.
340
- //
341
- // The goal of this check is to ensure that when we start un-marshalling
342
- // a new sequence, we check the minimal size of this new sequence against
343
- // the estimated remaining buffer size. This estimatation is based on
344
- // the minimum size of the enclosing sequences, it's _minSeqSize.
345
- //
346
- if(_startSeq == -1 || i > (b.begin() + _startSeq + _minSeqSize))
347
- {
348
- _startSeq = static_cast<int>(i - b.begin());
349
- _minSeqSize = sz * minSize;
350
- }
351
- else
352
- {
353
- _minSeqSize += sz * minSize;
354
- }
355
-
356
- //
357
- // If there isn't enough data to read on the stream for the sequence (and
358
- // possibly enclosed sequences), something is wrong with the marshalled
359
- // data: it's claiming having more data that what is possible to read.
360
- //
361
- if(_startSeq + _minSeqSize > static_cast<int>(b.size()))
362
- {
363
- throw UnmarshalOutOfBoundsException(__FILE__, __LINE__);
364
- }
365
-
366
- return sz;
367
- }
368
-
369
- void
370
- IceInternal::BasicStream::writeBlob(const vector<Byte>& v)
371
- {
372
- if(!v.empty())
373
- {
374
- Container::size_type pos = b.size();
375
- resize(pos + v.size());
376
- memcpy(&b[pos], &v[0], v.size());
377
- }
378
- }
379
-
380
- void
381
- IceInternal::BasicStream::readBlob(vector<Byte>& v, Int sz)
382
- {
383
- if(sz > 0)
384
- {
385
- if(b.end() - i < sz)
386
- {
387
- throw UnmarshalOutOfBoundsException(__FILE__, __LINE__);
388
- }
389
- vector<Byte>(i, i + sz).swap(v);
390
- i += sz;
391
- }
392
- else
393
- {
394
- v.clear();
395
- }
396
- }
397
-
398
- void
399
- IceInternal::BasicStream::write(const Byte* begin, const Byte* end)
400
- {
401
- Int sz = static_cast<Int>(end - begin);
402
- writeSize(sz);
403
- if(sz > 0)
404
- {
405
- Container::size_type pos = b.size();
406
- resize(pos + sz);
407
- memcpy(&b[pos], begin, sz);
408
- }
409
- }
410
-
411
- void
412
- IceInternal::BasicStream::read(std::vector<Ice::Byte>& v)
413
- {
414
- std::pair<const Ice::Byte*, const Ice::Byte*> p;
415
- read(p);
416
- if(p.first != p.second)
417
- {
418
- v.resize(static_cast<Ice::Int>(p.second - p.first));
419
- copy(p.first, p.second, v.begin());
420
- }
421
- else
422
- {
423
- v.clear();
424
- }
425
- }
426
-
427
- void
428
- IceInternal::BasicStream::read(pair<const Byte*, const Byte*>& v)
429
- {
430
- Int sz = readAndCheckSeqSize(1);
431
- if(sz > 0)
432
- {
433
- v.first = i;
434
- v.second = i + sz;
435
- i += sz;
436
- }
437
- else
438
- {
439
- v.first = v.second = i;
440
- }
441
- }
442
-
443
- void
444
- IceInternal::BasicStream::write(const vector<bool>& v)
445
- {
446
- Int sz = static_cast<Int>(v.size());
447
- writeSize(sz);
448
- if(sz > 0)
449
- {
450
- Container::size_type pos = b.size();
451
- resize(pos + sz);
452
- copy(v.begin(), v.end(), b.begin() + pos);
453
- }
454
- }
455
-
456
- namespace
457
- {
458
-
459
- template<size_t boolSize>
460
- struct BasicStreamWriteBoolHelper
461
- {
462
- static void write(const bool* begin, BasicStream::Container::size_type pos, BasicStream::Container& b, Int sz)
463
- {
464
- for(int idx = 0; idx < sz; ++idx)
465
- {
466
- b[pos + idx] = static_cast<Byte>(*(begin + idx));
467
- }
468
- }
469
- };
470
-
471
- template<>
472
- struct BasicStreamWriteBoolHelper<1>
473
- {
474
- static void write(const bool* begin, BasicStream::Container::size_type pos, BasicStream::Container& b, Int sz)
475
- {
476
- memcpy(&b[pos], begin, sz);
477
- }
478
- };
479
-
480
- }
481
-
482
- void
483
- IceInternal::BasicStream::write(const bool* begin, const bool* end)
484
- {
485
- Int sz = static_cast<Int>(end - begin);
486
- writeSize(sz);
487
- if(sz > 0)
488
- {
489
- Container::size_type pos = b.size();
490
- resize(pos + sz);
491
- BasicStreamWriteBoolHelper<sizeof(bool)>::write(begin, pos, b, sz);
492
- }
493
- }
494
-
495
- void
496
- IceInternal::BasicStream::read(vector<bool>& v)
497
- {
498
- Int sz = readAndCheckSeqSize(1);
499
- if(sz > 0)
500
- {
501
- v.resize(sz);
502
- copy(i, i + sz, v.begin());
503
- i += sz;
504
- }
505
- else
506
- {
507
- v.clear();
508
- }
509
- }
510
-
511
- namespace
512
- {
513
-
514
- template<size_t boolSize>
515
- struct BasicStreamReadBoolHelper
516
- {
517
- static bool* read(pair<const bool*, const bool*>& v, Int sz, BasicStream::Container::iterator& i)
518
- {
519
- bool* array = new bool[sz];
520
- for(int idx = 0; idx < sz; ++idx)
521
- {
522
- array[idx] = static_cast<bool>(*(i + idx));
523
- }
524
- v.first = array;
525
- v.second = array + sz;
526
- return array;
527
- }
528
- };
529
-
530
- template<>
531
- struct BasicStreamReadBoolHelper<1>
532
- {
533
- static bool* read(pair<const bool*, const bool*>& v, Int sz, BasicStream::Container::iterator& i)
534
- {
535
- v.first = reinterpret_cast<bool*>(i);
536
- v.second = reinterpret_cast<bool*>(i) + sz;
537
- return 0;
538
- }
539
- };
540
-
541
- }
542
-
543
- void
544
- IceInternal::BasicStream::read(pair<const bool*, const bool*>& v, IceUtil::ScopedArray<bool>& result)
545
- {
546
- Int sz = readAndCheckSeqSize(1);
547
- if(sz > 0)
548
- {
549
- result.reset(BasicStreamReadBoolHelper<sizeof(bool)>::read(v, sz, i));
550
- i += sz;
551
- }
552
- else
553
- {
554
- result.reset();
555
- v.first = v.second = reinterpret_cast<bool*>(i);
556
- }
557
- }
558
-
559
- void
560
- IceInternal::BasicStream::write(Short v)
561
- {
562
- Container::size_type pos = b.size();
563
- resize(pos + sizeof(Short));
564
- Byte* dest = &b[pos];
565
- #ifdef ICE_BIG_ENDIAN
566
- const Byte* src = reinterpret_cast<const Byte*>(&v) + sizeof(Short) - 1;
567
- *dest++ = *src--;
568
- *dest = *src;
569
- #else
570
- const Byte* src = reinterpret_cast<const Byte*>(&v);
571
- *dest++ = *src++;
572
- *dest = *src;
573
- #endif
574
- }
575
-
576
- void
577
- IceInternal::BasicStream::write(const Short* begin, const Short* end)
578
- {
579
- Int sz = static_cast<Int>(end - begin);
580
- writeSize(sz);
581
- if(sz > 0)
582
- {
583
- Container::size_type pos = b.size();
584
- resize(pos + sz * sizeof(Short));
585
- #ifdef ICE_BIG_ENDIAN
586
- const Byte* src = reinterpret_cast<const Byte*>(begin) + sizeof(Short) - 1;
587
- Byte* dest = &(*(b.begin() + pos));
588
- for(int j = 0 ; j < sz ; ++j)
589
- {
590
- *dest++ = *src--;
591
- *dest++ = *src--;
592
- src += 2 * sizeof(Short);
593
- }
594
- #else
595
- memcpy(&b[pos], reinterpret_cast<const Byte*>(begin), sz * sizeof(Short));
596
- #endif
597
- }
598
- }
599
-
600
- void
601
- IceInternal::BasicStream::read(Short& v)
602
- {
603
- if(b.end() - i < static_cast<int>(sizeof(Short)))
604
- {
605
- throw UnmarshalOutOfBoundsException(__FILE__, __LINE__);
606
- }
607
- const Byte* src = &(*i);
608
- i += sizeof(Short);
609
- #ifdef ICE_BIG_ENDIAN
610
- Byte* dest = reinterpret_cast<Byte*>(&v) + sizeof(Short) - 1;
611
- *dest-- = *src++;
612
- *dest = *src;
613
- #else
614
- Byte* dest = reinterpret_cast<Byte*>(&v);
615
- *dest++ = *src++;
616
- *dest = *src;
617
- #endif
618
- }
619
-
620
- void
621
- IceInternal::BasicStream::read(vector<Short>& v)
622
- {
623
- Int sz = readAndCheckSeqSize(static_cast<int>(sizeof(Short)));
624
- if(sz > 0)
625
- {
626
- Container::iterator begin = i;
627
- i += sz * static_cast<int>(sizeof(Short));
628
- v.resize(sz);
629
- #ifdef ICE_BIG_ENDIAN
630
- const Byte* src = &(*begin);
631
- Byte* dest = reinterpret_cast<Byte*>(&v[0]) + sizeof(Short) - 1;
632
- for(int j = 0 ; j < sz ; ++j)
633
- {
634
- *dest-- = *src++;
635
- *dest-- = *src++;
636
- dest += 2 * sizeof(Short);
637
- }
638
- #else
639
- copy(begin, i, reinterpret_cast<Byte*>(&v[0]));
640
- #endif
641
- }
642
- else
643
- {
644
- v.clear();
645
- }
646
- }
647
-
648
- void
649
- IceInternal::BasicStream::read(pair<const Short*, const Short*>& v, IceUtil::ScopedArray<Short>& result)
650
- {
651
- Int sz = readAndCheckSeqSize(static_cast<int>(sizeof(Short)));
652
- if(sz > 0)
653
- {
654
- #if defined(__i386) || defined(_M_IX86) || defined(__x86_64) || defined(_M_X64)
655
- v.first = reinterpret_cast<Short*>(i);
656
- i += sz * static_cast<int>(sizeof(Short));
657
- v.second = reinterpret_cast<Short*>(i);
658
- #else
659
- result.reset(new Short[sz]);
660
- v.first = result.get();
661
- v.second = result.get() + sz;
662
-
663
- Container::iterator begin = i;
664
- i += sz * static_cast<int>(sizeof(Short));
665
- # ifdef ICE_BIG_ENDIAN
666
- const Byte* src = &(*begin);
667
- Byte* dest = reinterpret_cast<Byte*>(&result[0]) + sizeof(Short) - 1;
668
- for(int j = 0 ; j < sz ; ++j)
669
- {
670
- *dest-- = *src++;
671
- *dest-- = *src++;
672
- dest += 2 * sizeof(Short);
673
- }
674
- # else
675
- copy(begin, i, reinterpret_cast<Byte*>(&result[0]));
676
- # endif
677
- #endif
678
- }
679
- else
680
- {
681
- result.reset();
682
- v.first = v.second = 0;
683
- }
684
- }
685
-
686
- void
687
- IceInternal::BasicStream::write(const Int* begin, const Int* end)
688
- {
689
- Int sz = static_cast<Int>(end - begin);
690
- writeSize(sz);
691
- if(sz > 0)
692
- {
693
- Container::size_type pos = b.size();
694
- resize(pos + sz * sizeof(Int));
695
- #ifdef ICE_BIG_ENDIAN
696
- const Byte* src = reinterpret_cast<const Byte*>(begin) + sizeof(Int) - 1;
697
- Byte* dest = &(*(b.begin() + pos));
698
- for(int j = 0 ; j < sz ; ++j)
699
- {
700
- *dest++ = *src--;
701
- *dest++ = *src--;
702
- *dest++ = *src--;
703
- *dest++ = *src--;
704
- src += 2 * sizeof(Int);
705
- }
706
- #else
707
- memcpy(&b[pos], reinterpret_cast<const Byte*>(begin), sz * sizeof(Int));
708
- #endif
709
- }
710
- }
711
-
712
- void
713
- IceInternal::BasicStream::read(vector<Int>& v)
714
- {
715
- Int sz = readAndCheckSeqSize(static_cast<int>(sizeof(Int)));
716
- if(sz > 0)
717
- {
718
- Container::iterator begin = i;
719
- i += sz * static_cast<int>(sizeof(Int));
720
- v.resize(sz);
721
- #ifdef ICE_BIG_ENDIAN
722
- const Byte* src = &(*begin);
723
- Byte* dest = reinterpret_cast<Byte*>(&v[0]) + sizeof(Int) - 1;
724
- for(int j = 0 ; j < sz ; ++j)
725
- {
726
- *dest-- = *src++;
727
- *dest-- = *src++;
728
- *dest-- = *src++;
729
- *dest-- = *src++;
730
- dest += 2 * sizeof(Int);
731
- }
732
- #else
733
- copy(begin, i, reinterpret_cast<Byte*>(&v[0]));
734
- #endif
735
- }
736
- else
737
- {
738
- v.clear();
739
- }
740
- }
741
-
742
- void
743
- IceInternal::BasicStream::read(pair<const Int*, const Int*>& v, ::IceUtil::ScopedArray<Int>& result)
744
- {
745
- Int sz = readAndCheckSeqSize(static_cast<int>(sizeof(Int)));
746
- if(sz > 0)
747
- {
748
- #if defined(__i386) || defined(_M_IX86) || defined(__x86_64) || defined(_M_X64)
749
- v.first = reinterpret_cast<Int*>(i);
750
- i += sz * static_cast<int>(sizeof(Int));
751
- v.second = reinterpret_cast<Int*>(i);
752
- #else
753
- result.reset(new Int[sz]);
754
- v.first = result.get();
755
- v.second = result.get() + sz;
756
-
757
- Container::iterator begin = i;
758
- i += sz * static_cast<int>(sizeof(Int));
759
- # ifdef ICE_BIG_ENDIAN
760
- const Byte* src = &(*begin);
761
- Byte* dest = reinterpret_cast<Byte*>(&result[0]) + sizeof(Int) - 1;
762
- for(int j = 0 ; j < sz ; ++j)
763
- {
764
- *dest-- = *src++;
765
- *dest-- = *src++;
766
- *dest-- = *src++;
767
- *dest-- = *src++;
768
- dest += 2 * sizeof(Int);
769
- }
770
- # else
771
- copy(begin, i, reinterpret_cast<Byte*>(&result[0]));
772
- # endif
773
- #endif
774
- }
775
- else
776
- {
777
- result.reset();
778
- v.first = v.second = 0;
779
- }
780
- }
781
-
782
- void
783
- IceInternal::BasicStream::write(Long v)
784
- {
785
- Container::size_type pos = b.size();
786
- resize(pos + sizeof(Long));
787
- Byte* dest = &b[pos];
788
- #ifdef ICE_BIG_ENDIAN
789
- const Byte* src = reinterpret_cast<const Byte*>(&v) + sizeof(Long) - 1;
790
- *dest++ = *src--;
791
- *dest++ = *src--;
792
- *dest++ = *src--;
793
- *dest++ = *src--;
794
- *dest++ = *src--;
795
- *dest++ = *src--;
796
- *dest++ = *src--;
797
- *dest = *src;
798
- #else
799
- const Byte* src = reinterpret_cast<const Byte*>(&v);
800
- *dest++ = *src++;
801
- *dest++ = *src++;
802
- *dest++ = *src++;
803
- *dest++ = *src++;
804
- *dest++ = *src++;
805
- *dest++ = *src++;
806
- *dest++ = *src++;
807
- *dest = *src;
808
- #endif
809
- }
810
-
811
- void
812
- IceInternal::BasicStream::write(const Long* begin, const Long* end)
813
- {
814
- Int sz = static_cast<Int>(end - begin);
815
- writeSize(sz);
816
- if(sz > 0)
817
- {
818
- Container::size_type pos = b.size();
819
- resize(pos + sz * sizeof(Long));
820
- #ifdef ICE_BIG_ENDIAN
821
- const Byte* src = reinterpret_cast<const Byte*>(begin) + sizeof(Long) - 1;
822
- Byte* dest = &(*(b.begin() + pos));
823
- for(int j = 0 ; j < sz ; ++j)
824
- {
825
- *dest++ = *src--;
826
- *dest++ = *src--;
827
- *dest++ = *src--;
828
- *dest++ = *src--;
829
- *dest++ = *src--;
830
- *dest++ = *src--;
831
- *dest++ = *src--;
832
- *dest++ = *src--;
833
- src += 2 * sizeof(Long);
834
- }
835
- #else
836
- memcpy(&b[pos], reinterpret_cast<const Byte*>(begin), sz * sizeof(Long));
837
- #endif
838
- }
839
- }
840
-
841
- void
842
- IceInternal::BasicStream::read(Long& v)
843
- {
844
- if(b.end() - i < static_cast<int>(sizeof(Long)))
845
- {
846
- throw UnmarshalOutOfBoundsException(__FILE__, __LINE__);
847
- }
848
- const Byte* src = &(*i);
849
- i += sizeof(Long);
850
- #ifdef ICE_BIG_ENDIAN
851
- Byte* dest = reinterpret_cast<Byte*>(&v) + sizeof(Long) - 1;
852
- *dest-- = *src++;
853
- *dest-- = *src++;
854
- *dest-- = *src++;
855
- *dest-- = *src++;
856
- *dest-- = *src++;
857
- *dest-- = *src++;
858
- *dest-- = *src++;
859
- *dest = *src;
860
- #else
861
- Byte* dest = reinterpret_cast<Byte*>(&v);
862
- *dest++ = *src++;
863
- *dest++ = *src++;
864
- *dest++ = *src++;
865
- *dest++ = *src++;
866
- *dest++ = *src++;
867
- *dest++ = *src++;
868
- *dest++ = *src++;
869
- *dest = *src;
870
- #endif
871
- }
872
-
873
- void
874
- IceInternal::BasicStream::read(vector<Long>& v)
875
- {
876
- Int sz = readAndCheckSeqSize(static_cast<int>(sizeof(Long)));
877
- if(sz > 0)
878
- {
879
- Container::iterator begin = i;
880
- i += sz * static_cast<int>(sizeof(Long));
881
- v.resize(sz);
882
- #ifdef ICE_BIG_ENDIAN
883
- const Byte* src = &(*begin);
884
- Byte* dest = reinterpret_cast<Byte*>(&v[0]) + sizeof(Long) - 1;
885
- for(int j = 0 ; j < sz ; ++j)
886
- {
887
- *dest-- = *src++;
888
- *dest-- = *src++;
889
- *dest-- = *src++;
890
- *dest-- = *src++;
891
- *dest-- = *src++;
892
- *dest-- = *src++;
893
- *dest-- = *src++;
894
- *dest-- = *src++;
895
- dest += 2 * sizeof(Long);
896
- }
897
- #else
898
- copy(begin, i, reinterpret_cast<Byte*>(&v[0]));
899
- #endif
900
- }
901
- else
902
- {
903
- v.clear();
904
- }
905
- }
906
-
907
- void
908
- IceInternal::BasicStream::read(pair<const Long*, const Long*>& v, IceUtil::ScopedArray<Long>& result)
909
- {
910
- Int sz = readAndCheckSeqSize(static_cast<int>(sizeof(Long)));
911
- if(sz > 0)
912
- {
913
- #if defined(__i386) || defined(_M_IX86) || defined(__x86_64) || defined(_M_X64)
914
- v.first = reinterpret_cast<Long*>(i);
915
- i += sz * static_cast<int>(sizeof(Long));
916
- v.second = reinterpret_cast<Long*>(i);
917
- #else
918
- result.reset(new Long[sz]);
919
- v.first = result.get();
920
- v.second = result.get() + sz;
921
-
922
- Container::iterator begin = i;
923
- i += sz * static_cast<int>(sizeof(Long));
924
- # ifdef ICE_BIG_ENDIAN
925
- const Byte* src = &(*begin);
926
- Byte* dest = reinterpret_cast<Byte*>(&result[0]) + sizeof(Long) - 1;
927
- for(int j = 0 ; j < sz ; ++j)
928
- {
929
- *dest-- = *src++;
930
- *dest-- = *src++;
931
- *dest-- = *src++;
932
- *dest-- = *src++;
933
- *dest-- = *src++;
934
- *dest-- = *src++;
935
- *dest-- = *src++;
936
- *dest-- = *src++;
937
- dest += 2 * sizeof(Long);
938
- }
939
- # else
940
- copy(begin, i, reinterpret_cast<Byte*>(&result[0]));
941
- # endif
942
- #endif
943
- }
944
- else
945
- {
946
- result.reset();
947
- v.first = v.second = 0;
948
- }
949
- }
950
-
951
- void
952
- IceInternal::BasicStream::write(Float v)
953
- {
954
- Container::size_type pos = b.size();
955
- resize(pos + sizeof(Float));
956
- Byte* dest = &b[pos];
957
- #ifdef ICE_BIG_ENDIAN
958
- const Byte* src = reinterpret_cast<const Byte*>(&v) + sizeof(Float) - 1;
959
- *dest++ = *src--;
960
- *dest++ = *src--;
961
- *dest++ = *src--;
962
- *dest = *src;
963
- #else
964
- const Byte* src = reinterpret_cast<const Byte*>(&v);
965
- *dest++ = *src++;
966
- *dest++ = *src++;
967
- *dest++ = *src++;
968
- *dest = *src;
969
- #endif
970
- }
971
-
972
- void
973
- IceInternal::BasicStream::write(const Float* begin, const Float* end)
974
- {
975
- Int sz = static_cast<Int>(end - begin);
976
- writeSize(sz);
977
- if(sz > 0)
978
- {
979
- Container::size_type pos = b.size();
980
- resize(pos + sz * sizeof(Float));
981
- #ifdef ICE_BIG_ENDIAN
982
- const Byte* src = reinterpret_cast<const Byte*>(begin) + sizeof(Float) - 1;
983
- Byte* dest = &(*(b.begin() + pos));
984
- for(int j = 0 ; j < sz ; ++j)
985
- {
986
- *dest++ = *src--;
987
- *dest++ = *src--;
988
- *dest++ = *src--;
989
- *dest++ = *src--;
990
- src += 2 * sizeof(Float);
991
- }
992
- #else
993
- memcpy(&b[pos], reinterpret_cast<const Byte*>(begin), sz * sizeof(Float));
994
- #endif
995
- }
996
- }
997
-
998
- void
999
- IceInternal::BasicStream::read(Float& v)
1000
- {
1001
- if(b.end() - i < static_cast<int>(sizeof(Float)))
1002
- {
1003
- throw UnmarshalOutOfBoundsException(__FILE__, __LINE__);
1004
- }
1005
- const Byte* src = &(*i);
1006
- i += sizeof(Float);
1007
- #ifdef ICE_BIG_ENDIAN
1008
- Byte* dest = reinterpret_cast<Byte*>(&v) + sizeof(Float) - 1;
1009
- *dest-- = *src++;
1010
- *dest-- = *src++;
1011
- *dest-- = *src++;
1012
- *dest = *src;
1013
- #else
1014
- Byte* dest = reinterpret_cast<Byte*>(&v);
1015
- *dest++ = *src++;
1016
- *dest++ = *src++;
1017
- *dest++ = *src++;
1018
- *dest = *src;
1019
- #endif
1020
- }
1021
-
1022
- void
1023
- IceInternal::BasicStream::read(vector<Float>& v)
1024
- {
1025
- Int sz = readAndCheckSeqSize(static_cast<int>(sizeof(Float)));
1026
- if(sz > 0)
1027
- {
1028
- Container::iterator begin = i;
1029
- i += sz * static_cast<int>(sizeof(Float));
1030
- v.resize(sz);
1031
- #ifdef ICE_BIG_ENDIAN
1032
- const Byte* src = &(*begin);
1033
- Byte* dest = reinterpret_cast<Byte*>(&v[0]) + sizeof(Float) - 1;
1034
- for(int j = 0 ; j < sz ; ++j)
1035
- {
1036
- *dest-- = *src++;
1037
- *dest-- = *src++;
1038
- *dest-- = *src++;
1039
- *dest-- = *src++;
1040
- dest += 2 * sizeof(Float);
1041
- }
1042
- #else
1043
- copy(begin, i, reinterpret_cast<Byte*>(&v[0]));
1044
- #endif
1045
- }
1046
- else
1047
- {
1048
- v.clear();
1049
- }
1050
- }
1051
-
1052
- void
1053
- IceInternal::BasicStream::read(pair<const Float*, const Float*>& v, IceUtil::ScopedArray<Float>& result)
1054
- {
1055
- Int sz = readAndCheckSeqSize(static_cast<int>(sizeof(Float)));
1056
- if(sz > 0)
1057
- {
1058
- #if defined(__i386) || defined(_M_IX86) || defined(__x86_64) || defined(_M_X64)
1059
- v.first = reinterpret_cast<Float*>(i);
1060
- i += sz * static_cast<int>(sizeof(Float));
1061
- v.second = reinterpret_cast<Float*>(i);
1062
- #else
1063
- result.reset(new Float[sz]);
1064
- v.first = result.get();
1065
- v.second = result.get() + sz;
1066
-
1067
- Container::iterator begin = i;
1068
- i += sz * static_cast<int>(sizeof(Float));
1069
- # ifdef ICE_BIG_ENDIAN
1070
- const Byte* src = &(*begin);
1071
- Byte* dest = reinterpret_cast<Byte*>(&result[0]) + sizeof(Float) - 1;
1072
- for(int j = 0 ; j < sz ; ++j)
1073
- {
1074
- *dest-- = *src++;
1075
- *dest-- = *src++;
1076
- *dest-- = *src++;
1077
- *dest-- = *src++;
1078
- dest += 2 * sizeof(Float);
1079
- }
1080
- # else
1081
- copy(begin, i, reinterpret_cast<Byte*>(&result[0]));
1082
- # endif
1083
- #endif
1084
- }
1085
- else
1086
- {
1087
- result.reset();
1088
- v.first = v.second = 0;
1089
- }
1090
- }
1091
-
1092
- void
1093
- IceInternal::BasicStream::write(Double v)
1094
- {
1095
- Container::size_type pos = b.size();
1096
- resize(pos + sizeof(Double));
1097
- Byte* dest = &b[pos];
1098
- #ifdef ICE_BIG_ENDIAN
1099
- const Byte* src = reinterpret_cast<const Byte*>(&v) + sizeof(Double) - 1;
1100
- *dest++ = *src--;
1101
- *dest++ = *src--;
1102
- *dest++ = *src--;
1103
- *dest++ = *src--;
1104
- *dest++ = *src--;
1105
- *dest++ = *src--;
1106
- *dest++ = *src--;
1107
- *dest = *src;
1108
- #else
1109
- const Byte* src = reinterpret_cast<const Byte*>(&v);
1110
- # if defined(ICE_LITTLEBYTE_BIGWORD)
1111
- dest[4] = *src++;
1112
- dest[5] = *src++;
1113
- dest[6] = *src++;
1114
- dest[7] = *src++;
1115
- dest[0] = *src++;
1116
- dest[1] = *src++;
1117
- dest[2] = *src++;
1118
- dest[3] = *src;
1119
- # else
1120
- *dest++ = *src++;
1121
- *dest++ = *src++;
1122
- *dest++ = *src++;
1123
- *dest++ = *src++;
1124
- *dest++ = *src++;
1125
- *dest++ = *src++;
1126
- *dest++ = *src++;
1127
- *dest = *src;
1128
- # endif
1129
- #endif
1130
- }
1131
-
1132
- void
1133
- IceInternal::BasicStream::write(const Double* begin, const Double* end)
1134
- {
1135
- Int sz = static_cast<Int>(end - begin);
1136
- writeSize(sz);
1137
- if(sz > 0)
1138
- {
1139
- Container::size_type pos = b.size();
1140
- resize(pos + sz * sizeof(Double));
1141
- #ifdef ICE_BIG_ENDIAN
1142
- const Byte* src = reinterpret_cast<const Byte*>(begin) + sizeof(Double) - 1;
1143
- Byte* dest = &(*(b.begin() + pos));
1144
- for(int j = 0 ; j < sz ; ++j)
1145
- {
1146
- *dest++ = *src--;
1147
- *dest++ = *src--;
1148
- *dest++ = *src--;
1149
- *dest++ = *src--;
1150
- *dest++ = *src--;
1151
- *dest++ = *src--;
1152
- *dest++ = *src--;
1153
- *dest++ = *src--;
1154
- src += 2 * sizeof(Double);
1155
- }
1156
- #elif defined(ICE_LITTLEBYTE_BIGWORD)
1157
- const Byte* src = reinterpret_cast<const Byte*>(begin);
1158
- Byte* dest = &(*(b.begin() + pos));
1159
- for(int j = 0 ; j < sz ; ++j)
1160
- {
1161
- dest[4] = *src++;
1162
- dest[5] = *src++;
1163
- dest[6] = *src++;
1164
- dest[7] = *src++;
1165
- dest[0] = *src++;
1166
- dest[1] = *src++;
1167
- dest[2] = *src++;
1168
- dest[3] = *src++;
1169
- dest += sizeof(Double);
1170
- }
1171
- #else
1172
- memcpy(&b[pos], reinterpret_cast<const Byte*>(begin), sz * sizeof(Double));
1173
- #endif
1174
- }
1175
- }
1176
-
1177
- void
1178
- IceInternal::BasicStream::read(Double& v)
1179
- {
1180
- if(b.end() - i < static_cast<int>(sizeof(Double)))
1181
- {
1182
- throw UnmarshalOutOfBoundsException(__FILE__, __LINE__);
1183
- }
1184
- const Byte* src = &(*i);
1185
- i += sizeof(Double);
1186
- #ifdef ICE_BIG_ENDIAN
1187
- Byte* dest = reinterpret_cast<Byte*>(&v) + sizeof(Double) - 1;
1188
- *dest-- = *src++;
1189
- *dest-- = *src++;
1190
- *dest-- = *src++;
1191
- *dest-- = *src++;
1192
- *dest-- = *src++;
1193
- *dest-- = *src++;
1194
- *dest-- = *src++;
1195
- *dest = *src;
1196
- #else
1197
- Byte* dest = reinterpret_cast<Byte*>(&v);
1198
- # if defined(ICE_LITTLEBYTE_BIGWORD)
1199
- dest[4] = *src++;
1200
- dest[5] = *src++;
1201
- dest[6] = *src++;
1202
- dest[7] = *src++;
1203
- dest[0] = *src++;
1204
- dest[1] = *src++;
1205
- dest[2] = *src++;
1206
- dest[3] = *src;
1207
- # else
1208
- *dest++ = *src++;
1209
- *dest++ = *src++;
1210
- *dest++ = *src++;
1211
- *dest++ = *src++;
1212
- *dest++ = *src++;
1213
- *dest++ = *src++;
1214
- *dest++ = *src++;
1215
- *dest = *src;
1216
- # endif
1217
- #endif
1218
- }
1219
-
1220
- void
1221
- IceInternal::BasicStream::read(vector<Double>& v)
1222
- {
1223
- Int sz = readAndCheckSeqSize(static_cast<int>(sizeof(Double)));
1224
- if(sz > 0)
1225
- {
1226
- Container::iterator begin = i;
1227
- i += sz * static_cast<int>(sizeof(Double));
1228
- v.resize(sz);
1229
- #ifdef ICE_BIG_ENDIAN
1230
- const Byte* src = &(*begin);
1231
- Byte* dest = reinterpret_cast<Byte*>(&v[0]) + sizeof(Double) - 1;
1232
- for(int j = 0 ; j < sz ; ++j)
1233
- {
1234
- *dest-- = *src++;
1235
- *dest-- = *src++;
1236
- *dest-- = *src++;
1237
- *dest-- = *src++;
1238
- *dest-- = *src++;
1239
- *dest-- = *src++;
1240
- *dest-- = *src++;
1241
- *dest-- = *src++;
1242
- dest += 2 * sizeof(Double);
1243
- }
1244
- #elif defined(ICE_LITTLEBYTE_BIGWORD)
1245
- const Byte* src = &(*begin);
1246
- Byte* dest = reinterpret_cast<Byte*>(&v[0]);
1247
- for(int j = 0 ; j < sz ; ++j)
1248
- {
1249
- dest[4] = *src++;
1250
- dest[5] = *src++;
1251
- dest[6] = *src++;
1252
- dest[7] = *src++;
1253
- dest[0] = *src++;
1254
- dest[1] = *src++;
1255
- dest[2] = *src++;
1256
- dest[3] = *src++;
1257
- dest += sizeof(Double);
1258
- }
1259
- #else
1260
- copy(begin, i, reinterpret_cast<Byte*>(&v[0]));
1261
- #endif
1262
- }
1263
- else
1264
- {
1265
- v.clear();
1266
- }
1267
- }
1268
-
1269
- void
1270
- IceInternal::BasicStream::read(pair<const Double*, const Double*>& v, IceUtil::ScopedArray<Double>& result)
1271
- {
1272
- Int sz = readAndCheckSeqSize(static_cast<int>(sizeof(Double)));
1273
- if(sz > 0)
1274
- {
1275
- #if defined(__i386) || defined(_M_IX86) || defined(__x86_64) || defined(_M_X64)
1276
- v.first = reinterpret_cast<Double*>(i);
1277
- i += sz * static_cast<int>(sizeof(Double));
1278
- v.second = reinterpret_cast<Double*>(i);
1279
- #else
1280
- result.reset(new Double[sz]);
1281
- v.first = result.get();
1282
- v.second = result.get() + sz;
1283
-
1284
- Container::iterator begin = i;
1285
- i += sz * static_cast<int>(sizeof(Double));
1286
- # ifdef ICE_BIG_ENDIAN
1287
- const Byte* src = &(*begin);
1288
- Byte* dest = reinterpret_cast<Byte*>(&result[0]) + sizeof(Double) - 1;
1289
- for(int j = 0 ; j < sz ; ++j)
1290
- {
1291
- *dest-- = *src++;
1292
- *dest-- = *src++;
1293
- *dest-- = *src++;
1294
- *dest-- = *src++;
1295
- *dest-- = *src++;
1296
- *dest-- = *src++;
1297
- *dest-- = *src++;
1298
- *dest-- = *src++;
1299
- dest += 2 * sizeof(Double);
1300
- }
1301
- # elif defined(ICE_LITTLEBYTE_BIGWORD)
1302
- const Byte* src = &(*begin);
1303
- Byte* dest = reinterpret_cast<Byte*>(&result[0]);
1304
- for(int j = 0 ; j < sz ; ++j)
1305
- {
1306
- dest[4] = *src++;
1307
- dest[5] = *src++;
1308
- dest[6] = *src++;
1309
- dest[7] = *src++;
1310
- dest[0] = *src++;
1311
- dest[1] = *src++;
1312
- dest[2] = *src++;
1313
- dest[3] = *src++;
1314
- dest += sizeof(Double);
1315
- }
1316
-
1317
- # else
1318
- copy(begin, i, reinterpret_cast<Byte*>(&result[0]));
1319
- # endif
1320
- #endif
1321
- }
1322
- else
1323
- {
1324
- result.reset();
1325
- v.first = v.second = 0;
1326
- }
1327
- }
1328
-
1329
- //
1330
- // NOTE: This member function is intentionally omitted in order to
1331
- // cause a link error if it is used. This is for efficiency reasons:
1332
- // writing a const char * requires a traversal of the string to get
1333
- // the string length first, which takes O(n) time, whereas getting the
1334
- // string length from a std::string takes constant time.
1335
- //
1336
- /*
1337
- void
1338
- IceInternal::BasicStream::write(const char*)
1339
- {
1340
- }
1341
- */
1342
-
1343
- void
1344
- IceInternal::BasicStream::writeConverted(const char* vdata, size_t vsize)
1345
- {
1346
- //
1347
- // What is the size of the resulting UTF-8 encoded string?
1348
- // Impossible to tell, so we guess. If we don't guess correctly,
1349
- // we'll have to fix the mistake afterwards
1350
- //
1351
- try
1352
- {
1353
- Int guessedSize = static_cast<Int>(vsize);
1354
- writeSize(guessedSize); // writeSize() only writes the size; it does not reserve any buffer space.
1355
-
1356
- size_t firstIndex = b.size();
1357
- StreamUTF8BufferI buffer(*this);
1358
-
1359
- Byte* lastByte = _stringConverter->toUTF8(vdata, vdata + vsize, buffer);
1360
- if(lastByte != b.end())
1361
- {
1362
- resize(lastByte - b.begin());
1363
- }
1364
- size_t lastIndex = b.size();
1365
-
1366
- Int actualSize = static_cast<Int>(lastIndex - firstIndex);
1367
-
1368
- //
1369
- // Check against the guess
1370
- //
1371
- if(guessedSize != actualSize)
1372
- {
1373
- if(guessedSize <= 254 && actualSize > 254)
1374
- {
1375
- //
1376
- // Move the UTF-8 sequence 4 bytes further
1377
- // Use memmove instead of memcpy since the source and destination typically overlap.
1378
- //
1379
- resize(b.size() + 4);
1380
- memmove(b.begin() + firstIndex + 4, b.begin() + firstIndex, actualSize);
1381
- }
1382
- else if(guessedSize > 254 && actualSize <= 254)
1383
- {
1384
- //
1385
- // Move the UTF-8 sequence 4 bytes back
1386
- //
1387
- memmove(b.begin() + firstIndex - 4, b.begin() + firstIndex, actualSize);
1388
- resize(b.size() - 4);
1389
- }
1390
-
1391
- if(guessedSize <= 254)
1392
- {
1393
- rewriteSize(actualSize, b.begin() + firstIndex - 1);
1394
- }
1395
- else
1396
- {
1397
- rewriteSize(actualSize, b.begin() + firstIndex - 1 - 4);
1398
- }
1399
- }
1400
- }
1401
- catch(const IceUtil::IllegalConversionException& ex)
1402
- {
1403
- throw StringConversionException(__FILE__, __LINE__, ex.reason());
1404
- }
1405
- }
1406
-
1407
- void
1408
- IceInternal::BasicStream::write(const string* begin, const string* end, bool convert)
1409
- {
1410
- Int sz = static_cast<Int>(end - begin);
1411
- writeSize(sz);
1412
- if(sz > 0)
1413
- {
1414
- for(int i = 0; i < sz; ++i)
1415
- {
1416
- write(begin[i], convert);
1417
- }
1418
- }
1419
- }
1420
-
1421
- void
1422
- IceInternal::BasicStream::readConverted(string& v, int sz)
1423
- {
1424
- try
1425
- {
1426
- _stringConverter->fromUTF8(i, i + sz, v);
1427
- }
1428
- catch(const IceUtil::IllegalConversionException& ex)
1429
- {
1430
- throw StringConversionException(__FILE__, __LINE__, ex.reason());
1431
- }
1432
- }
1433
-
1434
- void
1435
- IceInternal::BasicStream::read(vector<string>& v, bool convert)
1436
- {
1437
- Int sz = readAndCheckSeqSize(1);
1438
- if(sz > 0)
1439
- {
1440
- v.resize(sz);
1441
- for(int j = 0; j < sz; ++j)
1442
- {
1443
- read(v[j], convert);
1444
- }
1445
- }
1446
- else
1447
- {
1448
- v.clear();
1449
- }
1450
- }
1451
-
1452
- void
1453
- IceInternal::BasicStream::write(const wstring& v)
1454
- {
1455
- if(v.empty())
1456
- {
1457
- writeSize(0);
1458
- return;
1459
- }
1460
-
1461
- //
1462
- // What is the size of the resulting UTF-8 encoded string?
1463
- // Impossible to tell, so we guess. If we don't guess correctly,
1464
- // we'll have to fix the mistake afterwards
1465
- //
1466
- try
1467
- {
1468
- Int guessedSize = static_cast<Int>(v.size());
1469
- writeSize(guessedSize); // writeSize() only writes the size; it does not reserve any buffer space.
1470
-
1471
- size_t firstIndex = b.size();
1472
- StreamUTF8BufferI buffer(*this);
1473
-
1474
- Byte* lastByte = _wstringConverter->toUTF8(v.data(), v.data() + v.size(), buffer);
1475
- if(lastByte != b.end())
1476
- {
1477
- resize(lastByte - b.begin());
1478
- }
1479
- size_t lastIndex = b.size();
1480
-
1481
- Int actualSize = static_cast<Int>(lastIndex - firstIndex);
1482
-
1483
- //
1484
- // Check against the guess
1485
- //
1486
- if(guessedSize != actualSize)
1487
- {
1488
- if(guessedSize <= 254 && actualSize > 254)
1489
- {
1490
- //
1491
- // Move the UTF-8 sequence 4 bytes further
1492
- // Use memmove instead of memcpy since the source and destination typically overlap.
1493
- //
1494
- resize(b.size() + 4);
1495
- memmove(b.begin() + firstIndex + 4, b.begin() + firstIndex, actualSize);
1496
- }
1497
- else if(guessedSize > 254 && actualSize <= 254)
1498
- {
1499
- //
1500
- // Move the UTF-8 sequence 4 bytes back
1501
- //
1502
- memmove(b.begin() + firstIndex - 4, b.begin() + firstIndex, actualSize);
1503
- resize(b.size() - 4);
1504
- }
1505
-
1506
- if(guessedSize <= 254)
1507
- {
1508
- rewriteSize(actualSize, b.begin() + firstIndex - 1);
1509
- }
1510
- else
1511
- {
1512
- rewriteSize(actualSize, b.begin() + firstIndex - 1 - 4);
1513
- }
1514
- }
1515
- }
1516
- catch(const IceUtil::IllegalConversionException& ex)
1517
- {
1518
- throw StringConversionException(__FILE__, __LINE__, ex.reason());
1519
- }
1520
- }
1521
-
1522
- void
1523
- IceInternal::BasicStream::write(const wstring* begin, const wstring* end)
1524
- {
1525
- Int sz = static_cast<Int>(end - begin);
1526
- writeSize(sz);
1527
- if(sz > 0)
1528
- {
1529
- for(int i = 0; i < sz; ++i)
1530
- {
1531
- write(begin[i]);
1532
- }
1533
- }
1534
- }
1535
-
1536
- void
1537
- IceInternal::BasicStream::read(wstring& v)
1538
- {
1539
- Int sz = readSize();
1540
- if(sz > 0)
1541
- {
1542
- if(b.end() - i < sz)
1543
- {
1544
- throwUnmarshalOutOfBoundsException(__FILE__, __LINE__);
1545
- }
1546
-
1547
- try
1548
- {
1549
- _wstringConverter->fromUTF8(i, i + sz, v);
1550
- i += sz;
1551
- }
1552
- catch(const IceUtil::IllegalConversionException& ex)
1553
- {
1554
- throw StringConversionException(__FILE__, __LINE__, ex.reason());
1555
- }
1556
- }
1557
- else
1558
- {
1559
- v.clear();
1560
- }
1561
- }
1562
-
1563
- void
1564
- IceInternal::BasicStream::read(vector<wstring>& v)
1565
- {
1566
- Int sz = readAndCheckSeqSize(1);
1567
- if(sz > 0)
1568
- {
1569
- v.resize(sz);
1570
- for(int j = 0; j < sz; ++j)
1571
- {
1572
- read(v[j]);
1573
- }
1574
- }
1575
- else
1576
- {
1577
- v.clear();
1578
- }
1579
- }
1580
-
1581
- void
1582
- IceInternal::BasicStream::write(const ObjectPrx& v)
1583
- {
1584
- _instance->proxyFactory()->proxyToStream(v, this);
1585
- }
1586
-
1587
- void
1588
- IceInternal::BasicStream::read(ObjectPrx& v)
1589
- {
1590
- v = _instance->proxyFactory()->streamToProxy(this);
1591
- }
1592
-
1593
- Int
1594
- IceInternal::BasicStream::readEnum(Int maxValue)
1595
- {
1596
- if(getReadEncoding() == Encoding_1_0)
1597
- {
1598
- if(maxValue < 127)
1599
- {
1600
- Byte value;
1601
- read(value);
1602
- return value;
1603
- }
1604
- else if(maxValue < 32767)
1605
- {
1606
- Short value;
1607
- read(value);
1608
- return value;
1609
- }
1610
- else
1611
- {
1612
- Int value;
1613
- read(value);
1614
- return value;
1615
- }
1616
- }
1617
- else
1618
- {
1619
- return readSize();
1620
- }
1621
- }
1622
-
1623
- void
1624
- IceInternal::BasicStream::writeEnum(Int v, Int maxValue)
1625
- {
1626
- if(getWriteEncoding() == Encoding_1_0)
1627
- {
1628
- if(maxValue < 127)
1629
- {
1630
- write(static_cast<Byte>(v));
1631
- }
1632
- else if(maxValue < 32767)
1633
- {
1634
- write(static_cast<Short>(v));
1635
- }
1636
- else
1637
- {
1638
- write(v);
1639
- }
1640
- }
1641
- else
1642
- {
1643
- writeSize(v);
1644
- }
1645
- }
1646
-
1647
- void
1648
- IceInternal::BasicStream::writeException(const UserException& e)
1649
- {
1650
- initWriteEncaps();
1651
- _currentWriteEncaps->encoder->write(e);
1652
- }
1653
-
1654
- void
1655
- IceInternal::BasicStream::throwException(const UserExceptionFactoryPtr& factory)
1656
- {
1657
- initReadEncaps();
1658
- _currentReadEncaps->decoder->throwException(factory);
1659
- }
1660
-
1661
- void
1662
- IceInternal::BasicStream::sliceObjects(bool doSlice)
1663
- {
1664
- _sliceObjects = doSlice;
1665
- }
1666
-
1667
- bool
1668
- IceInternal::BasicStream::readOptImpl(Int readTag, OptionalFormat expectedFormat)
1669
- {
1670
- if(getReadEncoding() == Encoding_1_0)
1671
- {
1672
- return false; // Optional members aren't supported with the 1.0 encoding.
1673
- }
1674
-
1675
- while(true)
1676
- {
1677
- if(i >= b.begin() + _currentReadEncaps->start + _currentReadEncaps->sz)
1678
- {
1679
- return false; // End of encapsulation also indicates end of optionals.
1680
- }
1681
-
1682
- Byte v;
1683
- read(v);
1684
- if(v == OPTIONAL_END_MARKER)
1685
- {
1686
- --i; // Rewind
1687
- return false;
1688
- }
1689
-
1690
- OptionalFormat format = static_cast<OptionalFormat>(v & 0x07); // First 3 bits.
1691
- Int tag = static_cast<Int>(v >> 3);
1692
- if(tag == 30)
1693
- {
1694
- tag = readSize();
1695
- }
1696
-
1697
- if(tag > readTag)
1698
- {
1699
- i -= tag < 30 ? 1 : (tag < 255 ? 2 : 6); // Rewind
1700
- return false; // No optional data members with the requested tag.
1701
- }
1702
- else if(tag < readTag)
1703
- {
1704
- skipOpt(format); // Skip optional data members
1705
- }
1706
- else
1707
- {
1708
- if(format != expectedFormat)
1709
- {
1710
- ostringstream os;
1711
- os << "invalid optional data member `" << tag << "': unexpected format";
1712
- throw MarshalException(__FILE__, __LINE__, os.str());
1713
- }
1714
- return true;
1715
- }
1716
- }
1717
- return true; // Keep the compiler happy.
1718
- }
1719
-
1720
- bool
1721
- IceInternal::BasicStream::writeOptImpl(Int tag, OptionalFormat type)
1722
- {
1723
- if(getWriteEncoding() == Encoding_1_0)
1724
- {
1725
- return false; // Optional members aren't supported with the 1.0 encoding.
1726
- }
1727
-
1728
- Byte v = static_cast<Byte>(type);
1729
- if(tag < 30)
1730
- {
1731
- v |= static_cast<Byte>(tag << 3);
1732
- write(v);
1733
- }
1734
- else
1735
- {
1736
- v |= 0xF0; // tag = 30
1737
- write(v);
1738
- writeSize(tag);
1739
- }
1740
- return true;
1741
- }
1742
-
1743
- void
1744
- IceInternal::BasicStream::skipOpt(OptionalFormat type)
1745
- {
1746
- switch(type)
1747
- {
1748
- case Ice::OptionalFormatF1:
1749
- {
1750
- skip(1);
1751
- break;
1752
- }
1753
- case Ice::OptionalFormatF2:
1754
- {
1755
- skip(2);
1756
- break;
1757
- }
1758
- case Ice::OptionalFormatF4:
1759
- {
1760
- skip(4);
1761
- break;
1762
- }
1763
- case Ice::OptionalFormatF8:
1764
- {
1765
- skip(8);
1766
- break;
1767
- }
1768
- case Ice::OptionalFormatSize:
1769
- {
1770
- skipSize();
1771
- break;
1772
- }
1773
- case Ice::OptionalFormatVSize:
1774
- {
1775
- skip(readSize());
1776
- break;
1777
- }
1778
- case Ice::OptionalFormatFSize:
1779
- {
1780
- Int sz;
1781
- read(sz);
1782
- skip(sz);
1783
- break;
1784
- }
1785
- case Ice::OptionalFormatClass:
1786
- {
1787
- read(0, 0);
1788
- break;
1789
- }
1790
- }
1791
- }
1792
-
1793
- void
1794
- BasicStream::skipOpts()
1795
- {
1796
- //
1797
- // Skip remaining un-read optional members.
1798
- //
1799
- while(true)
1800
- {
1801
- if(i >= b.begin() + _currentReadEncaps->start + _currentReadEncaps->sz)
1802
- {
1803
- return; // End of encapsulation also indicates end of optionals.
1804
- }
1805
-
1806
- Byte v;
1807
- read(v);
1808
- if(v == OPTIONAL_END_MARKER)
1809
- {
1810
- return;
1811
- }
1812
-
1813
- OptionalFormat format = static_cast<OptionalFormat>(v & 0x07); // Read first 3 bits.
1814
- if(static_cast<Int>(v >> 3) == 30)
1815
- {
1816
- skipSize();
1817
- }
1818
- skipOpt(format);
1819
- }
1820
- }
1821
-
1822
- void
1823
- IceInternal::BasicStream::throwUnmarshalOutOfBoundsException(const char* file, int line)
1824
- {
1825
- throw UnmarshalOutOfBoundsException(file, line);
1826
- }
1827
-
1828
- void
1829
- IceInternal::BasicStream::throwEncapsulationException(const char* file, int line)
1830
- {
1831
- throw EncapsulationException(file, line);
1832
- }
1833
-
1834
- void
1835
- IceInternal::BasicStream::initReadEncaps()
1836
- {
1837
- if(!_currentReadEncaps) // Lazy initialization.
1838
- {
1839
- _currentReadEncaps = &_preAllocatedReadEncaps;
1840
- _currentReadEncaps->sz = static_cast<Ice::Int>(b.size());
1841
- }
1842
-
1843
- if(!_currentReadEncaps->decoder) // Lazy initialization.
1844
- {
1845
- ObjectFactoryManagerPtr factoryManager = _instance->servantFactoryManager();
1846
- size_t classGraphDepthMax = _instance->classGraphDepthMax();
1847
- if(_currentReadEncaps->encoding == Encoding_1_0)
1848
- {
1849
- _currentReadEncaps->decoder = new EncapsDecoder10(this, _currentReadEncaps, _sliceObjects,
1850
- classGraphDepthMax, factoryManager);
1851
- }
1852
- else
1853
- {
1854
- _currentReadEncaps->decoder = new EncapsDecoder11(this, _currentReadEncaps, _sliceObjects,
1855
- classGraphDepthMax, factoryManager);
1856
- }
1857
- }
1858
- }
1859
-
1860
- void
1861
- IceInternal::BasicStream::initWriteEncaps()
1862
- {
1863
- if(!_currentWriteEncaps) // Lazy initialization.
1864
- {
1865
- _currentWriteEncaps = &_preAllocatedWriteEncaps;
1866
- _currentWriteEncaps->start = b.size();
1867
- }
1868
-
1869
- if(_currentWriteEncaps->format == Ice::DefaultFormat)
1870
- {
1871
- _currentWriteEncaps->format = _instance->defaultsAndOverrides()->defaultFormat;
1872
- }
1873
-
1874
- if(!_currentWriteEncaps->encoder) // Lazy initialization.
1875
- {
1876
- if(_currentWriteEncaps->encoding == Encoding_1_0)
1877
- {
1878
- _currentWriteEncaps->encoder = new EncapsEncoder10(this, _currentWriteEncaps);
1879
- }
1880
- else
1881
- {
1882
- _currentWriteEncaps->encoder = new EncapsEncoder11(this, _currentWriteEncaps);
1883
- }
1884
- }
1885
- }
1886
-
1887
- string
1888
- IceInternal::BasicStream::EncapsDecoder::readTypeId(bool isIndex)
1889
- {
1890
- if(isIndex)
1891
- {
1892
- Int index = _stream->readSize();
1893
- TypeIdReadMap::const_iterator k = _typeIdMap.find(index);
1894
- if(k == _typeIdMap.end())
1895
- {
1896
- throw UnmarshalOutOfBoundsException(__FILE__, __LINE__);
1897
- }
1898
- return k->second;
1899
- }
1900
- else
1901
- {
1902
- string typeId;
1903
- _stream->read(typeId, false);
1904
- _typeIdMap.insert(make_pair(++_typeIdIndex, typeId));
1905
- return typeId;
1906
- }
1907
- }
1908
-
1909
- Ice::ObjectPtr
1910
- IceInternal::BasicStream::EncapsDecoder::newInstance(const string& typeId)
1911
- {
1912
- Ice::ObjectPtr v;
1913
-
1914
- //
1915
- // Try to find a factory registered for the specific type.
1916
- //
1917
- ObjectFactoryPtr userFactory = _servantFactoryManager->find(typeId);
1918
- if(userFactory)
1919
- {
1920
- v = userFactory->create(typeId);
1921
- }
1922
-
1923
- //
1924
- // If that fails, invoke the default factory if one has been
1925
- // registered.
1926
- //
1927
- if(!v)
1928
- {
1929
- userFactory = _servantFactoryManager->find("");
1930
- if(userFactory)
1931
- {
1932
- v = userFactory->create(typeId);
1933
- }
1934
- }
1935
-
1936
- //
1937
- // Last chance: check the table of static factories (i.e.,
1938
- // automatically generated factories for concrete classes).
1939
- //
1940
- if(!v)
1941
- {
1942
- ObjectFactoryPtr of = IceInternal::factoryTable->getObjectFactory(typeId);
1943
- if(of)
1944
- {
1945
- v = of->create(typeId);
1946
- assert(v);
1947
- }
1948
- }
1949
-
1950
- return v;
1951
- }
1952
-
1953
- void
1954
- IceInternal::BasicStream::EncapsDecoder::addPatchEntry(Int index, PatchFunc patchFunc, void* patchAddr)
1955
- {
1956
- assert(index > 0);
1957
-
1958
- //
1959
- // Check if already un-marshalled the object. If that's the case,
1960
- // just patch the object smart pointer and we're done.
1961
- //
1962
- IndexToPtrMap::iterator p = _unmarshaledMap.find(index);
1963
- if(p != _unmarshaledMap.end())
1964
- {
1965
- (*patchFunc)(patchAddr, p->second);
1966
- return;
1967
- }
1968
-
1969
- //
1970
- // Add patch entry if the object isn't un-marshalled yet, the
1971
- // smart pointer will be patched when the instance is
1972
- // un-marshalled.
1973
- //
1974
-
1975
- PatchMap::iterator q = _patchMap.find(index);
1976
- if(q == _patchMap.end())
1977
- {
1978
- //
1979
- // We have no outstanding instances to be patched for this
1980
- // index, so make a new entry in the patch map.
1981
- //
1982
- q = _patchMap.insert(make_pair(index, PatchList())).first;
1983
- }
1984
-
1985
- //
1986
- // Append a patch entry for this instance.
1987
- //
1988
- PatchEntry e;
1989
- e.patchFunc = patchFunc;
1990
- e.patchAddr = patchAddr;
1991
- e.classGraphDepth = _classGraphDepth;
1992
- q->second.push_back(e);
1993
- }
1994
-
1995
- void
1996
- IceInternal::BasicStream::EncapsDecoder::unmarshal(Int index, const Ice::ObjectPtr& v)
1997
- {
1998
- //
1999
- // Add the object to the map of un-marshalled objects, this must
2000
- // be done before reading the objects (for circular references).
2001
- //
2002
- _unmarshaledMap.insert(make_pair(index, v));
2003
-
2004
- //
2005
- // Read the object.
2006
- //
2007
- v->__read(_stream);
2008
-
2009
- //
2010
- // Patch all instances now that the object is un-marshalled.
2011
- //
2012
- PatchMap::iterator patchPos = _patchMap.find(index);
2013
- if(patchPos != _patchMap.end())
2014
- {
2015
- assert(patchPos->second.size() > 0);
2016
-
2017
- //
2018
- // Patch all pointers that refer to the instance.
2019
- //
2020
- for(PatchList::iterator k = patchPos->second.begin(); k != patchPos->second.end(); ++k)
2021
- {
2022
- (*k->patchFunc)(k->patchAddr, v);
2023
- }
2024
-
2025
- //
2026
- // Clear out the patch map for that index -- there is nothing left
2027
- // to patch for that index for the time being.
2028
- //
2029
- _patchMap.erase(patchPos);
2030
- }
2031
-
2032
- if(_objectList.empty() && _patchMap.empty())
2033
- {
2034
- try
2035
- {
2036
- if(_stream->instance()->collectObjects())
2037
- {
2038
- v->ice_collectable(true);
2039
- }
2040
- v->ice_postUnmarshal();
2041
- }
2042
- catch(const std::exception& ex)
2043
- {
2044
- Warning out(_stream->instance()->initializationData().logger);
2045
- out << "std::exception raised by ice_postUnmarshal:\n" << ex;
2046
- }
2047
- catch(...)
2048
- {
2049
- Warning out(_stream->instance()->initializationData().logger);
2050
- out << "unknown exception raised by ice_postUnmarshal";
2051
- }
2052
- }
2053
- else
2054
- {
2055
- _objectList.push_back(v);
2056
-
2057
- if(_patchMap.empty())
2058
- {
2059
- //
2060
- // Iterate over the object list and invoke ice_postUnmarshal on
2061
- // each object. We must do this after all objects have been
2062
- // unmarshaled in order to ensure that any object data members
2063
- // have been properly patched.
2064
- //
2065
- for(ObjectList::iterator p = _objectList.begin(); p != _objectList.end(); ++p)
2066
- {
2067
- try
2068
- {
2069
- if(_stream->instance()->collectObjects())
2070
- {
2071
- (*p)->ice_collectable(true);
2072
- }
2073
- (*p)->ice_postUnmarshal();
2074
- }
2075
- catch(const std::exception& ex)
2076
- {
2077
- Warning out(_stream->instance()->initializationData().logger);
2078
- out << "std::exception raised by ice_postUnmarshal:\n" << ex;
2079
- }
2080
- catch(...)
2081
- {
2082
- Warning out(_stream->instance()->initializationData().logger);
2083
- out << "unknown exception raised by ice_postUnmarshal";
2084
- }
2085
- }
2086
- _objectList.clear();
2087
- }
2088
- }
2089
- }
2090
-
2091
- void
2092
- IceInternal::BasicStream::EncapsDecoder10::read(PatchFunc patchFunc, void* patchAddr)
2093
- {
2094
- assert(patchFunc && patchAddr);
2095
-
2096
- //
2097
- // Object references are encoded as a negative integer in 1.0.
2098
- //
2099
- Int index;
2100
- _stream->read(index);
2101
- if(index > 0)
2102
- {
2103
- throw MarshalException(__FILE__, __LINE__, "invalid object id");
2104
- }
2105
- index = -index;
2106
-
2107
- if(index == 0)
2108
- {
2109
- //
2110
- // Calling the patch function for null instances is necessary for correct functioning of Ice for
2111
- // Python and Ruby.
2112
- //
2113
- ObjectPtr nil;
2114
- patchFunc(patchAddr, nil);
2115
- }
2116
- else
2117
- {
2118
- addPatchEntry(index, patchFunc, patchAddr);
2119
- }
2120
- }
2121
-
2122
- void
2123
- IceInternal::BasicStream::EncapsDecoder10::throwException(const UserExceptionFactoryPtr& factory)
2124
- {
2125
- assert(_sliceType == NoSlice);
2126
-
2127
- //
2128
- // User exception with the 1.0 encoding start with a boolean flag
2129
- // that indicates whether or not the exception has classes.
2130
- //
2131
- // This allows reading the pending objects even if some part of
2132
- // the exception was sliced.
2133
- //
2134
- bool usesClasses;
2135
- _stream->read(usesClasses);
2136
-
2137
- _sliceType = ExceptionSlice;
2138
- _skipFirstSlice = false;
2139
-
2140
- //
2141
- // Read the first slice header.
2142
- //
2143
- startSlice();
2144
- const string mostDerivedId = _typeId;
2145
- UserExceptionFactoryPtr exceptionFactory = factory;
2146
- while(true)
2147
- {
2148
- //
2149
- // Look for a statically-generated factory for this ID.
2150
- //
2151
- if(!exceptionFactory)
2152
- {
2153
- exceptionFactory = factoryTable->getExceptionFactory(_typeId);
2154
- }
2155
-
2156
- //
2157
- // We found a factory, we get out of this loop.
2158
- //
2159
- if(exceptionFactory)
2160
- {
2161
- //
2162
- // Got factory -- ask the factory to instantiate the
2163
- // exception, initialize the exception members, and throw
2164
- // the exception.
2165
- //
2166
- try
2167
- {
2168
- exceptionFactory->createAndThrow(_typeId);
2169
- }
2170
- catch(UserException& ex)
2171
- {
2172
- ex.__read(_stream);
2173
- if(usesClasses)
2174
- {
2175
- readPendingObjects();
2176
- }
2177
- throw;
2178
-
2179
- // Never reached.
2180
- }
2181
- }
2182
-
2183
- //
2184
- // Slice off what we don't understand.
2185
- //
2186
- skipSlice();
2187
- try
2188
- {
2189
- startSlice();
2190
- }
2191
- catch(UnmarshalOutOfBoundsException& ex)
2192
- {
2193
- //
2194
- // An oversight in the 1.0 encoding means there is no marker to indicate
2195
- // the last slice of an exception. As a result, we just try to read the
2196
- // next type ID, which raises UnmarshalOutOfBoundsException when the
2197
- // input buffer underflows.
2198
- //
2199
- // Set the reason member to a more helpful message.
2200
- //
2201
- ex.reason = "unknown exception type `" + mostDerivedId + "'";
2202
- throw;
2203
- }
2204
- }
2205
- }
2206
-
2207
- void
2208
- #ifndef NDEBUG
2209
- IceInternal::BasicStream::EncapsDecoder10::startInstance(SliceType sliceType)
2210
- #else
2211
- IceInternal::BasicStream::EncapsDecoder10::startInstance(SliceType)
2212
- #endif
2213
- {
2214
- assert(_sliceType == sliceType);
2215
- _skipFirstSlice = true;
2216
- }
2217
-
2218
- SlicedDataPtr
2219
- IceInternal::BasicStream::EncapsDecoder10::endInstance(bool)
2220
- {
2221
- //
2222
- // Read the Ice::Object slice.
2223
- //
2224
- if(_sliceType == ObjectSlice)
2225
- {
2226
- startSlice();
2227
- Int sz = _stream->readSize(); // For compatibility with the old AFM.
2228
- if(sz != 0)
2229
- {
2230
- throw MarshalException(__FILE__, __LINE__, "invalid Object slice");
2231
- }
2232
- endSlice();
2233
- }
2234
- _sliceType = NoSlice;
2235
- return 0;
2236
- }
2237
-
2238
- const std::string&
2239
- IceInternal::BasicStream::EncapsDecoder10::startSlice()
2240
- {
2241
- //
2242
- // If first slice, don't read the header, it was already read in
2243
- // readInstance or throwException to find the factory.
2244
- //
2245
- if(_skipFirstSlice)
2246
- {
2247
- _skipFirstSlice = false;
2248
- return _typeId;
2249
- }
2250
-
2251
- //
2252
- // For objects, first read the type ID boolean which indicates
2253
- // whether or not the type ID is encoded as a string or as an
2254
- // index. For exceptions, the type ID is always encoded as a
2255
- // string.
2256
- //
2257
- if(_sliceType == ObjectSlice)
2258
- {
2259
- bool isIndex;
2260
- _stream->read(isIndex);
2261
- _typeId = readTypeId(isIndex);
2262
- }
2263
- else
2264
- {
2265
- _stream->read(_typeId, false);
2266
- }
2267
-
2268
- _stream->read(_sliceSize);
2269
- if(_sliceSize < 4)
2270
- {
2271
- throw UnmarshalOutOfBoundsException(__FILE__, __LINE__);
2272
- }
2273
- return _typeId;
2274
- }
2275
-
2276
- void
2277
- IceInternal::BasicStream::EncapsDecoder10::endSlice()
2278
- {
2279
- }
2280
-
2281
- void
2282
- IceInternal::BasicStream::EncapsDecoder10::skipSlice()
2283
- {
2284
- if(_stream->instance()->traceLevels()->slicing > 0)
2285
- {
2286
- const Ice::LoggerPtr& logger = _stream->instance()->initializationData().logger;
2287
- if(_sliceType == ExceptionSlice)
2288
- {
2289
- traceSlicing("exception", _typeId, _stream->instance()->traceLevels()->slicingCat, logger);
2290
- }
2291
- else
2292
- {
2293
- traceSlicing("object", _typeId, _stream->instance()->traceLevels()->slicingCat, logger);
2294
- }
2295
- }
2296
- assert(_sliceSize >= 4);
2297
- _stream->skip(_sliceSize - sizeof(Int));
2298
- }
2299
-
2300
- void
2301
- IceInternal::BasicStream::EncapsDecoder10::readPendingObjects()
2302
- {
2303
- Int num;
2304
- do
2305
- {
2306
- num = _stream->readSize();
2307
- for(Int k = num; k > 0; --k)
2308
- {
2309
- readInstance();
2310
- }
2311
- }
2312
- while(num);
2313
-
2314
- if(!_patchMap.empty())
2315
- {
2316
- //
2317
- // If any entries remain in the patch map, the sender has sent an index for an object, but failed
2318
- // to supply the object.
2319
- //
2320
- throw MarshalException(__FILE__, __LINE__, "index for class received, but no instance");
2321
- }
2322
- }
2323
-
2324
- void
2325
- IceInternal::BasicStream::EncapsDecoder10::readInstance()
2326
- {
2327
- Int index;
2328
- _stream->read(index);
2329
-
2330
- if(index <= 0)
2331
- {
2332
- throw MarshalException(__FILE__, __LINE__, "invalid object id");
2333
- }
2334
-
2335
- _sliceType = ObjectSlice;
2336
- _skipFirstSlice = false;
2337
-
2338
- //
2339
- // Read the first slice header.
2340
- //
2341
- startSlice();
2342
- const string mostDerivedId = _typeId;
2343
- ObjectPtr v;
2344
- while(true)
2345
- {
2346
- //
2347
- // For the 1.0 encoding, the type ID for the base Object class
2348
- // marks the last slice.
2349
- //
2350
- if(_typeId == Object::ice_staticId())
2351
- {
2352
- throw NoObjectFactoryException(__FILE__, __LINE__, "", mostDerivedId);
2353
- }
2354
-
2355
- v = newInstance(_typeId);
2356
-
2357
- //
2358
- // We found a factory, we get out of this loop.
2359
- //
2360
- if(v)
2361
- {
2362
- break;
2363
- }
2364
-
2365
- //
2366
- // If object slicing is disabled, stop un-marshalling.
2367
- //
2368
- if(!_sliceObjects)
2369
- {
2370
- throw NoObjectFactoryException(__FILE__, __LINE__, "no object factory found and object slicing is disabled",
2371
- _typeId);
2372
- }
2373
-
2374
- //
2375
- // Slice off what we don't understand.
2376
- //
2377
- skipSlice();
2378
- startSlice(); // Read next Slice header for next iteration.
2379
- }
2380
-
2381
- //
2382
- // Compute the biggest class graph depth of this object. To compute this,
2383
- // we get the class graph depth of each ancestor from the patch map and
2384
- // keep the biggest one.
2385
- //
2386
- _classGraphDepth = 0;
2387
- PatchMap::iterator patchPos = _patchMap.find(index);
2388
- if(patchPos != _patchMap.end())
2389
- {
2390
- assert(patchPos->second.size() > 0);
2391
- for(PatchList::iterator k = patchPos->second.begin(); k != patchPos->second.end(); ++k)
2392
- {
2393
- if(k->classGraphDepth > _classGraphDepth)
2394
- {
2395
- _classGraphDepth = k->classGraphDepth;
2396
- }
2397
- }
2398
- }
2399
-
2400
- if(++_classGraphDepth > _classGraphDepthMax)
2401
- {
2402
- throw MarshalException(__FILE__, __LINE__, "maximum class graph depth reached");
2403
- }
2404
-
2405
- //
2406
- // Un-marshal the object and add-it to the map of un-marshaled objects.
2407
- //
2408
- unmarshal(index, v);
2409
- }
2410
-
2411
- void
2412
- IceInternal::BasicStream::EncapsDecoder11::read(PatchFunc patchFunc, void* patchAddr)
2413
- {
2414
- Int index = _stream->readSize();
2415
- if(index < 0)
2416
- {
2417
- throw MarshalException(__FILE__, __LINE__, "invalid object id");
2418
- }
2419
- else if(index == 0)
2420
- {
2421
- //
2422
- // Calling the patch function for null instances is necessary for correct functioning of Ice for
2423
- // Python and Ruby.
2424
- //
2425
- if(patchFunc)
2426
- {
2427
- ObjectPtr nil;
2428
- patchFunc(patchAddr, nil);
2429
- }
2430
- }
2431
- else if(_current && _current->sliceFlags & FLAG_HAS_INDIRECTION_TABLE)
2432
- {
2433
- //
2434
- // When reading an object within a slice and there's an
2435
- // indirect object table, always read an indirect reference
2436
- // that points to an object from the indirect object table
2437
- // marshaled at the end of the Slice.
2438
- //
2439
- // Maintain a list of indirect references. Note that the
2440
- // indirect index starts at 1, so we decrement it by one to
2441
- // derive an index into the indirection table that we'll read
2442
- // at the end of the slice.
2443
- //
2444
- if(patchFunc)
2445
- {
2446
- IndirectPatchEntry e;
2447
- e.index = index - 1;
2448
- e.patchFunc = patchFunc;
2449
- e.patchAddr = patchAddr;
2450
- _current->indirectPatchList.push_back(e);
2451
- }
2452
- }
2453
- else
2454
- {
2455
- readInstance(index, patchFunc, patchAddr);
2456
- }
2457
- }
2458
-
2459
- void
2460
- IceInternal::BasicStream::EncapsDecoder11::throwException(const UserExceptionFactoryPtr& factory)
2461
- {
2462
- assert(!_current);
2463
-
2464
- push(ExceptionSlice);
2465
-
2466
- //
2467
- // Read the first slice header.
2468
- //
2469
- startSlice();
2470
- const string mostDerivedId = _current->typeId;
2471
- UserExceptionFactoryPtr exceptionFactory = factory;
2472
- while(true)
2473
- {
2474
- //
2475
- // Look for a statically-generated factory for this ID.
2476
- //
2477
- if(!exceptionFactory)
2478
- {
2479
- exceptionFactory = factoryTable->getExceptionFactory(_current->typeId);
2480
- }
2481
-
2482
- //
2483
- // We found a factory, we get out of this loop.
2484
- //
2485
- if(exceptionFactory)
2486
- {
2487
- //
2488
- // Got factory -- ask the factory to instantiate the
2489
- // exception, initialize the exception members, and throw
2490
- // the exception.
2491
- //
2492
- try
2493
- {
2494
- exceptionFactory->createAndThrow(_current->typeId);
2495
- }
2496
- catch(UserException& ex)
2497
- {
2498
- ex.__read(_stream);
2499
- throw;
2500
-
2501
- // Never reached.
2502
- }
2503
- }
2504
-
2505
- //
2506
- // Slice off what we don't understand.
2507
- //
2508
- skipSlice();
2509
-
2510
- //
2511
- // If this is the last slice, raise an exception and stop un-marshalling.
2512
- //
2513
- if(_current->sliceFlags & FLAG_IS_LAST_SLICE)
2514
- {
2515
- if(mostDerivedId.length() > 2 && mostDerivedId[0] == ':' && mostDerivedId[1] == ':')
2516
- {
2517
- throw UnknownUserException(__FILE__, __LINE__, mostDerivedId.substr(2));
2518
- }
2519
- else
2520
- {
2521
- throw UnknownUserException(__FILE__, __LINE__, mostDerivedId);
2522
- }
2523
- }
2524
-
2525
- startSlice();
2526
- }
2527
- }
2528
-
2529
- void
2530
- #ifndef NDEBUG
2531
- IceInternal::BasicStream::EncapsDecoder11::startInstance(SliceType sliceType)
2532
- #else
2533
- IceInternal::BasicStream::EncapsDecoder11::startInstance(SliceType)
2534
- #endif
2535
- {
2536
- assert(_current->sliceType == sliceType);
2537
- _current->skipFirstSlice = true;
2538
- }
2539
-
2540
- SlicedDataPtr
2541
- IceInternal::BasicStream::EncapsDecoder11::endInstance(bool preserve)
2542
- {
2543
- SlicedDataPtr slicedData;
2544
- if(preserve)
2545
- {
2546
- slicedData = readSlicedData();
2547
- }
2548
- _current->slices.clear();
2549
- _current->indirectionTables.clear();
2550
- _current = _current->previous;
2551
- return slicedData;
2552
- }
2553
-
2554
- const std::string&
2555
- IceInternal::BasicStream::EncapsDecoder11::startSlice()
2556
- {
2557
- //
2558
- // If first slice, don't read the header, it was already read in
2559
- // readInstance or throwException to find the factory.
2560
- //
2561
- if(_current->skipFirstSlice)
2562
- {
2563
- _current->skipFirstSlice = false;
2564
- return _current->typeId;
2565
- }
2566
-
2567
- _stream->read(_current->sliceFlags);
2568
-
2569
- //
2570
- // Read the type ID, for object slices the type ID is encoded as a
2571
- // string or as an index, for exceptions it's always encoded as a
2572
- // string.
2573
- //
2574
- if(_current->sliceType == ObjectSlice)
2575
- {
2576
- if((_current->sliceFlags & FLAG_HAS_TYPE_ID_COMPACT) == FLAG_HAS_TYPE_ID_COMPACT) // Must be checked first!
2577
- {
2578
- _current->typeId.clear();
2579
- _current->compactId = _stream->readSize();
2580
- }
2581
- else if(_current->sliceFlags & (FLAG_HAS_TYPE_ID_STRING | FLAG_HAS_TYPE_ID_INDEX))
2582
- {
2583
- _current->typeId = readTypeId(_current->sliceFlags & FLAG_HAS_TYPE_ID_INDEX);
2584
- _current->compactId = -1;
2585
- }
2586
- else
2587
- {
2588
- // Only the most derived slice encodes the type ID for the compact format.
2589
- _current->typeId.clear();
2590
- _current->compactId = -1;
2591
- }
2592
- }
2593
- else
2594
- {
2595
- _stream->read(_current->typeId, false);
2596
- }
2597
-
2598
- //
2599
- // Read the slice size if necessary.
2600
- //
2601
- if(_current->sliceFlags & FLAG_HAS_SLICE_SIZE)
2602
- {
2603
- _stream->read(_current->sliceSize);
2604
- if(_current->sliceSize < 4)
2605
- {
2606
- throw UnmarshalOutOfBoundsException(__FILE__, __LINE__);
2607
- }
2608
- }
2609
- else
2610
- {
2611
- _current->sliceSize = 0;
2612
- }
2613
-
2614
- return _current->typeId;
2615
- }
2616
-
2617
- void
2618
- IceInternal::BasicStream::EncapsDecoder11::endSlice()
2619
- {
2620
- if(_current->sliceFlags & FLAG_HAS_OPTIONAL_MEMBERS)
2621
- {
2622
- _stream->skipOpts();
2623
- }
2624
-
2625
- //
2626
- // Read the indirect object table if one is present.
2627
- //
2628
- if(_current->sliceFlags & FLAG_HAS_INDIRECTION_TABLE)
2629
- {
2630
- IndexList indirectionTable(_stream->readAndCheckSeqSize(1));
2631
- for(IndexList::iterator p = indirectionTable.begin(); p != indirectionTable.end(); ++p)
2632
- {
2633
- *p = readInstance(_stream->readSize(), 0, 0);
2634
- }
2635
-
2636
- //
2637
- // Sanity checks. If there are optional members, it's possible
2638
- // that not all object references were read if they are from
2639
- // unknown optional data members.
2640
- //
2641
- if(indirectionTable.empty())
2642
- {
2643
- throw MarshalException(__FILE__, __LINE__, "empty indirection table");
2644
- }
2645
- if(_current->indirectPatchList.empty() && !(_current->sliceFlags & FLAG_HAS_OPTIONAL_MEMBERS))
2646
- {
2647
- throw MarshalException(__FILE__, __LINE__, "no references to indirection table");
2648
- }
2649
-
2650
- //
2651
- // Convert indirect references into direct references.
2652
- //
2653
- IndirectPatchList::iterator p;
2654
- for(p = _current->indirectPatchList.begin(); p != _current->indirectPatchList.end(); ++p)
2655
- {
2656
- assert(p->index >= 0);
2657
- if(p->index >= static_cast<Int>(indirectionTable.size()))
2658
- {
2659
- throw MarshalException(__FILE__, __LINE__, "indirection out of range");
2660
- }
2661
- addPatchEntry(indirectionTable[p->index], p->patchFunc, p->patchAddr);
2662
- }
2663
- _current->indirectPatchList.clear();
2664
- }
2665
- }
2666
-
2667
- void
2668
- IceInternal::BasicStream::EncapsDecoder11::skipSlice()
2669
- {
2670
- if(_stream->instance()->traceLevels()->slicing > 0)
2671
- {
2672
- const Ice::LoggerPtr& logger = _stream->instance()->initializationData().logger;
2673
- if(_current->sliceType == ExceptionSlice)
2674
- {
2675
- traceSlicing("exception", _current->typeId, _stream->instance()->traceLevels()->slicingCat, logger);
2676
- }
2677
- else
2678
- {
2679
- traceSlicing("object", _current->typeId, _stream->instance()->traceLevels()->slicingCat, logger);
2680
- }
2681
- }
2682
-
2683
- Container::iterator start = _stream->i;
2684
-
2685
- if(_current->sliceFlags & FLAG_HAS_SLICE_SIZE)
2686
- {
2687
- assert(_current->sliceSize >= 4);
2688
- _stream->skip(_current->sliceSize - sizeof(Int));
2689
- }
2690
- else
2691
- {
2692
- if(_current->sliceType == ObjectSlice)
2693
- {
2694
- throw NoObjectFactoryException(__FILE__, __LINE__,
2695
- "no object factory found and compact format prevents "
2696
- "slicing (the sender should use the sliced format instead)",
2697
- _current->typeId);
2698
- }
2699
- else
2700
- {
2701
- if(_current->typeId.length() > 2 && _current->typeId[0] == ':' && _current->typeId[1] == ':')
2702
- {
2703
- throw UnknownUserException(__FILE__, __LINE__, _current->typeId.substr(2));
2704
- }
2705
- else
2706
- {
2707
- throw UnknownUserException(__FILE__, __LINE__, _current->typeId);
2708
- }
2709
- }
2710
- }
2711
-
2712
- //
2713
- // Preserve this slice.
2714
- //
2715
- SliceInfoPtr info = new SliceInfo;
2716
- info->typeId = _current->typeId;
2717
- info->compactId = _current->compactId;
2718
- info->hasOptionalMembers = _current->sliceFlags & FLAG_HAS_OPTIONAL_MEMBERS;
2719
- info->isLastSlice = _current->sliceFlags & FLAG_IS_LAST_SLICE;
2720
- if(info->hasOptionalMembers)
2721
- {
2722
- //
2723
- // Don't include the optional member end marker. It will be re-written by
2724
- // endSlice when the sliced data is re-written.
2725
- //
2726
- vector<Byte>(start, _stream->i - 1).swap(info->bytes);
2727
- }
2728
- else
2729
- {
2730
- vector<Byte>(start, _stream->i).swap(info->bytes);
2731
- }
2732
-
2733
- _current->indirectionTables.push_back(IndexList());
2734
-
2735
- //
2736
- // Read the indirect object table. We read the instances or their
2737
- // IDs if the instance is a reference to an already un-marhsaled
2738
- // object.
2739
- //
2740
- // The SliceInfo object sequence is initialized only if
2741
- // readSlicedData is called.
2742
- //
2743
- if(_current->sliceFlags & FLAG_HAS_INDIRECTION_TABLE)
2744
- {
2745
- IndexList& table = _current->indirectionTables.back();
2746
- table.resize(_stream->readAndCheckSeqSize(1));
2747
- for(IndexList::iterator p = table.begin(); p != table.end(); ++p)
2748
- {
2749
- *p = readInstance(_stream->readSize(), 0, 0);
2750
- }
2751
- }
2752
-
2753
- _current->slices.push_back(info);
2754
- }
2755
-
2756
- bool
2757
- IceInternal::BasicStream::EncapsDecoder11::readOpt(Ice::Int readTag, Ice::OptionalFormat expectedFormat)
2758
- {
2759
- if(!_current)
2760
- {
2761
- return _stream->readOptImpl(readTag, expectedFormat);
2762
- }
2763
- else if(_current->sliceFlags & FLAG_HAS_OPTIONAL_MEMBERS)
2764
- {
2765
- return _stream->readOptImpl(readTag, expectedFormat);
2766
- }
2767
- return false;
2768
- }
2769
-
2770
- Int
2771
- IceInternal::BasicStream::EncapsDecoder11::readInstance(Int index, PatchFunc patchFunc, void* patchAddr)
2772
- {
2773
- assert(index > 0);
2774
-
2775
- if(index > 1)
2776
- {
2777
- if(patchFunc)
2778
- {
2779
- addPatchEntry(index, patchFunc, patchAddr);
2780
- }
2781
- return index;
2782
- }
2783
-
2784
- push(ObjectSlice);
2785
-
2786
- //
2787
- // Get the object ID before we start reading slices. If some
2788
- // slices are skiped, the indirect object table are still read and
2789
- // might read other objects.
2790
- //
2791
- index = ++_objectIdIndex;
2792
-
2793
- //
2794
- // Read the first slice header.
2795
- //
2796
- startSlice();
2797
- const string mostDerivedId = _current->typeId;
2798
- Ice::ObjectPtr v;
2799
- const CompactIdResolverPtr& compactIdResolver = _stream->instance()->initializationData().compactIdResolver;
2800
- while(true)
2801
- {
2802
- if(_current->compactId >= 0)
2803
- {
2804
- //
2805
- // Translate a compact (numeric) type ID into a string type ID.
2806
- //
2807
- _current->typeId.clear();
2808
- if(compactIdResolver)
2809
- {
2810
- try
2811
- {
2812
- _current->typeId = compactIdResolver->resolve(_current->compactId);
2813
- }
2814
- catch(const LocalException&)
2815
- {
2816
- throw;
2817
- }
2818
- catch(const std::exception& ex)
2819
- {
2820
- ostringstream ostr;
2821
- ostr << "exception in CompactIdResolver for ID " << _current->compactId;
2822
- string msg = ostr.str();
2823
- string what = ex.what();
2824
- if(!what.empty())
2825
- {
2826
- msg += ":\n" + what;
2827
- }
2828
- throw MarshalException(__FILE__, __LINE__, msg);
2829
- }
2830
- catch(...)
2831
- {
2832
- ostringstream ostr;
2833
- ostr << "unknown exception in CompactIdResolver for ID " << _current->compactId;
2834
- throw MarshalException(__FILE__, __LINE__, ostr.str());
2835
- }
2836
- }
2837
- if(_current->typeId.empty())
2838
- {
2839
- _current->typeId = IceInternal::factoryTable->getTypeId(_current->compactId);
2840
- }
2841
- }
2842
-
2843
- if(!_current->typeId.empty())
2844
- {
2845
- v = newInstance(_current->typeId);
2846
-
2847
- //
2848
- // We found a factory, we get out of this loop.
2849
- //
2850
- if(v)
2851
- {
2852
- break;
2853
- }
2854
- }
2855
-
2856
- //
2857
- // If object slicing is disabled, stop un-marshalling.
2858
- //
2859
- if(!_sliceObjects)
2860
- {
2861
- throw NoObjectFactoryException(__FILE__, __LINE__, "no object factory found and object slicing is disabled",
2862
- _current->typeId);
2863
- }
2864
-
2865
- //
2866
- // Slice off what we don't understand.
2867
- //
2868
- skipSlice();
2869
-
2870
- //
2871
- // If this is the last slice, keep the object as an opaque UnknownSlicedObject.
2872
- //
2873
- if(_current->sliceFlags & FLAG_IS_LAST_SLICE)
2874
- {
2875
- //
2876
- // Provide a factory with an opportunity to supply the object.
2877
- // We pass the "::Ice::Object" ID to indicate that this is the
2878
- // last chance to preserve the object.
2879
- //
2880
- v = newInstance(Object::ice_staticId());
2881
- if(!v)
2882
- {
2883
- v = new UnknownSlicedObject(mostDerivedId);
2884
- }
2885
-
2886
- break;
2887
- }
2888
-
2889
- startSlice(); // Read next Slice header for next iteration.
2890
- }
2891
-
2892
- if(++_classGraphDepth > _classGraphDepthMax)
2893
- {
2894
- throw MarshalException(__FILE__, __LINE__, "maximum class graph depth reached");
2895
- }
2896
-
2897
- //
2898
- // Un-marshal the object
2899
- //
2900
- unmarshal(index, v);
2901
-
2902
- --_classGraphDepth;
2903
-
2904
- if(!_current && !_patchMap.empty())
2905
- {
2906
- //
2907
- // If any entries remain in the patch map, the sender has sent an index for an object, but failed
2908
- // to supply the object.
2909
- //
2910
- throw MarshalException(__FILE__, __LINE__, "index for class received, but no instance");
2911
- }
2912
-
2913
- if(patchFunc)
2914
- {
2915
- patchFunc(patchAddr, v);
2916
- }
2917
- return index;
2918
- }
2919
-
2920
- SlicedDataPtr
2921
- IceInternal::BasicStream::EncapsDecoder11::readSlicedData()
2922
- {
2923
- if(_current->slices.empty()) // No preserved slices.
2924
- {
2925
- return 0;
2926
- }
2927
-
2928
- //
2929
- // The indirectionTables member holds the indirection table for
2930
- // each slice in slices.
2931
- //
2932
- assert(_current->slices.size() == _current->indirectionTables.size());
2933
- for(SliceInfoSeq::size_type n = 0; n < _current->slices.size(); ++n)
2934
- {
2935
- //
2936
- // We use the "objects" list in SliceInfo to hold references
2937
- // to the target objects. Note that the objects might not have
2938
- // been read yet in the case of a circular reference to an
2939
- // enclosing object.
2940
- //
2941
- const IndexList& table = _current->indirectionTables[n];
2942
- vector<ObjectPtr>& objects = _current->slices[n]->objects;
2943
- objects.resize(table.size());
2944
- IndexList::size_type j = 0;
2945
- for(IndexList::const_iterator p = table.begin(); p != table.end(); ++p)
2946
- {
2947
- addPatchEntry(*p, &patchHandle<Object>, &objects[j++]);
2948
- }
2949
- }
2950
- return new SlicedData(_current->slices);
2951
- }
2952
-
2953
- Int
2954
- IceInternal::BasicStream::EncapsEncoder::registerTypeId(const string& typeId)
2955
- {
2956
- TypeIdWriteMap::const_iterator p = _typeIdMap.find(typeId);
2957
- if(p != _typeIdMap.end())
2958
- {
2959
- return p->second;
2960
- }
2961
- else
2962
- {
2963
- _typeIdMap.insert(make_pair(typeId, ++_typeIdIndex));
2964
- return -1;
2965
- }
2966
- }
2967
-
2968
- void
2969
- IceInternal::BasicStream::EncapsEncoder10::write(const ObjectPtr& v)
2970
- {
2971
- //
2972
- // Object references are encoded as a negative integer in 1.0.
2973
- //
2974
- if(v)
2975
- {
2976
- _stream->write(-registerObject(v));
2977
- }
2978
- else
2979
- {
2980
- _stream->write(0);
2981
- }
2982
- }
2983
-
2984
- void
2985
- IceInternal::BasicStream::EncapsEncoder10::write(const UserException& v)
2986
- {
2987
- //
2988
- // User exception with the 1.0 encoding start with a boolean
2989
- // flag that indicates whether or not the exception uses
2990
- // classes.
2991
- //
2992
- // This allows reading the pending objects even if some part of
2993
- // the exception was sliced.
2994
- //
2995
- bool usesClasses = v.__usesClasses();
2996
- _stream->write(usesClasses);
2997
- v.__write(_stream);
2998
- if(usesClasses)
2999
- {
3000
- writePendingObjects();
3001
- }
3002
- }
3003
-
3004
- void
3005
- IceInternal::BasicStream::EncapsEncoder10::startInstance(SliceType sliceType, const SlicedDataPtr&)
3006
- {
3007
- _sliceType = sliceType;
3008
- }
3009
-
3010
- void
3011
- IceInternal::BasicStream::EncapsEncoder10::endInstance()
3012
- {
3013
- if(_sliceType == ObjectSlice)
3014
- {
3015
- //
3016
- // Write the Object slice.
3017
- //
3018
- startSlice(Object::ice_staticId(), -1, true);
3019
- _stream->writeSize(0); // For compatibility with the old AFM.
3020
- endSlice();
3021
- }
3022
- _sliceType = NoSlice;
3023
- }
3024
-
3025
- void
3026
- IceInternal::BasicStream::EncapsEncoder10::startSlice(const string& typeId, int, bool /*last*/)
3027
- {
3028
- //
3029
- // For object slices, encode a boolean to indicate how the type ID
3030
- // is encoded and the type ID either as a string or index. For
3031
- // exception slices, always encode the type ID as a string.
3032
- //
3033
- if(_sliceType == ObjectSlice)
3034
- {
3035
- Int index = registerTypeId(typeId);
3036
- if(index < 0)
3037
- {
3038
- _stream->write(false);
3039
- _stream->write(typeId, false);
3040
- }
3041
- else
3042
- {
3043
- _stream->write(true);
3044
- _stream->writeSize(index);
3045
- }
3046
- }
3047
- else
3048
- {
3049
- _stream->write(typeId, false);
3050
- }
3051
-
3052
- _stream->write(Int(0)); // Placeholder for the slice length.
3053
-
3054
- _writeSlice = _stream->b.size();
3055
- }
3056
-
3057
- void
3058
- IceInternal::BasicStream::EncapsEncoder10::endSlice()
3059
- {
3060
- //
3061
- // Write the slice length.
3062
- //
3063
- Int sz = static_cast<Int>(_stream->b.size() - _writeSlice + sizeof(Int));
3064
- Byte* dest = &(*(_stream->b.begin() + _writeSlice - sizeof(Int)));
3065
- _stream->write(sz, dest);
3066
- }
3067
-
3068
- void
3069
- IceInternal::BasicStream::EncapsEncoder10::writePendingObjects()
3070
- {
3071
- while(!_toBeMarshaledMap.empty())
3072
- {
3073
- //
3074
- // Consider the to be marshalled objects as marshalled now,
3075
- // this is necessary to avoid adding again the "to be
3076
- // marshalled objects" into _toBeMarshaledMap while writing
3077
- // objects.
3078
- //
3079
- _marshaledMap.insert(_toBeMarshaledMap.begin(), _toBeMarshaledMap.end());
3080
-
3081
- PtrToIndexMap savedMap;
3082
- savedMap.swap(_toBeMarshaledMap);
3083
- _stream->writeSize(static_cast<Int>(savedMap.size()));
3084
- for(PtrToIndexMap::iterator p = savedMap.begin(); p != savedMap.end(); ++p)
3085
- {
3086
- //
3087
- // Ask the instance to marshal itself. Any new class
3088
- // instances that are triggered by the classes marshaled
3089
- // are added to toBeMarshaledMap.
3090
- //
3091
- _stream->write(p->second);
3092
-
3093
- try
3094
- {
3095
- p->first->ice_preMarshal();
3096
- }
3097
- catch(const std::exception& ex)
3098
- {
3099
- Warning out(_stream->instance()->initializationData().logger);
3100
- out << "std::exception raised by ice_preMarshal:\n" << ex;
3101
- }
3102
- catch(...)
3103
- {
3104
- Warning out(_stream->instance()->initializationData().logger);
3105
- out << "unknown exception raised by ice_preMarshal";
3106
- }
3107
-
3108
- p->first->__write(_stream);
3109
- }
3110
- }
3111
- _stream->writeSize(0); // Zero marker indicates end of sequence of sequences of instances.
3112
- }
3113
-
3114
- Int
3115
- IceInternal::BasicStream::EncapsEncoder10::registerObject(const ObjectPtr& v)
3116
- {
3117
- assert(v);
3118
-
3119
- //
3120
- // Look for this instance in the to-be-marshaled map.
3121
- //
3122
- PtrToIndexMap::const_iterator p = _toBeMarshaledMap.find(v);
3123
- if(p != _toBeMarshaledMap.end())
3124
- {
3125
- return p->second;
3126
- }
3127
-
3128
- //
3129
- // Didn't find it, try the marshaled map next.
3130
- //
3131
- PtrToIndexMap::const_iterator q = _marshaledMap.find(v);
3132
- if(q != _marshaledMap.end())
3133
- {
3134
- return q->second;
3135
- }
3136
-
3137
- //
3138
- // We haven't seen this instance previously, create a new
3139
- // index, and insert it into the to-be-marshaled map.
3140
- //
3141
- _toBeMarshaledMap.insert(make_pair(v, ++_objectIdIndex));
3142
- return _objectIdIndex;
3143
- }
3144
-
3145
- void
3146
- IceInternal::BasicStream::EncapsEncoder11::write(const ObjectPtr& v)
3147
- {
3148
- if(!v)
3149
- {
3150
- _stream->writeSize(0); // Nil reference.
3151
- }
3152
- else if(_current && _encaps->format == SlicedFormat)
3153
- {
3154
- //
3155
- // If writting an object within a slice and using the sliced
3156
- // format, write an index from the object indirection
3157
- // table. The indirect object table is encoded at the end of
3158
- // each slice and is always read (even if the Slice is
3159
- // unknown).
3160
- //
3161
- PtrToIndexMap::const_iterator p = _current->indirectionMap.find(v);
3162
- if(p == _current->indirectionMap.end())
3163
- {
3164
- _current->indirectionTable.push_back(v);
3165
- Int idx = static_cast<Int>(_current->indirectionTable.size()); // Position + 1 (0 is reserved for nil)
3166
- _current->indirectionMap.insert(make_pair(v, idx));
3167
- _stream->writeSize(idx);
3168
- }
3169
- else
3170
- {
3171
- _stream->writeSize(p->second);
3172
- }
3173
- }
3174
- else
3175
- {
3176
- writeInstance(v); // Write the instance or a reference if already marshaled.
3177
- }
3178
- }
3179
-
3180
- void
3181
- IceInternal::BasicStream::EncapsEncoder11::write(const UserException& v)
3182
- {
3183
- v.__write(_stream);
3184
- }
3185
-
3186
- void
3187
- IceInternal::BasicStream::EncapsEncoder11::startInstance(SliceType sliceType, const SlicedDataPtr& data)
3188
- {
3189
- if(!_current)
3190
- {
3191
- _current = &_preAllocatedInstanceData;
3192
- }
3193
- else
3194
- {
3195
- _current = _current->next ? _current->next : new InstanceData(_current);
3196
- }
3197
- _current->sliceType = sliceType;
3198
- _current->firstSlice = true;
3199
-
3200
- if(data)
3201
- {
3202
- writeSlicedData(data);
3203
- }
3204
- }
3205
-
3206
- void
3207
- IceInternal::BasicStream::EncapsEncoder11::endInstance()
3208
- {
3209
- _current = _current->previous;
3210
- }
3211
-
3212
- void
3213
- IceInternal::BasicStream::EncapsEncoder11::startSlice(const string& typeId, int compactId, bool last)
3214
- {
3215
- assert(_current->indirectionTable.empty() && _current->indirectionMap.empty());
3216
-
3217
- _current->sliceFlagsPos = _stream->b.size();
3218
-
3219
- _current->sliceFlags = 0;
3220
- if(_encaps->format == SlicedFormat)
3221
- {
3222
- _current->sliceFlags |= FLAG_HAS_SLICE_SIZE; // Encode the slice size if using the sliced format.
3223
- }
3224
- if(last)
3225
- {
3226
- _current->sliceFlags |= FLAG_IS_LAST_SLICE; // This is the last slice.
3227
- }
3228
-
3229
- _stream->write(Byte(0)); // Placeholder for the slice flags
3230
-
3231
- //
3232
- // For object slices, encode the flag and the type ID either as a
3233
- // string or index. For exception slices, always encode the type
3234
- // ID a string.
3235
- //
3236
- if(_current->sliceType == ObjectSlice)
3237
- {
3238
- //
3239
- // Encode the type ID (only in the first slice for the compact
3240
- // encoding).
3241
- //
3242
- if(_encaps->format == SlicedFormat || _current->firstSlice)
3243
- {
3244
- if(compactId >= 0)
3245
- {
3246
- _current->sliceFlags |= FLAG_HAS_TYPE_ID_COMPACT;
3247
- _stream->writeSize(compactId);
3248
- }
3249
- else
3250
- {
3251
- Int index = registerTypeId(typeId);
3252
- if(index < 0)
3253
- {
3254
- _current->sliceFlags |= FLAG_HAS_TYPE_ID_STRING;
3255
- _stream->write(typeId, false);
3256
- }
3257
- else
3258
- {
3259
- _current->sliceFlags |= FLAG_HAS_TYPE_ID_INDEX;
3260
- _stream->writeSize(index);
3261
- }
3262
- }
3263
- }
3264
- }
3265
- else
3266
- {
3267
- _stream->write(typeId, false);
3268
- }
3269
-
3270
- if(_current->sliceFlags & FLAG_HAS_SLICE_SIZE)
3271
- {
3272
- _stream->write(Int(0)); // Placeholder for the slice length.
3273
- }
3274
-
3275
- _current->writeSlice = _stream->b.size();
3276
- _current->firstSlice = false;
3277
- }
3278
-
3279
- void
3280
- IceInternal::BasicStream::EncapsEncoder11::endSlice()
3281
- {
3282
- //
3283
- // Write the optional member end marker if some optional members
3284
- // were encoded. Note that the optional members are encoded before
3285
- // the indirection table and are included in the slice size.
3286
- //
3287
- if(_current->sliceFlags & FLAG_HAS_OPTIONAL_MEMBERS)
3288
- {
3289
- _stream->write(OPTIONAL_END_MARKER);
3290
- }
3291
-
3292
- //
3293
- // Write the slice length if necessary.
3294
- //
3295
- if(_current->sliceFlags & FLAG_HAS_SLICE_SIZE)
3296
- {
3297
- Int sz = static_cast<Int>(_stream->b.size() - _current->writeSlice + sizeof(Int));
3298
- Byte* dest = &(*(_stream->b.begin() + _current->writeSlice - sizeof(Int)));
3299
- _stream->write(sz, dest);
3300
- }
3301
-
3302
- //
3303
- // Only write the indirection table if it contains entries.
3304
- //
3305
- if(!_current->indirectionTable.empty())
3306
- {
3307
- assert(_encaps->format == SlicedFormat);
3308
- _current->sliceFlags |= FLAG_HAS_INDIRECTION_TABLE;
3309
-
3310
- //
3311
- // Write the indirection object table.
3312
- //
3313
- _stream->writeSize(static_cast<Int>(_current->indirectionTable.size()));
3314
- ObjectList::const_iterator p;
3315
- for(p = _current->indirectionTable.begin(); p != _current->indirectionTable.end(); ++p)
3316
- {
3317
- writeInstance(*p);
3318
- }
3319
- _current->indirectionTable.clear();
3320
- _current->indirectionMap.clear();
3321
- }
3322
-
3323
- //
3324
- // Finally, update the slice flags.
3325
- //
3326
- Byte* dest = &(*(_stream->b.begin() + _current->sliceFlagsPos));
3327
- *dest = _current->sliceFlags;
3328
- }
3329
-
3330
- bool
3331
- IceInternal::BasicStream::EncapsEncoder11::writeOpt(Ice::Int tag, Ice::OptionalFormat format)
3332
- {
3333
- if(!_current)
3334
- {
3335
- return _stream->writeOptImpl(tag, format);
3336
- }
3337
- else
3338
- {
3339
- if(_stream->writeOptImpl(tag, format))
3340
- {
3341
- _current->sliceFlags |= FLAG_HAS_OPTIONAL_MEMBERS;
3342
- return true;
3343
- }
3344
- else
3345
- {
3346
- return false;
3347
- }
3348
- }
3349
- }
3350
-
3351
- void
3352
- IceInternal::BasicStream::EncapsEncoder11::writeSlicedData(const SlicedDataPtr& slicedData)
3353
- {
3354
- assert(slicedData);
3355
-
3356
- //
3357
- // We only remarshal preserved slices if we are using the sliced
3358
- // format. Otherwise, we ignore the preserved slices, which
3359
- // essentially "slices" the object into the most-derived type
3360
- // known by the sender.
3361
- //
3362
- if(_encaps->format != SlicedFormat)
3363
- {
3364
- return;
3365
- }
3366
-
3367
- for(SliceInfoSeq::const_iterator p = slicedData->slices.begin(); p != slicedData->slices.end(); ++p)
3368
- {
3369
- startSlice((*p)->typeId, (*p)->compactId, (*p)->isLastSlice);
3370
-
3371
- //
3372
- // Write the bytes associated with this slice.
3373
- //
3374
- _stream->writeBlob((*p)->bytes);
3375
-
3376
- if((*p)->hasOptionalMembers)
3377
- {
3378
- _current->sliceFlags |= FLAG_HAS_OPTIONAL_MEMBERS;
3379
- }
3380
-
3381
- //
3382
- // Make sure to also re-write the object indirection table.
3383
- //
3384
- _current->indirectionTable = (*p)->objects;
3385
-
3386
- endSlice();
3387
- }
3388
- }
3389
-
3390
- void
3391
- IceInternal::BasicStream::EncapsEncoder11::writeInstance(const ObjectPtr& v)
3392
- {
3393
- assert(v);
3394
-
3395
- //
3396
- // If the instance was already marshaled, just write it's ID.
3397
- //
3398
- PtrToIndexMap::const_iterator q = _marshaledMap.find(v);
3399
- if(q != _marshaledMap.end())
3400
- {
3401
- _stream->writeSize(q->second);
3402
- return;
3403
- }
3404
-
3405
- //
3406
- // We haven't seen this instance previously, create a new ID,
3407
- // insert it into the marshaled map, and write the instance.
3408
- //
3409
- _marshaledMap.insert(make_pair(v, ++_objectIdIndex));
3410
-
3411
- try
3412
- {
3413
- v->ice_preMarshal();
3414
- }
3415
- catch(const std::exception& ex)
3416
- {
3417
- Warning out(_stream->instance()->initializationData().logger);
3418
- out << "std::exception raised by ice_preMarshal:\n" << ex;
3419
- }
3420
- catch(...)
3421
- {
3422
- Warning out(_stream->instance()->initializationData().logger);
3423
- out << "unknown exception raised by ice_preMarshal";
3424
- }
3425
-
3426
- _stream->writeSize(1); // Object instance marker.
3427
- v->__write(_stream);
3428
- }