TypeCode kind
This function categorizes the abstract data type described by a TypeCode.
Contents
Syntax
TypeCode tc; Environment *env; TCKind rc; rc = TypeCode_kind(tc, env);
Parameters
- tc (TypeCode)
- The TypeCode whose TCKind categorization is requested.
- env (Environment *)
- A pointer to an Environment structure.
- The CORBA standard mandates the use of this structure as a standard way to return exception information when an error condition is detected.
Returns
- rc (TCKind)
- Returns one of the enumerators listed in the TCKind enumeration shown below. No exceptions are raised by this function.
enum TCKind { tk_null, tk_void, tk_short, tk_long, tk_ushort, tk_ulong, tk_float, tk_double, tk_boolean, tk_char, tk_octet, tk_any, tk_TypeCode, tk_Principal, tk_objref, tk_struct, tk_union, tk_enum, tk_string, tk_sequence, tk_array, tk_pointer, tk_self, tk_foreign };
Remarks
The TypeCode_kind function can be used to classify a TypeCode into one of the categories listed in the TCKind enumeration. Based on the "kind" classification, a TypeCode may contain 0 or more additional parameters to fully describe the underlying data type.
The following table indicates the number and function of these additional parameters. TCKind entries not listed in the table are basic data types and do not have any additional parameters. The designation "N" refers to the number of members in a struct or union, or the number of enumerators in an enum.
TCKIND | PARAMETERS | TYPE | FUNCTION |
---|---|---|---|
TK_OBJREF | 1 | STRING | The ID of the corresponding INTERFACEDEF in the Interface Repository |
TK_STRUCT | 2N+1 | STRING | The name of the STRUCT. |
───── next 2 repeat for each member ───── | |||
STRING | The name of the STRUCT member. | ||
TYPECODE | The type of the STRUCT member. | ||
TK_UNION | 3N+2 | STRING | The name of the UNION. |
TYPECODE | The type of the discriminator. | ||
───── next 3 repeat for each member ───── | |||
LONG | The label value | ||
STRING | The name of the member. | ||
TYPECODE | The type of the member. | ||
TK_ENUM | N+1 | STRING | The name of the ENUM. |
─── next repeats for each enumerator ──── | |||
STRING | The name of the enumerator. | ||
TK_STRING | 1 | LONG | The maximum string length or 0. |
TK_SEQUENCE | 2 | TYPECODE | The type of element in the sequence. |
LONG | The maximum number of elements or 0. | ||
TK_ARRAY | 2 | TYPECODE | The type of element in the ARRAY. |
LONG | The maximum number of elements. | ||
TK_POINTER* | 1 | TYPECODE | The type of the referenced datum. |
TK_SELF* | 1 | STRING | The name of the referenced enclosing STRUCT or UNION. |
TK_FOREIGN* | 3 | STRING | The name of the foreign type. |
STRING | The implementation context. | ||
LONG | The size of an instance. | ||
* The TCKIND values TK_POINTER, TK_SELF, and TK_FOREIGN are SOM-unique extensions to the CORBA standard. They are provided to permit TYPECODES to describe types that cannot be expressed in standard IDL.
The TK_POINTER TYPECODE contains only one parameter-a TYPECODE which describes the data type that the pointer references. The TK_SELF TYPECODE is used to describe a "self-referential" structure or union without introducing unbounded recursion in the TYPECODE. For example, the following C struct: struct node { long count; struct node *next; }; could be described with a TYPECODE created as follows: TypeCode tcForNode; tcForNode = TypeCodeNew (tk_struct, "node", "count", TypeCodeNew (tk_long), "next", TypeCodeNew (tk_pointer, TypeCodeNew (tk_self, "node"))); The TK_FOREIGN TYPECODE provides a more general escape mechanism, allowing TYPECODEs to be created that partially describe non-IDL types. Since these foreign TYPECODEs carry only a partial description of a type, the "implementation context" parameter can be used by a non-IDL execution environment to recognize other types that are known or understood in that environment. See the section entitled "Using the tk_foreign TypeCode" in Chapter 7 of the SOM Toolkit User's Guide for more information about using foreign TYPECODES in SOM IDL files. Note that the use of self-referential structures, pointers, or foreign types is beyond the scope of the CORBA standard, and may result in a loss of portability or distributability in client code. |
Original Class
- TypeDef
Related Information
- TypeCodeNew
- TypeCode_alignment
- TypeCode_equal
- TypeCode_param_count
- TypeCode_parameter
- TypeCode_copy
- TypeCode_free
- TypeCode_print
- TypeCode_setAlignment
- TypeCode_size
Parameters
- tc (TypeCode)
- The TypeCode to be examined.
- env (Environment *)
- A pointer to an Environment structure. The CORBA standard mandates the use of this structure as a standard way to return exception information when an error condition is detected.
Return
rc
Remarks
The TypeCode_print function can be used during program debugging to inspect the contents of a TypeCode. It prints (in a human-readable format) all of the information contained in the TypeCode. The format of the information shown by TypeCode_print is the same form that could be used by a C programmer to code the corresponding TypeCodeNew function call to create the TypeCode.
This function is a SOM-unique extension to the CORBA standard.
Related Information
- TypeCodeNew
- TypeCode_alignment
- TypeCode_equal
- TypeCode_kind
- TypeCode_param_count
- TypeCode_parameter
- TypeCode_copy
- TypeCode_free
- TypeCode_size
- TypeCode_setAlignment