r2corba 1.4.1-x86-mingw32

Sign up to get free protection for your applications and to get access to all the features.
Files changed (267) 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/r2corba.bat +20 -0
  8. data/bin/ridlc +11 -0
  9. data/bin/ridlc.bat +23 -0
  10. data/bin/rins +7 -0
  11. data/bin/rins.bat +19 -0
  12. data/ext/.keep +0 -0
  13. data/lib/corba/cbase/IORMap.rb +33 -0
  14. data/lib/corba/cbase/ORB.rb +231 -0
  15. data/lib/corba/cbase/Request.rb +134 -0
  16. data/lib/corba/cbase/Streams.rb +129 -0
  17. data/lib/corba/cbase/Stub.rb +19 -0
  18. data/lib/corba/cbase/Typecode.rb +441 -0
  19. data/lib/corba/cbase/Values.rb +129 -0
  20. data/lib/corba/cbase/exception.rb +66 -0
  21. data/lib/corba/cbase/poa.rb +23 -0
  22. data/lib/corba/cbase/policies.rb +78 -0
  23. data/lib/corba/cbase/post_require.rb +14 -0
  24. data/lib/corba/cbase/require.rb +28 -0
  25. data/lib/corba/cmds/base.rb +85 -0
  26. data/lib/corba/cmds/test.rb +30 -0
  27. data/lib/corba/common/Any.rb +91 -0
  28. data/lib/corba/common/IDL.rb +104 -0
  29. data/lib/corba/common/ORB.rb +368 -0
  30. data/lib/corba/common/Object.rb +208 -0
  31. data/lib/corba/common/Request.rb +20 -0
  32. data/lib/corba/common/Servant.rb +108 -0
  33. data/lib/corba/common/Struct.rb +22 -0
  34. data/lib/corba/common/Stub.rb +79 -0
  35. data/lib/corba/common/Typecode.rb +1121 -0
  36. data/lib/corba/common/Union.rb +56 -0
  37. data/lib/corba/common/Values.rb +92 -0
  38. data/lib/corba/common/const.rb +22 -0
  39. data/lib/corba/common/exception.rb +68 -0
  40. data/lib/corba/common/require.rb +27 -0
  41. data/lib/corba/common/version.rb +22 -0
  42. data/lib/corba/idl/BiDirPolicyC.rb +63 -0
  43. data/lib/corba/idl/CosNamingC.rb +461 -0
  44. data/lib/corba/idl/CosNamingS.rb +309 -0
  45. data/lib/corba/idl/IDL.rb +21 -0
  46. data/lib/corba/idl/IORTable.pidl +62 -0
  47. data/lib/corba/idl/IORTableC.rb +117 -0
  48. data/lib/corba/idl/MessagingC.rb +904 -0
  49. data/lib/corba/idl/POAC.rb +930 -0
  50. data/lib/corba/idl/TAO_Ext.pidl +46 -0
  51. data/lib/corba/idl/TAO_ExtC.rb +179 -0
  52. data/lib/corba/idl/r2c_orb.rb +572 -0
  53. data/lib/corba/idl/require.rb +20 -0
  54. data/lib/corba/jbase/Any.rb +273 -0
  55. data/lib/corba/jbase/IORMap.rb +36 -0
  56. data/lib/corba/jbase/ORB.rb +99 -0
  57. data/lib/corba/jbase/Object.rb +98 -0
  58. data/lib/corba/jbase/Request.rb +226 -0
  59. data/lib/corba/jbase/Servant.rb +247 -0
  60. data/lib/corba/jbase/ServerRequest.rb +128 -0
  61. data/lib/corba/jbase/Streams.rb +671 -0
  62. data/lib/corba/jbase/Stub.rb +38 -0
  63. data/lib/corba/jbase/Typecode.rb +520 -0
  64. data/lib/corba/jbase/Values.rb +173 -0
  65. data/lib/corba/jbase/exception.rb +106 -0
  66. data/lib/corba/jbase/poa.rb +229 -0
  67. data/lib/corba/jbase/policies.rb +300 -0
  68. data/lib/corba/jbase/post_require.rb +14 -0
  69. data/lib/corba/jbase/require.rb +86 -0
  70. data/lib/corba/naming.rb +14 -0
  71. data/lib/corba/naming_service.rb +15 -0
  72. data/lib/corba/poa.rb +15 -0
  73. data/lib/corba/policies.rb +18 -0
  74. data/lib/corba/require.rb +17 -0
  75. data/lib/corba/svcs/ins/cos_naming.rb +426 -0
  76. data/lib/corba/svcs/ins/ins.rb +526 -0
  77. data/lib/corba/svcs/ins/naming_service.rb +119 -0
  78. data/lib/corba.rb +16 -0
  79. data/lib/ridlbe/ruby/config.rb +336 -0
  80. data/lib/ridlbe/ruby/orb.pidlc +0 -0
  81. data/lib/ridlbe/ruby/require.rb +16 -0
  82. data/lib/ridlbe/ruby/walker.rb +1582 -0
  83. data/mkrf_conf_bingem.rb +101 -0
  84. data/rakelib/bin.rake +80 -0
  85. data/rakelib/bin.rb +146 -0
  86. data/rakelib/build.rake +87 -0
  87. data/rakelib/config.rake +52 -0
  88. data/rakelib/config.rb +450 -0
  89. data/rakelib/ext.rake +242 -0
  90. data/rakelib/ext.rb +308 -0
  91. data/rakelib/ext_r2tao.rb +232 -0
  92. data/rakelib/gem.rake +212 -0
  93. data/rakelib/gem.rb +146 -0
  94. data/rakelib/package.rake +26 -0
  95. data/rakelib/test.rake +23 -0
  96. data/test/BiDirectional/Test.idl +34 -0
  97. data/test/BiDirectional/client.rb +132 -0
  98. data/test/BiDirectional/run_test.rb +68 -0
  99. data/test/BiDirectional/server.ior +1 -0
  100. data/test/BiDirectional/server.rb +169 -0
  101. data/test/CORBA_Services/Naming/BindingIterator/Test.idl +27 -0
  102. data/test/CORBA_Services/Naming/BindingIterator/client.rb +121 -0
  103. data/test/CORBA_Services/Naming/BindingIterator/ins.ior +1 -0
  104. data/test/CORBA_Services/Naming/BindingIterator/run_test.rb +82 -0
  105. data/test/CORBA_Services/Naming/BindingIterator/server.rb +109 -0
  106. data/test/CORBA_Services/Naming/Corbaname/Test.idl +27 -0
  107. data/test/CORBA_Services/Naming/Corbaname/client.rb +85 -0
  108. data/test/CORBA_Services/Naming/Corbaname/corbaname.ior +1 -0
  109. data/test/CORBA_Services/Naming/Corbaname/ins.ior +1 -0
  110. data/test/CORBA_Services/Naming/Corbaname/run_test.rb +88 -0
  111. data/test/CORBA_Services/Naming/Corbaname/server.rb +135 -0
  112. data/test/CORBA_Services/Naming/Simple/Test.idl +27 -0
  113. data/test/CORBA_Services/Naming/Simple/client.rb +84 -0
  114. data/test/CORBA_Services/Naming/Simple/ins.ior +1 -0
  115. data/test/CORBA_Services/Naming/Simple/run_test.rb +82 -0
  116. data/test/CORBA_Services/Naming/Simple/server.rb +109 -0
  117. data/test/Collocation/Diamond.idl +39 -0
  118. data/test/Collocation/run_test.rb +52 -0
  119. data/test/Collocation/test.rb +195 -0
  120. data/test/Connect_Timeout/Test.idl +27 -0
  121. data/test/Connect_Timeout/client.rb +111 -0
  122. data/test/Connect_Timeout/run_test.rb +52 -0
  123. data/test/DII/Test.idl +27 -0
  124. data/test/DII/client.rb +115 -0
  125. data/test/DII/run_test.rb +69 -0
  126. data/test/DII/server.ior +1 -0
  127. data/test/DII/server.rb +95 -0
  128. data/test/DSI/Test.idl +27 -0
  129. data/test/DSI/client.rb +66 -0
  130. data/test/DSI/run_test.rb +69 -0
  131. data/test/DSI/server.ior +1 -0
  132. data/test/DSI/server.rb +106 -0
  133. data/test/Exceptions/Test.idl +48 -0
  134. data/test/Exceptions/client.rb +118 -0
  135. data/test/Exceptions/run_test.rb +69 -0
  136. data/test/Exceptions/server.ior +1 -0
  137. data/test/Exceptions/server.rb +131 -0
  138. data/test/Hello/Test.idl +27 -0
  139. data/test/Hello/client.rb +78 -0
  140. data/test/Hello/run_test.rb +71 -0
  141. data/test/Hello/server.rb +95 -0
  142. data/test/IDL_Test/Test.idl +113 -0
  143. data/test/IDL_Test/Test_inc.idl +17 -0
  144. data/test/IDL_Test/client.rb +102 -0
  145. data/test/IDL_Test/run_test.rb +69 -0
  146. data/test/IDL_Test/server.ior +1 -0
  147. data/test/IDL_Test/server.rb +99 -0
  148. data/test/IORMap/Test.idl +27 -0
  149. data/test/IORMap/client.rb +73 -0
  150. data/test/IORMap/run_test.rb +69 -0
  151. data/test/IORMap/server.ior +1 -0
  152. data/test/IORMap/server.rb +114 -0
  153. data/test/IORTable/Test.idl +27 -0
  154. data/test/IORTable/client.rb +75 -0
  155. data/test/IORTable/run_test.rb +69 -0
  156. data/test/IORTable/server.ior +1 -0
  157. data/test/IORTable/server.rb +130 -0
  158. data/test/Implicit_Conversion/Test.idl +31 -0
  159. data/test/Implicit_Conversion/client.rb +110 -0
  160. data/test/Implicit_Conversion/run_test.rb +69 -0
  161. data/test/Implicit_Conversion/server.ior +1 -0
  162. data/test/Implicit_Conversion/server.rb +99 -0
  163. data/test/Multi_Threading/Multiple_ORB/Test.idl +27 -0
  164. data/test/Multi_Threading/Multiple_ORB/client.rb +82 -0
  165. data/test/Multi_Threading/Multiple_ORB/run_test.rb +71 -0
  166. data/test/Multi_Threading/Multiple_ORB/server.rb +108 -0
  167. data/test/Multi_Threading/Multiple_ORB/server0.ior +1 -0
  168. data/test/Multi_Threading/Multiple_ORB/server1.ior +1 -0
  169. data/test/Multi_Threading/Simple/Test.idl +27 -0
  170. data/test/Multi_Threading/Simple/client.rb +88 -0
  171. data/test/Multi_Threading/Simple/run_test.rb +69 -0
  172. data/test/Multi_Threading/Simple/server.ior +1 -0
  173. data/test/Multi_Threading/Simple/server.rb +118 -0
  174. data/test/Multi_Threading/Threads/Test.idl +31 -0
  175. data/test/Multi_Threading/Threads/client.rb +80 -0
  176. data/test/Multi_Threading/Threads/run_test.rb +76 -0
  177. data/test/Multi_Threading/Threads/server.ior +1 -0
  178. data/test/Multi_Threading/Threads/server.rb +119 -0
  179. data/test/Multi_Threading/Threads/watchdog.ior +1 -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.ior +1 -0
  185. data/test/Multiple_Servant_Interfaces/server.rb +102 -0
  186. data/test/Nil/Test.idl +27 -0
  187. data/test/Nil/run_test.rb +52 -0
  188. data/test/Nil/test.rb +78 -0
  189. data/test/OBV/AbstractInterface/client.rb +179 -0
  190. data/test/OBV/AbstractInterface/run_test.rb +69 -0
  191. data/test/OBV/AbstractInterface/server.ior +1 -0
  192. data/test/OBV/AbstractInterface/server.rb +149 -0
  193. data/test/OBV/AbstractInterface/test.idl +53 -0
  194. data/test/OBV/Custom/OBV.idl +18 -0
  195. data/test/OBV/Custom/OBV_impl.rb +40 -0
  196. data/test/OBV/Custom/client.rb +86 -0
  197. data/test/OBV/Custom/run_test.rb +69 -0
  198. data/test/OBV/Custom/server.ior +1 -0
  199. data/test/OBV/Custom/server.rb +100 -0
  200. data/test/OBV/Simple/OBV.idl +15 -0
  201. data/test/OBV/Simple/OBV_impl.rb +26 -0
  202. data/test/OBV/Simple/client.rb +86 -0
  203. data/test/OBV/Simple/run_test.rb +69 -0
  204. data/test/OBV/Simple/server.ior +1 -0
  205. data/test/OBV/Simple/server.rb +100 -0
  206. data/test/OBV/Simple_Event/Event.idl +15 -0
  207. data/test/OBV/Simple_Event/Event_impl.rb +26 -0
  208. data/test/OBV/Simple_Event/client.rb +86 -0
  209. data/test/OBV/Simple_Event/run_test.rb +69 -0
  210. data/test/OBV/Simple_Event/server.ior +1 -0
  211. data/test/OBV/Simple_Event/server.rb +100 -0
  212. data/test/OBV/Supports/client.rb +116 -0
  213. data/test/OBV/Supports/run_test.rb +69 -0
  214. data/test/OBV/Supports/server.ior +1 -0
  215. data/test/OBV/Supports/server.rb +103 -0
  216. data/test/OBV/Supports/supports.idl +33 -0
  217. data/test/OBV/Supports/supports_impl.rb +57 -0
  218. data/test/OBV/Tree/client.rb +116 -0
  219. data/test/OBV/Tree/run_test.rb +69 -0
  220. data/test/OBV/Tree/server.ior +1 -0
  221. data/test/OBV/Tree/server.rb +117 -0
  222. data/test/OBV/Tree/test.idl +32 -0
  223. data/test/OBV/Truncatable/Extra.idl +27 -0
  224. data/test/OBV/Truncatable/Truncatable.idl +105 -0
  225. data/test/OBV/Truncatable/Truncatable_impl.rb +86 -0
  226. data/test/OBV/Truncatable/client.rb +279 -0
  227. data/test/OBV/Truncatable/run_test.rb +69 -0
  228. data/test/OBV/Truncatable/server.ior +1 -0
  229. data/test/OBV/Truncatable/server.rb +89 -0
  230. data/test/OBV/ValueBox/client.rb +497 -0
  231. data/test/OBV/ValueBox/run_test.rb +69 -0
  232. data/test/OBV/ValueBox/server.ior +1 -0
  233. data/test/OBV/ValueBox/server.rb +271 -0
  234. data/test/OBV/ValueBox/valuebox.idl +101 -0
  235. data/test/OBV/ValueBox/vb_basic.idl +75 -0
  236. data/test/OBV/ValueBox/vb_struct.idl +68 -0
  237. data/test/OBV/ValueBox/vb_union.idl +21 -0
  238. data/test/Object/Test.idl +27 -0
  239. data/test/Object/client.rb +103 -0
  240. data/test/Object/run_test.rb +69 -0
  241. data/test/Object/server.ior +1 -0
  242. data/test/Object/server.rb +126 -0
  243. data/test/POA/Test.idl +27 -0
  244. data/test/POA/run_test.rb +52 -0
  245. data/test/POA/test.rb +112 -0
  246. data/test/Param_Test/Test.idl +182 -0
  247. data/test/Param_Test/client.rb +277 -0
  248. data/test/Param_Test/run_test.rb +69 -0
  249. data/test/Param_Test/server.ior +1 -0
  250. data/test/Param_Test/server.rb +296 -0
  251. data/test/Performance/Simple/Test.idl +27 -0
  252. data/test/Performance/Simple/client.rb +90 -0
  253. data/test/Performance/Simple/run_test.rb +69 -0
  254. data/test/Performance/Simple/server.ior +1 -0
  255. data/test/Performance/Simple/server.rb +95 -0
  256. data/test/Policies/Test.idl +27 -0
  257. data/test/Policies/run_test.rb +52 -0
  258. data/test/Policies/test.rb +144 -0
  259. data/test/Timeout/client.rb +207 -0
  260. data/test/Timeout/run_test.rb +69 -0
  261. data/test/Timeout/server.ior +1 -0
  262. data/test/Timeout/server.rb +109 -0
  263. data/test/Timeout/test.idl +19 -0
  264. data/test/lib/assert.rb +43 -0
  265. data/test/lib/test.rb +542 -0
  266. data/test/test_runner.rb +193 -0
  267. metadata +342 -0
@@ -0,0 +1,1121 @@
1
+ #--------------------------------------------------------------------
2
+ # Typecode.rb - Common CORBA TypeCode definitions
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
+ require 'monitor'
14
+
15
+ module R2CORBA
16
+ module CORBA
17
+ class TypeCode
18
+ def initialize
19
+ raise RuntimeError, 'not allowed'
20
+ end
21
+
22
+ @@wrapper_klass = Class.new(CORBA::TypeCode) do
23
+ def initialize(ntc)
24
+ @tc_ = ntc
25
+ end
26
+ end
27
+
28
+ attr_reader :tc_
29
+
30
+ def self._wrap_native(ntc)
31
+ raise ArgumentError, 'Expected org.omg.CORBA.TypeCode' unless ntc.nil? || ntc.is_a?(Native::TypeCode)
32
+ ntc.nil?() ? ntc : @@wrapper_klass.new(ntc)
33
+ end
34
+
35
+ def TypeCode._tc
36
+ CORBA::_tc_TypeCode
37
+ end
38
+
39
+ OctetRange = (0..0xFF).freeze
40
+ UShortRange = (0..0xFFFF).freeze
41
+ ULongRange = (0..0xFFFFFFFF).freeze
42
+ ULongLongRange = (0..0xFFFFFFFFFFFFFFFF).freeze
43
+ ShortRange = (-0x8000...0x8000).freeze
44
+ LongRange = (-0x80000000...0x80000000).freeze
45
+ LongLongRange = (-0x8000000000000000...0x8000000000000000).freeze
46
+
47
+ @@typecode_registry = (Class.new(Monitor) do
48
+ def initialize
49
+ @id_types = {}
50
+ @name_types = {}
51
+ super
52
+ end
53
+ def []=(id, tc)
54
+ synchronize do
55
+ @id_types[id] = tc
56
+ types_for_name_ = @name_types[tc.name] || []
57
+ types_for_name_ << tc
58
+ @name_types[tc.name] = types_for_name_
59
+ end
60
+ end
61
+ def [](id)
62
+ tc = nil
63
+ synchronize do
64
+ tc = @id_types[id]
65
+ end
66
+ tc
67
+ end
68
+ def types_for_name(name)
69
+ tcs = nil
70
+ synchronize do
71
+ tcs = @name_types[name]
72
+ end
73
+ tcs
74
+ end
75
+ end).new
76
+
77
+ def TypeCode.register_id_type(id, tc)
78
+ @@typecode_registry[id] = tc
79
+ end
80
+
81
+ def TypeCode.typecode_for_id(id)
82
+ @@typecode_registry[id]
83
+ end
84
+
85
+ def TypeCode.typecodes_for_name(name)
86
+ @@typecode_registry.types_for_name(name)
87
+ end
88
+
89
+ # native to ruby
90
+
91
+ def TypeCode.native_kind(ntc)
92
+ ntc.kind
93
+ end
94
+
95
+ def TypeCode.from_native(ntc)
96
+ if [TK_NULL,TK_VOID,TK_ANY,TK_BOOLEAN,TK_SHORT,TK_LONG,TK_USHORT,
97
+ TK_WCHAR,TK_ULONG,TK_LONGLONG,TK_ULONGLONG,TK_OCTET,
98
+ TK_FLOAT,TK_DOUBLE,TK_LONGDOUBLE,TK_CHAR,
99
+ TK_TYPECODE,TK_PRINCIPAL].include?(native_kind(ntc))
100
+ ## primitive typecode; wrap it
101
+ return TypeCode._wrap_native(ntc)
102
+ else
103
+ rtc = nil
104
+ case native_kind(ntc)
105
+ when TK_STRING
106
+ rtc = TypeCode::String.new(ntc)
107
+ when TK_WSTRING
108
+ rtc = TypeCode::WString.new(ntc)
109
+ when TK_FIXED
110
+ rtc = TypeCode::Fixed.new(ntc)
111
+ when TK_ALIAS
112
+ rtc = TypeCode.typecode_for_id(ntc.id)
113
+ unless rtc
114
+ rtc = TypeCode::Alias.new(ntc)
115
+ end
116
+ when TK_ENUM
117
+ rtc = TypeCode.typecode_for_id(ntc.id)
118
+ unless rtc
119
+ rtc = TypeCode::Enum.new(ntc)
120
+ end
121
+ when TK_ARRAY
122
+ rtc = TypeCode::Array.new(ntc)
123
+ when TK_SEQUENCE
124
+ rtc = TypeCode::Sequence.new(ntc)
125
+ when TK_STRUCT
126
+ rtc = TypeCode.typecode_for_id(ntc.id)
127
+ unless rtc
128
+ rtc = TypeCode::Struct.new(ntc)
129
+ end
130
+ when TK_EXCEPT
131
+ rtc = TypeCode.typecode_for_id(ntc.id)
132
+ unless rtc
133
+ rtc = TypeCode::Except.new(ntc)
134
+ end
135
+ when TK_UNION
136
+ rtc = TypeCode.typecode_for_id(ntc.id)
137
+ unless rtc
138
+ rtc = TypeCode::Union.new(ntc)
139
+ end
140
+ when TK_OBJREF
141
+ rtc = TypeCode.typecode_for_id(ntc.id)
142
+ unless rtc
143
+ rtc = TypeCode::ObjectRef.new(ntc)
144
+ end
145
+ when TK_ABSTRACT_INTERFACE
146
+ rtc = TypeCode.typecode_for_id(ntc.id)
147
+ unless rtc
148
+ rtc = TypeCode::AbstractInterface.new(ntc)
149
+ end
150
+ when TK_VALUE_BOX
151
+ rtc = TypeCode.typecode_for_id(ntc.id)
152
+ unless rtc
153
+ rtc = TypeCode::Valuebox.new(ntc)
154
+ end
155
+ when TK_VALUE
156
+ rtc = TypeCode.typecode_for_id(ntc.id)
157
+ unless rtc
158
+ rtc = TypeCode::Valuetype.new(ntc)
159
+ end
160
+ when TK_NATIVE
161
+ raise CORBA::NO_IMPLEMENT.new('typecode #{native_kind(ntc)} not supported',0,CORBA::COMPLETED_NO)
162
+ else
163
+ raise CORBA::MARSHAL.new("unknown kind [#{native_kind(ntc)}]",0,CORBA::COMPLETED_NO)
164
+ end
165
+ return rtc
166
+ end
167
+ end
168
+
169
+ # instance methods
170
+
171
+ def resolved_tc
172
+ self
173
+ end
174
+
175
+ def is_recursive_tc?
176
+ false
177
+ end
178
+
179
+ def kind
180
+ raise CORBA::NO_IMPLEMENT
181
+ end
182
+
183
+ def get_compact_typecode
184
+ CORBA::TypeCode.from_native(self.tc_.get_compact_typecode)
185
+ end
186
+
187
+ def equal?(tc)
188
+ raise ArgumentError, "expected CORBA::TypeCode" unless tc.is_a?(CORBA::TypeCode)
189
+ begin
190
+ self.tc_.equal(tc.tc_)
191
+ rescue ::NativeException
192
+ CORBA::Exception.native2r($!)
193
+ end
194
+ end
195
+
196
+ def equivalent?(tc)
197
+ raise ArgumentError, "expected CORBA::TypeCode" unless tc.is_a?(CORBA::TypeCode)
198
+ begin
199
+ self.tc_.equivalent(tc.tc_)
200
+ rescue ::NativeException
201
+ CORBA::Exception.native2r($!)
202
+ end
203
+ end
204
+
205
+ def id
206
+ begin
207
+ self.tc_.id()
208
+ rescue ::NativeException
209
+ CORBA::Exception.native2r($!)
210
+ end
211
+ end
212
+
213
+ def name
214
+ begin
215
+ self.tc_.name()
216
+ rescue ::NativeException
217
+ CORBA::Exception.native2r($!)
218
+ end
219
+ end
220
+
221
+ def member_count
222
+ begin
223
+ self.tc_.member_count()
224
+ rescue ::NativeException
225
+ CORBA::Exception.native2r($!)
226
+ end
227
+ end
228
+
229
+ def member_name(index)
230
+ begin
231
+ self.tc_.member_name(index.to_i)
232
+ rescue ::NativeException
233
+ CORBA::Exception.native2r($!)
234
+ end
235
+ end
236
+
237
+ def member_type(index)
238
+ begin
239
+ CORBA::TypeCode.from_native(self.tc_.member_type(index.to_i))
240
+ rescue ::NativeException
241
+ CORBA::Exception.native2r($!)
242
+ end
243
+ end
244
+
245
+ def member_label(index)
246
+ raise CORBA::NO_IMPLEMENT
247
+ end
248
+
249
+ def discriminator_type
250
+ CORBA::TypeCode.from_native(self.tc_.discriminator_type)
251
+ end
252
+
253
+ def default_index
254
+ begin
255
+ self.tc_.default_index()
256
+ rescue ::NativeException
257
+ CORBA::Exception.native2r($!)
258
+ end
259
+ end
260
+
261
+ def length
262
+ begin
263
+ self.tc_.length()
264
+ rescue ::NativeException
265
+ CORBA::Exception.native2r($!)
266
+ end
267
+ end
268
+
269
+ def content_type
270
+ CORBA::TypeCode.from_native(self.tc_.content_type)
271
+ end
272
+
273
+ def fixed_digits
274
+ begin
275
+ self.tc_.fixed_digits()
276
+ rescue ::NativeException
277
+ CORBA::Exception.native2r($!)
278
+ end
279
+ end
280
+
281
+ def fixed_scale
282
+ begin
283
+ self.tc_.fixed_scale()
284
+ rescue ::NativeException
285
+ CORBA::Exception.native2r($!)
286
+ end
287
+ end
288
+
289
+ def member_visibility(index)
290
+ begin
291
+ self.tc_.member_visibility(index.to_i)
292
+ rescue ::NativeException
293
+ CORBA::Exception.native2r($!)
294
+ end
295
+ end
296
+
297
+ def type_modifier
298
+ begin
299
+ self.tc_.type_modifier()
300
+ rescue ::NativeException
301
+ CORBA::Exception.native2r($!)
302
+ end
303
+ end
304
+
305
+ def concrete_base_type
306
+ ntc = self.tc_.concrete_base_type
307
+ ntc.nil? ? nil : CORBA::TypeCode.from_native(ntc)
308
+ end
309
+
310
+ def get_type
311
+ @type ||= case self.kind
312
+ when TK_SHORT, TK_LONG, TK_USHORT, TK_ULONG
313
+ ::Fixnum
314
+ when TK_LONGLONG, TK_ULONGLONG
315
+ ::Bignum
316
+ when TK_FLOAT, TK_DOUBLE
317
+ ::Float
318
+ when TK_LONGDOUBLE
319
+ ::CORBA::LongDouble
320
+ when TK_BOOLEAN
321
+ ::TrueClass
322
+ when TK_CHAR, TK_STRING
323
+ ::String
324
+ when TK_WCHAR, TK_OCTET
325
+ ::Fixnum
326
+ when TK_VOID, TK_NULL
327
+ ::NilClass
328
+ when TK_ANY
329
+ ::Object
330
+ when TK_TYPECODE
331
+ CORBA::TypeCode
332
+ when TK_OBJREF
333
+ CORBA::Object
334
+ when TK_ABSTRACT_INTERFACE
335
+ ::Object
336
+ else
337
+ nil
338
+ end
339
+ end
340
+
341
+ def validate(val)
342
+ case self.kind
343
+ when TK_ANY
344
+ return CORBA::Any === val ? val : Any.to_any(val)
345
+ when TK_BOOLEAN
346
+ return val if ((val.is_a? TrueClass) || (val.is_a? FalseClass))
347
+ when TK_SHORT
348
+ return val.to_int if val.respond_to?(:to_int) && ShortRange === val.to_int
349
+ when TK_LONG
350
+ return val.to_int if val.respond_to?(:to_int) && LongRange === val.to_int
351
+ when TK_USHORT, TK_WCHAR
352
+ return val.to_int if val.respond_to?(:to_int) && UShortRange === val.to_int
353
+ when TK_ULONG
354
+ return val.to_int if val.respond_to?(:to_int) && ULongRange === val.to_int
355
+ when TK_LONGLONG
356
+ return val.to_int if val.respond_to?(:to_int) && LongLongRange === val.to_int
357
+ when TK_ULONGLONG
358
+ return val.to_int if val.respond_to?(:to_int) && ULongLongRange === val.to_int
359
+ when TK_OCTET
360
+ return val.to_int if val.respond_to?(:to_int) && OctetRange === val.to_int
361
+ when TK_FLOAT, TK_DOUBLE
362
+ return val if val.is_a?(::Float)
363
+ when TK_LONGDOUBLE
364
+ return val if val.is_a?(::CORBA::LongDouble)
365
+ when TK_CHAR
366
+ if (val.respond_to?(:to_str) && (val.to_str.size == 1)) ||
367
+ (val.respond_to?(:to_int) && OctetRange === val.to_int)
368
+ return val.respond_to?(:to_str) ? val.to_str : val.to_int.chr
369
+ end
370
+ else
371
+ return val if (val.nil? || val.is_a?(self.get_type))
372
+ end
373
+ raise CORBA::MARSHAL.new(
374
+ "value does not match type: value = #{val}, value type == #{val.class.name}, type == #{get_type.name}",
375
+ 1, CORBA::COMPLETED_NO)
376
+ end
377
+
378
+ def needs_conversion(val)
379
+ case self.kind
380
+ when TK_SHORT, TK_LONG,
381
+ TK_USHORT, TK_WCHAR,
382
+ TK_ULONG, TK_LONGLONG, TK_ULONGLONG,
383
+ TK_OCTET
384
+ return !(::Integer === val)
385
+ when TK_CHAR
386
+ return !(::String === val)
387
+ end
388
+ false
389
+ end
390
+
391
+ class Recursive < CORBA::TypeCode
392
+
393
+ def initialize(id)
394
+ raise RuntimeError, 'overload required'
395
+ end
396
+
397
+ def recursed_tc
398
+ @recursive_tc ||= TypeCode.typecode_for_id(self.id)
399
+ @recursive_tc || ::CORBA::TypeCode.new(TK_NULL)
400
+ end
401
+ def resolved_tc
402
+ recursed_tc.resolved_tc
403
+ end
404
+ def is_recursive_tc?
405
+ true
406
+ end
407
+ def get_type
408
+ @recursive_tc ||= TypeCode.typecode_for_id(self.id)
409
+ if @recursive_tc.nil? then nil; else @recursive_tc.get_type; end
410
+ end
411
+ def validate(val)
412
+ recursed_tc.validate(val)
413
+ end
414
+ def needs_conversion(val)
415
+ recursed_tc.needs_conversion(val)
416
+ end
417
+ end # Recursive
418
+
419
+ class String < CORBA::TypeCode
420
+
421
+ def initialize(*args)
422
+ raise RuntimeError, 'overload required'
423
+ end
424
+
425
+ def get_type
426
+ ::String
427
+ end
428
+
429
+ def validate(val)
430
+ return val if val.nil?
431
+ super(val) unless ::String === val || val.respond_to?(:to_str)
432
+ val = ::String === val ? val : val.to_str
433
+ raise ::CORBA::MARSHAL.new(
434
+ "string size exceeds bound: #{self.length.to_s}",
435
+ 1, ::CORBA::COMPLETED_NO) unless (self.length==0 || val.size<=self.length)
436
+ val
437
+ end
438
+
439
+ def needs_conversion(val)
440
+ !(::String === val)
441
+ end
442
+ end # String
443
+
444
+ class WString < CORBA::TypeCode
445
+
446
+ def initialize(*args)
447
+ raise RuntimeError, 'overload required'
448
+ end
449
+
450
+ def get_type
451
+ ::Array
452
+ end
453
+
454
+ def validate(val)
455
+ return val if val.nil?
456
+ super(val) unless ::Array === val || val.respond_to?(:to_str) || val.respond_to?(:to_ary)
457
+ val = if ::Array === val
458
+ val
459
+ elsif val.respond_to?(:to_ary)
460
+ val.to_ary
461
+ else
462
+ a = []
463
+ val.to_str.each_byte { |c| a << c }
464
+ a
465
+ end
466
+ raise ::CORBA::MARSHAL.new(
467
+ "widestring size exceeds bound: #{self.length.to_s}",
468
+ 1, ::CORBA::COMPLETED_NO) unless (self.length==0 || val.size<=self.length)
469
+ raise ::CORBA::MARSHAL.new(
470
+ "invalid widestring element(s)",
471
+ 1, ::CORBA::COMPLETED_NO) if val.any? { |el| !(UShortRange === (el.respond_to?(:to_int) ? el.to_int : el)) }
472
+ val.any? { |el| !(::Integer === el) } ? val.collect { |el| el.to_int } : val
473
+ end
474
+
475
+ def needs_conversion(val)
476
+ !(::Array === val) ? true : val.any? { |el| !(::Integer === el) }
477
+ end
478
+
479
+ def in_value(val)
480
+ if val.respond_to?(:to_str)
481
+ a = []
482
+ val.to_str.each_byte { |c| a << c }
483
+ a
484
+ else
485
+ ::Array === val ? val : val.to_ary
486
+ end
487
+ end
488
+ end # WString
489
+
490
+ class Fixed < CORBA::TypeCode
491
+
492
+ def initialize(*args)
493
+ raise RuntimeError, 'overload required'
494
+ end
495
+
496
+ def get_type
497
+ ::BigDecimal
498
+ end
499
+
500
+ def validate(val)
501
+ return val if val.nil?
502
+ super(val) unless ::BigDecimal === val || val.respond_to?(:to_str)
503
+ val = ::BigDecimal === val ? val : BigDecimal.new(val.to_str)
504
+ val
505
+ end
506
+
507
+ def needs_conversion(val)
508
+ !(::BigDecimal === val)
509
+ end
510
+ end # Fixed
511
+
512
+ class Sequence < CORBA::TypeCode
513
+
514
+ def initialize(*args)
515
+ raise RuntimeError, 'overload required'
516
+ end
517
+
518
+ def get_type
519
+ self.content_type.kind == TK_OCTET || self.content_type.kind == TK_CHAR ? ::String : ::Array
520
+ end
521
+
522
+ def validate(val)
523
+ return val if val.nil?
524
+ super(val) unless val.respond_to?(:to_str) || val.respond_to?(:to_ary)
525
+ val = if self.content_type.kind == TK_OCTET || self.content_type.kind == TK_CHAR
526
+ if val.respond_to?(:to_str)
527
+ ::String === val ? val : val.to_str
528
+ else
529
+ s = ''
530
+ val.to_ary.each { |e| s << (e.respond_to?(:to_int) ? e.to_int.chr : e.to_str) }
531
+ s
532
+ end
533
+ elsif val.respond_to?(:to_ary)
534
+ ::Array === val ? val : val.to_ary
535
+ else
536
+ a = []
537
+ val.to_str.each_byte { |c| a << c }
538
+ a
539
+ end
540
+ raise ::CORBA::MARSHAL.new(
541
+ "sequence size exceeds bound: #{self.length.to_s}",
542
+ 1, ::CORBA::COMPLETED_NO) unless (self.length==0 || val.size<=self.length)
543
+ if ::Array === val
544
+ if val.any? { |e| self.content_type.needs_conversion(e) }
545
+ val.collect { |e| self.content_type.validate(e) }
546
+ else
547
+ val.each { |e| self.content_type.validate(e) }
548
+ end
549
+ else
550
+ val
551
+ end
552
+ end
553
+
554
+ def needs_conversion(val)
555
+ if self.content_type.kind == TK_OCTET || self.content_type.kind == TK_CHAR
556
+ !(::String === val)
557
+ else
558
+ !(::Array === val) ? true : val.any? { |el| self.content_type.needs_conversion(el) }
559
+ end
560
+ end
561
+
562
+ def inspect
563
+ "#{self.class.name}: "+
564
+ "length=#{if self.length.nil? then ""; else self.length.to_s; end}; "+
565
+ "content=#{self.content_type.inspect}"
566
+ end
567
+ end
568
+
569
+ class Array < CORBA::TypeCode
570
+
571
+ def initialize(*args)
572
+ raise RuntimeError, 'overload required'
573
+ end
574
+
575
+ def get_type
576
+ ::Array
577
+ end
578
+
579
+ def validate(val)
580
+ return val if val.nil?
581
+ super(val)
582
+ raise ::CORBA::MARSHAL.new(
583
+ "array size exceeds bound: #{self.length.to_s}",
584
+ 1, ::CORBA::COMPLETED_NO) unless val.nil? || val.size<=self.length
585
+ raise ::CORBA::MARSHAL.new(
586
+ "array size too small: #{self.length.to_s}",
587
+ 1, ::CORBA::COMPLETED_NO) unless val.nil? || val.size>=self.length
588
+ val.any? { |e| self.content_type.needs_conversion(e) } ? val.collect { |e| self.content_type.validate(e) } : val.each { |e| self.content_type.validate(e) }
589
+ end
590
+
591
+ def needs_conversion(val)
592
+ val.any? { |e| self.content_type.needs_conversion(e) }
593
+ end
594
+ end # Array
595
+
596
+ class IdentifiedTypeCode < CORBA::TypeCode
597
+
598
+ def initialize(id)
599
+ CORBA::TypeCode.register_id_type(id.to_s, self)
600
+ end
601
+ end # IdentifiedTypeCode
602
+
603
+ class Alias < IdentifiedTypeCode
604
+ def initialize(*args)
605
+ raise RuntimeError, 'overload required'
606
+ end
607
+
608
+ def get_type
609
+ @type || self.content_type.get_type
610
+ end
611
+ def validate(val)
612
+ self.content_type.validate(val)
613
+ end
614
+
615
+ def needs_conversion(val)
616
+ self.content_type.needs_conversion(val)
617
+ end
618
+
619
+ def resolved_tc
620
+ self.content_type.resolved_tc
621
+ end
622
+ end # Alias
623
+
624
+ class Valuetype < IdentifiedTypeCode
625
+ attr_reader :members
626
+ def initialize(*args)
627
+ raise RuntimeError, 'overload required'
628
+ end
629
+ def add_member(name, tc, access)
630
+ raise ArgumentError, 'expected CORBA::TypeCode' unless tc.is_a?(CORBA::TypeCode)
631
+ @members << [name, tc, access]
632
+ end
633
+
634
+ def Valuetype.define_type(tc)
635
+ trunc_ids = [tc.id]
636
+ rtc = tc
637
+ while rtc != nil && rtc.type_modifier == CORBA::VM_TRUNCATABLE
638
+ rtc = rtc.concrete_base_type
639
+ trunc_ids << rtc.id unless rtc.nil?
640
+ end
641
+ code = %Q{
642
+ class #{tc.name} < ::CORBA::ValueBase
643
+ TRUNCATABLE_IDS = ['#{trunc_ids.join("', '")}'].freeze
644
+ def self._tc
645
+ @@tc_#{tc.name} ||= TypeCode.typecode_for_id('#{tc.id}')
646
+ end
647
+ module Intf
648
+ end
649
+ include Intf
650
+ end
651
+ #{tc.name}
652
+ }
653
+ value_type = ::Object.module_eval(code)
654
+ tc.members.each do |nm_, tc_, access_|
655
+ value_type::Intf.module_eval(%Q{attr_accessor :#{nm_}})
656
+ value_type::Intf.__send__(:private, nm_.intern)
657
+ value_type::Intf.__send__(:private, (nm_+'=').intern)
658
+ end
659
+ value_type
660
+ end
661
+
662
+ def get_type
663
+ @type ||= CORBA::TypeCode::Valuetype.define_type(self)
664
+ end
665
+
666
+ def validate(val)
667
+ return val if val.nil?
668
+ super(val)
669
+ if needs_conversion(val)
670
+ vorg = val
671
+ val = vorg.class.new
672
+ @members.each { |name, tc| val.__send__((name+'=').intern, tc.validate(vorg.__send__(name.intern))) }
673
+ else
674
+ @members.each { |name, tc| tc.validate(val.__send__(name.intern)) }
675
+ end
676
+ val
677
+ end
678
+
679
+ def needs_conversion(val)
680
+ return false if val.nil?
681
+ @members.any? { |name,tc| tc.needs_conversion(val.__send__(name.intern)) }
682
+ end
683
+
684
+ def member_count
685
+ @members.size
686
+ end
687
+ def member_name(index)
688
+ raise ::CORBA::TypeCode::Bounds.new if (index<0) || (index>=@members.size)
689
+ @members[index][0]
690
+ end
691
+ def member_type(index)
692
+ raise ::CORBA::TypeCode::Bounds.new if (index<0) || (index>=@members.size)
693
+ @members[index][1]
694
+ end
695
+
696
+ def inspect
697
+ s = "#{self.class.name}: #{name} - #{id}\n"
698
+ @members.each { |n, t| s += " #{n} = "+t.inspect+"\n" }
699
+ s
700
+ end
701
+ end # Valuetype
702
+
703
+ class Eventtype < Valuetype
704
+ end # Eventtype
705
+
706
+ class Valuebox < IdentifiedTypeCode
707
+ def initialize(*args)
708
+ raise RuntimeError, 'overload required'
709
+ end
710
+
711
+ def Valuebox.define_type(tc)
712
+ code = %Q{
713
+ class #{tc.name} < ::CORBA::Portable::BoxedValueBase
714
+ def self._tc
715
+ @@tc_#{tc.name} ||= TypeCode.typecode_for_id('#{tc.id}')
716
+ end
717
+ attr_accessor :value
718
+ def initialize(val)
719
+ @value = val
720
+ end
721
+ end
722
+ #{tc.name}
723
+ }
724
+ ::Object.module_eval(code)
725
+ end
726
+
727
+ def get_type
728
+ @type || CORBA::TypeCode::Valuebox.define_type(self)
729
+ end
730
+
731
+ def validate(val)
732
+ return val if val.nil?
733
+ if CORBA::Portable::BoxedValueBase === val
734
+ super(val)
735
+ val.value = self.content_type.validate(val.value)
736
+ else
737
+ val = self.content_type.validate(val)
738
+ end
739
+ val
740
+ end
741
+
742
+ def needs_conversion(val)
743
+ return false if val.nil?
744
+ if CORBA::Portable::BoxedValueBase === val
745
+ self.content_type.needs_conversion(val.value)
746
+ else
747
+ self.content_type.needs_conversion(val)
748
+ end
749
+ end
750
+ end # Valuebox
751
+
752
+ class ObjectRef < IdentifiedTypeCode
753
+ def initialize(*args)
754
+ raise RuntimeError, 'overload required'
755
+ end
756
+
757
+ def get_type
758
+ @type
759
+ end
760
+ end # ObjectRef
761
+
762
+ class AbstractInterface < IdentifiedTypeCode
763
+ def initialize(*args)
764
+ raise RuntimeError, 'overload required'
765
+ end
766
+
767
+ def get_type
768
+ @type
769
+ end
770
+ end # AbstractInterface
771
+
772
+ class Struct < IdentifiedTypeCode
773
+ attr_reader :members
774
+ def initialize(*args)
775
+ raise RuntimeError, 'overload required'
776
+ end
777
+ def add_member(name, tc)
778
+ raise ArgumentError, 'expected CORBA::TypeCode' unless tc.is_a?(CORBA::TypeCode)
779
+ @members << [name, tc]
780
+ end
781
+
782
+ def Struct.define_type(tc)
783
+ code = %Q{
784
+ class #{tc.name} < ::CORBA::Portable::Struct
785
+ def self._tc
786
+ @@tc_#{tc.name} ||= TypeCode.typecode_for_id('#{tc.id}')
787
+ end
788
+ def initialize(*param_)
789
+ #{tc.members.collect {|n,t| "@#{n}"}.join(', ')} = param_
790
+ end
791
+ end
792
+ #{tc.name}
793
+ }
794
+ struct_type = ::Object.module_eval(code)
795
+ tc.members.each do |nm_, tc_|
796
+ struct_type.module_eval(%Q{attr_accessor :#{nm_}})
797
+ end
798
+ struct_type
799
+ end
800
+
801
+ def get_type
802
+ @type ||= CORBA::TypeCode::Struct.define_type(self)
803
+ end
804
+
805
+ def validate(val)
806
+ return val if val.nil?
807
+ super(val)
808
+ if needs_conversion(val)
809
+ vorg = val
810
+ val = vorg.class.new
811
+ @members.each { |name, tc| val.__send__((name+'=').intern, tc.validate(vorg.__send__(name.intern))) }
812
+ else
813
+ @members.each { |name, tc| tc.validate(val.__send__(name.intern)) }
814
+ end
815
+ val
816
+ end
817
+
818
+ def needs_conversion(val)
819
+ @members.any? { |name,tc| tc.needs_conversion(val.__send__(name.intern)) }
820
+ end
821
+
822
+ def member_count
823
+ @members.size
824
+ end
825
+ def member_name(index)
826
+ raise ::CORBA::TypeCode::Bounds.new if (index<0) || (index>=@members.size)
827
+ @members[index][0]
828
+ end
829
+ def member_type(index)
830
+ raise ::CORBA::TypeCode::Bounds.new if (index<0) || (index>=@members.size)
831
+ @members[index][1]
832
+ end
833
+
834
+ def inspect
835
+ s = "#{self.class.name}: #{name} - #{id}\n"
836
+ @members.each { |n, t| s += " #{n} = "+t.inspect+"\n" }
837
+ s
838
+ end
839
+ end # Struct
840
+
841
+ class SysExcept < Struct
842
+ def initialize(id, name)
843
+ members_ = [['minor', CORBA::_tc_long], ['completed', CORBA::_tc_CompletionStatus]]
844
+ super(id, name, members_)
845
+ end
846
+
847
+ def SysExcept.define_type(tc)
848
+ tc.get_type
849
+ end
850
+
851
+ def get_type
852
+ CORBA.const_get(self.name.to_sym)
853
+ end
854
+ end
855
+
856
+ class Except < Struct
857
+ def Except.define_type(tc)
858
+ except_type = ::Object.module_eval(%Q{
859
+ class #{tc.name} < CORBA::UserException
860
+ def _tc
861
+ @@tc_#{tc.name} ||= TypeCode.typecode_for_id('#{tc.id}')
862
+ end
863
+ def initialize(*param_)
864
+ #{tc.members.collect {|n,t| "@#{n}"}.join(',')} = param_
865
+ end
866
+ end
867
+ #{tc.name}
868
+ })
869
+ tc.members.each do |mname, mtc|
870
+ except_type.module_eval(%Q{attr_accessor :#{mname}})
871
+ end
872
+ except_type
873
+ end
874
+
875
+ def get_type
876
+ @type ||= CORBA::TypeCode::Except.define_type(self)
877
+ end
878
+ end # Except
879
+
880
+ class Union < IdentifiedTypeCode
881
+ attr_reader :members
882
+ attr_reader :switchtype
883
+ attr_reader :implicit_default
884
+ def initialize(*args)
885
+ raise RuntimeError, 'overload required'
886
+ end
887
+ # because creating the native tc involves creating Any's we postpone until actually needed
888
+ def tc_
889
+ raise RuntimeError, 'overload required'
890
+ end
891
+ def id
892
+ @id
893
+ end
894
+ def name
895
+ @name
896
+ end
897
+ def add_member(label, name, tc)
898
+ raise ArgumentError, 'expected CORBA::TypeCode' unless tc.is_a?(CORBA::TypeCode)
899
+ @switchtype.validate(label) unless label == :default
900
+ @labels[label] = @members.size
901
+ @members << [label, name.to_s, tc]
902
+ end
903
+
904
+ def Union.define_type(tc)
905
+ union_type = ::Object.module_eval(%Q{
906
+ class #{tc.name} < ::CORBA::Portable::Union
907
+ def _tc
908
+ @@tc_#{tc.name} ||= TypeCode.typecode_for_id('#{tc.id}')
909
+ end
910
+ end
911
+ #{tc.name}
912
+ })
913
+ accessors = {}
914
+ tc.members.each_with_index do |_m, ix|
915
+ accessors[_m[1]] = ix unless accessors.has_key?(_m[1])
916
+ end
917
+ accessors.each do |mname, ix|
918
+ union_type.module_eval(%Q{
919
+ def #{mname}; @value; end
920
+ def #{mname}=(val); _set_value(#{ix.to_s}, val); end
921
+ })
922
+ end
923
+ if tc.implicit_default
924
+ union_type.module_eval(%Q{
925
+ def _default; @discriminator = #{tc.implicit_default}; @value = nil; end
926
+ })
927
+ end
928
+ union_type
929
+ end
930
+
931
+ def get_type
932
+ @type ||= CORBA::TypeCode::Union.define_type(self)
933
+ end
934
+
935
+ def validate(val)
936
+ return val if val.nil?
937
+ super(val)
938
+ @switchtype.validate(val._disc) unless val._disc == :default
939
+ #raise CORBA::MARSHAL.new(
940
+ # "invalid discriminator value (#{val._disc.to_s}) for union #{name}",
941
+ # 1, CORBA::COMPLETED_NO) unless @labels.has_key?(val._disc)
942
+ if @labels.has_key?(val._disc) # no need to check for implicit defaults
943
+ if needs_conversion(val)
944
+ vorg = val
945
+ val = vorg.class.new
946
+ val.__send__((@members[@labels[vorg._disc]][1]+'=').intern,
947
+ @members[@labels[vorg._disc]][2].validate(vorg._value))
948
+ else
949
+ @members[@labels[val._disc]][2].validate(val._value)
950
+ end
951
+ end
952
+ val
953
+ end
954
+
955
+ def needs_conversion(val)
956
+ @members[@labels[val._disc]][2].needs_conversion(val._value)
957
+ end
958
+
959
+ def member_count
960
+ @members.size
961
+ end
962
+ def member_name(index)
963
+ raise CORBA::TypeCode::Bounds.new if (index<0) || (index>=@members.size)
964
+ @members[index][1]
965
+ end
966
+ def member_type(index)
967
+ raise CORBA::TypeCode::Bounds.new if (index<0) || (index>=@members.size)
968
+ @members[index][2]
969
+ end
970
+ def member_label(index)
971
+ raise CORBA::TypeCode::Bounds.new if (index<0) || (index>=@members.size)
972
+ @members[index][0]
973
+ end
974
+ def discriminator_type
975
+ @switchtype
976
+ end
977
+ def default_index
978
+ if @labels.has_key? :default then @labels[:default]; else -1; end
979
+ end
980
+
981
+ def label_index(val)
982
+ val = @switchtype.validate(val) unless val == :default
983
+ #raise CORBA::MARSHAL.new(
984
+ # "invalid discriminator value (#{val}) for union #{name}",
985
+ # 1, CORBA::COMPLETED_NO) unless val == :default || @labels.has_key?(val) || @labels.has_key?(:default)
986
+ if val == :default then @labels[:default]; elsif @labels.has_key?(val) then @labels[val] else nil end
987
+ end
988
+
989
+ def label_member(val)
990
+ return nil unless (lbl_ix = label_index(val))
991
+ member_name(lbl_ix)
992
+ end
993
+
994
+ def inspect
995
+ s = "#{self.class.name}: #{name} - #{id}\n"
996
+ @members.each { |l, n, t| s += " case #{l.to_s}: #{n} = "+t.inspect+"\n" }
997
+ s
998
+ end
999
+ end # Union
1000
+
1001
+ class Enum < IdentifiedTypeCode
1002
+ attr_reader :members
1003
+ def initialize(*args)
1004
+ raise RuntimeError, 'overload required'
1005
+ end
1006
+ def get_type
1007
+ ::Integer
1008
+ end
1009
+
1010
+ def validate(val)
1011
+ super(val) if !val.respond_to?(:to_int)
1012
+ raise CORBA::MARSHAL.new(
1013
+ "value (#{val}) out of range (#{@range}) for enum: #{name}",
1014
+ 1, CORBA::COMPLETED_NO) unless @range === (::Integer === val ? val : val.to_int)
1015
+ (::Integer === val ? val : val.to_int)
1016
+ end
1017
+
1018
+ def needs_conversion(val)
1019
+ !(::Integer === val)
1020
+ end
1021
+
1022
+ def member_count
1023
+ @members.size
1024
+ end
1025
+ def member_name(index)
1026
+ raise CORBA::TypeCode::Bounds.new if (index<0) || (index>=@members.size)
1027
+ @members[index]
1028
+ end
1029
+ end # Enum
1030
+
1031
+ class Bounds < CORBA::UserException
1032
+ def Bounds._tc
1033
+ @@tc_Bounds ||= CORBA::TypeCode::Except.new('IDL:omg.org/CORBA/TypeCode/Bounds:1.0'.freeze, 'Bounds', [], self)
1034
+ end
1035
+ end
1036
+
1037
+ class BadKind < CORBA::UserException
1038
+ def BadKind._tc
1039
+ @@tc_BadKind ||= CORBA::TypeCode::Except.new('IDL:omg.org/CORBA/TypeCode/BadKind:1.0'.freeze, 'BadKind', [], self)
1040
+ end
1041
+ end
1042
+
1043
+ def TypeCode.get_primitive_tc(kind)
1044
+ raise RuntimeError, 'overload required'
1045
+ end
1046
+
1047
+ private
1048
+
1049
+ def TypeCode._init
1050
+
1051
+ Bounds._tc
1052
+
1053
+ BadKind._tc
1054
+ end
1055
+
1056
+ end # TypeCode
1057
+
1058
+ # define typecode constants for primitive types
1059
+ [ 'null', 'void',
1060
+ 'short', 'long', 'ushort', 'ulong', 'longlong', 'ulonglong',
1061
+ 'float', 'double', 'longdouble',
1062
+ 'boolean',
1063
+ 'char', 'octet',
1064
+ 'wchar',
1065
+ 'any',
1066
+ ].each do |tck|
1067
+ CORBA.module_eval %Q{
1068
+ def CORBA._tc_#{tck}
1069
+ @@tc_#{tck} ||= TypeCode.get_primitive_tc(CORBA::TK_#{tck.upcase})
1070
+ end
1071
+ }
1072
+ end
1073
+
1074
+ def CORBA._tc_string
1075
+ @@tc_string ||= TypeCode::String.new()
1076
+ end
1077
+
1078
+ def CORBA._tc_wstring
1079
+ @@tc_wstring ||= TypeCode::WString.new()
1080
+ end
1081
+
1082
+ # define special typecode constants
1083
+
1084
+ def CORBA._tc_TypeCode
1085
+ @@tc_TypeCode ||= TypeCode.get_primitive_tc(CORBA::TK_TYPECODE)
1086
+ end
1087
+
1088
+ def CORBA._tc_Principal
1089
+ @@tc_Principal ||= TypeCode.get_primitive_tc(CORBA::TK_PRINCIPAL)
1090
+ end
1091
+
1092
+ def CORBA._tc_Object
1093
+ @@tc_Object ||= TypeCode.get_primitive_tc(CORBA::TK_OBJREF)
1094
+ end
1095
+
1096
+ def CORBA._tc_CCMObject
1097
+ @@tc_CCMObject ||= TypeCode::Component.new("IDL:omg.org/CORBA/CCMObject:1.0", "CCMObject", CORBA::Object).freeze
1098
+ end
1099
+
1100
+ def CORBA._tc_CCHome
1101
+ @@tc_CCHome ||= TypeCode::Home.new("IDL:omg.org/CORBA/CCHome:1.0", "CCHome", CORBA::Object).freeze
1102
+ end
1103
+
1104
+ # define system exception related typecode constants
1105
+
1106
+ def CORBA._tc_CompletionStatus
1107
+ @@tc_CompletionStatus ||= TypeCode::Enum.new("IDL:omg.org/CORBA/CompletionStatus:1.0", "CompletionStatus",
1108
+ CORBA::COMPLETED_TXT.collect {|t| "COMPLETED_#{t}"})
1109
+ end
1110
+
1111
+ class LongDouble
1112
+ def to_d(precision)
1113
+ BigDecimal.new(self.to_s(precision))
1114
+ end
1115
+ def LongDouble._tc
1116
+ CORBA._tc_longdouble
1117
+ end
1118
+ end
1119
+
1120
+ end ## module CORBA
1121
+ end ## module R2CORBA