Next Previous Up Top Contents Index

7.10 The C structure

7.10.1 The C.Structure structure

This structure provides facilities for loading and dynamically linking foreign code for use with the C data model.

c_structure

Type abbreviation

Specification:

type c_structure

Description:

Objects of type c_structure are containers of foreign code. Each c_structure object is created as a result of dynamically linking foreign code from a file.
No attempt is made at present to cache this code when images are saved, and so it would have to be restored when an image is restarted. Fortunately, this is made trivial by using the tools provided via the Aliens structure. See "The Aliens structure" on page 241.
load_mode

Datatype

Specification:

datatype load_mode = IMMEDIATE_LOAD | DEFERRED_LOAD

Description:

When foreign code is loaded, the dynamic linking of that code may occur immediately (at load time) or later (at call time). These options are reflected here by:
IMMEDIATE_LOAD

Link foreign code immediately.

DEFERRED_LOAD

Link foreign code at first call to the library.

loadObjectFile

Function

Signature:

val loadObjectFile : filename * load_mode -> c_structure

Description:

This function generates a c_structure by dynamically linking foreign code associated with the specified file, in accordance with the given load_mode.
fileInfo

Function

Signature:

val fileInfo : c_structure -> (filename * load_mode)

Description:

This function obtains both the filename and the load_mode used to create the c_structure.
filesLoaded

Function

Signature:

val filesLoaded : unit -> filename list

Description:

This yields a list of all foreign code files loaded so far.
symbols

Function

Signature:

val symbols : c_structure -> name list

Description:

Extracts symbol table information concerning the foreign code contained within a given c_structure. This info might indicate the name of the object, what kind of object it is, and even a relocatable address associated with the code.
value_type

Datatype

Specification:

datatype value_type = CODE_VALUE | VAR_VALUE | UNKNOWN_VALUE

Description:

This datatype provides a coarse classification of foreign code objects.
CODE_VALUE

Object appears to be functional code of some description.

VAR_VALUE

Object appears to be a (visible) variable containing foreign data.

UNKNOWN_VALUE

Object cannot be classified, though it could be either of the above.

symbolInfo

Function

Signature:

val symbolInfo : c_structure * name -> value_type

Description:

This function attempts to classify named foreign code objects according to the scheme given in value_type, above.

MLWorks Reference Manual version 2.0 - 29 Jul 1998

Next Previous Up Top Contents Index

Generated with Harlequin WebMaker