home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / fnd101.zip / Add-Ons / Fnorb / examples / unions / Unions.idl < prev   
Text File  |  1999-06-28  |  3KB  |  137 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:      Fnorb
  29. // File:         $Source: /units/arch/src/Fnorb/examples/unions/RCS/Unions.idl,v $
  30. // Version:      @(#)$RCSfile: Unions.idl,v $ $Revision: 1.5 $
  31. //
  32. //---------------------------------------------------------------------------
  33.  
  34. #pragma prefix "dstc.edu.au"
  35.  
  36. module Unions {
  37.  
  38.     // Union with a boolean discriminator and complete case coverage.
  39.     union A switch(boolean) {
  40.  
  41.     case TRUE:
  42.         short t;
  43.  
  44.     case FALSE:
  45.         string f;
  46.  
  47.     };
  48.  
  49.     // Union with a boolean discriminator and incomplete case coverage.
  50.     union B switch(boolean) {
  51.  
  52.     case TRUE:
  53.         short t;
  54.  
  55.     };
  56.  
  57.     // Union with a boolean discriminator and a default case.
  58.     union C switch(boolean) {
  59.  
  60.     case TRUE:
  61.         short t;
  62.  
  63.     default:
  64.         string d;
  65.  
  66.     };
  67.  
  68.     // An enum for switching.
  69.     enum color {red, green, blue};
  70.  
  71.     // Union with an enum discriminator and complete case coverage.
  72.     union D switch(color) {
  73.  
  74.     case red:
  75.         short r;
  76.  
  77.     case green:
  78.         float g;
  79.  
  80.     case blue:
  81.         string b;
  82.     };
  83.  
  84.     // Union with an enum discriminator and incomplete case coverage.
  85.     union E switch(color) {
  86.  
  87.     case red:
  88.         short r;
  89.     };
  90.  
  91.     // Union with an enum discriminator and a default case.
  92.     union F switch(color) {
  93.  
  94.     case red:
  95.         short r;
  96.  
  97.     default:
  98.         string d;
  99.     };
  100.  
  101.     // Define an interface using the unions.
  102.     interface test {
  103.     
  104.         // 'in' parameters.
  105.         void in_a(in A a);
  106.         void in_b(in B b);
  107.         void in_c(in C c);
  108.         void in_d(in D d);
  109.         void in_e(in E e);
  110.         void in_f(in F f);
  111.  
  112.         // 'inout' parameters.
  113.         void inout_a(inout A a);
  114.         void inout_b(inout B b);
  115.         void inout_c(inout C c);
  116.         void inout_d(inout D d);
  117.         void inout_e(inout E e);
  118.         void inout_f(inout F f);
  119.  
  120.         // 'out' parameters.
  121.         void out_a(out A a);
  122.         void out_b(out B b);
  123.         void out_c(out C c);
  124.         void out_d(out D d);
  125.         void out_e(out E e);
  126.         void out_f(out F f);
  127.  
  128.         // Return values.
  129.         A return_a();
  130.         B return_b();
  131.         C return_c();
  132.         D return_d();
  133.         E return_e();
  134.         F return_f();
  135.     };
  136. };
  137.