CORBA/Object.pm untested

filter: Statementstmt 0.0% 0 / 58 Branchbran 0.0% 0 / 14 Conditioncond 0.0% 0 / 6 MC/DCmcdc 0.0% 0 / 3 Subroutinesub 0.0% 0 / 12 Podpod 0.0% 0 / 6 totaltotal 0.0% 0 / 99 CC 8 SCAR 25.8
CC
8
Cov
0%
_attribute
30.0
_new_from_ior
20.0
_nil
2.0
CRAP 13.2
1 # $Id: Object.pm,v 1.4 1997/06/19 14:34:40 schuller Exp $
2 # Copyright (c) 1997 Lunatech Research / Bart Schuller <schuller@lunatech.com>
3 # See the file "Artistic" in the distribution for licensing and
4 # (lack of) warranties.
5  
6 use strict;
7  
8 package CORBA::Object;
9 use COPE::GIOP;
10 use COPE::IOP;
11 use IO::Socket;
12 require COPE::CORBA::BOA;
13 require COPE::CORBA::Request;
14  
15 $CORBA::Object::_tc = CORBA::TypeCode::_create_interface_tc('IDL:omg.org/CORBA/Object:1.0', 'Object');
16  
17 sub _nil {
18 return 0;
19 }
20  
21 sub _new_from_ior {
22 my($class, $ior, $orb) = @_;
23 if (!defined $orb) {
24 $orb = $CORBA::ORB::_The_Orb;
25 }
26 my $profile;
27 foreach (@{$ior->{profiles}}) {
28 if ($_->{tag} == 0) {
29 $profile = $_->{profile_data};
30 }
31 }
32 my $object = {_ior => $ior};
33 if (defined $profile) {
34 my $byte_order = unpack('C', substr($profile, 0, 1));
35 my $index = 1;
36 my $profilebody = IIOP::ProfileBody::_unmarshal(\$profile, \$index, $byte_order);
37 $object->{orb} = $orb;
38 @$object{qw(host port object_key)} = @$profilebody{qw(host port object_key)};
39 }
40 return bless $object, $class;
41 }
42  
43 sub _narrow ($$) {
44 my($class,$self) = @_;
45 bless $self, $class;
46 return $self;
47 }
48  
49 sub is_nil {
50 my($self) = @_;
51 return !($self && ref($self) && exists($self->{host}));
52 }
53  
54 sub create_request {
55 my $self = shift;
56 my $request = {@_};
57 @$request{qw(orb host port object_key)} = @$self{qw(orb host port object_key)};
58 return bless $request, 'CORBA::Request';
59 }
60  
61 sub _attribute {
62 my($self,$name,$type,$arg) = @_;
63 my $result_ = { _type => defined $arg ? $CORBA::_tc_void : $type };
64 my $arg_list = [];
65 if (defined $arg) {
66 push @$arg_list,
67 { 'argument' =>
68 { _type => $type, _value => $arg },
69 'arg_modes' => 0,
70 };
71 }
72 my $opname = defined $arg ? '_set_' : '_get_';
73 $opname .= $name;
74 my $request_ = $self->create_request(
75 'operation' => $opname,
76 'arg_list' => $arg_list,
77 'result' => $result_,
78 );
79 $request_->invoke(0);
80 if (!defined $arg) {
81 return $result_->{_value};
82 }
83 }
84  
85 1;
86