Next Previous Up Top Contents Index

7.10 The C structure

7.10.4 The C.Signature structure

This structure defines how external signature information is represented and provides operators for manipulating this information.

c_type

Type abbreviation

Specification:

type c_type

Description:

Representation for C-type information. Equivalent to Type.c_type.
c_signature

Type abbreviation

Specification:

type c_signature

Description:

This is an encapsulated abstract type for representing consistent collections of C declaration information for types, functions and variables.
c_decl

Datatype

Specification:

datatype c_decl = UNDEF_DECL | VAR_DECL of { name : name, ctype : c_type } | FUN_DECL of { name : name, source : c_type list, target : c_type } | TYPE_DECL of { name : name, defn : c_type, size : int } | CONST_DECL of { name : name, ctype : c_type }

Description:

This data type is used to represent C type declaration info and has the following structure:
UNDEF_DECL

This value is included as a default return value for queries rather than using option values (that is, NONE and SOME) for wrapping and unwrapping these values.

VAR_DECL of { name : name, ctype : c_type }

C variable declarations can be recorded in this form. The type information may be updated and modified.
FUN_DECL of { name : name, source : c_type list, target : c_type }

C function declaration information can be recorded in this form. The type information may be updated and modified.
TYPE_DECL of { name : name, defn : c_type, size : int }

C type information associated with a name (that is, typedef and struct/union/enum declarations) can be recorded in this form. The associated type and size information may be updated and modified.
CONST_DECL of { name : name, ctype : c_type }

Type information associated with simple literal #define constants can be recorded in this form.
newSignature

Function

Signature:

val newSignature : unit -> c_signature

Description:

This generates a fresh c_signature object.
lookupEntry

Function

Signature:

val lookupEntry : c_signature -> name -> c_decl

Description:

This takes a c_signature and a name and returns a declaration value having that name, if one exists.
defEntry

Function

Signature:

val defEntry : c_signature * c_decl -> unit

Description:

This updates a c_signature object by adding a given entry.
removeEntry

Function

Signature:

val removeEntry : c_signature * name -> unit

Description:

This removes the named entry from the given c_signature object.
showEntries

Function

Signature:

val showEntries : c_signature -> c_decl list

Description:

This yields a list of all the entries contained within a given c_signature.
normaliseType

Function

Signature:

val normaliseType : c_signature -> (c_type -> c_type)

Description:

This function takes a c_type object and ensures that size information is correct and up to date. Normalised types can have their sizes computed using sizeOf. See page 253.

MLWorks Reference Manual version 2.0 - 29 Jul 1998

Next Previous Up Top Contents Index

Generated with Harlequin WebMaker