On this page:
ffi-obj
ffi-obj?
ffi-obj-lib
ffi-obj-name
ctype-basetype
ctype-scheme->c
ctype-c->scheme
ffi-call
ffi-callback
ffi-callback?
Version: 4.1

7 Unexported Primitive Functions

Parts of the scheme/foreign library are implemented by the MzScheme built-in '#%foreign module. The '#%foreign module is not intended for direct use, but it exports the following procedures. If you find any of these useful, please let us know.

(ffi-obj objname lib)  any

  objname : (or/c string? bytes? symbol?)

  lib : (or/c ffi-lib? path-string? false/c)

Pulls out a foreign object from a library, returning a Scheme value that can be used as a pointer. If a name is provided instead of a foreign-library value, ffi-lib is used to create a library object.

(ffi-obj? x)  boolean?

  x : any/c

(ffi-obj-lib obj)  ffi-lib?

  obj : ffi-obj?

(ffi-obj-name obj)  string?

  obj : ffi-obj?

A predicate for objects returned by ffi-obj, and accessor functions that return its corresponding library object and name. These values can also be used as C pointer objects.

(ctype-basetype type)  (or/c ctype? false/c)

  type : ctype?

(ctype-scheme->c type)  procedure?

  type : ctype?

(ctype-c->scheme type)  procedure?

  type : ctype?

Accessors for the components of a C type object, made by make-ctype. The ctype-basetype selector returns #f for primitive types (including cstruct types).

(ffi-call ptr in-types out-type)  any

  ptr : any/c

  in-types : (listof ctype?)

  out-type : ctype?

The primitive mechanism that creates Scheme “callout” values. The given ptr (any pointer value, including ffi-obj values) is wrapped in a Scheme-callable primitive function that uses the types to specify how values are marshaled.

(ffi-callback proc in-types out-type)  ffi-callback?

  proc : any/c

  in-types : any/c

  out-type : any/c

The symmetric counterpart of ffi-call. It receives a Scheme procedure and creates a callback object, which can also be used as a pointer. This object can be used as a C-callable function, which invokes proc using the types to specify how values are marshaled.

(ffi-callback? x)  boolean?

  x : any/c

A predicate for callback values that are created by ffi-callback.