| 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 | #pragma prefix "orbit"
|
|---|
| 22 |
|
|---|
| 23 | module test {
|
|---|
| 24 | const char CONST_CHAR_NL = '\x0A';
|
|---|
| 25 | const char CONST_CHAR = 't';
|
|---|
| 26 | const short CONST_SHORT = 0x1234;
|
|---|
| 27 | const long CONST_LONG = 0x12345678;
|
|---|
| 28 | const long long CONST_LONG_LONG = 0x12345678;
|
|---|
| 29 | const string CONST_STRING = "ConstString";
|
|---|
| 30 | const float CONST_FLOAT = 1234.56;
|
|---|
| 31 | const double CONST_DOUBLE = 1234.5678;
|
|---|
| 32 | const long double CONST_LONG_DOUBLE = 1234.567891;
|
|---|
| 33 | const boolean CONST_BOOLEAN = TRUE;
|
|---|
| 34 | enum Soup { veggie, chicken, tomato, oxtail };
|
|---|
| 35 | const Soup FAVORITE_SOUP = veggie;
|
|---|
| 36 | const Soup HORRIBLE_SOUP = oxtail;
|
|---|
| 37 |
|
|---|
| 38 | // Forward declarations
|
|---|
| 39 | interface BasicServer;
|
|---|
| 40 |
|
|---|
| 41 | interface StructServer;
|
|---|
| 42 | interface SequenceServer;
|
|---|
| 43 | interface UnionServer;
|
|---|
| 44 | interface ArrayServer;
|
|---|
| 45 | interface AnyServer;
|
|---|
| 46 | interface BaseServer;
|
|---|
| 47 | interface B1;
|
|---|
| 48 | interface B2;
|
|---|
| 49 | interface DerivedServer;
|
|---|
| 50 | interface TransientObj;
|
|---|
| 51 | interface ContextServer;
|
|---|
| 52 | interface DeadReferenceObj;
|
|---|
| 53 | interface PingPongServer;
|
|---|
| 54 | interface LifeCycleServer;
|
|---|
| 55 |
|
|---|
| 56 | interface TestFactory {
|
|---|
| 57 | BasicServer getBasicServer();
|
|---|
| 58 | StructServer getStructServer();
|
|---|
| 59 | string getStructServerIOR();
|
|---|
| 60 | SequenceServer getSequenceServer();
|
|---|
| 61 | UnionServer getUnionServer();
|
|---|
| 62 | ArrayServer getArrayServer();
|
|---|
| 63 | AnyServer getAnyServer();
|
|---|
| 64 | ContextServer getContextServer();
|
|---|
| 65 | oneway void segv (in string when);
|
|---|
| 66 | BaseServer getBaseServer();
|
|---|
| 67 | DerivedServer getDerivedServer();
|
|---|
| 68 | BaseServer getDerivedServerAsBaseServer();
|
|---|
| 69 | B2 getDerivedServerAsB2();
|
|---|
| 70 | TransientObj createTransientObj();
|
|---|
| 71 | DeadReferenceObj createDeadReferenceObj();
|
|---|
| 72 | PingPongServer createPingPongServer ();
|
|---|
| 73 | LifeCycleServer createLifeCycleServer ();
|
|---|
| 74 | void noOp ();
|
|---|
| 75 | };
|
|---|
| 76 |
|
|---|
| 77 | interface LifeCycleServer {
|
|---|
| 78 | void deactivateOnReturn();
|
|---|
| 79 | void deactivateUnrefOnReturn();
|
|---|
| 80 | };
|
|---|
| 81 |
|
|---|
| 82 | interface DeadReferenceObj {
|
|---|
| 83 | void test ();
|
|---|
| 84 | };
|
|---|
| 85 |
|
|---|
| 86 | interface TransientObj {
|
|---|
| 87 | void remove();
|
|---|
| 88 | };
|
|---|
| 89 |
|
|---|
| 90 | typedef struct FixedLengthStruct {
|
|---|
| 91 | short a;
|
|---|
| 92 | } DummyStruct;
|
|---|
| 93 |
|
|---|
| 94 | struct VariableLengthStruct {
|
|---|
| 95 | string a;
|
|---|
| 96 | };
|
|---|
| 97 |
|
|---|
| 98 | struct StructAny {
|
|---|
| 99 | string a;
|
|---|
| 100 | any b;
|
|---|
| 101 | };
|
|---|
| 102 |
|
|---|
| 103 | struct CompoundStruct {
|
|---|
| 104 | VariableLengthStruct a;
|
|---|
| 105 | };
|
|---|
| 106 |
|
|---|
| 107 | struct ObjectStruct {
|
|---|
| 108 | DerivedServer serv;
|
|---|
| 109 | };
|
|---|
| 110 |
|
|---|
| 111 | struct AlignHoleInnerStruct {
|
|---|
| 112 | double a;
|
|---|
| 113 | octet b;
|
|---|
| 114 | };
|
|---|
| 115 | struct AlignHoleStruct {
|
|---|
| 116 | AlignHoleInnerStruct a;
|
|---|
| 117 | char b;
|
|---|
| 118 | };
|
|---|
| 119 |
|
|---|
| 120 | typedef sequence<string> StrSeq;
|
|---|
| 121 | typedef sequence<string> AnotherStrSeq;
|
|---|
| 122 | typedef sequence<CompoundStruct,2> BoundedStructSeq;
|
|---|
| 123 | typedef sequence<long,2> BoundedLongSeq;
|
|---|
| 124 | typedef sequence<long> LongSeq;
|
|---|
| 125 | typedef sequence<StrSeq> StrSeqSeq;
|
|---|
| 126 | typedef sequence<any> AnySeq;
|
|---|
| 127 |
|
|---|
| 128 | struct StructWithSequenceInIt {
|
|---|
| 129 | StrSeqSeq theSeq;
|
|---|
| 130 | };
|
|---|
| 131 |
|
|---|
| 132 | interface SequenceServer {
|
|---|
| 133 | StrSeq opStrSeq(in StrSeq inArg, inout StrSeq inoutArg, out StrSeq outArg);
|
|---|
| 134 | BoundedStructSeq opBoundedStructSeq(in BoundedStructSeq inArg,
|
|---|
| 135 | inout BoundedStructSeq inoutArg,
|
|---|
| 136 | out BoundedStructSeq outArg);
|
|---|
| 137 | LongSeq opMassiveSeq();
|
|---|
| 138 | AnySeq opAnySeq();
|
|---|
| 139 | };
|
|---|
| 140 |
|
|---|
| 141 | typedef enum AnEnum {
|
|---|
| 142 | ENUM_IN,
|
|---|
| 143 | ENUM_INOUT_IN,
|
|---|
| 144 | ENUM_INOUT_OUT,
|
|---|
| 145 | ENUM_OUT,
|
|---|
| 146 | ENUM_RETN
|
|---|
| 147 | } DummyEnum;
|
|---|
| 148 |
|
|---|
| 149 | exception SimpleException {
|
|---|
| 150 | };
|
|---|
| 151 |
|
|---|
| 152 | exception TestException {
|
|---|
| 153 | string reason;
|
|---|
| 154 | long number;
|
|---|
| 155 | LongSeq aseq;
|
|---|
| 156 | TestFactory factory;
|
|---|
| 157 | };
|
|---|
| 158 |
|
|---|
| 159 | const long SequenceLen = 4;
|
|---|
| 160 |
|
|---|
| 161 | typedef octet OctetArray[SequenceLen];
|
|---|
| 162 | typedef long LongArray[SequenceLen];
|
|---|
| 163 | typedef string StrArray[SequenceLen];
|
|---|
| 164 | typedef string StrArrayMultiDimensional[SequenceLen][3][5];
|
|---|
| 165 | typedef FixedLengthStruct FixedLengthStructArray[SequenceLen];
|
|---|
| 166 | typedef VariableLengthStruct VariableLengthStructArray[SequenceLen];
|
|---|
| 167 | typedef AlignHoleStruct AlignHoleStructArray[SequenceLen];
|
|---|
| 168 |
|
|---|
| 169 | interface ArrayServer {
|
|---|
| 170 | LongArray opLongArray(in LongArray inArg, inout LongArray inoutArg, out LongArray outArg);
|
|---|
| 171 | OctetArray opOctetArray(in OctetArray inArg, inout OctetArray inoutArg, out OctetArray outArg);
|
|---|
| 172 | FixedLengthStructArray opFixedLengthStructArray(in FixedLengthStructArray inArg, inout FixedLengthStructArray inoutArg, out FixedLengthStructArray outArg);
|
|---|
| 173 | StrArray opStrArray(in StrArray inArg, inout StrArray inoutArg, out StrArray outArg);
|
|---|
| 174 | AlignHoleStructArray opAlignHoleStructArray(in AlignHoleStructArray inArg, inout AlignHoleStructArray inoutArg, out AlignHoleStructArray outArg);
|
|---|
| 175 | };
|
|---|
| 176 |
|
|---|
| 177 | interface BasicServer {
|
|---|
| 178 | attribute string foo;
|
|---|
| 179 | readonly attribute long bah;
|
|---|
| 180 | string opString(in string inArg, inout string inoutArg, out string outArg);
|
|---|
| 181 | long opLong(in long inArg, inout long inoutArg, out long outArg);
|
|---|
| 182 | long long opLongLong(in long long inArg, inout long long inoutArg, out long long outArg);
|
|---|
| 183 | float opFloat (in float inArg, inout float inoutArg, out float outArg);
|
|---|
| 184 | double opDouble (in double inArg, inout double inoutArg, out double outArg);
|
|---|
| 185 | long double opLongDouble (in long double inArg, inout long double inoutArg, out long double outArg);
|
|---|
| 186 | AnEnum opEnum(in AnEnum inArg, inout AnEnum inoutArg, out AnEnum outArg);
|
|---|
| 187 | void opException() raises(TestException);
|
|---|
| 188 | oneway void opOneWay(in string inArg);
|
|---|
| 189 | void noImplement ();
|
|---|
| 190 | void testLargeStringSeq (in StrSeq seq);
|
|---|
| 191 |
|
|---|
| 192 | long getObjectCount ();
|
|---|
| 193 | Object getObject (in long which);
|
|---|
| 194 |
|
|---|
| 195 | void testBoolString (in boolean inBool, in string inArg, inout string inoutArg);
|
|---|
| 196 | };
|
|---|
| 197 |
|
|---|
| 198 | interface StructServer : BasicServer {
|
|---|
| 199 | FixedLengthStruct opFixed (in FixedLengthStruct inArg,
|
|---|
| 200 | inout FixedLengthStruct inoutArg,
|
|---|
| 201 | out FixedLengthStruct outArg);
|
|---|
| 202 | VariableLengthStruct opVariable (in VariableLengthStruct inArg,
|
|---|
| 203 | inout VariableLengthStruct inoutArg,
|
|---|
| 204 | out VariableLengthStruct outArg);
|
|---|
| 205 | CompoundStruct opCompound (in CompoundStruct inArg,
|
|---|
| 206 | inout CompoundStruct inoutArg,
|
|---|
| 207 | out CompoundStruct outArg);
|
|---|
| 208 | AlignHoleStruct opAlignHole (in AlignHoleStruct inArg,
|
|---|
| 209 | inout AlignHoleStruct inoutArg,
|
|---|
| 210 | out AlignHoleStruct outArg);
|
|---|
| 211 | oneway void opObjectStruct (in ObjectStruct inArg);
|
|---|
| 212 | StructAny opStructAny ();
|
|---|
| 213 | };
|
|---|
| 214 |
|
|---|
| 215 | interface BaseServer {
|
|---|
| 216 | long opPolymorphic();
|
|---|
| 217 | attribute string attribPolymorphic;
|
|---|
| 218 | };
|
|---|
| 219 |
|
|---|
| 220 | // diamond of death, + an additional single inheritance level
|
|---|
| 221 | interface B1 : BaseServer{};
|
|---|
| 222 | interface B2 : BaseServer{};
|
|---|
| 223 | interface C1 : B1,B2 {};
|
|---|
| 224 |
|
|---|
| 225 | interface DerivedServer : C1 {};
|
|---|
| 226 |
|
|---|
| 227 | union FixedLengthUnion switch (char) {
|
|---|
| 228 | case 'a': long x;
|
|---|
| 229 | case 'b': char y;
|
|---|
| 230 | case 'c':
|
|---|
| 231 | case 'd': boolean z;
|
|---|
| 232 | case 'e': FixedLengthStruct v;
|
|---|
| 233 | };
|
|---|
| 234 |
|
|---|
| 235 | union VariableLengthUnion switch (long) {
|
|---|
| 236 | case 1: long x;
|
|---|
| 237 | default: long w;
|
|---|
| 238 | case 2: string y;
|
|---|
| 239 | case 3: double j;
|
|---|
| 240 | case 4: boolean z;
|
|---|
| 241 | case 5: VariableLengthStruct a;
|
|---|
| 242 | case 6: StrSeq b;
|
|---|
| 243 | case 7: FixedLengthUnion c;
|
|---|
| 244 | case 8: StrArray d;
|
|---|
| 245 | };
|
|---|
| 246 |
|
|---|
| 247 | union EnumUnion switch (enum Colour { red, green, blue }) {
|
|---|
| 248 | case red: long x;
|
|---|
| 249 | case blue: boolean y;
|
|---|
| 250 | };
|
|---|
| 251 |
|
|---|
| 252 | union BooleanUnion switch(boolean) {
|
|---|
| 253 | case 0: VariableLengthStruct x;
|
|---|
| 254 | case 1: string y;
|
|---|
| 255 | };
|
|---|
| 256 |
|
|---|
| 257 | typedef string StrArray2[20];
|
|---|
| 258 |
|
|---|
| 259 | union ArrayUnion switch(unsigned short) {
|
|---|
| 260 | case 22: StrArray2 d;
|
|---|
| 261 | };
|
|---|
| 262 |
|
|---|
| 263 | typedef sequence <VariableLengthUnion> unionSeq;
|
|---|
| 264 | typedef FixedLengthUnion FixedLengthUnionArray[SequenceLen];
|
|---|
| 265 |
|
|---|
| 266 | interface UnionServer {
|
|---|
| 267 | FixedLengthUnion opFixed (in FixedLengthUnion inArg,
|
|---|
| 268 | inout FixedLengthUnion inoutArg,
|
|---|
| 269 | out FixedLengthUnion outArg);
|
|---|
| 270 |
|
|---|
| 271 | VariableLengthUnion opVariable (in VariableLengthUnion inArg,
|
|---|
| 272 | inout VariableLengthUnion inoutArg,
|
|---|
| 273 | out VariableLengthUnion outArg);
|
|---|
| 274 |
|
|---|
| 275 | EnumUnion opMisc (in unionSeq inSeq,
|
|---|
| 276 | in BooleanUnion inArg,
|
|---|
| 277 | out ArrayUnion outArg);
|
|---|
| 278 |
|
|---|
| 279 | FixedLengthUnionArray opFixedLengthUnionArray (in FixedLengthUnionArray inArg,
|
|---|
| 280 | inout FixedLengthUnionArray inoutArg,
|
|---|
| 281 | out FixedLengthUnionArray outArg);
|
|---|
| 282 | };
|
|---|
| 283 |
|
|---|
| 284 | interface AnyServer {
|
|---|
| 285 | any opAnyStrSeq();
|
|---|
| 286 | any opAnyLong(in any inArg, inout any inoutArg, out any outArg);
|
|---|
| 287 | any opAnyString(in any inArg, inout any inoutArg, out any outArg);
|
|---|
| 288 | any opAnyStruct(in any inArg, inout any inoutArg, out any outArg);
|
|---|
| 289 | TypeCode opTypeCode(in TypeCode inArg, inout TypeCode inoutArg, out TypeCode outArg);
|
|---|
| 290 | };
|
|---|
| 291 |
|
|---|
| 292 | interface ContextServer {
|
|---|
| 293 | Object opWithContext(in Object inArg, inout Object inoutArg, out Object outArg)
|
|---|
| 294 | context ("foo", "bar");
|
|---|
| 295 | };
|
|---|
| 296 |
|
|---|
| 297 | interface PingPongServer {
|
|---|
| 298 | oneway void opSleep (in string large_string);
|
|---|
| 299 | oneway void opOneWay (in long l);
|
|---|
| 300 | oneway void opOneWayCallback (in PingPongServer obj);
|
|---|
| 301 | void opRoundTrip ();
|
|---|
| 302 | long pingPong (in PingPongServer replyTo,
|
|---|
| 303 | in long idx);
|
|---|
| 304 | void set (in PingPongServer reg,
|
|---|
| 305 | in string name);
|
|---|
| 306 | Object get (in string name);
|
|---|
| 307 | };
|
|---|
| 308 | };
|
|---|
| 309 |
|
|---|