home *** CD-ROM | disk | FTP | other *** search
/ Power GUI Programming with VisualAge C++ / powergui.iso / trialva / ibmcppw / include / somtc.h < prev    next >
Encoding:
C/C++ Source or Header  |  1996-01-24  |  5.7 KB  |  159 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. /* %Z% %I% %W% %G% %U% [%H% %T%] */
  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. SOMEXTERN short    SOMLINK tcAlignment (TypeCode t,Environment *ev);
  38. SOMEXTERN TypeCode SOMLINK tcCopy      (TypeCode t,Environment *ev);
  39. SOMEXTERN boolean  SOMLINK tcEqual     (TypeCode x,Environment *ev,TypeCode y);
  40. SOMEXTERN void     SOMLINK tcFree      (TypeCode t,Environment *ev);
  41. SOMEXTERN TCKind   SOMLINK tcKind      (TypeCode t,Environment *ev);
  42. SOMEXTERN long     SOMLINK tcParmCount (TypeCode t,Environment *ev);
  43. SOMEXTERN any      SOMLINK tcParameter (TypeCode t,Environment *ev,long index);
  44. SOMEXTERN void     SOMLINK tcPrint     (TypeCode t,Environment *ev);
  45. SOMEXTERN void     SOMLINK tcSetAlignment (TypeCode t,Environment *ev, short a);
  46. SOMEXTERN long     SOMLINK tcSize      (TypeCode t,Environment *ev);
  47.  
  48. /*
  49.  * Variable argument sequences for tcNew:
  50.  * (based on CORBA 7.6.1 Table 16 pp 139-140)
  51.  *
  52.  *  char     *interfaceId, *name, *mbrName, *enumId;
  53.  *  char     *structOrUnionName, *typeName, *context;
  54.  *  long     maxLength, length, labelFlag, labelValue;
  55.  *  TypeCode swTC, mbrTC, seqTC, arrayTC, ptrTC;
  56.  *  TCKind   tk_<xxx>;
  57.  *
  58.  *  tcNew (tk_<xxx>);
  59.  *  tcNew (tk_objref interfaceId);
  60.  *  tcNew (tk_string, maxLength);
  61.  *  tcNew (tk_sequence, seqTC, maxLength);
  62.  *  tcNew (tk_array, arrayTC, length);
  63.  *  tcNew (tk_pointer, ptrTC);                     <---[SOM extension]
  64.  *  tcNew (tk_self, structOrUnionName);            <---[SOM extension]
  65.  *  tcNew (tk_foreign, typeName, context, length); <---[SOM extension]
  66.  *
  67.  *  tcNew (tk_struct, name, mbrName, mbrTC, [...,] NULL);
  68.  *      [mbrName & TypeCode repeat as needed]
  69.  *
  70.  *  tcNew (tk_union, name, swTC, 
  71.  *      labelFlag, labelValue, mbrName, mbrTC, [...,] NULL);
  72.  *      [labelFlag, labelValue, mbrName & TypeCode repeat as needed]
  73.  *      labelFlag has the following meanings:
  74.  *          TCREGULAR_CASE - regular labelValue, cast as a long, follows,
  75.  *          TCDEFAULT_CASE - default case, with 0L for labelValue follows.
  76.  *
  77.  *  tcNew (tk_enum, name, enumId, [...,] NULL);
  78.  *      [enumId repeats as needed]
  79.  *
  80.  *  NULL is returned if tcNew detects an error or an attempt
  81.  *  to construct an illegal TypeCode
  82.  *
  83.  *  TypeCodes are assigned default alignment attributes appropriate 
  84.  *  to their constituent types.  The default alignment associated with  
  85.  *  the TypeCode as a whole is the greatest alignment associated with
  86.  *  any of its subordinate TypeCodes or primitive elements.  Note that
  87.  *  alignment information is platform-specific.  Default alignment
  88.  *  information can be overridden using the tcSetAlignment function,
  89.  *  where an argument value of zero means use default alignment, 
  90.  *  1 = byte alignment, n = alignment to an address boundary divisible 
  91.  *  by n.
  92.  *
  93.  *  TypeCodes created by tcNew do not hold references to any of the
  94.  *  passed strings, which are assumed to be owned by the caller.
  95.  *  This is not the case for the "TypeCode" arguments. They become
  96.  *  directly imbedded in the new TypeCode.  If you need to retain
  97.  *  ownership of passed TypeCodes, pass them using tcCopy.  Note that
  98.  *  TypeCode constants (TC_<xxx>) can be freely passed as arguments to
  99.  *  tcNew without using tcCopy.
  100.  *
  101.  *  All TypeCodes created by tcNew can be freed using tcFree.
  102.  */
  103. SOMEXTERN TypeCode SOMLINK tcNew (TCKind tag, ...);
  104.  
  105. /*  The following special variant on tcNew can be used when the
  106.  *  arguments are not known at compile-time and must be constructed
  107.  *  dynamically as a va_list.
  108.  */
  109. SOMEXTERN TypeCode SOMLINK tcNewVL (TCKind tag, va_list ap);
  110.  
  111. /*
  112.  *  Following constants used with tcNew to create union TypeCodes.
  113.  *  See calling sequences above.
  114.  */
  115. #define TCREGULAR_CASE 1L
  116. #define TCDEFAULT_CASE 2L
  117.  
  118. SOMEXTERN GENERIC_SEQUENCE * SOMLINK tcSequenceNew (TypeCode t,
  119.                             unsigned long max);
  120. #ifndef _IDL_SEQUENCE_string_defined
  121. #define _IDL_SEQUENCE_string_defined
  122. SOM_SEQUENCE_TYPEDEF (string);
  123. #endif /* _IDL_SEQUENCE_string_defined */
  124.  
  125. SOMEXTERN sequence(string) SOMLINK tcSeqFromListString (string s);
  126.  
  127. /* CORBA function names for TypeCodes, per CORBA 7.6.1, p.139 */
  128. #define TypeCode_kind         tcKind
  129. #define TypeCode_equal        tcEqual
  130. #define TypeCode_param_count  tcParmCount
  131. #define TypeCode_parameter    tcParameter
  132. /*
  133.  *  The following are IBM TypeCode extensions
  134.  */
  135. #define TypeCode_alignment    tcAlignment
  136. #define TypeCode_copy         tcCopy
  137. #define TypeCode_free         tcFree
  138. #define TypeCode_print        tcPrint
  139. #define TypeCode_setAlignment tcSetAlignment
  140. #define TypeCode_size         tcSize
  141.  
  142. #define TypeCodeNew           tcNew
  143. #define TypeCodeNewVL         tcNewVL
  144.  
  145. /* somVaBuf support - added for 18274 */
  146. #ifndef SOMVABUF
  147. #define SOMVABUF
  148. typedef somToken somVaBuf;
  149.  
  150. SOMEXTERN void* SOMLINK  somVaBuf_create(char *, int);
  151. SOMEXTERN void  SOMLINK  somVaBuf_get_valist(void *, va_list *);
  152. SOMEXTERN void  SOMLINK  somVaBuf_destroy(void *);
  153. SOMEXTERN long  SOMLINK  somVaBuf_add(void * , char *, int);
  154. SOMEXTERN void  SOMLINK  somvalistSetTarget(va_list, unsigned long);
  155. SOMEXTERN unsigned long SOMLINK  somvalistGetTarget(va_list);
  156. #endif /* SOMVABUF */
  157.  
  158. #endif /* SOMTC_h */
  159.