home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / tolkit45.zip / os2tk45 / som / include / somtc.h < prev    next >
C/C++ Source or Header  |  1999-02-22  |  7KB  |  194 lines

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