This module defines a Quintus compatible foreign language interface
based on the foreign_file/2 and foreign/3 declarations.
Predicates:
- load_foreign_files
- Load all foreign files defined with foreign_file/2 statement
in the current module.
- load_foreign_files(+Files, +Libs)
- Load specified foreign files, linking them with the given
libraries
- load_foreign_files(+SharedObject, +Files, +Libs)
- As load_foreign_files/2, but first tries to load `SharedObject'.
If the SharedObject exists it is loaded using load_foreign_library/1.
Otherwise it is first created with make_shared_object/3.
- make_shared_object(+SharedObject, +Files, +Libs)
- Generate a wrapper and link it using plld to the given SharedObject.
- make_foreign_wrapper_file(+Files, +OutBase)
- Generate wrapper for the named object files in OutBase.c.
- make_foreign_wrapper_file(+Files)
- Generate wrapper for all declared object files in OutBase.c.
Example:
foreign_file('-lm', [sin/2]).
foreign(sin, c, sin(+float, [-float])).
:- load_foreign_files,
abolish(foreign_file, 2),
abolish(foreign, 3).
Supported types:
Spec | Prolog | C |
integer | integer | long |
float | float,integer | double |
single | float,integer | single |
string | atom,string | char * |
atom | atom | atom identifier (type atomic) |
NOTE This modules requires a correctly functioning swipl-ld and
load_foreign_library/1 on your system. If this isn't the
case use make_foreign_wrapper_file/[1,2] to generate a
wrapper and use static embedding.
- bug
- - Only supports C-interface
- - Insufficient checking for misusage.
- - Documentation is too short and very outdated
- load_foreign_files is det
- load_foreign_files(:Files, +Libs) is det
- load_foreign_files(+SharedObject, :Files, +Libs) is det
- Calls
make_foreign_wrapper_file(+File)
, compiles the wrapper
and loads the predicates.
- make_shared_object(+Object, :Files, +Libs) is det
- Generate a wrapper and link it using plld to the given
SharedObject.
- make_foreign_wrapper_file(:OutFile) is det
- make_foreign_wrapper_file(:Files, +OutFile) is det
- Just output the wrapper file to the named .c file. May be used
to prepare for static linking or the preparation of the native
SWI-Prolog foreign-file.
- make_foreign_resource_wrapper(:Resource, +ResBase, +FileBase)
- Create a wrapper-file for the given foreign resource
- load_foreign_resource(:Resource, +Dir)
- Load a foreign module. First try to load from the same direcory
as the Prolog file. Otherwise load using SWI-Prolog's default
search path.
Re-exported predicates
The following predicates are exported from this file while their implementation is defined in imported modules or non-module files loaded by this module.
- load_foreign_files is det
- load_foreign_files(:Files, +Libs) is det
- load_foreign_files(+SharedObject, :Files, +Libs) is det
- Calls
make_foreign_wrapper_file(+File)
, compiles the wrapper
and loads the predicates.
- load_foreign_files is det
- load_foreign_files(:Files, +Libs) is det
- load_foreign_files(+SharedObject, :Files, +Libs) is det
- Calls
make_foreign_wrapper_file(+File)
, compiles the wrapper
and loads the predicates.
- make_foreign_wrapper_file(:OutFile) is det
- make_foreign_wrapper_file(:Files, +OutFile) is det
- Just output the wrapper file to the named .c file. May be used
to prepare for static linking or the preparation of the native
SWI-Prolog foreign-file.