//--------------------------------------------------------------------------- // Copyright (C) DSTC Pty Ltd (ACN 052 372 577) 1997, 1998, 1999 // All Rights Reserved. // // The software contained on this media is the property of the DSTC Pty // Ltd. Use of this software is strictly in accordance with the // license agreement in the accompanying LICENSE.HTML file. If your // distribution of this software does not contain a LICENSE.HTML file // then you have no rights to use this software in any manner and // should contact DSTC at the address below to determine an appropriate // licensing arrangement. // // DSTC Pty Ltd // Level 7, GP SOuth // Staff House Road // University of Queensland // St Lucia, 4072 // Australia // Tel: +61 7 3365 4310 // Fax: +61 7 3365 4311 // Email: enquiries@dstc.edu.au // // This software is being provided "AS IS" without warranty of any // kind. In no event shall DSTC Pty Ltd be liable for damage of any // kind arising out of or in connection with the use or performance of // this software. // // Project: Distributed Environment // File: $Source: /cvsroot/fnorb/fnorb/examples/misc/Example.idl,v $ // Version: @(#)$RCSfile: Example.idl,v $ $Revision: 1.9 $ // //--------------------------------------------------------------------------- #pragma prefix "dstc.edu.au" // // This module attempts to cover most aspects of the mapping from IDL to // Python. // /* A comment */ module Example { interface Sprite { string get_name(); }; interface ExampleIF { // // Ok, for starters, lets take a look at an IDL version of the // old faithful, 'hello world'! // // This operation takes no parameters and returns a string. // string hello_world(); // // Well that was easy, now lets look at passing an 'in' // parameter. // // This operation takes a single long parameter and returns a // long. // long double_it(in long n); // // Now lets do the same with an 'inout' parameter. // void double_it_again(inout long n); // // And finally, with an 'in' and an 'out'!! // void double_it_one_last_time(in long n, out long result); // // Now lets take a look at some complex types ... // // // Structures. // struct Point { long x; long y; }; Point move_by(in Point p, in long delta_x, in long delta_y); // // Recursive structures. // struct Tree { string name; sequence children; }; void take_tree(in Tree t); // // Unions. // union OneOfThese switch(short) { case 0: long l; case 1: float f; default: string s; }; void take_that(in OneOfThese u); // // Arrays. typedef string StringArray[10]; void ten_hello_worlds(inout StringArray x); // // Sequences. // typedef sequence StringSeq; StringSeq lots_of_hello_worlds(in long n); // // Enums // enum color {red, green, blue}; color next_color(in color c); // // Lets try raising a user exception!! // exception DOH { string message; }; void get_beer() raises(DOH); // // And now a system exception. /// void get_peanuts(); // // Oops, nearly forgot, here are a couple of attributes. // attribute long width; readonly attribute string quality; // Create a new object Sprite create_sprite(in string name); // // A nested struct type // struct OuterStruct { long l; struct InnerStruct { short x; short y; } inner; }; // // An operation to test the nested struct // void take_nested_struct(in OuterStruct outer_struct); // // A struct type with a nested union // struct OuterStructWithUnion { long l; union InnerUnion switch (boolean) { case TRUE: short x; case FALSE: short y; } inner; }; // // An operation to test the struct type with a nested union // void take_nested_struct_with_union( in OuterStructWithUnion outer_struct); // // A union type with a nested struct // union OuterUnion switch (boolean) { case TRUE: long l; case FALSE: union InnerUnion switch (boolean) { case TRUE: short x; case FALSE: short y; } inner; }; // // An operation to test the union type with a nested struct // void take_nested_union(in OuterUnion outer_union); // // A union type with a nested struct // union OuterUnionWithStruct switch (boolean) { case TRUE: long l; case FALSE: struct InnerStruct { short x; short y; } inner; }; // // An operation to test the union type with a nested struct // void take_nested_union_with_struct( in OuterUnionWithStruct outer_union); // // And finally, a one-way operation that will close down the // server! oneway void quit(); }; };