source: trunk/ORBit2-2.14.0/test/everything/structServer.c

Last change on this file was 92, checked in by cinc, 19 years ago

Orbit2 modified for use with NOM

File size: 5.0 KB
Line 
1/*
2 * CORBA C language mapping tests
3 *
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License as published by the
6 * Free Software Foundation; either version 2, or (at your option) any
7 * later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software Foundation,
16 * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17 *
18 * Author: Phil Dawes <philipd@users.sourceforge.net>
19 */
20
21
22#include "everything.h"
23#include "constants.h"
24#include <stdio.h>
25
26static test_FixedLengthStruct
27StructServer_opFixed (PortableServer_Servant servant,
28 const test_FixedLengthStruct *inArg,
29 test_FixedLengthStruct *inoutArg,
30 test_FixedLengthStruct *outArg,
31 CORBA_Environment *ev)
32{
33 test_FixedLengthStruct retval;
34 g_assert (inArg->a == constants_SHORT_IN);
35 g_assert (inoutArg->a == constants_SHORT_INOUT_IN);
36
37 inoutArg->a = constants_SHORT_INOUT_OUT;
38 outArg->a = constants_SHORT_OUT;
39 retval.a = constants_SHORT_RETN;
40
41 return retval;
42}
43
44
45
46static test_VariableLengthStruct*
47StructServer_opVariable (PortableServer_Servant servant,
48 const test_VariableLengthStruct *inArg,
49 test_VariableLengthStruct *inoutArg,
50 test_VariableLengthStruct **outArg,
51 CORBA_Environment *ev)
52{
53 test_VariableLengthStruct *retval;
54 g_assert (!strcmp (inArg->a,constants_STRING_IN));
55 g_assert (!strcmp (inoutArg->a,constants_STRING_INOUT_IN));
56
57 *outArg = test_VariableLengthStruct__alloc ();
58 retval = test_VariableLengthStruct__alloc ();
59
60 CORBA_free (inoutArg->a);
61
62 inoutArg->a = CORBA_string_dup (constants_STRING_INOUT_OUT);
63 (*outArg)->a = CORBA_string_dup (constants_STRING_OUT);
64 retval->a = CORBA_string_dup (constants_STRING_RETN);
65
66 return retval;
67}
68
69static test_CompoundStruct *
70StructServer_opCompound (PortableServer_Servant servant,
71 const test_CompoundStruct *inArg,
72 test_CompoundStruct *inoutArg,
73 test_CompoundStruct **outArg,
74 CORBA_Environment *ev)
75{
76 test_CompoundStruct *retval;
77 g_assert (!strcmp (inArg->a.a,constants_STRING_IN));
78 g_assert (!strcmp (inoutArg->a.a,constants_STRING_INOUT_IN));
79
80 *outArg = test_CompoundStruct__alloc ();
81 retval = test_CompoundStruct__alloc ();
82
83 CORBA_free (inoutArg->a.a);
84
85 inoutArg->a.a = CORBA_string_dup (constants_STRING_INOUT_OUT);
86 (*outArg)->a.a = CORBA_string_dup (constants_STRING_OUT);
87 retval->a.a = CORBA_string_dup (constants_STRING_RETN);
88
89 return retval;
90}
91
92static test_AlignHoleStruct
93StructServer_opAlignHole (PortableServer_Servant servant,
94 const test_AlignHoleStruct *inArg,
95 test_AlignHoleStruct *inoutArg,
96 test_AlignHoleStruct *outArg,
97 CORBA_Environment *ev)
98{
99 test_AlignHoleStruct retval;
100 g_assert (inArg->a.a == constants_DOUBLE_IN);
101 g_assert (inArg->a.b == constants_OCTET_IN);
102 g_assert (inArg->b == constants_CHAR_IN);
103
104 g_assert (inoutArg->a.a == constants_DOUBLE_INOUT_IN);
105 g_assert (inoutArg->a.b == constants_OCTET_INOUT_IN);
106 g_assert (inoutArg->b == constants_CHAR_INOUT_IN);
107
108 inoutArg->a.a = constants_DOUBLE_INOUT_OUT;
109 inoutArg->a.b = constants_OCTET_INOUT_OUT;
110 inoutArg->b = constants_CHAR_INOUT_OUT;
111
112 outArg->a.a = constants_DOUBLE_OUT;
113 outArg->a.b = constants_OCTET_OUT;
114 outArg->b = constants_CHAR_OUT;
115
116 retval.a.a = constants_DOUBLE_RETN;
117 retval.a.b = constants_OCTET_RETN;
118 retval.b = constants_CHAR_RETN;
119
120 return retval;
121}
122
123static void
124StructServer_opObjectStruct (PortableServer_Servant servant,
125 const test_ObjectStruct *inArg,
126 CORBA_Environment *ev)
127{
128 CORBA_Object objref;
129 test_StructAny *val;
130
131 objref = CORBA_Object_duplicate (inArg->serv, ev);
132 g_assert (ev->_major == CORBA_NO_EXCEPTION);
133
134 val = test_StructServer_opStructAny (inArg->serv, ev);
135 g_assert (ev->_major == CORBA_NO_EXCEPTION);
136
137 CORBA_free (val);
138
139 CORBA_Object_release (objref, ev);
140}
141
142static test_StructAny *
143StructServer_opStructAny (PortableServer_Servant servant,
144 CORBA_Environment *ev)
145{
146 test_StructAny *a = test_StructAny__alloc ();
147 static CORBA_long l;
148
149 a->a = CORBA_string_dup (constants_STRING_IN);
150
151 l = constants_LONG_IN;
152 a->b._release = FALSE;
153 a->b._value = &l;
154 a->b._type = TC_CORBA_long;
155
156 return a;
157}
158
159POA_test_StructServer__epv StructServer_epv = {
160 NULL,
161 StructServer_opFixed,
162 StructServer_opVariable,
163 StructServer_opCompound,
164 StructServer_opAlignHole,
165 StructServer_opObjectStruct,
166 StructServer_opStructAny
167};
168
169PortableServer_ServantBase__epv StructServer_base_epv = {NULL, simple_finalize, NULL};
170POA_test_StructServer__vepv StructServer_vepv = {&StructServer_base_epv,&BasicServer_epv,&StructServer_epv};
171
172POA_test_StructServer StructServer_servant = {NULL,&StructServer_vepv}; /* Singleton */
Note: See TracBrowser for help on using the repository browser.