home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / fnd101.zip / Add-Ons / Fnorb / examples / misc / Example.idl < prev    next >
Text File  |  1999-06-28  |  3KB  |  138 lines

  1. //---------------------------------------------------------------------------
  2. // Copyright (C) DSTC Pty Ltd (ACN 052 372 577) 1997, 1998, 1999
  3. // All Rights Reserved.
  4. //
  5. // The software contained on this media is the property of the DSTC Pty
  6. // Ltd.  Use of this software is strictly in accordance with the
  7. // license agreement in the accompanying LICENSE.HTML file.  If your
  8. // distribution of this software does not contain a LICENSE.HTML file
  9. // then you have no rights to use this software in any manner and
  10. // should contact DSTC at the address below to determine an appropriate
  11. // licensing arrangement.
  12. // 
  13. //      DSTC Pty Ltd
  14. //      Level 7, GP SOuth
  15. //      Staff House Road
  16. //      University of Queensland
  17. //      St Lucia, 4072
  18. //      Australia
  19. //      Tel: +61 7 3365 4310
  20. //      Fax: +61 7 3365 4311
  21. //      Email: enquiries@dstc.edu.au
  22. // 
  23. // This software is being provided "AS IS" without warranty of any
  24. // kind.  In no event shall DSTC Pty Ltd be liable for damage of any
  25. // kind arising out of or in connection with the use or performance of
  26. // this software.
  27. //
  28. // Project:      Distributed Environment
  29. // File:         $Source: /units/arch/src/Fnorb/examples/misc/RCS/Example.idl,v $
  30. // Version:      @(#)$RCSfile: Example.idl,v $ $Revision: 1.3 $
  31. //
  32. //---------------------------------------------------------------------------
  33.  
  34. #pragma prefix "dstc.edu.au"
  35.  
  36. //
  37. // This module attempts to cover most aspects of the mapping from IDL to
  38. // Python.
  39. //
  40. module Example {
  41.  
  42.     interface ExampleIF {
  43.         //
  44.         // Ok, for starters, lets take a look at an IDL version of the
  45.         // old faithful, 'hello world'!
  46.         //
  47.         // This operation takes no parameters and returns a string.
  48.         //
  49.         string hello_world();
  50.  
  51.         //
  52.         // Well that was easy, now lets look at passing an 'in'
  53.         // parameter.
  54.         //
  55.         // This operation takes a single long parameter and returns a
  56.         // long.
  57.         //
  58.         long double_it(in long n);
  59.  
  60.         //
  61.         // Now lets do the same with an 'inout' parameter.
  62.         //
  63.         void double_it_again(inout long n);
  64.  
  65.         //
  66.         // And finally, with an 'in' and an 'out'!!
  67.         //
  68.         void double_it_one_last_time(in long n, out long result);
  69.  
  70.         //
  71.         // Now lets take a look at some complex types.
  72.         //
  73.         // Structures.
  74.         //
  75.         struct Point {
  76.             long x;
  77.             long y;
  78.         };
  79.         Point move_by(in Point p, in long delta_x, in long delta_y);
  80.  
  81.         //
  82.         // Unions.
  83.         //
  84.         union OneOfThese switch(short) {
  85.         case 0:
  86.             long l;
  87.  
  88.         case 1:
  89.             float f;
  90.     
  91.         default:
  92.             string s;
  93.         };
  94.         void take_that(in OneOfThese u);
  95.  
  96.         //
  97.         // Arrays.
  98.         typedef string StringArray[10];
  99.         void ten_hello_worlds(inout StringArray x);        
  100.  
  101.         //
  102.         // Sequences.
  103.         //
  104.         typedef sequence<string> StringSeq;
  105.         StringSeq lots_of_hello_worlds(in long n);
  106.  
  107.         //
  108.         // Enums
  109.         //
  110.         enum color {red, green, blue};
  111.         color next_color(in color c);
  112.  
  113.         //
  114.         // Lets try raising a user exception!!
  115.         //
  116.         exception DOH {
  117.             string message;
  118.         };
  119.         void get_beer() raises(DOH);        
  120.  
  121.         //
  122.         // And now a system exception.
  123.         ///
  124.         void get_peanuts();
  125.  
  126.         //
  127.         // Oops, nearly forgot, here are a couple of attributes.
  128.         //
  129.         attribute long width;
  130.         readonly attribute string quality;
  131.  
  132.         //
  133.         // And finally, a one-way operation that will close down the
  134.         // server!
  135.         oneway void quit();
  136.     };            
  137. };
  138.