r2corba 1.4.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (254) hide show
  1. checksums.yaml +7 -0
  2. data/CHANGES +159 -0
  3. data/LICENSE +59 -0
  4. data/README +62 -0
  5. data/THANKS +52 -0
  6. data/bin/r2corba +8 -0
  7. data/bin/ridlc +11 -0
  8. data/bin/rins +7 -0
  9. data/ext/ext.mwc +6 -0
  10. data/ext/extload/extload.c +60 -0
  11. data/ext/libr2tao/any.cpp +1543 -0
  12. data/ext/libr2tao/exception.cpp +202 -0
  13. data/ext/libr2tao/exception.h +104 -0
  14. data/ext/libr2tao/longdouble.cpp +173 -0
  15. data/ext/libr2tao/longdouble.h +31 -0
  16. data/ext/libr2tao/object.cpp +1150 -0
  17. data/ext/libr2tao/object.h +38 -0
  18. data/ext/libr2tao/orb.cpp +1029 -0
  19. data/ext/libr2tao/orb.h +36 -0
  20. data/ext/libr2tao/r2tao_export.h +45 -0
  21. data/ext/libr2tao/r2tao_ext.h +38 -0
  22. data/ext/libr2tao/required.cpp +463 -0
  23. data/ext/libr2tao/required.h +187 -0
  24. data/ext/libr2tao/typecode.cpp +888 -0
  25. data/ext/libr2tao/typecode.h +45 -0
  26. data/ext/libr2tao/values.cpp +2938 -0
  27. data/ext/libr2tao/values.h +396 -0
  28. data/ext/librpoa/iortable.cpp +250 -0
  29. data/ext/librpoa/poa.cpp +1076 -0
  30. data/ext/librpoa/poa.h +24 -0
  31. data/ext/librpoa/rpoa_export.h +44 -0
  32. data/ext/librpoa/servant.cpp +1338 -0
  33. data/ext/librpoa/servant.h +116 -0
  34. data/ext/librpoa/srvreq_fix.cpp +283 -0
  35. data/ext/librpoa/srvreq_fix.h +149 -0
  36. data/ext/librpol/policies.cpp +763 -0
  37. data/ext/librpol/policies.h +15 -0
  38. data/ext/librpol/rpol_export.h +44 -0
  39. data/lib/corba/cbase/IORMap.rb +33 -0
  40. data/lib/corba/cbase/ORB.rb +231 -0
  41. data/lib/corba/cbase/Request.rb +134 -0
  42. data/lib/corba/cbase/Streams.rb +129 -0
  43. data/lib/corba/cbase/Stub.rb +19 -0
  44. data/lib/corba/cbase/Typecode.rb +441 -0
  45. data/lib/corba/cbase/Values.rb +129 -0
  46. data/lib/corba/cbase/exception.rb +66 -0
  47. data/lib/corba/cbase/poa.rb +23 -0
  48. data/lib/corba/cbase/policies.rb +78 -0
  49. data/lib/corba/cbase/post_require.rb +14 -0
  50. data/lib/corba/cbase/require.rb +28 -0
  51. data/lib/corba/cmds/base.rb +85 -0
  52. data/lib/corba/cmds/test.rb +30 -0
  53. data/lib/corba/common/Any.rb +91 -0
  54. data/lib/corba/common/IDL.rb +104 -0
  55. data/lib/corba/common/ORB.rb +368 -0
  56. data/lib/corba/common/Object.rb +208 -0
  57. data/lib/corba/common/Request.rb +20 -0
  58. data/lib/corba/common/Servant.rb +108 -0
  59. data/lib/corba/common/Struct.rb +22 -0
  60. data/lib/corba/common/Stub.rb +79 -0
  61. data/lib/corba/common/Typecode.rb +1121 -0
  62. data/lib/corba/common/Union.rb +56 -0
  63. data/lib/corba/common/Values.rb +92 -0
  64. data/lib/corba/common/const.rb +22 -0
  65. data/lib/corba/common/exception.rb +68 -0
  66. data/lib/corba/common/require.rb +27 -0
  67. data/lib/corba/common/version.rb +22 -0
  68. data/lib/corba/idl/IDL.rb +21 -0
  69. data/lib/corba/idl/IORTable.pidl +62 -0
  70. data/lib/corba/idl/TAO_Ext.pidl +46 -0
  71. data/lib/corba/idl/require.rb +20 -0
  72. data/lib/corba/jbase/Any.rb +273 -0
  73. data/lib/corba/jbase/IORMap.rb +36 -0
  74. data/lib/corba/jbase/ORB.rb +99 -0
  75. data/lib/corba/jbase/Object.rb +98 -0
  76. data/lib/corba/jbase/Request.rb +226 -0
  77. data/lib/corba/jbase/Servant.rb +247 -0
  78. data/lib/corba/jbase/ServerRequest.rb +128 -0
  79. data/lib/corba/jbase/Streams.rb +671 -0
  80. data/lib/corba/jbase/Stub.rb +38 -0
  81. data/lib/corba/jbase/Typecode.rb +520 -0
  82. data/lib/corba/jbase/Values.rb +173 -0
  83. data/lib/corba/jbase/exception.rb +106 -0
  84. data/lib/corba/jbase/poa.rb +229 -0
  85. data/lib/corba/jbase/policies.rb +300 -0
  86. data/lib/corba/jbase/post_require.rb +14 -0
  87. data/lib/corba/jbase/require.rb +86 -0
  88. data/lib/corba/naming.rb +14 -0
  89. data/lib/corba/naming_service.rb +15 -0
  90. data/lib/corba/poa.rb +15 -0
  91. data/lib/corba/policies.rb +18 -0
  92. data/lib/corba/require.rb +17 -0
  93. data/lib/corba/svcs/ins/cos_naming.rb +426 -0
  94. data/lib/corba/svcs/ins/ins.rb +526 -0
  95. data/lib/corba/svcs/ins/naming_service.rb +119 -0
  96. data/lib/corba.rb +16 -0
  97. data/lib/ridlbe/ruby/config.rb +336 -0
  98. data/lib/ridlbe/ruby/require.rb +16 -0
  99. data/lib/ridlbe/ruby/walker.rb +1582 -0
  100. data/mkrf_conf_srcgem.rb +186 -0
  101. data/rakelib/bin.rake +80 -0
  102. data/rakelib/bin.rb +146 -0
  103. data/rakelib/build.rake +87 -0
  104. data/rakelib/config.rake +52 -0
  105. data/rakelib/config.rb +450 -0
  106. data/rakelib/ext.rake +242 -0
  107. data/rakelib/ext.rb +308 -0
  108. data/rakelib/ext_r2tao.rb +232 -0
  109. data/rakelib/gem.rake +212 -0
  110. data/rakelib/gem.rb +146 -0
  111. data/rakelib/package.rake +26 -0
  112. data/rakelib/test.rake +23 -0
  113. data/test/BiDirectional/Test.idl +34 -0
  114. data/test/BiDirectional/client.rb +132 -0
  115. data/test/BiDirectional/run_test.rb +68 -0
  116. data/test/BiDirectional/server.rb +169 -0
  117. data/test/CORBA_Services/Naming/BindingIterator/Test.idl +27 -0
  118. data/test/CORBA_Services/Naming/BindingIterator/client.rb +121 -0
  119. data/test/CORBA_Services/Naming/BindingIterator/run_test.rb +82 -0
  120. data/test/CORBA_Services/Naming/BindingIterator/server.rb +109 -0
  121. data/test/CORBA_Services/Naming/Corbaname/Test.idl +27 -0
  122. data/test/CORBA_Services/Naming/Corbaname/client.rb +85 -0
  123. data/test/CORBA_Services/Naming/Corbaname/run_test.rb +88 -0
  124. data/test/CORBA_Services/Naming/Corbaname/server.rb +135 -0
  125. data/test/CORBA_Services/Naming/Simple/Test.idl +27 -0
  126. data/test/CORBA_Services/Naming/Simple/client.rb +84 -0
  127. data/test/CORBA_Services/Naming/Simple/run_test.rb +82 -0
  128. data/test/CORBA_Services/Naming/Simple/server.rb +109 -0
  129. data/test/Collocation/Diamond.idl +39 -0
  130. data/test/Collocation/run_test.rb +52 -0
  131. data/test/Collocation/test.rb +195 -0
  132. data/test/Connect_Timeout/Test.idl +27 -0
  133. data/test/Connect_Timeout/client.rb +111 -0
  134. data/test/Connect_Timeout/run_test.rb +52 -0
  135. data/test/DII/Test.idl +27 -0
  136. data/test/DII/client.rb +115 -0
  137. data/test/DII/run_test.rb +69 -0
  138. data/test/DII/server.rb +95 -0
  139. data/test/DSI/Test.idl +27 -0
  140. data/test/DSI/client.rb +66 -0
  141. data/test/DSI/run_test.rb +69 -0
  142. data/test/DSI/server.rb +106 -0
  143. data/test/Exceptions/Test.idl +48 -0
  144. data/test/Exceptions/client.rb +118 -0
  145. data/test/Exceptions/run_test.rb +69 -0
  146. data/test/Exceptions/server.rb +131 -0
  147. data/test/Hello/Test.idl +27 -0
  148. data/test/Hello/client.rb +78 -0
  149. data/test/Hello/run_test.rb +71 -0
  150. data/test/Hello/server.rb +95 -0
  151. data/test/IDL_Test/Test.idl +113 -0
  152. data/test/IDL_Test/Test_inc.idl +17 -0
  153. data/test/IDL_Test/client.rb +102 -0
  154. data/test/IDL_Test/run_test.rb +69 -0
  155. data/test/IDL_Test/server.rb +99 -0
  156. data/test/IORMap/Test.idl +27 -0
  157. data/test/IORMap/client.rb +73 -0
  158. data/test/IORMap/run_test.rb +69 -0
  159. data/test/IORMap/server.rb +114 -0
  160. data/test/IORTable/Test.idl +27 -0
  161. data/test/IORTable/client.rb +75 -0
  162. data/test/IORTable/run_test.rb +69 -0
  163. data/test/IORTable/server.rb +130 -0
  164. data/test/Implicit_Conversion/Test.idl +31 -0
  165. data/test/Implicit_Conversion/client.rb +110 -0
  166. data/test/Implicit_Conversion/run_test.rb +69 -0
  167. data/test/Implicit_Conversion/server.rb +99 -0
  168. data/test/Multi_Threading/Multiple_ORB/Test.idl +27 -0
  169. data/test/Multi_Threading/Multiple_ORB/client.rb +82 -0
  170. data/test/Multi_Threading/Multiple_ORB/run_test.rb +71 -0
  171. data/test/Multi_Threading/Multiple_ORB/server.rb +108 -0
  172. data/test/Multi_Threading/Simple/Test.idl +27 -0
  173. data/test/Multi_Threading/Simple/client.rb +88 -0
  174. data/test/Multi_Threading/Simple/run_test.rb +69 -0
  175. data/test/Multi_Threading/Simple/server.rb +118 -0
  176. data/test/Multi_Threading/Threads/Test.idl +31 -0
  177. data/test/Multi_Threading/Threads/client.rb +80 -0
  178. data/test/Multi_Threading/Threads/run_test.rb +76 -0
  179. data/test/Multi_Threading/Threads/server.rb +119 -0
  180. data/test/Multi_Threading/Threads/watchdog.rb +87 -0
  181. data/test/Multiple_Servant_Interfaces/Test.idl +34 -0
  182. data/test/Multiple_Servant_Interfaces/client.rb +70 -0
  183. data/test/Multiple_Servant_Interfaces/run_test.rb +69 -0
  184. data/test/Multiple_Servant_Interfaces/server.rb +102 -0
  185. data/test/Nil/Test.idl +27 -0
  186. data/test/Nil/run_test.rb +52 -0
  187. data/test/Nil/test.rb +78 -0
  188. data/test/OBV/AbstractInterface/client.rb +179 -0
  189. data/test/OBV/AbstractInterface/run_test.rb +69 -0
  190. data/test/OBV/AbstractInterface/server.rb +149 -0
  191. data/test/OBV/AbstractInterface/test.idl +53 -0
  192. data/test/OBV/Custom/OBV.idl +18 -0
  193. data/test/OBV/Custom/OBV_impl.rb +40 -0
  194. data/test/OBV/Custom/client.rb +86 -0
  195. data/test/OBV/Custom/run_test.rb +69 -0
  196. data/test/OBV/Custom/server.rb +100 -0
  197. data/test/OBV/Simple/OBV.idl +15 -0
  198. data/test/OBV/Simple/OBV_impl.rb +26 -0
  199. data/test/OBV/Simple/client.rb +86 -0
  200. data/test/OBV/Simple/run_test.rb +69 -0
  201. data/test/OBV/Simple/server.rb +100 -0
  202. data/test/OBV/Simple_Event/Event.idl +15 -0
  203. data/test/OBV/Simple_Event/Event_impl.rb +26 -0
  204. data/test/OBV/Simple_Event/client.rb +86 -0
  205. data/test/OBV/Simple_Event/run_test.rb +69 -0
  206. data/test/OBV/Simple_Event/server.rb +100 -0
  207. data/test/OBV/Supports/client.rb +116 -0
  208. data/test/OBV/Supports/run_test.rb +69 -0
  209. data/test/OBV/Supports/server.rb +103 -0
  210. data/test/OBV/Supports/supports.idl +33 -0
  211. data/test/OBV/Supports/supports_impl.rb +57 -0
  212. data/test/OBV/Tree/client.rb +116 -0
  213. data/test/OBV/Tree/run_test.rb +69 -0
  214. data/test/OBV/Tree/server.rb +117 -0
  215. data/test/OBV/Tree/test.idl +32 -0
  216. data/test/OBV/Truncatable/Extra.idl +27 -0
  217. data/test/OBV/Truncatable/Truncatable.idl +105 -0
  218. data/test/OBV/Truncatable/Truncatable_impl.rb +86 -0
  219. data/test/OBV/Truncatable/client.rb +279 -0
  220. data/test/OBV/Truncatable/run_test.rb +69 -0
  221. data/test/OBV/Truncatable/server.rb +89 -0
  222. data/test/OBV/ValueBox/client.rb +497 -0
  223. data/test/OBV/ValueBox/run_test.rb +69 -0
  224. data/test/OBV/ValueBox/server.rb +271 -0
  225. data/test/OBV/ValueBox/valuebox.idl +101 -0
  226. data/test/OBV/ValueBox/vb_basic.idl +75 -0
  227. data/test/OBV/ValueBox/vb_struct.idl +68 -0
  228. data/test/OBV/ValueBox/vb_union.idl +21 -0
  229. data/test/Object/Test.idl +27 -0
  230. data/test/Object/client.rb +103 -0
  231. data/test/Object/run_test.rb +69 -0
  232. data/test/Object/server.rb +126 -0
  233. data/test/POA/Test.idl +27 -0
  234. data/test/POA/run_test.rb +52 -0
  235. data/test/POA/test.rb +112 -0
  236. data/test/Param_Test/Test.idl +182 -0
  237. data/test/Param_Test/client.rb +277 -0
  238. data/test/Param_Test/run_test.rb +69 -0
  239. data/test/Param_Test/server.rb +296 -0
  240. data/test/Performance/Simple/Test.idl +27 -0
  241. data/test/Performance/Simple/client.rb +90 -0
  242. data/test/Performance/Simple/run_test.rb +69 -0
  243. data/test/Performance/Simple/server.rb +95 -0
  244. data/test/Policies/Test.idl +27 -0
  245. data/test/Policies/run_test.rb +52 -0
  246. data/test/Policies/test.rb +144 -0
  247. data/test/Timeout/client.rb +207 -0
  248. data/test/Timeout/run_test.rb +69 -0
  249. data/test/Timeout/server.rb +109 -0
  250. data/test/Timeout/test.idl +19 -0
  251. data/test/lib/assert.rb +43 -0
  252. data/test/lib/test.rb +542 -0
  253. data/test/test_runner.rb +193 -0
  254. metadata +334 -0
@@ -0,0 +1,2938 @@
1
+ /*--------------------------------------------------------------------
2
+ # values.cpp - R2TAO CORBA Valuetype support
3
+ #
4
+ # Author: Martin Corino
5
+ #
6
+ # This program is free software; you can redistribute it and/or
7
+ # modify it under the terms of the R2CORBA LICENSE which is
8
+ # included with this program.
9
+ #
10
+ # Copyright (c) Remedy IT Expertise BV
11
+ # Chamber of commerce Rotterdam nr.276339, The Netherlands
12
+ #------------------------------------------------------------------*/
13
+
14
+ #include "required.h"
15
+ #include "exception.h"
16
+ #include "object.h"
17
+ #include "typecode.h"
18
+ #include "longdouble.h"
19
+ #include "values.h"
20
+ #include "tao/CDR.h"
21
+ #include "tao/ORB_Core.h"
22
+ #include "tao/DynamicAny/DynamicAny.h"
23
+
24
+ #define RUBY_INVOKE_FUNC RUBY_ALLOC_FUNC
25
+
26
+ static ID ci_ivar_ID;
27
+ static ID val_ivar_ID;
28
+
29
+ static VALUE r2tao_nsValueBase;
30
+ static VALUE r2tao_nsInputStream;
31
+ static VALUE r2tao_nsOutputStream;
32
+ static VALUE r2tao_cInputStream;
33
+ static VALUE r2tao_cOutputStream;
34
+
35
+ VALUE r2tao_cValueFactoryBase = 0;
36
+ VALUE r2tao_cBoxedValueBase = 0;
37
+
38
+ // Ruby ValueBase methods
39
+ VALUE r2tao_Value_pre_marshal(VALUE self, VALUE strm);
40
+ VALUE r2tao_Value_post_marshal(VALUE self, VALUE strm);
41
+ VALUE r2tao_Value_pre_unmarshal(VALUE self, VALUE strm);
42
+ VALUE r2tao_Value_post_unmarshal(VALUE self, VALUE strm);
43
+
44
+ // Ruby Stream methods
45
+ static VALUE r2tao_InputStream_t2r(TAO_InputCDR* strm);
46
+ static VALUE r2tao_OutputStream_t2r(R2TAO_Value* val);
47
+ static TAO_InputCDR* r2tao_InputStream_r2t(VALUE strm);
48
+ static R2TAO_Value* r2tao_OutputStream_r2t(VALUE strm);
49
+
50
+ VALUE r2tao_OStream_write_any (VALUE self, VALUE rval);
51
+ VALUE r2tao_OStream_write_boolean (VALUE self, VALUE rval);
52
+ VALUE r2tao_OStream_write_char (VALUE self, VALUE rval);
53
+ VALUE r2tao_OStream_write_wchar (VALUE self, VALUE rval);
54
+ VALUE r2tao_OStream_write_octet (VALUE self, VALUE rval);
55
+ VALUE r2tao_OStream_write_short (VALUE self, VALUE rval);
56
+ VALUE r2tao_OStream_write_ushort (VALUE self, VALUE rval);
57
+ VALUE r2tao_OStream_write_long (VALUE self, VALUE rval);
58
+ VALUE r2tao_OStream_write_ulong (VALUE self, VALUE rval);
59
+ VALUE r2tao_OStream_write_longlong (VALUE self, VALUE rval);
60
+ VALUE r2tao_OStream_write_ulonglong (VALUE self, VALUE rval);
61
+ VALUE r2tao_OStream_write_float (VALUE self, VALUE rval);
62
+ VALUE r2tao_OStream_write_double (VALUE self, VALUE rval);
63
+ VALUE r2tao_OStream_write_longdouble (VALUE self, VALUE rval);
64
+ VALUE r2tao_OStream_write_Object (VALUE self, VALUE rval);
65
+ VALUE r2tao_OStream_write_Abstract (VALUE self, VALUE rval);
66
+ VALUE r2tao_OStream_write_Value (VALUE self, VALUE rval);
67
+ VALUE r2tao_OStream_write_TypeCode (VALUE self, VALUE rval);
68
+ VALUE r2tao_OStream_write_fixed (VALUE self, VALUE rval);
69
+
70
+ VALUE r2tao_OStream_write_string (VALUE self, VALUE rval);
71
+ VALUE r2tao_OStream_write_wstring (VALUE self, VALUE rval);
72
+
73
+ VALUE r2tao_OStream_write_any_array (VALUE self, VALUE rval, VALUE offset, VALUE length);
74
+ VALUE r2tao_OStream_write_boolean_array (VALUE self, VALUE rval, VALUE offset, VALUE length);
75
+ VALUE r2tao_OStream_write_char_array (VALUE self, VALUE rval, VALUE offset, VALUE length);
76
+ VALUE r2tao_OStream_write_wchar_array (VALUE self, VALUE rval, VALUE offset, VALUE length);
77
+ VALUE r2tao_OStream_write_octet_array (VALUE self, VALUE rval, VALUE offset, VALUE length);
78
+ VALUE r2tao_OStream_write_short_array (VALUE self, VALUE rval, VALUE offset, VALUE length);
79
+ VALUE r2tao_OStream_write_ushort_array (VALUE self, VALUE rval, VALUE offset, VALUE length);
80
+ VALUE r2tao_OStream_write_long_array (VALUE self, VALUE rval, VALUE offset, VALUE length);
81
+ VALUE r2tao_OStream_write_ulong_array (VALUE self, VALUE rval, VALUE offset, VALUE length);
82
+ VALUE r2tao_OStream_write_longlong_array (VALUE self, VALUE rval, VALUE offset, VALUE length);
83
+ VALUE r2tao_OStream_write_ulonglong_array (VALUE self, VALUE rval, VALUE offset, VALUE length);
84
+ VALUE r2tao_OStream_write_float_array (VALUE self, VALUE rval, VALUE offset, VALUE length);
85
+ VALUE r2tao_OStream_write_double_array (VALUE self, VALUE rval, VALUE offset, VALUE length);
86
+ VALUE r2tao_OStream_write_longdouble_array (VALUE self, VALUE rval, VALUE offset, VALUE length);
87
+ VALUE r2tao_OStream_write_fixed_array (VALUE self, VALUE rval, VALUE offset, VALUE length);
88
+
89
+ VALUE r2tao_OStream_write_construct (VALUE self, VALUE rval, VALUE rtc);
90
+
91
+ VALUE r2tao_IStream_read_any (VALUE self);
92
+ VALUE r2tao_IStream_read_boolean (VALUE self);
93
+ VALUE r2tao_IStream_read_char (VALUE self);
94
+ VALUE r2tao_IStream_read_wchar (VALUE self);
95
+ VALUE r2tao_IStream_read_octet (VALUE self);
96
+ VALUE r2tao_IStream_read_short (VALUE self);
97
+ VALUE r2tao_IStream_read_ushort (VALUE self);
98
+ VALUE r2tao_IStream_read_long (VALUE self);
99
+ VALUE r2tao_IStream_read_ulong (VALUE self);
100
+ VALUE r2tao_IStream_read_longlong (VALUE self);
101
+ VALUE r2tao_IStream_read_ulonglong (VALUE self);
102
+ VALUE r2tao_IStream_read_float (VALUE self);
103
+ VALUE r2tao_IStream_read_double (VALUE self);
104
+ VALUE r2tao_IStream_read_longdouble (VALUE self);
105
+ VALUE r2tao_IStream_read_Object (VALUE self);
106
+ VALUE r2tao_IStream_read_Abstract (VALUE self);
107
+ VALUE r2tao_IStream_read_Value (VALUE self);
108
+ VALUE r2tao_IStream_read_TypeCode (VALUE self);
109
+ VALUE r2tao_IStream_read_fixed (VALUE self);
110
+
111
+ VALUE r2tao_IStream_read_string (VALUE self);
112
+ VALUE r2tao_IStream_read_wstring (VALUE self);
113
+
114
+ VALUE r2tao_IStream_read_any_array (VALUE self, VALUE rval, VALUE offset, VALUE length);
115
+ VALUE r2tao_IStream_read_boolean_array (VALUE self, VALUE rval, VALUE offset, VALUE length);
116
+ VALUE r2tao_IStream_read_char_array (VALUE self, VALUE rval, VALUE offset, VALUE length);
117
+ VALUE r2tao_IStream_read_wchar_array (VALUE self, VALUE rval, VALUE offset, VALUE length);
118
+ VALUE r2tao_IStream_read_octet_array (VALUE self, VALUE rval, VALUE offset, VALUE length);
119
+ VALUE r2tao_IStream_read_short_array (VALUE self, VALUE rval, VALUE offset, VALUE length);
120
+ VALUE r2tao_IStream_read_ushort_array (VALUE self, VALUE rval, VALUE offset, VALUE length);
121
+ VALUE r2tao_IStream_read_long_array (VALUE self, VALUE rval, VALUE offset, VALUE length);
122
+ VALUE r2tao_IStream_read_ulong_array (VALUE self, VALUE rval, VALUE offset, VALUE length);
123
+ VALUE r2tao_IStream_read_longlong_array (VALUE self, VALUE rval, VALUE offset, VALUE length);
124
+ VALUE r2tao_IStream_read_ulonglong_array (VALUE self, VALUE rval, VALUE offset, VALUE length);
125
+ VALUE r2tao_IStream_read_float_array (VALUE self, VALUE rval, VALUE offset, VALUE length);
126
+ VALUE r2tao_IStream_read_double_array (VALUE self, VALUE rval, VALUE offset, VALUE length);
127
+ VALUE r2tao_IStream_read_longdouble_array (VALUE self, VALUE rval, VALUE offset, VALUE length);
128
+ VALUE r2tao_IStream_read_fixed_array (VALUE self, VALUE rval, VALUE offset, VALUE length);
129
+
130
+ VALUE r2tao_IStream_read_construct (VALUE self, VALUE rtc);
131
+
132
+ VALUE r2tao_VFB_register_value_factory(VALUE self, VALUE id, VALUE rfact);
133
+ VALUE r2tao_VFB_unregister_value_factory(VALUE self, VALUE id);
134
+ VALUE r2tao_VFB_lookup_value_factory(VALUE self, VALUE id);
135
+
136
+ void r2tao_init_Values()
137
+ {
138
+ VALUE k;
139
+
140
+ ci_ivar_ID = rb_intern ("@__ci_holder_");
141
+ val_ivar_ID = rb_intern ("@__native_value_");
142
+
143
+ /*
144
+ * Define Portable stream modules
145
+ */
146
+ k = rb_eval_string ("R2CORBA::CORBA::Portable");
147
+ r2tao_nsInputStream = rb_define_module_under(k, "InputStream");
148
+ r2tao_nsOutputStream = rb_define_module_under(k, "OutputStream");
149
+
150
+ /*
151
+ * Define single instance writers
152
+ */
153
+ #define R2TAO_DEFMETHOD(type) \
154
+ rb_define_method (r2tao_nsOutputStream, "write_" #type, RUBY_METHOD_FUNC (r2tao_OStream_write_ ## type), 1)
155
+
156
+ R2TAO_DEFMETHOD (any);
157
+ R2TAO_DEFMETHOD (boolean);
158
+ R2TAO_DEFMETHOD (char);
159
+ R2TAO_DEFMETHOD (wchar);
160
+ R2TAO_DEFMETHOD (octet);
161
+ R2TAO_DEFMETHOD (short);
162
+ R2TAO_DEFMETHOD (ushort);
163
+ R2TAO_DEFMETHOD (long);
164
+ R2TAO_DEFMETHOD (ulong);
165
+ R2TAO_DEFMETHOD (longlong);
166
+ R2TAO_DEFMETHOD (ulonglong);
167
+ R2TAO_DEFMETHOD (float);
168
+ R2TAO_DEFMETHOD (double);
169
+ R2TAO_DEFMETHOD (longdouble);
170
+ R2TAO_DEFMETHOD (Object);
171
+ R2TAO_DEFMETHOD (Abstract);
172
+ R2TAO_DEFMETHOD (Value);
173
+ R2TAO_DEFMETHOD (TypeCode);
174
+ R2TAO_DEFMETHOD (fixed);
175
+ R2TAO_DEFMETHOD (string);
176
+ R2TAO_DEFMETHOD (wstring);
177
+
178
+ /*
179
+ * Define array writers
180
+ */
181
+ #undef R2TAO_DEFMETHOD
182
+ #define R2TAO_DEFMETHOD(type) \
183
+ rb_define_method (r2tao_nsOutputStream, "write_" #type "_array", RUBY_METHOD_FUNC (r2tao_OStream_write_ ## type ## _array), 3)
184
+
185
+ R2TAO_DEFMETHOD (any);
186
+ R2TAO_DEFMETHOD (boolean);
187
+ R2TAO_DEFMETHOD (char);
188
+ R2TAO_DEFMETHOD (wchar);
189
+ R2TAO_DEFMETHOD (octet);
190
+ R2TAO_DEFMETHOD (short);
191
+ R2TAO_DEFMETHOD (ushort);
192
+ R2TAO_DEFMETHOD (long);
193
+ R2TAO_DEFMETHOD (ulong);
194
+ R2TAO_DEFMETHOD (longlong);
195
+ R2TAO_DEFMETHOD (ulonglong);
196
+ R2TAO_DEFMETHOD (float);
197
+ R2TAO_DEFMETHOD (double);
198
+ R2TAO_DEFMETHOD (longdouble);
199
+ R2TAO_DEFMETHOD (fixed);
200
+
201
+ /*
202
+ * Define construct writer
203
+ */
204
+ rb_define_method (r2tao_nsOutputStream, "write_construct", RUBY_METHOD_FUNC (r2tao_OStream_write_construct), 2);
205
+
206
+ /*
207
+ * Define single instance readers
208
+ */
209
+ #undef R2TAO_DEFMETHOD
210
+ #define R2TAO_DEFMETHOD(type) \
211
+ rb_define_method (r2tao_nsInputStream, "read_" #type, RUBY_METHOD_FUNC (r2tao_IStream_read_ ## type), 0)
212
+
213
+ R2TAO_DEFMETHOD (any);
214
+ R2TAO_DEFMETHOD (boolean);
215
+ R2TAO_DEFMETHOD (char);
216
+ R2TAO_DEFMETHOD (wchar);
217
+ R2TAO_DEFMETHOD (octet);
218
+ R2TAO_DEFMETHOD (short);
219
+ R2TAO_DEFMETHOD (ushort);
220
+ R2TAO_DEFMETHOD (long);
221
+ R2TAO_DEFMETHOD (ulong);
222
+ R2TAO_DEFMETHOD (longlong);
223
+ R2TAO_DEFMETHOD (ulonglong);
224
+ R2TAO_DEFMETHOD (float);
225
+ R2TAO_DEFMETHOD (double);
226
+ R2TAO_DEFMETHOD (longdouble);
227
+ R2TAO_DEFMETHOD (Object);
228
+ R2TAO_DEFMETHOD (Abstract);
229
+ R2TAO_DEFMETHOD (Value);
230
+ R2TAO_DEFMETHOD (TypeCode);
231
+ R2TAO_DEFMETHOD (fixed);
232
+ R2TAO_DEFMETHOD (string);
233
+ R2TAO_DEFMETHOD (wstring);
234
+
235
+ /*
236
+ * Define array readers
237
+ */
238
+ #undef R2TAO_DEFMETHOD
239
+ #define R2TAO_DEFMETHOD(type) \
240
+ rb_define_method (r2tao_nsInputStream, "read_" #type "_array", RUBY_METHOD_FUNC (r2tao_IStream_read_ ## type ## _array), 3)
241
+
242
+ R2TAO_DEFMETHOD (any);
243
+ R2TAO_DEFMETHOD (boolean);
244
+ R2TAO_DEFMETHOD (char);
245
+ R2TAO_DEFMETHOD (wchar);
246
+ R2TAO_DEFMETHOD (octet);
247
+ R2TAO_DEFMETHOD (short);
248
+ R2TAO_DEFMETHOD (ushort);
249
+ R2TAO_DEFMETHOD (long);
250
+ R2TAO_DEFMETHOD (ulong);
251
+ R2TAO_DEFMETHOD (longlong);
252
+ R2TAO_DEFMETHOD (ulonglong);
253
+ R2TAO_DEFMETHOD (float);
254
+ R2TAO_DEFMETHOD (double);
255
+ R2TAO_DEFMETHOD (longdouble);
256
+ R2TAO_DEFMETHOD (fixed);
257
+
258
+ /*
259
+ * Define construct reader
260
+ */
261
+ rb_define_method (r2tao_nsInputStream, "read_construct", RUBY_METHOD_FUNC (r2tao_IStream_read_construct), 1);
262
+
263
+ /*
264
+ * Create anonymous classes to wrap native streams;
265
+ * include Portable stream modules to provide wrapper methods
266
+ */
267
+ r2tao_cInputStream = rb_class_new (rb_cObject);
268
+ rb_global_variable (&r2tao_cInputStream); // pin it down so GC doesn't get it
269
+ rb_include_module (r2tao_cInputStream, r2tao_nsInputStream);
270
+ r2tao_cOutputStream = rb_class_new (rb_cObject);
271
+ rb_global_variable (&r2tao_cOutputStream); // pin it down so GC doesn't get it
272
+ rb_include_module (r2tao_cOutputStream, r2tao_nsOutputStream);
273
+
274
+ /*
275
+ * Define marshaling hooks for ValueBase
276
+ */
277
+ r2tao_nsValueBase = k = rb_eval_string ("R2CORBA::CORBA::ValueBase");
278
+ rb_define_protected_method(k, "pre_marshal", RUBY_METHOD_FUNC(r2tao_Value_pre_marshal), 1);
279
+ rb_define_protected_method(k, "post_marshal", RUBY_METHOD_FUNC(r2tao_Value_post_marshal), 1);
280
+ rb_define_protected_method(k, "pre_unmarshal", RUBY_METHOD_FUNC(r2tao_Value_pre_unmarshal), 1);
281
+ rb_define_protected_method(k, "post_unmarshal", RUBY_METHOD_FUNC(r2tao_Value_post_unmarshal), 1);
282
+
283
+ r2tao_cValueFactoryBase = k = rb_eval_string ("R2CORBA::CORBA::Portable::ValueFactoryBase");
284
+
285
+ rb_define_singleton_method(k, "_register_value_factory", RUBY_METHOD_FUNC(r2tao_VFB_register_value_factory), 2);
286
+ rb_define_singleton_method(k, "_unregister_value_factory", RUBY_METHOD_FUNC(r2tao_VFB_unregister_value_factory), 1);
287
+ rb_define_singleton_method(k, "_lookup_value_factory", RUBY_METHOD_FUNC(r2tao_VFB_lookup_value_factory), 1);
288
+
289
+ r2tao_cBoxedValueBase = rb_eval_string ("R2CORBA::CORBA::Portable::BoxedValueBase");
290
+ }
291
+
292
+ //-------------------------------------------------------------------
293
+ // R2TAO_ArrayAny_Impl_T template class
294
+ //
295
+ //===================================================================
296
+
297
+ template<typename T>
298
+ R2TAO_ArrayAny_Impl_T<T>::R2TAO_ArrayAny_Impl_T (CORBA::TypeCode_ptr tc,
299
+ T * const val,
300
+ CORBA::ULong len)
301
+ : TAO::Any_Impl (0, CORBA::TypeCode::_duplicate (tc)),
302
+ value_ (val),
303
+ length_ (len)
304
+ {
305
+ }
306
+
307
+ template<typename T>
308
+ R2TAO_ArrayAny_Impl_T<T>::~R2TAO_ArrayAny_Impl_T (void)
309
+ {
310
+ this->free_value ();
311
+ }
312
+
313
+ template<typename T>
314
+ void R2TAO_ArrayAny_Impl_T<T>::insert (CORBA::Any &any,
315
+ CORBA::TypeCode_ptr tc,
316
+ T * const val,
317
+ CORBA::ULong len)
318
+ {
319
+ R2TAO_ArrayAny_Impl_T<T> *new_impl = 0;
320
+ ACE_NEW (new_impl,
321
+ R2TAO_ArrayAny_Impl_T<T> (tc,
322
+ val,
323
+ len));
324
+ any.replace (new_impl);
325
+ }
326
+
327
+ template<typename T>
328
+ CORBA::Boolean R2TAO_ArrayAny_Impl_T<T>::marshal_value (TAO_OutputCDR &cdr)
329
+ {
330
+ switch (this->type_->kind ())
331
+ {
332
+ case CORBA::tk_short:
333
+ case CORBA::tk_ushort:
334
+ case CORBA::tk_long:
335
+ case CORBA::tk_ulong:
336
+ case CORBA::tk_float:
337
+ case CORBA::tk_double:
338
+ case CORBA::tk_longlong:
339
+ case CORBA::tk_ulonglong:
340
+ case CORBA::tk_longdouble:
341
+ case CORBA::tk_any:
342
+ {
343
+ for (CORBA::ULong i=0; i<this->length_ ;++i)
344
+ {
345
+ cdr << (reinterpret_cast<T*> (this->value_))[i];
346
+ }
347
+ return true;
348
+ }
349
+ default:
350
+ return false;
351
+ }
352
+ }
353
+
354
+ template<>
355
+ CORBA::Boolean R2TAO_ArrayAny_Impl_T<CORBA::Boolean>::marshal_value (TAO_OutputCDR &cdr)
356
+ {
357
+ for (CORBA::ULong i=0; i<this->length_ ;++i)
358
+ {
359
+ cdr << ACE_OutputCDR::from_boolean ((reinterpret_cast<CORBA::Boolean*> (this->value_))[i]);
360
+ }
361
+ return true;
362
+ }
363
+
364
+ template<>
365
+ CORBA::Boolean R2TAO_ArrayAny_Impl_T<CORBA::Char>::marshal_value (TAO_OutputCDR &cdr)
366
+ {
367
+ for (CORBA::ULong i=0; i<this->length_ ;++i)
368
+ {
369
+ cdr << ACE_OutputCDR::from_char ((reinterpret_cast<CORBA::Char*> (this->value_))[i]);
370
+ }
371
+ return true;
372
+ }
373
+
374
+ template<>
375
+ CORBA::Boolean R2TAO_ArrayAny_Impl_T<CORBA::WChar>::marshal_value (TAO_OutputCDR &cdr)
376
+ {
377
+ for (CORBA::ULong i=0; i<this->length_ ;++i)
378
+ {
379
+ cdr << ACE_OutputCDR::from_wchar ((reinterpret_cast<CORBA::WChar*> (this->value_))[i]);
380
+ }
381
+ return true;
382
+ }
383
+
384
+ template<>
385
+ CORBA::Boolean R2TAO_ArrayAny_Impl_T<CORBA::Octet>::marshal_value (TAO_OutputCDR &cdr)
386
+ {
387
+ for (CORBA::ULong i=0; i<this->length_ ;++i)
388
+ {
389
+ cdr << ACE_OutputCDR::from_octet ((reinterpret_cast<CORBA::Octet*> (this->value_))[i]);
390
+ }
391
+ return true;
392
+ }
393
+
394
+ template<typename T>
395
+ const void *R2TAO_ArrayAny_Impl_T<T>::value (void) const
396
+ {
397
+ return this->value_;
398
+ }
399
+
400
+ template<typename T>
401
+ void R2TAO_ArrayAny_Impl_T<T>::free_value (void)
402
+ {
403
+ if (this->value_ != 0)
404
+ {
405
+ delete [] reinterpret_cast<T*> (this->value_);
406
+ }
407
+
408
+ ::CORBA::release (this->type_);
409
+ this->value_ = 0;
410
+ }
411
+
412
+ //-------------------------------------------------------------------
413
+ // R2TAO Value class
414
+ //
415
+ //===================================================================
416
+
417
+ R2TAO_Value::R2TAO_Value (VALUE rbValue, bool for_unmarshal)
418
+ : for_unmarshal_ (for_unmarshal),
419
+ started_chunk_unmarshal_ (false),
420
+ requires_truncation_ (false),
421
+ rbValue_ (rbValue),
422
+ rbValueClass_ (Qnil),
423
+ rbCIHolder_ (Qnil),
424
+ last_chunk_ (0)
425
+ {
426
+ init ();
427
+ }
428
+
429
+ R2TAO_Value::~R2TAO_Value ()
430
+ {
431
+ if (TAO_debug_level > 9)
432
+ ACE_DEBUG ((LM_INFO, "R2TAO (%P|%t) - R2TAO_Value::dtor "
433
+ "destroying Value wrapper %@ for %C\n",
434
+ this, this->val_tc_->id ()));
435
+ // reset value reference
436
+ rb_ivar_set (this->rbValue_, val_ivar_ID, Qnil);
437
+ // free Ruby value for gc collection
438
+ r2tao_unregister_object (this->rbValue_);
439
+ this->rbValue_ = Qnil;
440
+ this->rbCIHolder_ = Qnil;
441
+ }
442
+
443
+ CORBA::ValueBase* R2TAO_Value::_copy_value (void)
444
+ {
445
+ return 0; // noop
446
+ }
447
+
448
+ void R2TAO_Value::init ()
449
+ {
450
+ static ID tc_ID = rb_intern ("_tc");
451
+ static R2TAO_RBFuncall FN_marshal ("do_marshal", false);
452
+
453
+ // mark Ruby value to prevent gc collection
454
+ r2tao_register_object (this->rbValue_);
455
+
456
+ this->rbValueClass_ = rb_class_of(this->rbValue_);
457
+ VALUE rtc = rb_funcall (this->rbValueClass_, tc_ID, 0);
458
+ this->val_tc_ = CORBA::TypeCode::_duplicate (r2corba_TypeCode_r2t (rtc));
459
+
460
+ // determin if this is a truncatable value type
461
+ if (this->val_tc_->kind () == CORBA::tk_value)
462
+ this->is_truncatable_ = (CORBA::VM_TRUNCATABLE == this->val_tc_->type_modifier ());
463
+ else
464
+ this->is_truncatable_ = false; // value box
465
+
466
+ // create special wrapper object to hold this value reference
467
+ VALUE valref = Data_Wrap_Struct (rb_cObject, 0, 0, this);
468
+
469
+ // create an instance variable to value reference
470
+ rb_ivar_set (this->rbValue_, val_ivar_ID, valref);
471
+
472
+ if (this->for_unmarshal_)
473
+ {
474
+ // create special wrapper object to hold chunk info
475
+ this->rbCIHolder_ = Data_Wrap_Struct (rb_cObject, 0, 0, 0);
476
+
477
+ // create an instance variable to hold chunk info while (de)marshaling
478
+ rb_ivar_set (this->rbValue_, ci_ivar_ID, this->rbCIHolder_);
479
+ }
480
+ else
481
+ {
482
+ // invoke Ruby Value marshaling to collect element data
483
+ VALUE rargs = rb_ary_new2 (1);
484
+ rb_ary_push (rargs, r2tao_OutputStream_t2r (this));
485
+
486
+ if (TAO_debug_level > 10)
487
+ ACE_DEBUG ((LM_INFO, "R2TAO (%P|%t) - R2TAO_Value::init: "
488
+ "invoking Ruby marshaling for value %@ for %C\n",
489
+ this->rbValue_,
490
+ this->val_tc_->id ()));
491
+
492
+ FN_marshal.invoke (this->rbValue_, rargs);
493
+ if (FN_marshal.has_caught_exception ())
494
+ {
495
+ rb_eval_string ("STDERR.puts $!.to_s+\"\\n\"+$!.backtrace.join(\"\\n\")");
496
+ throw ::CORBA::MARSHAL (0, CORBA::COMPLETED_NO);
497
+ }
498
+
499
+ if (TAO_debug_level > 10)
500
+ ACE_DEBUG ((LM_INFO, "R2TAO (%P|%t) - R2TAO_Value::init: "
501
+ "Ruby marshaling succeeded for value %@ for %C\n",
502
+ this->rbValue_,
503
+ this->val_tc_->id ()));
504
+
505
+ }
506
+
507
+ if (TAO_debug_level > 9)
508
+ ACE_DEBUG ((LM_INFO, "R2TAO (%P|%t) - R2TAO_Value::ctor "
509
+ "created Value wrapper %@ for %s %s\n",
510
+ this, this->val_tc_->id (),
511
+ this->is_truncatable_ ? "(truncatable)" : ""));
512
+ }
513
+
514
+ void R2TAO_Value::_tao_any_destructor (void *_tao_void_pointer)
515
+ {
516
+ R2TAO_Value *_tao_tmp_pointer =
517
+ static_cast<R2TAO_Value *> (_tao_void_pointer);
518
+ ::CORBA::remove_ref (_tao_tmp_pointer);
519
+ }
520
+
521
+ void R2TAO_Value::truncation_hook ()
522
+ {
523
+ this->requires_truncation_ = true;
524
+ }
525
+
526
+ R2TAO_Value* R2TAO_Value::_downcast (::CORBA::ValueBase *v)
527
+ {
528
+ return dynamic_cast<R2TAO_Value*> (v);
529
+ }
530
+
531
+ CORBA::TypeCode_ptr R2TAO_Value::_tao_type (void) const
532
+ {
533
+ return this->val_tc_.in ();
534
+ }
535
+
536
+ const char * R2TAO_Value::_tao_obv_repository_id (void) const
537
+ {
538
+ return this->val_tc_->id ();
539
+ }
540
+
541
+ void R2TAO_Value::_tao_obv_truncatable_repo_ids (Repository_Id_List & ids) const
542
+ {
543
+ static ID TRUNC_IDS_ID = rb_intern ("TRUNCATABLE_IDS");
544
+
545
+ VALUE rb_ids = rb_const_get(this->rbValueClass_, TRUNC_IDS_ID);
546
+ CHECK_RTYPE (rb_ids, T_ARRAY);
547
+ CORBA::ULong alen = static_cast<unsigned long> (RARRAY_LEN (rb_ids));
548
+ for (CORBA::ULong l=0; l<alen ;++l)
549
+ {
550
+ VALUE id = rb_ary_entry (rb_ids, l);
551
+ CHECK_RTYPE (id, T_STRING);
552
+ ids.push_back (RSTRING_PTR (id));
553
+ }
554
+ }
555
+
556
+ class CI_Guard
557
+ {
558
+ public:
559
+ CI_Guard (VALUE rbval, TAO_ChunkInfo *pci)
560
+ : rbval_ (rbval)
561
+ { DATA_PTR (this->rbval_) = static_cast<void*> (pci); }
562
+ ~CI_Guard () { DATA_PTR (this->rbval_) = 0; }
563
+ private:
564
+ VALUE rbval_;
565
+ };
566
+
567
+ ::CORBA::Boolean R2TAO_Value::_tao_marshal_v (TAO_OutputCDR &strm) const
568
+ {
569
+ if (this->for_unmarshal_) return false;
570
+
571
+ // setup chunking info
572
+ TAO_ChunkInfo ci (this->is_truncatable_ || this->chunking_);
573
+
574
+ if (TAO_debug_level > 9)
575
+ ACE_DEBUG ((LM_INFO, "R2TAO (%P|%t) - R2TAO_Value::_tao_marshal_v: "
576
+ "marshaling value %@ for %s %s\n",
577
+ this,
578
+ this->val_tc_->id (),
579
+ ci.chunking_ ? "(chunked)" : ""));
580
+
581
+ if (! ci.start_chunk (strm))
582
+ return false;
583
+
584
+ // marshal all elements in all chunks (== all concrete values from inheritance chain)
585
+ Chunk* p = this->chunk_list_.get ();
586
+ while (p)
587
+ {
588
+ if (! ci.start_chunk (strm))
589
+ return false;
590
+
591
+ if (TAO_debug_level > 10)
592
+ ACE_DEBUG ((LM_INFO, "R2TAO (%P|%t) - R2TAO_Value::_tao_marshal_v: "
593
+ "marshaling chunk %@ for value %@ for %s\n",
594
+ p,
595
+ this,
596
+ this->val_tc_->id ()));
597
+
598
+ ChunkElements::size_type n = p->elems_.size ();
599
+ for (ChunkElements::size_type e = 0; e < n ;++e)
600
+ {
601
+ if (TAO_debug_level > 10)
602
+ ACE_DEBUG ((LM_INFO, "R2TAO (%P|%t) - R2TAO_Value::_tao_marshal_v: "
603
+ "marshaling chunk element %u for value %@ for %s\n",
604
+ e,
605
+ this,
606
+ this->val_tc_->id ()));
607
+
608
+ if (p->elems_[e] == 0 || p->elems_[e]->impl () == 0)
609
+ {
610
+ // should not ever happen
611
+ ACE_DEBUG ((LM_ERROR, "R2TAO (%P|%t) - R2TAO_Value::_tao_marshal_v: "
612
+ "chunk element %u for value %@ for %s is INVALID (%C is null)\n",
613
+ e,
614
+ this,
615
+ this->val_tc_->id (),
616
+ p->elems_[e] == 0 ? "_var ptr" : "Any impl"));
617
+ return false;
618
+ }
619
+
620
+ p->elems_[e]->impl ()->marshal_value (strm);
621
+ }
622
+
623
+ if (! ci.end_chunk (strm))
624
+ return false;
625
+
626
+ p = p->next_;
627
+ }
628
+
629
+ if (TAO_debug_level > 9)
630
+ ACE_DEBUG ((LM_INFO, "R2TAO (%P|%t) - R2TAO_Value::_tao_marshal_v: "
631
+ "succeeded marshaling value %@ for %s\n",
632
+ this,
633
+ this->val_tc_->id ()));
634
+
635
+ return ci.end_chunk (strm);
636
+ }
637
+
638
+ bool R2TAO_Value::add_chunk ()
639
+ {
640
+ Chunk* new_chunk = 0;
641
+ ACE_NEW_NORETURN (new_chunk, Chunk());
642
+ if (new_chunk != 0)
643
+ {
644
+ if (this->last_chunk_)
645
+ {
646
+ this->last_chunk_->next_ = new_chunk;
647
+ }
648
+ else
649
+ {
650
+ this->chunk_list_.reset (new_chunk);
651
+ }
652
+ this->last_chunk_ = new_chunk;
653
+
654
+ if (TAO_debug_level > 10)
655
+ ACE_DEBUG ((LM_INFO, "R2TAO (%P|%t) - R2TAO_Value::add_chunk: "
656
+ "added chunk %@ for value %@ for %s\n",
657
+ new_chunk,
658
+ this,
659
+ this->val_tc_->id ()));
660
+
661
+ return true;
662
+ }
663
+ return false;
664
+ }
665
+
666
+ bool R2TAO_Value::add_chunk_element (CORBA::Any_var& elem)
667
+ {
668
+ if (this->last_chunk_ || this->add_chunk())
669
+ {
670
+ ChunkElements::size_type last_ix = this->last_chunk_->elems_.size ();
671
+ this->last_chunk_->elems_.size (last_ix+1);
672
+ this->last_chunk_->elems_[last_ix] = elem._retn ();
673
+
674
+ if (TAO_debug_level > 10)
675
+ ACE_DEBUG ((LM_INFO, "R2TAO (%P|%t) - R2TAO_Value::add_chunk: "
676
+ "added chunk %@ element %u for value %@ for %s\n",
677
+ this->last_chunk_,
678
+ last_ix,
679
+ this,
680
+ this->val_tc_->id ()));
681
+
682
+ return true;
683
+ }
684
+ return false;
685
+ }
686
+
687
+
688
+ ::CORBA::Boolean R2TAO_Value::_tao_unmarshal_v (TAO_InputCDR &strm)
689
+ {
690
+ static R2TAO_RBFuncall FN_unmarshal ("do_unmarshal", false);
691
+
692
+ if (!this->for_unmarshal_) return false;
693
+
694
+ // setup chunking info
695
+ TAO_ChunkInfo ci (this->is_truncatable_ || this->chunking_, 1);
696
+ // store info with Ruby value
697
+ CI_Guard __ci_guard(this->rbCIHolder_, &ci);
698
+
699
+ if (TAO_debug_level > 9)
700
+ ACE_DEBUG ((LM_INFO, "R2TAO (%P|%t) - R2TAO_Value::_tao_unmarshal_v: "
701
+ "unmarshaling value %@ for %s\n",
702
+ this->rbValue_,
703
+ this->val_tc_->id ()));
704
+
705
+ if (!ci.handle_chunking (strm))
706
+ return false;
707
+
708
+ // invoke Ruby Value unmarshaling
709
+ VALUE rargs = rb_ary_new2 (1);
710
+ rb_ary_push (rargs, r2tao_InputStream_t2r (&strm));
711
+
712
+ if (TAO_debug_level > 10)
713
+ ACE_DEBUG ((LM_INFO, "R2TAO (%P|%t) - R2TAO_Value::_tao_unmarshal_v: "
714
+ "invoking Ruby unmarshaling for value %@ for %s\n",
715
+ this->rbValue_,
716
+ this->val_tc_->id ()));
717
+
718
+ FN_unmarshal.invoke (this->rbValue_, rargs);
719
+ if (FN_unmarshal.has_caught_exception ())
720
+ {
721
+ rb_eval_string ("STDERR.puts $!.to_s+\"\\n\"+$!.backtrace.join(\"\\n\")");
722
+ return false;
723
+ }
724
+
725
+ if (TAO_debug_level > 10)
726
+ ACE_DEBUG ((LM_INFO, "R2TAO (%P|%t) - R2TAO_Value::_tao_unmarshal_v: "
727
+ "succeeded unmarshaling value %@ for %s %s\n",
728
+ this->rbValue_,
729
+ this->val_tc_->id (),
730
+ this->requires_truncation_ ? "(with truncation)" : ""));
731
+
732
+ if (this->requires_truncation_)
733
+ return ci.skip_chunks (strm);
734
+ else
735
+ return ci.handle_chunking (strm);
736
+ }
737
+
738
+ // always return false -> i.e. always marshal type Id
739
+ ::CORBA::Boolean R2TAO_Value::_tao_match_formal_type (ptrdiff_t ) const
740
+ {
741
+ return 0;
742
+ }
743
+
744
+ void operator<<= (::CORBA::Any & _tao_any, R2TAO_Value_ptr _tao_elem)
745
+ {
746
+ ::CORBA::add_ref (_tao_elem);
747
+ _tao_any <<= &_tao_elem;
748
+ }
749
+ void operator<<= (::CORBA::Any & _tao_any, R2TAO_Value_ptr * _tao_elem)
750
+ {
751
+ TAO::Any_Impl_T<R2TAO_Value>::insert (
752
+ _tao_any,
753
+ R2TAO_Value::_tao_any_destructor,
754
+ (*_tao_elem)->_tao_type (),
755
+ *_tao_elem);
756
+ }
757
+
758
+ ::CORBA::Boolean operator<< (TAO_OutputCDR &strm, const R2TAO_Value * _tao_valref)
759
+ {
760
+ // check for existence of TAO valuetype indirection map
761
+ if (!strm.get_value_map ().is_nil ())
762
+ {
763
+ // keep map clear effectively disabling indirection
764
+ // because this does not work with R2TAO Value objects
765
+ strm.get_value_map ()->get ()->unbind_all ();
766
+ }
767
+
768
+ return
769
+ ::CORBA::ValueBase::_tao_marshal (
770
+ strm,
771
+ _tao_valref,
772
+ reinterpret_cast<ptrdiff_t> (&R2TAO_Value::_downcast)
773
+ );
774
+ }
775
+
776
+ ::CORBA::Boolean operator>> (TAO_InputCDR &strm, R2TAO_Value *&_tao_valref)
777
+ {
778
+ CORBA::ValueBase * _tao_valbase = _tao_valref;
779
+ ::CORBA::Boolean ret = R2TAO_Value::_tao_unmarshal (strm, _tao_valbase);
780
+ _tao_valref = dynamic_cast <R2TAO_Value*> (_tao_valbase);
781
+ return ret;
782
+ }
783
+
784
+ void TAO::Value_Traits<R2TAO_Value>::add_ref (R2TAO_Value * p)
785
+ {
786
+ ::CORBA::add_ref (p);
787
+ }
788
+
789
+ void TAO::Value_Traits<R2TAO_Value>::remove_ref (R2TAO_Value * p)
790
+ {
791
+ ::CORBA::remove_ref (p);
792
+ }
793
+
794
+ void TAO::Value_Traits<R2TAO_Value>::release (R2TAO_Value * p)
795
+ {
796
+ ::CORBA::remove_ref (p);
797
+ }
798
+
799
+ VALUE r2tao_wrap_Valuebox(VALUE rval, CORBA::TypeCode_ptr tc)
800
+ {
801
+ static ID set_value_ID = rb_intern ("value=");
802
+
803
+ CORBA::ValueFactory factory =
804
+ TAO_ORB_Core_instance ()->orb ()->lookup_value_factory (
805
+ tc->id ());
806
+ if (factory)
807
+ {
808
+ CORBA::ValueBase * vb = factory->create_for_unmarshal ();
809
+ R2TAO_Value_var r2tval = R2TAO_Value::_downcast (vb);
810
+ factory->_remove_ref (); // we're done with this
811
+ rb_funcall (r2tval->get_ruby_value(), set_value_ID, 1, rval);
812
+ return r2tval->get_ruby_value();
813
+ }
814
+ else
815
+ {
816
+ throw CORBA::BAD_PARAM();
817
+ }
818
+ }
819
+
820
+ //-------------------------------------------------------------------
821
+ // R2TAO Value methods
822
+ //
823
+ //===================================================================
824
+
825
+ VALUE r2tao_Value_pre_marshal(VALUE /*self*/, VALUE rstrm)
826
+ {
827
+ R2TAO_Value* val = r2tao_OutputStream_r2t(rstrm);
828
+
829
+ if (!val->add_chunk ())
830
+ X_CORBA (MARSHAL);
831
+
832
+ return Qtrue;
833
+ }
834
+
835
+ VALUE r2tao_Value_post_marshal(VALUE /*self*/, VALUE /*rstrm*/)
836
+ {
837
+ return Qtrue;
838
+ }
839
+
840
+ VALUE r2tao_Value_pre_unmarshal(VALUE self, VALUE rstrm)
841
+ {
842
+ // get reference holder for native value
843
+ VALUE rb_val = rb_ivar_get (self, val_ivar_ID);
844
+ // get native Value
845
+ R2TAO_Value* val = static_cast<R2TAO_Value*> (DATA_PTR (rb_val));
846
+
847
+ if (TAO_debug_level > 10)
848
+ ACE_DEBUG ((LM_INFO, "R2TAO (%P|%t) - R2CORBA::CORBA::ValueBase::pre_unmarshal: "
849
+ "unmarshaling value state for %@ %s\n",
850
+ self,
851
+ val->requires_truncation () ? "with truncation" : ""));
852
+
853
+ // get ChunkInfo holder
854
+ VALUE rb_ci = rb_ivar_get (self, ci_ivar_ID);
855
+ // get ChunkInfo
856
+ TAO_ChunkInfo &ci = *static_cast<TAO_ChunkInfo*> (DATA_PTR (rb_ci));
857
+
858
+ TAO_InputCDR& strm = *r2tao_InputStream_r2t(rstrm);
859
+
860
+ if (val->has_started_chunk_unmarshalling ())
861
+ {
862
+ if (TAO_debug_level > 10)
863
+ ACE_DEBUG ((LM_INFO, "R2TAO (%P|%t) - R2CORBA::CORBA::ValueBase::pre_unmarshal: "
864
+ "finish unmarshalling previous value state chunk for %@\n",
865
+ self));
866
+ // need to finish the previous chunk unmarshalling
867
+ if (!ci.handle_chunking (strm))
868
+ X_CORBA (MARSHAL);
869
+
870
+ val->ended_chunk_unmarshalling ();
871
+ }
872
+
873
+ // start next chunk
874
+ if (!ci.handle_chunking (strm))
875
+ X_CORBA (MARSHAL);
876
+
877
+ val->started_chunk_unmarshalling ();
878
+
879
+ return Qtrue;
880
+ }
881
+
882
+ VALUE r2tao_Value_post_unmarshal(VALUE /*self*/, VALUE /*rstrm*/)
883
+ {
884
+ return Qtrue;
885
+ }
886
+
887
+ //-------------------------------------------------------------------
888
+ // R2TAO Valuefactory class
889
+ //
890
+ // Wrapper class for reference to R2CORBA valuefactory instance
891
+ //===================================================================
892
+
893
+ R2TAO_RBFuncall R2TAO_ValueFactory::fn_create_default_ ("_create_default", false);
894
+
895
+ R2TAO_ValueFactory::R2TAO_ValueFactory (VALUE rbValueFactory)
896
+ : rbValueFactory_ (rbValueFactory)
897
+ {
898
+ r2tao_register_object (this->rbValueFactory_);
899
+ }
900
+
901
+ R2TAO_ValueFactory::~R2TAO_ValueFactory (void)
902
+ {
903
+ r2tao_unregister_object (this->rbValueFactory_);
904
+ }
905
+
906
+ R2TAO_ValueFactory* R2TAO_ValueFactory::_downcast ( ::CORBA::ValueFactoryBase * vfb)
907
+ {
908
+ return dynamic_cast <R2TAO_ValueFactory*> (vfb);
909
+ }
910
+
911
+ ::CORBA::ValueBase * R2TAO_ValueFactory::create_for_unmarshal (void)
912
+ {
913
+ // create new Ruby Value
914
+ VALUE rval = fn_create_default_.invoke (this->rbValueFactory_);
915
+ if (fn_create_default_.has_caught_exception ())
916
+ {
917
+ rb_eval_string ("STDERR.puts $!.to_s+\"\\n\"+$!.backtrace.join(\"\\n\")");
918
+ return 0;
919
+ }
920
+
921
+ R2TAO_Value *ret_val = 0;
922
+ ACE_NEW_THROW_EX (
923
+ ret_val,
924
+ R2TAO_Value (rval, true),
925
+ ::CORBA::NO_MEMORY ()
926
+ );
927
+
928
+ if (TAO_debug_level > 9)
929
+ ACE_DEBUG ((LM_INFO, "R2TAO (%P|%t) - R2TAO_ValueFactory::create_for_unmarshal: "
930
+ "created value wrapper %@ for %s\n",
931
+ ret_val,
932
+ this->tao_repository_id ()));
933
+
934
+ return ret_val;
935
+ }
936
+
937
+ ::CORBA::AbstractBase_ptr R2TAO_ValueFactory::create_for_unmarshal_abstract (void)
938
+ {
939
+ // create new Ruby Value
940
+ VALUE rval = fn_create_default_.invoke (this->rbValueFactory_);
941
+ if (fn_create_default_.has_caught_exception ())
942
+ {
943
+ rb_eval_string ("STDERR.puts $!.to_s+\"\\n\"+$!.backtrace.join(\"\\n\")");
944
+ return 0;
945
+ }
946
+
947
+ // create without 'abs_tc' below since this object will not be
948
+ // used for marshaling but only for unmarshaling
949
+ // through a call to _tao_unmarshal_v()
950
+ R2TAO_AbstractValue *ret_val = 0;
951
+ ACE_NEW_THROW_EX (
952
+ ret_val,
953
+ R2TAO_AbstractValue (rval),
954
+ ::CORBA::NO_MEMORY ()
955
+ );
956
+ return ret_val;
957
+ }
958
+
959
+ // TAO-specific extensions
960
+ const char* R2TAO_ValueFactory::tao_repository_id (void)
961
+ {
962
+ static ID value_id_ID = rb_intern ("value_id");
963
+
964
+ VALUE id = rb_funcall (this->rbValueFactory_, value_id_ID, 0);
965
+ CHECK_RTYPE (id, T_STRING);
966
+ return RSTRING_PTR (id);
967
+ }
968
+
969
+ VALUE r2tao_VFB_register_value_factory(VALUE /*self*/, VALUE id, VALUE rfact)
970
+ {
971
+ #if !defined(CORBA_E_MICRO)
972
+ R2TAO_TRY {
973
+ CHECK_RTYPE (id, T_STRING);
974
+ if (rb_obj_is_kind_of (rfact, r2tao_cValueFactoryBase) != Qtrue)
975
+ {
976
+ throw CORBA::BAD_PARAM (0, CORBA::COMPLETED_NO);
977
+ }
978
+
979
+ if (TAO_debug_level > 5)
980
+ ACE_DEBUG ((LM_INFO, "R2TAO (%P|%t) - ValueFactoryBase::register_value_factory:: "
981
+ "registering factory for %s\n",
982
+ RSTRING_PTR (id)));
983
+
984
+ CORBA::ValueFactory factory = new R2TAO_ValueFactory (rfact);
985
+ CORBA::ValueFactory prev_factory =
986
+ TAO_ORB_Core_instance ()->orb ()->register_value_factory (
987
+ RSTRING_PTR (id),
988
+ factory);
989
+ if (prev_factory) prev_factory->_remove_ref ();
990
+ factory->_remove_ref ();
991
+ } R2TAO_CATCH;
992
+ #else
993
+ X_CORBA(NO_IMPLEMENT);
994
+ #endif
995
+ return Qnil;
996
+ }
997
+
998
+ VALUE r2tao_VFB_unregister_value_factory(VALUE /*self*/, VALUE id)
999
+ {
1000
+ #if !defined(CORBA_E_MICRO)
1001
+ R2TAO_TRY {
1002
+ CHECK_RTYPE (id, T_STRING);
1003
+
1004
+ if (TAO_debug_level > 5)
1005
+ ACE_DEBUG ((LM_INFO, "R2TAO (%P|%t) - ORB::unregister_value_factory:: "
1006
+ "unregistering factory for %s\n",
1007
+ RSTRING_PTR (id)));
1008
+
1009
+ TAO_ORB_Core_instance ()->orb ()->unregister_value_factory (
1010
+ RSTRING_PTR (id));
1011
+ } R2TAO_CATCH;
1012
+ #else
1013
+ X_CORBA(NO_IMPLEMENT);
1014
+ #endif
1015
+ return Qnil;
1016
+ }
1017
+
1018
+ VALUE r2tao_VFB_lookup_value_factory(VALUE /*self*/, VALUE id)
1019
+ {
1020
+ VALUE ret = Qnil;
1021
+ #if !defined(CORBA_E_MICRO)
1022
+ R2TAO_TRY {
1023
+ CHECK_RTYPE (id, T_STRING);
1024
+
1025
+ if (TAO_debug_level > 5)
1026
+ ACE_DEBUG ((LM_INFO, "R2TAO (%P|%t) - ORB::lookup_value_factory:: "
1027
+ "looking up factory for %s\n",
1028
+ RSTRING_PTR (id)));
1029
+
1030
+ CORBA::ValueFactory factory =
1031
+ TAO_ORB_Core_instance ()->orb ()->lookup_value_factory (
1032
+ RSTRING_PTR (id));
1033
+ if (factory)
1034
+ {
1035
+ R2TAO_ValueFactory* r2tfact = dynamic_cast <R2TAO_ValueFactory*> (factory);
1036
+ ret = r2tfact->get_ruby_factory();
1037
+ factory->_remove_ref ();
1038
+ }
1039
+ } R2TAO_CATCH;
1040
+ #else
1041
+ X_CORBA(NO_IMPLEMENT);
1042
+ #endif
1043
+ return ret;
1044
+ }
1045
+
1046
+ //-------------------------------------------------------------------
1047
+ // R2TAO AbstractValue class
1048
+ //
1049
+ // Wrapper class for value type to present CORBA::AbstractBase
1050
+ // interface to TAO Any
1051
+ //===================================================================
1052
+
1053
+ R2TAO_AbstractValue::R2TAO_AbstractValue (VALUE rbValue,
1054
+ CORBA::TypeCode_ptr abs_tc)
1055
+ : ::CORBA::AbstractBase (),
1056
+ R2TAO_Value (rbValue),
1057
+ abs_tc_ (CORBA::TypeCode::_duplicate (abs_tc))
1058
+ {
1059
+ }
1060
+
1061
+ R2TAO_AbstractValue::R2TAO_AbstractValue (VALUE rbValue)
1062
+ : ::CORBA::AbstractBase (),
1063
+ R2TAO_Value (rbValue, true)
1064
+ {
1065
+ }
1066
+
1067
+ R2TAO_AbstractValue::~R2TAO_AbstractValue ()
1068
+ {
1069
+ }
1070
+
1071
+ void R2TAO_AbstractValue::_tao_any_destructor (void *_tao_void_pointer)
1072
+ {
1073
+ R2TAO_AbstractValue *_tao_tmp_pointer =
1074
+ static_cast<R2TAO_AbstractValue *> (_tao_void_pointer);
1075
+ ::CORBA::remove_ref (_tao_tmp_pointer);
1076
+ }
1077
+
1078
+ R2TAO_AbstractValue_ptr R2TAO_AbstractValue::_duplicate (R2TAO_AbstractValue_ptr obj)
1079
+ {
1080
+ if (! ::CORBA::is_nil (obj))
1081
+ {
1082
+ obj->_add_ref ();
1083
+ }
1084
+
1085
+ return obj;
1086
+ }
1087
+
1088
+ R2TAO_AbstractValue* R2TAO_AbstractValue::_downcast ( ::CORBA::ValueBase *v)
1089
+ {
1090
+ return dynamic_cast< ::R2TAO_AbstractValue * > (v);
1091
+ }
1092
+
1093
+ const char* R2TAO_AbstractValue::_tao_obv_repository_id (void) const
1094
+ {
1095
+ return this->R2TAO_Value::_tao_obv_repository_id ();
1096
+ }
1097
+ CORBA::Boolean R2TAO_AbstractValue::_tao_marshal_v (TAO_OutputCDR &strm) const
1098
+ {
1099
+ return this->R2TAO_Value::_tao_marshal_v (strm);
1100
+ }
1101
+ CORBA::Boolean R2TAO_AbstractValue::_tao_unmarshal_v (TAO_InputCDR &strm)
1102
+ {
1103
+ return this->R2TAO_Value::_tao_unmarshal_v (strm);
1104
+ }
1105
+ CORBA::Boolean R2TAO_AbstractValue::_tao_match_formal_type (ptrdiff_t p) const
1106
+ {
1107
+ return this->R2TAO_Value::_tao_match_formal_type (p);
1108
+ }
1109
+
1110
+ void R2TAO_AbstractValue::_add_ref (void)
1111
+ {
1112
+ this->::CORBA::DefaultValueRefCountBase::_add_ref ();
1113
+ }
1114
+
1115
+ void R2TAO_AbstractValue::_remove_ref (void)
1116
+ {
1117
+ this->::CORBA::DefaultValueRefCountBase::_remove_ref ();
1118
+ }
1119
+
1120
+ ::CORBA::ValueBase *R2TAO_AbstractValue::_tao_to_value (void)
1121
+ {
1122
+ return this;
1123
+ }
1124
+
1125
+ CORBA::TypeCode_ptr R2TAO_AbstractValue::abstract_type () const
1126
+ {
1127
+ return this->abs_tc_.in ();
1128
+ }
1129
+
1130
+ void operator<<= (::CORBA::Any & _tao_any, R2TAO_AbstractValue_ptr _tao_elem)
1131
+ {
1132
+ R2TAO_AbstractValue_ptr _tao_valptr =
1133
+ R2TAO_AbstractValue::_duplicate (_tao_elem);
1134
+ _tao_any <<= &_tao_valptr;
1135
+ }
1136
+ void operator<<= (::CORBA::Any & _tao_any, R2TAO_AbstractValue_ptr * _tao_elem)
1137
+ {
1138
+ TAO::Any_Impl_T<R2TAO_AbstractValue>::insert (
1139
+ _tao_any,
1140
+ R2TAO_AbstractValue::_tao_any_destructor,
1141
+ (*_tao_elem)->abstract_type (),
1142
+ *_tao_elem);
1143
+ }
1144
+
1145
+ ::CORBA::Boolean operator<< (TAO_OutputCDR &strm, const R2TAO_AbstractValue_ptr _tao_valref)
1146
+ {
1147
+ ::CORBA::AbstractBase_ptr _tao_corba_abs = _tao_valref;
1148
+ return (strm << _tao_corba_abs);
1149
+ }
1150
+
1151
+ // Dummy to allow compilation of Any_Impl_T<R2TAO_AbstractValue> template instantiation.
1152
+ // We never use the extraction code of that template though.
1153
+ ::CORBA::Boolean operator>> (TAO_InputCDR &/*strm*/, R2TAO_AbstractValue_ptr &/*_tao_objref*/)
1154
+ {
1155
+ return false;
1156
+ }
1157
+
1158
+ R2TAO_AbstractValue_ptr
1159
+ TAO::Objref_Traits<R2TAO_AbstractValue>::duplicate (
1160
+ R2TAO_AbstractValue_ptr p)
1161
+ {
1162
+ return R2TAO_AbstractValue::_duplicate (p);
1163
+ }
1164
+
1165
+ void
1166
+ TAO::Objref_Traits<R2TAO_AbstractValue>::release (
1167
+ R2TAO_AbstractValue_ptr p)
1168
+ {
1169
+ ::CORBA::release (p);
1170
+ }
1171
+
1172
+ R2TAO_AbstractValue_ptr
1173
+ TAO::Objref_Traits<R2TAO_AbstractValue>::nil (void)
1174
+ {
1175
+ return 0;
1176
+ }
1177
+
1178
+ ::CORBA::Boolean
1179
+ TAO::Objref_Traits<R2TAO_AbstractValue>::marshal (
1180
+ const R2TAO_AbstractValue_ptr p,
1181
+ TAO_OutputCDR & cdr)
1182
+ {
1183
+ return cdr << p;
1184
+ }
1185
+
1186
+ //-------------------------------------------------------------------
1187
+ // R2TAO AbstractObject class
1188
+ //
1189
+ // Wrapper class for object reference to present CORBA::AbstractBase
1190
+ // interface to TAO Any
1191
+ //===================================================================
1192
+
1193
+ R2TAO_AbstractObject::R2TAO_AbstractObject (CORBA::Object_ptr objref,
1194
+ CORBA::TypeCode_ptr abs_tc)
1195
+ : CORBA::AbstractBase (objref->_stubobj(),
1196
+ objref->_is_collocated(),
1197
+ objref->_is_collocated() ? objref->_stubobj()->collocated_servant () : 0),
1198
+ CORBA::Object (),
1199
+ abs_tc_ (CORBA::TypeCode::_duplicate (abs_tc))
1200
+ {
1201
+ }
1202
+
1203
+ R2TAO_AbstractObject::~R2TAO_AbstractObject ()
1204
+ {
1205
+ }
1206
+
1207
+ void CORBA::release (R2TAO_AbstractObject_ptr p)
1208
+ {
1209
+ ::CORBA::AbstractBase_ptr abs = p;
1210
+ ::CORBA::release (abs);
1211
+ }
1212
+
1213
+ ::CORBA::Boolean CORBA::is_nil (R2TAO_AbstractObject_ptr p)
1214
+ {
1215
+ ::CORBA::Object_ptr obj = p;
1216
+ return ::CORBA::is_nil (obj);
1217
+ }
1218
+
1219
+ void R2TAO_AbstractObject::_tao_any_destructor (void *_tao_void_pointer)
1220
+ {
1221
+ R2TAO_AbstractObject *_tao_tmp_pointer =
1222
+ static_cast<R2TAO_AbstractObject *> (_tao_void_pointer);
1223
+ ::CORBA::release (_tao_tmp_pointer);
1224
+ }
1225
+
1226
+ R2TAO_AbstractObject_ptr R2TAO_AbstractObject::_duplicate (R2TAO_AbstractObject_ptr obj)
1227
+ {
1228
+ if (! ::CORBA::is_nil (obj))
1229
+ {
1230
+ obj->_add_ref ();
1231
+ }
1232
+
1233
+ return obj;
1234
+ }
1235
+
1236
+ void R2TAO_AbstractObject::_tao_release (R2TAO_AbstractObject_ptr obj)
1237
+ {
1238
+ ::CORBA::release (obj);
1239
+ }
1240
+
1241
+ void R2TAO_AbstractObject::_add_ref (void)
1242
+ {
1243
+ this->::CORBA::Object::_add_ref();
1244
+ }
1245
+ void R2TAO_AbstractObject::_remove_ref (void)
1246
+ {
1247
+ this->::CORBA::Object::_remove_ref();
1248
+ }
1249
+
1250
+ ::CORBA::Boolean R2TAO_AbstractObject::_is_a (const char *type_id)
1251
+ {
1252
+ return this->::CORBA::AbstractBase::_is_a (type_id) ||
1253
+ ACE_OS::strcmp (type_id,
1254
+ "IDL:omg.org/CORBA/Object:1.0") == 0 ||
1255
+ this->::CORBA::Object::_is_a (type_id);
1256
+ }
1257
+
1258
+ const char* R2TAO_AbstractObject::_interface_repository_id (void) const
1259
+ {
1260
+ return this->abs_tc_->id ();
1261
+ }
1262
+
1263
+ ::CORBA::Boolean R2TAO_AbstractObject::marshal (TAO_OutputCDR &cdr)
1264
+ {
1265
+ return (cdr << (::CORBA::AbstractBase_ptr)this);
1266
+ }
1267
+
1268
+ CORBA::TypeCode_ptr R2TAO_AbstractObject::abstract_type () const
1269
+ {
1270
+ return this->abs_tc_.in ();
1271
+ }
1272
+
1273
+ void operator<<= (::CORBA::Any & _tao_any, R2TAO_AbstractObject_ptr _tao_elem)
1274
+ {
1275
+ R2TAO_AbstractObject_ptr _tao_objptr =
1276
+ R2TAO_AbstractObject::_duplicate (_tao_elem);
1277
+ _tao_any <<= &_tao_objptr;
1278
+ }
1279
+ void operator<<= (::CORBA::Any & _tao_any, R2TAO_AbstractObject_ptr * _tao_elem)
1280
+ {
1281
+ TAO::Any_Impl_T<R2TAO_AbstractObject>::insert (
1282
+ _tao_any,
1283
+ R2TAO_AbstractObject::_tao_any_destructor,
1284
+ (*_tao_elem)->abstract_type (),
1285
+ *_tao_elem);
1286
+ }
1287
+
1288
+ ::CORBA::Boolean operator<< (TAO_OutputCDR &strm, const R2TAO_AbstractObject_ptr _tao_objref)
1289
+ {
1290
+ ::CORBA::AbstractBase_ptr _tao_corba_obj = _tao_objref;
1291
+ return (strm << _tao_corba_obj);
1292
+ }
1293
+
1294
+ // Dummy to allow compilation of Any_Impl_T<R2TAO_AbstractObject> template instantiation.
1295
+ // We never use the extraction code of that template though.
1296
+ ::CORBA::Boolean operator>> (TAO_InputCDR &/*strm*/, R2TAO_AbstractObject_ptr &/*_tao_objref*/)
1297
+ {
1298
+ return false;
1299
+ }
1300
+
1301
+ R2TAO_AbstractObject_ptr
1302
+ TAO::Objref_Traits<R2TAO_AbstractObject>::duplicate (
1303
+ R2TAO_AbstractObject_ptr p)
1304
+ {
1305
+ return R2TAO_AbstractObject::_duplicate (p);
1306
+ }
1307
+
1308
+ void
1309
+ TAO::Objref_Traits<R2TAO_AbstractObject>::release (
1310
+ R2TAO_AbstractObject_ptr p)
1311
+ {
1312
+ ::CORBA::release (p);
1313
+ }
1314
+
1315
+ R2TAO_AbstractObject_ptr
1316
+ TAO::Objref_Traits<R2TAO_AbstractObject>::nil (void)
1317
+ {
1318
+ return 0;
1319
+ }
1320
+
1321
+ ::CORBA::Boolean
1322
+ TAO::Objref_Traits<R2TAO_AbstractObject>::marshal (
1323
+ const R2TAO_AbstractObject_ptr p,
1324
+ TAO_OutputCDR & cdr)
1325
+ {
1326
+ return cdr << p;
1327
+ }
1328
+
1329
+ //-------------------------------------------------------------------
1330
+ // R2TAO Stream methods
1331
+ //
1332
+ //===================================================================
1333
+
1334
+ // wrapping & unwrapping
1335
+
1336
+ static VALUE
1337
+ r2tao_InputStream_t2r(TAO_InputCDR* strm)
1338
+ {
1339
+ VALUE ret;
1340
+
1341
+ ret = Data_Wrap_Struct(r2tao_cInputStream, 0, 0, strm);
1342
+
1343
+ return ret;
1344
+ }
1345
+
1346
+ static VALUE
1347
+ r2tao_OutputStream_t2r(R2TAO_Value* val)
1348
+ {
1349
+ VALUE ret;
1350
+
1351
+ ret = Data_Wrap_Struct(r2tao_cOutputStream, 0, 0, val);
1352
+
1353
+ return ret;
1354
+ }
1355
+
1356
+ static TAO_InputCDR*
1357
+ r2tao_InputStream_r2t(VALUE strm)
1358
+ {
1359
+ TAO_InputCDR *ret;
1360
+
1361
+ Data_Get_Struct(strm, TAO_InputCDR, ret);
1362
+
1363
+ return ret;
1364
+ }
1365
+
1366
+ static R2TAO_Value*
1367
+ r2tao_OutputStream_r2t(VALUE strm)
1368
+ {
1369
+ R2TAO_Value *ret;
1370
+
1371
+ Data_Get_Struct(strm, R2TAO_Value, ret);
1372
+
1373
+ return ret;
1374
+ }
1375
+
1376
+ // ------------------------------------------------------------------
1377
+ // OutputStream
1378
+
1379
+ VALUE r2tao_OStream_write_any (VALUE self, VALUE rval)
1380
+ {
1381
+ R2TAO_Value* vt = r2tao_OutputStream_r2t(self);
1382
+ R2TAO_TRY {
1383
+ if (NIL_P (rval))
1384
+ {
1385
+ if (TAO_debug_level > 0)
1386
+ ACE_DEBUG ((LM_ERROR, "R2TAO (%P|%t) - OutputStream#write_any:: "
1387
+ "NIL value not allowed\n"));
1388
+ throw CORBA::MARSHAL ();
1389
+ }
1390
+ CORBA::Any* any = 0;
1391
+ ACE_NEW_THROW_EX (any,
1392
+ CORBA::Any (),
1393
+ CORBA::NO_MEMORY());
1394
+ CORBA::Any_var any_safe = any;
1395
+ r2tao_Ruby_to_Any(*any, rval);
1396
+ if (!vt->add_chunk_element (any_safe))
1397
+ throw CORBA::MARSHAL ();
1398
+ } R2TAO_CATCH;
1399
+ return Qnil;
1400
+ }
1401
+
1402
+ VALUE r2tao_OStream_write_boolean (VALUE self, VALUE rval)
1403
+ {
1404
+ R2TAO_Value* vt = r2tao_OutputStream_r2t(self);
1405
+ R2TAO_TRY {
1406
+ CORBA::Any* any = 0;
1407
+ ACE_NEW_THROW_EX (any,
1408
+ CORBA::Any (),
1409
+ CORBA::NO_MEMORY());
1410
+ CORBA::Any_var any_safe = any;
1411
+ CORBA::Boolean f = (NIL_P (rval) || rval == Qfalse) ? 0 : 1;
1412
+ *any <<= CORBA::Any::from_boolean (f);
1413
+ if (!vt->add_chunk_element (any_safe))
1414
+ throw CORBA::MARSHAL ();
1415
+ } R2TAO_CATCH;
1416
+ return Qnil;
1417
+ }
1418
+
1419
+ VALUE r2tao_OStream_write_char (VALUE self, VALUE rval)
1420
+ {
1421
+ R2TAO_Value* vt = r2tao_OutputStream_r2t(self);
1422
+ R2TAO_TRY {
1423
+ CORBA::Any* any = 0;
1424
+ ACE_NEW_THROW_EX (any,
1425
+ CORBA::Any (),
1426
+ CORBA::NO_MEMORY());
1427
+ CORBA::Any_var any_safe = any;
1428
+ CORBA::Char ch = 0;
1429
+ if (!NIL_P (rval))
1430
+ {
1431
+ CHECK_RTYPE(rval, T_STRING);
1432
+ ch = *RSTRING_PTR (rval);
1433
+ }
1434
+ *any <<= CORBA::Any::from_char (ch);
1435
+ if (!vt->add_chunk_element (any_safe))
1436
+ throw CORBA::MARSHAL ();
1437
+ } R2TAO_CATCH;
1438
+ return Qnil;
1439
+ }
1440
+
1441
+ VALUE r2tao_OStream_write_wchar (VALUE self, VALUE rval)
1442
+ {
1443
+ R2TAO_Value* vt = r2tao_OutputStream_r2t(self);
1444
+ R2TAO_TRY {
1445
+ CORBA::Any* any = 0;
1446
+ ACE_NEW_THROW_EX (any,
1447
+ CORBA::Any (),
1448
+ CORBA::NO_MEMORY());
1449
+ CORBA::Any_var any_safe = any;
1450
+ CORBA::WChar wc = NIL_P (rval) ? 0 : NUM2UINT (rval);
1451
+ *any <<= CORBA::Any::from_wchar (wc);
1452
+ if (!vt->add_chunk_element (any_safe))
1453
+ throw CORBA::MARSHAL ();
1454
+ } R2TAO_CATCH;
1455
+ return Qnil;
1456
+ }
1457
+
1458
+ VALUE r2tao_OStream_write_octet (VALUE self, VALUE rval)
1459
+ {
1460
+ R2TAO_Value* vt = r2tao_OutputStream_r2t(self);
1461
+ R2TAO_TRY {
1462
+ CORBA::Any* any = 0;
1463
+ ACE_NEW_THROW_EX (any,
1464
+ CORBA::Any (),
1465
+ CORBA::NO_MEMORY());
1466
+ CORBA::Any_var any_safe = any;
1467
+ CORBA::Octet byte = NIL_P (rval) ? 0 : NUM2UINT (rval);
1468
+ *any <<= CORBA::Any::from_octet (byte);
1469
+ if (!vt->add_chunk_element (any_safe))
1470
+ throw CORBA::MARSHAL ();
1471
+ } R2TAO_CATCH;
1472
+ return Qnil;
1473
+ }
1474
+
1475
+ VALUE r2tao_OStream_write_short (VALUE self, VALUE rval)
1476
+ {
1477
+ R2TAO_Value* vt = r2tao_OutputStream_r2t(self);
1478
+ R2TAO_TRY {
1479
+ CORBA::Any* any = 0;
1480
+ ACE_NEW_THROW_EX (any,
1481
+ CORBA::Any (),
1482
+ CORBA::NO_MEMORY());
1483
+ CORBA::Any_var any_safe = any;
1484
+ CORBA::Short sh = NIL_P (rval) ? 0 : NUM2INT (rval);
1485
+ *any <<= sh;
1486
+ if (!vt->add_chunk_element (any_safe))
1487
+ throw CORBA::MARSHAL ();
1488
+ } R2TAO_CATCH;
1489
+ return Qnil;
1490
+ }
1491
+
1492
+ VALUE r2tao_OStream_write_ushort (VALUE self, VALUE rval)
1493
+ {
1494
+ R2TAO_Value* vt = r2tao_OutputStream_r2t(self);
1495
+ R2TAO_TRY {
1496
+ CORBA::Any* any = 0;
1497
+ ACE_NEW_THROW_EX (any,
1498
+ CORBA::Any (),
1499
+ CORBA::NO_MEMORY());
1500
+ CORBA::Any_var any_safe = any;
1501
+ CORBA::UShort ush = NIL_P (rval) ? 0 : NUM2UINT (rval);
1502
+ *any <<= ush;
1503
+ if (!vt->add_chunk_element (any_safe))
1504
+ throw CORBA::MARSHAL ();
1505
+ } R2TAO_CATCH;
1506
+ return Qnil;
1507
+ }
1508
+
1509
+ VALUE r2tao_OStream_write_long (VALUE self, VALUE rval)
1510
+ {
1511
+ R2TAO_Value* vt = r2tao_OutputStream_r2t(self);
1512
+ R2TAO_TRY {
1513
+ CORBA::Any* any = 0;
1514
+ ACE_NEW_THROW_EX (any,
1515
+ CORBA::Any (),
1516
+ CORBA::NO_MEMORY());
1517
+ CORBA::Any_var any_safe = any;
1518
+ CORBA::Long l = NIL_P (rval) ? 0 : NUM2LONG (rval);
1519
+ *any <<= l;
1520
+ if (!vt->add_chunk_element (any_safe))
1521
+ throw CORBA::MARSHAL ();
1522
+ } R2TAO_CATCH;
1523
+ return Qnil;
1524
+ }
1525
+
1526
+ VALUE r2tao_OStream_write_ulong (VALUE self, VALUE rval)
1527
+ {
1528
+ R2TAO_Value* vt = r2tao_OutputStream_r2t(self);
1529
+ R2TAO_TRY {
1530
+ CORBA::Any* any = 0;
1531
+ ACE_NEW_THROW_EX (any,
1532
+ CORBA::Any (),
1533
+ CORBA::NO_MEMORY());
1534
+ CORBA::Any_var any_safe = any;
1535
+ CORBA::ULong ul = NIL_P (rval) ? 0 : NUM2ULONG (rval);
1536
+ *any <<= ul;
1537
+ if (!vt->add_chunk_element (any_safe))
1538
+ throw CORBA::MARSHAL ();
1539
+ } R2TAO_CATCH;
1540
+ return Qnil;
1541
+ }
1542
+
1543
+ VALUE r2tao_OStream_write_longlong (VALUE self, VALUE rval)
1544
+ {
1545
+ R2TAO_Value* vt = r2tao_OutputStream_r2t(self);
1546
+ R2TAO_TRY {
1547
+ CORBA::Any* any = 0;
1548
+ ACE_NEW_THROW_EX (any,
1549
+ CORBA::Any (),
1550
+ CORBA::NO_MEMORY());
1551
+ CORBA::Any_var any_safe = any;
1552
+ CORBA::LongLong ll = NIL_P (rval) ? 0 : NUM2LL (rval);
1553
+ *any <<= ll;
1554
+ if (!vt->add_chunk_element (any_safe))
1555
+ throw CORBA::MARSHAL ();
1556
+ } R2TAO_CATCH;
1557
+ return Qnil;
1558
+ }
1559
+
1560
+ VALUE r2tao_OStream_write_ulonglong (VALUE self, VALUE rval)
1561
+ {
1562
+ R2TAO_Value* vt = r2tao_OutputStream_r2t(self);
1563
+ R2TAO_TRY {
1564
+ CORBA::Any* any = 0;
1565
+ ACE_NEW_THROW_EX (any,
1566
+ CORBA::Any (),
1567
+ CORBA::NO_MEMORY());
1568
+ CORBA::Any_var any_safe = any;
1569
+ CORBA::ULongLong ull = NIL_P (rval) ? 0 : NUM2ULL (rval);
1570
+ *any <<= ull;
1571
+ if (!vt->add_chunk_element (any_safe))
1572
+ throw CORBA::MARSHAL ();
1573
+ } R2TAO_CATCH;
1574
+ return Qnil;
1575
+ }
1576
+
1577
+ VALUE r2tao_OStream_write_float (VALUE self, VALUE rval)
1578
+ {
1579
+ R2TAO_Value* vt = r2tao_OutputStream_r2t(self);
1580
+ R2TAO_TRY {
1581
+ CORBA::Any* any = 0;
1582
+ ACE_NEW_THROW_EX (any,
1583
+ CORBA::Any (),
1584
+ CORBA::NO_MEMORY());
1585
+ CORBA::Any_var any_safe = any;
1586
+ CORBA::Float f = NIL_P (rval) ? 0.0f : (CORBA::Float)NUM2DBL (rval);
1587
+ *any <<= f;
1588
+ if (!vt->add_chunk_element (any_safe))
1589
+ throw CORBA::MARSHAL ();
1590
+ } R2TAO_CATCH;
1591
+ return Qnil;
1592
+ }
1593
+
1594
+ VALUE r2tao_OStream_write_double (VALUE self, VALUE rval)
1595
+ {
1596
+ R2TAO_Value* vt = r2tao_OutputStream_r2t(self);
1597
+ R2TAO_TRY {
1598
+ CORBA::Any* any = 0;
1599
+ ACE_NEW_THROW_EX (any,
1600
+ CORBA::Any (),
1601
+ CORBA::NO_MEMORY());
1602
+ CORBA::Any_var any_safe = any;
1603
+ CORBA::Double d = NIL_P (rval) ? 0.0 : NUM2DBL (rval);
1604
+ *any <<= d;
1605
+ if (!vt->add_chunk_element (any_safe))
1606
+ throw CORBA::MARSHAL ();
1607
+ } R2TAO_CATCH;
1608
+ return Qnil;
1609
+ }
1610
+
1611
+ VALUE r2tao_OStream_write_longdouble (VALUE self, VALUE rval)
1612
+ {
1613
+ R2TAO_Value* vt = r2tao_OutputStream_r2t(self);
1614
+ R2TAO_TRY {
1615
+ CORBA::Any* any = 0;
1616
+ ACE_NEW_THROW_EX (any,
1617
+ CORBA::Any (),
1618
+ CORBA::NO_MEMORY());
1619
+ CORBA::Any_var any_safe = any;
1620
+ CORBA::LongDouble ld;
1621
+ ACE_CDR_LONG_DOUBLE_ASSIGNMENT (ld, NIL_P (rval) ? 0.0 : RLD2CLD (rval));
1622
+ *any <<= ld;
1623
+ if (!vt->add_chunk_element (any_safe))
1624
+ throw CORBA::MARSHAL ();
1625
+ } R2TAO_CATCH;
1626
+ return Qnil;
1627
+ }
1628
+
1629
+ VALUE r2tao_OStream_write_Object (VALUE self, VALUE rval)
1630
+ {
1631
+ R2TAO_Value* vt = r2tao_OutputStream_r2t(self);
1632
+ R2TAO_TRY {
1633
+ CORBA::Any* any = 0;
1634
+ ACE_NEW_THROW_EX (any,
1635
+ CORBA::Any (),
1636
+ CORBA::NO_MEMORY());
1637
+ CORBA::Any_var any_safe = any;
1638
+ if (!NIL_P (rval))
1639
+ {
1640
+ *any <<= r2corba_Object_r2t (rval);
1641
+ }
1642
+ else
1643
+ {
1644
+ *any <<= CORBA::Object::_nil ();
1645
+ }
1646
+ if (!vt->add_chunk_element (any_safe))
1647
+ throw CORBA::MARSHAL ();
1648
+ } R2TAO_CATCH;
1649
+ return Qnil;
1650
+ }
1651
+
1652
+ VALUE r2tao_OStream_write_Abstract (VALUE self, VALUE rval)
1653
+ {
1654
+ R2TAO_Value* vt = r2tao_OutputStream_r2t(self);
1655
+ R2TAO_TRY {
1656
+ CORBA::Any* any = 0;
1657
+ ACE_NEW_THROW_EX (any,
1658
+ CORBA::Any (),
1659
+ CORBA::NO_MEMORY());
1660
+ CORBA::Any_var any_safe = any;
1661
+ if (rval == Qnil)
1662
+ {
1663
+ TAO::Any_Impl_T<CORBA::AbstractBase>::insert (
1664
+ *any,
1665
+ CORBA::AbstractBase::_tao_any_destructor,
1666
+ CORBA::TypeCode::_nil (), // irrelevant in this case
1667
+ 0);
1668
+ }
1669
+ else
1670
+ {
1671
+ r2tao_Ruby_to_Any(*any, rval);
1672
+ }
1673
+ if (!vt->add_chunk_element (any_safe))
1674
+ throw CORBA::MARSHAL ();
1675
+ } R2TAO_CATCH;
1676
+ return Qnil;
1677
+ }
1678
+
1679
+ VALUE r2tao_OStream_write_Value (VALUE self, VALUE rval)
1680
+ {
1681
+ R2TAO_Value* vt = r2tao_OutputStream_r2t(self);
1682
+ R2TAO_TRY {
1683
+ CORBA::Any* any = 0;
1684
+ ACE_NEW_THROW_EX (any,
1685
+ CORBA::Any (),
1686
+ CORBA::NO_MEMORY());
1687
+ CORBA::Any_var any_safe = any;
1688
+ if (rval == Qnil)
1689
+ {
1690
+ TAO::Any_Impl_T<R2TAO_Value>::insert (
1691
+ *any,
1692
+ R2TAO_Value::_tao_any_destructor,
1693
+ CORBA::TypeCode::_nil (), // irrelevant in this case
1694
+ 0);
1695
+ }
1696
+ else
1697
+ {
1698
+ r2tao_Ruby_to_Any(*any, rval);
1699
+ }
1700
+ if (!vt->add_chunk_element (any_safe))
1701
+ throw CORBA::MARSHAL ();
1702
+ } R2TAO_CATCH;
1703
+ return Qnil;
1704
+ }
1705
+
1706
+ VALUE r2tao_OStream_write_TypeCode (VALUE self, VALUE rval)
1707
+ {
1708
+ R2TAO_Value* vt = r2tao_OutputStream_r2t(self);
1709
+ R2TAO_TRY {
1710
+ CORBA::Any* any = 0;
1711
+ ACE_NEW_THROW_EX (any,
1712
+ CORBA::Any (),
1713
+ CORBA::NO_MEMORY());
1714
+ CORBA::Any_var any_safe = any;
1715
+ if (!NIL_P (rval))
1716
+ {
1717
+ CORBA::TypeCode_ptr tctc = r2corba_TypeCode_r2t (rval);
1718
+ *any <<= tctc;
1719
+ }
1720
+ else
1721
+ {
1722
+ *any <<= CORBA::TypeCode::_nil ();
1723
+ }
1724
+ if (!vt->add_chunk_element (any_safe))
1725
+ throw CORBA::MARSHAL ();
1726
+ } R2TAO_CATCH;
1727
+ return Qnil;
1728
+ }
1729
+
1730
+ VALUE r2tao_OStream_write_fixed (VALUE , VALUE )
1731
+ {
1732
+ X_CORBA (NO_IMPLEMENT);
1733
+ }
1734
+
1735
+ VALUE r2tao_OStream_write_string (VALUE self, VALUE rval)
1736
+ {
1737
+ R2TAO_Value* vt = r2tao_OutputStream_r2t(self);
1738
+ R2TAO_TRY {
1739
+ CORBA::Any* any = 0;
1740
+ ACE_NEW_THROW_EX (any,
1741
+ CORBA::Any (),
1742
+ CORBA::NO_MEMORY());
1743
+ CORBA::Any_var any_safe = any;
1744
+ if (NIL_P (rval))
1745
+ {
1746
+ *any <<= (char*)0;
1747
+ }
1748
+ else
1749
+ {
1750
+ CHECK_RTYPE(rval, T_STRING);
1751
+ *any <<= RSTRING_PTR (rval);
1752
+ }
1753
+ if (!vt->add_chunk_element (any_safe))
1754
+ throw CORBA::MARSHAL ();
1755
+ } R2TAO_CATCH;
1756
+ return Qnil;
1757
+ }
1758
+
1759
+ VALUE r2tao_OStream_write_wstring (VALUE self, VALUE rval)
1760
+ {
1761
+ R2TAO_Value* vt = r2tao_OutputStream_r2t(self);
1762
+ R2TAO_TRY {
1763
+ CORBA::Any* any = 0;
1764
+ ACE_NEW_THROW_EX (any,
1765
+ CORBA::Any (),
1766
+ CORBA::NO_MEMORY());
1767
+ CORBA::Any_var any_safe = any;
1768
+ if (NIL_P (rval))
1769
+ {
1770
+ *any <<= (CORBA::WChar*)0;
1771
+ }
1772
+ else
1773
+ {
1774
+ CHECK_RTYPE(rval, T_ARRAY);
1775
+ CORBA::ULong alen = static_cast<unsigned long> (RARRAY_LEN (rval));
1776
+ CORBA::WString_var ws = CORBA::wstring_alloc (alen+1);
1777
+ for (CORBA::ULong l=0; l<alen ;++l)
1778
+ {
1779
+ ws[l] = static_cast<CORBA::WChar> (NUM2INT (rb_ary_entry (rval, l)));
1780
+ }
1781
+ ws[alen] = static_cast<CORBA::WChar> (0);
1782
+ *any <<= ws;
1783
+ }
1784
+ if (!vt->add_chunk_element (any_safe))
1785
+ throw CORBA::MARSHAL ();
1786
+ } R2TAO_CATCH;
1787
+ return Qnil;
1788
+ }
1789
+
1790
+ VALUE r2tao_OStream_write_any_array (VALUE self, VALUE rval, VALUE offset, VALUE length)
1791
+ {
1792
+ R2TAO_Value* vt = r2tao_OutputStream_r2t(self);
1793
+ R2TAO_TRY {
1794
+ CORBA::Any* any = 0;
1795
+ ACE_NEW_THROW_EX (any,
1796
+ CORBA::Any (),
1797
+ CORBA::NO_MEMORY());
1798
+ CORBA::Any_var any_safe = any;
1799
+
1800
+ CHECK_RTYPE(rval, T_ARRAY);
1801
+ CORBA::ULong asz = static_cast<unsigned long> (RARRAY_LEN (rval));
1802
+ CORBA::ULong offs = NUM2ULONG (offset);
1803
+ CORBA::ULong alen = NUM2ULONG (length);
1804
+ CORBA::ULong len = ((offs + alen) <= asz) ? alen : (offs < asz ? (asz - offs) : 0);
1805
+ if (len > 0)
1806
+ {
1807
+ CORBA::Any* any_array = 0;
1808
+ ACE_NEW_THROW_EX (any_array,
1809
+ CORBA::Any[len],
1810
+ CORBA::NO_MEMORY());
1811
+ ACE_Auto_Ptr<CORBA::Any> any_array_safe (any_array);
1812
+ for (CORBA::ULong l=0; l<len ;++l)
1813
+ {
1814
+ VALUE rel = rb_ary_entry (rval, offs+l);
1815
+ r2tao_Ruby_to_Any(any_array[l], rel);
1816
+ }
1817
+ R2TAO_ArrayAny_Impl_T<CORBA::Any>::insert (*any,
1818
+ CORBA::_tc_any,
1819
+ any_array_safe.release (),
1820
+ len);
1821
+
1822
+ if (!vt->add_chunk_element (any_safe))
1823
+ throw CORBA::MARSHAL ();
1824
+ }
1825
+ } R2TAO_CATCH;
1826
+ return Qnil;
1827
+ }
1828
+
1829
+ VALUE r2tao_OStream_write_boolean_array (VALUE self, VALUE rval, VALUE offset, VALUE length)
1830
+ {
1831
+ R2TAO_Value* vt = r2tao_OutputStream_r2t(self);
1832
+ R2TAO_TRY {
1833
+ CORBA::Any* any = 0;
1834
+ ACE_NEW_THROW_EX (any,
1835
+ CORBA::Any (),
1836
+ CORBA::NO_MEMORY());
1837
+ CORBA::Any_var any_safe = any;
1838
+
1839
+ CHECK_RTYPE(rval, T_ARRAY);
1840
+ CORBA::ULong asz = static_cast<unsigned long> (RARRAY_LEN (rval));
1841
+ CORBA::ULong offs = NUM2ULONG (offset);
1842
+ CORBA::ULong alen = NUM2ULONG (length);
1843
+ CORBA::ULong len = ((offs + alen) <= asz) ? alen : (offs < asz ? (asz - offs) : 0);
1844
+ if (len > 0)
1845
+ {
1846
+ CORBA::Boolean* native_array = 0;
1847
+ ACE_NEW_THROW_EX (native_array,
1848
+ CORBA::Boolean[len],
1849
+ CORBA::NO_MEMORY());
1850
+ ACE_Auto_Ptr<CORBA::Boolean> native_array_safe (native_array);
1851
+ for (CORBA::ULong l=0; l<len ;++l)
1852
+ {
1853
+ VALUE rel = rb_ary_entry (rval, offs+l);
1854
+ native_array[l] = (NIL_P (rel) || rel == Qfalse) ? 0 : 1;
1855
+ }
1856
+ R2TAO_ArrayAny_Impl_T<CORBA::Boolean>::insert (*any,
1857
+ CORBA::_tc_boolean,
1858
+ native_array_safe.release (),
1859
+ len);
1860
+
1861
+ if (!vt->add_chunk_element (any_safe))
1862
+ throw CORBA::MARSHAL ();
1863
+ }
1864
+ } R2TAO_CATCH;
1865
+ return Qnil;
1866
+ }
1867
+
1868
+ VALUE r2tao_OStream_write_char_array (VALUE self, VALUE rval, VALUE offset, VALUE length)
1869
+ {
1870
+ R2TAO_Value* vt = r2tao_OutputStream_r2t(self);
1871
+ R2TAO_TRY {
1872
+ CORBA::Any* any = 0;
1873
+ ACE_NEW_THROW_EX (any,
1874
+ CORBA::Any (),
1875
+ CORBA::NO_MEMORY());
1876
+ CORBA::Any_var any_safe = any;
1877
+
1878
+ CHECK_RTYPE(rval, T_STRING);
1879
+ CORBA::ULong asz = static_cast<unsigned long> (RSTRING_LEN (rval));
1880
+ CORBA::ULong offs = NUM2ULONG (offset);
1881
+ CORBA::ULong alen = NUM2ULONG (length);
1882
+ CORBA::ULong len = ((offs + alen) <= asz) ? alen : (offs < asz ? (asz - offs) : 0);
1883
+ if (len > 0)
1884
+ {
1885
+ CORBA::Char* native_array = 0;
1886
+ ACE_NEW_THROW_EX (native_array,
1887
+ CORBA::Char[len],
1888
+ CORBA::NO_MEMORY());
1889
+ ACE_Auto_Ptr<CORBA::Char> native_array_safe (native_array);
1890
+ char* s = RSTRING_PTR (rval);
1891
+ for (CORBA::ULong l=0; l<len ;++l)
1892
+ {
1893
+ native_array[l] = s[offs+l];
1894
+ }
1895
+ R2TAO_ArrayAny_Impl_T<CORBA::Char>::insert (*any,
1896
+ CORBA::_tc_char,
1897
+ native_array_safe.release (),
1898
+ len);
1899
+
1900
+ if (!vt->add_chunk_element (any_safe))
1901
+ throw CORBA::MARSHAL ();
1902
+ }
1903
+ } R2TAO_CATCH;
1904
+ return Qnil;
1905
+ }
1906
+
1907
+ VALUE r2tao_OStream_write_wchar_array (VALUE self, VALUE rval, VALUE offset, VALUE length)
1908
+ {
1909
+ R2TAO_Value* vt = r2tao_OutputStream_r2t(self);
1910
+ R2TAO_TRY {
1911
+ CORBA::Any* any = 0;
1912
+ ACE_NEW_THROW_EX (any,
1913
+ CORBA::Any (),
1914
+ CORBA::NO_MEMORY());
1915
+ CORBA::Any_var any_safe = any;
1916
+
1917
+ CHECK_RTYPE(rval, T_ARRAY);
1918
+ CORBA::ULong asz = static_cast<unsigned long> (RARRAY_LEN (rval));
1919
+ CORBA::ULong offs = NUM2ULONG (offset);
1920
+ CORBA::ULong alen = NUM2ULONG (length);
1921
+ CORBA::ULong len = ((offs + alen) <= asz) ? alen : (offs < asz ? (asz - offs) : 0);
1922
+ if (len > 0)
1923
+ {
1924
+ CORBA::WChar* native_array = 0;
1925
+ ACE_NEW_THROW_EX (native_array,
1926
+ CORBA::WChar[len],
1927
+ CORBA::NO_MEMORY());
1928
+ ACE_Auto_Ptr<CORBA::WChar> native_array_safe (native_array);
1929
+ for (CORBA::ULong l=0; l<len ;++l)
1930
+ {
1931
+ VALUE rel = rb_ary_entry (rval, offs+l);
1932
+ native_array[l] = (CORBA::WChar)NUM2INT (rel);
1933
+ }
1934
+ R2TAO_ArrayAny_Impl_T<CORBA::WChar>::insert (*any,
1935
+ CORBA::_tc_wchar,
1936
+ native_array_safe.release (),
1937
+ len);
1938
+
1939
+ if (!vt->add_chunk_element (any_safe))
1940
+ throw CORBA::MARSHAL ();
1941
+ }
1942
+ } R2TAO_CATCH;
1943
+ return Qnil;
1944
+ }
1945
+
1946
+ VALUE r2tao_OStream_write_octet_array (VALUE self, VALUE rval, VALUE offset, VALUE length)
1947
+ {
1948
+ R2TAO_Value* vt = r2tao_OutputStream_r2t(self);
1949
+ R2TAO_TRY {
1950
+ CORBA::Any* any = 0;
1951
+ ACE_NEW_THROW_EX (any,
1952
+ CORBA::Any (),
1953
+ CORBA::NO_MEMORY());
1954
+ CORBA::Any_var any_safe = any;
1955
+
1956
+ CHECK_RTYPE(rval, T_STRING);
1957
+ CORBA::ULong asz = static_cast<unsigned long> (RSTRING_LEN (rval));
1958
+ CORBA::ULong offs = NUM2ULONG (offset);
1959
+ CORBA::ULong alen = NUM2ULONG (length);
1960
+ CORBA::ULong len = ((offs + alen) <= asz) ? alen : (offs < asz ? (asz - offs) : 0);
1961
+ if (len > 0)
1962
+ {
1963
+ CORBA::Octet* native_array = 0;
1964
+ ACE_NEW_THROW_EX (native_array,
1965
+ CORBA::Octet[len],
1966
+ CORBA::NO_MEMORY());
1967
+ ACE_Auto_Ptr<CORBA::Octet> native_array_safe (native_array);
1968
+ unsigned char* s = (unsigned char*)RSTRING_PTR (rval);
1969
+ for (CORBA::ULong l=0; l<len ;++l)
1970
+ {
1971
+ native_array[l] = s[offs+l];
1972
+ }
1973
+ R2TAO_ArrayAny_Impl_T<CORBA::Octet>::insert (*any,
1974
+ CORBA::_tc_octet,
1975
+ native_array_safe.release (),
1976
+ len);
1977
+
1978
+ if (!vt->add_chunk_element (any_safe))
1979
+ throw CORBA::MARSHAL ();
1980
+ }
1981
+ } R2TAO_CATCH;
1982
+ return Qnil;
1983
+ }
1984
+
1985
+ VALUE r2tao_OStream_write_short_array (VALUE self, VALUE rval, VALUE offset, VALUE length)
1986
+ {
1987
+ R2TAO_Value* vt = r2tao_OutputStream_r2t(self);
1988
+ R2TAO_TRY {
1989
+ CORBA::Any* any = 0;
1990
+ ACE_NEW_THROW_EX (any,
1991
+ CORBA::Any (),
1992
+ CORBA::NO_MEMORY());
1993
+ CORBA::Any_var any_safe = any;
1994
+
1995
+ CHECK_RTYPE(rval, T_ARRAY);
1996
+ CORBA::ULong asz = static_cast<unsigned long> (RARRAY_LEN (rval));
1997
+ CORBA::ULong offs = NUM2ULONG (offset);
1998
+ CORBA::ULong alen = NUM2ULONG (length);
1999
+ CORBA::ULong len = ((offs + alen) <= asz) ? alen : (offs < asz ? (asz - offs) : 0);
2000
+ if (len > 0)
2001
+ {
2002
+ CORBA::Short* native_array = 0;
2003
+ ACE_NEW_THROW_EX (native_array,
2004
+ CORBA::Short[len],
2005
+ CORBA::NO_MEMORY());
2006
+ ACE_Auto_Ptr<CORBA::Short> native_array_safe (native_array);
2007
+ for (CORBA::ULong l=0; l<len ;++l)
2008
+ {
2009
+ VALUE rel = rb_ary_entry (rval, offs+l);
2010
+ native_array[l] = (CORBA::Short)NUM2INT (rel);
2011
+ }
2012
+ R2TAO_ArrayAny_Impl_T<CORBA::Short>::insert (*any,
2013
+ CORBA::_tc_short,
2014
+ native_array_safe.release (),
2015
+ len);
2016
+
2017
+ if (!vt->add_chunk_element (any_safe))
2018
+ throw CORBA::MARSHAL ();
2019
+ }
2020
+ } R2TAO_CATCH;
2021
+ return Qnil;
2022
+ }
2023
+
2024
+ VALUE r2tao_OStream_write_ushort_array (VALUE self, VALUE rval, VALUE offset, VALUE length)
2025
+ {
2026
+ R2TAO_Value* vt = r2tao_OutputStream_r2t(self);
2027
+ R2TAO_TRY {
2028
+ CORBA::Any* any = 0;
2029
+ ACE_NEW_THROW_EX (any,
2030
+ CORBA::Any (),
2031
+ CORBA::NO_MEMORY());
2032
+ CORBA::Any_var any_safe = any;
2033
+
2034
+ CHECK_RTYPE(rval, T_ARRAY);
2035
+ CORBA::ULong asz = static_cast<unsigned long> (RARRAY_LEN (rval));
2036
+ CORBA::ULong offs = NUM2ULONG (offset);
2037
+ CORBA::ULong alen = NUM2ULONG (length);
2038
+ CORBA::ULong len = ((offs + alen) <= asz) ? alen : (offs < asz ? (asz - offs) : 0);
2039
+ if (len > 0)
2040
+ {
2041
+ CORBA::UShort* native_array = 0;
2042
+ ACE_NEW_THROW_EX (native_array,
2043
+ CORBA::UShort[len],
2044
+ CORBA::NO_MEMORY());
2045
+ ACE_Auto_Ptr<CORBA::UShort> native_array_safe (native_array);
2046
+ for (CORBA::ULong l=0; l<len ;++l)
2047
+ {
2048
+ VALUE rel = rb_ary_entry (rval, offs+l);
2049
+ native_array[l] = (CORBA::UShort)NUM2UINT (rel);
2050
+ }
2051
+ R2TAO_ArrayAny_Impl_T<CORBA::UShort>::insert (*any,
2052
+ CORBA::_tc_ushort,
2053
+ native_array_safe.release (),
2054
+ len);
2055
+
2056
+ if (!vt->add_chunk_element (any_safe))
2057
+ throw CORBA::MARSHAL ();
2058
+ }
2059
+ } R2TAO_CATCH;
2060
+ return Qnil;
2061
+ }
2062
+
2063
+ VALUE r2tao_OStream_write_long_array (VALUE self, VALUE rval, VALUE offset, VALUE length)
2064
+ {
2065
+ R2TAO_Value* vt = r2tao_OutputStream_r2t(self);
2066
+ R2TAO_TRY {
2067
+ CORBA::Any* any = 0;
2068
+ ACE_NEW_THROW_EX (any,
2069
+ CORBA::Any (),
2070
+ CORBA::NO_MEMORY());
2071
+ CORBA::Any_var any_safe = any;
2072
+
2073
+ CHECK_RTYPE(rval, T_ARRAY);
2074
+ CORBA::ULong asz = static_cast<unsigned long> (RARRAY_LEN (rval));
2075
+ CORBA::ULong offs = NUM2ULONG (offset);
2076
+ CORBA::ULong alen = NUM2ULONG (length);
2077
+ CORBA::ULong len = ((offs + alen) <= asz) ? alen : (offs < asz ? (asz - offs) : 0);
2078
+ if (len > 0)
2079
+ {
2080
+ CORBA::Long* native_array = 0;
2081
+ ACE_NEW_THROW_EX (native_array,
2082
+ CORBA::Long[len],
2083
+ CORBA::NO_MEMORY());
2084
+ ACE_Auto_Ptr<CORBA::Long> native_array_safe (native_array);
2085
+ for (CORBA::ULong l=0; l<len ;++l)
2086
+ {
2087
+ VALUE rel = rb_ary_entry (rval, offs+l);
2088
+ native_array[l] = (CORBA::Long)NUM2LONG (rel);
2089
+ }
2090
+ R2TAO_ArrayAny_Impl_T<CORBA::Long>::insert (*any,
2091
+ CORBA::_tc_long,
2092
+ native_array_safe.release (),
2093
+ len);
2094
+
2095
+ if (!vt->add_chunk_element (any_safe))
2096
+ throw CORBA::MARSHAL ();
2097
+ }
2098
+ } R2TAO_CATCH;
2099
+ return Qnil;
2100
+ }
2101
+
2102
+ VALUE r2tao_OStream_write_ulong_array (VALUE self, VALUE rval, VALUE offset, VALUE length)
2103
+ {
2104
+ R2TAO_Value* vt = r2tao_OutputStream_r2t(self);
2105
+ R2TAO_TRY {
2106
+ CORBA::Any* any = 0;
2107
+ ACE_NEW_THROW_EX (any,
2108
+ CORBA::Any (),
2109
+ CORBA::NO_MEMORY());
2110
+ CORBA::Any_var any_safe = any;
2111
+
2112
+ CHECK_RTYPE(rval, T_ARRAY);
2113
+ CORBA::ULong asz = static_cast<unsigned long> (RARRAY_LEN (rval));
2114
+ CORBA::ULong offs = NUM2ULONG (offset);
2115
+ CORBA::ULong alen = NUM2ULONG (length);
2116
+ CORBA::ULong len = ((offs + alen) <= asz) ? alen : (offs < asz ? (asz - offs) : 0);
2117
+ if (len > 0)
2118
+ {
2119
+ CORBA::ULong* native_array = 0;
2120
+ ACE_NEW_THROW_EX (native_array,
2121
+ CORBA::ULong[len],
2122
+ CORBA::NO_MEMORY());
2123
+ ACE_Auto_Ptr<CORBA::ULong> native_array_safe (native_array);
2124
+ for (CORBA::ULong l=0; l<len ;++l)
2125
+ {
2126
+ VALUE rel = rb_ary_entry (rval, offs+l);
2127
+ native_array[l] = (CORBA::ULong)NUM2ULONG (rel);
2128
+ }
2129
+ R2TAO_ArrayAny_Impl_T<CORBA::ULong>::insert (*any,
2130
+ CORBA::_tc_ulong,
2131
+ native_array_safe.release (),
2132
+ len);
2133
+
2134
+ if (!vt->add_chunk_element (any_safe))
2135
+ throw CORBA::MARSHAL ();
2136
+ }
2137
+ } R2TAO_CATCH;
2138
+ return Qnil;
2139
+ }
2140
+
2141
+ VALUE r2tao_OStream_write_longlong_array (VALUE self, VALUE rval, VALUE offset, VALUE length)
2142
+ {
2143
+ R2TAO_Value* vt = r2tao_OutputStream_r2t(self);
2144
+ R2TAO_TRY {
2145
+ CORBA::Any* any = 0;
2146
+ ACE_NEW_THROW_EX (any,
2147
+ CORBA::Any (),
2148
+ CORBA::NO_MEMORY());
2149
+ CORBA::Any_var any_safe = any;
2150
+
2151
+ CHECK_RTYPE(rval, T_ARRAY);
2152
+ CORBA::ULong asz = static_cast<unsigned long> (RARRAY_LEN (rval));
2153
+ CORBA::ULong offs = NUM2ULONG (offset);
2154
+ CORBA::ULong alen = NUM2ULONG (length);
2155
+ CORBA::ULong len = ((offs + alen) <= asz) ? alen : (offs < asz ? (asz - offs) : 0);
2156
+ if (len > 0)
2157
+ {
2158
+ CORBA::LongLong* native_array = 0;
2159
+ ACE_NEW_THROW_EX (native_array,
2160
+ CORBA::LongLong[len],
2161
+ CORBA::NO_MEMORY());
2162
+ ACE_Auto_Ptr<CORBA::LongLong> native_array_safe (native_array);
2163
+ for (CORBA::ULong l=0; l<len ;++l)
2164
+ {
2165
+ VALUE rel = rb_ary_entry (rval, offs+l);
2166
+ native_array[l] = (CORBA::LongLong)NUM2LL (rel);
2167
+ }
2168
+ R2TAO_ArrayAny_Impl_T<CORBA::LongLong>::insert (*any,
2169
+ CORBA::_tc_longlong,
2170
+ native_array_safe.release (),
2171
+ len);
2172
+
2173
+ if (!vt->add_chunk_element (any_safe))
2174
+ throw CORBA::MARSHAL ();
2175
+ }
2176
+ } R2TAO_CATCH;
2177
+ return Qnil;
2178
+ }
2179
+
2180
+ VALUE r2tao_OStream_write_ulonglong_array (VALUE self, VALUE rval, VALUE offset, VALUE length)
2181
+ {
2182
+ R2TAO_Value* vt = r2tao_OutputStream_r2t(self);
2183
+ R2TAO_TRY {
2184
+ CORBA::Any* any = 0;
2185
+ ACE_NEW_THROW_EX (any,
2186
+ CORBA::Any (),
2187
+ CORBA::NO_MEMORY());
2188
+ CORBA::Any_var any_safe = any;
2189
+
2190
+ CHECK_RTYPE(rval, T_ARRAY);
2191
+ CORBA::ULong asz = static_cast<unsigned long> (RARRAY_LEN (rval));
2192
+ CORBA::ULong offs = NUM2ULONG (offset);
2193
+ CORBA::ULong alen = NUM2ULONG (length);
2194
+ CORBA::ULong len = ((offs + alen) <= asz) ? alen : (offs < asz ? (asz - offs) : 0);
2195
+ if (len > 0)
2196
+ {
2197
+ CORBA::ULongLong* native_array = 0;
2198
+ ACE_NEW_THROW_EX (native_array,
2199
+ CORBA::ULongLong[len],
2200
+ CORBA::NO_MEMORY());
2201
+ ACE_Auto_Ptr<CORBA::ULongLong> native_array_safe (native_array);
2202
+ for (CORBA::ULong l=0; l<len ;++l)
2203
+ {
2204
+ VALUE rel = rb_ary_entry (rval, offs+l);
2205
+ native_array[l] = (CORBA::ULongLong)NUM2ULL (rel);
2206
+ }
2207
+ R2TAO_ArrayAny_Impl_T<CORBA::ULongLong>::insert (*any,
2208
+ CORBA::_tc_ulonglong,
2209
+ native_array_safe.release (),
2210
+ len);
2211
+
2212
+ if (!vt->add_chunk_element (any_safe))
2213
+ throw CORBA::MARSHAL ();
2214
+ }
2215
+ } R2TAO_CATCH;
2216
+ return Qnil;
2217
+ }
2218
+
2219
+ VALUE r2tao_OStream_write_float_array (VALUE self, VALUE rval, VALUE offset, VALUE length)
2220
+ {
2221
+ R2TAO_Value* vt = r2tao_OutputStream_r2t(self);
2222
+ R2TAO_TRY {
2223
+ CORBA::Any* any = 0;
2224
+ ACE_NEW_THROW_EX (any,
2225
+ CORBA::Any (),
2226
+ CORBA::NO_MEMORY());
2227
+ CORBA::Any_var any_safe = any;
2228
+
2229
+ CHECK_RTYPE(rval, T_ARRAY);
2230
+ CORBA::ULong asz = static_cast<unsigned long> (RARRAY_LEN (rval));
2231
+ CORBA::ULong offs = NUM2ULONG (offset);
2232
+ CORBA::ULong alen = NUM2ULONG (length);
2233
+ CORBA::ULong len = ((offs + alen) <= asz) ? alen : (offs < asz ? (asz - offs) : 0);
2234
+ if (len > 0)
2235
+ {
2236
+ CORBA::Float* native_array = 0;
2237
+ ACE_NEW_THROW_EX (native_array,
2238
+ CORBA::Float[len],
2239
+ CORBA::NO_MEMORY());
2240
+ ACE_Auto_Ptr<CORBA::Float> native_array_safe (native_array);
2241
+ for (CORBA::ULong l=0; l<len ;++l)
2242
+ {
2243
+ VALUE rel = rb_ary_entry (rval, offs+l);
2244
+ native_array[l] = (CORBA::Float)NUM2DBL (rel);
2245
+ }
2246
+ R2TAO_ArrayAny_Impl_T<CORBA::Float>::insert (*any,
2247
+ CORBA::_tc_float,
2248
+ native_array_safe.release (),
2249
+ len);
2250
+
2251
+ if (!vt->add_chunk_element (any_safe))
2252
+ throw CORBA::MARSHAL ();
2253
+ }
2254
+ } R2TAO_CATCH;
2255
+ return Qnil;
2256
+ }
2257
+
2258
+ VALUE r2tao_OStream_write_double_array (VALUE self, VALUE rval, VALUE offset, VALUE length)
2259
+ {
2260
+ R2TAO_Value* vt = r2tao_OutputStream_r2t(self);
2261
+ R2TAO_TRY {
2262
+ CORBA::Any* any = 0;
2263
+ ACE_NEW_THROW_EX (any,
2264
+ CORBA::Any (),
2265
+ CORBA::NO_MEMORY());
2266
+ CORBA::Any_var any_safe = any;
2267
+
2268
+ CHECK_RTYPE(rval, T_ARRAY);
2269
+ CORBA::ULong asz = static_cast<unsigned long> (RARRAY_LEN (rval));
2270
+ CORBA::ULong offs = NUM2ULONG (offset);
2271
+ CORBA::ULong alen = NUM2ULONG (length);
2272
+ CORBA::ULong len = ((offs + alen) <= asz) ? alen : (offs < asz ? (asz - offs) : 0);
2273
+ if (len > 0)
2274
+ {
2275
+ CORBA::Double* native_array = 0;
2276
+ ACE_NEW_THROW_EX (native_array,
2277
+ CORBA::Double[len],
2278
+ CORBA::NO_MEMORY());
2279
+ ACE_Auto_Ptr<CORBA::Double> native_array_safe (native_array);
2280
+ for (CORBA::ULong l=0; l<len ;++l)
2281
+ {
2282
+ VALUE rel = rb_ary_entry (rval, offs+l);
2283
+ native_array[l] = (CORBA::Double)NUM2DBL (rel);
2284
+ }
2285
+ R2TAO_ArrayAny_Impl_T<CORBA::Double>::insert (*any,
2286
+ CORBA::_tc_double,
2287
+ native_array_safe.release (),
2288
+ len);
2289
+
2290
+ if (!vt->add_chunk_element (any_safe))
2291
+ throw CORBA::MARSHAL ();
2292
+ }
2293
+ } R2TAO_CATCH;
2294
+ return Qnil;
2295
+ }
2296
+
2297
+ VALUE r2tao_OStream_write_longdouble_array (VALUE self, VALUE rval, VALUE offset, VALUE length)
2298
+ {
2299
+ R2TAO_Value* vt = r2tao_OutputStream_r2t(self);
2300
+ R2TAO_TRY {
2301
+ CORBA::Any* any = 0;
2302
+ ACE_NEW_THROW_EX (any,
2303
+ CORBA::Any (),
2304
+ CORBA::NO_MEMORY());
2305
+ CORBA::Any_var any_safe = any;
2306
+
2307
+ CHECK_RTYPE(rval, T_ARRAY);
2308
+ CORBA::ULong asz = static_cast<unsigned long> (RARRAY_LEN (rval));
2309
+ CORBA::ULong offs = NUM2ULONG (offset);
2310
+ CORBA::ULong alen = NUM2ULONG (length);
2311
+ CORBA::ULong len = ((offs + alen) <= asz) ? alen : (offs < asz ? (asz - offs) : 0);
2312
+ if (len > 0)
2313
+ {
2314
+ CORBA::LongDouble* native_array = 0;
2315
+ ACE_NEW_THROW_EX (native_array,
2316
+ CORBA::LongDouble[len],
2317
+ CORBA::NO_MEMORY());
2318
+ ACE_Auto_Ptr<CORBA::LongDouble> native_array_safe (native_array);
2319
+ for (CORBA::ULong l=0; l<len ;++l)
2320
+ {
2321
+ VALUE rel = rb_ary_entry (rval, offs+l);
2322
+ ACE_CDR_LONG_DOUBLE_ASSIGNMENT (native_array[l], CLD2RLD (rel));
2323
+ }
2324
+ R2TAO_ArrayAny_Impl_T<CORBA::LongDouble>::insert (*any,
2325
+ CORBA::_tc_longdouble,
2326
+ native_array_safe.release (),
2327
+ len);
2328
+
2329
+ if (!vt->add_chunk_element (any_safe))
2330
+ throw CORBA::MARSHAL ();
2331
+ }
2332
+ } R2TAO_CATCH;
2333
+ return Qnil;
2334
+ }
2335
+
2336
+ VALUE r2tao_OStream_write_fixed_array (VALUE , VALUE , VALUE , VALUE )
2337
+ {
2338
+ X_CORBA (NO_IMPLEMENT);
2339
+ }
2340
+
2341
+ VALUE r2tao_OStream_write_construct (VALUE self, VALUE rval, VALUE rtc)
2342
+ {
2343
+ R2TAO_Value* val = r2tao_OutputStream_r2t(self);
2344
+ R2TAO_TRY {
2345
+ CORBA::TypeCode_ptr tc_ = r2corba_TypeCode_r2t (rtc);
2346
+
2347
+ CORBA::Any* any = 0;
2348
+ ACE_NEW_THROW_EX (any,
2349
+ CORBA::Any (),
2350
+ CORBA::NO_MEMORY());
2351
+ CORBA::Any_var any_safe = any;
2352
+ r2tao_Ruby2Any (*any, tc_, rval);
2353
+ if (!val->add_chunk_element (any_safe))
2354
+ throw CORBA::MARSHAL ();
2355
+ } R2TAO_CATCH;
2356
+ return Qnil;
2357
+ }
2358
+
2359
+ // ------------------------------------------------------------------
2360
+ // InputStream
2361
+
2362
+ VALUE r2tao_IStream_read_any (VALUE self)
2363
+ {
2364
+ VALUE ret = Qnil;
2365
+ TAO_InputCDR &strm = *r2tao_InputStream_r2t(self);
2366
+ R2TAO_TRY {
2367
+ CORBA::Any any;
2368
+ strm >> any;
2369
+ ret = r2tao_Any_to_Ruby (any);
2370
+ } R2TAO_CATCH;
2371
+ return ret;
2372
+ }
2373
+
2374
+ VALUE r2tao_IStream_read_boolean (VALUE self)
2375
+ {
2376
+ VALUE ret = Qnil;
2377
+ TAO_InputCDR &strm = *r2tao_InputStream_r2t(self);
2378
+ R2TAO_TRY {
2379
+ CORBA::Boolean val = false;
2380
+ TAO_InputCDR::to_boolean bool_ (val);
2381
+ strm >> bool_;
2382
+ ret = val ? Qtrue : Qfalse;
2383
+ } R2TAO_CATCH;
2384
+ return ret;
2385
+ }
2386
+
2387
+ VALUE r2tao_IStream_read_char (VALUE self)
2388
+ {
2389
+ VALUE ret = Qnil;
2390
+ TAO_InputCDR &strm = *r2tao_InputStream_r2t(self);
2391
+ R2TAO_TRY {
2392
+ CORBA::Char val = 0;
2393
+ TAO_InputCDR::to_char ch_ (val);
2394
+ strm >> ch_;
2395
+ ret = rb_str_new (&val, 1);
2396
+ } R2TAO_CATCH;
2397
+ return ret;
2398
+ }
2399
+
2400
+ VALUE r2tao_IStream_read_wchar (VALUE self)
2401
+ {
2402
+ VALUE ret = Qnil;
2403
+ TAO_InputCDR &strm = *r2tao_InputStream_r2t(self);
2404
+ R2TAO_TRY {
2405
+ CORBA::WChar val = 0;
2406
+ TAO_InputCDR::to_wchar wch_ (val);
2407
+ strm >> wch_;
2408
+ ret = INT2FIX ((int)val);
2409
+ } R2TAO_CATCH;
2410
+ return ret;
2411
+ }
2412
+
2413
+ VALUE r2tao_IStream_read_octet (VALUE self)
2414
+ {
2415
+ VALUE ret = Qnil;
2416
+ TAO_InputCDR &strm = *r2tao_InputStream_r2t(self);
2417
+ R2TAO_TRY {
2418
+ CORBA::Octet val = 0;
2419
+ TAO_InputCDR::to_octet byte_ (val);
2420
+ strm >> byte_;
2421
+ ret = INT2FIX ((int)val);
2422
+ } R2TAO_CATCH;
2423
+ return ret;
2424
+ }
2425
+
2426
+ VALUE r2tao_IStream_read_short (VALUE self)
2427
+ {
2428
+ VALUE ret = Qnil;
2429
+ TAO_InputCDR &strm = *r2tao_InputStream_r2t(self);
2430
+ R2TAO_TRY {
2431
+ CORBA::Short val = 0;
2432
+ strm >> val;
2433
+ ret = INT2FIX ((int)val);
2434
+ } R2TAO_CATCH;
2435
+ return ret;
2436
+ }
2437
+
2438
+ VALUE r2tao_IStream_read_ushort (VALUE self)
2439
+ {
2440
+ VALUE ret = Qnil;
2441
+ TAO_InputCDR &strm = *r2tao_InputStream_r2t(self);
2442
+ R2TAO_TRY {
2443
+ CORBA::UShort val = 0;
2444
+ strm >> val;
2445
+ ret = UINT2NUM ((unsigned int)val);
2446
+ } R2TAO_CATCH;
2447
+ return ret;
2448
+ }
2449
+
2450
+ VALUE r2tao_IStream_read_long (VALUE self)
2451
+ {
2452
+ VALUE ret = Qnil;
2453
+ TAO_InputCDR &strm = *r2tao_InputStream_r2t(self);
2454
+ R2TAO_TRY {
2455
+ CORBA::Long val = 0;
2456
+ strm >> val;
2457
+ ret = LONG2FIX (val);
2458
+ } R2TAO_CATCH;
2459
+ return ret;
2460
+ }
2461
+
2462
+ VALUE r2tao_IStream_read_ulong (VALUE self)
2463
+ {
2464
+ VALUE ret = Qnil;
2465
+ TAO_InputCDR &strm = *r2tao_InputStream_r2t(self);
2466
+ R2TAO_TRY {
2467
+ CORBA::ULong val = 0;
2468
+ strm >> val;
2469
+ ret = ULONG2NUM (val);
2470
+ } R2TAO_CATCH;
2471
+ return ret;
2472
+ }
2473
+
2474
+ VALUE r2tao_IStream_read_longlong (VALUE self)
2475
+ {
2476
+ VALUE ret = Qnil;
2477
+ TAO_InputCDR &strm = *r2tao_InputStream_r2t(self);
2478
+ R2TAO_TRY {
2479
+ CORBA::LongLong val = 0;
2480
+ strm >> val;
2481
+ ret = LL2NUM (val);
2482
+ } R2TAO_CATCH;
2483
+ return ret;
2484
+ }
2485
+
2486
+ VALUE r2tao_IStream_read_ulonglong (VALUE self)
2487
+ {
2488
+ VALUE ret = Qnil;
2489
+ TAO_InputCDR &strm = *r2tao_InputStream_r2t(self);
2490
+ R2TAO_TRY {
2491
+ CORBA::ULongLong val = 0;
2492
+ strm >> val;
2493
+ ret = ULL2NUM (val);
2494
+ } R2TAO_CATCH;
2495
+ return ret;
2496
+ }
2497
+
2498
+ VALUE r2tao_IStream_read_float (VALUE self)
2499
+ {
2500
+ VALUE ret = Qnil;
2501
+ TAO_InputCDR &strm = *r2tao_InputStream_r2t(self);
2502
+ R2TAO_TRY {
2503
+ CORBA::Float val = 0;
2504
+ strm >> val;
2505
+ ret = rb_float_new ((double)val);
2506
+ } R2TAO_CATCH;
2507
+ return ret;
2508
+ }
2509
+
2510
+ VALUE r2tao_IStream_read_double (VALUE self)
2511
+ {
2512
+ VALUE ret = Qnil;
2513
+ TAO_InputCDR &strm = *r2tao_InputStream_r2t(self);
2514
+ R2TAO_TRY {
2515
+ CORBA::Double val = 0;
2516
+ strm >> val;
2517
+ ret = rb_float_new ((double)val);
2518
+ } R2TAO_CATCH;
2519
+ return ret;
2520
+ }
2521
+
2522
+ VALUE r2tao_IStream_read_longdouble (VALUE self)
2523
+ {
2524
+ VALUE ret = Qnil;
2525
+ TAO_InputCDR &strm = *r2tao_InputStream_r2t(self);
2526
+ R2TAO_TRY {
2527
+ CORBA::LongDouble val;
2528
+ strm >> val;
2529
+ ret = CLD2RLD (val);
2530
+ } R2TAO_CATCH;
2531
+ return ret;
2532
+ }
2533
+
2534
+ VALUE r2tao_IStream_read_Object (VALUE self)
2535
+ {
2536
+ VALUE ret = Qnil;
2537
+ TAO_InputCDR &strm = *r2tao_InputStream_r2t(self);
2538
+ R2TAO_TRY {
2539
+ CORBA::Object_var val;
2540
+ strm >> val;
2541
+ if (CORBA::is_nil (val.in ()))
2542
+ ret = Qnil;
2543
+ else
2544
+ ret = r2corba_Object_t2r(val.in ());
2545
+ } R2TAO_CATCH;
2546
+ return ret;
2547
+ }
2548
+
2549
+ VALUE r2tao_IStream_read_Abstract (VALUE self)
2550
+ {
2551
+ VALUE ret = Qnil;
2552
+ TAO_InputCDR &strm = *r2tao_InputStream_r2t(self);
2553
+ CORBA::Boolean val = false;
2554
+ R2TAO_TRY {
2555
+ TAO_InputCDR::to_boolean bool_ (val);
2556
+ strm >> bool_;
2557
+ } R2TAO_CATCH;
2558
+ if (val)
2559
+ {
2560
+ // Object
2561
+ ret = r2tao_IStream_read_Object (self);
2562
+ }
2563
+ else
2564
+ {
2565
+ // Value
2566
+ ret = r2tao_IStream_read_Value (self);
2567
+ }
2568
+ return ret;
2569
+ }
2570
+
2571
+ VALUE r2tao_IStream_read_Value (VALUE self)
2572
+ {
2573
+ VALUE ret = Qnil;
2574
+ TAO_InputCDR &strm = *r2tao_InputStream_r2t(self);
2575
+ R2TAO_TRY {
2576
+ R2TAO_Value_var val;
2577
+ strm >> val.out ();
2578
+ if (!CORBA::is_nil (val.in ()))
2579
+ ret = val.in ()->get_ruby_value ();
2580
+
2581
+ //CORBA::ValueBase_var val;
2582
+ //strm >> val.out ();
2583
+ //if (!CORBA::is_nil (val.in ()))
2584
+ // ret = R2TAO_Value::_downcast (val.in ())->get_ruby_value ();
2585
+ } R2TAO_CATCH;
2586
+ return ret;
2587
+ }
2588
+
2589
+ VALUE r2tao_IStream_read_TypeCode (VALUE self)
2590
+ {
2591
+ VALUE ret = Qnil;
2592
+ TAO_InputCDR &strm = *r2tao_InputStream_r2t(self);
2593
+ R2TAO_TRY {
2594
+ CORBA::TypeCode_var val;
2595
+ strm >> val.out ();
2596
+ if (CORBA::is_nil (val.in ()))
2597
+ ret = Qnil;
2598
+ else
2599
+ ret = r2corba_TypeCode_t2r(val.in ());
2600
+ } R2TAO_CATCH;
2601
+ return ret;
2602
+ }
2603
+
2604
+ VALUE r2tao_IStream_read_fixed (VALUE)
2605
+ {
2606
+ X_CORBA (NO_IMPLEMENT);
2607
+ }
2608
+
2609
+ VALUE r2tao_IStream_read_string (VALUE self)
2610
+ {
2611
+ VALUE ret = Qnil;
2612
+ TAO_InputCDR &strm = *r2tao_InputStream_r2t(self);
2613
+ CORBA::Char* val = 0;
2614
+ R2TAO_TRY {
2615
+ strm >> val;
2616
+ } R2TAO_CATCH;
2617
+ ret = val ? rb_str_new2 (val) : Qnil;
2618
+ return ret;
2619
+ }
2620
+
2621
+ VALUE r2tao_IStream_read_wstring (VALUE self)
2622
+ {
2623
+ VALUE ret = Qnil;
2624
+ TAO_InputCDR &strm = *r2tao_InputStream_r2t(self);
2625
+ CORBA::WChar* val = 0;
2626
+ R2TAO_TRY {
2627
+ strm >> val;
2628
+ } R2TAO_CATCH;
2629
+ if (val == 0)
2630
+ return Qnil;
2631
+ else
2632
+ {
2633
+ ret = rb_class_new_instance (0, 0, rb_cArray);
2634
+ for (CORBA::ULong l=0; val[l] != CORBA::WChar(0) ;++l)
2635
+ rb_ary_push (ret, INT2FIX (val[l]));
2636
+ }
2637
+ return ret;
2638
+ }
2639
+
2640
+ VALUE r2tao_IStream_read_any_array (VALUE self, VALUE rval, VALUE offset, VALUE length)
2641
+ {
2642
+ TAO_InputCDR &strm = *r2tao_InputStream_r2t(self);
2643
+ R2TAO_TRY {
2644
+ CHECK_RTYPE(rval, T_ARRAY);
2645
+ CORBA::ULong offs = NUM2ULONG (offset);
2646
+ CORBA::ULong alen = NUM2ULONG (length);
2647
+ for (CORBA::ULong l=0; l<alen ;++l)
2648
+ {
2649
+ CORBA::Any any;
2650
+ strm >> any;
2651
+ VALUE rv = r2tao_Any_to_Ruby (any);
2652
+ rb_ary_store (rval, (long)offs+l, rv);
2653
+ }
2654
+ } R2TAO_CATCH;
2655
+ return rval;
2656
+ }
2657
+
2658
+ VALUE r2tao_IStream_read_boolean_array (VALUE self, VALUE rval, VALUE offset, VALUE length)
2659
+ {
2660
+ TAO_InputCDR &strm = *r2tao_InputStream_r2t(self);
2661
+ R2TAO_TRY {
2662
+ CHECK_RTYPE(rval, T_ARRAY);
2663
+ CORBA::ULong offs = NUM2ULONG (offset);
2664
+ CORBA::ULong alen = NUM2ULONG (length);
2665
+ for (CORBA::ULong l=0; l<alen ;++l)
2666
+ {
2667
+ CORBA::Boolean val = false;
2668
+ TAO_InputCDR::to_boolean bool_ (val);
2669
+ strm >> bool_;
2670
+ VALUE rv = val ? Qtrue : Qfalse;
2671
+ rb_ary_store (rval, (long)offs+l, rv);
2672
+ }
2673
+ } R2TAO_CATCH;
2674
+ return rval;
2675
+ }
2676
+
2677
+ VALUE r2tao_IStream_read_char_array (VALUE self, VALUE rval, VALUE offset, VALUE length)
2678
+ {
2679
+ TAO_InputCDR &strm = *r2tao_InputStream_r2t(self);
2680
+ R2TAO_TRY {
2681
+ CHECK_RTYPE(rval, T_STRING);
2682
+ CORBA::ULong slen = static_cast<CORBA::ULong> (RSTRING_LEN (rval));
2683
+ CORBA::ULong offs = NUM2ULONG (offset);
2684
+ CORBA::ULong alen = NUM2ULONG (length);
2685
+ CORBA::ULong rlen = slen < (offs + alen) ? (offs + alen) : slen;
2686
+ CORBA::String_var str = CORBA::string_alloc (rlen + 1);
2687
+ ACE_OS::strncpy (str, RSTRING_PTR (rval), slen < offs ? slen : offs);
2688
+ for (CORBA::ULong l=0; l<alen ;++l)
2689
+ {
2690
+ CORBA::Char val = 0;
2691
+ TAO_InputCDR::to_char ch_ (val);
2692
+ strm >> ch_;
2693
+ str[offs+l] = val;
2694
+ }
2695
+ if (slen > (offs + alen))
2696
+ {
2697
+ ACE_OS::strncpy (&(str[offs+alen]), RSTRING_PTR (rval) + (offs+alen), slen - (offs + alen));
2698
+ }
2699
+ rb_str_resize (rval, 0);
2700
+ rb_str_cat (rval, str.in (), (long)rlen);
2701
+ } R2TAO_CATCH;
2702
+ return rval;
2703
+ }
2704
+
2705
+ VALUE r2tao_IStream_read_wchar_array (VALUE self, VALUE rval, VALUE offset, VALUE length)
2706
+ {
2707
+ TAO_InputCDR &strm = *r2tao_InputStream_r2t(self);
2708
+ R2TAO_TRY {
2709
+ CHECK_RTYPE(rval, T_ARRAY);
2710
+ CORBA::ULong offs = NUM2ULONG (offset);
2711
+ CORBA::ULong alen = NUM2ULONG (length);
2712
+ for (CORBA::ULong l=0; l<alen ;++l)
2713
+ {
2714
+ CORBA::WChar val = 0;
2715
+ TAO_InputCDR::to_wchar wch_ (val);
2716
+ strm >> wch_;
2717
+ VALUE rv = INT2FIX ((int)val);
2718
+ rb_ary_store (rval, (long)offs+l, rv);
2719
+ }
2720
+ } R2TAO_CATCH;
2721
+ return rval;
2722
+ }
2723
+
2724
+ VALUE r2tao_IStream_read_octet_array (VALUE self, VALUE rval, VALUE offset, VALUE length)
2725
+ {
2726
+ TAO_InputCDR &strm = *r2tao_InputStream_r2t(self);
2727
+ R2TAO_TRY {
2728
+ CHECK_RTYPE(rval, T_STRING);
2729
+ CORBA::ULong slen = static_cast<CORBA::ULong> (RSTRING_LEN (rval));
2730
+ CORBA::ULong offs = NUM2ULONG (offset);
2731
+ CORBA::ULong alen = NUM2ULONG (length);
2732
+ CORBA::ULong rlen = slen < (offs + alen) ? (offs + alen) : slen;
2733
+ CORBA::String_var str = CORBA::string_alloc (rlen + 1);
2734
+ ACE_OS::strncpy (str.out (), RSTRING_PTR (rval), slen < offs ? slen : offs);
2735
+ for (CORBA::ULong l=0; l<alen ;++l)
2736
+ {
2737
+ CORBA::Char val = 0;
2738
+ TAO_InputCDR::to_octet byte_ ((CORBA::Octet&)val);
2739
+ strm >> byte_;
2740
+ str[offs+l] = val;
2741
+ }
2742
+ if (slen > (offs + alen))
2743
+ {
2744
+ ACE_OS::strncpy (&(str[offs+alen]), RSTRING_PTR (rval) + (offs+alen), slen - (offs + alen));
2745
+ }
2746
+ rb_str_resize (rval, 0);
2747
+ rb_str_cat (rval, str.in (), (long)rlen);
2748
+ } R2TAO_CATCH;
2749
+ return rval;
2750
+ }
2751
+
2752
+ VALUE r2tao_IStream_read_short_array (VALUE self, VALUE rval, VALUE offset, VALUE length)
2753
+ {
2754
+ TAO_InputCDR &strm = *r2tao_InputStream_r2t(self);
2755
+ R2TAO_TRY {
2756
+ CHECK_RTYPE(rval, T_ARRAY);
2757
+ CORBA::ULong offs = NUM2ULONG (offset);
2758
+ CORBA::ULong alen = NUM2ULONG (length);
2759
+ for (CORBA::ULong l=0; l<alen ;++l)
2760
+ {
2761
+ CORBA::Short val = 0;
2762
+ strm >> val;
2763
+ VALUE rv = INT2FIX (val);
2764
+ rb_ary_store (rval, (long)offs+l, rv);
2765
+ }
2766
+ } R2TAO_CATCH;
2767
+ return rval;
2768
+ }
2769
+
2770
+ VALUE r2tao_IStream_read_ushort_array (VALUE self, VALUE rval, VALUE offset, VALUE length)
2771
+ {
2772
+ TAO_InputCDR &strm = *r2tao_InputStream_r2t(self);
2773
+ R2TAO_TRY {
2774
+ CHECK_RTYPE(rval, T_ARRAY);
2775
+ CORBA::ULong offs = NUM2ULONG (offset);
2776
+ CORBA::ULong alen = NUM2ULONG (length);
2777
+ for (CORBA::ULong l=0; l<alen ;++l)
2778
+ {
2779
+ CORBA::UShort val = 0;
2780
+ strm >> val;
2781
+ VALUE rv = UINT2NUM (val);
2782
+ rb_ary_store (rval, (long)offs+l, rv);
2783
+ }
2784
+ } R2TAO_CATCH;
2785
+ return rval;
2786
+ }
2787
+
2788
+ VALUE r2tao_IStream_read_long_array (VALUE self, VALUE rval, VALUE offset, VALUE length)
2789
+ {
2790
+ TAO_InputCDR &strm = *r2tao_InputStream_r2t(self);
2791
+ R2TAO_TRY {
2792
+ CHECK_RTYPE(rval, T_ARRAY);
2793
+ CORBA::ULong offs = NUM2ULONG (offset);
2794
+ CORBA::ULong alen = NUM2ULONG (length);
2795
+ for (CORBA::ULong l=0; l<alen ;++l)
2796
+ {
2797
+ CORBA::Long val = 0;
2798
+ strm >> val;
2799
+ VALUE rv = LONG2FIX (val);
2800
+ rb_ary_store (rval, (long)offs+l, rv);
2801
+ }
2802
+ } R2TAO_CATCH;
2803
+ return rval;
2804
+ }
2805
+
2806
+ VALUE r2tao_IStream_read_ulong_array (VALUE self, VALUE rval, VALUE offset, VALUE length)
2807
+ {
2808
+ TAO_InputCDR &strm = *r2tao_InputStream_r2t(self);
2809
+ R2TAO_TRY {
2810
+ CHECK_RTYPE(rval, T_ARRAY);
2811
+ CORBA::ULong offs = NUM2ULONG (offset);
2812
+ CORBA::ULong alen = NUM2ULONG (length);
2813
+ for (CORBA::ULong l=0; l<alen ;++l)
2814
+ {
2815
+ CORBA::ULong val = 0;
2816
+ strm >> val;
2817
+ VALUE rv = ULONG2NUM (val);
2818
+ rb_ary_store (rval, (long)offs+l, rv);
2819
+ }
2820
+ } R2TAO_CATCH;
2821
+ return rval;
2822
+ }
2823
+
2824
+ VALUE r2tao_IStream_read_longlong_array (VALUE self, VALUE rval, VALUE offset, VALUE length)
2825
+ {
2826
+ TAO_InputCDR &strm = *r2tao_InputStream_r2t(self);
2827
+ R2TAO_TRY {
2828
+ CHECK_RTYPE(rval, T_ARRAY);
2829
+ CORBA::ULong offs = NUM2ULONG (offset);
2830
+ CORBA::ULong alen = NUM2ULONG (length);
2831
+ for (CORBA::ULong l=0; l<alen ;++l)
2832
+ {
2833
+ CORBA::LongLong val = 0;
2834
+ strm >> val;
2835
+ VALUE rv = LL2NUM (val);
2836
+ rb_ary_store (rval, (long)offs+l, rv);
2837
+ }
2838
+ } R2TAO_CATCH;
2839
+ return rval;
2840
+ }
2841
+
2842
+ VALUE r2tao_IStream_read_ulonglong_array (VALUE self, VALUE rval, VALUE offset, VALUE length)
2843
+ {
2844
+ TAO_InputCDR &strm = *r2tao_InputStream_r2t(self);
2845
+ R2TAO_TRY {
2846
+ CHECK_RTYPE(rval, T_ARRAY);
2847
+ CORBA::ULong offs = NUM2ULONG (offset);
2848
+ CORBA::ULong alen = NUM2ULONG (length);
2849
+ for (CORBA::ULong l=0; l<alen ;++l)
2850
+ {
2851
+ CORBA::ULongLong val = 0;
2852
+ strm >> val;
2853
+ VALUE rv = ULL2NUM (val);
2854
+ rb_ary_store (rval, (long)offs+l, rv);
2855
+ }
2856
+ } R2TAO_CATCH;
2857
+ return rval;
2858
+ }
2859
+
2860
+ VALUE r2tao_IStream_read_float_array (VALUE self, VALUE rval, VALUE offset, VALUE length)
2861
+ {
2862
+ TAO_InputCDR &strm = *r2tao_InputStream_r2t(self);
2863
+ R2TAO_TRY {
2864
+ CHECK_RTYPE(rval, T_ARRAY);
2865
+ CORBA::ULong offs = NUM2ULONG (offset);
2866
+ CORBA::ULong alen = NUM2ULONG (length);
2867
+ for (CORBA::ULong l=0; l<alen ;++l)
2868
+ {
2869
+ CORBA::Float val = 0;
2870
+ strm >> val;
2871
+ VALUE rv = rb_float_new ((double)val);
2872
+ rb_ary_store (rval, (long)offs+l, rv);
2873
+ }
2874
+ } R2TAO_CATCH;
2875
+ return rval;
2876
+ }
2877
+
2878
+ VALUE r2tao_IStream_read_double_array (VALUE self, VALUE rval, VALUE offset, VALUE length)
2879
+ {
2880
+ TAO_InputCDR &strm = *r2tao_InputStream_r2t(self);
2881
+ R2TAO_TRY {
2882
+ CHECK_RTYPE(rval, T_ARRAY);
2883
+ CORBA::ULong offs = NUM2ULONG (offset);
2884
+ CORBA::ULong alen = NUM2ULONG (length);
2885
+ for (CORBA::ULong l=0; l<alen ;++l)
2886
+ {
2887
+ CORBA::Double val = 0;
2888
+ strm >> val;
2889
+ VALUE rv = rb_float_new ((double)val);
2890
+ rb_ary_store (rval, (long)offs+l, rv);
2891
+ }
2892
+ } R2TAO_CATCH;
2893
+ return rval;
2894
+ }
2895
+
2896
+ VALUE r2tao_IStream_read_longdouble_array (VALUE self, VALUE rval, VALUE offset, VALUE length)
2897
+ {
2898
+ TAO_InputCDR &strm = *r2tao_InputStream_r2t(self);
2899
+ R2TAO_TRY {
2900
+ CHECK_RTYPE(rval, T_ARRAY);
2901
+ CORBA::ULong offs = NUM2ULONG (offset);
2902
+ CORBA::ULong alen = NUM2ULONG (length);
2903
+ for (CORBA::ULong l=0; l<alen ;++l)
2904
+ {
2905
+ CORBA::LongDouble val;
2906
+ strm >> val;
2907
+ VALUE rv = CLD2RLD (val);
2908
+ rb_ary_store (rval, (long)offs+l, rv);
2909
+ }
2910
+ } R2TAO_CATCH;
2911
+ return rval;
2912
+ }
2913
+
2914
+ VALUE r2tao_IStream_read_fixed_array (VALUE, VALUE, VALUE, VALUE)
2915
+ {
2916
+ X_CORBA (NO_IMPLEMENT);
2917
+ }
2918
+
2919
+ VALUE r2tao_IStream_read_construct (VALUE self, VALUE rtc)
2920
+ {
2921
+ VALUE ret = Qnil;
2922
+ TAO_InputCDR &strm = *r2tao_InputStream_r2t(self);
2923
+ R2TAO_TRY {
2924
+ CORBA::TypeCode_ptr tc_ = r2corba_TypeCode_r2t (rtc);
2925
+
2926
+ CORBA::Any any_;
2927
+ TAO::Unknown_IDL_Type *impl = 0;
2928
+ ACE_NEW_RETURN (impl,
2929
+ TAO::Unknown_IDL_Type (tc_),
2930
+ false);
2931
+
2932
+ any_.replace (impl);
2933
+ impl->_tao_decode (strm);
2934
+
2935
+ ret = r2tao_Any2Ruby (any_, tc_, rtc, rtc);
2936
+ } R2TAO_CATCH;
2937
+ return ret;
2938
+ }