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
data/ext/Proxy.h ADDED
@@ -0,0 +1,27 @@
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_RUBY_PROXY_H
11
+ #define ICE_RUBY_PROXY_H
12
+
13
+ #include <Config.h>
14
+ #include <Ice/ProxyF.h>
15
+ #include <Ice/CommunicatorF.h>
16
+
17
+ namespace IceRuby
18
+ {
19
+
20
+ void initProxy(VALUE);
21
+ VALUE createProxy(const Ice::ObjectPrx&, VALUE = Qnil);
22
+ Ice::ObjectPrx getProxy(VALUE);
23
+ bool checkProxy(VALUE);
24
+
25
+ }
26
+
27
+ #endif
data/ext/Slice.cpp ADDED
@@ -0,0 +1,223 @@
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 <Slice.h>
11
+ #include <Util.h>
12
+ #include <Slice/Preprocessor.h>
13
+ #include <Slice/RubyUtil.h>
14
+ #include <Slice/Util.h>
15
+ #include <IceUtil/Options.h>
16
+
17
+ using namespace std;
18
+ using namespace IceRuby;
19
+ using namespace Slice;
20
+ using namespace Slice::Ruby;
21
+
22
+ extern "C"
23
+ VALUE
24
+ IceRuby_loadSlice(int argc, VALUE* argv, VALUE self)
25
+ {
26
+ ICE_RUBY_TRY
27
+ {
28
+ if(argc < 1 || argc > 2)
29
+ {
30
+ throw RubyException(rb_eArgError, "wrong number of arguments");
31
+ }
32
+
33
+ string cmd = getString(argv[0]);
34
+ vector<string> argSeq;
35
+ try
36
+ {
37
+ argSeq = IceUtilInternal::Options::split(cmd);
38
+ }
39
+ catch(const IceUtilInternal::BadOptException& ex)
40
+ {
41
+ throw RubyException(rb_eArgError, "error in Slice options: %s", ex.reason.c_str());
42
+ }
43
+ catch(const IceUtilInternal::APIException& ex)
44
+ {
45
+ throw RubyException(rb_eArgError, "error in Slice options: %s", ex.reason.c_str());
46
+ }
47
+
48
+ if(argc > 1)
49
+ {
50
+ if(!arrayToStringSeq(argv[1], argSeq))
51
+ {
52
+ throw RubyException(rb_eTypeError, "argument 2 is not an array");
53
+ }
54
+ }
55
+
56
+ IceUtilInternal::Options opts;
57
+ opts.addOpt("D", "", IceUtilInternal::Options::NeedArg, "", IceUtilInternal::Options::Repeat);
58
+ opts.addOpt("U", "", IceUtilInternal::Options::NeedArg, "", IceUtilInternal::Options::Repeat);
59
+ opts.addOpt("I", "", IceUtilInternal::Options::NeedArg, "", IceUtilInternal::Options::Repeat);
60
+ opts.addOpt("d", "debug");
61
+ opts.addOpt("", "ice");
62
+ opts.addOpt("", "underscore");
63
+ opts.addOpt("", "checksum");
64
+ opts.addOpt("", "all");
65
+
66
+ vector<string> files;
67
+ try
68
+ {
69
+ argSeq.insert(argSeq.begin(), ""); // dummy argv[0]
70
+ files = opts.parse(argSeq);
71
+ if(files.empty())
72
+ {
73
+ throw RubyException(rb_eArgError, "no Slice files specified in `%s'", cmd.c_str());
74
+ }
75
+ }
76
+ catch(const IceUtilInternal::BadOptException& ex)
77
+ {
78
+ throw RubyException(rb_eArgError, "error in Slice options: %s", ex.reason.c_str());
79
+ }
80
+ catch(const IceUtilInternal::APIException& ex)
81
+ {
82
+ throw RubyException(rb_eArgError, "error in Slice options: %s", ex.reason.c_str());
83
+ }
84
+
85
+ vector<string> cppArgs;
86
+ vector<string> includePaths;
87
+ bool debug = false;
88
+ bool ice = true; // This must be true so that we can create Ice::Identity when necessary.
89
+ bool underscore = opts.isSet("underscore");
90
+ bool all = false;
91
+ bool checksum = false;
92
+ if(opts.isSet("D"))
93
+ {
94
+ vector<string> optargs = opts.argVec("D");
95
+ for(vector<string>::const_iterator i = optargs.begin(); i != optargs.end(); ++i)
96
+ {
97
+ cppArgs.push_back("-D" + *i);
98
+ }
99
+ }
100
+ if(opts.isSet("U"))
101
+ {
102
+ vector<string> optargs = opts.argVec("U");
103
+ for(vector<string>::const_iterator i = optargs.begin(); i != optargs.end(); ++i)
104
+ {
105
+ cppArgs.push_back("-U" + *i);
106
+ }
107
+ }
108
+ if(opts.isSet("I"))
109
+ {
110
+ includePaths = opts.argVec("I");
111
+ for(vector<string>::const_iterator i = includePaths.begin(); i != includePaths.end(); ++i)
112
+ {
113
+ cppArgs.push_back("-I" + *i);
114
+ }
115
+ }
116
+ debug = opts.isSet("d") || opts.isSet("debug");
117
+ all = opts.isSet("all");
118
+ checksum = opts.isSet("checksum");
119
+
120
+ bool ignoreRedefs = false;
121
+
122
+ for(vector<string>::const_iterator p = files.begin(); p != files.end(); ++p)
123
+ {
124
+ string file = *p;
125
+ Slice::PreprocessorPtr icecpp = Slice::Preprocessor::create("icecpp", file, cppArgs);
126
+ FILE* cppHandle = icecpp->preprocess(false, "-D__SLICE2RB__");
127
+
128
+ if(cppHandle == 0)
129
+ {
130
+ throw RubyException(rb_eArgError, "Slice preprocessing failed for `%s'", cmd.c_str());
131
+ }
132
+
133
+ UnitPtr u = Slice::Unit::createUnit(ignoreRedefs, all, ice, underscore);
134
+ int parseStatus = u->parse(file, cppHandle, debug);
135
+
136
+ if(!icecpp->close() || parseStatus == EXIT_FAILURE)
137
+ {
138
+ u->destroy();
139
+ throw RubyException(rb_eArgError, "Slice parsing failed for `%s'", cmd.c_str());
140
+ }
141
+
142
+ //
143
+ // Generate the Ruby code into a string stream.
144
+ //
145
+ ostringstream codeStream;
146
+ IceUtilInternal::Output out(codeStream);
147
+ out.setUseTab(false);
148
+ generate(u, all, checksum, includePaths, out);
149
+ u->destroy();
150
+
151
+ string code = codeStream.str();
152
+ callRuby(rb_eval_string, code.c_str());
153
+ }
154
+ }
155
+ ICE_RUBY_CATCH
156
+
157
+ return Qnil;
158
+ }
159
+
160
+ extern "C"
161
+ VALUE
162
+ IceRuby_compile(int argc, VALUE* argv, VALUE self)
163
+ {
164
+ ICE_RUBY_TRY
165
+ {
166
+ if(argc != 1)
167
+ {
168
+ throw RubyException(rb_eArgError, "wrong number of arguments");
169
+ }
170
+
171
+ vector<string> argSeq;
172
+ if(!arrayToStringSeq(argv[0], argSeq))
173
+ {
174
+ throw RubyException(rb_eTypeError, "argument is not an array");
175
+ }
176
+ char** argv = new char*[argSeq.size()+1];
177
+ // Manufacture a fake argv[0].
178
+ argv[0] = const_cast<char*>("slice2rb");
179
+ for(size_t i = 0; i < argSeq.size(); ++i)
180
+ {
181
+ argv[i+1] = const_cast<char*>(argSeq[i].c_str());
182
+ }
183
+
184
+ int rc;
185
+ try
186
+ {
187
+ rc = Slice::Ruby::compile(argSeq.size()+1, argv);
188
+ }
189
+ catch(const std::exception& ex)
190
+ {
191
+ getErrorStream() << argv[0] << ": error:" << ex.what() << endl;
192
+ rc = EXIT_FAILURE;
193
+ }
194
+ catch(const std::string& msg)
195
+ {
196
+ getErrorStream() << argv[0] << ": error:" << msg << endl;
197
+ rc = EXIT_FAILURE;
198
+ }
199
+ catch(const char* msg)
200
+ {
201
+ getErrorStream() << argv[0] << ": error:" << msg << endl;
202
+ rc = EXIT_FAILURE;
203
+ }
204
+ catch(...)
205
+ {
206
+ getErrorStream() << argv[0] << ": error:" << "unknown exception" << endl;
207
+ rc = EXIT_FAILURE;
208
+ }
209
+
210
+ delete[] argv;
211
+ return INT2FIX(rc);
212
+ }
213
+ ICE_RUBY_CATCH
214
+
215
+ return Qnil;
216
+ }
217
+
218
+ void
219
+ IceRuby::initSlice(VALUE iceModule)
220
+ {
221
+ rb_define_module_function(iceModule, "loadSlice", CAST_METHOD(IceRuby_loadSlice), -1);
222
+ rb_define_module_function(iceModule, "compile", CAST_METHOD(IceRuby_compile), -1);
223
+ }
data/ext/Slice.h ADDED
@@ -0,0 +1,22 @@
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_RUBY_SLICE_H
11
+ #define ICE_RUBY_SLICE_H
12
+
13
+ #include <Config.h>
14
+
15
+ namespace IceRuby
16
+ {
17
+
18
+ void initSlice(VALUE);
19
+
20
+ }
21
+
22
+ #endif
data/ext/Types.cpp ADDED
@@ -0,0 +1,3160 @@
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 <Types.h>
11
+ #include <Proxy.h>
12
+ #include <Util.h>
13
+ #include <IceUtil/InputUtil.h>
14
+ #include <IceUtil/OutputUtil.h>
15
+ #include <IceUtil/ScopedArray.h>
16
+ #include <Ice/LocalException.h>
17
+ #include <Ice/SlicedData.h>
18
+ #include <list>
19
+
20
+ //
21
+ // Required for RHASH_SIZE to work properly with Ruby 1.8.x.
22
+ // T_ZOMBIE is only defined in Ruby 1.9.
23
+ //
24
+ #ifndef T_ZOMBIE
25
+ # include "st.h"
26
+ #endif
27
+
28
+ #ifndef RHASH_SIZE
29
+ # define RHASH_SIZE(v) RHASH(v)->tbl->num_entries
30
+ #endif
31
+
32
+ using namespace std;
33
+ using namespace IceRuby;
34
+ using namespace IceUtil;
35
+ using namespace IceUtilInternal;
36
+
37
+ static VALUE _typeInfoClass, _exceptionInfoClass, _unsetTypeClass;
38
+
39
+ typedef map<string, ClassInfoPtr> ClassInfoMap;
40
+ static ClassInfoMap _classInfoMap;
41
+
42
+ typedef map<Ice::Int, ClassInfoPtr> CompactIdMap;
43
+ static CompactIdMap _compactIdMap;
44
+
45
+ typedef map<string, ProxyInfoPtr> ProxyInfoMap;
46
+ static ProxyInfoMap _proxyInfoMap;
47
+
48
+ typedef map<string, ExceptionInfoPtr> ExceptionInfoMap;
49
+ static ExceptionInfoMap _exceptionInfoMap;
50
+
51
+ namespace IceRuby
52
+ {
53
+
54
+ VALUE Unset;
55
+
56
+ class InfoMapDestroyer
57
+ {
58
+ public:
59
+
60
+ ~InfoMapDestroyer();
61
+ };
62
+ static InfoMapDestroyer infoMapDestroyer;
63
+
64
+ class ReadObjectCallback : public Ice::ReadObjectCallback
65
+ {
66
+ public:
67
+
68
+ ReadObjectCallback(const ClassInfoPtr&, const UnmarshalCallbackPtr&, VALUE, void*);
69
+
70
+ virtual void invoke(const Ice::ObjectPtr&);
71
+
72
+ private:
73
+
74
+ ClassInfoPtr _info;
75
+ UnmarshalCallbackPtr _cb;
76
+ VALUE _target;
77
+ void* _closure;
78
+ };
79
+
80
+ string
81
+ escapeString(const string& str)
82
+ {
83
+ static const string basicSourceChars = "abcdefghijklmnopqrstuvwxyz"
84
+ "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
85
+ "0123456789"
86
+ "_{}[]#()<>%:;.?*+-/^&|~!=,\\\"' ";
87
+ static const set<char> charSet(basicSourceChars.begin(), basicSourceChars.end());
88
+
89
+ ostringstream out;
90
+
91
+ for(string::const_iterator c = str.begin(); c != str.end(); ++c)
92
+ {
93
+ if(charSet.find(*c) == charSet.end())
94
+ {
95
+ unsigned char uc = *c; // char may be signed, so make it positive
96
+ ostringstream s;
97
+ s << "\\"; // Print as octal if not in basic source character set
98
+ s.width(3);
99
+ s.fill('0');
100
+ s << oct;
101
+ s << static_cast<unsigned>(uc);
102
+ out << s.str();
103
+ }
104
+ else
105
+ {
106
+ out << *c; // Print normally if in basic source character set
107
+ }
108
+ }
109
+
110
+ return out.str();
111
+ }
112
+
113
+ }
114
+
115
+ //
116
+ // addClassInfo()
117
+ //
118
+ static void
119
+ addClassInfo(const string& id, const ClassInfoPtr& info)
120
+ {
121
+ //
122
+ // Do not assert. An application may load statically-
123
+ // translated definitions and then dynamically load
124
+ // duplicate definitions.
125
+ //
126
+ // assert(_classInfoMap.find(id) == _classInfoMap.end());
127
+ ClassInfoMap::iterator p = _classInfoMap.find(id);
128
+ if(p != _classInfoMap.end())
129
+ {
130
+ _classInfoMap.erase(p);
131
+ }
132
+ _classInfoMap.insert(ClassInfoMap::value_type(id, info));
133
+ }
134
+
135
+ //
136
+ // addProxyInfo()
137
+ //
138
+ static void
139
+ addProxyInfo(const string& id, const ProxyInfoPtr& info)
140
+ {
141
+ //
142
+ // Do not assert. An application may load statically-
143
+ // translated definitions and then dynamically load
144
+ // duplicate definitions.
145
+ //
146
+ // assert(_proxyInfoMap.find(id) == _proxyInfoMap.end());
147
+ ProxyInfoMap::iterator p = _proxyInfoMap.find(id);
148
+ if(p != _proxyInfoMap.end())
149
+ {
150
+ _proxyInfoMap.erase(p);
151
+ }
152
+ _proxyInfoMap.insert(ProxyInfoMap::value_type(id, info));
153
+ }
154
+
155
+ //
156
+ // lookupProxyInfo()
157
+ //
158
+ static IceRuby::ProxyInfoPtr
159
+ lookupProxyInfo(const string& id)
160
+ {
161
+ ProxyInfoMap::iterator p = _proxyInfoMap.find(id);
162
+ if(p != _proxyInfoMap.end())
163
+ {
164
+ return p->second;
165
+ }
166
+ return 0;
167
+ }
168
+
169
+ //
170
+ // addExceptionInfo()
171
+ //
172
+ static void
173
+ addExceptionInfo(const string& id, const ExceptionInfoPtr& info)
174
+ {
175
+ //
176
+ // Do not assert. An application may load statically-
177
+ // translated definitions and then dynamically load
178
+ // duplicate definitions.
179
+ //
180
+ // assert(_exceptionInfoMap.find(id) == _exceptionInfoMap.end());
181
+ _exceptionInfoMap.insert(ExceptionInfoMap::value_type(id, info));
182
+ }
183
+
184
+ //
185
+ // SlicedDataUtil implementation
186
+ //
187
+ VALUE IceRuby::SlicedDataUtil::_slicedDataType = Qnil;
188
+ VALUE IceRuby::SlicedDataUtil::_sliceInfoType = Qnil;
189
+
190
+ IceRuby::SlicedDataUtil::SlicedDataUtil()
191
+ {
192
+ }
193
+
194
+ IceRuby::SlicedDataUtil::~SlicedDataUtil()
195
+ {
196
+ //
197
+ // Make sure we break any cycles among the ObjectReaders in preserved slices.
198
+ //
199
+ for(set<ObjectReaderPtr>::iterator p = _readers.begin(); p != _readers.end(); ++p)
200
+ {
201
+ Ice::SlicedDataPtr slicedData = (*p)->getSlicedData();
202
+ for(Ice::SliceInfoSeq::const_iterator q = slicedData->slices.begin(); q != slicedData->slices.end(); ++q)
203
+ {
204
+ //
205
+ // Don't just call (*q)->objects.clear(), as releasing references
206
+ // to the objects could have unexpected side effects. We exchange
207
+ // the vector into a temporary and then let the temporary fall out
208
+ // of scope.
209
+ //
210
+ vector<Ice::ObjectPtr> tmp;
211
+ tmp.swap((*q)->objects);
212
+ }
213
+ }
214
+ }
215
+
216
+ void
217
+ IceRuby::SlicedDataUtil::add(const ObjectReaderPtr& reader)
218
+ {
219
+ assert(reader->getSlicedData());
220
+ _readers.insert(reader);
221
+ }
222
+
223
+ void
224
+ IceRuby::SlicedDataUtil::update()
225
+ {
226
+ for(set<ObjectReaderPtr>::iterator p = _readers.begin(); p != _readers.end(); ++p)
227
+ {
228
+ setMember((*p)->getObject(), (*p)->getSlicedData());
229
+ }
230
+ }
231
+
232
+ void
233
+ IceRuby::SlicedDataUtil::setMember(VALUE obj, const Ice::SlicedDataPtr& slicedData)
234
+ {
235
+ //
236
+ // Create a Ruby equivalent of the SlicedData object.
237
+ //
238
+
239
+ assert(slicedData);
240
+
241
+ if(_slicedDataType == Qnil)
242
+ {
243
+ _slicedDataType = callRuby(rb_path2class, "Ice::SlicedData");
244
+ assert(!NIL_P(_slicedDataType));
245
+ }
246
+ if(_sliceInfoType == Qnil)
247
+ {
248
+ _sliceInfoType = callRuby(rb_path2class, "Ice::SliceInfo");
249
+ assert(!NIL_P(_sliceInfoType));
250
+ }
251
+
252
+ volatile VALUE sd = callRuby(rb_class_new_instance, 0, static_cast<VALUE*>(0), _slicedDataType);
253
+
254
+ Ice::Int sz = slicedData->slices.size();
255
+ volatile VALUE slices = createArray(sz);
256
+
257
+ callRuby(rb_iv_set, sd, "@slices", slices);
258
+
259
+ //
260
+ // Translate each SliceInfo object into its Ruby equivalent.
261
+ //
262
+ int i = 0;
263
+ for(vector<Ice::SliceInfoPtr>::const_iterator p = slicedData->slices.begin(); p != slicedData->slices.end(); ++p)
264
+ {
265
+ volatile VALUE slice = callRuby(rb_class_new_instance, 0, static_cast<VALUE*>(0), _sliceInfoType);
266
+
267
+ RARRAY_PTR(slices)[i++] = slice;
268
+
269
+ //
270
+ // typeId
271
+ //
272
+ volatile VALUE typeId = createString((*p)->typeId);
273
+ callRuby(rb_iv_set, slice, "@typeId", typeId);
274
+
275
+ //
276
+ // compactId
277
+ //
278
+ volatile VALUE compactId = INT2FIX((*p)->compactId);
279
+ callRuby(rb_iv_set, slice, "@compactId", compactId);
280
+
281
+ //
282
+ // bytes
283
+ //
284
+ volatile VALUE bytes = callRuby(rb_str_new, reinterpret_cast<const char*>(&(*p)->bytes[0]), (*p)->bytes.size());
285
+ callRuby(rb_iv_set, slice, "@bytes", bytes);
286
+
287
+ //
288
+ // objects
289
+ //
290
+ volatile VALUE objects = createArray((*p)->objects.size());
291
+ callRuby(rb_iv_set, slice, "@objects", objects);
292
+
293
+ int j = 0;
294
+ for(vector<Ice::ObjectPtr>::iterator q = (*p)->objects.begin(); q != (*p)->objects.end(); ++q)
295
+ {
296
+ //
297
+ // Each element in the objects list is an instance of ObjectReader that wraps a Ruby object.
298
+ //
299
+ assert(*q);
300
+ ObjectReaderPtr r = ObjectReaderPtr::dynamicCast(*q);
301
+ assert(r);
302
+ VALUE o = r->getObject();
303
+ assert(o != Qnil); // Should be non-nil.
304
+ RARRAY_PTR(objects)[j++] = o;
305
+ }
306
+
307
+ //
308
+ // hasOptionalMembers
309
+ //
310
+ callRuby(rb_iv_set, slice, "@hasOptionalMembers", (*p)->hasOptionalMembers ? Qtrue : Qfalse);
311
+
312
+ //
313
+ // isLastSlice
314
+ //
315
+ callRuby(rb_iv_set, slice, "@isLastSlice", (*p)->isLastSlice ? Qtrue : Qfalse);
316
+ }
317
+
318
+ callRuby(rb_iv_set, obj, "@_ice_slicedData", sd);
319
+ }
320
+
321
+ //
322
+ // Instances of preserved class and exception types may have a data member
323
+ // named _ice_slicedData which is an instance of the Ruby class Ice::SlicedData.
324
+ //
325
+ Ice::SlicedDataPtr
326
+ IceRuby::SlicedDataUtil::getMember(VALUE obj, ObjectMap* objectMap)
327
+ {
328
+ Ice::SlicedDataPtr slicedData;
329
+
330
+ if(callRuby(rb_ivar_defined, obj, rb_intern("@_ice_slicedData")) == Qtrue)
331
+ {
332
+ volatile VALUE sd = callRuby(rb_iv_get, obj, "@_ice_slicedData");
333
+
334
+ if(sd != Qnil)
335
+ {
336
+ //
337
+ // The "slices" member is an array of Ice::SliceInfo objects.
338
+ //
339
+ volatile VALUE sl = callRuby(rb_iv_get, sd, "@slices");
340
+ assert(TYPE(sl) == T_ARRAY);
341
+
342
+ Ice::SliceInfoSeq slices;
343
+
344
+ long sz = RARRAY_LEN(sl);
345
+ for(long i = 0; i < sz; ++i)
346
+ {
347
+ volatile VALUE s = RARRAY_PTR(sl)[i];
348
+
349
+ Ice::SliceInfoPtr info = new Ice::SliceInfo;
350
+
351
+ volatile VALUE typeId = callRuby(rb_iv_get, s, "@typeId");
352
+ info->typeId = getString(typeId);
353
+
354
+ volatile VALUE compactId = callRuby(rb_iv_get, s, "@compactId");
355
+ info->compactId = static_cast<Ice::Int>(getInteger(compactId));
356
+
357
+ volatile VALUE bytes = callRuby(rb_iv_get, s, "@bytes");
358
+ assert(TYPE(bytes) == T_STRING);
359
+ const char* str = RSTRING_PTR(bytes);
360
+ const long len = RSTRING_LEN(bytes);
361
+ if(str != 0 && len != 0)
362
+ {
363
+ vector<Ice::Byte> vtmp(reinterpret_cast<const Ice::Byte*>(str),
364
+ reinterpret_cast<const Ice::Byte*>(str + len));
365
+ info->bytes.swap(vtmp);
366
+ }
367
+
368
+ volatile VALUE objects = callRuby(rb_iv_get, s, "@objects");
369
+ assert(TYPE(objects) == T_ARRAY);
370
+ long osz = RARRAY_LEN(objects);
371
+ for(long j = 0; j < osz; ++j)
372
+ {
373
+ VALUE o = RARRAY_PTR(objects)[j];
374
+
375
+ Ice::ObjectPtr writer;
376
+
377
+ ObjectMap::iterator i = objectMap->find(o);
378
+ if(i == objectMap->end())
379
+ {
380
+ writer = new ObjectWriter(o, objectMap);
381
+ objectMap->insert(ObjectMap::value_type(o, writer));
382
+ }
383
+ else
384
+ {
385
+ writer = i->second;
386
+ }
387
+
388
+ info->objects.push_back(writer);
389
+ }
390
+
391
+ volatile VALUE hasOptionalMembers = callRuby(rb_iv_get, s, "@hasOptionalMembers");
392
+ info->hasOptionalMembers = hasOptionalMembers == Qtrue;
393
+
394
+ volatile VALUE isLastSlice = callRuby(rb_iv_get, s, "@isLastSlice");
395
+ info->isLastSlice = isLastSlice == Qtrue;
396
+
397
+ slices.push_back(info);
398
+ }
399
+
400
+ slicedData = new Ice::SlicedData(slices);
401
+ }
402
+ }
403
+
404
+ return slicedData;
405
+ }
406
+
407
+ //
408
+ // UnmarshalCallback implementation.
409
+ //
410
+ IceRuby::UnmarshalCallback::~UnmarshalCallback()
411
+ {
412
+ }
413
+
414
+ //
415
+ // TypeInfo implementation.
416
+ //
417
+ IceRuby::TypeInfo::TypeInfo()
418
+ {
419
+ }
420
+
421
+ bool
422
+ IceRuby::TypeInfo::usesClasses() const
423
+ {
424
+ return false;
425
+ }
426
+
427
+ void
428
+ IceRuby::TypeInfo::unmarshaled(VALUE, VALUE, void*)
429
+ {
430
+ assert(false);
431
+ }
432
+
433
+ void
434
+ IceRuby::TypeInfo::destroy()
435
+ {
436
+ }
437
+
438
+ //
439
+ // PrimitiveInfo implementation.
440
+ //
441
+ IceRuby::PrimitiveInfo::PrimitiveInfo()
442
+ {
443
+ }
444
+
445
+ IceRuby::PrimitiveInfo::PrimitiveInfo(Kind k) : kind(k)
446
+ {
447
+ }
448
+
449
+ string
450
+ IceRuby::PrimitiveInfo::getId() const
451
+ {
452
+ switch(kind)
453
+ {
454
+ case KindBool:
455
+ return "bool";
456
+ case KindByte:
457
+ return "byte";
458
+ case KindShort:
459
+ return "short";
460
+ case KindInt:
461
+ return "int";
462
+ case KindLong:
463
+ return "long";
464
+ case KindFloat:
465
+ return "float";
466
+ case KindDouble:
467
+ return "double";
468
+ case KindString:
469
+ return "string";
470
+ }
471
+ assert(false);
472
+ return string();
473
+ }
474
+
475
+ bool
476
+ IceRuby::PrimitiveInfo::validate(VALUE)
477
+ {
478
+ //
479
+ // Ruby supports type coercion, such that it's technically possible for any
480
+ // value to be coerced to a primitive type. It would be expensive to perform
481
+ // this coercion twice, once to validate and again to marshal, so we skip
482
+ // the validation here.
483
+ //
484
+ return true;
485
+ }
486
+
487
+ bool
488
+ IceRuby::PrimitiveInfo::variableLength() const
489
+ {
490
+ return kind == KindString;
491
+ }
492
+
493
+ int
494
+ IceRuby::PrimitiveInfo::wireSize() const
495
+ {
496
+ switch(kind)
497
+ {
498
+ case KindBool:
499
+ case KindByte:
500
+ return 1;
501
+ case KindShort:
502
+ return 2;
503
+ case KindInt:
504
+ return 4;
505
+ case KindLong:
506
+ return 8;
507
+ case KindFloat:
508
+ return 4;
509
+ case KindDouble:
510
+ return 8;
511
+ case KindString:
512
+ return 1;
513
+ }
514
+ assert(false);
515
+ return 0;
516
+ }
517
+
518
+ Ice::OptionalFormat
519
+ IceRuby::PrimitiveInfo::optionalFormat() const
520
+ {
521
+ switch(kind)
522
+ {
523
+ case KindBool:
524
+ case KindByte:
525
+ return Ice::OptionalFormatF1;
526
+ case KindShort:
527
+ return Ice::OptionalFormatF2;
528
+ case KindInt:
529
+ return Ice::OptionalFormatF4;
530
+ case KindLong:
531
+ return Ice::OptionalFormatF8;
532
+ case KindFloat:
533
+ return Ice::OptionalFormatF4;
534
+ case KindDouble:
535
+ return Ice::OptionalFormatF8;
536
+ case KindString:
537
+ return Ice::OptionalFormatVSize;
538
+ }
539
+
540
+ assert(false);
541
+ return Ice::OptionalFormatF1;
542
+ }
543
+
544
+ void
545
+ IceRuby::PrimitiveInfo::marshal(VALUE p, const Ice::OutputStreamPtr& os, ObjectMap*, bool)
546
+ {
547
+ switch(kind)
548
+ {
549
+ case PrimitiveInfo::KindBool:
550
+ {
551
+ os->write(static_cast<bool>(RTEST(p)));
552
+ break;
553
+ }
554
+ case PrimitiveInfo::KindByte:
555
+ {
556
+ long i = getInteger(p);
557
+ if(i >= 0 && i <= 255)
558
+ {
559
+ os->write(static_cast<Ice::Byte>(i));
560
+ break;
561
+ }
562
+ throw RubyException(rb_eTypeError, "value is out of range for a byte");
563
+ }
564
+ case PrimitiveInfo::KindShort:
565
+ {
566
+ long i = getInteger(p);
567
+ if(i >= SHRT_MIN && i <= SHRT_MAX)
568
+ {
569
+ os->write(static_cast<Ice::Short>(i));
570
+ break;
571
+ }
572
+ throw RubyException(rb_eTypeError, "value is out of range for a short");
573
+ }
574
+ case PrimitiveInfo::KindInt:
575
+ {
576
+ long i = getInteger(p);
577
+ if(i >= INT_MIN && i <= INT_MAX)
578
+ {
579
+ os->write(static_cast<Ice::Int>(i));
580
+ break;
581
+ }
582
+ throw RubyException(rb_eTypeError, "value is out of range for an int");
583
+ }
584
+ case PrimitiveInfo::KindLong:
585
+ {
586
+ os->write(getLong(p));
587
+ break;
588
+ }
589
+ case PrimitiveInfo::KindFloat:
590
+ {
591
+ volatile VALUE val = callRuby(rb_Float, p);
592
+ if(NIL_P(val))
593
+ {
594
+ throw RubyException(rb_eTypeError, "unable to convert value to a float");
595
+ }
596
+ assert(TYPE(val) == T_FLOAT);
597
+ os->write(static_cast<float>(RFLOAT_VALUE(val)));
598
+ break;
599
+ }
600
+ case PrimitiveInfo::KindDouble:
601
+ {
602
+ volatile VALUE val = callRuby(rb_Float, p);
603
+ if(NIL_P(val))
604
+ {
605
+ throw RubyException(rb_eTypeError, "unable to convert value to a double");
606
+ }
607
+ assert(TYPE(val) == T_FLOAT);
608
+ os->write(static_cast<double>(RFLOAT_VALUE(val)));
609
+ break;
610
+ }
611
+ case PrimitiveInfo::KindString:
612
+ {
613
+ string val = getString(p);
614
+ os->write(val);
615
+ break;
616
+ }
617
+ }
618
+ }
619
+
620
+ void
621
+ IceRuby::PrimitiveInfo::unmarshal(const Ice::InputStreamPtr& is, const UnmarshalCallbackPtr& cb, VALUE target,
622
+ void* closure, bool)
623
+ {
624
+ volatile VALUE val = Qnil;
625
+ switch(kind)
626
+ {
627
+ case PrimitiveInfo::KindBool:
628
+ {
629
+ bool b;
630
+ is->read(b);
631
+ val = b ? Qtrue : Qfalse;
632
+ break;
633
+ }
634
+ case PrimitiveInfo::KindByte:
635
+ {
636
+ Ice::Byte b;
637
+ is->read(b);
638
+ val = callRuby(rb_int2inum, b);
639
+ break;
640
+ }
641
+ case PrimitiveInfo::KindShort:
642
+ {
643
+ Ice::Short sh;
644
+ is->read(sh);
645
+ val = callRuby(rb_int2inum, sh);
646
+ break;
647
+ }
648
+ case PrimitiveInfo::KindInt:
649
+ {
650
+ Ice::Int i;
651
+ is->read(i);
652
+ val = callRuby(rb_int2inum, i);
653
+ break;
654
+ }
655
+ case PrimitiveInfo::KindLong:
656
+ {
657
+ Ice::Long l;
658
+ is->read(l);
659
+ val = callRuby(rb_ll2inum, l);
660
+ break;
661
+ }
662
+ case PrimitiveInfo::KindFloat:
663
+ {
664
+ Ice::Float f;
665
+ is->read(f);
666
+ val = callRuby(rb_float_new, f);
667
+ break;
668
+ }
669
+ case PrimitiveInfo::KindDouble:
670
+ {
671
+ Ice::Double d;
672
+ is->read(d);
673
+ val = callRuby(rb_float_new, d);
674
+ break;
675
+ }
676
+ case PrimitiveInfo::KindString:
677
+ {
678
+ string str;
679
+ is->read(str);
680
+ val = createString(str);
681
+ break;
682
+ }
683
+ }
684
+ cb->unmarshaled(val, target, closure);
685
+ }
686
+
687
+ void
688
+ IceRuby::PrimitiveInfo::print(VALUE value, IceUtilInternal::Output& out, PrintObjectHistory*)
689
+ {
690
+ switch(kind)
691
+ {
692
+ case PrimitiveInfo::KindBool:
693
+ {
694
+ out << (RTEST(value) ? "true" : "false");
695
+ break;
696
+ }
697
+ case PrimitiveInfo::KindByte:
698
+ case PrimitiveInfo::KindShort:
699
+ case PrimitiveInfo::KindInt:
700
+ {
701
+ out << getInteger(value);
702
+ break;
703
+ }
704
+ case PrimitiveInfo::KindLong:
705
+ {
706
+ Ice::Long l = getLong(value);
707
+ out << IceUtilInternal::int64ToString(l);
708
+ break;
709
+ }
710
+ case PrimitiveInfo::KindFloat:
711
+ case PrimitiveInfo::KindDouble:
712
+ {
713
+ double d = toDouble(value);
714
+ out << d;
715
+ break;
716
+ }
717
+ case PrimitiveInfo::KindString:
718
+ {
719
+ out << "'" << getString(value) << "'";
720
+ break;
721
+ }
722
+ }
723
+ }
724
+
725
+ double
726
+ IceRuby::PrimitiveInfo::toDouble(VALUE v)
727
+ {
728
+ volatile VALUE val = callRuby(rb_Float, v);
729
+ if(NIL_P(val))
730
+ {
731
+ throw RubyException(rb_eTypeError, "unable to convert value to a double");
732
+ }
733
+ assert(TYPE(val) == T_FLOAT);
734
+ return RFLOAT_VALUE(val);
735
+ }
736
+
737
+ //
738
+ // EnumInfo implementation.
739
+ //
740
+
741
+ namespace
742
+ {
743
+ struct EnumDefinitionIterator : public IceRuby::HashIterator
744
+ {
745
+ EnumDefinitionIterator() :
746
+ maxValue(0)
747
+ {
748
+ }
749
+
750
+ virtual void element(VALUE key, VALUE value)
751
+ {
752
+ const Ice::Int v = static_cast<Ice::Int>(getInteger(key));
753
+ assert(enumerators.find(v) == enumerators.end());
754
+ enumerators[v] = value;
755
+
756
+ if(v > maxValue)
757
+ {
758
+ maxValue = v;
759
+ }
760
+ }
761
+
762
+ Ice::Int maxValue;
763
+ IceRuby::EnumeratorMap enumerators;
764
+ };
765
+ }
766
+
767
+ IceRuby::EnumInfo::EnumInfo(VALUE ident, VALUE t, VALUE e) :
768
+ rubyClass(t), maxValue(0)
769
+ {
770
+ const_cast<string&>(id) = getString(ident);
771
+
772
+ EnumDefinitionIterator iter;
773
+ hashIterate(e, iter);
774
+
775
+ const_cast<Ice::Int&>(maxValue) = iter.maxValue;
776
+ const_cast<EnumeratorMap&>(enumerators) = iter.enumerators;
777
+ }
778
+
779
+ string
780
+ IceRuby::EnumInfo::getId() const
781
+ {
782
+ return id;
783
+ }
784
+
785
+ bool
786
+ IceRuby::EnumInfo::validate(VALUE val)
787
+ {
788
+ return callRuby(rb_obj_is_instance_of, val, rubyClass) == Qtrue;
789
+ }
790
+
791
+ bool
792
+ IceRuby::EnumInfo::variableLength() const
793
+ {
794
+ return true;
795
+ }
796
+
797
+ int
798
+ IceRuby::EnumInfo::wireSize() const
799
+ {
800
+ return 1;
801
+ }
802
+
803
+ Ice::OptionalFormat
804
+ IceRuby::EnumInfo::optionalFormat() const
805
+ {
806
+ return Ice::OptionalFormatSize;
807
+ }
808
+
809
+ void
810
+ IceRuby::EnumInfo::marshal(VALUE p, const Ice::OutputStreamPtr& os, ObjectMap*, bool)
811
+ {
812
+ assert(callRuby(rb_obj_is_instance_of, p, rubyClass) == Qtrue); // validate() should have caught this.
813
+
814
+ //
815
+ // Validate value.
816
+ //
817
+ volatile VALUE val = callRuby(rb_iv_get, p, "@value");
818
+ const Ice::Int ival = static_cast<Ice::Int>(getInteger(val));
819
+ if(enumerators.find(ival) == enumerators.end())
820
+ {
821
+ throw RubyException(rb_eRangeError, "invalid enumerator %ld for enum %s", ival, id.c_str());
822
+ }
823
+
824
+ os->writeEnum(ival, maxValue);
825
+ }
826
+
827
+ void
828
+ IceRuby::EnumInfo::unmarshal(const Ice::InputStreamPtr& is, const UnmarshalCallbackPtr& cb, VALUE target, void* closure,
829
+ bool)
830
+ {
831
+ Ice::Int val = is->readEnum(maxValue);
832
+
833
+ EnumeratorMap::const_iterator p = enumerators.find(val);
834
+ if(p == enumerators.end())
835
+ {
836
+ ostringstream ostr;
837
+ ostr << "invalid enumerator " << val << " for enum " << id;
838
+ throw Ice::MarshalException(__FILE__, __LINE__, ostr.str());
839
+ }
840
+
841
+ cb->unmarshaled(p->second, target, closure);
842
+ }
843
+
844
+ void
845
+ IceRuby::EnumInfo::print(VALUE value, IceUtilInternal::Output& out, PrintObjectHistory*)
846
+ {
847
+ if(!validate(value))
848
+ {
849
+ out << "<invalid value - expected " << id << ">";
850
+ return;
851
+ }
852
+ volatile VALUE str = callRuby(rb_funcall, value, rb_intern("inspect"), 0);
853
+ out << getString(str);
854
+ }
855
+
856
+ //
857
+ // DataMember implementation.
858
+ //
859
+ void
860
+ IceRuby::DataMember::unmarshaled(VALUE val, VALUE target, void*)
861
+ {
862
+ callRuby(rb_ivar_set, target, rubyID, val);
863
+ }
864
+
865
+ static void
866
+ convertDataMembers(VALUE members, DataMemberList& reqMembers, DataMemberList& optMembers, bool allowOptional)
867
+ {
868
+ list<DataMemberPtr> optList;
869
+
870
+ volatile VALUE arr = callRuby(rb_check_array_type, members);
871
+ assert(!NIL_P(arr));
872
+ for(long i = 0; i < RARRAY_LEN(arr); ++i)
873
+ {
874
+ volatile VALUE m = callRuby(rb_check_array_type, RARRAY_PTR(arr)[i]);
875
+ assert(!NIL_P(m));
876
+ assert(RARRAY_LEN(m) == allowOptional ? 4 : 2);
877
+
878
+ DataMemberPtr member = new DataMember;
879
+
880
+ member->name = getString(RARRAY_PTR(m)[0]);
881
+ member->type = getType(RARRAY_PTR(m)[1]);
882
+ string s = "@" + member->name;
883
+ member->rubyID = rb_intern(s.c_str());
884
+
885
+ if(allowOptional)
886
+ {
887
+ member->optional = RTEST(RARRAY_PTR(m)[2]);
888
+ member->tag = static_cast<int>(getInteger(RARRAY_PTR(m)[3]));
889
+ }
890
+ else
891
+ {
892
+ member->optional = false;
893
+ member->tag = 0;
894
+ }
895
+
896
+ if(member->optional)
897
+ {
898
+ optList.push_back(member);
899
+ }
900
+ else
901
+ {
902
+ reqMembers.push_back(member);
903
+ }
904
+ }
905
+
906
+ if(allowOptional)
907
+ {
908
+ class SortFn
909
+ {
910
+ public:
911
+ static bool compare(const DataMemberPtr& lhs, const DataMemberPtr& rhs)
912
+ {
913
+ return lhs->tag < rhs->tag;
914
+ }
915
+ };
916
+
917
+ optList.sort(SortFn::compare);
918
+ copy(optList.begin(), optList.end(), back_inserter(optMembers));
919
+ }
920
+ }
921
+
922
+ //
923
+ // StructInfo implementation.
924
+ //
925
+ IceRuby::StructInfo::StructInfo(VALUE ident, VALUE t, VALUE m) :
926
+ rubyClass(t)
927
+ {
928
+ const_cast<string&>(id) = getString(ident);
929
+
930
+ DataMemberList opt;
931
+ convertDataMembers(m, const_cast<DataMemberList&>(members), opt, false);
932
+ assert(opt.empty());
933
+
934
+ _variableLength = false;
935
+ _wireSize = 0;
936
+ for(DataMemberList::const_iterator p = members.begin(); p != members.end(); ++p)
937
+ {
938
+ if(!_variableLength && (*p)->type->variableLength())
939
+ {
940
+ _variableLength = true;
941
+ }
942
+ _wireSize += (*p)->type->wireSize();
943
+ }
944
+ }
945
+
946
+ string
947
+ IceRuby::StructInfo::getId() const
948
+ {
949
+ return id;
950
+ }
951
+
952
+ bool
953
+ IceRuby::StructInfo::validate(VALUE val)
954
+ {
955
+ return callRuby(rb_obj_is_kind_of, val, rubyClass) == Qtrue;
956
+ }
957
+
958
+ bool
959
+ IceRuby::StructInfo::variableLength() const
960
+ {
961
+ return _variableLength;
962
+ }
963
+
964
+ int
965
+ IceRuby::StructInfo::wireSize() const
966
+ {
967
+ return _wireSize;
968
+ }
969
+
970
+ Ice::OptionalFormat
971
+ IceRuby::StructInfo::optionalFormat() const
972
+ {
973
+ return _variableLength ? Ice::OptionalFormatFSize : Ice::OptionalFormatVSize;
974
+ }
975
+
976
+ bool
977
+ IceRuby::StructInfo::usesClasses() const
978
+ {
979
+ for(DataMemberList::const_iterator p = members.begin(); p != members.end(); ++p)
980
+ {
981
+ if((*p)->type->usesClasses())
982
+ {
983
+ return true;
984
+ }
985
+ }
986
+
987
+ return false;
988
+ }
989
+
990
+ void
991
+ IceRuby::StructInfo::marshal(VALUE p, const Ice::OutputStreamPtr& os, ObjectMap* objectMap, bool optional)
992
+ {
993
+ assert(callRuby(rb_obj_is_kind_of, p, rubyClass) == Qtrue); // validate() should have caught this.
994
+
995
+ Ice::OutputStream::size_type sizePos = -1;
996
+ if(optional)
997
+ {
998
+ if(_variableLength)
999
+ {
1000
+ sizePos = os->startSize();
1001
+ }
1002
+ else
1003
+ {
1004
+ os->writeSize(_wireSize);
1005
+ }
1006
+ }
1007
+
1008
+ for(DataMemberList::const_iterator q = members.begin(); q != members.end(); ++q)
1009
+ {
1010
+ DataMemberPtr member = *q;
1011
+ volatile VALUE val = callRuby(rb_ivar_get, p, member->rubyID);
1012
+ if(!member->type->validate(val))
1013
+ {
1014
+ throw RubyException(rb_eTypeError, "invalid value for %s member `%s'", const_cast<char*>(id.c_str()),
1015
+ member->name.c_str());
1016
+ }
1017
+ member->type->marshal(val, os, objectMap, false);
1018
+ }
1019
+
1020
+ if(optional && _variableLength)
1021
+ {
1022
+ os->endSize(sizePos);
1023
+ }
1024
+ }
1025
+
1026
+ void
1027
+ IceRuby::StructInfo::unmarshal(const Ice::InputStreamPtr& is, const UnmarshalCallbackPtr& cb, VALUE target,
1028
+ void* closure, bool optional)
1029
+ {
1030
+ volatile VALUE obj = callRuby(rb_class_new_instance, 0, static_cast<VALUE*>(0), rubyClass);
1031
+
1032
+ if(optional)
1033
+ {
1034
+ if(_variableLength)
1035
+ {
1036
+ is->skip(4);
1037
+ }
1038
+ else
1039
+ {
1040
+ is->skipSize();
1041
+ }
1042
+ }
1043
+
1044
+ for(DataMemberList::const_iterator q = members.begin(); q != members.end(); ++q)
1045
+ {
1046
+ DataMemberPtr member = *q;
1047
+ member->type->unmarshal(is, member, obj, 0, false);
1048
+ }
1049
+
1050
+ cb->unmarshaled(obj, target, closure);
1051
+ }
1052
+
1053
+ void
1054
+ IceRuby::StructInfo::print(VALUE value, IceUtilInternal::Output& out, PrintObjectHistory* history)
1055
+ {
1056
+ if(!validate(value))
1057
+ {
1058
+ out << "<invalid value - expected " << id << ">";
1059
+ return;
1060
+ }
1061
+ out.sb();
1062
+ for(DataMemberList::const_iterator q = members.begin(); q != members.end(); ++q)
1063
+ {
1064
+ DataMemberPtr member = *q;
1065
+ out << nl << member->name << " = ";
1066
+ if(callRuby(rb_ivar_defined, value, member->rubyID) == Qfalse)
1067
+ {
1068
+ out << "<not defined>";
1069
+ }
1070
+ else
1071
+ {
1072
+ volatile VALUE val = callRuby(rb_ivar_get, value, member->rubyID);
1073
+ member->type->print(val, out, history);
1074
+ }
1075
+ }
1076
+ out.eb();
1077
+ }
1078
+
1079
+ void
1080
+ IceRuby::StructInfo::destroy()
1081
+ {
1082
+ for(DataMemberList::const_iterator p = members.begin(); p != members.end(); ++p)
1083
+ {
1084
+ (*p)->type->destroy();
1085
+ }
1086
+ const_cast<DataMemberList&>(members).clear();
1087
+ }
1088
+
1089
+ //
1090
+ // SequenceInfo implementation.
1091
+ //
1092
+ IceRuby::SequenceInfo::SequenceInfo(VALUE ident, VALUE t)
1093
+ {
1094
+ const_cast<string&>(id) = getString(ident);
1095
+ const_cast<TypeInfoPtr&>(elementType) = getType(t);
1096
+ }
1097
+
1098
+ string
1099
+ IceRuby::SequenceInfo::getId() const
1100
+ {
1101
+ return id;
1102
+ }
1103
+
1104
+ bool
1105
+ IceRuby::SequenceInfo::validate(VALUE val)
1106
+ {
1107
+ //
1108
+ // Accept nil, an array, a string (for sequence<byte>), or any object that responds to to_ary.
1109
+ //
1110
+ if(NIL_P(val) || TYPE(val) == T_ARRAY)
1111
+ {
1112
+ return true;
1113
+ }
1114
+ if(TYPE(val) == T_STRING)
1115
+ {
1116
+ PrimitiveInfoPtr pi = PrimitiveInfoPtr::dynamicCast(elementType);
1117
+ if(pi && pi->kind == PrimitiveInfo::KindByte)
1118
+ {
1119
+ return true;
1120
+ }
1121
+ }
1122
+ ID id = rb_intern("to_ary");
1123
+ return callRuby(rb_respond_to, val, id) != 0;
1124
+ }
1125
+
1126
+ bool
1127
+ IceRuby::SequenceInfo::variableLength() const
1128
+ {
1129
+ return true;
1130
+ }
1131
+
1132
+ int
1133
+ IceRuby::SequenceInfo::wireSize() const
1134
+ {
1135
+ return 1;
1136
+ }
1137
+
1138
+ Ice::OptionalFormat
1139
+ IceRuby::SequenceInfo::optionalFormat() const
1140
+ {
1141
+ return elementType->variableLength() ? Ice::OptionalFormatFSize : Ice::OptionalFormatVSize;
1142
+ }
1143
+
1144
+ bool
1145
+ IceRuby::SequenceInfo::usesClasses() const
1146
+ {
1147
+ return elementType->usesClasses();
1148
+ }
1149
+
1150
+ void
1151
+ IceRuby::SequenceInfo::marshal(VALUE p, const Ice::OutputStreamPtr& os, ObjectMap* objectMap, bool optional)
1152
+ {
1153
+ PrimitiveInfoPtr pi = PrimitiveInfoPtr::dynamicCast(elementType);
1154
+
1155
+ volatile VALUE arr = Qnil;
1156
+
1157
+ Ice::OutputStream::size_type sizePos = -1;
1158
+ if(optional)
1159
+ {
1160
+ if(elementType->variableLength())
1161
+ {
1162
+ sizePos = os->startSize();
1163
+ }
1164
+ else if(elementType->wireSize() > 1)
1165
+ {
1166
+ //
1167
+ // Determine the sequence size.
1168
+ //
1169
+ int sz = 0;
1170
+ if(!NIL_P(p))
1171
+ {
1172
+ if(TYPE(p) == T_ARRAY)
1173
+ {
1174
+ sz = static_cast<int>(RARRAY_LEN(p));
1175
+ }
1176
+ else
1177
+ {
1178
+ arr = callRuby(rb_Array, p);
1179
+ if(NIL_P(arr))
1180
+ {
1181
+ throw RubyException(rb_eTypeError, "unable to convert value to an array");
1182
+ }
1183
+ sz = static_cast<int>(RARRAY_LEN(arr));
1184
+ }
1185
+ }
1186
+ os->writeSize(sz == 0 ? 1 : sz * elementType->wireSize() + (sz > 254 ? 5 : 1));
1187
+ }
1188
+ }
1189
+
1190
+ if(NIL_P(p))
1191
+ {
1192
+ os->writeSize(0);
1193
+ }
1194
+ else if(pi)
1195
+ {
1196
+ marshalPrimitiveSequence(pi, p, os);
1197
+ }
1198
+ else
1199
+ {
1200
+ if(NIL_P(arr))
1201
+ {
1202
+ arr = callRuby(rb_Array, p);
1203
+ if(NIL_P(arr))
1204
+ {
1205
+ throw RubyException(rb_eTypeError, "unable to convert value to an array");
1206
+ }
1207
+ }
1208
+
1209
+ long sz = RARRAY_LEN(arr);
1210
+ os->writeSize(static_cast<Ice::Int>(sz));
1211
+ for(long i = 0; i < sz; ++i)
1212
+ {
1213
+ if(!elementType->validate(RARRAY_PTR(arr)[i]))
1214
+ {
1215
+ throw RubyException(rb_eTypeError, "invalid value for element %ld of `%s'", i,
1216
+ const_cast<char*>(id.c_str()));
1217
+ }
1218
+ elementType->marshal(RARRAY_PTR(arr)[i], os, objectMap, false);
1219
+ }
1220
+ }
1221
+
1222
+ if(optional && elementType->variableLength())
1223
+ {
1224
+ os->endSize(sizePos);
1225
+ }
1226
+ }
1227
+
1228
+ void
1229
+ IceRuby::SequenceInfo::unmarshal(const Ice::InputStreamPtr& is, const UnmarshalCallbackPtr& cb, VALUE target,
1230
+ void* closure, bool optional)
1231
+ {
1232
+ if(optional)
1233
+ {
1234
+ if(elementType->variableLength())
1235
+ {
1236
+ is->skip(4);
1237
+ }
1238
+ else if(elementType->wireSize() > 1)
1239
+ {
1240
+ is->skipSize();
1241
+ }
1242
+ }
1243
+
1244
+ PrimitiveInfoPtr pi = PrimitiveInfoPtr::dynamicCast(elementType);
1245
+ if(pi)
1246
+ {
1247
+ unmarshalPrimitiveSequence(pi, is, cb, target, closure);
1248
+ return;
1249
+ }
1250
+
1251
+ Ice::Int sz = is->readSize();
1252
+ volatile VALUE arr = createArray(sz);
1253
+
1254
+ for(Ice::Int i = 0; i < sz; ++i)
1255
+ {
1256
+ void* cl = reinterpret_cast<void*>(i);
1257
+ elementType->unmarshal(is, this, arr, cl, false);
1258
+ }
1259
+
1260
+ cb->unmarshaled(arr, target, closure);
1261
+ }
1262
+
1263
+ void
1264
+ IceRuby::SequenceInfo::unmarshaled(VALUE val, VALUE target, void* closure)
1265
+ {
1266
+ #ifdef ICE_64
1267
+ long i = static_cast<long>(reinterpret_cast<long long>(closure));
1268
+ #else
1269
+ long i = reinterpret_cast<long>(closure);
1270
+ #endif
1271
+ RARRAY_PTR(target)[i] = val;
1272
+ }
1273
+
1274
+ void
1275
+ IceRuby::SequenceInfo::print(VALUE value, IceUtilInternal::Output& out, PrintObjectHistory* history)
1276
+ {
1277
+ if(!validate(value))
1278
+ {
1279
+ out << "<invalid value - expected " << id << ">";
1280
+ return;
1281
+ }
1282
+
1283
+ if(NIL_P(value))
1284
+ {
1285
+ out << "{}";
1286
+ }
1287
+ else
1288
+ {
1289
+ if(TYPE(value) == T_STRING)
1290
+ {
1291
+ PrimitiveInfoPtr pi = PrimitiveInfoPtr::dynamicCast(elementType);
1292
+ if(pi && pi->kind == PrimitiveInfo::KindByte)
1293
+ {
1294
+ out << "'" << escapeString(getString(value)) << "'";
1295
+ return;
1296
+ }
1297
+ }
1298
+
1299
+ volatile VALUE arr = callRuby(rb_Array, value);
1300
+ if(NIL_P(arr))
1301
+ {
1302
+ throw RubyException(rb_eTypeError, "unable to convert value to an array");
1303
+ }
1304
+
1305
+ long sz = RARRAY_LEN(arr);
1306
+
1307
+ out.sb();
1308
+ for(long i = 0; i < sz; ++i)
1309
+ {
1310
+ out << nl << '[' << i << "] = ";
1311
+ elementType->print(RARRAY_PTR(arr)[i], out, history);
1312
+ }
1313
+ out.eb();
1314
+ }
1315
+ }
1316
+
1317
+ void
1318
+ IceRuby::SequenceInfo::destroy()
1319
+ {
1320
+ if(elementType)
1321
+ {
1322
+ elementType->destroy();
1323
+ const_cast<TypeInfoPtr&>(elementType) = 0;
1324
+ }
1325
+ }
1326
+
1327
+ void
1328
+ IceRuby::SequenceInfo::marshalPrimitiveSequence(const PrimitiveInfoPtr& pi, VALUE p, const Ice::OutputStreamPtr& os)
1329
+ {
1330
+ volatile VALUE arr = Qnil;
1331
+ volatile VALUE str = Qnil;
1332
+
1333
+ //
1334
+ // Accept a string or an array for sequence<byte>.
1335
+ //
1336
+ if(pi->kind == PrimitiveInfo::KindByte)
1337
+ {
1338
+ if(TYPE(p) == T_STRING)
1339
+ {
1340
+ str = p;
1341
+ }
1342
+ else
1343
+ {
1344
+ arr = callRuby(rb_Array, p);
1345
+ if(NIL_P(arr))
1346
+ {
1347
+ throw RubyException(rb_eTypeError, "argument is not a string or an array");
1348
+ }
1349
+ }
1350
+ }
1351
+ else
1352
+ {
1353
+ arr = callRuby(rb_Array, p);
1354
+ if(NIL_P(arr))
1355
+ {
1356
+ throw RubyException(rb_eTypeError, "unable to convert value to an array");
1357
+ }
1358
+ }
1359
+
1360
+ switch(pi->kind)
1361
+ {
1362
+ case PrimitiveInfo::KindBool:
1363
+ {
1364
+ long sz = RARRAY_LEN(arr);
1365
+ Ice::BoolSeq seq(sz);
1366
+ for(long i = 0; i < sz; ++i)
1367
+ {
1368
+ seq[i] = RTEST(RARRAY_PTR(arr)[i]);
1369
+ }
1370
+ os->write(seq);
1371
+ break;
1372
+ }
1373
+ case PrimitiveInfo::KindByte:
1374
+ {
1375
+ if(!NIL_P(str))
1376
+ {
1377
+ const char* s = RSTRING_PTR(str);
1378
+ const long len = RSTRING_LEN(str);
1379
+ if(s == 0 || len == 0)
1380
+ {
1381
+ os->write(Ice::Int(0));
1382
+ }
1383
+ else
1384
+ {
1385
+ os->write(reinterpret_cast<const Ice::Byte*>(s), reinterpret_cast<const Ice::Byte*>(s + len));
1386
+ }
1387
+ }
1388
+ else
1389
+ {
1390
+ long sz = RARRAY_LEN(arr);
1391
+ Ice::ByteSeq seq(sz);
1392
+ for(long i = 0; i < sz; ++i)
1393
+ {
1394
+ long val = getInteger(RARRAY_PTR(arr)[i]);
1395
+ if(val < 0 || val > 255)
1396
+ {
1397
+ throw RubyException(rb_eTypeError, "invalid value for element %ld of sequence<byte>", i);
1398
+ }
1399
+ seq[i] = static_cast<Ice::Byte>(val);
1400
+ }
1401
+ os->write(&seq[0], &seq[0] + seq.size());
1402
+ }
1403
+ break;
1404
+ }
1405
+ case PrimitiveInfo::KindShort:
1406
+ {
1407
+ long sz = RARRAY_LEN(arr);
1408
+ Ice::ShortSeq seq(sz);
1409
+ for(long i = 0; i < sz; ++i)
1410
+ {
1411
+ long val = getInteger(RARRAY_PTR(arr)[i]);
1412
+ if(val < SHRT_MIN || val > SHRT_MAX)
1413
+ {
1414
+ throw RubyException(rb_eTypeError, "invalid value for element %ld of sequence<short>", i);
1415
+ }
1416
+ seq[i] = static_cast<Ice::Short>(val);
1417
+ }
1418
+ os->write(&seq[0], &seq[0] + seq.size());
1419
+ break;
1420
+ }
1421
+ case PrimitiveInfo::KindInt:
1422
+ {
1423
+ long sz = RARRAY_LEN(arr);
1424
+ Ice::IntSeq seq(sz);
1425
+ for(long i = 0; i < sz; ++i)
1426
+ {
1427
+ long val = getInteger(RARRAY_PTR(arr)[i]);
1428
+ if(val < INT_MIN || val > INT_MAX)
1429
+ {
1430
+ throw RubyException(rb_eTypeError, "invalid value for element %ld of sequence<int>", i);
1431
+ }
1432
+ seq[i] = static_cast<Ice::Int>(val);
1433
+ }
1434
+ os->write(&seq[0], &seq[0] + seq.size());
1435
+ break;
1436
+ }
1437
+ case PrimitiveInfo::KindLong:
1438
+ {
1439
+ long sz = RARRAY_LEN(arr);
1440
+ Ice::LongSeq seq(sz);
1441
+ for(long i = 0; i < sz; ++i)
1442
+ {
1443
+ seq[i] = getLong(RARRAY_PTR(arr)[i]);
1444
+ }
1445
+ os->write(&seq[0], &seq[0] + seq.size());
1446
+ break;
1447
+ }
1448
+ case PrimitiveInfo::KindFloat:
1449
+ {
1450
+ long sz = RARRAY_LEN(arr);
1451
+ Ice::FloatSeq seq(sz);
1452
+ for(long i = 0; i < sz; ++i)
1453
+ {
1454
+ volatile VALUE v = callRuby(rb_Float, RARRAY_PTR(arr)[i]);
1455
+ if(NIL_P(v))
1456
+ {
1457
+ throw RubyException(rb_eTypeError, "unable to convert array element %ld to a float", i);
1458
+ }
1459
+ assert(TYPE(v) == T_FLOAT);
1460
+ seq[i] = static_cast<Ice::Float>(RFLOAT_VALUE(v));
1461
+ }
1462
+ os->write(&seq[0], &seq[0] + seq.size());
1463
+ break;
1464
+ }
1465
+ case PrimitiveInfo::KindDouble:
1466
+ {
1467
+ long sz = RARRAY_LEN(arr);
1468
+ Ice::DoubleSeq seq(sz);
1469
+ for(long i = 0; i < sz; ++i)
1470
+ {
1471
+ volatile VALUE v = callRuby(rb_Float, RARRAY_PTR(arr)[i]);
1472
+ if(NIL_P(v))
1473
+ {
1474
+ throw RubyException(rb_eTypeError, "unable to convert array element %ld to a double", i);
1475
+ }
1476
+ assert(TYPE(v) == T_FLOAT);
1477
+ seq[i] = RFLOAT_VALUE(v);
1478
+ }
1479
+ os->write(&seq[0], &seq[0] + seq.size());
1480
+ break;
1481
+ }
1482
+ case PrimitiveInfo::KindString:
1483
+ {
1484
+ long sz = RARRAY_LEN(arr);
1485
+ Ice::StringSeq seq(sz);
1486
+ for(long i = 0; i < sz; ++i)
1487
+ {
1488
+ seq[i] = getString(RARRAY_PTR(arr)[i]);
1489
+ }
1490
+ os->write(seq, true);
1491
+ break;
1492
+ }
1493
+ }
1494
+ }
1495
+
1496
+ void
1497
+ IceRuby::SequenceInfo::unmarshalPrimitiveSequence(const PrimitiveInfoPtr& pi, const Ice::InputStreamPtr& is,
1498
+ const UnmarshalCallbackPtr& cb, VALUE target, void* closure)
1499
+ {
1500
+ volatile VALUE result = Qnil;
1501
+
1502
+ switch(pi->kind)
1503
+ {
1504
+ case PrimitiveInfo::KindBool:
1505
+ {
1506
+ pair<const bool*, const bool*> p;
1507
+ IceUtil::ScopedArray<bool> sa;
1508
+ is->read(p, sa);
1509
+ long sz = static_cast<long>(p.second - p.first);
1510
+ result = createArray(sz);
1511
+
1512
+ if(sz > 0)
1513
+ {
1514
+ for(long i = 0; i < sz; ++i)
1515
+ {
1516
+ RARRAY_PTR(result)[i] = p.first[i] ? Qtrue : Qfalse;
1517
+ }
1518
+ }
1519
+ break;
1520
+ }
1521
+ case PrimitiveInfo::KindByte:
1522
+ {
1523
+ pair<const Ice::Byte*, const Ice::Byte*> p;
1524
+ is->read(p);
1525
+ result = callRuby(rb_str_new, reinterpret_cast<const char*>(p.first), static_cast<long>(p.second - p.first));
1526
+ break;
1527
+ }
1528
+ case PrimitiveInfo::KindShort:
1529
+ {
1530
+ pair<const Ice::Short*, const Ice::Short*> p;
1531
+ IceUtil::ScopedArray<Ice::Short> sa;
1532
+ is->read(p, sa);
1533
+ long sz = static_cast<long>(p.second - p.first);
1534
+ result = createArray(sz);
1535
+
1536
+ if(sz > 0)
1537
+ {
1538
+ for(long i = 0; i < sz; ++i)
1539
+ {
1540
+ RARRAY_PTR(result)[i] = INT2FIX(p.first[i]);
1541
+ }
1542
+ }
1543
+ break;
1544
+ }
1545
+ case PrimitiveInfo::KindInt:
1546
+ {
1547
+ pair<const Ice::Int*, const Ice::Int*> p;
1548
+ IceUtil::ScopedArray<Ice::Int> sa;
1549
+ is->read(p, sa);
1550
+ long sz = static_cast<long>(p.second - p.first);
1551
+ result = createArray(sz);
1552
+
1553
+ if(sz > 0)
1554
+ {
1555
+ for(long i = 0; i < sz; ++i)
1556
+ {
1557
+ RARRAY_PTR(result)[i] = INT2FIX(p.first[i]);
1558
+ }
1559
+ }
1560
+ break;
1561
+ }
1562
+ case PrimitiveInfo::KindLong:
1563
+ {
1564
+ pair<const Ice::Long*, const Ice::Long*> p;
1565
+ IceUtil::ScopedArray<Ice::Long> sa;
1566
+ is->read(p, sa);
1567
+ long sz = static_cast<long>(p.second - p.first);
1568
+ result = createArray(sz);
1569
+
1570
+ if(sz > 0)
1571
+ {
1572
+ for(long i = 0; i < sz; ++i)
1573
+ {
1574
+ RARRAY_PTR(result)[i] = callRuby(rb_ll2inum, p.first[i]);
1575
+ }
1576
+ }
1577
+ break;
1578
+ }
1579
+ case PrimitiveInfo::KindFloat:
1580
+ {
1581
+ pair<const Ice::Float*, const Ice::Float*> p;
1582
+ IceUtil::ScopedArray<Ice::Float> sa;
1583
+ is->read(p, sa);
1584
+ long sz = static_cast<long>(p.second - p.first);
1585
+ result = createArray(sz);
1586
+
1587
+ if(sz > 0)
1588
+ {
1589
+ for(long i = 0; i < sz; ++i)
1590
+ {
1591
+ RARRAY_PTR(result)[i] = callRuby(rb_float_new, p.first[i]);
1592
+ }
1593
+ }
1594
+ break;
1595
+ }
1596
+ case PrimitiveInfo::KindDouble:
1597
+ {
1598
+ pair<const Ice::Double*, const Ice::Double*> p;
1599
+ IceUtil::ScopedArray<Ice::Double> sa;
1600
+ is->read(p, sa);
1601
+ long sz = static_cast<long>(p.second - p.first);
1602
+ result = createArray(sz);
1603
+
1604
+ if(sz > 0)
1605
+ {
1606
+ for(long i = 0; i < sz; ++i)
1607
+ {
1608
+ RARRAY_PTR(result)[i] = callRuby(rb_float_new, p.first[i]);
1609
+ }
1610
+ }
1611
+ break;
1612
+ }
1613
+ case PrimitiveInfo::KindString:
1614
+ {
1615
+ Ice::StringSeq seq;
1616
+ is->read(seq, true);
1617
+ long sz = static_cast<long>(seq.size());
1618
+ result = createArray(sz);
1619
+
1620
+ if(sz > 0)
1621
+ {
1622
+ for(long i = 0; i < sz; ++i)
1623
+ {
1624
+ RARRAY_PTR(result)[i] = createString(seq[i]);
1625
+ }
1626
+ }
1627
+ break;
1628
+ }
1629
+ }
1630
+ cb->unmarshaled(result, target, closure);
1631
+ }
1632
+
1633
+ //
1634
+ // DictionaryInfo implementation.
1635
+ //
1636
+ IceRuby::DictionaryInfo::DictionaryInfo(VALUE ident, VALUE kt, VALUE vt)
1637
+ {
1638
+ const_cast<string&>(id) = getString(ident);
1639
+ const_cast<TypeInfoPtr&>(keyType) = getType(kt);
1640
+ const_cast<TypeInfoPtr&>(valueType) = getType(vt);
1641
+
1642
+ _variableLength = keyType->variableLength() || valueType->variableLength();
1643
+ _wireSize = keyType->wireSize() + valueType->wireSize();
1644
+ }
1645
+
1646
+ string
1647
+ IceRuby::DictionaryInfo::getId() const
1648
+ {
1649
+ return id;
1650
+ }
1651
+
1652
+ bool
1653
+ IceRuby::DictionaryInfo::validate(VALUE val)
1654
+ {
1655
+ //
1656
+ // Accept nil, a hash, or any object that responds to to_hash.
1657
+ //
1658
+ if(NIL_P(val) || TYPE(val) == T_HASH)
1659
+ {
1660
+ return true;
1661
+ }
1662
+ ID id = rb_intern("to_hash");
1663
+ return callRuby(rb_respond_to, val, id) != 0;
1664
+ }
1665
+
1666
+ bool
1667
+ IceRuby::DictionaryInfo::variableLength() const
1668
+ {
1669
+ return true;
1670
+ }
1671
+
1672
+ int
1673
+ IceRuby::DictionaryInfo::wireSize() const
1674
+ {
1675
+ return 1;
1676
+ }
1677
+
1678
+ Ice::OptionalFormat
1679
+ IceRuby::DictionaryInfo::optionalFormat() const
1680
+ {
1681
+ return _variableLength ? Ice::OptionalFormatFSize : Ice::OptionalFormatVSize;
1682
+ }
1683
+
1684
+ bool
1685
+ IceRuby::DictionaryInfo::usesClasses() const
1686
+ {
1687
+ return valueType->usesClasses();
1688
+ }
1689
+
1690
+ namespace
1691
+ {
1692
+ struct DictionaryMarshalIterator : public IceRuby::HashIterator
1693
+ {
1694
+ DictionaryMarshalIterator(const IceRuby::DictionaryInfoPtr& d, const Ice::OutputStreamPtr o, IceRuby::ObjectMap* m)
1695
+ : dict(d), os(o), objectMap(m)
1696
+ {
1697
+ }
1698
+
1699
+ virtual void element(VALUE key, VALUE value)
1700
+ {
1701
+ dict->marshalElement(key, value, os, objectMap);
1702
+ }
1703
+
1704
+ IceRuby::DictionaryInfoPtr dict;
1705
+ Ice::OutputStreamPtr os;
1706
+ IceRuby::ObjectMap* objectMap;
1707
+ };
1708
+ }
1709
+
1710
+ void
1711
+ IceRuby::DictionaryInfo::marshal(VALUE p, const Ice::OutputStreamPtr& os, ObjectMap* objectMap, bool optional)
1712
+ {
1713
+ volatile VALUE hash = Qnil;
1714
+
1715
+ if(!NIL_P(p))
1716
+ {
1717
+ hash = callRuby(rb_convert_type, p, T_HASH, "Hash", "to_hash");
1718
+ if(NIL_P(hash))
1719
+ {
1720
+ throw RubyException(rb_eTypeError, "unable to convert value to a hash");
1721
+ }
1722
+ }
1723
+
1724
+ int sz = 0;
1725
+ if(!NIL_P(hash))
1726
+ {
1727
+ sz = RHASH_SIZE(hash);
1728
+ }
1729
+
1730
+ Ice::OutputStream::size_type sizePos = 0;
1731
+ if(optional)
1732
+ {
1733
+ if(_variableLength)
1734
+ {
1735
+ sizePos = os->startSize();
1736
+ }
1737
+ else
1738
+ {
1739
+ os->writeSize(sz == 0 ? 1 : sz * _wireSize + (sz > 254 ? 5 : 1));
1740
+ }
1741
+ }
1742
+
1743
+ if(NIL_P(hash))
1744
+ {
1745
+ os->writeSize(0);
1746
+ }
1747
+ else
1748
+ {
1749
+ os->writeSize(sz);
1750
+ if(sz > 0)
1751
+ {
1752
+ DictionaryMarshalIterator iter(this, os, objectMap);
1753
+ hashIterate(hash, iter);
1754
+ }
1755
+ }
1756
+
1757
+ if(optional && _variableLength)
1758
+ {
1759
+ os->endSize(sizePos);
1760
+ }
1761
+ }
1762
+
1763
+ void
1764
+ IceRuby::DictionaryInfo::marshalElement(VALUE key, VALUE value, const Ice::OutputStreamPtr& os, ObjectMap* objectMap)
1765
+ {
1766
+ if(!keyType->validate(key))
1767
+ {
1768
+ throw RubyException(rb_eTypeError, "invalid key in `%s' element", const_cast<char*>(id.c_str()));
1769
+ }
1770
+
1771
+ if(!valueType->validate(value))
1772
+ {
1773
+ throw RubyException(rb_eTypeError, "invalid value in `%s' element", const_cast<char*>(id.c_str()));
1774
+ }
1775
+
1776
+ keyType->marshal(key, os, objectMap, false);
1777
+ valueType->marshal(value, os, objectMap, false);
1778
+ }
1779
+
1780
+ void
1781
+ IceRuby::DictionaryInfo::unmarshal(const Ice::InputStreamPtr& is, const UnmarshalCallbackPtr& cb, VALUE target,
1782
+ void* closure, bool optional)
1783
+ {
1784
+ if(optional)
1785
+ {
1786
+ if(_variableLength)
1787
+ {
1788
+ is->skip(4);
1789
+ }
1790
+ else
1791
+ {
1792
+ is->skipSize();
1793
+ }
1794
+ }
1795
+
1796
+ volatile VALUE hash = callRuby(rb_hash_new);
1797
+
1798
+ KeyCallbackPtr keyCB = new KeyCallback;
1799
+ keyCB->key = Qnil;
1800
+
1801
+ Ice::Int sz = is->readSize();
1802
+ for(Ice::Int i = 0; i < sz; ++i)
1803
+ {
1804
+ //
1805
+ // A dictionary key cannot be a class (or contain one), so the key must be
1806
+ // available immediately.
1807
+ //
1808
+ keyType->unmarshal(is, keyCB, Qnil, 0, false);
1809
+ assert(!NIL_P(keyCB->key));
1810
+
1811
+ //
1812
+ // The callback will set the dictionary entry with the unmarshaled value,
1813
+ // so we pass it the key.
1814
+ //
1815
+ void* cl = reinterpret_cast<void*>(keyCB->key);
1816
+ valueType->unmarshal(is, this, hash, cl, false);
1817
+ }
1818
+
1819
+ cb->unmarshaled(hash, target, closure);
1820
+ }
1821
+
1822
+ void
1823
+ IceRuby::DictionaryInfo::unmarshaled(VALUE val, VALUE target, void* closure)
1824
+ {
1825
+ volatile VALUE key = reinterpret_cast<VALUE>(closure);
1826
+ callRuby(rb_hash_aset, target, key, val);
1827
+ }
1828
+
1829
+ namespace
1830
+ {
1831
+ struct DictionaryPrintIterator : public IceRuby::HashIterator
1832
+ {
1833
+ DictionaryPrintIterator(const DictionaryInfoPtr& d, IceUtilInternal::Output& o, PrintObjectHistory* h) :
1834
+ dict(d), out(o), history(h)
1835
+ {
1836
+ }
1837
+
1838
+ virtual void element(VALUE key, VALUE value)
1839
+ {
1840
+ dict->printElement(key, value, out, history);
1841
+ }
1842
+
1843
+ IceRuby::DictionaryInfoPtr dict;
1844
+ IceUtilInternal::Output& out;
1845
+ IceRuby::PrintObjectHistory* history;
1846
+ };
1847
+ }
1848
+
1849
+ void
1850
+ IceRuby::DictionaryInfo::print(VALUE value, IceUtilInternal::Output& out, PrintObjectHistory* history)
1851
+ {
1852
+ if(!validate(value))
1853
+ {
1854
+ out << "<invalid value - expected " << id << ">";
1855
+ return;
1856
+ }
1857
+
1858
+ if(NIL_P(value))
1859
+ {
1860
+ out << "{}";
1861
+ }
1862
+ else
1863
+ {
1864
+ volatile VALUE hash = callRuby(rb_convert_type, value, T_HASH, "Hash", "to_hash");
1865
+ if(NIL_P(hash))
1866
+ {
1867
+ throw RubyException(rb_eTypeError, "unable to convert value to a hash");
1868
+ }
1869
+
1870
+ if(RHASH_SIZE(hash) == 0)
1871
+ {
1872
+ out << "{}";
1873
+ return;
1874
+ }
1875
+
1876
+ out.sb();
1877
+ DictionaryPrintIterator iter(this, out, history);
1878
+ hashIterate(hash, iter);
1879
+ out.eb();
1880
+ }
1881
+ }
1882
+
1883
+ void
1884
+ IceRuby::DictionaryInfo::printElement(VALUE key, VALUE value, IceUtilInternal::Output& out, PrintObjectHistory* history)
1885
+ {
1886
+ out << nl << "key = ";
1887
+ keyType->print(key, out, history);
1888
+ out << nl << "value = ";
1889
+ valueType->print(value, out, history);
1890
+ }
1891
+
1892
+ void
1893
+ IceRuby::DictionaryInfo::KeyCallback::unmarshaled(VALUE val, VALUE, void*)
1894
+ {
1895
+ key = val;
1896
+ }
1897
+
1898
+ void
1899
+ IceRuby::DictionaryInfo::destroy()
1900
+ {
1901
+ if(keyType)
1902
+ {
1903
+ keyType->destroy();
1904
+ const_cast<TypeInfoPtr&>(keyType) = 0;
1905
+ }
1906
+ if(valueType)
1907
+ {
1908
+ valueType->destroy();
1909
+ const_cast<TypeInfoPtr&>(valueType) = 0;
1910
+ }
1911
+ }
1912
+
1913
+ //
1914
+ // ClassInfo implementation.
1915
+ //
1916
+ IceRuby::ClassInfo::ClassInfo(VALUE ident, bool loc) :
1917
+ compactId(-1), isBase(false), isLocal(loc), isAbstract(false), preserve(false), rubyClass(Qnil), typeObj(Qnil),
1918
+ defined(false)
1919
+ {
1920
+ const_cast<string&>(id) = getString(ident);
1921
+ if(isLocal)
1922
+ {
1923
+ const_cast<bool&>(isBase) = id == "::Ice::LocalObject";
1924
+ }
1925
+ else
1926
+ {
1927
+ const_cast<bool&>(isBase) = id == Ice::Object::ice_staticId();
1928
+ }
1929
+ const_cast<VALUE&>(typeObj) = createType(this);
1930
+ }
1931
+
1932
+ void
1933
+ IceRuby::ClassInfo::define(VALUE t, VALUE compact, VALUE abstr, VALUE pres, VALUE b, VALUE i, VALUE m)
1934
+ {
1935
+ if(!NIL_P(b))
1936
+ {
1937
+ const_cast<ClassInfoPtr&>(base) = ClassInfoPtr::dynamicCast(getType(b));
1938
+ assert(base);
1939
+ }
1940
+
1941
+ const_cast<Ice::Int&>(compactId) = static_cast<Ice::Int>(getInteger(compact));
1942
+ const_cast<bool&>(isAbstract) = RTEST(abstr);
1943
+ const_cast<bool&>(preserve) = RTEST(pres);
1944
+
1945
+ long n;
1946
+ volatile VALUE arr;
1947
+
1948
+ arr = callRuby(rb_check_array_type, i);
1949
+ assert(!NIL_P(arr));
1950
+ for(n = 0; n < RARRAY_LEN(arr); ++n)
1951
+ {
1952
+ ClassInfoPtr iface = ClassInfoPtr::dynamicCast(getType(RARRAY_PTR(arr)[n]));
1953
+ assert(iface);
1954
+ const_cast<ClassInfoList&>(interfaces).push_back(iface);
1955
+ }
1956
+
1957
+ convertDataMembers(m, const_cast<DataMemberList&>(members), const_cast<DataMemberList&>(optionalMembers), true);
1958
+
1959
+ const_cast<VALUE&>(rubyClass) = t;
1960
+ const_cast<bool&>(defined) = true;
1961
+ }
1962
+
1963
+ string
1964
+ IceRuby::ClassInfo::getId() const
1965
+ {
1966
+ return id;
1967
+ }
1968
+
1969
+ bool
1970
+ IceRuby::ClassInfo::validate(VALUE val)
1971
+ {
1972
+ if(NIL_P(val))
1973
+ {
1974
+ return true;
1975
+ }
1976
+
1977
+ //
1978
+ // We consider an object to be an instance of this class if its class contains
1979
+ // an ICE_TYPE constant that refers to this class, or a subclass of this class.
1980
+ //
1981
+ volatile VALUE cls = CLASS_OF(val);
1982
+ volatile VALUE type = Qnil;
1983
+ try
1984
+ {
1985
+ type = callRuby(rb_const_get, cls, rb_intern("ICE_TYPE"));
1986
+ }
1987
+ catch(const RubyException& ex)
1988
+ {
1989
+ if(callRuby(rb_obj_is_instance_of, ex.ex, rb_eNameError) == Qtrue)
1990
+ {
1991
+ //
1992
+ // The ICE_TYPE constant will be missing from an instance of LocalObject
1993
+ // if it does not implement a user-defined type. This means the user
1994
+ // could potentially pass any kind of object; there isn't much we can do
1995
+ // since LocalObject maps to the base object type.
1996
+ //
1997
+ return id == "::Ice::LocalObject";
1998
+ }
1999
+ else
2000
+ {
2001
+ throw;
2002
+ }
2003
+ }
2004
+ assert(!NIL_P(type));
2005
+ ClassInfoPtr info = ClassInfoPtr::dynamicCast(getType(type));
2006
+ assert(info);
2007
+ return info->isA(this);
2008
+ }
2009
+
2010
+ bool
2011
+ IceRuby::ClassInfo::variableLength() const
2012
+ {
2013
+ return true;
2014
+ }
2015
+
2016
+ int
2017
+ IceRuby::ClassInfo::wireSize() const
2018
+ {
2019
+ return 1;
2020
+ }
2021
+
2022
+ Ice::OptionalFormat
2023
+ IceRuby::ClassInfo::optionalFormat() const
2024
+ {
2025
+ return Ice::OptionalFormatClass;
2026
+ }
2027
+
2028
+ bool
2029
+ IceRuby::ClassInfo::usesClasses() const
2030
+ {
2031
+ return true;
2032
+ }
2033
+
2034
+ void
2035
+ IceRuby::ClassInfo::marshal(VALUE p, const Ice::OutputStreamPtr& os, ObjectMap* objectMap, bool)
2036
+ {
2037
+ if(!defined)
2038
+ {
2039
+ throw RubyException(rb_eRuntimeError, "class %s is declared but not defined", id.c_str());
2040
+ }
2041
+
2042
+ if(NIL_P(p))
2043
+ {
2044
+ os->writeObject(0);
2045
+ return;
2046
+ }
2047
+
2048
+ //
2049
+ // Ice::ObjectWriter is a subclass of Ice::Object that wraps a Ruby object for marshaling.
2050
+ // It is possible that this Ruby object has already been marshaled, therefore we first must
2051
+ // check the object map to see if this object is present. If so, we use the existing ObjectWriter,
2052
+ // otherwise we create a new one.
2053
+ //
2054
+ Ice::ObjectPtr writer;
2055
+ assert(objectMap);
2056
+ ObjectMap::iterator q = objectMap->find(p);
2057
+ if(q == objectMap->end())
2058
+ {
2059
+ writer = new ObjectWriter(p, objectMap);
2060
+ objectMap->insert(ObjectMap::value_type(p, writer));
2061
+ }
2062
+ else
2063
+ {
2064
+ writer = q->second;
2065
+ }
2066
+
2067
+ //
2068
+ // Give the writer to the stream. The stream will eventually call write() on it.
2069
+ //
2070
+ os->writeObject(writer);
2071
+ }
2072
+
2073
+ void
2074
+ IceRuby::ClassInfo::unmarshal(const Ice::InputStreamPtr& is, const UnmarshalCallbackPtr& cb, VALUE target,
2075
+ void* closure, bool)
2076
+ {
2077
+ if(!defined)
2078
+ {
2079
+ throw RubyException(rb_eRuntimeError, "class %s is declared but not defined", id.c_str());
2080
+ }
2081
+
2082
+ is->readObject(new ReadObjectCallback(this, cb, target, closure));
2083
+ }
2084
+
2085
+ void
2086
+ IceRuby::ClassInfo::print(VALUE value, IceUtilInternal::Output& out, PrintObjectHistory* history)
2087
+ {
2088
+ if(!validate(value))
2089
+ {
2090
+ out << "<invalid value - expected " << id << ">";
2091
+ return;
2092
+ }
2093
+
2094
+ if(NIL_P(value))
2095
+ {
2096
+ out << "<nil>";
2097
+ }
2098
+ else
2099
+ {
2100
+ map<VALUE, int>::iterator q = history->objects.find(value);
2101
+ if(q != history->objects.end())
2102
+ {
2103
+ out << "<object #" << q->second << ">";
2104
+ }
2105
+ else
2106
+ {
2107
+ volatile VALUE cls = CLASS_OF(value);
2108
+ volatile VALUE type = Qnil;
2109
+ ClassInfoPtr info;
2110
+ try
2111
+ {
2112
+ type = callRuby(rb_const_get, cls, rb_intern("ICE_TYPE"));
2113
+ info = ClassInfoPtr::dynamicCast(getType(type));
2114
+ }
2115
+ catch(const RubyException& ex)
2116
+ {
2117
+ if(callRuby(rb_obj_is_instance_of, ex.ex, rb_eNameError) == Qtrue)
2118
+ {
2119
+ //
2120
+ // The ICE_TYPE constant will be missing from an instance of LocalObject
2121
+ // if it does not implement a user-defined type. This means the user
2122
+ // could potentially pass any kind of object; there isn't much we can do
2123
+ // since LocalObject maps to the base object type.
2124
+ //
2125
+ if(id == "::Ice::LocalObject")
2126
+ {
2127
+ info = this;
2128
+ }
2129
+ else
2130
+ {
2131
+ out << "<invalid value - expected " << id << ">";
2132
+ return;
2133
+ }
2134
+ }
2135
+ else
2136
+ {
2137
+ throw;
2138
+ }
2139
+ }
2140
+ assert(info);
2141
+ out << "object #" << history->index << " (" << info->id << ')';
2142
+ history->objects.insert(map<VALUE, int>::value_type(value, history->index));
2143
+ ++history->index;
2144
+ out.sb();
2145
+ info->printMembers(value, out, history);
2146
+ out.eb();
2147
+ }
2148
+ }
2149
+ }
2150
+
2151
+ void
2152
+ IceRuby::ClassInfo::destroy()
2153
+ {
2154
+ const_cast<ClassInfoPtr&>(base) = 0;
2155
+ const_cast<ClassInfoList&>(interfaces).clear();
2156
+ if(!members.empty())
2157
+ {
2158
+ DataMemberList ml = members;
2159
+ const_cast<DataMemberList&>(members).clear();
2160
+ for(DataMemberList::iterator p = ml.begin(); p != ml.end(); ++p)
2161
+ {
2162
+ (*p)->type->destroy();
2163
+ }
2164
+ }
2165
+ }
2166
+
2167
+ void
2168
+ IceRuby::ClassInfo::printMembers(VALUE value, IceUtilInternal::Output& out, PrintObjectHistory* history)
2169
+ {
2170
+ if(base)
2171
+ {
2172
+ base->printMembers(value, out, history);
2173
+ }
2174
+
2175
+ DataMemberList::const_iterator q;
2176
+
2177
+ for(q = members.begin(); q != members.end(); ++q)
2178
+ {
2179
+ DataMemberPtr member = *q;
2180
+ out << nl << member->name << " = ";
2181
+ if(callRuby(rb_ivar_defined, value, member->rubyID) == Qfalse)
2182
+ {
2183
+ out << "<not defined>";
2184
+ }
2185
+ else
2186
+ {
2187
+ volatile VALUE val = callRuby(rb_ivar_get, value, member->rubyID);
2188
+ member->type->print(val, out, history);
2189
+ }
2190
+ }
2191
+
2192
+ for(q = optionalMembers.begin(); q != optionalMembers.end(); ++q)
2193
+ {
2194
+ DataMemberPtr member = *q;
2195
+ out << nl << member->name << " = ";
2196
+ if(callRuby(rb_ivar_defined, value, member->rubyID) == Qfalse)
2197
+ {
2198
+ out << "<not defined>";
2199
+ }
2200
+ else
2201
+ {
2202
+ volatile VALUE val = callRuby(rb_ivar_get, value, member->rubyID);
2203
+ if(val == Unset)
2204
+ {
2205
+ out << "<unset>";
2206
+ }
2207
+ else
2208
+ {
2209
+ member->type->print(val, out, history);
2210
+ }
2211
+ }
2212
+ }
2213
+ }
2214
+
2215
+ bool
2216
+ IceRuby::ClassInfo::isA(const ClassInfoPtr& info)
2217
+ {
2218
+ //
2219
+ // Return true if this class has an is-a relationship with info.
2220
+ //
2221
+ if(info->isBase && isLocal == info->isLocal)
2222
+ {
2223
+ return true;
2224
+ }
2225
+ else if(this == info.get())
2226
+ {
2227
+ return true;
2228
+ }
2229
+ else if(base && base->isA(info))
2230
+ {
2231
+ return true;
2232
+ }
2233
+ else if(!interfaces.empty())
2234
+ {
2235
+ for(ClassInfoList::const_iterator p = interfaces.begin(); p != interfaces.end(); ++p)
2236
+ {
2237
+ if((*p)->isA(info))
2238
+ {
2239
+ return true;
2240
+ }
2241
+ }
2242
+ }
2243
+
2244
+ return false;
2245
+ }
2246
+
2247
+ //
2248
+ // ProxyInfo implementation.
2249
+ //
2250
+ IceRuby::ProxyInfo::ProxyInfo(VALUE ident) :
2251
+ rubyClass(Qnil), typeObj(Qnil)
2252
+ {
2253
+ const_cast<string&>(id) = getString(ident);
2254
+ const_cast<VALUE&>(typeObj) = createType(this);
2255
+ }
2256
+
2257
+ void
2258
+ IceRuby::ProxyInfo::define(VALUE t, VALUE i)
2259
+ {
2260
+ const_cast<VALUE&>(rubyClass) = t;
2261
+ const_cast<ClassInfoPtr&>(classInfo) = ClassInfoPtr::dynamicCast(getType(i));
2262
+ assert(classInfo);
2263
+ }
2264
+
2265
+ string
2266
+ IceRuby::ProxyInfo::getId() const
2267
+ {
2268
+ return id;
2269
+ }
2270
+
2271
+ bool
2272
+ IceRuby::ProxyInfo::validate(VALUE val)
2273
+ {
2274
+ if(!NIL_P(val))
2275
+ {
2276
+ if(!checkProxy(val))
2277
+ {
2278
+ return false;
2279
+ }
2280
+ volatile VALUE cls = CLASS_OF(val);
2281
+ volatile VALUE type = callRuby(rb_const_get, cls, rb_intern("ICE_TYPE"));
2282
+ assert(!NIL_P(type));
2283
+ ProxyInfoPtr info = ProxyInfoPtr::dynamicCast(getType(type));
2284
+ assert(info);
2285
+ return info->classInfo->isA(classInfo);
2286
+ }
2287
+ return true;
2288
+ }
2289
+
2290
+ bool
2291
+ IceRuby::ProxyInfo::variableLength() const
2292
+ {
2293
+ return true;
2294
+ }
2295
+
2296
+ int
2297
+ IceRuby::ProxyInfo::wireSize() const
2298
+ {
2299
+ return 1;
2300
+ }
2301
+
2302
+ Ice::OptionalFormat
2303
+ IceRuby::ProxyInfo::optionalFormat() const
2304
+ {
2305
+ return Ice::OptionalFormatFSize;
2306
+ }
2307
+
2308
+ void
2309
+ IceRuby::ProxyInfo::marshal(VALUE p, const Ice::OutputStreamPtr& os, ObjectMap*, bool optional)
2310
+ {
2311
+ Ice::OutputStream::size_type sizePos = -1;
2312
+ if(optional)
2313
+ {
2314
+ sizePos = os->startSize();
2315
+ }
2316
+
2317
+ if(NIL_P(p))
2318
+ {
2319
+ os->write(Ice::ObjectPrx());
2320
+ }
2321
+ else
2322
+ {
2323
+ assert(checkProxy(p)); // validate() should have caught this.
2324
+ os->write(getProxy(p));
2325
+ }
2326
+
2327
+ if(optional)
2328
+ {
2329
+ os->endSize(sizePos);
2330
+ }
2331
+ }
2332
+
2333
+ void
2334
+ IceRuby::ProxyInfo::unmarshal(const Ice::InputStreamPtr& is, const UnmarshalCallbackPtr& cb, VALUE target,
2335
+ void* closure, bool optional)
2336
+ {
2337
+ if(optional)
2338
+ {
2339
+ is->skip(4);
2340
+ }
2341
+
2342
+ Ice::ObjectPrx proxy;
2343
+ is->read(proxy);
2344
+
2345
+ if(!proxy)
2346
+ {
2347
+ cb->unmarshaled(Qnil, target, closure);
2348
+ return;
2349
+ }
2350
+
2351
+ if(NIL_P(rubyClass))
2352
+ {
2353
+ throw RubyException(rb_eRuntimeError, "class %s is declared but not defined", id.c_str());
2354
+ }
2355
+
2356
+ volatile VALUE p = createProxy(proxy, rubyClass);
2357
+ cb->unmarshaled(p, target, closure);
2358
+ }
2359
+
2360
+ void
2361
+ IceRuby::ProxyInfo::print(VALUE value, IceUtilInternal::Output& out, PrintObjectHistory*)
2362
+ {
2363
+ if(!validate(value))
2364
+ {
2365
+ out << "<invalid value - expected " << getId() << ">";
2366
+ return;
2367
+ }
2368
+
2369
+ if(NIL_P(value))
2370
+ {
2371
+ out << "<nil>";
2372
+ }
2373
+ else
2374
+ {
2375
+ out << getString(value);
2376
+ }
2377
+ }
2378
+
2379
+ void
2380
+ IceRuby::ProxyInfo::destroy()
2381
+ {
2382
+ const_cast<ClassInfoPtr&>(classInfo) = 0;
2383
+ }
2384
+
2385
+ //
2386
+ // ObjectWriter implementation.
2387
+ //
2388
+ IceRuby::ObjectWriter::ObjectWriter(VALUE object, ObjectMap* objectMap) :
2389
+ _object(object), _map(objectMap)
2390
+ {
2391
+ volatile VALUE cls = CLASS_OF(object);
2392
+ volatile VALUE type = callRuby(rb_const_get, cls, rb_intern("ICE_TYPE"));
2393
+ assert(!NIL_P(type));
2394
+ _info = ClassInfoPtr::dynamicCast(getType(type));
2395
+ assert(_info);
2396
+ }
2397
+
2398
+ void
2399
+ IceRuby::ObjectWriter::ice_preMarshal()
2400
+ {
2401
+ ID id = rb_intern("ice_preMarshal");
2402
+ if(callRuby(rb_respond_to, _object, id))
2403
+ {
2404
+ callRuby(rb_funcall, _object, id, 0);
2405
+ }
2406
+ }
2407
+
2408
+ void
2409
+ IceRuby::ObjectWriter::write(const Ice::OutputStreamPtr& os) const
2410
+ {
2411
+ Ice::SlicedDataPtr slicedData;
2412
+
2413
+ if(_info->preserve)
2414
+ {
2415
+ //
2416
+ // Retrieve the SlicedData object that we stored as a hidden member of the Ruby object.
2417
+ //
2418
+ slicedData = SlicedDataUtil::getMember(_object, const_cast<ObjectMap*>(_map));
2419
+ }
2420
+
2421
+ os->startObject(slicedData);
2422
+
2423
+ if(_info->id != "::Ice::UnknownSlicedObject")
2424
+ {
2425
+ ClassInfoPtr info = _info;
2426
+ while(info)
2427
+ {
2428
+ os->startSlice(info->id, info->compactId, !info->base);
2429
+
2430
+ writeMembers(os, info->members);
2431
+ writeMembers(os, info->optionalMembers); // The optional members have already been sorted by tag.
2432
+
2433
+ os->endSlice();
2434
+
2435
+ info = info->base;
2436
+ }
2437
+ }
2438
+
2439
+ os->endObject();
2440
+ }
2441
+
2442
+ void
2443
+ IceRuby::ObjectWriter::writeMembers(const Ice::OutputStreamPtr& os, const DataMemberList& members) const
2444
+ {
2445
+ for(DataMemberList::const_iterator q = members.begin(); q != members.end(); ++q)
2446
+ {
2447
+ DataMemberPtr member = *q;
2448
+
2449
+ volatile VALUE val = callRuby(rb_ivar_get, _object, member->rubyID);
2450
+
2451
+ if(member->optional && (val == Unset || !os->writeOptional(member->tag, member->type->optionalFormat())))
2452
+ {
2453
+ continue;
2454
+ }
2455
+
2456
+ if(!member->type->validate(val))
2457
+ {
2458
+ throw RubyException(rb_eTypeError, "invalid value for %s member `%s'", _info->id.c_str(),
2459
+ member->name.c_str());
2460
+ }
2461
+
2462
+ member->type->marshal(val, os, _map, member->optional);
2463
+ }
2464
+ }
2465
+
2466
+ //
2467
+ // ObjectReader implementation.
2468
+ //
2469
+ IceRuby::ObjectReader::ObjectReader(VALUE object, const ClassInfoPtr& info) :
2470
+ _object(object), _info(info)
2471
+ {
2472
+ }
2473
+
2474
+ void
2475
+ IceRuby::ObjectReader::ice_postUnmarshal()
2476
+ {
2477
+ ID id = rb_intern("ice_postUnmarshal");
2478
+ if(callRuby(rb_respond_to, _object, id))
2479
+ {
2480
+ callRuby(rb_funcall, _object, id, 0);
2481
+ }
2482
+ }
2483
+
2484
+ void
2485
+ IceRuby::ObjectReader::read(const Ice::InputStreamPtr& is)
2486
+ {
2487
+ is->startObject();
2488
+
2489
+ const bool unknown = _info->id == "::Ice::UnknownSlicedObject";
2490
+
2491
+ //
2492
+ // Unmarshal the slices of a user-defined class.
2493
+ //
2494
+ if(!unknown && _info->id != Ice::Object::ice_staticId())
2495
+ {
2496
+ ClassInfoPtr info = _info;
2497
+ while(info)
2498
+ {
2499
+ is->startSlice();
2500
+
2501
+ DataMemberList::const_iterator p;
2502
+
2503
+ for(p = info->members.begin(); p != info->members.end(); ++p)
2504
+ {
2505
+ DataMemberPtr member = *p;
2506
+ member->type->unmarshal(is, member, _object, 0, false);
2507
+ }
2508
+
2509
+ //
2510
+ // The optional members have already been sorted by tag.
2511
+ //
2512
+ for(p = info->optionalMembers.begin(); p != info->optionalMembers.end(); ++p)
2513
+ {
2514
+ DataMemberPtr member = *p;
2515
+ if(is->readOptional(member->tag, member->type->optionalFormat()))
2516
+ {
2517
+ member->type->unmarshal(is, member, _object, 0, true);
2518
+ }
2519
+ else
2520
+ {
2521
+ callRuby(rb_ivar_set, _object, member->rubyID, Unset);
2522
+ }
2523
+ }
2524
+
2525
+ is->endSlice();
2526
+
2527
+ info = info->base;
2528
+ }
2529
+ }
2530
+
2531
+ _slicedData = is->endObject(_info->preserve);
2532
+
2533
+ if(_slicedData)
2534
+ {
2535
+ SlicedDataUtil* util = reinterpret_cast<SlicedDataUtil*>(is->closure());
2536
+ assert(util);
2537
+ util->add(this);
2538
+
2539
+ //
2540
+ // Define the "unknownTypeId" member for an instance of UnknownSlicedObject.
2541
+ //
2542
+ if(unknown)
2543
+ {
2544
+ assert(!_slicedData->slices.empty());
2545
+
2546
+ volatile VALUE typeId = createString(_slicedData->slices[0]->typeId);
2547
+ callRuby(rb_iv_set, _object, "@unknownTypeId", typeId);
2548
+ }
2549
+ }
2550
+ }
2551
+
2552
+ ClassInfoPtr
2553
+ IceRuby::ObjectReader::getInfo() const
2554
+ {
2555
+ return _info;
2556
+ }
2557
+
2558
+ VALUE
2559
+ IceRuby::ObjectReader::getObject() const
2560
+ {
2561
+ return _object;
2562
+ }
2563
+
2564
+ Ice::SlicedDataPtr
2565
+ IceRuby::ObjectReader::getSlicedData() const
2566
+ {
2567
+ return _slicedData;
2568
+ }
2569
+
2570
+ //
2571
+ // InfoMapDestroyer implementation.
2572
+ //
2573
+ IceRuby::InfoMapDestroyer::~InfoMapDestroyer()
2574
+ {
2575
+ {
2576
+ for(ProxyInfoMap::iterator p = _proxyInfoMap.begin(); p != _proxyInfoMap.end(); ++p)
2577
+ {
2578
+ p->second->destroy();
2579
+ }
2580
+ }
2581
+ {
2582
+ for(ClassInfoMap::iterator p = _classInfoMap.begin(); p != _classInfoMap.end(); ++p)
2583
+ {
2584
+ p->second->destroy();
2585
+ }
2586
+ }
2587
+ _compactIdMap.clear();
2588
+ _exceptionInfoMap.clear();
2589
+ }
2590
+
2591
+ //
2592
+ // ReadObjectCallback implementation.
2593
+ //
2594
+ IceRuby::ReadObjectCallback::ReadObjectCallback(const ClassInfoPtr& info, const UnmarshalCallbackPtr& cb,
2595
+ VALUE target, void* closure) :
2596
+ _info(info), _cb(cb), _target(target), _closure(closure)
2597
+ {
2598
+ }
2599
+
2600
+ void
2601
+ IceRuby::ReadObjectCallback::invoke(const Ice::ObjectPtr& p)
2602
+ {
2603
+ if(p)
2604
+ {
2605
+ ObjectReaderPtr reader = ObjectReaderPtr::dynamicCast(p);
2606
+ assert(reader);
2607
+
2608
+ //
2609
+ // Verify that the unmarshaled object is compatible with the formal type.
2610
+ //
2611
+ volatile VALUE obj = reader->getObject();
2612
+ if(!_info->validate(obj))
2613
+ {
2614
+ Ice::UnexpectedObjectException ex(__FILE__, __LINE__);
2615
+ ex.reason = "unmarshaled object is not an instance of " + _info->id;
2616
+ ex.type = reader->getInfo()->getId();
2617
+ ex.expectedType = _info->id;
2618
+ throw ex;
2619
+ }
2620
+
2621
+ _cb->unmarshaled(obj, _target, _closure);
2622
+ }
2623
+ else
2624
+ {
2625
+ _cb->unmarshaled(Qnil, _target, _closure);
2626
+ }
2627
+ }
2628
+
2629
+ //
2630
+ // ExceptionInfo implementation.
2631
+ //
2632
+ VALUE
2633
+ IceRuby::ExceptionInfo::unmarshal(const Ice::InputStreamPtr& is)
2634
+ {
2635
+ volatile VALUE obj = callRuby(rb_class_new_instance, 0, static_cast<VALUE*>(0), rubyClass);
2636
+
2637
+ ExceptionInfoPtr info = this;
2638
+ while(info)
2639
+ {
2640
+ is->startSlice();
2641
+
2642
+ DataMemberList::iterator q;
2643
+
2644
+ for(q = info->members.begin(); q != info->members.end(); ++q)
2645
+ {
2646
+ DataMemberPtr member = *q;
2647
+ member->type->unmarshal(is, member, obj, 0, false);
2648
+ }
2649
+
2650
+ //
2651
+ // The optional members have already been sorted by tag.
2652
+ //
2653
+ for(q = info->optionalMembers.begin(); q != info->optionalMembers.end(); ++q)
2654
+ {
2655
+ DataMemberPtr member = *q;
2656
+ if(is->readOptional(member->tag, member->type->optionalFormat()))
2657
+ {
2658
+ member->type->unmarshal(is, member, obj, 0, true);
2659
+ }
2660
+ else
2661
+ {
2662
+ callRuby(rb_ivar_set, obj, member->rubyID, Unset);
2663
+ }
2664
+ }
2665
+
2666
+ is->endSlice();
2667
+
2668
+ info = info->base;
2669
+ }
2670
+
2671
+ return obj;
2672
+ }
2673
+
2674
+ void
2675
+ IceRuby::ExceptionInfo::print(VALUE value, IceUtilInternal::Output& out)
2676
+ {
2677
+ if(callRuby(rb_obj_is_kind_of, value, rubyClass) == Qfalse)
2678
+ {
2679
+ out << "<invalid value - expected " << id << ">";
2680
+ return;
2681
+ }
2682
+
2683
+ PrintObjectHistory history;
2684
+ history.index = 0;
2685
+
2686
+ out << "exception " << id;
2687
+ out.sb();
2688
+ printMembers(value, out, &history);
2689
+ out.eb();
2690
+ }
2691
+
2692
+ void
2693
+ IceRuby::ExceptionInfo::printMembers(VALUE value, IceUtilInternal::Output& out, PrintObjectHistory* history)
2694
+ {
2695
+ if(base)
2696
+ {
2697
+ base->printMembers(value, out, history);
2698
+ }
2699
+
2700
+ DataMemberList::const_iterator q;
2701
+
2702
+ for(q = members.begin(); q != members.end(); ++q)
2703
+ {
2704
+ DataMemberPtr member = *q;
2705
+ out << nl << member->name << " = ";
2706
+ if(callRuby(rb_ivar_defined, value, member->rubyID) == Qfalse)
2707
+ {
2708
+ out << "<not defined>";
2709
+ }
2710
+ else
2711
+ {
2712
+ volatile VALUE val = callRuby(rb_ivar_get, value, member->rubyID);
2713
+ member->type->print(val, out, history);
2714
+ }
2715
+ }
2716
+
2717
+ for(q = optionalMembers.begin(); q != optionalMembers.end(); ++q)
2718
+ {
2719
+ DataMemberPtr member = *q;
2720
+ out << nl << member->name << " = ";
2721
+ if(callRuby(rb_ivar_defined, value, member->rubyID) == Qfalse)
2722
+ {
2723
+ out << "<not defined>";
2724
+ }
2725
+ else
2726
+ {
2727
+ volatile VALUE val = callRuby(rb_ivar_get, value, member->rubyID);
2728
+ if(val == Unset)
2729
+ {
2730
+ out << "<unset>";
2731
+ }
2732
+ else
2733
+ {
2734
+ member->type->print(val, out, history);
2735
+ }
2736
+ }
2737
+ }
2738
+ }
2739
+
2740
+ //
2741
+ // ExceptionReader implementation.
2742
+ //
2743
+ IceRuby::ExceptionReader::ExceptionReader(const Ice::CommunicatorPtr& communicator, const ExceptionInfoPtr& info) :
2744
+ Ice::UserExceptionReader(communicator), _info(info)
2745
+ {
2746
+ }
2747
+
2748
+ IceRuby::ExceptionReader::~ExceptionReader()
2749
+ throw()
2750
+ {
2751
+ }
2752
+
2753
+ void
2754
+ IceRuby::ExceptionReader::read(const Ice::InputStreamPtr& is) const
2755
+ {
2756
+ is->startException();
2757
+
2758
+ const_cast<VALUE&>(_ex) = _info->unmarshal(is);
2759
+
2760
+ const_cast<Ice::SlicedDataPtr&>(_slicedData) = is->endException(_info->preserve);
2761
+ }
2762
+
2763
+ bool
2764
+ IceRuby::ExceptionReader::usesClasses() const
2765
+ {
2766
+ return _info->usesClasses;
2767
+ }
2768
+
2769
+ string
2770
+ IceRuby::ExceptionReader::ice_name() const
2771
+ {
2772
+ return _info->id;
2773
+ }
2774
+
2775
+ Ice::UserException*
2776
+ IceRuby::ExceptionReader::ice_clone() const
2777
+ {
2778
+ assert(false);
2779
+ return 0;
2780
+ }
2781
+
2782
+ void
2783
+ IceRuby::ExceptionReader::ice_throw() const
2784
+ {
2785
+ throw *this;
2786
+ }
2787
+
2788
+ VALUE
2789
+ IceRuby::ExceptionReader::getException() const
2790
+ {
2791
+ return _ex;
2792
+ }
2793
+
2794
+ Ice::SlicedDataPtr
2795
+ IceRuby::ExceptionReader::getSlicedData() const
2796
+ {
2797
+ return _slicedData;
2798
+ }
2799
+
2800
+ //
2801
+ // IdResolver
2802
+ //
2803
+ string
2804
+ IceRuby::IdResolver::resolve(Ice::Int id) const
2805
+ {
2806
+ CompactIdMap::iterator p = _compactIdMap.find(id);
2807
+ if(p != _compactIdMap.end())
2808
+ {
2809
+ return p->second->id;
2810
+ }
2811
+ return string();
2812
+ }
2813
+
2814
+ extern "C"
2815
+ VALUE
2816
+ IceRuby_defineEnum(VALUE /*self*/, VALUE id, VALUE type, VALUE enumerators)
2817
+ {
2818
+ ICE_RUBY_TRY
2819
+ {
2820
+ EnumInfoPtr info = new EnumInfo(id, type, enumerators);
2821
+ return createType(info);
2822
+ }
2823
+ ICE_RUBY_CATCH
2824
+ return Qnil;
2825
+ }
2826
+
2827
+ extern "C"
2828
+ VALUE
2829
+ IceRuby_defineStruct(VALUE /*self*/, VALUE id, VALUE type, VALUE members)
2830
+ {
2831
+ ICE_RUBY_TRY
2832
+ {
2833
+ StructInfoPtr info = new StructInfo(id, type, members);
2834
+ return createType(info);
2835
+ }
2836
+ ICE_RUBY_CATCH
2837
+ return Qnil;
2838
+ }
2839
+
2840
+ extern "C"
2841
+ VALUE
2842
+ IceRuby_defineSequence(VALUE /*self*/, VALUE id, VALUE elementType)
2843
+ {
2844
+ ICE_RUBY_TRY
2845
+ {
2846
+ SequenceInfoPtr info = new SequenceInfo(id, elementType);
2847
+ return createType(info);
2848
+ }
2849
+ ICE_RUBY_CATCH
2850
+ return Qnil;
2851
+ }
2852
+
2853
+ extern "C"
2854
+ VALUE
2855
+ IceRuby_defineDictionary(VALUE /*self*/, VALUE id, VALUE keyType, VALUE valueType)
2856
+ {
2857
+ ICE_RUBY_TRY
2858
+ {
2859
+ DictionaryInfoPtr info = new DictionaryInfo(id, keyType, valueType);
2860
+ return createType(info);
2861
+ }
2862
+ ICE_RUBY_CATCH
2863
+ return Qnil;
2864
+ }
2865
+
2866
+ extern "C"
2867
+ VALUE
2868
+ IceRuby_declareProxy(VALUE /*self*/, VALUE id)
2869
+ {
2870
+ ICE_RUBY_TRY
2871
+ {
2872
+ string proxyId = getString(id);
2873
+ proxyId += "Prx";
2874
+
2875
+ ProxyInfoPtr info = lookupProxyInfo(proxyId);
2876
+ if(!info)
2877
+ {
2878
+ info = new ProxyInfo(id);
2879
+ addProxyInfo(proxyId, info);
2880
+ }
2881
+
2882
+ return info->typeObj;
2883
+ }
2884
+ ICE_RUBY_CATCH
2885
+ return Qnil;
2886
+ }
2887
+
2888
+ extern "C"
2889
+ VALUE
2890
+ IceRuby_declareClass(VALUE /*self*/, VALUE id)
2891
+ {
2892
+ ICE_RUBY_TRY
2893
+ {
2894
+ string idstr = getString(id);
2895
+ ClassInfoPtr info = lookupClassInfo(idstr);
2896
+ if(!info)
2897
+ {
2898
+ info = new ClassInfo(id, false);
2899
+ addClassInfo(idstr, info);
2900
+ }
2901
+
2902
+ return info->typeObj;
2903
+ }
2904
+ ICE_RUBY_CATCH
2905
+ return Qnil;
2906
+ }
2907
+
2908
+ extern "C"
2909
+ VALUE
2910
+ IceRuby_declareLocalClass(VALUE /*self*/, VALUE id)
2911
+ {
2912
+ ICE_RUBY_TRY
2913
+ {
2914
+ string idstr = getString(id);
2915
+ ClassInfoPtr info = lookupClassInfo(idstr);
2916
+ if(!info)
2917
+ {
2918
+ info = new ClassInfo(id, true);
2919
+ addClassInfo(idstr, info);
2920
+ }
2921
+
2922
+ return info->typeObj;
2923
+ }
2924
+ ICE_RUBY_CATCH
2925
+ return Qnil;
2926
+ }
2927
+
2928
+ extern "C"
2929
+ VALUE
2930
+ IceRuby_defineException(VALUE /*self*/, VALUE id, VALUE type, VALUE preserve, VALUE base, VALUE members)
2931
+ {
2932
+ ICE_RUBY_TRY
2933
+ {
2934
+ ExceptionInfoPtr info = new ExceptionInfo;
2935
+ info->id = getString(id);
2936
+
2937
+ info->preserve = preserve == Qtrue;
2938
+
2939
+ if(!NIL_P(base))
2940
+ {
2941
+ info->base = ExceptionInfoPtr::dynamicCast(getException(base));
2942
+ assert(info->base);
2943
+ }
2944
+
2945
+ convertDataMembers(members, info->members, info->optionalMembers, true);
2946
+
2947
+ info->usesClasses = false;
2948
+
2949
+ //
2950
+ // Only examine the required members to see if any use classes.
2951
+ //
2952
+ for(DataMemberList::iterator p = info->members.begin(); p != info->members.end(); ++p)
2953
+ {
2954
+ if(!info->usesClasses)
2955
+ {
2956
+ info->usesClasses = (*p)->type->usesClasses();
2957
+ }
2958
+ }
2959
+
2960
+ info->rubyClass = type;
2961
+
2962
+ addExceptionInfo(info->id, info);
2963
+
2964
+ return createException(info);
2965
+ }
2966
+ ICE_RUBY_CATCH
2967
+ return Qnil;
2968
+ }
2969
+
2970
+ extern "C"
2971
+ VALUE
2972
+ IceRuby_TypeInfo_defineProxy(VALUE self, VALUE type, VALUE classInfo)
2973
+ {
2974
+ ICE_RUBY_TRY
2975
+ {
2976
+ ProxyInfoPtr info = ProxyInfoPtr::dynamicCast(getType(self));
2977
+ assert(info);
2978
+
2979
+ info->define(type, classInfo);
2980
+ }
2981
+ ICE_RUBY_CATCH
2982
+ return Qnil;
2983
+ }
2984
+
2985
+ extern "C"
2986
+ VALUE
2987
+ IceRuby_TypeInfo_defineClass(VALUE self, VALUE type, VALUE compactId, VALUE isAbstract, VALUE preserve, VALUE base,
2988
+ VALUE interfaces, VALUE members)
2989
+ {
2990
+ ICE_RUBY_TRY
2991
+ {
2992
+ ClassInfoPtr info = ClassInfoPtr::dynamicCast(getType(self));
2993
+ assert(info);
2994
+
2995
+ info->define(type, compactId, isAbstract, preserve, base, interfaces, members);
2996
+
2997
+ CompactIdMap::iterator q = _compactIdMap.find(info->compactId);
2998
+ if(q != _compactIdMap.end())
2999
+ {
3000
+ _compactIdMap.erase(q);
3001
+ }
3002
+ _compactIdMap.insert(CompactIdMap::value_type(info->compactId, info));
3003
+ }
3004
+ ICE_RUBY_CATCH
3005
+ return Qnil;
3006
+ }
3007
+
3008
+ extern "C"
3009
+ VALUE
3010
+ IceRuby_stringify(VALUE /*self*/, VALUE obj, VALUE type)
3011
+ {
3012
+ ICE_RUBY_TRY
3013
+ {
3014
+ TypeInfoPtr info = getType(type);
3015
+
3016
+ ostringstream ostr;
3017
+ IceUtilInternal::Output out(ostr);
3018
+ PrintObjectHistory history;
3019
+ history.index = 0;
3020
+ info->print(obj, out, &history);
3021
+
3022
+ string str = ostr.str();
3023
+ return createString(str);
3024
+ }
3025
+ ICE_RUBY_CATCH
3026
+ return Qnil;
3027
+ }
3028
+
3029
+ extern "C"
3030
+ VALUE
3031
+ IceRuby_stringifyException(VALUE /*self*/, VALUE ex)
3032
+ {
3033
+ ICE_RUBY_TRY
3034
+ {
3035
+ volatile VALUE cls = CLASS_OF(ex);
3036
+ volatile VALUE type = callRuby(rb_const_get, cls, rb_intern("ICE_TYPE"));
3037
+ ExceptionInfoPtr info = getException(type);
3038
+
3039
+ ostringstream ostr;
3040
+ IceUtilInternal::Output out(ostr);
3041
+ info->print(ex, out);
3042
+
3043
+ string str = ostr.str();
3044
+ return createString(str);
3045
+ }
3046
+ ICE_RUBY_CATCH
3047
+ return Qnil;
3048
+ }
3049
+
3050
+ //
3051
+ // lookupClassInfo()
3052
+ //
3053
+ IceRuby::ClassInfoPtr
3054
+ IceRuby::lookupClassInfo(const string& id)
3055
+ {
3056
+ ClassInfoMap::iterator p = _classInfoMap.find(id);
3057
+ if(p != _classInfoMap.end())
3058
+ {
3059
+ return p->second;
3060
+ }
3061
+ return 0;
3062
+ }
3063
+
3064
+ //
3065
+ // lookupExceptionInfo()
3066
+ //
3067
+ IceRuby::ExceptionInfoPtr
3068
+ IceRuby::lookupExceptionInfo(const string& id)
3069
+ {
3070
+ ExceptionInfoMap::iterator p = _exceptionInfoMap.find(id);
3071
+ if(p != _exceptionInfoMap.end())
3072
+ {
3073
+ return p->second;
3074
+ }
3075
+ return 0;
3076
+ }
3077
+
3078
+ bool
3079
+ IceRuby::initTypes(VALUE iceModule)
3080
+ {
3081
+ //
3082
+ // Define a class to represent TypeInfo, and another to represent ExceptionInfo.
3083
+ //
3084
+ _typeInfoClass = rb_define_class_under(iceModule, "Internal_TypeInfo", rb_cObject);
3085
+ _exceptionInfoClass = rb_define_class_under(iceModule, "Internal_ExceptionInfo", rb_cObject);
3086
+
3087
+ rb_define_const(iceModule, "T_bool", createType(new PrimitiveInfo(PrimitiveInfo::KindBool)));
3088
+ rb_define_const(iceModule, "T_byte", createType(new PrimitiveInfo(PrimitiveInfo::KindByte)));
3089
+ rb_define_const(iceModule, "T_short", createType(new PrimitiveInfo(PrimitiveInfo::KindShort)));
3090
+ rb_define_const(iceModule, "T_int", createType(new PrimitiveInfo(PrimitiveInfo::KindInt)));
3091
+ rb_define_const(iceModule, "T_long", createType(new PrimitiveInfo(PrimitiveInfo::KindLong)));
3092
+ rb_define_const(iceModule, "T_float", createType(new PrimitiveInfo(PrimitiveInfo::KindFloat)));
3093
+ rb_define_const(iceModule, "T_double", createType(new PrimitiveInfo(PrimitiveInfo::KindDouble)));
3094
+ rb_define_const(iceModule, "T_string", createType(new PrimitiveInfo(PrimitiveInfo::KindString)));
3095
+
3096
+ rb_define_module_function(iceModule, "__defineEnum", CAST_METHOD(IceRuby_defineEnum), 3);
3097
+ rb_define_module_function(iceModule, "__defineStruct", CAST_METHOD(IceRuby_defineStruct), 3);
3098
+ rb_define_module_function(iceModule, "__defineSequence", CAST_METHOD(IceRuby_defineSequence), 2);
3099
+ rb_define_module_function(iceModule, "__defineDictionary", CAST_METHOD(IceRuby_defineDictionary), 3);
3100
+ rb_define_module_function(iceModule, "__declareProxy", CAST_METHOD(IceRuby_declareProxy), 1);
3101
+ rb_define_module_function(iceModule, "__declareClass", CAST_METHOD(IceRuby_declareClass), 1);
3102
+ rb_define_module_function(iceModule, "__declareLocalClass", CAST_METHOD(IceRuby_declareLocalClass), 1);
3103
+ rb_define_module_function(iceModule, "__defineException", CAST_METHOD(IceRuby_defineException), 5);
3104
+
3105
+ rb_define_method(_typeInfoClass, "defineClass", CAST_METHOD(IceRuby_TypeInfo_defineClass), 7);
3106
+ rb_define_method(_typeInfoClass, "defineProxy", CAST_METHOD(IceRuby_TypeInfo_defineProxy), 2);
3107
+
3108
+ rb_define_module_function(iceModule, "__stringify", CAST_METHOD(IceRuby_stringify), 2);
3109
+ rb_define_module_function(iceModule, "__stringifyException", CAST_METHOD(IceRuby_stringifyException), 1);
3110
+
3111
+ _unsetTypeClass = rb_define_class_under(iceModule, "Internal_UnsetType", rb_cObject);
3112
+ Unset = callRuby(rb_class_new_instance, 0, static_cast<VALUE*>(0), _unsetTypeClass);
3113
+ rb_define_const(iceModule, "Unset", Unset);
3114
+
3115
+ return true;
3116
+ }
3117
+
3118
+ IceRuby::TypeInfoPtr
3119
+ IceRuby::getType(VALUE obj)
3120
+ {
3121
+ assert(TYPE(obj) == T_DATA);
3122
+ assert(rb_obj_is_instance_of(obj, _typeInfoClass) == Qtrue);
3123
+ TypeInfoPtr* p = reinterpret_cast<TypeInfoPtr*>(DATA_PTR(obj));
3124
+ return *p;
3125
+ }
3126
+
3127
+ extern "C"
3128
+ void
3129
+ IceRuby_TypeInfo_free(TypeInfoPtr* p)
3130
+ {
3131
+ delete p;
3132
+ }
3133
+
3134
+ VALUE
3135
+ IceRuby::createType(const TypeInfoPtr& info)
3136
+ {
3137
+ return Data_Wrap_Struct(_typeInfoClass, 0, IceRuby_TypeInfo_free, new TypeInfoPtr(info));
3138
+ }
3139
+
3140
+ IceRuby::ExceptionInfoPtr
3141
+ IceRuby::getException(VALUE obj)
3142
+ {
3143
+ assert(TYPE(obj) == T_DATA);
3144
+ assert(rb_obj_is_instance_of(obj, _exceptionInfoClass) == Qtrue);
3145
+ ExceptionInfoPtr* p = reinterpret_cast<ExceptionInfoPtr*>(DATA_PTR(obj));
3146
+ return *p;
3147
+ }
3148
+
3149
+ extern "C"
3150
+ void
3151
+ IceRuby_ExceptionInfo_free(ExceptionInfoPtr* p)
3152
+ {
3153
+ delete p;
3154
+ }
3155
+
3156
+ VALUE
3157
+ IceRuby::createException(const ExceptionInfoPtr& info)
3158
+ {
3159
+ return Data_Wrap_Struct(_exceptionInfoClass, 0, IceRuby_ExceptionInfo_free, new ExceptionInfoPtr(info));
3160
+ }