r2corba 1.4.1-x86-mingw32 → 1.5.1-x86-mingw32

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 -7
  2. data/CHANGES +173 -159
  3. data/LICENSE +59 -59
  4. data/README +62 -62
  5. data/THANKS +54 -52
  6. data/bin/r2corba +1 -1
  7. data/bin/ridlc +1 -1
  8. data/bin/rins +1 -1
  9. data/lib/corba.rb +16 -16
  10. data/lib/corba/cbase/IORMap.rb +33 -33
  11. data/lib/corba/cbase/ORB.rb +237 -231
  12. data/lib/corba/cbase/Request.rb +133 -133
  13. data/lib/corba/cbase/Streams.rb +129 -129
  14. data/lib/corba/cbase/Stub.rb +19 -19
  15. data/lib/corba/cbase/Typecode.rb +441 -441
  16. data/lib/corba/cbase/Values.rb +129 -129
  17. data/lib/corba/cbase/exception.rb +66 -66
  18. data/lib/corba/cbase/poa.rb +23 -23
  19. data/lib/corba/cbase/policies.rb +77 -77
  20. data/lib/corba/cbase/post_require.rb +13 -13
  21. data/lib/corba/cbase/require.rb +28 -28
  22. data/lib/corba/cmds/base.rb +85 -85
  23. data/lib/corba/cmds/test.rb +30 -30
  24. data/lib/corba/common/Any.rb +91 -91
  25. data/lib/corba/common/IDL.rb +104 -104
  26. data/lib/corba/common/ORB.rb +368 -368
  27. data/lib/corba/common/Object.rb +208 -208
  28. data/lib/corba/common/Request.rb +19 -19
  29. data/lib/corba/common/Servant.rb +108 -108
  30. data/lib/corba/common/Struct.rb +21 -21
  31. data/lib/corba/common/Stub.rb +79 -79
  32. data/lib/corba/common/Typecode.rb +1121 -1121
  33. data/lib/corba/common/Union.rb +55 -55
  34. data/lib/corba/common/Values.rb +91 -91
  35. data/lib/corba/common/const.rb +22 -22
  36. data/lib/corba/common/exception.rb +68 -68
  37. data/lib/corba/common/require.rb +27 -27
  38. data/lib/corba/common/version.rb +22 -22
  39. data/lib/corba/idl/IDL.rb +21 -21
  40. data/lib/corba/idl/IORTable.pidl +62 -62
  41. data/lib/corba/idl/TAO_Ext.pidl +46 -46
  42. data/lib/corba/idl/require.rb +20 -20
  43. data/lib/corba/jbase/Any.rb +273 -273
  44. data/lib/corba/jbase/IORMap.rb +35 -35
  45. data/lib/corba/jbase/ORB.rb +112 -99
  46. data/lib/corba/jbase/Object.rb +99 -98
  47. data/lib/corba/jbase/Request.rb +225 -225
  48. data/lib/corba/jbase/Servant.rb +247 -246
  49. data/lib/corba/jbase/ServerRequest.rb +127 -127
  50. data/lib/corba/jbase/Streams.rb +670 -670
  51. data/lib/corba/jbase/Stub.rb +38 -38
  52. data/lib/corba/jbase/Typecode.rb +520 -520
  53. data/lib/corba/jbase/Values.rb +173 -173
  54. data/lib/corba/jbase/exception.rb +106 -106
  55. data/lib/corba/jbase/poa.rb +228 -228
  56. data/lib/corba/jbase/policies.rb +299 -299
  57. data/lib/corba/jbase/post_require.rb +14 -14
  58. data/lib/corba/jbase/require.rb +89 -86
  59. data/lib/corba/naming.rb +14 -14
  60. data/lib/corba/naming_service.rb +15 -15
  61. data/lib/corba/poa.rb +15 -15
  62. data/lib/corba/policies.rb +18 -18
  63. data/lib/corba/require.rb +17 -17
  64. data/lib/corba/svcs/ins/cos_naming.rb +426 -426
  65. data/lib/corba/svcs/ins/ins.rb +526 -526
  66. data/lib/corba/svcs/ins/naming_service.rb +119 -119
  67. data/lib/ridlbe/ruby/config.rb +336 -336
  68. data/lib/ridlbe/ruby/orb.pidlc +0 -0
  69. data/lib/ridlbe/ruby/require.rb +16 -16
  70. data/lib/ridlbe/ruby/walker.rb +1582 -1582
  71. data/mkrf_conf_bingem.rb +151 -101
  72. data/rakelib/bin.rake +80 -80
  73. data/rakelib/bin.rb +145 -145
  74. data/rakelib/build.rake +87 -87
  75. data/rakelib/config.rake +51 -51
  76. data/rakelib/config.rb +543 -449
  77. data/rakelib/ext.rake +242 -242
  78. data/rakelib/ext.rb +316 -308
  79. data/rakelib/ext_r2tao.rb +235 -232
  80. data/rakelib/gem.rake +235 -211
  81. data/rakelib/gem.rb +145 -145
  82. data/rakelib/package.rake +26 -26
  83. data/rakelib/test.rake +23 -23
  84. data/test/BiDirectional/Test.idl +34 -34
  85. data/test/BiDirectional/client.rb +131 -131
  86. data/test/BiDirectional/run_test.rb +68 -68
  87. data/test/BiDirectional/server.ior +1 -1
  88. data/test/BiDirectional/server.rb +169 -169
  89. data/test/CORBA_Services/Naming/BindingIterator/Test.idl +27 -27
  90. data/test/CORBA_Services/Naming/BindingIterator/client.rb +121 -121
  91. data/test/CORBA_Services/Naming/BindingIterator/ins.ior +1 -1
  92. data/test/CORBA_Services/Naming/BindingIterator/run_test.rb +82 -82
  93. data/test/CORBA_Services/Naming/BindingIterator/server.rb +109 -109
  94. data/test/CORBA_Services/Naming/Corbaname/Test.idl +27 -27
  95. data/test/CORBA_Services/Naming/Corbaname/client.rb +85 -85
  96. data/test/CORBA_Services/Naming/Corbaname/ins.ior +1 -1
  97. data/test/CORBA_Services/Naming/Corbaname/run_test.rb +88 -88
  98. data/test/CORBA_Services/Naming/Corbaname/server.rb +135 -135
  99. data/test/CORBA_Services/Naming/Simple/Test.idl +27 -27
  100. data/test/CORBA_Services/Naming/Simple/client.rb +84 -84
  101. data/test/CORBA_Services/Naming/Simple/ins.ior +1 -1
  102. data/test/CORBA_Services/Naming/Simple/run_test.rb +82 -82
  103. data/test/CORBA_Services/Naming/Simple/server.rb +109 -109
  104. data/test/Collocation/Diamond.idl +39 -39
  105. data/test/Collocation/run_test.rb +52 -52
  106. data/test/Collocation/test.rb +195 -195
  107. data/test/Connect_Timeout/Test.idl +27 -27
  108. data/test/Connect_Timeout/client.rb +111 -111
  109. data/test/Connect_Timeout/run_test.rb +52 -52
  110. data/test/DII/Test.idl +27 -27
  111. data/test/DII/client.rb +115 -115
  112. data/test/DII/run_test.rb +69 -69
  113. data/test/DII/server.ior +1 -1
  114. data/test/DII/server.rb +95 -95
  115. data/test/DSI/Test.idl +27 -27
  116. data/test/DSI/client.rb +66 -66
  117. data/test/DSI/run_test.rb +69 -69
  118. data/test/DSI/server.ior +1 -1
  119. data/test/DSI/server.rb +106 -106
  120. data/test/Exceptions/Test.idl +48 -48
  121. data/test/Exceptions/client.rb +117 -117
  122. data/test/Exceptions/run_test.rb +69 -69
  123. data/test/Exceptions/server.ior +1 -1
  124. data/test/Exceptions/server.rb +131 -131
  125. data/test/Hello/Test.idl +27 -27
  126. data/test/Hello/client.rb +78 -78
  127. data/test/Hello/run_test.rb +71 -71
  128. data/test/Hello/server.rb +95 -95
  129. data/test/IDL_Test/Test.idl +113 -113
  130. data/test/IDL_Test/Test_inc.idl +17 -17
  131. data/test/IDL_Test/client.rb +102 -102
  132. data/test/IDL_Test/run_test.rb +69 -69
  133. data/test/IDL_Test/server.ior +1 -1
  134. data/test/IDL_Test/server.rb +99 -99
  135. data/test/IORMap/Test.idl +27 -27
  136. data/test/IORMap/client.rb +73 -73
  137. data/test/IORMap/run_test.rb +69 -69
  138. data/test/IORMap/server.ior +1 -1
  139. data/test/IORMap/server.rb +114 -114
  140. data/test/IORTable/Test.idl +27 -27
  141. data/test/IORTable/client.rb +75 -75
  142. data/test/IORTable/run_test.rb +69 -69
  143. data/test/IORTable/server.ior +1 -1
  144. data/test/IORTable/server.rb +130 -130
  145. data/test/Implicit_Conversion/Test.idl +31 -31
  146. data/test/Implicit_Conversion/client.rb +110 -110
  147. data/test/Implicit_Conversion/run_test.rb +69 -69
  148. data/test/Implicit_Conversion/server.ior +1 -1
  149. data/test/Implicit_Conversion/server.rb +99 -99
  150. data/test/Multi_Threading/Multiple_ORB/Test.idl +27 -27
  151. data/test/Multi_Threading/Multiple_ORB/client.rb +82 -82
  152. data/test/Multi_Threading/Multiple_ORB/run_test.rb +71 -71
  153. data/test/Multi_Threading/Multiple_ORB/server.rb +108 -108
  154. data/test/Multi_Threading/Multiple_ORB/server0.ior +1 -1
  155. data/test/Multi_Threading/Multiple_ORB/server1.ior +1 -1
  156. data/test/Multi_Threading/Simple/Test.idl +27 -27
  157. data/test/Multi_Threading/Simple/client.rb +93 -88
  158. data/test/Multi_Threading/Simple/run_test.rb +69 -69
  159. data/test/Multi_Threading/Simple/server.ior +1 -1
  160. data/test/Multi_Threading/Simple/server.rb +117 -117
  161. data/test/Multi_Threading/Threads/Test.idl +31 -31
  162. data/test/Multi_Threading/Threads/client.rb +80 -80
  163. data/test/Multi_Threading/Threads/run_test.rb +76 -76
  164. data/test/Multi_Threading/Threads/server.ior +1 -1
  165. data/test/Multi_Threading/Threads/server.rb +119 -119
  166. data/test/Multi_Threading/Threads/watchdog.ior +1 -1
  167. data/test/Multi_Threading/Threads/watchdog.rb +87 -87
  168. data/test/Multiple_Servant_Interfaces/Test.idl +34 -34
  169. data/test/Multiple_Servant_Interfaces/client.rb +70 -70
  170. data/test/Multiple_Servant_Interfaces/run_test.rb +69 -69
  171. data/test/Multiple_Servant_Interfaces/server.ior +1 -1
  172. data/test/Multiple_Servant_Interfaces/server.rb +102 -102
  173. data/test/Nil/Test.idl +27 -27
  174. data/test/Nil/run_test.rb +52 -52
  175. data/test/Nil/test.rb +78 -78
  176. data/test/OBV/AbstractInterface/client.rb +179 -179
  177. data/test/OBV/AbstractInterface/run_test.rb +69 -69
  178. data/test/OBV/AbstractInterface/server.ior +1 -1
  179. data/test/OBV/AbstractInterface/server.rb +149 -149
  180. data/test/OBV/AbstractInterface/test.idl +53 -53
  181. data/test/OBV/Custom/OBV.idl +18 -18
  182. data/test/OBV/Custom/OBV_impl.rb +40 -40
  183. data/test/OBV/Custom/client.rb +86 -86
  184. data/test/OBV/Custom/run_test.rb +69 -69
  185. data/test/OBV/Custom/server.ior +1 -1
  186. data/test/OBV/Custom/server.rb +100 -100
  187. data/test/OBV/Simple/OBV.idl +15 -15
  188. data/test/OBV/Simple/OBV_impl.rb +26 -26
  189. data/test/OBV/Simple/client.rb +86 -86
  190. data/test/OBV/Simple/run_test.rb +69 -69
  191. data/test/OBV/Simple/server.ior +1 -1
  192. data/test/OBV/Simple/server.rb +100 -100
  193. data/test/OBV/Simple_Event/Event.idl +15 -15
  194. data/test/OBV/Simple_Event/Event_impl.rb +26 -26
  195. data/test/OBV/Simple_Event/client.rb +86 -86
  196. data/test/OBV/Simple_Event/run_test.rb +69 -69
  197. data/test/OBV/Simple_Event/server.ior +1 -1
  198. data/test/OBV/Simple_Event/server.rb +100 -100
  199. data/test/OBV/Supports/client.rb +116 -116
  200. data/test/OBV/Supports/run_test.rb +69 -69
  201. data/test/OBV/Supports/server.ior +1 -1
  202. data/test/OBV/Supports/server.rb +103 -103
  203. data/test/OBV/Supports/supports.idl +33 -33
  204. data/test/OBV/Supports/supports_impl.rb +57 -57
  205. data/test/OBV/Tree/client.rb +116 -116
  206. data/test/OBV/Tree/run_test.rb +69 -69
  207. data/test/OBV/Tree/server.ior +1 -1
  208. data/test/OBV/Tree/server.rb +117 -117
  209. data/test/OBV/Tree/test.idl +32 -32
  210. data/test/OBV/Truncatable/Extra.idl +27 -27
  211. data/test/OBV/Truncatable/Truncatable.idl +105 -105
  212. data/test/OBV/Truncatable/Truncatable_impl.rb +86 -86
  213. data/test/OBV/Truncatable/client.rb +279 -279
  214. data/test/OBV/Truncatable/run_test.rb +69 -69
  215. data/test/OBV/Truncatable/server.ior +1 -1
  216. data/test/OBV/Truncatable/server.rb +89 -89
  217. data/test/OBV/ValueBox/client.rb +497 -497
  218. data/test/OBV/ValueBox/run_test.rb +69 -69
  219. data/test/OBV/ValueBox/server.ior +1 -1
  220. data/test/OBV/ValueBox/server.rb +271 -271
  221. data/test/OBV/ValueBox/valuebox.idl +101 -101
  222. data/test/OBV/ValueBox/vb_basic.idl +75 -75
  223. data/test/OBV/ValueBox/vb_struct.idl +68 -68
  224. data/test/OBV/ValueBox/vb_union.idl +21 -21
  225. data/test/Object/Test.idl +27 -27
  226. data/test/Object/client.rb +112 -103
  227. data/test/Object/run_test.rb +69 -69
  228. data/test/Object/server.ior +1 -1
  229. data/test/Object/server.rb +126 -126
  230. data/test/POA/Test.idl +27 -27
  231. data/test/POA/run_test.rb +52 -52
  232. data/test/POA/test.rb +111 -111
  233. data/test/Param_Test/Test.idl +182 -182
  234. data/test/Param_Test/client.rb +277 -277
  235. data/test/Param_Test/run_test.rb +69 -69
  236. data/test/Param_Test/server.ior +1 -1
  237. data/test/Param_Test/server.rb +296 -296
  238. data/test/Performance/Simple/Test.idl +27 -27
  239. data/test/Performance/Simple/client.rb +90 -90
  240. data/test/Performance/Simple/run_test.rb +69 -69
  241. data/test/Performance/Simple/server.ior +1 -1
  242. data/test/Performance/Simple/server.rb +95 -95
  243. data/test/Policies/Test.idl +27 -27
  244. data/test/Policies/run_test.rb +52 -52
  245. data/test/Policies/test.rb +144 -144
  246. data/test/Timeout/client.rb +207 -207
  247. data/test/Timeout/run_test.rb +69 -69
  248. data/test/Timeout/server.ior +1 -1
  249. data/test/Timeout/server.rb +109 -109
  250. data/test/Timeout/test.idl +19 -19
  251. data/test/lib/assert.rb +43 -43
  252. data/test/lib/test.rb +542 -542
  253. data/test/test_runner.rb +193 -193
  254. metadata +141 -137
@@ -1,128 +1,128 @@
1
- #--------------------------------------------------------------------
2
- # ServerRequest.rb - R2TAO CORBA ServerRequest 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
- module R2CORBA
15
-
16
- module CORBA
17
-
18
- module ServerRequest
19
- @@wrapper_klass = Class.new do
20
- include CORBA::ServerRequest
21
- def initialize(jsrvreq, jorb)
22
- @srvreq_ = jsrvreq
23
- @orb_ = jorb
24
- @nvlist_ = nil
25
- @result_type_ = nil
26
- @arg_list_ = nil
27
- @exc_list_ = nil
28
- @arg_ = nil
29
- @arg_index_ = nil
30
- @arg_out_ = 0
31
- end
32
- attr_reader :srvreq_
33
- attr_reader :orb_
34
- attr_reader :arg_list_
35
- attr_reader :result_type_
36
- attr_reader :exc_list_
37
- attr_reader :nvlist_
38
- attr_reader :arg_out_
39
- end
40
-
41
- def self._wrap_native(jsrvreq, jorb)
42
- raise ArgumentError, 'Expected org.omg.CORBA.ServerRequest' unless jsrvreq.is_a?(Native::ServerRequest)
43
- raise ArgumentError, 'Expected org.omg.CORBA.ORB' unless jorb.is_a?(Native::ORB)
44
- @@wrapper_klass.new(jsrvreq, jorb)
45
- end
46
-
47
- def operation
48
- begin
49
- self.srvreq_.operation
50
- rescue ::NativeException
51
- CORBA::Exception.native2r($!)
52
- end
53
- end
54
-
55
- def describe(opsig)
56
- raise CORBA::BAD_INV_ORDER.new('',0,CORBA::COMPLETED_NO) if @nvlist_
57
- raise CORBA::NO_IMPLEMENT.new('',0,CORBA::COMPLETED_NO) unless opsig && (Hash === opsig)
58
- @arg_list_ = opsig[:arg_list]
59
- @result_type_ = opsig[:result_type]
60
- @exc_list_ = opsig[:exc_list]
61
- raise CORBA::BAD_PARAM.new('',0,CORBA::COMPLETED_NO) unless (@arg_list_.nil? || @arg_list_.is_a?(Array)) &&
62
- (@result_type_.nil? || @result_type_.is_a?(CORBA::TypeCode)) &&
63
- (@exc_list_.nil? || @exc_list_.is_a?(Array))
64
- @nvlist_ = extract_arguments_(@arg_list_)
65
- self
66
- end
67
-
68
- def arguments
69
- raise CORBA::BAD_INV_ORDER.new('',0,CORBA::COMPLETED_NO) unless @nvlist_
70
- unless @arg_
71
- @arg_ = []
72
- @nvlist_.count().times do |i|
73
- jnv = @nvlist_.item(i)
74
- @arg_ << CORBA::Any.from_java(jnv.value, self.orb_, @arg_list_[i][2]) if [CORBA::ARG_IN, CORBA::ARG_INOUT].include?(jnv.flags)
75
- @arg_out_ += 1 if [CORBA::ARG_OUT, CORBA::ARG_INOUT].include?(jnv.flags)
76
- end
77
- end
78
- @arg_
79
- end
80
-
81
- def [](key)
82
- self.arguments # make sure the @arg_ member has been initialized
83
- key = arg_index_from_name(key) if String === key
84
- key = key.to_i if key
85
- raise CORBA::BAD_PARAM.new('', 0, CORBA::COMPLETD_NO) unless key && (key>=0) && (key<@arg_.size)
86
- @arg_[key]
87
- end
88
-
89
- def []=(key, val)
90
- self.arguments # make sure the @arg_ member has been initialized
91
- key = arg_index_from_name(key) if String === key
92
- key = key.to_i if key
93
- raise CORBA::BAD_PARAM.new('', 0, CORBA::COMPLETD_NO) unless key && (key>=0) && (key<@arg_.size)
94
- jnv = @nvlist_.item(key)
95
- rtc = @arg_list_[key][2]
96
- CORBA::Any.to_any(val, rtc).to_java(self.orb_, jnv.value())
97
- @arg_[key] = val
98
- end
99
-
100
- protected
101
- def arg_index_from_name(arg_name)
102
- unless @arg_index_
103
- @arg_index_ = {}
104
- @nvlist_.count().times do |i|
105
- jnv = @nvlist_.item(i)
106
- @arg_index_[jnv.name] = i
107
- end
108
- end
109
- @arg_index_[arg_name]
110
- end
111
-
112
- def extract_arguments_(arg_list)
113
- jnvlist = self.orb_.create_list(0)
114
- unless arg_list.nil?
115
- arg_list.each do |argnm, argf, argtc|
116
- raise CORBA::BAD_PARAM.new('', 0, CORBA::COMPLETED_NO) if argf.nil? || argtc.nil? || !argtc.is_a?(CORBA::TypeCode)
117
- jnvlist.add_value(argnm.to_s, Any.to_any(nil,argtc).to_java(@orb_), argf.to_i)
118
- end
119
- self.srvreq_.arguments(jnvlist)
120
- end
121
- jnvlist
122
- end
123
-
124
- end # ServerRequest
125
-
126
- end # CORBA
127
-
1
+ #--------------------------------------------------------------------
2
+ # ServerRequest.rb - R2TAO CORBA ServerRequest 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
+ module R2CORBA
15
+
16
+ module CORBA
17
+
18
+ module ServerRequest
19
+ @@wrapper_klass = Class.new do
20
+ include CORBA::ServerRequest
21
+ def initialize(jsrvreq, jorb)
22
+ @srvreq_ = jsrvreq
23
+ @orb_ = jorb
24
+ @nvlist_ = nil
25
+ @result_type_ = nil
26
+ @arg_list_ = nil
27
+ @exc_list_ = nil
28
+ @arg_ = nil
29
+ @arg_index_ = nil
30
+ @arg_out_ = 0
31
+ end
32
+ attr_reader :srvreq_
33
+ attr_reader :orb_
34
+ attr_reader :arg_list_
35
+ attr_reader :result_type_
36
+ attr_reader :exc_list_
37
+ attr_reader :nvlist_
38
+ attr_reader :arg_out_
39
+ end
40
+
41
+ def self._wrap_native(jsrvreq, jorb)
42
+ raise ArgumentError, 'Expected org.omg.CORBA.ServerRequest' unless jsrvreq.is_a?(Native::ServerRequest)
43
+ raise ArgumentError, 'Expected org.omg.CORBA.ORB' unless jorb.is_a?(Native::ORB)
44
+ @@wrapper_klass.new(jsrvreq, jorb)
45
+ end
46
+
47
+ def operation
48
+ begin
49
+ self.srvreq_.operation
50
+ rescue ::NativeException
51
+ CORBA::Exception.native2r($!)
52
+ end
53
+ end
54
+
55
+ def describe(opsig)
56
+ raise CORBA::BAD_INV_ORDER.new('',0,CORBA::COMPLETED_NO) if @nvlist_
57
+ raise CORBA::NO_IMPLEMENT.new('',0,CORBA::COMPLETED_NO) unless opsig && (Hash === opsig)
58
+ @arg_list_ = opsig[:arg_list]
59
+ @result_type_ = opsig[:result_type]
60
+ @exc_list_ = opsig[:exc_list]
61
+ raise CORBA::BAD_PARAM.new('',0,CORBA::COMPLETED_NO) unless (@arg_list_.nil? || @arg_list_.is_a?(Array)) &&
62
+ (@result_type_.nil? || @result_type_.is_a?(CORBA::TypeCode)) &&
63
+ (@exc_list_.nil? || @exc_list_.is_a?(Array))
64
+ @nvlist_ = extract_arguments_(@arg_list_)
65
+ self
66
+ end
67
+
68
+ def arguments
69
+ raise CORBA::BAD_INV_ORDER.new('',0,CORBA::COMPLETED_NO) unless @nvlist_
70
+ unless @arg_
71
+ @arg_ = []
72
+ @nvlist_.count().times do |i|
73
+ jnv = @nvlist_.item(i)
74
+ @arg_ << CORBA::Any.from_java(jnv.value, self.orb_, @arg_list_[i][2]) if [CORBA::ARG_IN, CORBA::ARG_INOUT].include?(jnv.flags)
75
+ @arg_out_ += 1 if [CORBA::ARG_OUT, CORBA::ARG_INOUT].include?(jnv.flags)
76
+ end
77
+ end
78
+ @arg_
79
+ end
80
+
81
+ def [](key)
82
+ self.arguments # make sure the @arg_ member has been initialized
83
+ key = arg_index_from_name(key) if String === key
84
+ key = key.to_i if key
85
+ raise CORBA::BAD_PARAM.new('', 0, CORBA::COMPLETD_NO) unless key && (key>=0) && (key<@arg_.size)
86
+ @arg_[key]
87
+ end
88
+
89
+ def []=(key, val)
90
+ self.arguments # make sure the @arg_ member has been initialized
91
+ key = arg_index_from_name(key) if String === key
92
+ key = key.to_i if key
93
+ raise CORBA::BAD_PARAM.new('', 0, CORBA::COMPLETD_NO) unless key && (key>=0) && (key<@arg_.size)
94
+ jnv = @nvlist_.item(key)
95
+ rtc = @arg_list_[key][2]
96
+ CORBA::Any.to_any(val, rtc).to_java(self.orb_, jnv.value())
97
+ @arg_[key] = val
98
+ end
99
+
100
+ protected
101
+ def arg_index_from_name(arg_name)
102
+ unless @arg_index_
103
+ @arg_index_ = {}
104
+ @nvlist_.count().times do |i|
105
+ jnv = @nvlist_.item(i)
106
+ @arg_index_[jnv.name] = i
107
+ end
108
+ end
109
+ @arg_index_[arg_name]
110
+ end
111
+
112
+ def extract_arguments_(arg_list)
113
+ jnvlist = self.orb_.create_list(0)
114
+ unless arg_list.nil?
115
+ arg_list.each do |argnm, argf, argtc|
116
+ raise CORBA::BAD_PARAM.new('', 0, CORBA::COMPLETED_NO) if argf.nil? || argtc.nil? || !argtc.is_a?(CORBA::TypeCode)
117
+ jnvlist.add_value(argnm.to_s, Any.to_any(nil,argtc).to_java(@orb_), argf.to_i)
118
+ end
119
+ self.srvreq_.arguments(jnvlist)
120
+ end
121
+ jnvlist
122
+ end
123
+
124
+ end # ServerRequest
125
+
126
+ end # CORBA
127
+
128
128
  end # R2CORBA
@@ -1,671 +1,671 @@
1
- #--------------------------------------------------------------------
2
- # Streams.rb - Java/JacORB Definition of CORBA CDR Streams
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
- module R2CORBA
15
- module CORBA
16
- module Portable
17
- module InputStream
18
- @@wrapper_klass = Class.new do
19
- include CORBA::Portable::InputStream
20
- def initialize(jobj)
21
- @stream_ = jobj
22
- end
23
- attr_reader :stream_
24
- end
25
-
26
- def self._wrap_native(jobj)
27
- if jobj.nil? || !jobj.is_a?(Native::V2_3::Portable::InputStream)
28
- raise ArgumentError, 'Expected org.omg.CORBA.portable.InputStream'
29
- end
30
- @@wrapper_klass.new(jobj)
31
- end
32
-
33
- def read_member(tc)
34
- tc = tc.resolved_tc # takes care of recursive typecodes
35
- v = case tc.kind
36
- when TK_ANY
37
- read_any()
38
- when TK_BOOLEAN
39
- read_boolean()
40
- when TK_SHORT
41
- read_short()
42
- when TK_LONG
43
- read_long()
44
- when TK_USHORT
45
- read_ushort()
46
- when TK_WCHAR
47
- read_wchar()
48
- when TK_ULONG
49
- read_ulong()
50
- when TK_LONGLONG
51
- read_longlong()
52
- when TK_ULONGLONG
53
- read_ulonglong()
54
- when TK_OCTET
55
- read_octet()
56
- when TK_FLOAT
57
- read_float()
58
- when TK_DOUBLE
59
- read_double()
60
- when TK_LONGDOUBLE
61
- raise CORBA::NO_IMPLEMENT.new('LongDouble not supported',0,CORBA::COMPLETED_NO)
62
- when TK_FIXED
63
- read_fixed()
64
- when TK_CHAR
65
- read_char()
66
- when TK_STRING
67
- read_string()
68
- when TK_WSTRING
69
- read_wstring()
70
- when TK_OBJREF
71
- read_Object()
72
- when TK_TYPECODE
73
- read_TypeCode()
74
- when TK_ARRAY, TK_SEQUENCE,
75
- TK_ENUM, TK_STRUCT, TK_EXCEPT, TK_UNION,
76
- TK_PRINCIPAL
77
- read_construct(tc)
78
- when TK_ABSTRACT_INTERFACE
79
- read_Abstract()
80
- when TK_VALUE
81
- read_value()
82
- when TK_VALUE_BOX
83
- read_valuebox(tc.get_type.boxedvalue_helper)
84
- ## TODO: TK_NATIVE
85
- end
86
- v
87
- end
88
-
89
- def read_any()
90
- begin
91
- self.stream_.read_any()
92
- rescue ::NativeException
93
- CORBA::Exception.native2r($!)
94
- end
95
- end
96
- def read_boolean()
97
- begin
98
- self.stream_.read_boolean()
99
- rescue ::NativeException
100
- CORBA::Exception.native2r($!)
101
- end
102
- end
103
- def read_boolean_array(arr, offset, length)
104
- jarr = Array.new(arr.size).to_java(:boolean)
105
- begin
106
- self.stream_.read_boolean_array(jarr, offset, length)
107
- rescue ::NativeException
108
- CORBA::Exception.native2r($!)
109
- end
110
- arr.fill(offset, length) {|i| jarr[i]}
111
- end
112
- def read_char()
113
- begin
114
- self.stream_.read_char().chr
115
- rescue ::NativeException
116
- CORBA::Exception.native2r($!)
117
- end
118
- end
119
- def read_char_array(arr, offset, length)
120
- jarr = Array.new(arr.size).to_java(:char)
121
- begin
122
- self.stream_.read_char_array(jarr, offset, length)
123
- rescue ::NativeException
124
- CORBA::Exception.native2r($!)
125
- end
126
- arr.fill(offset, length) {|i| jarr[i].chr }
127
- end
128
- def read_wchar()
129
- begin
130
- self.stream_.read_wchar()
131
- rescue ::NativeException
132
- CORBA::Exception.native2r($!)
133
- end
134
- end
135
- def read_wchar_array(arr, offset, length)
136
- jarr = Array.new(arr.size).to_java(:char)
137
- begin
138
- self.stream_.read_char_array(jarr, offset, length)
139
- rescue ::NativeException
140
- CORBA::Exception.native2r($!)
141
- end
142
- arr.fill(offset, length) {|i| jarr[i] }
143
- end
144
- def read_octet(value)
145
- begin
146
- [self.stream_.read_octet()].pack('c').unpack('C').first
147
- rescue ::NativeException
148
- CORBA::Exception.native2r($!)
149
- end
150
- end
151
- def read_octet_array(arr, offset, length)
152
- jarr = Array.new(arr.size).to_java(:byte)
153
- begin
154
- self.stream_.read_octet_array(jarr, offset, length)
155
- rescue ::NativeException
156
- CORBA::Exception.native2r($!)
157
- end
158
- jarr = jarr.pack('c*').unpack('C*')
159
- arr.fill(offset, length) {|i| jarr[i] }
160
- end
161
- def read_short()
162
- begin
163
- self.stream_.read_short()
164
- rescue ::NativeException
165
- CORBA::Exception.native2r($!)
166
- end
167
- end
168
- def read_short_array(arr, offset, length)
169
- jarr = Array.new(arr.size).to_java(:short)
170
- begin
171
- self.stream_.read_short_array(jarr, offset, length)
172
- rescue ::NativeException
173
- CORBA::Exception.native2r($!)
174
- end
175
- arr.fill(offset, length) {|i| jarr[i] }
176
- end
177
- def read_ushort()
178
- begin
179
- [self.stream_.read_ushort()].pack('s').unpack('S').first
180
- rescue ::NativeException
181
- CORBA::Exception.native2r($!)
182
- end
183
- end
184
- def read_ushort_array(arr, offset, length)
185
- jarr = Array.new(arr.size).to_java(:short)
186
- begin
187
- self.stream_.read_octet_array(jarr, offset, length)
188
- rescue ::NativeException
189
- CORBA::Exception.native2r($!)
190
- end
191
- jarr = jarr.pack('s*').unpack('S*')
192
- arr.fill(offset, length) {|i| jarr[i] }
193
- end
194
- def read_long()
195
- begin
196
- self.stream_.read_long()
197
- rescue ::NativeException
198
- CORBA::Exception.native2r($!)
199
- end
200
- end
201
- def read_long_array(arr, offset, length)
202
- jarr = Array.new(arr.size).to_java(:int)
203
- begin
204
- self.stream_.read_long_array(jarr, offset, length)
205
- rescue ::NativeException
206
- CORBA::Exception.native2r($!)
207
- end
208
- arr.fill(offset, length) {|i| jarr[i] }
209
- end
210
- def read_ulong()
211
- begin
212
- [self.stream_.read_ulong()].pack('l').unpack('L').first
213
- rescue ::NativeException
214
- CORBA::Exception.native2r($!)
215
- end
216
- end
217
- def read_ulong_array(arr, offset, length)
218
- jarr = Array.new(arr.size).to_java(:int)
219
- begin
220
- self.stream_.read_ulong_array(jarr, offset, length)
221
- rescue ::NativeException
222
- CORBA::Exception.native2r($!)
223
- end
224
- jarr = jarr.pack('l*').unpack('L*')
225
- arr.fill(offset, length) {|i| jarr[i] }
226
- end
227
- def read_longlong()
228
- begin
229
- self.stream_.read_longlong()
230
- rescue ::NativeException
231
- CORBA::Exception.native2r($!)
232
- end
233
- end
234
- def read_longlong_array(arr, offset, length)
235
- jarr = Array.new(arr.size).to_java(:long)
236
- begin
237
- self.stream_.read_longlong_array(jarr, offset, length)
238
- rescue ::NativeException
239
- CORBA::Exception.native2r($!)
240
- end
241
- arr.fill(offset, length) {|i| jarr[i] }
242
- end
243
- def read_ulonglong()
244
- begin
245
- [self.stream_.read_ulonglong()].pack('q').unpack('Q').first
246
- rescue ::NativeException
247
- CORBA::Exception.native2r($!)
248
- end
249
- end
250
- def read_ulonglong_array(arr, offset, length)
251
- jarr = Array.new(arr.size).to_java(:long)
252
- begin
253
- self.stream_.read_ulonglong_array(jarr, offset, length)
254
- rescue ::NativeException
255
- CORBA::Exception.native2r($!)
256
- end
257
- jarr = jarr.pack('q*').unpack('Q*')
258
- arr.fill(offset, length) {|i| jarr[i] }
259
- end
260
- def read_float()
261
- begin
262
- self.stream_.read_float()
263
- rescue ::NativeException
264
- CORBA::Exception.native2r($!)
265
- end
266
- end
267
- def read_float_array(arr, offset, length)
268
- jarr = Array.new(arr.size).to_java(:float)
269
- begin
270
- self.stream_.read_float_array(jarr, offset, length)
271
- rescue ::NativeException
272
- CORBA::Exception.native2r($!)
273
- end
274
- arr.fill(offset, length) {|i| jarr[i] }
275
- end
276
- def read_double()
277
- begin
278
- self.stream_.read_double()
279
- rescue ::NativeException
280
- CORBA::Exception.native2r($!)
281
- end
282
- end
283
- def read_double_array(arr, offset, length)
284
- jarr = Array.new(arr.size).to_java(:double)
285
- begin
286
- self.stream_.read_double_array(jarr, offset, length)
287
- rescue ::NativeException
288
- CORBA::Exception.native2r($!)
289
- end
290
- arr.fill(offset, length) {|i| jarr[i] }
291
- end
292
- def read_string()
293
- begin
294
- self.stream_.read_string()
295
- rescue ::NativeException
296
- CORBA::Exception.native2r($!)
297
- end
298
- end
299
- def read_wstring()
300
- begin
301
- self.stream_.read_wstring()
302
- rescue ::NativeException
303
- CORBA::Exception.native2r($!)
304
- end
305
- end
306
- def read_Object()
307
- begin
308
- CORBA::Object._wrap_native(self.stream_().read_Object())
309
- rescue ::NativeException
310
- CORBA::Exception.native2r($!)
311
- end
312
- end
313
- def read_TypeCode()
314
- begin
315
- CORBA::TypeCode._wrap_native(self.stream_().read_TypeCode())
316
- rescue ::NativeException
317
- CORBA::Exception.native2r($!)
318
- end
319
- end
320
- def read_fixed()
321
- begin
322
- java.math.BigDecimal.new(self.stream_.read_fixed().toString())
323
- rescue ::NativeException
324
- CORBA::Exception.native2r($!)
325
- end
326
- end
327
- def read_construct(tc)
328
- begin
329
- jany = self.stream_.orb().create_any()
330
- jany.read_value(self.stream_, tc.tc_)
331
- CORBA::Any.from_java(jany, self.stream_.orb(), tc)
332
- rescue ::NativeException
333
- CORBA::Exception.native2r($!)
334
- end
335
- end
336
- def read_Abstract()
337
- begin
338
- obj = self.stream_.read_abstract_interface()
339
- rescue ::NativeException
340
- CORBA::Exception.native2r($!)
341
- end
342
- obj = CORBA::Object._wrap_native(obj) if obj.is_a?(CORBA::Native::Object)
343
- obj
344
- end
345
- def read_value()
346
- begin
347
- self.stream_.read_value()
348
- rescue ::NativeException
349
- CORBA::Exception.native2r($!)
350
- end
351
- end
352
- alias :read_Value :read_value
353
- def read_valuebox(boxedvalue_helper)
354
- begin
355
- self.stream_.read_value(boxedvalue_helper)
356
- rescue ::NativeException
357
- CORBA::Exception.native2r($!)
358
- end
359
- end
360
- end
361
-
362
- module OutputStream
363
- @@wrapper_klass = Class.new do
364
- include CORBA::Portable::OutputStream
365
- def initialize(jobj)
366
- @stream_ = jobj
367
- end
368
- attr_reader :stream_
369
- end
370
-
371
- def self._wrap_native(jobj)
372
- if jobj.nil? || !jobj.is_a?(Native::V2_3::Portable::OutputStream)
373
- raise ArgumentError, 'Expected org.omg.CORBA.portable.OutputStream'
374
- end
375
- @@wrapper_klass.new(jobj)
376
- end
377
-
378
- def write_member(tc, value)
379
- tc = tc.resolved_tc # takes care of recursive typecodes
380
- case tc.kind
381
- when TK_ANY
382
- write_any(value)
383
- when TK_BOOLEAN
384
- write_boolean(value)
385
- when TK_SHORT
386
- write_short(value)
387
- when TK_LONG
388
- write_long(value)
389
- when TK_USHORT
390
- write_ushort(value)
391
- when TK_WCHAR
392
- write_wchar(value)
393
- when TK_ULONG
394
- write_ulong(value)
395
- when TK_LONGLONG
396
- write_longlong(value)
397
- when TK_ULONGLONG
398
- write_ulonglong(value)
399
- when TK_OCTET
400
- write_octet(value)
401
- when TK_FLOAT
402
- write_float(value)
403
- when TK_DOUBLE
404
- write_double(value)
405
- when TK_LONGDOUBLE
406
- raise CORBA::NO_IMPLEMENT.new('LongDouble not supported',0,CORBA::COMPLETED_NO)
407
- when TK_FIXED
408
- write_fixed(value)
409
- when TK_CHAR
410
- write_char(value)
411
- when TK_STRING
412
- write_string(value)
413
- when TK_WSTRING
414
- write_wstring(value)
415
- when TK_OBJREF
416
- write_Object(value)
417
- when TK_TYPECODE
418
- write_TypeCode(value)
419
- when TK_ARRAY, TK_SEQUENCE,
420
- TK_ENUM, TK_STRUCT, TK_EXCEPT, TK_UNION,
421
- TK_PRINCIPAL
422
- write_construct(value, tc)
423
- when TK_ABSTRACT_INTERFACE
424
- write_Abstract(value)
425
- when TK_VALUE
426
- write_value(value)
427
- when TK_VALUE_BOX
428
- write_valuebox(value, tc.get_type().boxedvalue_helper())
429
- ## TODO: TK_NATIVE
430
- end
431
- end
432
-
433
- def write_any(value)
434
- begin
435
- self.stream_.write_any(value)
436
- rescue ::NativeException
437
- CORBA::Exception.native2r($!)
438
- end
439
- end
440
- def write_boolean(value)
441
- begin
442
- self.stream_.write_boolean(value)
443
- rescue ::NativeException
444
- CORBA::Exception.native2r($!)
445
- end
446
- end
447
- def write_boolean_array(value, offset, length)
448
- begin
449
- self.stream_.write_boolean_array(value.to_java(:boolean), offset, length)
450
- rescue ::NativeException
451
- CORBA::Exception.native2r($!)
452
- end
453
- end
454
- def write_char(value)
455
- begin
456
- self.stream_.write_char(value[0])
457
- rescue ::NativeException
458
- CORBA::Exception.native2r($!)
459
- end
460
- end
461
- def write_char_array(value, offset, length)
462
- begin
463
- self.stream_.write_char_array(value.collect{|c| c[0]}.to_java(:char), offset, length)
464
- rescue ::NativeException
465
- CORBA::Exception.native2r($!)
466
- end
467
- end
468
- def write_wchar(value)
469
- self.stream_.write_wchar(value)
470
- end
471
- def write_wchar_array(value, offset, length)
472
- begin
473
- self.stream_.write_wchar_array(value.to_java(:char), offset, length)
474
- rescue ::NativeException
475
- CORBA::Exception.native2r($!)
476
- end
477
- end
478
- def write_octet(value)
479
- begin
480
- self.stream_.write_octet([value].pack('C').unpack('c').first)
481
- rescue ::NativeException
482
- CORBA::Exception.native2r($!)
483
- end
484
- end
485
- def write_octet_array(value, offset, length)
486
- begin
487
- self.stream_.write_octet_array(value.pack('C*').unpack('c*').to_java(:byte), offset, length)
488
- rescue ::NativeException
489
- CORBA::Exception.native2r($!)
490
- end
491
- end
492
- def write_short(value)
493
- begin
494
- self.stream_.write_short(value)
495
- rescue ::NativeException
496
- CORBA::Exception.native2r($!)
497
- end
498
- end
499
- def write_short_array(value, offset, length)
500
- begin
501
- self.stream_.write_short_array(value.to_java(:short), offset, length)
502
- rescue ::NativeException
503
- CORBA::Exception.native2r($!)
504
- end
505
- end
506
- def write_ushort(value)
507
- begin
508
- self.stream_.write_ushort([value].pack('S').unpack('s').first)
509
- rescue ::NativeException
510
- CORBA::Exception.native2r($!)
511
- end
512
- end
513
- def write_ushort_array(value, offset, length)
514
- begin
515
- self.stream_.write_ushort_array(value.pack('S*').unpack('s*').to_java(:short), offset, length)
516
- rescue ::NativeException
517
- CORBA::Exception.native2r($!)
518
- end
519
- end
520
- def write_long(value)
521
- begin
522
- self.stream_.write_long(value)
523
- rescue ::NativeException
524
- CORBA::Exception.native2r($!)
525
- end
526
- end
527
- def write_long_array(value, offset, length)
528
- begin
529
- self.stream_.write_long_array(value.to_java(:int), offset, length)
530
- rescue ::NativeException
531
- CORBA::Exception.native2r($!)
532
- end
533
- end
534
- def write_ulong(value)
535
- begin
536
- self.stream_.write_ulong([value].pack('L').unpack('l').first)
537
- rescue ::NativeException
538
- CORBA::Exception.native2r($!)
539
- end
540
- end
541
- def write_ulong_array(value, offset, length)
542
- begin
543
- self.stream_.write_ulong_array(value.pack('L*').unpack('l*').to_java(:int), offset, length)
544
- rescue ::NativeException
545
- CORBA::Exception.native2r($!)
546
- end
547
- end
548
- def write_longlong(value)
549
- begin
550
- self.stream_.write_longlong(value)
551
- rescue ::NativeException
552
- CORBA::Exception.native2r($!)
553
- end
554
- end
555
- def write_longlong_array(value, offset, length)
556
- begin
557
- self.stream_.write_longlong_array(value.to_java(:long), offset, length)
558
- rescue ::NativeException
559
- CORBA::Exception.native2r($!)
560
- end
561
- end
562
- def write_ulonglong(value)
563
- begin
564
- self.stream_.write_ulonglong([value].pack('Q').unpack('q').first)
565
- rescue ::NativeException
566
- CORBA::Exception.native2r($!)
567
- end
568
- end
569
- def write_ulonglong_array(value, offset, length)
570
- begin
571
- self.stream_.write_ulonglong_array(value.pack('Q*').unpack('q*').to_java(:long), offset, length)
572
- rescue ::NativeException
573
- CORBA::Exception.native2r($!)
574
- end
575
- end
576
- def write_float(value)
577
- begin
578
- self.stream_.write_float(value)
579
- rescue ::NativeException
580
- CORBA::Exception.native2r($!)
581
- end
582
- end
583
- def write_float_array(value, offset, length)
584
- begin
585
- self.stream_.write_float_array(value.to_java(:float), offset, length)
586
- rescue ::NativeException
587
- CORBA::Exception.native2r($!)
588
- end
589
- end
590
- def write_double(value)
591
- begin
592
- self.stream_.write_double(value)
593
- rescue ::NativeException
594
- CORBA::Exception.native2r($!)
595
- end
596
- end
597
- def write_double_array(value, offset, length)
598
- begin
599
- self.stream_.write_double_array(value.to_java(:double), offset, length)
600
- rescue ::NativeException
601
- CORBA::Exception.native2r($!)
602
- end
603
- end
604
- def write_string(value)
605
- begin
606
- self.stream_.write_string(value)
607
- rescue ::NativeException
608
- CORBA::Exception.native2r($!)
609
- end
610
- end
611
- def write_wstring(value)
612
- begin
613
- self.stream_.write_wstring(value.inject('') {|s,b| s << b.chr})
614
- rescue ::NativeException
615
- CORBA::Exception.native2r($!)
616
- end
617
- end
618
- def write_fixed(value)
619
- begin
620
- self.stream_.write_fixed(java.math.BigDecimal.new(value.to_s))
621
- rescue ::NativeException
622
- CORBA::Exception.native2r($!)
623
- end
624
- end
625
- def write_Object(value)
626
- begin
627
- self.stream_.write_Object(value.objref_)
628
- rescue ::NativeException
629
- CORBA::Exception.native2r($!)
630
- end
631
- end
632
- def write_TypeCode(value)
633
- begin
634
- self.stream_.write_TypeCode(value.tc_)
635
- rescue ::NativeException
636
- CORBA::Exception.native2r($!)
637
- end
638
- end
639
- def write_construct(value, tc)
640
- begin
641
- CORBA::Any.to_any(value, tc).to_java(self.stream_().orb()).write_value(self.stream_)
642
- rescue ::NativeException
643
- CORBA::Exception.native2r($!)
644
- end
645
- end
646
- def write_Abstract(value)
647
- begin
648
- self.stream_().write_abstract_interface(value.is_a?(CORBA::Object) ? value.objref_ : value)
649
- rescue ::NativeException
650
- CORBA::Exception.native2r($!)
651
- end
652
- end
653
- def write_value(value)
654
- begin
655
- self.stream_.write_value(value)
656
- rescue ::NativeException
657
- CORBA::Exception.native2r($!)
658
- end
659
- end
660
- alias :write_Value :write_value
661
- def write_valuebox(value, boxedvalue_helper)
662
- begin
663
- self.stream_.write_value(value, boxedvalue_helper)
664
- rescue ::NativeException
665
- CORBA::Exception.native2r($!)
666
- end
667
- end
668
- end
669
- end
670
- end
1
+ #--------------------------------------------------------------------
2
+ # Streams.rb - Java/JacORB Definition of CORBA CDR Streams
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
+ module R2CORBA
15
+ module CORBA
16
+ module Portable
17
+ module InputStream
18
+ @@wrapper_klass = Class.new do
19
+ include CORBA::Portable::InputStream
20
+ def initialize(jobj)
21
+ @stream_ = jobj
22
+ end
23
+ attr_reader :stream_
24
+ end
25
+
26
+ def self._wrap_native(jobj)
27
+ if jobj.nil? || !jobj.is_a?(Native::V2_3::Portable::InputStream)
28
+ raise ArgumentError, 'Expected org.omg.CORBA.portable.InputStream'
29
+ end
30
+ @@wrapper_klass.new(jobj)
31
+ end
32
+
33
+ def read_member(tc)
34
+ tc = tc.resolved_tc # takes care of recursive typecodes
35
+ v = case tc.kind
36
+ when TK_ANY
37
+ read_any()
38
+ when TK_BOOLEAN
39
+ read_boolean()
40
+ when TK_SHORT
41
+ read_short()
42
+ when TK_LONG
43
+ read_long()
44
+ when TK_USHORT
45
+ read_ushort()
46
+ when TK_WCHAR
47
+ read_wchar()
48
+ when TK_ULONG
49
+ read_ulong()
50
+ when TK_LONGLONG
51
+ read_longlong()
52
+ when TK_ULONGLONG
53
+ read_ulonglong()
54
+ when TK_OCTET
55
+ read_octet()
56
+ when TK_FLOAT
57
+ read_float()
58
+ when TK_DOUBLE
59
+ read_double()
60
+ when TK_LONGDOUBLE
61
+ raise CORBA::NO_IMPLEMENT.new('LongDouble not supported',0,CORBA::COMPLETED_NO)
62
+ when TK_FIXED
63
+ read_fixed()
64
+ when TK_CHAR
65
+ read_char()
66
+ when TK_STRING
67
+ read_string()
68
+ when TK_WSTRING
69
+ read_wstring()
70
+ when TK_OBJREF
71
+ read_Object()
72
+ when TK_TYPECODE
73
+ read_TypeCode()
74
+ when TK_ARRAY, TK_SEQUENCE,
75
+ TK_ENUM, TK_STRUCT, TK_EXCEPT, TK_UNION,
76
+ TK_PRINCIPAL
77
+ read_construct(tc)
78
+ when TK_ABSTRACT_INTERFACE
79
+ read_Abstract()
80
+ when TK_VALUE
81
+ read_value()
82
+ when TK_VALUE_BOX
83
+ read_valuebox(tc.get_type.boxedvalue_helper)
84
+ ## TODO: TK_NATIVE
85
+ end
86
+ v
87
+ end
88
+
89
+ def read_any()
90
+ begin
91
+ self.stream_.read_any()
92
+ rescue ::NativeException
93
+ CORBA::Exception.native2r($!)
94
+ end
95
+ end
96
+ def read_boolean()
97
+ begin
98
+ self.stream_.read_boolean()
99
+ rescue ::NativeException
100
+ CORBA::Exception.native2r($!)
101
+ end
102
+ end
103
+ def read_boolean_array(arr, offset, length)
104
+ jarr = Array.new(arr.size).to_java(:boolean)
105
+ begin
106
+ self.stream_.read_boolean_array(jarr, offset, length)
107
+ rescue ::NativeException
108
+ CORBA::Exception.native2r($!)
109
+ end
110
+ arr.fill(offset, length) {|i| jarr[i]}
111
+ end
112
+ def read_char()
113
+ begin
114
+ self.stream_.read_char().chr
115
+ rescue ::NativeException
116
+ CORBA::Exception.native2r($!)
117
+ end
118
+ end
119
+ def read_char_array(arr, offset, length)
120
+ jarr = Array.new(arr.size).to_java(:char)
121
+ begin
122
+ self.stream_.read_char_array(jarr, offset, length)
123
+ rescue ::NativeException
124
+ CORBA::Exception.native2r($!)
125
+ end
126
+ arr.fill(offset, length) {|i| jarr[i].chr }
127
+ end
128
+ def read_wchar()
129
+ begin
130
+ self.stream_.read_wchar()
131
+ rescue ::NativeException
132
+ CORBA::Exception.native2r($!)
133
+ end
134
+ end
135
+ def read_wchar_array(arr, offset, length)
136
+ jarr = Array.new(arr.size).to_java(:char)
137
+ begin
138
+ self.stream_.read_char_array(jarr, offset, length)
139
+ rescue ::NativeException
140
+ CORBA::Exception.native2r($!)
141
+ end
142
+ arr.fill(offset, length) {|i| jarr[i] }
143
+ end
144
+ def read_octet(value)
145
+ begin
146
+ [self.stream_.read_octet()].pack('c').unpack('C').first
147
+ rescue ::NativeException
148
+ CORBA::Exception.native2r($!)
149
+ end
150
+ end
151
+ def read_octet_array(arr, offset, length)
152
+ jarr = Array.new(arr.size).to_java(:byte)
153
+ begin
154
+ self.stream_.read_octet_array(jarr, offset, length)
155
+ rescue ::NativeException
156
+ CORBA::Exception.native2r($!)
157
+ end
158
+ jarr = jarr.pack('c*').unpack('C*')
159
+ arr.fill(offset, length) {|i| jarr[i] }
160
+ end
161
+ def read_short()
162
+ begin
163
+ self.stream_.read_short()
164
+ rescue ::NativeException
165
+ CORBA::Exception.native2r($!)
166
+ end
167
+ end
168
+ def read_short_array(arr, offset, length)
169
+ jarr = Array.new(arr.size).to_java(:short)
170
+ begin
171
+ self.stream_.read_short_array(jarr, offset, length)
172
+ rescue ::NativeException
173
+ CORBA::Exception.native2r($!)
174
+ end
175
+ arr.fill(offset, length) {|i| jarr[i] }
176
+ end
177
+ def read_ushort()
178
+ begin
179
+ [self.stream_.read_ushort()].pack('s').unpack('S').first
180
+ rescue ::NativeException
181
+ CORBA::Exception.native2r($!)
182
+ end
183
+ end
184
+ def read_ushort_array(arr, offset, length)
185
+ jarr = Array.new(arr.size).to_java(:short)
186
+ begin
187
+ self.stream_.read_octet_array(jarr, offset, length)
188
+ rescue ::NativeException
189
+ CORBA::Exception.native2r($!)
190
+ end
191
+ jarr = jarr.pack('s*').unpack('S*')
192
+ arr.fill(offset, length) {|i| jarr[i] }
193
+ end
194
+ def read_long()
195
+ begin
196
+ self.stream_.read_long()
197
+ rescue ::NativeException
198
+ CORBA::Exception.native2r($!)
199
+ end
200
+ end
201
+ def read_long_array(arr, offset, length)
202
+ jarr = Array.new(arr.size).to_java(:int)
203
+ begin
204
+ self.stream_.read_long_array(jarr, offset, length)
205
+ rescue ::NativeException
206
+ CORBA::Exception.native2r($!)
207
+ end
208
+ arr.fill(offset, length) {|i| jarr[i] }
209
+ end
210
+ def read_ulong()
211
+ begin
212
+ [self.stream_.read_ulong()].pack('l').unpack('L').first
213
+ rescue ::NativeException
214
+ CORBA::Exception.native2r($!)
215
+ end
216
+ end
217
+ def read_ulong_array(arr, offset, length)
218
+ jarr = Array.new(arr.size).to_java(:int)
219
+ begin
220
+ self.stream_.read_ulong_array(jarr, offset, length)
221
+ rescue ::NativeException
222
+ CORBA::Exception.native2r($!)
223
+ end
224
+ jarr = jarr.pack('l*').unpack('L*')
225
+ arr.fill(offset, length) {|i| jarr[i] }
226
+ end
227
+ def read_longlong()
228
+ begin
229
+ self.stream_.read_longlong()
230
+ rescue ::NativeException
231
+ CORBA::Exception.native2r($!)
232
+ end
233
+ end
234
+ def read_longlong_array(arr, offset, length)
235
+ jarr = Array.new(arr.size).to_java(:long)
236
+ begin
237
+ self.stream_.read_longlong_array(jarr, offset, length)
238
+ rescue ::NativeException
239
+ CORBA::Exception.native2r($!)
240
+ end
241
+ arr.fill(offset, length) {|i| jarr[i] }
242
+ end
243
+ def read_ulonglong()
244
+ begin
245
+ [self.stream_.read_ulonglong()].pack('q').unpack('Q').first
246
+ rescue ::NativeException
247
+ CORBA::Exception.native2r($!)
248
+ end
249
+ end
250
+ def read_ulonglong_array(arr, offset, length)
251
+ jarr = Array.new(arr.size).to_java(:long)
252
+ begin
253
+ self.stream_.read_ulonglong_array(jarr, offset, length)
254
+ rescue ::NativeException
255
+ CORBA::Exception.native2r($!)
256
+ end
257
+ jarr = jarr.pack('q*').unpack('Q*')
258
+ arr.fill(offset, length) {|i| jarr[i] }
259
+ end
260
+ def read_float()
261
+ begin
262
+ self.stream_.read_float()
263
+ rescue ::NativeException
264
+ CORBA::Exception.native2r($!)
265
+ end
266
+ end
267
+ def read_float_array(arr, offset, length)
268
+ jarr = Array.new(arr.size).to_java(:float)
269
+ begin
270
+ self.stream_.read_float_array(jarr, offset, length)
271
+ rescue ::NativeException
272
+ CORBA::Exception.native2r($!)
273
+ end
274
+ arr.fill(offset, length) {|i| jarr[i] }
275
+ end
276
+ def read_double()
277
+ begin
278
+ self.stream_.read_double()
279
+ rescue ::NativeException
280
+ CORBA::Exception.native2r($!)
281
+ end
282
+ end
283
+ def read_double_array(arr, offset, length)
284
+ jarr = Array.new(arr.size).to_java(:double)
285
+ begin
286
+ self.stream_.read_double_array(jarr, offset, length)
287
+ rescue ::NativeException
288
+ CORBA::Exception.native2r($!)
289
+ end
290
+ arr.fill(offset, length) {|i| jarr[i] }
291
+ end
292
+ def read_string()
293
+ begin
294
+ self.stream_.read_string()
295
+ rescue ::NativeException
296
+ CORBA::Exception.native2r($!)
297
+ end
298
+ end
299
+ def read_wstring()
300
+ begin
301
+ self.stream_.read_wstring()
302
+ rescue ::NativeException
303
+ CORBA::Exception.native2r($!)
304
+ end
305
+ end
306
+ def read_Object()
307
+ begin
308
+ CORBA::Object._wrap_native(self.stream_().read_Object())
309
+ rescue ::NativeException
310
+ CORBA::Exception.native2r($!)
311
+ end
312
+ end
313
+ def read_TypeCode()
314
+ begin
315
+ CORBA::TypeCode._wrap_native(self.stream_().read_TypeCode())
316
+ rescue ::NativeException
317
+ CORBA::Exception.native2r($!)
318
+ end
319
+ end
320
+ def read_fixed()
321
+ begin
322
+ java.math.BigDecimal.new(self.stream_.read_fixed().toString())
323
+ rescue ::NativeException
324
+ CORBA::Exception.native2r($!)
325
+ end
326
+ end
327
+ def read_construct(tc)
328
+ begin
329
+ jany = self.stream_.orb().create_any()
330
+ jany.read_value(self.stream_, tc.tc_)
331
+ CORBA::Any.from_java(jany, self.stream_.orb(), tc)
332
+ rescue ::NativeException
333
+ CORBA::Exception.native2r($!)
334
+ end
335
+ end
336
+ def read_Abstract()
337
+ begin
338
+ obj = self.stream_.read_abstract_interface()
339
+ rescue ::NativeException
340
+ CORBA::Exception.native2r($!)
341
+ end
342
+ obj = CORBA::Object._wrap_native(obj) if obj.is_a?(CORBA::Native::Object)
343
+ obj
344
+ end
345
+ def read_value()
346
+ begin
347
+ self.stream_.read_value()
348
+ rescue ::NativeException
349
+ CORBA::Exception.native2r($!)
350
+ end
351
+ end
352
+ alias :read_Value :read_value
353
+ def read_valuebox(boxedvalue_helper)
354
+ begin
355
+ self.stream_.read_value(boxedvalue_helper)
356
+ rescue ::NativeException
357
+ CORBA::Exception.native2r($!)
358
+ end
359
+ end
360
+ end
361
+
362
+ module OutputStream
363
+ @@wrapper_klass = Class.new do
364
+ include CORBA::Portable::OutputStream
365
+ def initialize(jobj)
366
+ @stream_ = jobj
367
+ end
368
+ attr_reader :stream_
369
+ end
370
+
371
+ def self._wrap_native(jobj)
372
+ if jobj.nil? || !jobj.is_a?(Native::V2_3::Portable::OutputStream)
373
+ raise ArgumentError, 'Expected org.omg.CORBA.portable.OutputStream'
374
+ end
375
+ @@wrapper_klass.new(jobj)
376
+ end
377
+
378
+ def write_member(tc, value)
379
+ tc = tc.resolved_tc # takes care of recursive typecodes
380
+ case tc.kind
381
+ when TK_ANY
382
+ write_any(value)
383
+ when TK_BOOLEAN
384
+ write_boolean(value)
385
+ when TK_SHORT
386
+ write_short(value)
387
+ when TK_LONG
388
+ write_long(value)
389
+ when TK_USHORT
390
+ write_ushort(value)
391
+ when TK_WCHAR
392
+ write_wchar(value)
393
+ when TK_ULONG
394
+ write_ulong(value)
395
+ when TK_LONGLONG
396
+ write_longlong(value)
397
+ when TK_ULONGLONG
398
+ write_ulonglong(value)
399
+ when TK_OCTET
400
+ write_octet(value)
401
+ when TK_FLOAT
402
+ write_float(value)
403
+ when TK_DOUBLE
404
+ write_double(value)
405
+ when TK_LONGDOUBLE
406
+ raise CORBA::NO_IMPLEMENT.new('LongDouble not supported',0,CORBA::COMPLETED_NO)
407
+ when TK_FIXED
408
+ write_fixed(value)
409
+ when TK_CHAR
410
+ write_char(value)
411
+ when TK_STRING
412
+ write_string(value)
413
+ when TK_WSTRING
414
+ write_wstring(value)
415
+ when TK_OBJREF
416
+ write_Object(value)
417
+ when TK_TYPECODE
418
+ write_TypeCode(value)
419
+ when TK_ARRAY, TK_SEQUENCE,
420
+ TK_ENUM, TK_STRUCT, TK_EXCEPT, TK_UNION,
421
+ TK_PRINCIPAL
422
+ write_construct(value, tc)
423
+ when TK_ABSTRACT_INTERFACE
424
+ write_Abstract(value)
425
+ when TK_VALUE
426
+ write_value(value)
427
+ when TK_VALUE_BOX
428
+ write_valuebox(value, tc.get_type().boxedvalue_helper())
429
+ ## TODO: TK_NATIVE
430
+ end
431
+ end
432
+
433
+ def write_any(value)
434
+ begin
435
+ self.stream_.write_any(value)
436
+ rescue ::NativeException
437
+ CORBA::Exception.native2r($!)
438
+ end
439
+ end
440
+ def write_boolean(value)
441
+ begin
442
+ self.stream_.write_boolean(value)
443
+ rescue ::NativeException
444
+ CORBA::Exception.native2r($!)
445
+ end
446
+ end
447
+ def write_boolean_array(value, offset, length)
448
+ begin
449
+ self.stream_.write_boolean_array(value.to_java(:boolean), offset, length)
450
+ rescue ::NativeException
451
+ CORBA::Exception.native2r($!)
452
+ end
453
+ end
454
+ def write_char(value)
455
+ begin
456
+ self.stream_.write_char(value[0])
457
+ rescue ::NativeException
458
+ CORBA::Exception.native2r($!)
459
+ end
460
+ end
461
+ def write_char_array(value, offset, length)
462
+ begin
463
+ self.stream_.write_char_array(value.collect{|c| c[0]}.to_java(:char), offset, length)
464
+ rescue ::NativeException
465
+ CORBA::Exception.native2r($!)
466
+ end
467
+ end
468
+ def write_wchar(value)
469
+ self.stream_.write_wchar(value)
470
+ end
471
+ def write_wchar_array(value, offset, length)
472
+ begin
473
+ self.stream_.write_wchar_array(value.to_java(:char), offset, length)
474
+ rescue ::NativeException
475
+ CORBA::Exception.native2r($!)
476
+ end
477
+ end
478
+ def write_octet(value)
479
+ begin
480
+ self.stream_.write_octet([value].pack('C').unpack('c').first)
481
+ rescue ::NativeException
482
+ CORBA::Exception.native2r($!)
483
+ end
484
+ end
485
+ def write_octet_array(value, offset, length)
486
+ begin
487
+ self.stream_.write_octet_array(value.pack('C*').unpack('c*').to_java(:byte), offset, length)
488
+ rescue ::NativeException
489
+ CORBA::Exception.native2r($!)
490
+ end
491
+ end
492
+ def write_short(value)
493
+ begin
494
+ self.stream_.write_short(value)
495
+ rescue ::NativeException
496
+ CORBA::Exception.native2r($!)
497
+ end
498
+ end
499
+ def write_short_array(value, offset, length)
500
+ begin
501
+ self.stream_.write_short_array(value.to_java(:short), offset, length)
502
+ rescue ::NativeException
503
+ CORBA::Exception.native2r($!)
504
+ end
505
+ end
506
+ def write_ushort(value)
507
+ begin
508
+ self.stream_.write_ushort([value].pack('S').unpack('s').first)
509
+ rescue ::NativeException
510
+ CORBA::Exception.native2r($!)
511
+ end
512
+ end
513
+ def write_ushort_array(value, offset, length)
514
+ begin
515
+ self.stream_.write_ushort_array(value.pack('S*').unpack('s*').to_java(:short), offset, length)
516
+ rescue ::NativeException
517
+ CORBA::Exception.native2r($!)
518
+ end
519
+ end
520
+ def write_long(value)
521
+ begin
522
+ self.stream_.write_long(value)
523
+ rescue ::NativeException
524
+ CORBA::Exception.native2r($!)
525
+ end
526
+ end
527
+ def write_long_array(value, offset, length)
528
+ begin
529
+ self.stream_.write_long_array(value.to_java(:int), offset, length)
530
+ rescue ::NativeException
531
+ CORBA::Exception.native2r($!)
532
+ end
533
+ end
534
+ def write_ulong(value)
535
+ begin
536
+ self.stream_.write_ulong([value].pack('L').unpack('l').first)
537
+ rescue ::NativeException
538
+ CORBA::Exception.native2r($!)
539
+ end
540
+ end
541
+ def write_ulong_array(value, offset, length)
542
+ begin
543
+ self.stream_.write_ulong_array(value.pack('L*').unpack('l*').to_java(:int), offset, length)
544
+ rescue ::NativeException
545
+ CORBA::Exception.native2r($!)
546
+ end
547
+ end
548
+ def write_longlong(value)
549
+ begin
550
+ self.stream_.write_longlong(value)
551
+ rescue ::NativeException
552
+ CORBA::Exception.native2r($!)
553
+ end
554
+ end
555
+ def write_longlong_array(value, offset, length)
556
+ begin
557
+ self.stream_.write_longlong_array(value.to_java(:long), offset, length)
558
+ rescue ::NativeException
559
+ CORBA::Exception.native2r($!)
560
+ end
561
+ end
562
+ def write_ulonglong(value)
563
+ begin
564
+ self.stream_.write_ulonglong([value].pack('Q').unpack('q').first)
565
+ rescue ::NativeException
566
+ CORBA::Exception.native2r($!)
567
+ end
568
+ end
569
+ def write_ulonglong_array(value, offset, length)
570
+ begin
571
+ self.stream_.write_ulonglong_array(value.pack('Q*').unpack('q*').to_java(:long), offset, length)
572
+ rescue ::NativeException
573
+ CORBA::Exception.native2r($!)
574
+ end
575
+ end
576
+ def write_float(value)
577
+ begin
578
+ self.stream_.write_float(value)
579
+ rescue ::NativeException
580
+ CORBA::Exception.native2r($!)
581
+ end
582
+ end
583
+ def write_float_array(value, offset, length)
584
+ begin
585
+ self.stream_.write_float_array(value.to_java(:float), offset, length)
586
+ rescue ::NativeException
587
+ CORBA::Exception.native2r($!)
588
+ end
589
+ end
590
+ def write_double(value)
591
+ begin
592
+ self.stream_.write_double(value)
593
+ rescue ::NativeException
594
+ CORBA::Exception.native2r($!)
595
+ end
596
+ end
597
+ def write_double_array(value, offset, length)
598
+ begin
599
+ self.stream_.write_double_array(value.to_java(:double), offset, length)
600
+ rescue ::NativeException
601
+ CORBA::Exception.native2r($!)
602
+ end
603
+ end
604
+ def write_string(value)
605
+ begin
606
+ self.stream_.write_string(value)
607
+ rescue ::NativeException
608
+ CORBA::Exception.native2r($!)
609
+ end
610
+ end
611
+ def write_wstring(value)
612
+ begin
613
+ self.stream_.write_wstring(value.inject('') {|s,b| s << b.chr})
614
+ rescue ::NativeException
615
+ CORBA::Exception.native2r($!)
616
+ end
617
+ end
618
+ def write_fixed(value)
619
+ begin
620
+ self.stream_.write_fixed(java.math.BigDecimal.new(value.to_s))
621
+ rescue ::NativeException
622
+ CORBA::Exception.native2r($!)
623
+ end
624
+ end
625
+ def write_Object(value)
626
+ begin
627
+ self.stream_.write_Object(value.objref_)
628
+ rescue ::NativeException
629
+ CORBA::Exception.native2r($!)
630
+ end
631
+ end
632
+ def write_TypeCode(value)
633
+ begin
634
+ self.stream_.write_TypeCode(value.tc_)
635
+ rescue ::NativeException
636
+ CORBA::Exception.native2r($!)
637
+ end
638
+ end
639
+ def write_construct(value, tc)
640
+ begin
641
+ CORBA::Any.to_any(value, tc).to_java(self.stream_().orb()).write_value(self.stream_)
642
+ rescue ::NativeException
643
+ CORBA::Exception.native2r($!)
644
+ end
645
+ end
646
+ def write_Abstract(value)
647
+ begin
648
+ self.stream_().write_abstract_interface(value.is_a?(CORBA::Object) ? value.objref_ : value)
649
+ rescue ::NativeException
650
+ CORBA::Exception.native2r($!)
651
+ end
652
+ end
653
+ def write_value(value)
654
+ begin
655
+ self.stream_.write_value(value)
656
+ rescue ::NativeException
657
+ CORBA::Exception.native2r($!)
658
+ end
659
+ end
660
+ alias :write_Value :write_value
661
+ def write_valuebox(value, boxedvalue_helper)
662
+ begin
663
+ self.stream_.write_value(value, boxedvalue_helper)
664
+ rescue ::NativeException
665
+ CORBA::Exception.native2r($!)
666
+ end
667
+ end
668
+ end
669
+ end
670
+ end
671
671
  end