home *** CD-ROM | disk | FTP | other *** search
/ Power GUI Programming with VisualAge C++ / powergui.iso / trialva / ibmcppw / include / somcorba.h < prev    next >
Encoding:
C/C++ Source or Header  |  1996-01-24  |  6.9 KB  |  219 lines

  1. /*
  2.  *   COMPONENT_NAME: somk
  3.  *
  4.  *   ORIGINS: 27
  5.  *
  6.  *
  7.  *   10H9767, 10H9769  (C) COPYRIGHT International Business Machines Corp. 1992,1994
  8.  *   All Rights Reserved
  9.  *   Licensed Materials - Property of IBM
  10.  *   US Government Users Restricted Rights - Use, duplication or
  11.  *   disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
  12.  */
  13. /* %Z% %I% %W% %G% %U% [%H% %T%] */
  14.  
  15. /*
  16.  */
  17.  
  18. /*
  19.  *    SOMCORBA.H
  20.  *    Typedefs, structs, & prototypes in support of CORBA extensions
  21.  *    to the SOM run-time
  22.  */
  23.  
  24. #ifndef SOMCorba_h
  25. #define SOMCorba_h
  26. #include <string.h>  /* needed for memset, used below */
  27.  
  28. #ifdef CORBA_FUNCTION_NAMES
  29. #define CORBAObject Object
  30. #endif
  31.  
  32. /* in SOM, a CORBA object is a SOM object */
  33. typedef SOMObject CORBAObject;
  34.  
  35. /* CORBA 5.7, p.89 */
  36. #ifndef SOM_BOOLEAN
  37.   #define SOM_BOOLEAN
  38.   typedef unsigned char boolean;  
  39. #endif /* SOM_BOOLEAN */
  40. typedef unsigned char octet;
  41. typedef char *string;
  42.  
  43. /* CORBA 7.5.1, p. 129 */
  44. typedef string Identifier;
  45.  
  46. /* CORBA 4.13, p. 80 */
  47. typedef enum exception_type {NO_EXCEPTION, USER_EXCEPTION, SYSTEM_EXCEPTION}
  48.     exception_type;
  49. typedef enum completion_status {YES, NO, MAYBE} completion_status;
  50. typedef struct StExcep {
  51.     unsigned long minor;
  52.     completion_status completed;
  53. } StExcep;
  54.  
  55. typedef struct Environment {
  56.     exception_type             _major;
  57.     struct {
  58.     char *                 _exception_name;
  59.     void *                 _params;
  60.     } exception;
  61.     void *                     _somdAnchor;
  62. } Environment;
  63.  
  64. /* CORBA 7.6.1, p.139 plus 5.7, p.89 enum Data Type Mapping */
  65. typedef unsigned long TCKind; 
  66.   #define TypeCode_tk_null      1 
  67.   #define TypeCode_tk_void      2
  68.   #define TypeCode_tk_short     3 
  69.   #define TypeCode_tk_long      4 
  70.   #define TypeCode_tk_ushort    5 
  71.   #define TypeCode_tk_ulong     6
  72.   #define TypeCode_tk_float     7 
  73.   #define TypeCode_tk_double    8 
  74.   #define TypeCode_tk_boolean   9 
  75.   #define TypeCode_tk_char      10
  76.   #define TypeCode_tk_octet     11 
  77.   #define TypeCode_tk_any       12 
  78.   #define TypeCode_tk_TypeCode  13 
  79.   #define TypeCode_tk_Principal 14 
  80.   #define TypeCode_tk_objref    15
  81.   #define TypeCode_tk_struct    16 
  82.   #define TypeCode_tk_union     17 
  83.   #define TypeCode_tk_enum      18 
  84.   #define TypeCode_tk_string    19
  85.   #define TypeCode_tk_sequence  20 
  86.   #define TypeCode_tk_array     21
  87.  
  88.   #define TypeCode_tk_pointer   101 /* SOM extension */
  89.   #define TypeCode_tk_self      102 /* SOM extension */
  90.   #define TypeCode_tk_foreign   103 /* SOM extension */
  91.  
  92. /* Short forms of tk_<x> enumerators */
  93.  
  94.   #define tk_null       TypeCode_tk_null 
  95.   #define tk_void       TypeCode_tk_void
  96.   #define tk_short      TypeCode_tk_short 
  97.   #define tk_long       TypeCode_tk_long 
  98.   #define tk_ushort     TypeCode_tk_ushort 
  99.   #define tk_ulong      TypeCode_tk_ulong
  100.   #define tk_float      TypeCode_tk_float 
  101.   #define tk_double     TypeCode_tk_double 
  102.   #define tk_boolean    TypeCode_tk_boolean 
  103.   #define tk_char       TypeCode_tk_char
  104.   #define tk_octet      TypeCode_tk_octet 
  105.   #define tk_any        TypeCode_tk_any 
  106.   #define tk_TypeCode   TypeCode_tk_TypeCode 
  107.   #define tk_Principal  TypeCode_tk_Principal 
  108.   #define tk_objref     TypeCode_tk_objref
  109.   #define tk_struct     TypeCode_tk_struct 
  110.   #define tk_union      TypeCode_tk_union 
  111.   #define tk_enum       TypeCode_tk_enum 
  112.   #define tk_string     TypeCode_tk_string
  113.   #define tk_sequence   TypeCode_tk_sequence 
  114.   #define tk_array      TypeCode_tk_array
  115.   #define tk_pointer    TypeCode_tk_pointer
  116.   #define tk_self       TypeCode_tk_self
  117.   #define tk_foreign    TypeCode_tk_foreign 
  118.  
  119. #ifndef SOM_TYPECODE
  120.   #define SOM_TYPECODE
  121.   typedef void * TypeCode;
  122. #endif /* SOM_TYPECODE */
  123.  
  124. /* CORBA 5.7, p.89 */
  125. typedef struct any {
  126.     TypeCode _type;
  127.     void   * _value;
  128.     } any;
  129.  
  130. /* Convenience macros for sequences */
  131. #define sequence(type) _IDL_SEQUENCE_ ## type
  132. #define SOM_SEQUENCE_NAME(name,type)\
  133.     struct name {\
  134.     unsigned long _maximum;\
  135.     unsigned long _length;\
  136.     type     *    _buffer;\
  137.     }
  138. #define SOM_SEQUENCE(type)\
  139.     struct {\
  140.     unsigned long _maximum;\
  141.     unsigned long _length;\
  142.     type     *    _buffer;\
  143.     }
  144.  
  145. #define SOM_SEQUENCE_TYPEDEF(type) typedef SOM_SEQUENCE(type) sequence(type)
  146. #define SOM_SEQUENCE_TYPEDEF_NAME(type, name) typedef SOM_SEQUENCE(type) name
  147.  
  148. /* per CORBA 5.10, p.91 */
  149. #ifndef _IDL_SEQUENCE_void_defined
  150. #define _IDL_SEQUENCE_void_defined
  151. SOM_SEQUENCE_TYPEDEF (void);
  152. #endif /* _IDL_SEQUENCE_void_defined */
  153.  
  154. /* SOM extensions for sequence manipulation */
  155. #define GENERIC_SEQUENCE        sequence(void)
  156. #define sequenceNew(type,max)   (*(sequence(type) *)tcSequenceNew(TC_##type,max))
  157. /* Note that sequenceNew macro assumes that a TypeCode constant of the  */
  158. /* form TC_xxx exists for any type xxx used as an argument              */
  159. #define sequenceElement(s,elem) (s._buffer[elem])
  160. #define sequenceLength(s)       (s._length)
  161. #define sequenceMaximum(s)      (s._maximum)
  162.  
  163. SOMEXTERN char * SOMLINK somExceptionId    (Environment *ev);
  164. SOMEXTERN void * SOMLINK somExceptionValue (Environment *ev);
  165. SOMEXTERN void   SOMLINK somExceptionFree  (Environment *ev);
  166. SOMEXTERN void   SOMLINK somSetException   (Environment *ev,
  167.     exception_type major, char *exception_name, void *params);
  168. SOMEXTERN Environment * SOMLINK somGetGlobalEnvironment (void);
  169.  
  170. /* Exception function names per CORBA 5.19, p.99 */
  171. #define exception_id    somExceptionId
  172. #define exception_value somExceptionValue
  173. #define exception_free  somExceptionFree
  174.  
  175. #ifndef    TRUE
  176. #define    TRUE 1
  177. #endif  /* TRUE */
  178. #ifndef    FALSE
  179. #define    FALSE 0
  180. #endif  /* FALSE */
  181.  
  182. #define SOM_InterfaceRepository\
  183.     (__get_somInterfaceRepository(SOMClassMgrObject))
  184.  
  185. /*  Convenience macros for manipulating environment structures
  186.  *
  187.  *  SOM_CreateLocalEnvironment returns a pointer to an Environment.
  188.  *  The other 3 macros all expect a single argument that is also
  189.  *  a pointer to an Environment.  Use the create/destroy forms for
  190.  *  a dynamic local environment and the init/uninit forms for a stack-based
  191.  *  local environment.
  192.  *
  193.  *  For example 
  194.  *
  195.  *      Environment *ev;
  196.  *      ev = SOM_CreateLocalEnvironment ();
  197.  *      ... Use ev in methods 
  198.  *      SOM_DestroyLocalEnvironment (ev);
  199.  *
  200.  *  or
  201.  *
  202.  *      Environment ev;
  203.  *      SOM_InitEnvironment (&ev);
  204.  *      ... Use &ev in methods
  205.  *      SOM_UninitEnvironment (&ev);
  206.  */
  207. #define SOM_CreateLocalEnvironment()\
  208.     ((Environment *) SOMCalloc (1, sizeof (Environment)))
  209. #define SOM_DestroyLocalEnvironment(ev)\
  210.     (somExceptionFree ((ev)), (somGetGlobalEnvironment() == (ev)) ?\
  211.     (void) 0 : SOMFree ((ev))) 
  212. #define SOM_InitEnvironment(ev)\
  213.     ((somGetGlobalEnvironment() == (ev)) ?\
  214.     (void *) NULL : memset (((char *)((ev))), 0, sizeof (Environment)))
  215. #define SOM_UninitEnvironment(ev)\
  216.     (somExceptionFree ((ev)))
  217.  
  218. #endif /* SOMCorba_h */
  219.