home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / dtswps.zip / DTSFILES.ZIP / SOMCORBA.H < prev    next >
C/C++ Source or Header  |  1996-06-24  |  8KB  |  243 lines

  1. /*
  2.  *   COMPONENT_NAME: somk
  3.  *
  4.  *   ORIGINS: 27
  5.  *
  6.  *
  7.  *    25H7912  (C)  COPYRIGHT International Business Machines Corp. 1992,1994,1996 
  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. /* @(#) somk/somcorba.h 2.10.1.3 12/26/95 16:48:02 [6/24/96 08:12:08] */
  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. /*
  48.  * Generated SOM usage bindings for IDL enums start at 1, but
  49.  * somcorba.h is not generated, and the original SOM 2.0 somcorba.h
  50.  * used C enum typedefs to define the exception_type and
  51.  * completion_status enumerations.  As a result, to maintain backwards
  52.  * binary compatibility, the mapping for these enums starts at 0
  53.  * (which is also the mapping specified by CORBA 2.0).
  54.  *
  55.  * The additional value enum_name_MAX is needed to ensure that all
  56.  * compilers will allocate 4 bytes for these enums.  This technique
  57.  * for representing IDL enums is used in the CORBA 2.0 * C++ mappings.
  58.  */
  59. typedef enum exception_type {NO_EXCEPTION, USER_EXCEPTION, SYSTEM_EXCEPTION,
  60.     exception_type_MAX = 2147483647       /* ensure mapped as 4 bytes */
  61. } exception_type;
  62. typedef enum completion_status {YES, NO, MAYBE,
  63.     completion_status_MAX = 2147483647    /* ensure mapped as 4 bytes */
  64. } completion_status;
  65.  
  66. typedef struct StExcep {
  67.     unsigned long minor;
  68.     completion_status completed;
  69. } StExcep;
  70.  
  71. typedef struct Environment {
  72.     exception_type             _major;
  73.     struct {
  74.         char *                 _exception_name;
  75.         void *                 _params;
  76.     } exception;
  77.     void *                     _somdAnchor;
  78. } Environment;
  79.  
  80. /* CORBA 7.6.1, p.139 plus 5.7, p.89 enum Data Type Mapping */
  81. typedef unsigned long TCKind;
  82.   #define TypeCode_tk_null      1
  83.   #define TypeCode_tk_void      2
  84.   #define TypeCode_tk_short     3
  85.   #define TypeCode_tk_long      4
  86.   #define TypeCode_tk_ushort    5
  87.   #define TypeCode_tk_ulong     6
  88.   #define TypeCode_tk_float     7
  89.   #define TypeCode_tk_double    8
  90.   #define TypeCode_tk_boolean   9
  91.   #define TypeCode_tk_char      10
  92.   #define TypeCode_tk_octet     11
  93.   #define TypeCode_tk_any       12
  94.   #define TypeCode_tk_TypeCode  13
  95.   #define TypeCode_tk_Principal 14
  96.   #define TypeCode_tk_objref    15
  97.   #define TypeCode_tk_struct    16
  98.   #define TypeCode_tk_union     17
  99.   #define TypeCode_tk_enum      18
  100.   #define TypeCode_tk_string    19
  101.   #define TypeCode_tk_sequence  20
  102.   #define TypeCode_tk_array     21
  103.  
  104.   #define TypeCode_tk_pointer   101 /* SOM extension */
  105.   #define TypeCode_tk_self      102 /* SOM extension */
  106.   #define TypeCode_tk_foreign   103 /* SOM extension */
  107.  
  108. /* Short forms of tk_<x> enumerators */
  109.  
  110.   #define tk_null       TypeCode_tk_null
  111.   #define tk_void       TypeCode_tk_void
  112.   #define tk_short      TypeCode_tk_short
  113.   #define tk_long       TypeCode_tk_long
  114.   #define tk_ushort     TypeCode_tk_ushort
  115.   #define tk_ulong      TypeCode_tk_ulong
  116.   #define tk_float      TypeCode_tk_float
  117.   #define tk_double     TypeCode_tk_double
  118.   #define tk_boolean    TypeCode_tk_boolean
  119.   #define tk_char       TypeCode_tk_char
  120.   #define tk_octet      TypeCode_tk_octet
  121.   #define tk_any        TypeCode_tk_any
  122.   #define tk_TypeCode   TypeCode_tk_TypeCode
  123.   #define tk_Principal  TypeCode_tk_Principal
  124.   #define tk_objref     TypeCode_tk_objref
  125.   #define tk_struct     TypeCode_tk_struct
  126.   #define tk_union      TypeCode_tk_union
  127.   #define tk_enum       TypeCode_tk_enum
  128.   #define tk_string     TypeCode_tk_string
  129.   #define tk_sequence   TypeCode_tk_sequence
  130.   #define tk_array      TypeCode_tk_array
  131.   #define tk_pointer    TypeCode_tk_pointer
  132.   #define tk_self       TypeCode_tk_self
  133.   #define tk_foreign    TypeCode_tk_foreign
  134.  
  135. #ifndef SOM_TYPECODE
  136.   #define SOM_TYPECODE
  137.   typedef void * TypeCode;
  138. #endif /* SOM_TYPECODE */
  139.  
  140. /* CORBA 5.7, p.89 */
  141. typedef struct any {
  142.     TypeCode _type;
  143.     void   * _value;
  144.     } any;
  145.  
  146. /* Convenience macros for sequences */
  147. #define sequence(type) _IDL_SEQUENCE_ ## type
  148. #define SOM_SEQUENCE_NAME(name,type)\
  149.     struct name {\
  150.         unsigned long _maximum;\
  151.         unsigned long _length;\
  152.         type     *    _buffer;\
  153.     }
  154. #define SOM_SEQUENCE(type)\
  155.     struct {\
  156.         unsigned long _maximum;\
  157.         unsigned long _length;\
  158.         type     *    _buffer;\
  159.     }
  160.  
  161. #define SOM_SEQUENCE_TYPEDEF(type) typedef SOM_SEQUENCE(type) sequence(type)
  162. #define SOM_SEQUENCE_TYPEDEF_NAME(type, name) typedef SOM_SEQUENCE(type) name
  163.  
  164. /* per CORBA 5.10, p.91 */
  165. #ifndef _IDL_SEQUENCE_void_defined
  166. #define _IDL_SEQUENCE_void_defined
  167. SOM_SEQUENCE_TYPEDEF (void);
  168. #endif /* _IDL_SEQUENCE_void_defined */
  169.  
  170. /* SOM extensions for sequence manipulation */
  171. #define GENERIC_SEQUENCE        sequence(void)
  172. #define sequenceNew(type,max)   (*(sequence(type) *)tcSequenceNew(TC_##type,max))
  173. /* Note that sequenceNew macro assumes that a TypeCode constant of the  */
  174. /* form TC_xxx exists for any type xxx used as an argument              */
  175. #define sequenceElement(s,elem) ((s)._buffer[elem])
  176. #define sequenceLength(s)       ((s)._length)
  177. #define sequenceMaximum(s)      ((s)._maximum)
  178.  
  179. #ifdef __IBMC__
  180.   #pragma linkage (somExceptionId,             system)
  181.   #pragma linkage (somExceptionValue,          system)
  182.   #pragma linkage (somExceptionFree,           system)
  183.   #pragma linkage (somSetException,            system)
  184.   #pragma linkage (somGetGlobalEnvironment,    system)
  185. #endif /* __IBMC__ */
  186.  
  187. SOMEXTERN char * SOMLINK somExceptionId    (Environment *ev);
  188. SOMEXTERN void * SOMLINK somExceptionValue (Environment *ev);
  189. SOMEXTERN void   SOMLINK somExceptionFree  (Environment *ev);
  190. SOMEXTERN void   SOMLINK somSetException   (Environment *ev,
  191.     exception_type major, char *exception_name, void *params);
  192. SOMEXTERN Environment * SOMLINK somGetGlobalEnvironment (void);
  193.  
  194. /* Exception function names per CORBA 5.19, p.99 */
  195. #define exception_id    somExceptionId
  196. #define exception_value somExceptionValue
  197. #define exception_free  somExceptionFree
  198.  
  199. #ifndef    TRUE
  200. #define    TRUE 1
  201. #endif  /* TRUE */
  202. #ifndef    FALSE
  203. #define    FALSE 0
  204. #endif  /* FALSE */
  205.  
  206. #define SOM_InterfaceRepository\
  207.     (__get_somInterfaceRepository(SOMClassMgrObject))
  208.  
  209. /*  Convenience macros for manipulating environment structures
  210.  *
  211.  *  SOM_CreateLocalEnvironment returns a pointer to an Environment.
  212.  *  The other 3 macros all expect a single argument that is also
  213.  *  a pointer to an Environment.  Use the create/destroy forms for
  214.  *  a dynamic local environment and the init/uninit forms for a stack-based
  215.  *  local environment.
  216.  *
  217.  *  For example
  218.  *
  219.  *      Environment *ev;
  220.  *      ev = SOM_CreateLocalEnvironment ();
  221.  *      ... Use ev in methods
  222.  *      SOM_DestroyLocalEnvironment (ev);
  223.  *
  224.  *  or
  225.  *
  226.  *      Environment ev;
  227.  *      SOM_InitEnvironment (&ev);
  228.  *      ... Use &ev in methods
  229.  *      SOM_UninitEnvironment (&ev);
  230.  */
  231. #define SOM_CreateLocalEnvironment()\
  232.     ((Environment *) SOMCalloc (1, sizeof (Environment)))
  233. #define SOM_DestroyLocalEnvironment(ev)\
  234.     (somExceptionFree ((ev)), (somGetGlobalEnvironment() == (ev)) ?\
  235.         (void) 0 : SOMFree ((ev)))
  236. #define SOM_InitEnvironment(ev)\
  237.     ((somGetGlobalEnvironment() == (ev)) ?\
  238.         (void *) NULL : memset (((char *)((ev))), 0, sizeof (Environment)))
  239. #define SOM_UninitEnvironment(ev)\
  240.     (somExceptionFree ((ev)))
  241.  
  242. #endif /* SOMCorba_h */
  243.