Module: R2CORBA::CORBA::Portable::InputStream

Defined in:
lib/corba/cbase/Streams.rb,
lib/corba/jbase/Streams.rb

Constant Summary collapse

@@wrapper_klass =
Class.new do
  include CORBA::Portable::InputStream
  def initialize(jobj)
    @stream_ = jobj
  end
  attr_reader :stream_
end

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

._wrap_native(jobj) ⇒ Object



26
27
28
29
30
31
# File 'lib/corba/jbase/Streams.rb', line 26

def self._wrap_native(jobj)
  if jobj.nil? || !jobj.is_a?(Native::V2_3::Portable::InputStream)
    raise ArgumentError, 'Expected org.omg.CORBA.portable.InputStream'
  end
  @@wrapper_klass.new(jobj)
end

Instance Method Details

#read_AbstractObject



336
337
338
339
340
341
342
343
344
# File 'lib/corba/jbase/Streams.rb', line 336

def read_Abstract()
  begin
    obj = self.stream_.read_abstract_interface()
  rescue ::NativeException
    CORBA::Exception.native2r($!)
  end
  obj = CORBA::Object._wrap_native(obj) if obj.is_a?(CORBA::Native::Object)
  obj
end

#read_anyObject



89
90
91
92
93
94
95
# File 'lib/corba/jbase/Streams.rb', line 89

def read_any()
  begin
    self.stream_.read_any()
  rescue ::NativeException
    CORBA::Exception.native2r($!)
  end
end

#read_booleanObject



96
97
98
99
100
101
102
# File 'lib/corba/jbase/Streams.rb', line 96

def read_boolean()
  begin
    self.stream_.read_boolean()
  rescue ::NativeException
    CORBA::Exception.native2r($!)
  end
end

#read_boolean_array(arr, offset, length) ⇒ Object



103
104
105
106
107
108
109
110
111
# File 'lib/corba/jbase/Streams.rb', line 103

def read_boolean_array(arr, offset, length)
  jarr = Array.new(arr.size).to_java(:boolean)
  begin
    self.stream_.read_boolean_array(jarr, offset, length)
  rescue ::NativeException
    CORBA::Exception.native2r($!)
  end
  arr.fill(offset, length) {|i| jarr[i]}
end

#read_charObject



112
113
114
115
116
117
118
# File 'lib/corba/jbase/Streams.rb', line 112

def read_char()
  begin
    self.stream_.read_char().chr
  rescue ::NativeException
    CORBA::Exception.native2r($!)
  end
end

#read_char_array(arr, offset, length) ⇒ Object



119
120
121
122
123
124
125
126
127
# File 'lib/corba/jbase/Streams.rb', line 119

def read_char_array(arr, offset, length)
  jarr = Array.new(arr.size).to_java(:char)
  begin
    self.stream_.read_char_array(jarr, offset, length)
  rescue ::NativeException
    CORBA::Exception.native2r($!)
  end
  arr.fill(offset, length) {|i| jarr[i].chr }
end

#read_construct(tc) ⇒ Object



327
328
329
330
331
332
333
334
335
# File 'lib/corba/jbase/Streams.rb', line 327

def read_construct(tc)
  begin
    jany = self.stream_.orb().create_any()
    jany.read_value(self.stream_, tc.tc_)
    CORBA::Any.from_java(jany, self.stream_.orb(), tc)
  rescue ::NativeException
    CORBA::Exception.native2r($!)
  end
end

#read_doubleObject



276
277
278
279
280
281
282
# File 'lib/corba/jbase/Streams.rb', line 276

def read_double()
  begin
    self.stream_.read_double()
  rescue ::NativeException
    CORBA::Exception.native2r($!)
  end
end

#read_double_array(arr, offset, length) ⇒ Object



283
284
285
286
287
288
289
290
291
# File 'lib/corba/jbase/Streams.rb', line 283

def read_double_array(arr, offset, length)
  jarr = Array.new(arr.size).to_java(:double)
  begin
    self.stream_.read_double_array(jarr, offset, length)
  rescue ::NativeException
    CORBA::Exception.native2r($!)
  end
  arr.fill(offset, length) {|i| jarr[i] }
end

#read_fixedObject



320
321
322
323
324
325
326
# File 'lib/corba/jbase/Streams.rb', line 320

def read_fixed()
  begin
    java.math.BigDecimal.new(self.stream_.read_fixed().toString())
  rescue ::NativeException
    CORBA::Exception.native2r($!)
  end
end

#read_floatObject



260
261
262
263
264
265
266
# File 'lib/corba/jbase/Streams.rb', line 260

def read_float()
  begin
    self.stream_.read_float()
  rescue ::NativeException
    CORBA::Exception.native2r($!)
  end
end

#read_float_array(arr, offset, length) ⇒ Object



267
268
269
270
271
272
273
274
275
# File 'lib/corba/jbase/Streams.rb', line 267

def read_float_array(arr, offset, length)
  jarr = Array.new(arr.size).to_java(:float)
  begin
    self.stream_.read_float_array(jarr, offset, length)
  rescue ::NativeException
    CORBA::Exception.native2r($!)
  end
  arr.fill(offset, length) {|i| jarr[i] }
end

#read_longObject



194
195
196
197
198
199
200
# File 'lib/corba/jbase/Streams.rb', line 194

def read_long()
  begin
    self.stream_.read_long()
  rescue ::NativeException
    CORBA::Exception.native2r($!)
  end
end

#read_long_array(arr, offset, length) ⇒ Object



201
202
203
204
205
206
207
208
209
# File 'lib/corba/jbase/Streams.rb', line 201

def read_long_array(arr, offset, length)
  jarr = Array.new(arr.size).to_java(:int)
  begin
    self.stream_.read_long_array(jarr, offset, length)
  rescue ::NativeException
    CORBA::Exception.native2r($!)
  end
  arr.fill(offset, length) {|i| jarr[i] }
end

#read_longlongObject



227
228
229
230
231
232
233
# File 'lib/corba/jbase/Streams.rb', line 227

def read_longlong()
  begin
    self.stream_.read_longlong()
  rescue ::NativeException
    CORBA::Exception.native2r($!)
  end
end

#read_longlong_array(arr, offset, length) ⇒ Object



234
235
236
237
238
239
240
241
242
# File 'lib/corba/jbase/Streams.rb', line 234

def read_longlong_array(arr, offset, length)
  jarr = Array.new(arr.size).to_java(:long)
  begin
    self.stream_.read_longlong_array(jarr, offset, length)
  rescue ::NativeException
    CORBA::Exception.native2r($!)
  end
  arr.fill(offset, length) {|i| jarr[i] }
end

#read_member(tc) ⇒ Object



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
# File 'lib/corba/cbase/Streams.rb', line 18

def read_member(tc)
  tc = tc.resolved_tc # takes care of recursive typecodes
  v = case tc.kind
  when TK_ANY
    read_any()
  when TK_BOOLEAN
    read_boolean()
  when TK_SHORT
    read_short()
  when TK_LONG
    read_long()
  when TK_USHORT
    read_ushort()
  when TK_WCHAR
    read_wchar()
  when TK_ULONG
    read_ulong()
  when TK_LONGLONG
    read_longlong()
  when TK_ULONGLONG
    read_ulonglong()
  when TK_OCTET
    read_octet()
  when TK_FLOAT
    read_float()
  when TK_DOUBLE
    read_double()
  when TK_LONGDOUBLE
    raise CORBA::NO_IMPLEMENT.new('LongDouble not supported',0,CORBA::COMPLETED_NO)
  when TK_FIXED
    read_fixed()
  when TK_CHAR
    read_char()
  when TK_STRING
    read_string()
  when TK_WSTRING
    read_wstring()
  when TK_OBJREF
    read_Object()
  when TK_TYPECODE
    read_TypeCode()
  when TK_ARRAY, TK_SEQUENCE,
       TK_ENUM, TK_STRUCT, TK_EXCEPT, TK_UNION,
       TK_PRINCIPAL
    read_construct(tc)
  when TK_ABSTRACT_INTERFACE
    read_Abstract()
  when TK_VALUE, TK_VALUE_BOX, TK_EVENT
    read_Value()
    ## TODO: TK_NATIVE
  end
  v
end

#read_ObjectObject



306
307
308
309
310
311
312
# File 'lib/corba/jbase/Streams.rb', line 306

def read_Object()
  begin
    CORBA::Object._wrap_native(self.stream_().read_Object())
  rescue ::NativeException
    CORBA::Exception.native2r($!)
  end
end

#read_octet(value) ⇒ Object



144
145
146
147
148
149
150
# File 'lib/corba/jbase/Streams.rb', line 144

def read_octet(value)
  begin
    [self.stream_.read_octet()].pack('c').unpack('C').first
  rescue ::NativeException
    CORBA::Exception.native2r($!)
  end
end

#read_octet_array(arr, offset, length) ⇒ Object



151
152
153
154
155
156
157
158
159
160
# File 'lib/corba/jbase/Streams.rb', line 151

def read_octet_array(arr, offset, length)
  jarr = Array.new(arr.size).to_java(:byte)
  begin
    self.stream_.read_octet_array(jarr, offset, length)
  rescue ::NativeException
    CORBA::Exception.native2r($!)
  end
  jarr = jarr.pack('c*').unpack('C*')
  arr.fill(offset, length) {|i| jarr[i] }
end

#read_shortObject



161
162
163
164
165
166
167
# File 'lib/corba/jbase/Streams.rb', line 161

def read_short()
  begin
    self.stream_.read_short()
  rescue ::NativeException
    CORBA::Exception.native2r($!)
  end
end

#read_short_array(arr, offset, length) ⇒ Object



168
169
170
171
172
173
174
175
176
# File 'lib/corba/jbase/Streams.rb', line 168

def read_short_array(arr, offset, length)
  jarr = Array.new(arr.size).to_java(:short)
  begin
    self.stream_.read_short_array(jarr, offset, length)
  rescue ::NativeException
    CORBA::Exception.native2r($!)
  end
  arr.fill(offset, length) {|i| jarr[i] }
end

#read_stringObject



292
293
294
295
296
297
298
# File 'lib/corba/jbase/Streams.rb', line 292

def read_string()
  begin
    self.stream_.read_string()
  rescue ::NativeException
    CORBA::Exception.native2r($!)
  end
end

#read_TypeCodeObject



313
314
315
316
317
318
319
# File 'lib/corba/jbase/Streams.rb', line 313

def read_TypeCode()
  begin
    CORBA::TypeCode._wrap_native(self.stream_().read_TypeCode())
  rescue ::NativeException
    CORBA::Exception.native2r($!)
  end
end

#read_ulongObject



210
211
212
213
214
215
216
# File 'lib/corba/jbase/Streams.rb', line 210

def read_ulong()
  begin
    [self.stream_.read_ulong()].pack('l').unpack('L').first
  rescue ::NativeException
    CORBA::Exception.native2r($!)
  end
end

#read_ulong_array(arr, offset, length) ⇒ Object



217
218
219
220
221
222
223
224
225
226
# File 'lib/corba/jbase/Streams.rb', line 217

def read_ulong_array(arr, offset, length)
  jarr = Array.new(arr.size).to_java(:int)
  begin
    self.stream_.read_ulong_array(jarr, offset, length)
  rescue ::NativeException
    CORBA::Exception.native2r($!)
  end
  jarr = jarr.pack('l*').unpack('L*')
  arr.fill(offset, length) {|i| jarr[i] }
end

#read_ulonglongObject



243
244
245
246
247
248
249
# File 'lib/corba/jbase/Streams.rb', line 243

def read_ulonglong()
  begin
    [self.stream_.read_ulonglong()].pack('q').unpack('Q').first
  rescue ::NativeException
    CORBA::Exception.native2r($!)
  end
end

#read_ulonglong_array(arr, offset, length) ⇒ Object



250
251
252
253
254
255
256
257
258
259
# File 'lib/corba/jbase/Streams.rb', line 250

def read_ulonglong_array(arr, offset, length)
  jarr = Array.new(arr.size).to_java(:long)
  begin
    self.stream_.read_ulonglong_array(jarr, offset, length)
  rescue ::NativeException
    CORBA::Exception.native2r($!)
  end
  jarr = jarr.pack('q*').unpack('Q*')
  arr.fill(offset, length) {|i| jarr[i] }
end

#read_ushortObject



177
178
179
180
181
182
183
# File 'lib/corba/jbase/Streams.rb', line 177

def read_ushort()
  begin
    [self.stream_.read_ushort()].pack('s').unpack('S').first
  rescue ::NativeException
    CORBA::Exception.native2r($!)
  end
end

#read_ushort_array(arr, offset, length) ⇒ Object



184
185
186
187
188
189
190
191
192
193
# File 'lib/corba/jbase/Streams.rb', line 184

def read_ushort_array(arr, offset, length)
  jarr = Array.new(arr.size).to_java(:short)
  begin
    self.stream_.read_octet_array(jarr, offset, length)
  rescue ::NativeException
    CORBA::Exception.native2r($!)
  end
  jarr = jarr.pack('s*').unpack('S*')
  arr.fill(offset, length) {|i| jarr[i] }
end

#read_valueObject Also known as: read_Value



345
346
347
348
349
350
351
# File 'lib/corba/jbase/Streams.rb', line 345

def read_value()
  begin
    self.stream_.read_value()
  rescue ::NativeException
    CORBA::Exception.native2r($!)
  end
end

#read_valuebox(boxedvalue_helper) ⇒ Object



353
354
355
356
357
358
359
# File 'lib/corba/jbase/Streams.rb', line 353

def read_valuebox(boxedvalue_helper)
  begin
    self.stream_.read_value(boxedvalue_helper)
  rescue ::NativeException
    CORBA::Exception.native2r($!)
  end
end

#read_wcharObject



128
129
130
131
132
133
134
# File 'lib/corba/jbase/Streams.rb', line 128

def read_wchar()
  begin
    self.stream_.read_wchar()
  rescue ::NativeException
    CORBA::Exception.native2r($!)
  end
end

#read_wchar_array(arr, offset, length) ⇒ Object



135
136
137
138
139
140
141
142
143
# File 'lib/corba/jbase/Streams.rb', line 135

def read_wchar_array(arr, offset, length)
  jarr = Array.new(arr.size).to_java(:char)
  begin
    self.stream_.read_char_array(jarr, offset, length)
  rescue ::NativeException
    CORBA::Exception.native2r($!)
  end
  arr.fill(offset, length) {|i| jarr[i] }
end

#read_wstringObject



299
300
301
302
303
304
305
# File 'lib/corba/jbase/Streams.rb', line 299

def read_wstring()
  begin
    self.stream_.read_wstring()
  rescue ::NativeException
    CORBA::Exception.native2r($!)
  end
end