| 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 | static test_StrSeq *
|
|---|
| 27 | SequenceServer_opStrSeq (PortableServer_Servant _servant,
|
|---|
| 28 | const test_StrSeq * inArg,
|
|---|
| 29 | test_StrSeq * inoutArg,
|
|---|
| 30 | test_StrSeq ** outArg,
|
|---|
| 31 | CORBA_Environment * ev)
|
|---|
| 32 | {
|
|---|
| 33 | test_StrSeq *retn;
|
|---|
| 34 | guint i;
|
|---|
| 35 | for (i=0;i<inArg->_length;i++)
|
|---|
| 36 | g_assert(strcmp(inArg->_buffer[i],constants_SEQ_STRING_IN[i]) == 0);
|
|---|
| 37 |
|
|---|
| 38 | for (i=0;i<inoutArg->_length;i++)
|
|---|
| 39 | g_assert(strcmp(inoutArg->_buffer[i],constants_SEQ_STRING_INOUT_IN[i]) == 0);
|
|---|
| 40 |
|
|---|
| 41 | if (CORBA_sequence_get_release (inoutArg))
|
|---|
| 42 | CORBA_free(inoutArg->_buffer);
|
|---|
| 43 |
|
|---|
| 44 | inoutArg->_buffer = CORBA_sequence_CORBA_string_allocbuf(2);
|
|---|
| 45 | inoutArg->_length = 2;
|
|---|
| 46 | CORBA_sequence_set_release(inoutArg, CORBA_TRUE);
|
|---|
| 47 |
|
|---|
| 48 | for (i=0;i<inoutArg->_length;i++)
|
|---|
| 49 | inoutArg->_buffer[i] = CORBA_string_dup(constants_SEQ_STRING_INOUT_OUT[i]);
|
|---|
| 50 |
|
|---|
| 51 | *outArg = CORBA_sequence_CORBA_string__alloc();
|
|---|
| 52 | (*outArg)->_buffer = CORBA_sequence_CORBA_string_allocbuf(2);
|
|---|
| 53 | (*outArg)->_length = 2;
|
|---|
| 54 | CORBA_sequence_set_release(*outArg, CORBA_TRUE);
|
|---|
| 55 |
|
|---|
| 56 | for (i=0;i<(*outArg)->_length;i++)
|
|---|
| 57 | (*outArg)->_buffer[i] = CORBA_string_dup(constants_SEQ_STRING_OUT[i]);
|
|---|
| 58 |
|
|---|
| 59 | retn = CORBA_sequence_CORBA_string__alloc();
|
|---|
| 60 | retn->_buffer = CORBA_sequence_CORBA_string_allocbuf(2);
|
|---|
| 61 | retn->_length = 2;
|
|---|
| 62 | CORBA_sequence_set_release(retn, CORBA_TRUE);
|
|---|
| 63 |
|
|---|
| 64 | for (i=0;i<retn->_length;i++)
|
|---|
| 65 | retn->_buffer[i] = CORBA_string_dup(constants_SEQ_STRING_RETN[i]);
|
|---|
| 66 |
|
|---|
| 67 | return retn;
|
|---|
| 68 | }
|
|---|
| 69 |
|
|---|
| 70 | static test_BoundedStructSeq *
|
|---|
| 71 | SequenceServer_opBoundedStructSeq (PortableServer_Servant _servant,
|
|---|
| 72 | const test_BoundedStructSeq * inArg,
|
|---|
| 73 | test_BoundedStructSeq * inoutArg,
|
|---|
| 74 | test_BoundedStructSeq ** outArg,
|
|---|
| 75 | CORBA_Environment * ev)
|
|---|
| 76 | {
|
|---|
| 77 | test_BoundedStructSeq *retn;
|
|---|
| 78 | CORBA_long i;
|
|---|
| 79 | for (i = 0; i < inArg->_length; i++)
|
|---|
| 80 | g_assert (strcmp (inArg->_buffer[i].a.a, constants_SEQ_STRING_IN[i]) == 0);
|
|---|
| 81 |
|
|---|
| 82 | for (i = 0; i < inoutArg->_length; i++)
|
|---|
| 83 | g_assert(strcmp(inoutArg->_buffer[i].a.a,constants_SEQ_STRING_INOUT_IN[i]) == 0);
|
|---|
| 84 |
|
|---|
| 85 | if (CORBA_sequence_get_release (inoutArg))
|
|---|
| 86 | CORBA_free (inoutArg->_buffer);
|
|---|
| 87 |
|
|---|
| 88 | inoutArg->_buffer = CORBA_sequence_test_CompoundStruct_allocbuf (2);
|
|---|
| 89 | inoutArg->_length = 2;
|
|---|
| 90 | CORBA_sequence_set_release (inoutArg, CORBA_TRUE);
|
|---|
| 91 |
|
|---|
| 92 | for (i = 0; i < inoutArg->_length; i++)
|
|---|
| 93 | inoutArg->_buffer[i].a.a = CORBA_string_dup (constants_SEQ_STRING_INOUT_OUT[i]);
|
|---|
| 94 |
|
|---|
| 95 | *outArg = CORBA_sequence_test_CompoundStruct__alloc ();
|
|---|
| 96 | (*outArg)->_buffer = CORBA_sequence_test_CompoundStruct_allocbuf (2);
|
|---|
| 97 | (*outArg)->_length = 2;
|
|---|
| 98 | CORBA_sequence_set_release (*outArg, CORBA_TRUE);
|
|---|
| 99 |
|
|---|
| 100 | for (i = 0; i < (*outArg)->_length; i++)
|
|---|
| 101 | (*outArg)->_buffer[i].a.a = CORBA_string_dup (constants_SEQ_STRING_OUT[i]);
|
|---|
| 102 |
|
|---|
| 103 |
|
|---|
| 104 | retn = CORBA_sequence_test_CompoundStruct__alloc ();
|
|---|
| 105 | retn->_buffer = CORBA_sequence_test_CompoundStruct_allocbuf (2);
|
|---|
| 106 | retn->_length = 2;
|
|---|
| 107 | CORBA_sequence_set_release (retn, CORBA_TRUE);
|
|---|
| 108 |
|
|---|
| 109 | for (i = 0; i < retn->_length; i++)
|
|---|
| 110 | retn->_buffer[i].a.a = CORBA_string_dup (constants_SEQ_STRING_RETN[i]);
|
|---|
| 111 |
|
|---|
| 112 | return retn;
|
|---|
| 113 | }
|
|---|
| 114 |
|
|---|
| 115 | static test_LongSeq *
|
|---|
| 116 | SequenceServer_opMassiveSeq (PortableServer_Servant servant,
|
|---|
| 117 | CORBA_Environment *ev)
|
|---|
| 118 | {
|
|---|
| 119 | test_LongSeq *retn;
|
|---|
| 120 | CORBA_long i;
|
|---|
| 121 | CORBA_long n = 400000;
|
|---|
| 122 |
|
|---|
| 123 | retn = test_LongSeq__alloc ();
|
|---|
| 124 | retn->_buffer = test_LongSeq_allocbuf (n);
|
|---|
| 125 | retn->_length = n;
|
|---|
| 126 | CORBA_sequence_set_release (retn, CORBA_TRUE);
|
|---|
| 127 |
|
|---|
| 128 | for (i = 0; i < retn->_length; i++)
|
|---|
| 129 | retn->_buffer[i] = i;
|
|---|
| 130 |
|
|---|
| 131 | return retn;
|
|---|
| 132 | }
|
|---|
| 133 |
|
|---|
| 134 | static test_AnySeq *
|
|---|
| 135 | SequenceServer_opAnySeq (PortableServer_Servant servant,
|
|---|
| 136 | CORBA_Environment *ev)
|
|---|
| 137 | {
|
|---|
| 138 | test_AnySeq *retn;
|
|---|
| 139 | CORBA_long i;
|
|---|
| 140 | CORBA_long n = 1000;
|
|---|
| 141 |
|
|---|
| 142 | retn = test_AnySeq__alloc ();
|
|---|
| 143 | retn->_buffer = test_AnySeq_allocbuf (n);
|
|---|
| 144 | retn->_length = n;
|
|---|
| 145 | CORBA_sequence_set_release (retn, CORBA_TRUE);
|
|---|
| 146 |
|
|---|
| 147 | for (i = 0; i < retn->_length; i++) {
|
|---|
| 148 | if (i < 500)
|
|---|
| 149 | retn->_buffer[i]._type = TC_void;
|
|---|
| 150 | else
|
|---|
| 151 | retn->_buffer[i]._type = TC_null;
|
|---|
| 152 | retn->_buffer[i]._value = NULL;
|
|---|
| 153 | retn->_buffer[i]._release = CORBA_FALSE;
|
|---|
| 154 | }
|
|---|
| 155 | return retn;
|
|---|
| 156 | }
|
|---|
| 157 |
|
|---|
| 158 | POA_test_SequenceServer__epv SequenceServer_epv = {
|
|---|
| 159 | NULL,
|
|---|
| 160 | SequenceServer_opStrSeq,
|
|---|
| 161 | SequenceServer_opBoundedStructSeq,
|
|---|
| 162 | SequenceServer_opMassiveSeq,
|
|---|
| 163 | SequenceServer_opAnySeq,
|
|---|
| 164 | };
|
|---|
| 165 |
|
|---|
| 166 | PortableServer_ServantBase__epv SequenceServer_base_epv = {NULL, simple_finalize, NULL};
|
|---|
| 167 | POA_test_SequenceServer__vepv SequenceServer_vepv = { &SequenceServer_base_epv, &SequenceServer_epv };
|
|---|