#ifndef MOTHERIDL_IDL #define MOTHERIDL_IDL module corbasem { module gen { module motheridl { /* Let just see what is produced from * a simple module that contains a * struct and an interface. The * two interface methods each return * the struct type - Person. */ module holderexample { struct Person { string name; string ssn; }; interface FindPerson { Person GetByName(in string sName); Person GetBySSN(in string sSSN); }; }; /* Conflicts occur when IDL names and * Identifiers map exactly to a Java * reserved word. The collision * resolution is to prepend an underscore * (_) in th mapped name. */ module conflicts { // Next line generates a parse error // interface switch { // lightSwitch should work fine interface lightSwitch { boolean OnOff(in boolean x); }; /* The mapping itself may also create * a name conflict. Here the constructs * will want to create a 'helper' class. * The collision resolution rules apply * with constructed Java names mapped * from IDL. Look for the mapped name * to have an '_' in front. */ interface lightSwitchHelper { boolean try(in boolean x); }; }; module basictypes { interface UseAllTypes { boolean TrueOrFalse(in boolean boolx, inout boolean booly, out boolean boolz); char CharAll (in char chx, inout char chy, out char chz); wchar WCharAll (in wchar wchx, inout wchar wchy, out wchar wchz); octet Octest (in octet ox, inout octet oy, out octet oz); string StringAlong(in string stx, inout string sty, out string stz); wstring StringAWide(in wstring wstx, inout wstring wsty, out string wstz); short ShortNum (in short shortx, inout short shorty, out short shortz); unsigned short UShortNum(in unsigned short ushortx, inout unsigned short ushorty, out unsigned short ushortz); long LongNum (in long longx, inout long longy, out long longz); unsigned long ULongNum(in unsigned long ulongx, inout unsigned long ulongy, out unsigned long ulongz); long long LLongNum (in long long llx, inout long long lly, out long long llz); unsigned long long ULLongNum(in unsigned long long ullx, inout unsigned long long ully, out unsigned long long ullz); float floatNum (in float floatx, inout float floaty, out float floatz); double doubleNum (in double doublex, inout double doubley, out double doublez); // Not yet supported! // long double lDoubleNum (in long double ldoublex, // inout long double ldoubley, // out long double ldoublez); }; }; module constructedtypes { // an enumeration to be used in SurfReport enum Weather{cloudy, sunny}; // some typedefs to be used in SurfReport typedef unsigned short waveHeightT; typedef unsigned short waterTempT; typedef sequence windDirectionT; typedef unsigned short windSpeedT; // use of struct struct SurfReport { Weather presentWeather; waveHeightT waveHeight; waterTempT waterTemp; windDirectionT windDirection; windSpeedT windSpeed; }; // an enum to be used as the union discriminator enum PressureScale{inches,cc}; // example of a union union BarometricPressure switch (PressureScale) { case inches : float BarometerInInches; case cc : short BarometerInCCs; }; // bounded and unbounded array examples struct ofArrays { long shares[1000]; string spreadsheet[100][100]; // unbounded arrays NOT ALLOWED // long orders[]; }; // bounded and unbounded sequence examples typedef sequence Unbounded; typedef sequence Bounded; interface testbound { void testStub(in Bounded inB, out Bounded outB); }; // user defined exception exception OilSpill { long leakage; }; // Constant examples // Constant inside an interface interface PhysicalConstants { const float EquatorialRadiusEarth = 6378.388; // km }; // A constant outside an interface const float MeanDensityEarth = 5.522; // g/cm^3 const double SPEED_OF_LIGHT = 2.997925E8; const double AVOGADRO = 6.0222E26; // typedef example typedef SurfReport BeachReport; typedef char message[256]; // syntax below not allowed // typedef char[256] message; // Some useful types struct Date { short month; short day; long year; }; struct Address { sequence street; string city; string state; string country; string postalCode; }; enum Currency { USDollar, Euro }; struct Money { double amount; // next line will throw a // redefinition error. // Currency currency; Currency currencyType; }; }; // Same as holderexample above // Person object resolved here // FindPerson would be resolved in same way module holderexample2 { interface FindPerson { corbasem::gen::motheridl::holderexample::Person GetByName(in string sName); corbasem::gen::motheridl::holderexample::Person GetBySSN(in string sSSN); }; }; // test some multiple inheritance module MI { interface A{ long aMeth (in long num); }; interface B : A { long bMeth (in long num); }; interface C : A { long cMeth (in long num); }; interface D : B, C { string dMeth (in string str); }; }; module MI2 { interface A { long aMeth (in long num); }; // produces errors // interface B { char aMeth (in char num); }; // interface B { long aMeth (in long num); }; interface B { char bMeth (in char num); }; interface C : A, B { }; }; }; }; }; #endif