The uffi Reference Manual

Next: , Previous: , Up: (dir)   [Contents][Index]

The uffi Reference Manual

This is the uffi Reference Manual, version 2.0.0, generated automatically by Declt version 4.0 beta 2 "William Riker" on Mon Aug 15 06:05:58 2022 GMT+0.

Table of Contents


1 Introduction

Package:  UFFI (Universal Foreign Language Interface)
Web site: http://uffi.kpe.io
Author:   Kevin M. Rosenberg


BRIEF DESCRIPTION
-----------------
uffi is a Common Lisp package for interfacing C-language compatible
libraries. Every Common Lisp implementation has a method for
interfacing to such libraries. Unfortunately, these method vary widely
amongst implementations. uffi gathers a common subset of functionality
between Common Lisp implementations. uffi wraps this common subset of
functionality into it's own syntax and provides macro translation of
uffi features into the specific syntax of supported Common Lisp
implementations.

Currently, AllegroCL (Linux and Microsoft Windows), Lispworks (Linux
and Microsoft Windows), CMUCL, SBCL, and OpenMCL are supported.




2 Systems

The main system appears first, followed by any subsystem dependency.


Previous: , Up: Systems   [Contents][Index]

2.1 uffi

Universal Foreign Function Library for Common Lisp

Maintainer

Kevin M. Rosenberg <kmr@debian.org>

Author

Kevin Rosenberg <kevin@rosenberg.net>

License

Lessor Lisp General Public License

Long Description

UFFI provides a universal foreign function interface (FFI) for Common Lisp. UFFI supports CMUCL, Lispworks, and AllegroCL.

Version

2.0.0

Source

uffi.asd.

Child Component

src (module).


Next: , Previous: , Up: The uffi Reference Manual   [Contents][Index]

3 Modules

Modules are listed depth-first from the system components tree.


Previous: , Up: Modules   [Contents][Index]

3.1 uffi/src

Source

uffi.asd.

Parent Component

uffi (system).

Child Components

4 Files

Files are sorted by type and then listed depth-first from the systems components trees.


Previous: , Up: Files   [Contents][Index]

4.1 Lisp


Next: , Previous: , Up: Lisp   [Contents][Index]

4.1.1 uffi/uffi.asd

Source

uffi.asd.

Parent Component

uffi (system).

ASDF Systems

uffi.

Packages

uffi-system.


Next: , Previous: , Up: Lisp   [Contents][Index]

4.1.2 uffi/src/package.lisp

Source

uffi.asd.

Parent Component

src (module).

Packages

uffi.


4.1.3 uffi/src/i18n.lisp

Dependency

package.lisp (file).

Source

uffi.asd.

Parent Component

src (module).

Public Interface
Internals

4.1.4 uffi/src/primitives.lisp

Dependency

i18n.lisp (file).

Source

uffi.asd.

Parent Component

src (module).

Public Interface
Internals

4.1.5 uffi/src/objects.lisp

Dependency

primitives.lisp (file).

Source

uffi.asd.

Parent Component

src (module).

Public Interface

4.1.6 uffi/src/aggregates.lisp

Dependency

primitives.lisp (file).

Source

uffi.asd.

Parent Component

src (module).

Public Interface
Internals

4.1.7 uffi/src/strings.lisp

Dependencies
Source

uffi.asd.

Parent Component

src (module).

Public Interface
Internals

4.1.8 uffi/src/functions.lisp

Dependency

primitives.lisp (file).

Source

uffi.asd.

Parent Component

src (module).

Public Interface

def-function (macro).

Internals

4.1.9 uffi/src/libraries.lisp

Dependency

package.lisp (file).

Source

uffi.asd.

Parent Component

src (module).

Public Interface
Internals

4.1.10 uffi/src/os.lisp

Dependency

package.lisp (file).

Source

uffi.asd.

Parent Component

src (module).

Public Interface

5 Packages

Packages are listed by definition order.


Next: , Previous: , Up: Packages   [Contents][Index]

5.1 uffi

Source

package.lisp.

Use List

common-lisp.

Public Interface
Internals

Previous: , Up: Packages   [Contents][Index]

5.2 uffi-system

Source

uffi.asd.

Use List
  • asdf/interface.
  • common-lisp.

6 Definitions

Definitions are sorted by export status, category, package, and then by lexicographic order.


Next: , Previous: , Up: Definitions   [Contents][Index]

6.1 Public Interface


Next: , Previous: , Up: Public Interface   [Contents][Index]

6.1.1 Special variables

Special Variable: *default-foreign-encoding*

Normalized name of default external character format to use
for foreign string conversions. nil means use implementation default encoding.

Package

uffi.

Source

i18n.lisp.

Special Variable: *foreign-encodings*

List of normalized names of external formats support by underlying implementation.

Package

uffi.

Source

i18n.lisp.

Special Variable: +null-cstring-pointer+
Package

uffi.

Source

strings.lisp.


6.1.2 Macros

Macro: allocate-foreign-object (type &optional size)

Allocates an instance of TYPE. If size is specified, then allocate an array of TYPE with size SIZE. The TYPE parameter is evaluated.

Package

uffi.

Source

objects.lisp.

Macro: allocate-foreign-string (size &key unsigned)
Package

uffi.

Source

strings.lisp.

Macro: char-array-to-pointer (obj)
Package

uffi.

Source

objects.lisp.

Macro: convert-from-cstring (obj)

Converts a string from a c-call. Same as convert-from-foreign-string, except that LW/CMU automatically converts strings from c-calls.

Package

uffi.

Source

strings.lisp.

Macro: convert-from-foreign-string (obj &key length encoding null-terminated-p)
Package

uffi.

Source

strings.lisp.

Macro: convert-to-cstring (obj)
Package

uffi.

Source

strings.lisp.

Macro: convert-to-foreign-string (obj &optional encoding)
Package

uffi.

Source

strings.lisp.

Macro: def-array-pointer (name-array type)
Package

uffi.

Source

aggregates.lisp.

Macro: def-constant (name value &key export)

Macro to define a constant and to export it

Package

uffi.

Source

primitives.lisp.

Macro: def-enum (enum-name args &key separator-string)

Creates a constants for a C type enum list, symbols are created
in the created in the current package. The symbol is the concatenation of the enum-name name, separator-string, and field-name

Package

uffi.

Source

aggregates.lisp.

Macro: def-foreign-type (name type)
Package

uffi.

Source

primitives.lisp.

Macro: def-foreign-var (names type module)
Package

uffi.

Source

objects.lisp.

Macro: def-function (names args &key module returning)
Package

uffi.

Source

functions.lisp.

Macro: def-pointer-var (name value &optional doc)
Package

uffi.

Source

objects.lisp.

Macro: def-struct (name &rest fields)
Package

uffi.

Source

aggregates.lisp.

Macro: def-type (name type)

Generates a (deftype) statement for CL. Currently, only CMUCL supports takes advantage of this optimization.

Package

uffi.

Source

primitives.lisp.

Macro: def-union (name &rest fields)
Package

uffi.

Source

aggregates.lisp.

Macro: deref-array (obj type i)

Returns a field from a row

Package

uffi.

Source

aggregates.lisp.

Macro: deref-pointer (ptr type)

Returns a object pointed

Package

uffi.

Source

objects.lisp.

Macro: ensure-char-character (obj)
Package

uffi.

Source

objects.lisp.

Macro: ensure-char-integer (obj)
Package

uffi.

Source

objects.lisp.

Macro: ensure-char-storable (obj)
Package

uffi.

Source

objects.lisp.

Macro: free-cstring (obj)
Package

uffi.

Source

strings.lisp.

Macro: free-foreign-object (obj)
Package

uffi.

Source

objects.lisp.

Macro: get-slot-pointer (obj type slot)
Package

uffi.

Source

aggregates.lisp.

Macro: get-slot-value (obj type slot)
Package

uffi.

Source

aggregates.lisp.

Macro: make-null-pointer (type)
Package

uffi.

Source

objects.lisp.

Macro: make-pointer (addr type)
Package

uffi.

Source

objects.lisp.

Macro: null-char-p (val)

Returns T if character is NULL

Package

uffi.

Source

primitives.lisp.

Macro: null-pointer-p (obj)
Package

uffi.

Source

objects.lisp.

Macro: octets-to-string (octets &key encoding)

Converts a vector of octets to a Lisp string.

Package

uffi.

Source

i18n.lisp.

Macro: pointer-address (obj)
Package

uffi.

Source

objects.lisp.

Macro: string-to-octets (str &key encoding null-terminate)
Package

uffi.

Source

i18n.lisp.

Macro: with-cast-pointer ((binding-name pointer type) &body body)
Package

uffi.

Source

objects.lisp.

Macro: with-cstring ((cstring lisp-string) &body body)
Package

uffi.

Source

strings.lisp.

Macro: with-cstrings (bindings &rest body)
Package

uffi.

Source

strings.lisp.

Macro: with-foreign-object ((var type) &rest body)
Package

uffi.

Source

objects.lisp.

Macro: with-foreign-objects (bindings &rest body)
Package

uffi.

Source

objects.lisp.

Macro: with-foreign-string ((foreign-string lisp-string &optional encoding) &body body)
Package

uffi.

Source

strings.lisp.

Macro: with-foreign-strings (bindings &body body)
Package

uffi.

Source

strings.lisp.


Previous: , Up: Public Interface   [Contents][Index]

6.1.3 Ordinary functions

Function: convert-from-foreign-usb8 (s len)
Package

uffi.

Source

aggregates.lisp.

Function: default-foreign-library-type ()

Returns string naming default library type for platform

Package

uffi.

Source

libraries.lisp.

Function: find-foreign-library (names directories &key types drive-letters)

Looks for a foreign library. directories can be a single string or a list of strings of candidate directories. Use default library type if type is not specified.

Package

uffi.

Source

libraries.lisp.

Function: foreign-encoded-octet-count (str &key encoding)

Returns the octets required to represent the string when passed to a ~ foreign function.

Package

uffi.

Source

i18n.lisp.

Function: foreign-library-types ()

Returns list of string naming possible library types for platform, sorted by preference

Package

uffi.

Source

libraries.lisp.

Function: foreign-string-length (foreign-string)
Package

uffi.

Source

strings.lisp.

Function: getenv (var)

Return the value of the environment variable.

Package

uffi.

Source

os.lisp.

Function: load-foreign-library (filename &key module supporting-libraries force-load)
Package

uffi.

Source

libraries.lisp.

Function: run-shell-command (control-string &rest args &key output)

Interpolate ARGS into CONTROL-STRING as if by FORMAT, and synchronously execute the result using a Bourne-compatible shell, with output to *trace-output*. Returns the shell’s exit code.

Package

uffi.

Source

os.lisp.

Function: size-of-foreign-type (type)
Package

uffi.

Source

objects.lisp.


6.2 Internals


Next: , Previous: , Up: Internals   [Contents][Index]

6.2.1 Constants

Constant: +system-copy-multiplier+
Package

uffi.

Source

aggregates.lisp.

Constant: +system-copy-offset+
Package

uffi.

Source

aggregates.lisp.


Next: , Previous: , Up: Internals   [Contents][Index]

6.2.2 Special variables

Special Variable: *cmu-def-type-hash*
Package

uffi.

Source

primitives.lisp.

Special Variable: *cmu-sbcl-def-type-list*

Conversions in SBCL for def-foreign-type are different than in def-function

Package

uffi.

Source

primitives.lisp.

Special Variable: *foreign-encoding-mapping*

Mapping between normalized external format name and implementation name.

Package

uffi.

Source

i18n.lisp.

Special Variable: *loaded-libraries*

List of foreign libraries loaded. Used to prevent reloading a library

Package

uffi.

Source

libraries.lisp.

Special Variable: *system-copy-fn*
Package

uffi.

Source

aggregates.lisp.

Special Variable: *type-conversion-list*
Package

uffi.

Source

primitives.lisp.

Special Variable: +type-conversion-hash+
Package

uffi.

Source

primitives.lisp.


6.2.3 Macros

Macro: %def-function (names args &key module returning)
Package

uffi.

Source

functions.lisp.


Next: , Previous: , Up: Internals   [Contents][Index]

6.2.4 Ordinary functions

Function: %convert-from-uffi-type (type context)

Converts from a uffi type to an implementation specific type

Package

uffi.

Source

primitives.lisp.

Function: %convert-to-foreign-string (str encoding)
Package

uffi.

Source

strings.lisp.

Function: allegro-convert-return-type (type)
Package

uffi.

Source

functions.lisp.

Function: basic-convert-from-uffi-type (type)
Package

uffi.

Source

primitives.lisp.

Function: convert-from-uffi-type (type context)
Package

uffi.

Source

primitives.lisp.

Function: convert-lispworks-args (args)
Package

uffi.

Source

functions.lisp.

Function: convert-supporting-libraries-to-string (libs)
Package

uffi.

Source

libraries.lisp.

Function: funcallable-lambda-list (args)
Package

uffi.

Source

functions.lisp.

Function: lookup-foreign-encoding (normalized)
Package

uffi.

Source

i18n.lisp.

Function: make-lisp-name (name)
Package

uffi.

Source

primitives.lisp.

Function: preprocess-args (args)
Package

uffi.

Source

functions.lisp.

Function: preprocess-names (names)
Package

uffi.

Source

functions.lisp.

Function: process-function-args (args)
Package

uffi.

Source

functions.lisp.

Function: process-one-function-arg (arg)
Package

uffi.

Source

functions.lisp.

Function: process-struct-fields (name fields &optional variant)
Package

uffi.

Source

aggregates.lisp.

Function: strlen (str)
Package

uffi.

Source

strings.lisp.


6.2.5 Types

Type: char-ptr-def ()
Package

uffi.

Source

strings.lisp.


Appendix A Indexes


Next: , Previous: , Up: Indexes   [Contents][Index]

A.1 Concepts


Next: , Previous: , Up: Indexes   [Contents][Index]

A.2 Functions

Jump to:   %  
A   B   C   D   E   F   G   L   M   N   O   P   R   S   W  
Index Entry  Section

%
%convert-from-uffi-type: Private ordinary functions
%convert-to-foreign-string: Private ordinary functions
%def-function: Private macros

A
allegro-convert-return-type: Private ordinary functions
allocate-foreign-object: Public macros
allocate-foreign-string: Public macros

B
basic-convert-from-uffi-type: Private ordinary functions

C
char-array-to-pointer: Public macros
convert-from-cstring: Public macros
convert-from-foreign-string: Public macros
convert-from-foreign-usb8: Public ordinary functions
convert-from-uffi-type: Private ordinary functions
convert-lispworks-args: Private ordinary functions
convert-supporting-libraries-to-string: Private ordinary functions
convert-to-cstring: Public macros
convert-to-foreign-string: Public macros

D
def-array-pointer: Public macros
def-constant: Public macros
def-enum: Public macros
def-foreign-type: Public macros
def-foreign-var: Public macros
def-function: Public macros
def-pointer-var: Public macros
def-struct: Public macros
def-type: Public macros
def-union: Public macros
default-foreign-library-type: Public ordinary functions
deref-array: Public macros
deref-pointer: Public macros

E
ensure-char-character: Public macros
ensure-char-integer: Public macros
ensure-char-storable: Public macros

F
find-foreign-library: Public ordinary functions
foreign-encoded-octet-count: Public ordinary functions
foreign-library-types: Public ordinary functions
foreign-string-length: Public ordinary functions
free-cstring: Public macros
free-foreign-object: Public macros
funcallable-lambda-list: Private ordinary functions
Function, %convert-from-uffi-type: Private ordinary functions
Function, %convert-to-foreign-string: Private ordinary functions
Function, allegro-convert-return-type: Private ordinary functions
Function, basic-convert-from-uffi-type: Private ordinary functions
Function, convert-from-foreign-usb8: Public ordinary functions
Function, convert-from-uffi-type: Private ordinary functions
Function, convert-lispworks-args: Private ordinary functions
Function, convert-supporting-libraries-to-string: Private ordinary functions
Function, default-foreign-library-type: Public ordinary functions
Function, find-foreign-library: Public ordinary functions
Function, foreign-encoded-octet-count: Public ordinary functions
Function, foreign-library-types: Public ordinary functions
Function, foreign-string-length: Public ordinary functions
Function, funcallable-lambda-list: Private ordinary functions
Function, getenv: Public ordinary functions
Function, load-foreign-library: Public ordinary functions
Function, lookup-foreign-encoding: Private ordinary functions
Function, make-lisp-name: Private ordinary functions
Function, preprocess-args: Private ordinary functions
Function, preprocess-names: Private ordinary functions
Function, process-function-args: Private ordinary functions
Function, process-one-function-arg: Private ordinary functions
Function, process-struct-fields: Private ordinary functions
Function, run-shell-command: Public ordinary functions
Function, size-of-foreign-type: Public ordinary functions
Function, strlen: Private ordinary functions

G
get-slot-pointer: Public macros
get-slot-value: Public macros
getenv: Public ordinary functions

L
load-foreign-library: Public ordinary functions
lookup-foreign-encoding: Private ordinary functions

M
Macro, %def-function: Private macros
Macro, allocate-foreign-object: Public macros
Macro, allocate-foreign-string: Public macros
Macro, char-array-to-pointer: Public macros
Macro, convert-from-cstring: Public macros
Macro, convert-from-foreign-string: Public macros
Macro, convert-to-cstring: Public macros
Macro, convert-to-foreign-string: Public macros
Macro, def-array-pointer: Public macros
Macro, def-constant: Public macros
Macro, def-enum: Public macros
Macro, def-foreign-type: Public macros
Macro, def-foreign-var: Public macros
Macro, def-function: Public macros
Macro, def-pointer-var: Public macros
Macro, def-struct: Public macros
Macro, def-type: Public macros
Macro, def-union: Public macros
Macro, deref-array: Public macros
Macro, deref-pointer: Public macros
Macro, ensure-char-character: Public macros
Macro, ensure-char-integer: Public macros
Macro, ensure-char-storable: Public macros
Macro, free-cstring: Public macros
Macro, free-foreign-object: Public macros
Macro, get-slot-pointer: Public macros
Macro, get-slot-value: Public macros
Macro, make-null-pointer: Public macros
Macro, make-pointer: Public macros
Macro, null-char-p: Public macros
Macro, null-pointer-p: Public macros
Macro, octets-to-string: Public macros
Macro, pointer-address: Public macros
Macro, string-to-octets: Public macros
Macro, with-cast-pointer: Public macros
Macro, with-cstring: Public macros
Macro, with-cstrings: Public macros
Macro, with-foreign-object: Public macros
Macro, with-foreign-objects: Public macros
Macro, with-foreign-string: Public macros
Macro, with-foreign-strings: Public macros
make-lisp-name: Private ordinary functions
make-null-pointer: Public macros
make-pointer: Public macros

N
null-char-p: Public macros
null-pointer-p: Public macros

O
octets-to-string: Public macros

P
pointer-address: Public macros
preprocess-args: Private ordinary functions
preprocess-names: Private ordinary functions
process-function-args: Private ordinary functions
process-one-function-arg: Private ordinary functions
process-struct-fields: Private ordinary functions

R
run-shell-command: Public ordinary functions

S
size-of-foreign-type: Public ordinary functions
string-to-octets: Public macros
strlen: Private ordinary functions

W
with-cast-pointer: Public macros
with-cstring: Public macros
with-cstrings: Public macros
with-foreign-object: Public macros
with-foreign-objects: Public macros
with-foreign-string: Public macros
with-foreign-strings: Public macros

Jump to:   %  
A   B   C   D   E   F   G   L   M   N   O   P   R   S   W  

Next: , Previous: , Up: Indexes   [Contents][Index]

A.3 Variables

Jump to:   *   +  
C   S  
Index Entry  Section

*
*cmu-def-type-hash*: Private special variables
*cmu-sbcl-def-type-list*: Private special variables
*default-foreign-encoding*: Public special variables
*foreign-encoding-mapping*: Private special variables
*foreign-encodings*: Public special variables
*loaded-libraries*: Private special variables
*system-copy-fn*: Private special variables
*type-conversion-list*: Private special variables

+
+null-cstring-pointer+: Public special variables
+system-copy-multiplier+: Private constants
+system-copy-offset+: Private constants
+type-conversion-hash+: Private special variables

C
Constant, +system-copy-multiplier+: Private constants
Constant, +system-copy-offset+: Private constants

S
Special Variable, *cmu-def-type-hash*: Private special variables
Special Variable, *cmu-sbcl-def-type-list*: Private special variables
Special Variable, *default-foreign-encoding*: Public special variables
Special Variable, *foreign-encoding-mapping*: Private special variables
Special Variable, *foreign-encodings*: Public special variables
Special Variable, *loaded-libraries*: Private special variables
Special Variable, *system-copy-fn*: Private special variables
Special Variable, *type-conversion-list*: Private special variables
Special Variable, +null-cstring-pointer+: Public special variables
Special Variable, +type-conversion-hash+: Private special variables

Jump to:   *   +  
C   S  

Previous: , Up: Indexes   [Contents][Index]

A.4 Data types

Jump to:   A   C   F   I   L   M   O   P   S   T   U  
Index Entry  Section

A
aggregates.lisp: The uffi/src/aggregates․lisp file

C
char-ptr-def: Private types

F
File, aggregates.lisp: The uffi/src/aggregates․lisp file
File, functions.lisp: The uffi/src/functions․lisp file
File, i18n.lisp: The uffi/src/i18n․lisp file
File, libraries.lisp: The uffi/src/libraries․lisp file
File, objects.lisp: The uffi/src/objects․lisp file
File, os.lisp: The uffi/src/os․lisp file
File, package.lisp: The uffi/src/package․lisp file
File, primitives.lisp: The uffi/src/primitives․lisp file
File, strings.lisp: The uffi/src/strings․lisp file
File, uffi.asd: The uffi/uffi․asd file
functions.lisp: The uffi/src/functions․lisp file

I
i18n.lisp: The uffi/src/i18n․lisp file

L
libraries.lisp: The uffi/src/libraries․lisp file

M
Module, src: The uffi/src module

O
objects.lisp: The uffi/src/objects․lisp file
os.lisp: The uffi/src/os․lisp file

P
Package, uffi: The uffi package
Package, uffi-system: The uffi-system package
package.lisp: The uffi/src/package․lisp file
primitives.lisp: The uffi/src/primitives․lisp file

S
src: The uffi/src module
strings.lisp: The uffi/src/strings․lisp file
System, uffi: The uffi system

T
Type, char-ptr-def: Private types

U
uffi: The uffi system
uffi: The uffi package
uffi-system: The uffi-system package
uffi.asd: The uffi/uffi․asd file

Jump to:   A   C   F   I   L   M   O   P   S   T   U