| 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 |
|
|---|
| 26 |
|
|---|
| 27 |
|
|---|
| 28 | static CORBA_long opAnyLong_inout = constants_LONG_INOUT_OUT;
|
|---|
| 29 | static CORBA_long opAnyLong_out = constants_LONG_OUT;
|
|---|
| 30 | static CORBA_long opAnyLong_retn = constants_LONG_RETN;
|
|---|
| 31 |
|
|---|
| 32 | static CORBA_any *
|
|---|
| 33 | AnyServer_opAnyStrSeq (PortableServer_Servant _servant,
|
|---|
| 34 | CORBA_Environment * ev)
|
|---|
| 35 | {
|
|---|
| 36 | CORBA_any *retn;
|
|---|
| 37 | test_StrSeq *seq;
|
|---|
| 38 | int i;
|
|---|
| 39 |
|
|---|
| 40 | seq = test_StrSeq__alloc();
|
|---|
| 41 | seq->_length = 16;
|
|---|
| 42 | seq->_buffer = CORBA_sequence_CORBA_string_allocbuf (seq->_length);
|
|---|
| 43 | seq->_release = TRUE;
|
|---|
| 44 |
|
|---|
| 45 | for (i = 0; i < seq->_length; i++)
|
|---|
| 46 | seq->_buffer [i] = CORBA_string_dup ("Foo");
|
|---|
| 47 |
|
|---|
| 48 | retn = CORBA_any_alloc ();
|
|---|
| 49 | retn->_type = (CORBA_TypeCode) CORBA_Object_duplicate (
|
|---|
| 50 | (CORBA_Object) TC_test_StrSeq, ev);
|
|---|
| 51 | retn->_value = seq;
|
|---|
| 52 | retn->_release = TRUE;
|
|---|
| 53 |
|
|---|
| 54 | return retn;
|
|---|
| 55 | }
|
|---|
| 56 |
|
|---|
| 57 | static CORBA_any *
|
|---|
| 58 | AnyServer_opAnyLong (PortableServer_Servant _servant,
|
|---|
| 59 | const CORBA_any * inArg,
|
|---|
| 60 | CORBA_any * inoutArg,
|
|---|
| 61 | CORBA_any ** outArg,
|
|---|
| 62 | CORBA_Environment * ev)
|
|---|
| 63 | {
|
|---|
| 64 | CORBA_any *retn;
|
|---|
| 65 |
|
|---|
| 66 | g_assert(CORBA_TypeCode_equal(inArg->_type,TC_CORBA_long,ev));
|
|---|
| 67 | g_assert(*(CORBA_long*)inArg->_value == constants_LONG_IN);
|
|---|
| 68 |
|
|---|
| 69 | g_assert(CORBA_TypeCode_equal(inoutArg->_type,TC_CORBA_long,ev));
|
|---|
| 70 | g_assert(*(CORBA_long*)inoutArg->_value == constants_LONG_INOUT_IN);
|
|---|
| 71 |
|
|---|
| 72 | if(CORBA_any_get_release(inoutArg)){
|
|---|
| 73 | CORBA_free(inoutArg->_value);
|
|---|
| 74 | CORBA_Object_release((CORBA_Object)inoutArg->_type, ev);
|
|---|
| 75 | }
|
|---|
| 76 |
|
|---|
| 77 |
|
|---|
| 78 | inoutArg->_type = (CORBA_TypeCode)TC_CORBA_long;
|
|---|
| 79 | inoutArg->_value = &opAnyLong_inout;
|
|---|
| 80 | CORBA_any_set_release(inoutArg, CORBA_FALSE);
|
|---|
| 81 |
|
|---|
| 82 | *outArg = CORBA_any_alloc();
|
|---|
| 83 | (*outArg)->_type = (CORBA_TypeCode)TC_CORBA_long;
|
|---|
| 84 | (*outArg)->_value = &opAnyLong_out;
|
|---|
| 85 | CORBA_any_set_release(*outArg, CORBA_FALSE);
|
|---|
| 86 |
|
|---|
| 87 | retn = CORBA_any_alloc();
|
|---|
| 88 | retn->_type = (CORBA_TypeCode)TC_CORBA_long;
|
|---|
| 89 | retn->_value = &opAnyLong_retn;
|
|---|
| 90 | CORBA_any_set_release(retn, CORBA_FALSE);
|
|---|
| 91 |
|
|---|
| 92 | return retn;
|
|---|
| 93 | }
|
|---|
| 94 |
|
|---|
| 95 |
|
|---|
| 96 | static
|
|---|
| 97 | CORBA_any *
|
|---|
| 98 | AnyServer_opAnyString(PortableServer_Servant _servant,
|
|---|
| 99 | const CORBA_any * inArg,
|
|---|
| 100 | CORBA_any * inoutArg,
|
|---|
| 101 | CORBA_any ** outArg,
|
|---|
| 102 | CORBA_Environment * ev){
|
|---|
| 103 | CORBA_any *retn;
|
|---|
| 104 |
|
|---|
| 105 | g_assert(CORBA_TypeCode_equal(inArg->_type,TC_CORBA_string,ev));
|
|---|
| 106 | g_assert(strcmp(*(CORBA_char **)inArg->_value,constants_STRING_IN) == 0);
|
|---|
| 107 |
|
|---|
| 108 | g_assert(CORBA_TypeCode_equal(inoutArg->_type,TC_CORBA_string,ev) );
|
|---|
| 109 | g_assert(strcmp(*(CORBA_char **)inoutArg->_value,constants_STRING_INOUT_IN) == 0);
|
|---|
| 110 |
|
|---|
| 111 | if(CORBA_any_get_release(inoutArg)){
|
|---|
| 112 | CORBA_free(inoutArg->_value);
|
|---|
| 113 | CORBA_Object_release((CORBA_Object)inoutArg->_type, ev);
|
|---|
| 114 | }
|
|---|
| 115 |
|
|---|
| 116 | inoutArg->_type = (CORBA_TypeCode)TC_CORBA_string;
|
|---|
| 117 | inoutArg->_value = &constants_STRING_INOUT_OUT;
|
|---|
| 118 | CORBA_any_set_release(inoutArg, CORBA_FALSE);
|
|---|
| 119 |
|
|---|
| 120 | *outArg = CORBA_any_alloc();
|
|---|
| 121 | (*outArg)->_type = (CORBA_TypeCode)TC_CORBA_string;
|
|---|
| 122 | (*outArg)->_value = &constants_STRING_OUT;
|
|---|
| 123 | CORBA_any_set_release(*outArg, CORBA_FALSE);
|
|---|
| 124 |
|
|---|
| 125 | retn = CORBA_any_alloc();
|
|---|
| 126 | retn->_type = (CORBA_TypeCode)TC_CORBA_string;
|
|---|
| 127 | retn->_value = &constants_STRING_RETN;
|
|---|
| 128 | CORBA_any_set_release(retn, CORBA_FALSE);
|
|---|
| 129 |
|
|---|
| 130 | return retn;
|
|---|
| 131 | }
|
|---|
| 132 |
|
|---|
| 133 |
|
|---|
| 134 | static test_VariableLengthStruct inoutArgStruct;
|
|---|
| 135 | static test_VariableLengthStruct outArgStruct;
|
|---|
| 136 | static test_VariableLengthStruct retnStruct;
|
|---|
| 137 |
|
|---|
| 138 | static
|
|---|
| 139 | CORBA_any *
|
|---|
| 140 | AnyServer_opAnyStruct(PortableServer_Servant _servant,
|
|---|
| 141 | const CORBA_any * inArg,
|
|---|
| 142 | CORBA_any * inoutArg,
|
|---|
| 143 | CORBA_any ** outArg,
|
|---|
| 144 | CORBA_Environment * ev){
|
|---|
| 145 | CORBA_any *retn;
|
|---|
| 146 |
|
|---|
| 147 | g_assert(CORBA_TypeCode_equal(inArg->_type,TC_test_VariableLengthStruct,ev));
|
|---|
| 148 | g_assert(strcmp((*(test_VariableLengthStruct*)inArg->_value).a,constants_STRING_IN) == 0);
|
|---|
| 149 |
|
|---|
| 150 | g_assert(CORBA_TypeCode_equal(inoutArg->_type,TC_test_VariableLengthStruct,ev) );
|
|---|
| 151 | g_assert(strcmp((*(test_VariableLengthStruct*)inoutArg->_value).a,constants_STRING_INOUT_IN) == 0);
|
|---|
| 152 |
|
|---|
| 153 | if(CORBA_any_get_release(inoutArg)){
|
|---|
| 154 | CORBA_free(inoutArg->_value);
|
|---|
| 155 | CORBA_Object_release((CORBA_Object)inoutArg->_type, ev);
|
|---|
| 156 | }
|
|---|
| 157 |
|
|---|
| 158 | inoutArg->_type = (CORBA_TypeCode)TC_test_VariableLengthStruct;
|
|---|
| 159 | inoutArgStruct.a = (char *)constants_STRING_INOUT_OUT;
|
|---|
| 160 | inoutArg->_value = &inoutArgStruct;
|
|---|
| 161 | CORBA_any_set_release(inoutArg, CORBA_FALSE);
|
|---|
| 162 |
|
|---|
| 163 | *outArg = CORBA_any_alloc();
|
|---|
| 164 | (*outArg)->_type = (CORBA_TypeCode)TC_test_VariableLengthStruct;
|
|---|
| 165 | outArgStruct.a = (char *)constants_STRING_OUT;
|
|---|
| 166 | (*outArg)->_value = &outArgStruct;
|
|---|
| 167 | CORBA_any_set_release(*outArg, CORBA_FALSE);
|
|---|
| 168 |
|
|---|
| 169 | retn = CORBA_any_alloc();
|
|---|
| 170 | retn->_type = (CORBA_TypeCode)TC_test_VariableLengthStruct;
|
|---|
| 171 | retnStruct.a = (char *)constants_STRING_RETN;
|
|---|
| 172 | retn->_value = &retnStruct;
|
|---|
| 173 | CORBA_any_set_release(retn, CORBA_FALSE);
|
|---|
| 174 |
|
|---|
| 175 | return retn;
|
|---|
| 176 | }
|
|---|
| 177 |
|
|---|
| 178 |
|
|---|
| 179 | CORBA_TypeCode retntypecode = TC_test_VariableLengthStruct;
|
|---|
| 180 |
|
|---|
| 181 | static
|
|---|
| 182 | CORBA_TypeCode
|
|---|
| 183 | AnyServer_opTypeCode (PortableServer_Servant servant,
|
|---|
| 184 | const CORBA_TypeCode inArg,
|
|---|
| 185 | CORBA_TypeCode *inoutArg,
|
|---|
| 186 | CORBA_TypeCode *outArg,
|
|---|
| 187 | CORBA_Environment *ev)
|
|---|
| 188 | {
|
|---|
| 189 | g_assert (CORBA_TypeCode_equal (inArg, TC_test_ArrayUnion, ev));
|
|---|
| 190 | g_assert (CORBA_TypeCode_equal (*inoutArg, TC_test_AnyServer, ev));
|
|---|
| 191 |
|
|---|
| 192 | CORBA_Object_release ((CORBA_Object)*inoutArg, ev);
|
|---|
| 193 | *inoutArg = (CORBA_TypeCode) CORBA_Object_duplicate (
|
|---|
| 194 | (CORBA_Object) TC_test_TestException, ev);
|
|---|
| 195 | *outArg = TC_test_AnEnum;
|
|---|
| 196 |
|
|---|
| 197 | return TC_test_VariableLengthStruct;
|
|---|
| 198 | }
|
|---|
| 199 |
|
|---|
| 200 | POA_test_AnyServer__epv AnyServer_epv = {
|
|---|
| 201 | NULL,
|
|---|
| 202 | AnyServer_opAnyStrSeq,
|
|---|
| 203 | AnyServer_opAnyLong,
|
|---|
| 204 | AnyServer_opAnyString,
|
|---|
| 205 | AnyServer_opAnyStruct,
|
|---|
| 206 | AnyServer_opTypeCode,
|
|---|
| 207 | };
|
|---|
| 208 |
|
|---|
| 209 | PortableServer_ServantBase__epv AnyServer_base_epv = {NULL, simple_finalize, NULL};
|
|---|
| 210 | POA_test_AnyServer__vepv AnyServer_vepv = { &AnyServer_base_epv, &AnyServer_epv };
|
|---|