2 #include "interop_wchar_i.h"
4 // Implementation skeleton constructor
5 interop_WChar_Passer_i::interop_WChar_Passer_i (CORBA::ORB_ptr o
,
7 : orb_(CORBA::ORB::_duplicate (o
)),
12 // Implementation skeleton destructor
13 interop_WChar_Passer_i::~interop_WChar_Passer_i ()
18 interop_WChar_Passer_i::orb_name ()
20 return CORBA::string_dup ("TAO");
24 interop_WChar_Passer_i::wchar_to_server (CORBA::WChar test
,
27 return ref_
.match_wchar (key
,test
);
31 interop_WChar_Passer_i::wchar_from_server (CORBA::Short key
)
33 return ref_
.get_wchar (key
);
37 interop_WChar_Passer_i::wstring_to_server (const CORBA::WChar
* test
,
40 return ref_
.match_wstring(key
,test
);
44 interop_WChar_Passer_i::wstring_from_server (CORBA::Short key
)
46 return CORBA::wstring_dup (ref_
.get_wstring(key
));
50 interop_WChar_Passer_i::warray_to_server (const interop::warray test
,
53 return ref_
.match_warray(key
,test
);
56 interop::warray_slice
*
57 interop_WChar_Passer_i::warray_from_server (CORBA::Short key
)
59 return interop::warray_dup (ref_
.get_warray(key
));
63 interop_WChar_Passer_i::wstruct_to_server (const interop::wstruct
& test
,
67 ref_
.match_wchar (key
,test
.st_char
) &&
68 ref_
.match_wstring (key
,test
.st_string
) &&
69 ref_
.match_warray (key
,test
.st_array
) &&
70 this->any_to_server (test
.st_any
,key
);
74 interop_WChar_Passer_i::wstruct_from_server (CORBA::Short key
)
76 interop::wstruct_var ws
= new interop::wstruct ();
77 ws
->st_char
= this->wchar_from_server(key
);
78 ws
->st_string
= this->wstring_from_server(key
);
79 ref_
.assign_warray (key
, ws
->st_array
);
80 ws
->st_any
<<= ref_
.get_wstring(key
);
85 interop_WChar_Passer_i::wstructseq_to_server (const interop::wstructseq
& test
,
88 CORBA::Boolean result
= 1;
89 for (CORBA::ULong i
= 0; result
&& i
< test
.length(); i
++)
91 result
= this->wstruct_to_server(test
[i
], key
);
97 interop_WChar_Passer_i::wstructseq_from_server (CORBA::Short key
)
99 interop::wstructseq_var wsListI
= new interop::wstructseq();
102 for (CORBA::ULong i
= 0; i
< wsListI
->length(); i
++)
104 wsListI
[i
].st_char
= this->wchar_from_server(key
);
105 wsListI
[i
].st_string
= this->wstring_from_server(key
);
106 ref_
.assign_warray (key
, wsListI
[i
].st_array
);
107 // this is to keep Cxx on TRUE64 happy
108 // it won't cast a wide character literal (i.e. L"")
109 // to a CORBA::WChar *. +
110 // {I wonder if sizeof(wchar_t) != sizeof (CORBA::WChar)?}
111 const CORBA::WChar empty_wstring
[] = {0};
112 wsListI
[i
].st_any
<<= CORBA::wstring_dup(empty_wstring
);
114 return wsListI
._retn();
118 interop_WChar_Passer_i::wunion_to_server (const interop::wunion
& test
,
122 case interop::is_wchar
:
123 return this->wchar_to_server (test
.u_char(),key
);
124 case interop::is_wstring
:
125 return this->wstring_to_server (test
.u_string(),key
);
126 case interop::is_warray
:
127 return this->warray_to_server (test
.u_array(),key
);
135 interop_WChar_Passer_i::wunion_from_server (CORBA::Short key
,
136 interop::wchar_types type
)
138 interop::wunion
*wu
= new interop::wunion ();
140 case interop::is_wchar
:
141 wu
->u_char (ref_
.get_wchar(key
));
143 case interop::is_wstring
:
144 wu
->u_string (ref_
.get_wstring(key
));
146 case interop::is_warray
:
147 wu
->u_array (ref_
.get_warray(key
));
155 interop_WChar_Passer_i::any_to_server (const CORBA::Any
&test
,
159 const CORBA::WChar
*ws
;
160 CORBA::WString_var wstr
;
161 interop::warray_forany forany
;
163 if (test
>>= CORBA::Any::to_wchar(wc
))
165 return this->wchar_to_server(wc
,key
);
167 else if (test
>>= ws
)
169 return this->wstring_to_server (ws
,key
);
171 else if (test
>>= forany
)
173 return this->warray_to_server (forany
.in(),key
);
179 interop_WChar_Passer_i::any_from_server (CORBA::Short key
,
180 interop::wchar_types type
)
182 CORBA::Any
*any
= new CORBA::Any
;
184 case interop::is_wchar
:
185 (*any
) <<= CORBA::Any::from_wchar(ref_
.get_wchar(key
));
187 case interop::is_wstring
:
188 (*any
) <<= ref_
.get_wstring(key
);
190 case interop::is_warray
:
192 interop::warray_forany
forany(ref_
.get_warray(key
));
193 (*any
) <<= forany
.in();
201 interop_WChar_Passer_i::any_echo (const CORBA::Any
&test
)
203 return new CORBA::Any (test
);
207 interop_WChar_Passer_i::exception_test ( CORBA::Short key
)
209 throw interop::WChar_Passer::WStringException(ref_
.get_except(key
),
210 this->wchar_from_server(key
));
214 interop_WChar_Passer_i::shutdown ()
216 this->orb_
->shutdown(0);