summaryrefslogtreecommitdiff
path: root/TAO/IIOP/tests/Cubit/TAO/cubitC.cpp
blob: 99416520c15a70778daf1fd891558cef7b8fea1b (plain)
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
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
// @(#)cubitC.cpp	05/14/97
// Copyright 1994-1995 by Sun Microsystems Inc.
// All Rights Reserved
//
// Modified version of Cubit Example written by Sun Microsystems Inc.
// Modified by: Brian Mendel

#include	"cubitC.h"		// for stubs ...

Cubit_ptr Cubit::_duplicate(Cubit_ptr obj)
{
   if (obj)
      obj->AddRef();

   return obj;
}

Cubit_ptr Cubit::_narrow(CORBA_Object_ptr obj)
{
   CORBA_Environment env;
   if (obj->_is_a("IDL:Cubit:1.0", env))
   {
      STUB_Object *istub;
      if (obj->QueryInterface(IID_STUB_Object, (void **)&istub) != NOERROR)
      {
         return Cubit::_nil();
      }
      Cubit_ptr new_obj = new Cubit(istub);
      return Cubit::_duplicate(new_obj);
   }
   return Cubit::_nil();
}

Cubit_ptr Cubit::_nil()
{
   return (Cubit_ptr)NULL;
}

//
// CUBE OCTET
//

static const TAO_Param_Data Cubit_cube_octet_params [] = 
{
   { _tc_CORBA_Octet, PARAM_RETURN, 0 },
   { _tc_CORBA_Octet, PARAM_IN, 0 }
};
    

static const TAO_Call_Data Cubit_cube_octet_calldata = 
{
   "cube_octet", CORBA_B_TRUE,
      2, &Cubit_cube_octet_params [0],
      0, 0
};


CORBA_Octet
Cubit::Cubit_cube_octet (CORBA_Octet       o, 
                  CORBA_Environment &env)
{
   CORBA_Octet		retval;

   STUB_Object *istub;
   if (this->QueryInterface(IID_STUB_Object, (void **)&istub) != NOERROR)
   {
      env.exception(new CORBA_DATA_CONVERSION (COMPLETED_NO));
      return 0;
   }

   istub->do_call (env, &Cubit_cube_octet_calldata,
                        &retval, &o);
   istub->Release ();

   return retval;
}


//
// CUBE SHORT
//

static const TAO_Param_Data Cubit_cube_short_params [] = 
{
   { _tc_CORBA_Short, PARAM_RETURN, 0 },
   { _tc_CORBA_Short, PARAM_IN, 0 }
};

static const TAO_Call_Data Cubit_cube_short_calldata = 
{
   "cube_short", CORBA_B_TRUE,
      2, &Cubit_cube_short_params [0],
      0, 0
};


CORBA_Short
Cubit::Cubit_cube_short (CORBA_Short       s,
                  CORBA_Environment &env)
{
   CORBA_Short		retval;

   STUB_Object *istub;
   if (this->QueryInterface(IID_STUB_Object, (void **)&istub) != NOERROR)
   {
      env.exception(new CORBA_DATA_CONVERSION (COMPLETED_NO));
      return 0;
   }

   istub->do_call(env, &Cubit_cube_short_calldata,
                  &retval, &s);
   
   istub->Release ();
   
   return retval;
}

//
// CUBE LONG
//

static const TAO_Param_Data Cubit_cube_long_params [] = 
{
   { _tc_CORBA_Long, PARAM_RETURN, 0 },
   { _tc_CORBA_Long, PARAM_IN, 0 }
};

static const TAO_Call_Data Cubit_cube_long_calldata = 
{
   "cube_long", CORBA_B_TRUE,
      2, &Cubit_cube_long_params [0],
      0, 0
};


CORBA_Long
Cubit::Cubit_cube_long (CORBA_Long        l,
                 CORBA_Environment &env)
{
   CORBA_Long		retval;
   
   STUB_Object *istub;
   if (this->QueryInterface(IID_STUB_Object, (void **)&istub) != NOERROR)
   {
      env.exception(new CORBA_DATA_CONVERSION (COMPLETED_NO));
      return 0;
   }
   
   istub->do_call (env, &Cubit_cube_long_calldata,
                  &retval, &l);
   istub->Release ();
   
   return retval;
}


//
// Encapsulated parameters for struct "Cubit_Many" typecode.
// None of these parameters is complicated, so this is just
// a linear sequence of element encodings
//
// NOTE:  it's important that this be longword aligned!!
//
static const CORBA_Long _oc_Cubit_Many [] = 
{
   1,          // byte order flag (TRICKY!)
      
   1, 0,       // empty string:  repository/type ID
   1, 0,       // empty string:  struct name
      
   3,          // three struct elements
      
   // First structure element:  name, typecode for Octet
   1, 0,       // empty string:  name "o"
   tk_octet,
      
   // Second structure element:  name, typecode for Long
   1, 0,       // empty string:  name "l"
   tk_long,
      
   // Third structure element:  name, typecode for Short
   1, 0,       // empty string:  name "s"
   tk_short,
};

static CORBA_TypeCode _tc_Cubit_Many (tk_struct,
                                      sizeof _oc_Cubit_Many, (unsigned char *) &_oc_Cubit_Many,
                                      CORBA_B_FALSE);
CORBA_TypeCode_ptr TC_Cubit_Many = &_tc_Cubit_Many;


//
// CUBE STRUCT
//

static const TAO_Param_Data Cubit_cube_struct_params [] = 
{
   { &_tc_Cubit_Many, PARAM_RETURN, sizeof (Cubit_Many) },
   { &_tc_Cubit_Many, PARAM_IN, 0 }
};

static const TAO_Call_Data Cubit_cube_struct_calldata = 
{
   "cube_struct", CORBA_B_TRUE,
      2, &Cubit_cube_struct_params [0],
      0, 0
};

Cubit_Many*
Cubit::Cubit_cube_struct (Cubit_Many &values,
                          CORBA_Environment &env)
{
   Cubit_Many		*retval;

   STUB_Object *istub;
   if (this->QueryInterface(IID_STUB_Object, (void **)&istub) != NOERROR)
   {
      env.exception(new CORBA_DATA_CONVERSION (COMPLETED_NO));
      return 0;
   }
  
   istub->do_call (env, &Cubit_cube_struct_calldata,
                        &retval, &values);
   istub->Release ();
   
   return retval;
}


//
// CUBE UNION
//

//
// NOTE:  not all union typecodes can be encoded as an array
// of "long "values, but this one can.  Ones with discriminants
// that are one or two bytes long can't easily be coded portably. 
//
// The benefit of doing it as an array of "long" values is
// twofold:  (a) easier to read; (b) on most systems it's then
// adequately aligned for the typecode interpreter to use, so
// no additional runtime copy needs to be made.
//
static const CORBA_Long _oc_Cubit_oneof [] = 
{
   1,          // byte order flag (TRICKY)
   1, 0,       // omitted repository/type ID
   1, 0,       // omitted struct name, "oneof"
   
   //
   // discriminant typecode:
   //
   tk_enum,    // tk_enum
   72,         // encapsulation length
   
   1,          // byte order flag (TRICKY)
   1, 0,       // omitted repository/type ID
   1, 0,       // omitted enum name, "discrim"
   6,          // 5 elements in the enum
   
   1, 0,       // omitted member name, "e_0th"
   1, 0,       // omitted member name, "e_1st"
   1, 0,       // omitted member name, "e_2nd"
   1, 0,       // omitted member name, "e_3rd" 
   1, 0,       // omitted member name, "e_4th" 
   1, 0,       // omitted member name, "e_5th" 
   
   4,       	// default member index (zero based)
   5,       	// number of union members
   
   // the 1st union branch arm
   e_0th,       // member label value
   1, 0,        // omitted member name, "o"
   tk_octet,    // member typecode
   
   // the 2nd union branch arm
   e_1st,      // member label value
   1, 0,       // omitted member name, "s"
   tk_short,   // member typecode
   
   // the 3rd union branch arm
   e_2nd,      // member label value
   1, 0,       // omitted member name, "l"
   tk_long,    // member typecode
   
   // the 4th union branch arm
   e_3rd,      // member label value
   1, 0,       // omitted member name, "cm"
   
   // the 4th union member typecode
   tk_struct,  // tk_struct
   60,         // encap length
   
   1,          // byte order flag (TRICKY)
   1, 0,       // omitted repository/type ID
   1, 0,       // omitted struct name, "Many"
   3,          // three struct members
   
   // First structure element
   1, 0,       // omitted member name, "o"
   tk_octet,   // member type, tk_octet
   
   // Second structure element
   1, 0,       // omitted member name, "l"
   tk_long,    // member type, tk_long
   
   // Third structure element
   1, 0,       // omitted member name, "s"
   tk_short,   // member type, tk_short
   
   // the 5th union branch arm
   4,          // the 5th member label value
   1, 0,       // omitted member name, "cm"
   ~0,         // indirected typecode (~0)
   -84         // offset to struct "Many" typecode
};

static CORBA_TypeCode _tc_Cubit_oneof (tk_union,
                                       (sizeof _oc_Cubit_oneof), (unsigned char *) &_oc_Cubit_oneof,
                                       CORBA_B_FALSE);
CORBA_TypeCode_ptr TC_Cubit_oneof = &_tc_Cubit_oneof;

static const TAO_Param_Data Cubit_cube_union_params [] = 
{
   { &_tc_Cubit_oneof, PARAM_RETURN, sizeof (Cubit_oneof) },
   { &_tc_Cubit_oneof, PARAM_IN, 0 }
};

static const TAO_Call_Data Cubit_cube_union_calldata = 
{
   "cube_union", CORBA_B_TRUE,
      2, &Cubit_cube_union_params [0],
      0, 0
};

Cubit_oneof*
Cubit::Cubit_cube_union (Cubit_oneof		&values,
                  CORBA_Environment	&env)
{
   Cubit_oneof		*retval;

   STUB_Object *istub;
   if (this->QueryInterface(IID_STUB_Object, (void **)&istub) != NOERROR)
   {
      env.exception(new CORBA_DATA_CONVERSION (COMPLETED_NO));
      return 0;
   }

   istub->do_call (env, &Cubit_cube_union_calldata,
                  &retval, &values);
   istub->Release ();
   
   return retval;
}



//
// PLEASE EXIT
//

static const TAO_Call_Data Cubit_please_exit_calldata = 
{
   "please_exit", CORBA_B_FALSE,
      0, 0,
      0, 0
};

void
Cubit::Cubit_please_exit (CORBA_Environment	&env)
{
   STUB_Object *istub;
   if (this->QueryInterface(IID_STUB_Object, (void **)&istub) != NOERROR)
   {
      env.exception(new CORBA_DATA_CONVERSION (COMPLETED_NO));
      return;
   }

   istub->do_call (env, &Cubit_please_exit_calldata);
   istub->Release ();
}