- Documentation
- Reference manual
- Foreign Language Interface
- The Foreign Include File
- Argument Passing and Control
- Atoms and functors
- Analysing Terms via the Foreign Interface
- Constructing Terms
- Unifying data
- Convenient functions to generate Prolog exceptions
- BLOBS: Using atoms to store arbitrary binary data
- Exchanging GMP numbers
- Calling Prolog from C
- Discarding Data
- Foreign Code and Modules
- Prolog exceptions in foreign code
- Catching Signals (Software Interrupts)
- Miscellaneous
- Errors and warnings
- Environment Control from Foreign Code
- Querying Prolog
- Registering Foreign Predicates
- Foreign Code Hooks
- Storing foreign data
- Embedding SWI-Prolog in other applications
- The Foreign Include File
- Foreign Language Interface
- Packages
- Reference manual
11.4.11 Foreign Code and Modules
Modules are identified via a unique handle. The following functions are available to query and manipulate modules.
- module_t PL_context()
- Return the module identifier of the context module of the currently active foreign predicate.
- int PL_strip_module(term_t +raw, module_t *m, term_t -plain)
- Utility function. If raw is a term, possibly holding the
module construct <module>
:
<rest>, this function will make plain a reference to <rest> and fill module * with <module>. For further nested module constructs the innermost module is returned via module *. If raw is not a module construct, raw will simply be put in plain. The value pointed to by m must be initialized before calling PL_strip_module(), either to the default module or toNULL
. ANULL
value is replaced by the current context module if raw carries no module. The following example shows how to obtain the plain term and module if the default module is the user module:{ module m = PL_new_module(PL_new_atom("user")); term_t plain = PL_new_term_ref(); PL_strip_module(term, &m, plain); ... }
- atom_t PL_module_name(module_t module)
- Return the name of module as an atom.
- module_t PL_new_module(atom_t name)
- Find an existing module or create a new module with the name name.