home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / som30tk.zip / som30os2.zip / include / somtc.h < prev    next >
C/C++ Source or Header  |  1996-12-24  |  7KB  |  198 lines

  1. /*
  2.  *   COMPONENT_NAME: somi
  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. /* @(#) 2.13 src/somc/tc/somtc.h, somtc.funcs, som3.0 4/8/96 11:11:24 [12/24/96 07:39:17] */
  14.  
  15. /*
  16.  */
  17.  
  18. /*
  19.  * SOMTC.H
  20.  * Typedefs, structs, & enums in support of CORBA TypeCodes
  21.  * and sequences for use with SOM
  22.  */
  23.  
  24. #ifndef SOMTC_h
  25. #define SOMTC_h
  26.  
  27. #ifdef SOMTC_xh
  28.   #include <som.xh>
  29. #else
  30.   #include <som.h>
  31. #endif /* SOMTC_xh */
  32.  
  33. /*
  34.  * Operations supported by TypeCodes
  35.  *
  36.  */
  37. #ifndef _WIN32
  38. #ifdef __IBMC__
  39.   #pragma linkage (tcAlignment,       system)
  40.   #pragma linkage (tcCopy,       system)
  41.   #pragma linkage (tcEqual,       system)
  42.   #pragma linkage (tcFree,       system)
  43.   #pragma linkage (tcKind,       system)
  44.   #pragma linkage (tcNew,       system)
  45.   #pragma linkage (tcNewVL,       system)
  46.   #pragma linkage (tcParameter,    system)
  47.   #pragma linkage (tcParmCount,    system)
  48.   #pragma linkage (tcPrint,       system)
  49.   #pragma linkage (tcSetAlignment, system)
  50.   #pragma linkage (tcSize,       system)
  51.   #pragma linkage (tcSequenceNew,  system)
  52.   #pragma linkage (tcSeqFromListString, system)
  53.   #pragma linkage (tcSetZeroOriginEnum, system)        
  54.   #pragma linkage (tcGetZeroOriginEnum, system)    
  55. #endif /* __IBMC__ */
  56. #endif
  57.  
  58. SOMEXTERN short    SOMLINK tcAlignment (TypeCode t,Environment *ev);
  59. SOMEXTERN TypeCode SOMLINK tcCopy      (TypeCode t,Environment *ev);
  60. SOMEXTERN boolean  SOMLINK tcEqual     (TypeCode x,Environment *ev,TypeCode y);
  61. SOMEXTERN void       SOMLINK tcFree      (TypeCode t,Environment *ev);
  62. SOMEXTERN TCKind   SOMLINK tcKind      (TypeCode t,Environment *ev);
  63. SOMEXTERN long       SOMLINK tcParmCount (TypeCode t,Environment *ev);
  64. SOMEXTERN any       SOMLINK tcParameter (TypeCode t,Environment *ev,long index);
  65. SOMEXTERN void       SOMLINK tcPrint     (TypeCode t,Environment *ev);
  66. SOMEXTERN void       SOMLINK tcSetAlignment (TypeCode t,Environment *ev, short a);
  67. SOMEXTERN long       SOMLINK tcSize      (TypeCode t,Environment *ev);
  68.  
  69. SOMEXTERN long     SOMLINK tcSetZeroOriginEnum (TypeCode t, Environment *ev, boolean value);
  70. SOMEXTERN boolean  SOMLINK tcGetZeroOriginEnum (TypeCode t, Environment *ev);    
  71.  
  72.  
  73. /*
  74.  * Variable argument sequences for tcNew:
  75.  * (based on CORBA 7.6.1 Table 16 pp 139-140)
  76.  *
  77.  *  char     *interfaceId, *name, *mbrName, *enumId;
  78.  *  char     *structOrUnionName, *typeName, *context;
  79.  *  long     maxLength, length, labelFlag, labelValue;
  80.  *  TypeCode swTC, mbrTC, seqTC, arrayTC, ptrTC;
  81.  *  TCKind   tk_<xxx>;
  82.  *
  83.  *  tcNew (tk_<xxx>);
  84.  *  tcNew (tk_objref interfaceId);
  85.  *  tcNew (tk_string, maxLength);
  86.  *  tcNew (tk_sequence, seqTC, maxLength);
  87.  *  tcNew (tk_array, arrayTC, length);
  88.  *  tcNew (tk_pointer, ptrTC);                     <---[SOM extension]
  89.  *  tcNew (tk_self, structOrUnionName);            <---[SOM extension]
  90.  *  tcNew (tk_foreign, typeName, context, length); <---[SOM extension]
  91.  *
  92.  *  tcNew (tk_struct, name, mbrName, mbrTC, [...,] NULL);
  93.  *      [mbrName & TypeCode repeat as needed]
  94.  *
  95.  *  tcNew (tk_union, name, swTC, 
  96.  *      labelFlag, labelValue, mbrName, mbrTC, [...,] NULL);
  97.  *      [labelFlag, labelValue, mbrName & TypeCode repeat as needed]
  98.  *      labelFlag has the following meanings:
  99.  *        TCREGULAR_CASE - regular labelValue, cast as a long, follows,
  100.  *        TCDEFAULT_CASE - default case, with 0L for labelValue follows.
  101.  *
  102.  *  tcNew (tk_enum, name, enumId, [...,] NULL);
  103.  *    [enumId repeats as needed]
  104.  *
  105.  *  NULL is returned if tcNew detects an error or an attempt
  106.  *  to construct an illegal TypeCode
  107.  *
  108.  *  TypeCodes are assigned default alignment attributes appropriate 
  109.  *  to their constituent types.  The default alignment associated with  
  110.  *  the TypeCode as a whole is the greatest alignment associated with
  111.  *  any of its subordinate TypeCodes or primitive elements.  Note that
  112.  *  alignment information is platform-specific.  Default alignment
  113.  *  information can be overridden using the tcSetAlignment function,
  114.  *  where an argument value of zero means use default alignment, 
  115.  *  1 = byte alignment, n = alignment to an address boundary divisible 
  116.  *  by n.
  117.  *
  118.  *  TypeCodes created by tcNew do not hold references to any of the
  119.  *  passed strings, which are assumed to be owned by the caller.
  120.  *  This is not the case for the "TypeCode" arguments. They become
  121.  *  directly imbedded in the new TypeCode.  If you need to retain
  122.  *  ownership of passed TypeCodes, pass them using tcCopy.  Note that
  123.  *  TypeCode constants (TC_<xxx>) can be freely passed as arguments to
  124.  *  tcNew without using tcCopy.
  125.  *
  126.  *  All TypeCodes created by tcNew can be freed using tcFree.
  127.  */
  128. SOMEXTERN TypeCode SOMLINK tcNew (TCKind tag, ...);
  129.  
  130. /*  The following special variant on tcNew can be used when the
  131.  *  arguments are not known at compile-time and must be constructed
  132.  *  dynamically as a va_list.
  133.  */
  134. SOMEXTERN TypeCode SOMLINK tcNewVL (TCKind tag, va_list ap);
  135.  
  136. /*
  137.  *  Following constants used with tcNew to create union TypeCodes.
  138.  *  See calling sequences above.
  139.  */
  140. #define TCREGULAR_CASE 1L
  141. #define TCDEFAULT_CASE 2L
  142.  
  143. SOMEXTERN GENERIC_SEQUENCE * SOMLINK tcSequenceNew (TypeCode t,
  144.                             unsigned long max);
  145. #ifndef _IDL_SEQUENCE_string_defined
  146. #define _IDL_SEQUENCE_string_defined
  147. SOM_SEQUENCE_TYPEDEF (string);
  148. #endif /* _IDL_SEQUENCE_string_defined */
  149.  
  150. SOMEXTERN sequence(string) SOMLINK tcSeqFromListString (string s);
  151.  
  152. /* CORBA function names for TypeCodes, per CORBA 7.6.1, p.139 */
  153. #define TypeCode_kind          tcKind
  154. #define TypeCode_equal          tcEqual
  155. #define TypeCode_param_count  tcParmCount
  156. #define TypeCode_parameter    tcParameter
  157. /*
  158.  *  The following are IBM TypeCode extensions
  159.  */
  160. #define TypeCode_alignment    tcAlignment
  161. #define TypeCode_copy          tcCopy
  162. #define TypeCode_free          tcFree
  163. #define TypeCode_print          tcPrint
  164. #define TypeCode_setAlignment tcSetAlignment
  165. #define TypeCode_size          tcSize
  166. #define TypeCode_setZeroOriginEnum tcSetZeroOriginEnum
  167. #define TypeCode_getZeroOriginEnum tcGetZeroOriginEnum
  168.  
  169. #define TypeCodeNew           tcNew
  170. #define TypeCodeNewVL         tcNewVL
  171.  
  172. /* somVaBuf support */
  173.  
  174. #ifndef SOMVABUF
  175.   #define SOMVABUF
  176.   typedef somToken somVaBuf;
  177.  
  178. #ifndef _WIN32
  179. #ifdef __IBMC__
  180.   #pragma linkage(somVaBuf_create,    system)
  181.   #pragma linkage(somVaBuf_get_valist,    system)
  182.   #pragma linkage(somVaBuf_destroy,    system)
  183.   #pragma linkage(somVaBuf_add,        system)
  184.   #pragma linkage(somvalistGetTarget,    system)
  185.   #pragma linkage(somvalistSetTarget,    system)
  186. #endif
  187. #endif
  188.  
  189. SOMEXTERN void*  SOMLINK  somVaBuf_create(char *, int);
  190. SOMEXTERN void SOMLINK    somVaBuf_get_valist(void *, va_list *);
  191. SOMEXTERN void SOMLINK    somVaBuf_destroy(void *);
  192. SOMEXTERN long SOMLINK    somVaBuf_add(void * , void *, int);
  193. SOMEXTERN unsigned long SOMLINK   somvalistGetTarget(va_list);
  194. SOMEXTERN void   SOMLINK  somvalistSetTarget(va_list, void* );
  195. #endif /* SOMVABUF */
  196.  
  197. #endif /* SOMTC_h */
  198.