7.10 The C structure

c_type

Datatype

Specification:
datatype c_type =
VOID_TYPE | CHAR_TYPE | ...

Description:

The ML type c_type provides a representation of C type information accessable as an ML value. These values are used to provide information on how to interpret the value parts of c_object objects used to represent foreign data.

VOID_TYPE
This represents the C type void. Its size is zero bytes.

CHAR_TYPE
This represents the C type char. Its size is 1 byte. It may be associated with either signed or unsigned chars by the particular C compiler used.

UNSIGNED_CHAR_TYPE

This represents the C type unsigned char.

SIGNED_CHAR_TYPE

This represents the C type signed char.

SHORT_TYPE
This represents the C type short int.

INT_TYPE
This represents the C type int.

LONG_TYPE
This represents the C type long int.

UNSIGNED_SHORT_TYPE

This represents the C type unsigned short int.

UNSIGNED_INT_TYPE

This represents the C type unsigned int.

UNSIGNED_LONG_TYPE

This represents the C type unsigned long int.

FLOAT_TYPE
This represents the C type float.

DOUBLE_TYPE
This represents the C type double.

LONG_DOUBLE_TYPE

This represents the C type long double.

STRING_TYPE of { length : int }

This represents C string type char* where each string has an explicit amount of storage allocated for it. This length should include room for the null byte sentinel.

TYPENAME of { name : name, defn : c_type, size : int }

This represents the use of a named type (that is, a name created with typedef) within a C type.

POINTER_TYPE of { ctype : c_type, mode : pointer_kind ref }

This represents ANSI C's idea of typed pointers. The additional pointer mode information concerns how ML encodes and treats this pointer information. In particular, 'relative' pointers are simply small indices which make indirection within a store workspace more direct and efficient. The representation also caters for 'remote' pointers which can refer to arbitrary places in memory, and 'local' pointers are remote pointers which are known to refer to places in the associated store workspace.

STRUCT_TYPE of { tag : tag option, fields : c_field list, size : int }

This represents the structured record type in C. Such types may be tagged or untagged.

UNION_TYPE of { tag : tag option, variants : c_variant list ref, size : int, current : c_variant }

This represents the union type in C. Such types may be tagged or untagged.

ARRAY_TYPE of { length : int, ctype : c_type }

This represents the array type in C.

ENUM_TYPE of { tag : tag option, elems : enum_value list, card : int }

This represents (simple) enumerated types as provided by C. Such types may be tagged or untagged.


MLWorks Reference Manual (version 1.0) - 3 DEC 1996

Generated with Harlequin WebMaker