This structure provides support for representing C type information in a manipulable form as ML data.
enum_valueType abbreviation
type enum_value
string.
Type abbreviation
type tag
string.
Datatype
datatype pointer_kind = LOCAL_PTR | RELATIVE_PTR | REMOTE_PTR
LOCAL_PTRMachine address pointing within the associated store.
REMOTE_PTRMachine address pointing within user-accessible memory.
RELATIVE_PTRIndex value accessing location within associated store.
Datatype
datatype c_type =
VOID_TYPE | CHAR_TYPE | ...
c_type provides a representation of C type information accessible 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_TYPEunsigned char.
SIGNED_CHAR_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 unsigned short int.
UNSIGNED_INT_TYPE unsigned int.
UNSIGNED_LONG_TYPE unsigned long int.
FLOAT_TYPE This represents the C type float.
DOUBLE_TYPE This represents the C type double.
LONG_DOUBLE_TYPE long double.
STRING_TYPE of { length : int } 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 } typedef) within a C type.
POINTER_TYPE of { ctype : c_type, mode : pointer_kind ref } STRUCT_TYPE of { tag : tag option, fields : c_field list, size : int } UNION_TYPE of { tag : tag option, variants : c_variant list ref, size : int, current : c_variant } ARRAY_TYPE of { length : int, ctype : c_type } ENUM_TYPE of { tag : tag option, elems : enum_value list, card : int } Datatype
datatype c_variant = VARIANT of { name : name, ctype : c_type, size : int }
Datatype
datatype c_field = FIELD of { name : name, ctype : c_type, size : int, padding : int, offset : int }
Function
val sizeOf : c_type -> int
c_type object and fills in any size attributes that have not already been computed. Clearly, this requires named types to have had declarations filled in -- with failure if they are not.
Function
val equalType : c_type * c_type -> bool
c_type values can contain size attribute (which may be set to NONE), this function is used to make equality comparisons between two c_types which disregard the attribute components they may possess.
Some convenience functions for building compound c_type objects:
Function
val structType : string * (string * c_type) list -> c_type
Function
val unionType : string * (string * c_type) list -> c_type
Function
typeNameFunction
enumTypeFunction