Module: R2CORBA::CORBA::Portable::OutputStream

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

Constant Summary collapse

@@wrapper_klass =
Class.new do
  include CORBA::Portable::OutputStream
  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



371
372
373
374
375
376
# File 'lib/corba/jbase/Streams.rb', line 371

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

Instance Method Details

#write_Abstract(value) ⇒ Object



646
647
648
649
650
651
652
# File 'lib/corba/jbase/Streams.rb', line 646

def write_Abstract(value)
  begin
    self.stream_().write_abstract_interface(value.is_a?(CORBA::Object) ? value.objref_ : value)
  rescue ::NativeException
    CORBA::Exception.native2r($!)
  end
end

#write_any(value) ⇒ Object



433
434
435
436
437
438
439
# File 'lib/corba/jbase/Streams.rb', line 433

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

#write_boolean(value) ⇒ Object



440
441
442
443
444
445
446
# File 'lib/corba/jbase/Streams.rb', line 440

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

#write_boolean_array(value, offset, length) ⇒ Object



447
448
449
450
451
452
453
# File 'lib/corba/jbase/Streams.rb', line 447

def write_boolean_array(value, offset, length)
  begin
    self.stream_.write_boolean_array(value.to_java(:boolean), offset, length)
  rescue ::NativeException
    CORBA::Exception.native2r($!)
  end
end

#write_char(value) ⇒ Object



454
455
456
457
458
459
460
# File 'lib/corba/jbase/Streams.rb', line 454

def write_char(value)
  begin
    self.stream_.write_char(value[0])
  rescue ::NativeException
    CORBA::Exception.native2r($!)
  end
end

#write_char_array(value, offset, length) ⇒ Object



461
462
463
464
465
466
467
# File 'lib/corba/jbase/Streams.rb', line 461

def write_char_array(value, offset, length)
  begin
    self.stream_.write_char_array(value.collect{|c| c[0]}.to_java(:char), offset, length)
  rescue ::NativeException
    CORBA::Exception.native2r($!)
  end
end

#write_construct(value, tc) ⇒ Object



639
640
641
642
643
644
645
# File 'lib/corba/jbase/Streams.rb', line 639

def write_construct(value, tc)
  begin
    CORBA::Any.to_any(value, tc).to_java(self.stream_().orb()).write_value(self.stream_)
  rescue ::NativeException
    CORBA::Exception.native2r($!)
  end
end

#write_double(value) ⇒ Object



590
591
592
593
594
595
596
# File 'lib/corba/jbase/Streams.rb', line 590

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

#write_double_array(value, offset, length) ⇒ Object



597
598
599
600
601
602
603
# File 'lib/corba/jbase/Streams.rb', line 597

def write_double_array(value, offset, length)
  begin
    self.stream_.write_double_array(value.to_java(:double), offset, length)
  rescue ::NativeException
    CORBA::Exception.native2r($!)
  end
end

#write_fixed(value) ⇒ Object



618
619
620
621
622
623
624
# File 'lib/corba/jbase/Streams.rb', line 618

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

#write_float(value) ⇒ Object



576
577
578
579
580
581
582
# File 'lib/corba/jbase/Streams.rb', line 576

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

#write_float_array(value, offset, length) ⇒ Object



583
584
585
586
587
588
589
# File 'lib/corba/jbase/Streams.rb', line 583

def write_float_array(value, offset, length)
  begin
    self.stream_.write_float_array(value.to_java(:float), offset, length)
  rescue ::NativeException
    CORBA::Exception.native2r($!)
  end
end

#write_long(value) ⇒ Object



520
521
522
523
524
525
526
# File 'lib/corba/jbase/Streams.rb', line 520

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

#write_long_array(value, offset, length) ⇒ Object



527
528
529
530
531
532
533
# File 'lib/corba/jbase/Streams.rb', line 527

def write_long_array(value, offset, length)
  begin
    self.stream_.write_long_array(value.to_java(:int), offset, length)
  rescue ::NativeException
    CORBA::Exception.native2r($!)
  end
end

#write_longlong(value) ⇒ Object



548
549
550
551
552
553
554
# File 'lib/corba/jbase/Streams.rb', line 548

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

#write_longlong_array(value, offset, length) ⇒ Object



555
556
557
558
559
560
561
# File 'lib/corba/jbase/Streams.rb', line 555

def write_longlong_array(value, offset, length)
  begin
    self.stream_.write_longlong_array(value.to_java(:long), offset, length)
  rescue ::NativeException
    CORBA::Exception.native2r($!)
  end
end

#write_member(tc, value) ⇒ Object



74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
# File 'lib/corba/cbase/Streams.rb', line 74

def write_member(tc, value)
  tc = tc.resolved_tc # takes care of recursive typecodes
  case tc.kind
  when TK_ANY
    write_any(value)
  when TK_BOOLEAN
    write_boolean(value)
  when TK_SHORT
    write_short(value)
  when TK_LONG
    write_long(value)
  when TK_USHORT
    write_ushort(value)
  when TK_WCHAR
    write_wchar(value)
  when TK_ULONG
    write_ulong(value)
  when TK_LONGLONG
    write_longlong(value)
  when TK_ULONGLONG
    write_ulonglong(value)
  when TK_OCTET
    write_octet(value)
  when TK_FLOAT
    write_float(value)
  when TK_DOUBLE
    write_double(value)
  when TK_LONGDOUBLE
    raise CORBA::NO_IMPLEMENT.new('LongDouble not supported',0,CORBA::COMPLETED_NO)
  when TK_FIXED
    write_fixed(value)
  when TK_CHAR
    write_char(value)
  when TK_STRING
    write_string(value)
  when TK_WSTRING
    write_wstring(value)
  when TK_OBJREF
    write_Object(value)
  when TK_TYPECODE
    write_TypeCode(value)
  when TK_ARRAY, TK_SEQUENCE,
       TK_ENUM, TK_STRUCT, TK_EXCEPT, TK_UNION,
       TK_PRINCIPAL
    write_construct(value, tc)
  when TK_ABSTRACT_INTERFACE
    write_Abstract(value)
  when TK_VALUE, TK_VALUE_BOX, TK_EVENT
    write_Value(value)
    ## TODO: TK_NATIVE
  end
end

#write_Object(value) ⇒ Object



625
626
627
628
629
630
631
# File 'lib/corba/jbase/Streams.rb', line 625

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

#write_octet(value) ⇒ Object



478
479
480
481
482
483
484
# File 'lib/corba/jbase/Streams.rb', line 478

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

#write_octet_array(value, offset, length) ⇒ Object



485
486
487
488
489
490
491
# File 'lib/corba/jbase/Streams.rb', line 485

def write_octet_array(value, offset, length)
  begin
    self.stream_.write_octet_array(value.pack('C*').unpack('c*').to_java(:byte), offset, length)
  rescue ::NativeException
    CORBA::Exception.native2r($!)
  end
end

#write_short(value) ⇒ Object



492
493
494
495
496
497
498
# File 'lib/corba/jbase/Streams.rb', line 492

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

#write_short_array(value, offset, length) ⇒ Object



499
500
501
502
503
504
505
# File 'lib/corba/jbase/Streams.rb', line 499

def write_short_array(value, offset, length)
  begin
    self.stream_.write_short_array(value.to_java(:short), offset, length)
  rescue ::NativeException
    CORBA::Exception.native2r($!)
  end
end

#write_string(value) ⇒ Object



604
605
606
607
608
609
610
# File 'lib/corba/jbase/Streams.rb', line 604

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

#write_TypeCode(value) ⇒ Object



632
633
634
635
636
637
638
# File 'lib/corba/jbase/Streams.rb', line 632

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

#write_ulong(value) ⇒ Object



534
535
536
537
538
539
540
# File 'lib/corba/jbase/Streams.rb', line 534

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

#write_ulong_array(value, offset, length) ⇒ Object



541
542
543
544
545
546
547
# File 'lib/corba/jbase/Streams.rb', line 541

def write_ulong_array(value, offset, length)
  begin
    self.stream_.write_ulong_array(value.pack('L*').unpack('l*').to_java(:int), offset, length)
  rescue ::NativeException
    CORBA::Exception.native2r($!)
  end
end

#write_ulonglong(value) ⇒ Object



562
563
564
565
566
567
568
# File 'lib/corba/jbase/Streams.rb', line 562

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

#write_ulonglong_array(value, offset, length) ⇒ Object



569
570
571
572
573
574
575
# File 'lib/corba/jbase/Streams.rb', line 569

def write_ulonglong_array(value, offset, length)
  begin
    self.stream_.write_ulonglong_array(value.pack('Q*').unpack('q*').to_java(:long), offset, length)
  rescue ::NativeException
    CORBA::Exception.native2r($!)
  end
end

#write_ushort(value) ⇒ Object



506
507
508
509
510
511
512
# File 'lib/corba/jbase/Streams.rb', line 506

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

#write_ushort_array(value, offset, length) ⇒ Object



513
514
515
516
517
518
519
# File 'lib/corba/jbase/Streams.rb', line 513

def write_ushort_array(value, offset, length)
  begin
    self.stream_.write_ushort_array(value.pack('S*').unpack('s*').to_java(:short), offset, length)
  rescue ::NativeException
    CORBA::Exception.native2r($!)
  end
end

#write_value(value) ⇒ Object Also known as: write_Value



653
654
655
656
657
658
659
# File 'lib/corba/jbase/Streams.rb', line 653

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

#write_valuebox(value, boxedvalue_helper) ⇒ Object



661
662
663
664
665
666
667
# File 'lib/corba/jbase/Streams.rb', line 661

def write_valuebox(value, boxedvalue_helper)
  begin
    self.stream_.write_value(value, boxedvalue_helper)
  rescue ::NativeException
    CORBA::Exception.native2r($!)
  end
end

#write_wchar(value) ⇒ Object



468
469
470
# File 'lib/corba/jbase/Streams.rb', line 468

def write_wchar(value)
  self.stream_.write_wchar(value)
end

#write_wchar_array(value, offset, length) ⇒ Object



471
472
473
474
475
476
477
# File 'lib/corba/jbase/Streams.rb', line 471

def write_wchar_array(value, offset, length)
  begin
    self.stream_.write_wchar_array(value.to_java(:char), offset, length)
  rescue ::NativeException
    CORBA::Exception.native2r($!)
  end
end

#write_wstring(value) ⇒ Object



611
612
613
614
615
616
617
# File 'lib/corba/jbase/Streams.rb', line 611

def write_wstring(value)
  begin
    self.stream_.write_wstring(value.inject('') {|s,b| s << b.chr})
  rescue ::NativeException
    CORBA::Exception.native2r($!)
  end
end