zeroc-ice 3.6b1

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