r2corba 1.4.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/CHANGES +159 -0
- data/LICENSE +59 -0
- data/README +62 -0
- data/THANKS +52 -0
- data/bin/r2corba +8 -0
- data/bin/ridlc +11 -0
- data/bin/rins +7 -0
- data/ext/ext.mwc +6 -0
- data/ext/extload/extload.c +60 -0
- data/ext/libr2tao/any.cpp +1543 -0
- data/ext/libr2tao/exception.cpp +202 -0
- data/ext/libr2tao/exception.h +104 -0
- data/ext/libr2tao/longdouble.cpp +173 -0
- data/ext/libr2tao/longdouble.h +31 -0
- data/ext/libr2tao/object.cpp +1150 -0
- data/ext/libr2tao/object.h +38 -0
- data/ext/libr2tao/orb.cpp +1029 -0
- data/ext/libr2tao/orb.h +36 -0
- data/ext/libr2tao/r2tao_export.h +45 -0
- data/ext/libr2tao/r2tao_ext.h +38 -0
- data/ext/libr2tao/required.cpp +463 -0
- data/ext/libr2tao/required.h +187 -0
- data/ext/libr2tao/typecode.cpp +888 -0
- data/ext/libr2tao/typecode.h +45 -0
- data/ext/libr2tao/values.cpp +2938 -0
- data/ext/libr2tao/values.h +396 -0
- data/ext/librpoa/iortable.cpp +250 -0
- data/ext/librpoa/poa.cpp +1076 -0
- data/ext/librpoa/poa.h +24 -0
- data/ext/librpoa/rpoa_export.h +44 -0
- data/ext/librpoa/servant.cpp +1338 -0
- data/ext/librpoa/servant.h +116 -0
- data/ext/librpoa/srvreq_fix.cpp +283 -0
- data/ext/librpoa/srvreq_fix.h +149 -0
- data/ext/librpol/policies.cpp +763 -0
- data/ext/librpol/policies.h +15 -0
- data/ext/librpol/rpol_export.h +44 -0
- data/lib/corba/cbase/IORMap.rb +33 -0
- data/lib/corba/cbase/ORB.rb +231 -0
- data/lib/corba/cbase/Request.rb +134 -0
- data/lib/corba/cbase/Streams.rb +129 -0
- data/lib/corba/cbase/Stub.rb +19 -0
- data/lib/corba/cbase/Typecode.rb +441 -0
- data/lib/corba/cbase/Values.rb +129 -0
- data/lib/corba/cbase/exception.rb +66 -0
- data/lib/corba/cbase/poa.rb +23 -0
- data/lib/corba/cbase/policies.rb +78 -0
- data/lib/corba/cbase/post_require.rb +14 -0
- data/lib/corba/cbase/require.rb +28 -0
- data/lib/corba/cmds/base.rb +85 -0
- data/lib/corba/cmds/test.rb +30 -0
- data/lib/corba/common/Any.rb +91 -0
- data/lib/corba/common/IDL.rb +104 -0
- data/lib/corba/common/ORB.rb +368 -0
- data/lib/corba/common/Object.rb +208 -0
- data/lib/corba/common/Request.rb +20 -0
- data/lib/corba/common/Servant.rb +108 -0
- data/lib/corba/common/Struct.rb +22 -0
- data/lib/corba/common/Stub.rb +79 -0
- data/lib/corba/common/Typecode.rb +1121 -0
- data/lib/corba/common/Union.rb +56 -0
- data/lib/corba/common/Values.rb +92 -0
- data/lib/corba/common/const.rb +22 -0
- data/lib/corba/common/exception.rb +68 -0
- data/lib/corba/common/require.rb +27 -0
- data/lib/corba/common/version.rb +22 -0
- data/lib/corba/idl/IDL.rb +21 -0
- data/lib/corba/idl/IORTable.pidl +62 -0
- data/lib/corba/idl/TAO_Ext.pidl +46 -0
- data/lib/corba/idl/require.rb +20 -0
- data/lib/corba/jbase/Any.rb +273 -0
- data/lib/corba/jbase/IORMap.rb +36 -0
- data/lib/corba/jbase/ORB.rb +99 -0
- data/lib/corba/jbase/Object.rb +98 -0
- data/lib/corba/jbase/Request.rb +226 -0
- data/lib/corba/jbase/Servant.rb +247 -0
- data/lib/corba/jbase/ServerRequest.rb +128 -0
- data/lib/corba/jbase/Streams.rb +671 -0
- data/lib/corba/jbase/Stub.rb +38 -0
- data/lib/corba/jbase/Typecode.rb +520 -0
- data/lib/corba/jbase/Values.rb +173 -0
- data/lib/corba/jbase/exception.rb +106 -0
- data/lib/corba/jbase/poa.rb +229 -0
- data/lib/corba/jbase/policies.rb +300 -0
- data/lib/corba/jbase/post_require.rb +14 -0
- data/lib/corba/jbase/require.rb +86 -0
- data/lib/corba/naming.rb +14 -0
- data/lib/corba/naming_service.rb +15 -0
- data/lib/corba/poa.rb +15 -0
- data/lib/corba/policies.rb +18 -0
- data/lib/corba/require.rb +17 -0
- data/lib/corba/svcs/ins/cos_naming.rb +426 -0
- data/lib/corba/svcs/ins/ins.rb +526 -0
- data/lib/corba/svcs/ins/naming_service.rb +119 -0
- data/lib/corba.rb +16 -0
- data/lib/ridlbe/ruby/config.rb +336 -0
- data/lib/ridlbe/ruby/require.rb +16 -0
- data/lib/ridlbe/ruby/walker.rb +1582 -0
- data/mkrf_conf_srcgem.rb +186 -0
- data/rakelib/bin.rake +80 -0
- data/rakelib/bin.rb +146 -0
- data/rakelib/build.rake +87 -0
- data/rakelib/config.rake +52 -0
- data/rakelib/config.rb +450 -0
- data/rakelib/ext.rake +242 -0
- data/rakelib/ext.rb +308 -0
- data/rakelib/ext_r2tao.rb +232 -0
- data/rakelib/gem.rake +212 -0
- data/rakelib/gem.rb +146 -0
- data/rakelib/package.rake +26 -0
- data/rakelib/test.rake +23 -0
- data/test/BiDirectional/Test.idl +34 -0
- data/test/BiDirectional/client.rb +132 -0
- data/test/BiDirectional/run_test.rb +68 -0
- data/test/BiDirectional/server.rb +169 -0
- data/test/CORBA_Services/Naming/BindingIterator/Test.idl +27 -0
- data/test/CORBA_Services/Naming/BindingIterator/client.rb +121 -0
- data/test/CORBA_Services/Naming/BindingIterator/run_test.rb +82 -0
- data/test/CORBA_Services/Naming/BindingIterator/server.rb +109 -0
- data/test/CORBA_Services/Naming/Corbaname/Test.idl +27 -0
- data/test/CORBA_Services/Naming/Corbaname/client.rb +85 -0
- data/test/CORBA_Services/Naming/Corbaname/run_test.rb +88 -0
- data/test/CORBA_Services/Naming/Corbaname/server.rb +135 -0
- data/test/CORBA_Services/Naming/Simple/Test.idl +27 -0
- data/test/CORBA_Services/Naming/Simple/client.rb +84 -0
- data/test/CORBA_Services/Naming/Simple/run_test.rb +82 -0
- data/test/CORBA_Services/Naming/Simple/server.rb +109 -0
- data/test/Collocation/Diamond.idl +39 -0
- data/test/Collocation/run_test.rb +52 -0
- data/test/Collocation/test.rb +195 -0
- data/test/Connect_Timeout/Test.idl +27 -0
- data/test/Connect_Timeout/client.rb +111 -0
- data/test/Connect_Timeout/run_test.rb +52 -0
- data/test/DII/Test.idl +27 -0
- data/test/DII/client.rb +115 -0
- data/test/DII/run_test.rb +69 -0
- data/test/DII/server.rb +95 -0
- data/test/DSI/Test.idl +27 -0
- data/test/DSI/client.rb +66 -0
- data/test/DSI/run_test.rb +69 -0
- data/test/DSI/server.rb +106 -0
- data/test/Exceptions/Test.idl +48 -0
- data/test/Exceptions/client.rb +118 -0
- data/test/Exceptions/run_test.rb +69 -0
- data/test/Exceptions/server.rb +131 -0
- data/test/Hello/Test.idl +27 -0
- data/test/Hello/client.rb +78 -0
- data/test/Hello/run_test.rb +71 -0
- data/test/Hello/server.rb +95 -0
- data/test/IDL_Test/Test.idl +113 -0
- data/test/IDL_Test/Test_inc.idl +17 -0
- data/test/IDL_Test/client.rb +102 -0
- data/test/IDL_Test/run_test.rb +69 -0
- data/test/IDL_Test/server.rb +99 -0
- data/test/IORMap/Test.idl +27 -0
- data/test/IORMap/client.rb +73 -0
- data/test/IORMap/run_test.rb +69 -0
- data/test/IORMap/server.rb +114 -0
- data/test/IORTable/Test.idl +27 -0
- data/test/IORTable/client.rb +75 -0
- data/test/IORTable/run_test.rb +69 -0
- data/test/IORTable/server.rb +130 -0
- data/test/Implicit_Conversion/Test.idl +31 -0
- data/test/Implicit_Conversion/client.rb +110 -0
- data/test/Implicit_Conversion/run_test.rb +69 -0
- data/test/Implicit_Conversion/server.rb +99 -0
- data/test/Multi_Threading/Multiple_ORB/Test.idl +27 -0
- data/test/Multi_Threading/Multiple_ORB/client.rb +82 -0
- data/test/Multi_Threading/Multiple_ORB/run_test.rb +71 -0
- data/test/Multi_Threading/Multiple_ORB/server.rb +108 -0
- data/test/Multi_Threading/Simple/Test.idl +27 -0
- data/test/Multi_Threading/Simple/client.rb +88 -0
- data/test/Multi_Threading/Simple/run_test.rb +69 -0
- data/test/Multi_Threading/Simple/server.rb +118 -0
- data/test/Multi_Threading/Threads/Test.idl +31 -0
- data/test/Multi_Threading/Threads/client.rb +80 -0
- data/test/Multi_Threading/Threads/run_test.rb +76 -0
- data/test/Multi_Threading/Threads/server.rb +119 -0
- data/test/Multi_Threading/Threads/watchdog.rb +87 -0
- data/test/Multiple_Servant_Interfaces/Test.idl +34 -0
- data/test/Multiple_Servant_Interfaces/client.rb +70 -0
- data/test/Multiple_Servant_Interfaces/run_test.rb +69 -0
- data/test/Multiple_Servant_Interfaces/server.rb +102 -0
- data/test/Nil/Test.idl +27 -0
- data/test/Nil/run_test.rb +52 -0
- data/test/Nil/test.rb +78 -0
- data/test/OBV/AbstractInterface/client.rb +179 -0
- data/test/OBV/AbstractInterface/run_test.rb +69 -0
- data/test/OBV/AbstractInterface/server.rb +149 -0
- data/test/OBV/AbstractInterface/test.idl +53 -0
- data/test/OBV/Custom/OBV.idl +18 -0
- data/test/OBV/Custom/OBV_impl.rb +40 -0
- data/test/OBV/Custom/client.rb +86 -0
- data/test/OBV/Custom/run_test.rb +69 -0
- data/test/OBV/Custom/server.rb +100 -0
- data/test/OBV/Simple/OBV.idl +15 -0
- data/test/OBV/Simple/OBV_impl.rb +26 -0
- data/test/OBV/Simple/client.rb +86 -0
- data/test/OBV/Simple/run_test.rb +69 -0
- data/test/OBV/Simple/server.rb +100 -0
- data/test/OBV/Simple_Event/Event.idl +15 -0
- data/test/OBV/Simple_Event/Event_impl.rb +26 -0
- data/test/OBV/Simple_Event/client.rb +86 -0
- data/test/OBV/Simple_Event/run_test.rb +69 -0
- data/test/OBV/Simple_Event/server.rb +100 -0
- data/test/OBV/Supports/client.rb +116 -0
- data/test/OBV/Supports/run_test.rb +69 -0
- data/test/OBV/Supports/server.rb +103 -0
- data/test/OBV/Supports/supports.idl +33 -0
- data/test/OBV/Supports/supports_impl.rb +57 -0
- data/test/OBV/Tree/client.rb +116 -0
- data/test/OBV/Tree/run_test.rb +69 -0
- data/test/OBV/Tree/server.rb +117 -0
- data/test/OBV/Tree/test.idl +32 -0
- data/test/OBV/Truncatable/Extra.idl +27 -0
- data/test/OBV/Truncatable/Truncatable.idl +105 -0
- data/test/OBV/Truncatable/Truncatable_impl.rb +86 -0
- data/test/OBV/Truncatable/client.rb +279 -0
- data/test/OBV/Truncatable/run_test.rb +69 -0
- data/test/OBV/Truncatable/server.rb +89 -0
- data/test/OBV/ValueBox/client.rb +497 -0
- data/test/OBV/ValueBox/run_test.rb +69 -0
- data/test/OBV/ValueBox/server.rb +271 -0
- data/test/OBV/ValueBox/valuebox.idl +101 -0
- data/test/OBV/ValueBox/vb_basic.idl +75 -0
- data/test/OBV/ValueBox/vb_struct.idl +68 -0
- data/test/OBV/ValueBox/vb_union.idl +21 -0
- data/test/Object/Test.idl +27 -0
- data/test/Object/client.rb +103 -0
- data/test/Object/run_test.rb +69 -0
- data/test/Object/server.rb +126 -0
- data/test/POA/Test.idl +27 -0
- data/test/POA/run_test.rb +52 -0
- data/test/POA/test.rb +112 -0
- data/test/Param_Test/Test.idl +182 -0
- data/test/Param_Test/client.rb +277 -0
- data/test/Param_Test/run_test.rb +69 -0
- data/test/Param_Test/server.rb +296 -0
- data/test/Performance/Simple/Test.idl +27 -0
- data/test/Performance/Simple/client.rb +90 -0
- data/test/Performance/Simple/run_test.rb +69 -0
- data/test/Performance/Simple/server.rb +95 -0
- data/test/Policies/Test.idl +27 -0
- data/test/Policies/run_test.rb +52 -0
- data/test/Policies/test.rb +144 -0
- data/test/Timeout/client.rb +207 -0
- data/test/Timeout/run_test.rb +69 -0
- data/test/Timeout/server.rb +109 -0
- data/test/Timeout/test.idl +19 -0
- data/test/lib/assert.rb +43 -0
- data/test/lib/test.rb +542 -0
- data/test/test_runner.rb +193 -0
- metadata +334 -0
@@ -0,0 +1,520 @@
|
|
1
|
+
#--------------------------------------------------------------------
|
2
|
+
# Typecode.rb - Java/JacORB specific 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 "corba/jbase/Any.rb"
|
14
|
+
require 'bigdecimal'
|
15
|
+
|
16
|
+
module R2CORBA
|
17
|
+
module CORBA
|
18
|
+
|
19
|
+
# define typecode kind constants
|
20
|
+
['tk_null',
|
21
|
+
'tk_void',
|
22
|
+
'tk_short',
|
23
|
+
'tk_long',
|
24
|
+
'tk_ushort',
|
25
|
+
'tk_ulong',
|
26
|
+
'tk_float',
|
27
|
+
'tk_double',
|
28
|
+
'tk_boolean',
|
29
|
+
'tk_char',
|
30
|
+
'tk_octet',
|
31
|
+
'tk_any',
|
32
|
+
'tk_TypeCode',
|
33
|
+
'tk_Principal',
|
34
|
+
'tk_objref',
|
35
|
+
'tk_struct',
|
36
|
+
'tk_union',
|
37
|
+
'tk_enum',
|
38
|
+
'tk_string',
|
39
|
+
'tk_sequence',
|
40
|
+
'tk_array',
|
41
|
+
'tk_alias',
|
42
|
+
'tk_except',
|
43
|
+
'tk_longlong',
|
44
|
+
'tk_ulonglong',
|
45
|
+
'tk_longdouble',
|
46
|
+
'tk_wchar',
|
47
|
+
'tk_wstring',
|
48
|
+
'tk_fixed',
|
49
|
+
'tk_value',
|
50
|
+
'tk_value_box',
|
51
|
+
'tk_native',
|
52
|
+
'tk_abstract_interface'].each do |tk|
|
53
|
+
CORBA.const_set(tk.upcase.to_sym, CORBA::Native::TCKind.send("_#{tk}".to_sym))
|
54
|
+
end
|
55
|
+
|
56
|
+
class TypeCode
|
57
|
+
|
58
|
+
def TypeCode.native_kind(ntc)
|
59
|
+
ntc.kind.value
|
60
|
+
end
|
61
|
+
|
62
|
+
def kind
|
63
|
+
begin
|
64
|
+
self.tc_.kind.value
|
65
|
+
rescue ::NativeException
|
66
|
+
CORBA::Exception.native2r($!)
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
def member_label(index)
|
71
|
+
begin
|
72
|
+
Any.from_java(self.tc_.member_label(index.to_i))
|
73
|
+
rescue ::NativeException
|
74
|
+
CORBA::Exception.native2r($!)
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
class Recursive < CORBA::TypeCode
|
79
|
+
|
80
|
+
def initialize(id)
|
81
|
+
begin
|
82
|
+
@tc_ = CORBA::ORB._orb.create_recursive_tc(id)
|
83
|
+
rescue ::NativeException
|
84
|
+
CORBA::Exception.native2r($!)
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
end # Recursive
|
89
|
+
|
90
|
+
class String < CORBA::TypeCode
|
91
|
+
|
92
|
+
def initialize(*args)
|
93
|
+
if CORBA::Native::TypeCode === args.first
|
94
|
+
@tc_ = args.first
|
95
|
+
else
|
96
|
+
begin
|
97
|
+
@tc_ = CORBA::ORB._orb.create_string_tc(args.shift.to_i)
|
98
|
+
rescue ::NativeException
|
99
|
+
CORBA::Exception.native2r($!)
|
100
|
+
end
|
101
|
+
end
|
102
|
+
end
|
103
|
+
|
104
|
+
end # String
|
105
|
+
|
106
|
+
class WString < CORBA::TypeCode
|
107
|
+
|
108
|
+
def initialize(*args)
|
109
|
+
if CORBA::Native::TypeCode === args.first
|
110
|
+
@tc_ = args.first
|
111
|
+
else
|
112
|
+
begin
|
113
|
+
@tc_ = CORBA::ORB._orb.create_wstring_tc(args.shift.to_i)
|
114
|
+
rescue ::NativeException
|
115
|
+
CORBA::Exception.native2r($!)
|
116
|
+
end
|
117
|
+
end
|
118
|
+
end
|
119
|
+
|
120
|
+
end # WString
|
121
|
+
|
122
|
+
class Fixed < CORBA::TypeCode
|
123
|
+
|
124
|
+
def initialize(*args)
|
125
|
+
if CORBA::Native::TypeCode === args.first
|
126
|
+
@tc_ = args.first
|
127
|
+
else
|
128
|
+
digits, scale = args
|
129
|
+
begin
|
130
|
+
@tc_ = CORBA::ORB._orb.create_fixed_tc(digits.to_i, scale.to_i)
|
131
|
+
rescue ::NativeException
|
132
|
+
CORBA::Exception.native2r($!)
|
133
|
+
end
|
134
|
+
end
|
135
|
+
end
|
136
|
+
|
137
|
+
end # Fixed
|
138
|
+
|
139
|
+
class Sequence < CORBA::TypeCode
|
140
|
+
|
141
|
+
def initialize(*args)
|
142
|
+
if CORBA::Native::TypeCode === args.first
|
143
|
+
@tc_ = args.first
|
144
|
+
else
|
145
|
+
element_tc, bound = args
|
146
|
+
raise ArgumentError, 'expected CORBA::TypeCode' unless element_tc.is_a?(CORBA::TypeCode)
|
147
|
+
begin
|
148
|
+
@tc_ = CORBA::ORB._orb.create_sequence_tc(bound.to_i, element_tc.tc_)
|
149
|
+
rescue ::NativeException
|
150
|
+
CORBA::Exception.native2r($!)
|
151
|
+
end
|
152
|
+
end
|
153
|
+
end
|
154
|
+
|
155
|
+
end
|
156
|
+
|
157
|
+
class Array < CORBA::TypeCode
|
158
|
+
|
159
|
+
def initialize(*args)
|
160
|
+
if CORBA::Native::TypeCode === args.first
|
161
|
+
@tc_ = args.first
|
162
|
+
else
|
163
|
+
content_tc = args.shift
|
164
|
+
length = args
|
165
|
+
raise ArgumentError, 'expected CORBA::TypeCode' unless content_tc.is_a?(CORBA::TypeCode)
|
166
|
+
if length.size>1
|
167
|
+
this_len = length.shift
|
168
|
+
content_tc = self.class.new(content_tc, *length)
|
169
|
+
else
|
170
|
+
this_len = length.first
|
171
|
+
end
|
172
|
+
begin
|
173
|
+
@tc_ = CORBA::ORB._orb.create_array_tc(this_len.to_i, content_tc.tc_)
|
174
|
+
rescue ::NativeException
|
175
|
+
CORBA::Exception.native2r($!)
|
176
|
+
end
|
177
|
+
end
|
178
|
+
end
|
179
|
+
|
180
|
+
end # Array
|
181
|
+
|
182
|
+
class IdentifiedTypeCode < CORBA::TypeCode
|
183
|
+
|
184
|
+
def initialize(id)
|
185
|
+
CORBA::TypeCode.register_id_type(id.to_s, self)
|
186
|
+
end
|
187
|
+
|
188
|
+
end # IdentifiedTypeCode
|
189
|
+
|
190
|
+
class Alias < IdentifiedTypeCode
|
191
|
+
|
192
|
+
def initialize(*args)
|
193
|
+
if CORBA::Native::TypeCode === args.first
|
194
|
+
@tc_ = args.first
|
195
|
+
@type = nil
|
196
|
+
super(@tc_.id)
|
197
|
+
else
|
198
|
+
id, name, orig_tc, type = args
|
199
|
+
raise ArgumentError, 'expected CORBA::TypeCode' unless orig_tc.is_a?(CORBA::TypeCode)
|
200
|
+
begin
|
201
|
+
@tc_ = CORBA::ORB._orb.create_alias_tc(id.to_s, name.to_s, orig_tc.tc_)
|
202
|
+
rescue ::NativeException
|
203
|
+
CORBA::Exception.native2r($!)
|
204
|
+
end
|
205
|
+
@type = type
|
206
|
+
super(id)
|
207
|
+
end
|
208
|
+
end
|
209
|
+
|
210
|
+
end # Alias
|
211
|
+
|
212
|
+
class Valuetype < IdentifiedTypeCode
|
213
|
+
|
214
|
+
def initialize(*args)
|
215
|
+
if CORBA::Native::TypeCode === args.first
|
216
|
+
@tc_ = args.first
|
217
|
+
@type = nil
|
218
|
+
@members = []
|
219
|
+
@tc_.member_count.times do |i|
|
220
|
+
@members << [@tc_.member_name(i), TypeCode.from_native(@tc_.member_type(i))]
|
221
|
+
end
|
222
|
+
super(id)
|
223
|
+
else
|
224
|
+
id, name, modifier, base, members_, type_ = args
|
225
|
+
raise ArgumentError, 'expected CORBA::Typecode' unless base.nil? || base.is_a?(CORBA::TypeCode)
|
226
|
+
raise ArgumentError, 'expected members Array' unless members_.is_a?(::Array) || type_.nil?
|
227
|
+
if type_.nil? && !members_.is_a?(::Array)
|
228
|
+
type_ = members_
|
229
|
+
members_ = []
|
230
|
+
end
|
231
|
+
@type = type_
|
232
|
+
@members = []
|
233
|
+
members_.each { |n, tc, access| add_member(n, tc, access) }
|
234
|
+
jmembers = CORBA::Native::Reflect::Array.newInstance(CORBA::Native::ValueMember.java_class, @members.size)
|
235
|
+
@members.each_with_index do |(mn, mtc, access),i|
|
236
|
+
m_id = mtc.is_a?(IdentifiedTypeCode) ? mtc.id : 'IDL:*primitive*:1.0'
|
237
|
+
jmembers[i] = CORBA::Native::ValueMember.new(mn.to_s, m_id,
|
238
|
+
name, id.split(':').last,
|
239
|
+
mtc.tc_, nil,
|
240
|
+
access==:public ?
|
241
|
+
CORBA::PUBLIC_MEMBER :
|
242
|
+
CORBA::PRIVATE_MEMBER)
|
243
|
+
end
|
244
|
+
@tc_ = _create_tc(id, name, modifier, base, jmembers)
|
245
|
+
super(id)
|
246
|
+
end
|
247
|
+
end
|
248
|
+
|
249
|
+
protected
|
250
|
+
|
251
|
+
def _create_tc(id,name,modifier,base,jmembers)
|
252
|
+
begin
|
253
|
+
CORBA::ORB._orb.create_value_tc(id.to_s,
|
254
|
+
name.to_s,
|
255
|
+
CORBA::VT_MODIFIERS[modifier],
|
256
|
+
base.nil? ? nil : base.tc_,
|
257
|
+
jmembers)
|
258
|
+
rescue ::NativeException
|
259
|
+
CORBA::Exception.native2r($!)
|
260
|
+
end
|
261
|
+
end
|
262
|
+
|
263
|
+
end # Valuetype
|
264
|
+
|
265
|
+
class Eventtype < Valuetype
|
266
|
+
|
267
|
+
protected
|
268
|
+
|
269
|
+
def _create_tc(id,name,modifier,base,jmembers)
|
270
|
+
# JaCORB 2.3.1' does not support tk_event typecodes yet;
|
271
|
+
# so just let it be a regular valuetype
|
272
|
+
# NOTE: this will not be interoperable between jR2CORBA and R2CORBA
|
273
|
+
begin
|
274
|
+
CORBA::ORB._orb.create_value_tc(id.to_s,
|
275
|
+
name.to_s,
|
276
|
+
CORBA::VT_MODIFIERS[modifier],
|
277
|
+
base.nil? ? nil : base.tc_,
|
278
|
+
jmembers)
|
279
|
+
rescue ::NativeException
|
280
|
+
CORBA::Exception.native2r($!)
|
281
|
+
end
|
282
|
+
end
|
283
|
+
|
284
|
+
end # Eventtype
|
285
|
+
|
286
|
+
class Valuebox < IdentifiedTypeCode
|
287
|
+
|
288
|
+
def initialize(*args)
|
289
|
+
if CORBA::Native::TypeCode === args.first
|
290
|
+
@tc_ = args.first
|
291
|
+
@type = nil
|
292
|
+
super(@tc_.id)
|
293
|
+
else
|
294
|
+
id, name, boxed_tc, type = args
|
295
|
+
raise ArgumentError, 'expected CORBA::TypeCode' unless boxed_tc.is_a?(CORBA::TypeCode)
|
296
|
+
begin
|
297
|
+
@tc_ = CORBA::ORB._orb.create_value_box_tc(id.to_s, name.to_s, boxed_tc.tc_)
|
298
|
+
rescue ::NativeException
|
299
|
+
CORBA::Exception.native2r($!)
|
300
|
+
end
|
301
|
+
@type = type
|
302
|
+
super(id)
|
303
|
+
end
|
304
|
+
end
|
305
|
+
|
306
|
+
end # Valuebox
|
307
|
+
|
308
|
+
class ObjectRef < IdentifiedTypeCode
|
309
|
+
|
310
|
+
def initialize(*args)
|
311
|
+
if CORBA::Native::TypeCode === args.first
|
312
|
+
@tc_ = args.first
|
313
|
+
@type = CORBA::Object
|
314
|
+
super(@tc_.id)
|
315
|
+
else
|
316
|
+
id, name, type = args
|
317
|
+
begin
|
318
|
+
@tc_ = CORBA::ORB._orb.create_interface_tc(id.to_s, name.to_s)
|
319
|
+
rescue ::NativeException
|
320
|
+
CORBA::Exception.native2r($!)
|
321
|
+
end
|
322
|
+
@type = type
|
323
|
+
super(id)
|
324
|
+
end
|
325
|
+
end
|
326
|
+
|
327
|
+
end # ObjectRef
|
328
|
+
|
329
|
+
class AbstractInterface < IdentifiedTypeCode
|
330
|
+
|
331
|
+
def initialize(*args)
|
332
|
+
if CORBA::Native::TypeCode === args.first
|
333
|
+
@tc_ = args.first
|
334
|
+
@type = CORBA::AbstractBase
|
335
|
+
super(@tc_.id)
|
336
|
+
else
|
337
|
+
id, name, type = args
|
338
|
+
begin
|
339
|
+
@tc_ = CORBA::ORB._orb.create_abstract_interface_tc(id.to_s, name.to_s)
|
340
|
+
rescue ::NativeException
|
341
|
+
CORBA::Exception.native2r($!)
|
342
|
+
end
|
343
|
+
@type = type
|
344
|
+
super(id)
|
345
|
+
end
|
346
|
+
end
|
347
|
+
|
348
|
+
end # AbstractInterface
|
349
|
+
|
350
|
+
class Struct < IdentifiedTypeCode
|
351
|
+
|
352
|
+
def initialize(*args)
|
353
|
+
if CORBA::Native::TypeCode === args.first
|
354
|
+
@tc_ = args.first
|
355
|
+
@type = nil
|
356
|
+
@members = []
|
357
|
+
@tc_.member_count.times do |i|
|
358
|
+
@members << [@tc_.member_name(i), TypeCode.from_native(@tc_.member_type(i))]
|
359
|
+
end
|
360
|
+
super(id)
|
361
|
+
else
|
362
|
+
id, name, members_, type_ = args
|
363
|
+
raise ArgumentError, 'expected members Array' unless members_.is_a?(::Array) || type_.nil?
|
364
|
+
if type_.nil? && !members_.is_a?(::Array)
|
365
|
+
type_ = members_
|
366
|
+
members_ = []
|
367
|
+
end
|
368
|
+
@type = type_
|
369
|
+
@members = []
|
370
|
+
members_.each { |n, tc| add_member(n, tc) }
|
371
|
+
jmembers = CORBA::Native::Reflect::Array.newInstance(CORBA::Native::StructMember.java_class, @members.size)
|
372
|
+
@members.each_with_index {|(mn, mtc),i| jmembers[i] = CORBA::Native::StructMember.new(mn.to_s, mtc.tc_, nil) }
|
373
|
+
@tc_ = _create_tc(id, name, jmembers)
|
374
|
+
super(id)
|
375
|
+
end
|
376
|
+
end
|
377
|
+
|
378
|
+
protected
|
379
|
+
|
380
|
+
def _create_tc(id,name,jmembers)
|
381
|
+
begin
|
382
|
+
CORBA::ORB._orb.create_struct_tc(id.to_s, name.to_s, jmembers)
|
383
|
+
rescue ::NativeException
|
384
|
+
CORBA::Exception.native2r($!)
|
385
|
+
end
|
386
|
+
end
|
387
|
+
|
388
|
+
end # Struct
|
389
|
+
|
390
|
+
class Except < Struct
|
391
|
+
|
392
|
+
def from_java(jex)
|
393
|
+
raise CORBA::BAD_PARAM.new('org.om.CORBA.UserException expected',0,CORBA::COMPLETED_NO) unless jex.is_a?(CORBA::Native::UserException)
|
394
|
+
ex = get_type.new
|
395
|
+
members.each {|mname,mtc| ex.__send__("#{mname}=".to_sym, jex.__send__(mname.to_sym)) }
|
396
|
+
ex
|
397
|
+
end
|
398
|
+
|
399
|
+
def is_compatible?(jex)
|
400
|
+
raise CORBA::BAD_PARAM.new('org.om.CORBA.UserException expected',0,CORBA::COMPLETED_NO) unless jex.is_a?(CORBA::Native::UserException)
|
401
|
+
members.all? {|mname,mtc| jex.respond_to?(mname.to_sym) }
|
402
|
+
end
|
403
|
+
|
404
|
+
protected
|
405
|
+
|
406
|
+
def _create_tc(id,name,jmembers)
|
407
|
+
begin
|
408
|
+
CORBA::ORB._orb.create_exception_tc(id.to_s, name.to_s, jmembers)
|
409
|
+
rescue ::NativeException
|
410
|
+
CORBA::Exception.native2r($!)
|
411
|
+
end
|
412
|
+
end
|
413
|
+
|
414
|
+
end # Except
|
415
|
+
|
416
|
+
class Union < IdentifiedTypeCode
|
417
|
+
|
418
|
+
def initialize(*args)
|
419
|
+
if CORBA::Native::TypeCode === args.first
|
420
|
+
@tc_ = args.first
|
421
|
+
@type = nil
|
422
|
+
@switchtype = TypeCode.from_native(@tc_.discriminator_type)
|
423
|
+
@labels = {}
|
424
|
+
@members = []
|
425
|
+
def_inx = @tc_.default_index
|
426
|
+
@tc_.member_count.times do |i|
|
427
|
+
if def_inx < 0 || def_inx != i
|
428
|
+
ml_ = Any.from_java(@tc_.member_label(i))
|
429
|
+
else
|
430
|
+
ml_ = :default
|
431
|
+
end
|
432
|
+
@labels[ml] = i
|
433
|
+
@members << [ml, @tc_.member_name(i), TypeCode.from_native(@tc_.member_type(i))]
|
434
|
+
end
|
435
|
+
super(id)
|
436
|
+
else
|
437
|
+
id, name, switchtype_, members_, type_, implicit_default_ = args
|
438
|
+
raise ::CORBA::BAD_PARAM unless members_.is_a? ::Array
|
439
|
+
raise ::CORBA::BAD_PARAM unless switchtype_.is_a?(CORBA::TypeCode)
|
440
|
+
@type = type_
|
441
|
+
@implicit_default = implicit_default_
|
442
|
+
@switchtype = switchtype_.resolved_tc
|
443
|
+
@labels = {}
|
444
|
+
@members = []
|
445
|
+
members_.each { |mlabel, mname, mtc|
|
446
|
+
add_member(mlabel, mname, mtc)
|
447
|
+
}
|
448
|
+
@id = id
|
449
|
+
@name = name
|
450
|
+
super(id)
|
451
|
+
end
|
452
|
+
end
|
453
|
+
# because creating the native tc involves creating Any's we postpone until actually needed
|
454
|
+
def tc_
|
455
|
+
@tc_ ||= begin
|
456
|
+
jmembers = CORBA::Native::Reflect::Array.newInstance(CORBA::Native::UnionMember.java_class, @members.size)
|
457
|
+
@members.each_with_index {|(ml, mn, mt), i|
|
458
|
+
if ml == :default
|
459
|
+
# label octet:0 means default label
|
460
|
+
jmembers[i] = CORBA::Native::UnionMember.new(mn, Any.to_any(0, CORBA._tc_octet).to_java, mt.tc_, nil)
|
461
|
+
else
|
462
|
+
jmembers[i] = CORBA::Native::UnionMember.new(mn, Any.to_any(ml, @switchtype).to_java, mt.tc_, nil)
|
463
|
+
end
|
464
|
+
}
|
465
|
+
_create_tc(@id, @name, @switchtype, jmembers)
|
466
|
+
end
|
467
|
+
end
|
468
|
+
|
469
|
+
protected
|
470
|
+
|
471
|
+
def _create_tc(id,name, disctc,jmembers)
|
472
|
+
begin
|
473
|
+
CORBA::ORB._orb.create_union_tc(id.to_s, name.to_s, disctc.tc_, jmembers)
|
474
|
+
rescue ::NativeException
|
475
|
+
CORBA::Exception.native2r($!)
|
476
|
+
end
|
477
|
+
end
|
478
|
+
|
479
|
+
end # Union
|
480
|
+
|
481
|
+
class Enum < IdentifiedTypeCode
|
482
|
+
|
483
|
+
def initialize(*args)
|
484
|
+
if CORBA::Native::TypeCode === args.first
|
485
|
+
@tc_ = args.first
|
486
|
+
@range = (0..@tc_.member_count).freeze
|
487
|
+
@members = @range.to_a.collect {|i| @tc_.member_name(i) }
|
488
|
+
super(@tc_.id)
|
489
|
+
else
|
490
|
+
id, name, members_ = args
|
491
|
+
raise CORBA::BAD_PARAM unless members_.is_a? ::Array
|
492
|
+
@members = members_.collect {|m| m.to_s}
|
493
|
+
@range = (0...@members.size).freeze
|
494
|
+
begin
|
495
|
+
@tc_ = CORBA::ORB._orb.create_enum_tc(id.to_s, name.to_s, @members.to_java(:string))
|
496
|
+
rescue ::NativeException
|
497
|
+
CORBA::Exception.native2r($!)
|
498
|
+
end
|
499
|
+
super(id)
|
500
|
+
end
|
501
|
+
end
|
502
|
+
|
503
|
+
end # Enum
|
504
|
+
|
505
|
+
def TypeCode.get_primitive_tc(kind)
|
506
|
+
case kind
|
507
|
+
when CORBA::TK_OBJREF
|
508
|
+
TypeCode::ObjectRef.new("IDL:omg.org/CORBA/Object:1.0", "Object", CORBA::Object).freeze
|
509
|
+
else
|
510
|
+
TypeCode._wrap_native(CORBA::ORB._orb.get_primitive_tc(CORBA::Native::TCKind.from_int(kind.to_i)))
|
511
|
+
end
|
512
|
+
end
|
513
|
+
|
514
|
+
# final initialization
|
515
|
+
self._init()
|
516
|
+
|
517
|
+
end # TypeCode
|
518
|
+
|
519
|
+
end ## module CORBA
|
520
|
+
end ## module R2CORBA
|
@@ -0,0 +1,173 @@
|
|
1
|
+
#--------------------------------------------------------------------
|
2
|
+
# Values.rb - Java/JacORB CORBA Value and ValueBox 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
|
+
module CORBA
|
16
|
+
module AbstractValueBase
|
17
|
+
def self.included(mod)
|
18
|
+
mod.module_eval do
|
19
|
+
def self.===(obj)
|
20
|
+
obj.kind_of?(self)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
module ValueBase
|
26
|
+
def self.included(mod)
|
27
|
+
mod.module_eval do
|
28
|
+
include CORBA::Native::Portable::StreamableValue unless self.include?(CORBA::Native::Portable::StreamableValue)
|
29
|
+
# this defines the following methods to be implemented
|
30
|
+
# String[] _truncatable_ids();
|
31
|
+
# TypeCode _type();
|
32
|
+
# void _read(org.omg.CORBA.portable.InputStream is);
|
33
|
+
# void _write(org.omg.CORBA.portable.OutputStream os);
|
34
|
+
include CORBA::AbstractValueBase unless self.include?(CORBA::AbstractValueBase)
|
35
|
+
|
36
|
+
def _truncatable_ids
|
37
|
+
self.class::TRUNCATABLE_IDS.to_java(:string)
|
38
|
+
end
|
39
|
+
|
40
|
+
def _type
|
41
|
+
self.class._tc.tc_ # return Java TypeCode here
|
42
|
+
end
|
43
|
+
|
44
|
+
def _read(jis)
|
45
|
+
do_unmarshal(CORBA::Portable::InputStream._wrap_native(jis))
|
46
|
+
end
|
47
|
+
|
48
|
+
def _write(jos)
|
49
|
+
do_marshal(CORBA::Portable::OutputStream._wrap_native(jos))
|
50
|
+
end
|
51
|
+
|
52
|
+
def kind_of?(mod)
|
53
|
+
if mod < CORBA::AbstractValueBase && mod.const_defined?(:Intf)
|
54
|
+
super(mod::Intf)
|
55
|
+
else
|
56
|
+
super
|
57
|
+
end
|
58
|
+
end
|
59
|
+
alias :is_a? :kind_of?
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
def _marshal_with(os, &block)
|
64
|
+
self.instance_eval(&block)
|
65
|
+
end
|
66
|
+
|
67
|
+
def _unmarshal_with(is, &block)
|
68
|
+
self.instance_eval(&block)
|
69
|
+
end
|
70
|
+
end # ValueBase
|
71
|
+
|
72
|
+
module Portable
|
73
|
+
class ValueFactoryBase
|
74
|
+
include CORBA::Native::Portable::ValueFactory
|
75
|
+
## defines: java.io.Serializable read_value(InputStream is)
|
76
|
+
|
77
|
+
def self.inherited(value_factory_base)
|
78
|
+
# value_factory_base is the <valuetype>Factory base class
|
79
|
+
# generated from IDL
|
80
|
+
value_factory_base.module_eval do
|
81
|
+
def self.value_id
|
82
|
+
self::VALUE_ID
|
83
|
+
end
|
84
|
+
|
85
|
+
# overload
|
86
|
+
def read_value(jis)
|
87
|
+
vt = self._create_default
|
88
|
+
vt._read(jis)
|
89
|
+
vt
|
90
|
+
end
|
91
|
+
end
|
92
|
+
end
|
93
|
+
end # ValueFactoryBase
|
94
|
+
|
95
|
+
module CustomValueBase
|
96
|
+
def self.included(mod)
|
97
|
+
mod.module_eval do
|
98
|
+
include CORBA::ValueBase unless self.include?(CORBA::ValueBase)
|
99
|
+
|
100
|
+
def do_marshal(os)
|
101
|
+
self.marshal(os)
|
102
|
+
end
|
103
|
+
|
104
|
+
def do_unmarshal(is)
|
105
|
+
self.unmarshal(is)
|
106
|
+
end
|
107
|
+
end
|
108
|
+
end
|
109
|
+
end # CustomValueBase
|
110
|
+
|
111
|
+
module BoxedValueBase
|
112
|
+
class FactoryBase < CORBA::Portable::ValueFactoryBase
|
113
|
+
## generic factory base
|
114
|
+
end
|
115
|
+
def self.included(mod)
|
116
|
+
mod.module_eval do
|
117
|
+
include CORBA::ValueBase unless self.include?(CORBA::ValueBase)
|
118
|
+
|
119
|
+
def _write(jos)
|
120
|
+
CORBA::Portable::OutputStream._wrap_native(jos).write_member(
|
121
|
+
self.class._tc.content_type.resolved_tc, self.value)
|
122
|
+
end
|
123
|
+
|
124
|
+
def _read(jis)
|
125
|
+
self.value = CORBA::Portable::InputStream._wrap_native(jis).read_member(
|
126
|
+
self.class._tc.content_type.resolved_tc)
|
127
|
+
end
|
128
|
+
|
129
|
+
self.const_set(:Factory, Class.new(CORBA::Portable::BoxedValueBase::FactoryBase))
|
130
|
+
self::Factory.class_eval(%Q{
|
131
|
+
@@_reg = false
|
132
|
+
def self._check_factory(jorb)
|
133
|
+
return if @@_reg
|
134
|
+
self.get_factory(jorb)
|
135
|
+
@@_reg = true
|
136
|
+
end
|
137
|
+
|
138
|
+
def self.value_id
|
139
|
+
#{self.name}::TRUNCATABLE_IDS.first
|
140
|
+
end
|
141
|
+
|
142
|
+
def _create_default
|
143
|
+
#{self.name}.new
|
144
|
+
end
|
145
|
+
})
|
146
|
+
|
147
|
+
self.const_set(:Helper, Class.new)
|
148
|
+
self::Helper.class_eval(%Q{
|
149
|
+
include CORBA::Native::Portable::BoxedValueHelper unless self.include?(CORBA::Native::Portable::BoxedValueHelper)
|
150
|
+
|
151
|
+
def get_id()
|
152
|
+
#{self.name}::TRUNCATABLE_IDS.first
|
153
|
+
end
|
154
|
+
|
155
|
+
def read_value(jis)
|
156
|
+
#{self.name}.new._read(jis)
|
157
|
+
end
|
158
|
+
|
159
|
+
def write_value(jos, value)
|
160
|
+
value._write(jos)
|
161
|
+
end
|
162
|
+
})
|
163
|
+
|
164
|
+
def self.boxedvalue_helper
|
165
|
+
@@helper ||= Helper.new
|
166
|
+
end
|
167
|
+
end
|
168
|
+
end
|
169
|
+
end
|
170
|
+
|
171
|
+
end # Portable
|
172
|
+
end # CORBA
|
173
|
+
end # R2CORBA
|