-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathclient
More file actions
executable file
·119 lines (90 loc) · 2.86 KB
/
client
File metadata and controls
executable file
·119 lines (90 loc) · 2.86 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
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
71
72
73
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
#!/usr/bin/perl -w
use CORBA::ORBit idl => [ qw(Account.idl) ];
use Error qw(:try);
use strict;
# CORBA::ORBit::debug_wait;
# open IOR, "/home/otaylor/devel/corba-mico-nofixed/ir.ref";
# my $ior = <IOR>;
# close IOR;
# unshift @ARGV, "--ORBIfaceRepoIOR" => $ior;
my $orb = CORBA::ORB_init("orbit-local-orb");
open IOR, "account.ref";
my $ior = <IOR>;
close IOR;
my $account = $orb->string_to_object($ior);
if (!$account->_is_a ("IDL:Account/BaseAccount:1.0")) {
die ("Account isn't a BaseAccount!");
}
for (my $i=0;$i<0;$i++) {
$account->deposit( 1 );
}
$account->deposit( 100 );
$account->deposit( 100 );
$account->deposit( 100 );
$account->deposit( 100 );
$account->deposit( 100 / 3);
$account->withdraw( 240 );
$account->withdraw( 10 );
print "Balance is ".$account->balance."\n";
my $prefs = $account->_get_prefs;
print "Favorite color is ",$prefs->{favorite_color},"\n";
print "Lottery numbers are ",
join(" ", @{$prefs->{lottery_numbers}}),"\n";
print "Nickname is ",$prefs->{nickname},"\n";
$account->set_pref ( [ 'pt_color', 'chartreuse', ] );
$account->set_pref ( [ 'pt_nickname', 'Grumpy', ] );
$account->_set_appearance ( [ map { [ split // ] } split /\n/, <<'FACE' ] );
/****\
; ;
[ O O ]
l \ l
; -- ;
;;;;
FACE
for (@{$account->_get_appearance}) {
print join("",@$_),"\n";
}
print "Favorite color is now ",$account->get_pref('pt_color')->[1],"\n";
print "As an any: favorite color is now ",
$account->get_pref_any('pt_color')->value,"\n";
print "As an any: nickname is now ",
$account->get_pref_any('pt_nickname')->value,"\n";
#
# Test LongLong marshalling
#
sub commify # I forget how to do this more efficiently and simply :-)
{
my $str = shift;
$str =~ s/(\d)(?=(?:\d\d\d)+(?:$|\D))/$1,/g;
$str;
}
my $amount = '1000000000000';
my $double_amount = '2000000000000';
my $test_amount = $account->add ($amount, $amount);
printf "2 * %s pennies = %s pennies\n",
commify($amount), commify($test_amount);
if ("$test_amount" ne "$double_amount") {
die "Incorrect result from addition call!\n";
}
print "Withdrawing \$100,000\n";
try {
$account->withdraw (100_000);
} catch Account::Account::InsufficientFunds with {
my $e = shift;
print STDERR "Oops. I don't have that much money\n";
print STDERR " (I need $e->{overdraft} more)\n";
};
my $counter = $account->counter();
$counter = $account->echo_object ($counter);
print join(" ", map { $counter->next } (1..10)), "\n";
$counter->destroy();
try {
$counter->next;
} catch CORBA::Exception with {
print "Caught $_[0], while counting with a destroyed counter\n";
};
# Try getting some typecodes
my $tc1 = new CORBA::TypeCode "IDL:Account/Account/Preferences:1.0";
my $tc2 = new CORBA::TypeCode "IDL:Account/Amounts:1.0";
my $tc3 = new CORBA::TypeCode "IDL:omg.org/CORBA/Double:1.0";
print "Successful completion\n"