Merge /Users/vsc/yap-6.3
This commit is contained in:
commit
7063641a5b
11
C/attvar.c
11
C/attvar.c
|
@ -1,4 +1,4 @@
|
|||
/*************************************************************************
|
||||
0/*************************************************************************
|
||||
* *
|
||||
* YAP Prolog *
|
||||
* *
|
||||
|
@ -28,11 +28,10 @@ static char SccsId[] = "%W% %G%";
|
|||
#define NULL (void *)0
|
||||
#endif
|
||||
|
||||
/** @file attvars.c
|
||||
@{ */
|
||||
|
||||
/**
|
||||
* @defgroup AttributeVariables_Builtins Implementation of Attribute Declarations
|
||||
/**
|
||||
@file attvar.c
|
||||
@{
|
||||
@defgroup AttributeVariables_Builtins Implementation of Attribute Declarations
|
||||
@ingroup AttributeVariables
|
||||
*/
|
||||
|
||||
|
|
3
C/exec.c
3
C/exec.c
|
@ -950,8 +950,7 @@ static Int protect_stack_from_cut(USES_REGS1) {
|
|||
* external backtrack to current stack frame: call method
|
||||
* and control backtracking.
|
||||
*
|
||||
* @`
|
||||
* method protect_stack_from_restore
|
||||
* @method protect_stack_from_restore
|
||||
* @param USES_REGS1 [env for threaded execution]
|
||||
* @return c
|
||||
[next answer]
|
||||
|
|
|
@ -17,8 +17,9 @@
|
|||
|
||||
/** @file C/flags.c
|
||||
|
||||
@ingroup Flags
|
||||
@{
|
||||
@addtogroup Flags
|
||||
@ingroup core
|
||||
@{
|
||||
*/
|
||||
|
||||
// this is where we define flags
|
||||
|
|
4
C/init.c
4
C/init.c
|
@ -106,11 +106,9 @@ void *YAP_save;
|
|||
@ingroup Syntax
|
||||
@{
|
||||
|
||||
|
||||
|
||||
The Prolog syntax caters for operators of three main kinds:
|
||||
|
||||
+ prefix;
|
||||
+ prefix;
|
||||
+ infix;
|
||||
+ postfix.
|
||||
|
||||
|
|
177
C/inlines.c
177
C/inlines.c
|
@ -16,9 +16,15 @@
|
|||
*************************************************************************/
|
||||
|
||||
|
||||
/** @defgroup YAP_Terms Predicates on terms
|
||||
@ingroup builtins
|
||||
@{
|
||||
/**
|
||||
|
||||
|
||||
@file inlines.c
|
||||
|
||||
@defgroup YAP_Inlines Inlined Tests nad Ter Manipulation
|
||||
|
||||
@ingroup builtins
|
||||
@{
|
||||
|
||||
|
||||
*/
|
||||
|
@ -998,41 +1004,65 @@ p_erroneous_call( USES_REGS1 )
|
|||
return(FALSE);
|
||||
}
|
||||
|
||||
/**
|
||||
* @genarg( ?_Index_, +_Term_ , -_Arg_ )
|
||||
*
|
||||
* Similar to arg/3, but it can also backtrack through _T_'s arguments, that is:
|
||||
static Int
|
||||
p_save_cp( USES_REGS1 )
|
||||
{
|
||||
Term t = Deref(ARG1);
|
||||
Term td;
|
||||
#if SHADOW_HB
|
||||
register CELL *HBREG = HB;
|
||||
#endif
|
||||
if (!IsVarTerm(t)) return(FALSE);
|
||||
td = cp_as_integer(B PASS_REGS);
|
||||
YapBind((CELL *)t,td);
|
||||
return(TRUE);
|
||||
}
|
||||
|
||||
~~~~~~~~~
|
||||
?- arg:genarg(I, f(a,b), A).
|
||||
A = a,
|
||||
I = 1.
|
||||
;
|
||||
A = b,
|
||||
I = 2.
|
||||
~~~~~~~~~
|
||||
*
|
||||
* Note: SWI-Prolog defines arg/3 as genarg/3.
|
||||
*/
|
||||
static Int
|
||||
genarg( USES_REGS1 )
|
||||
{ /* getarg(?Atom) */
|
||||
Term t0 = Deref(ARG1);
|
||||
Term t1 = Deref(ARG2);
|
||||
CELL *pt, *end;
|
||||
int res;
|
||||
UInt arity;
|
||||
/// @}
|
||||
|
||||
if (!IsVarTerm(t0)) {
|
||||
res = p_arg( PASS_REGS1 );
|
||||
if (res) {
|
||||
cut_succeed();
|
||||
} else {
|
||||
cut_fail();
|
||||
}
|
||||
}
|
||||
if (IsVarTerm(t1)) {
|
||||
Yap_Error(INSTANTIATION_ERROR,t1,"genarg/3");
|
||||
/**
|
||||
*
|
||||
* @addtogroup args
|
||||
*
|
||||
* @{
|
||||
*
|
||||
* @namespace args
|
||||
*
|
||||
* @pred genarg( ?Index, +Term , -Arg )
|
||||
*
|
||||
*
|
||||
* Similar to arg/3, but it can also backtrack through _T_'s arguments, that is:
|
||||
|
||||
~~~~~~~~~
|
||||
?- arg:genarg(I, f(a,b), A).
|
||||
A = a,
|
||||
I = 1.
|
||||
;
|
||||
A = b,
|
||||
I = 2.
|
||||
~~~~~~~~~
|
||||
*
|
||||
* Note: SWI-Prolog defines arg/3 as genarg/3.
|
||||
*/
|
||||
static Int
|
||||
genarg( USES_REGS1 )
|
||||
{ /* getarg(?Atom) */
|
||||
Term t0 = Deref(ARG1);
|
||||
Term t1 = Deref(ARG2);
|
||||
CELL *pt, *end;
|
||||
int res;
|
||||
UInt arity;
|
||||
|
||||
if (!IsVarTerm(t0)) {
|
||||
res = p_arg( PASS_REGS1 );
|
||||
if (res) {
|
||||
cut_succeed();
|
||||
} else {
|
||||
cut_fail();
|
||||
}
|
||||
}
|
||||
if (IsVarTerm(t1)) {
|
||||
Yap_Error(INSTANTIATION_ERROR,t1,"genarg/3");
|
||||
return FALSE;
|
||||
}
|
||||
if (IsPrimitiveTerm(t1)) {
|
||||
|
@ -1088,55 +1118,38 @@ cont_genarg( USES_REGS1 )
|
|||
Yap_unify(ARG3,pt[0]);
|
||||
}
|
||||
|
||||
static Int
|
||||
p_save_cp( USES_REGS1 )
|
||||
{
|
||||
Term t = Deref(ARG1);
|
||||
Term td;
|
||||
#if SHADOW_HB
|
||||
register CELL *HBREG = HB;
|
||||
#endif
|
||||
if (!IsVarTerm(t)) return(FALSE);
|
||||
td = cp_as_integer(B PASS_REGS);
|
||||
YapBind((CELL *)t,td);
|
||||
return(TRUE);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
Yap_InitInlines(void)
|
||||
{
|
||||
CACHE_REGS
|
||||
Term cm = CurrentModule;
|
||||
Yap_InitAsmPred("$$cut_by", 1, _cut_by, p_cut_by, SafePredFlag);
|
||||
Yap_InitAsmPred("$$save_by", 1, _save_by, p_save_cp, SafePredFlag);
|
||||
Yap_InitAsmPred("atom", 1, _atom, p_atom, SafePredFlag);
|
||||
Yap_InitAsmPred("atomic", 1, _atomic, p_atomic, SafePredFlag);
|
||||
Yap_InitAsmPred("integer", 1, _integer, p_integer, SafePredFlag);
|
||||
Yap_InitAsmPred("nonvar", 1, _nonvar, p_nonvar, SafePredFlag);
|
||||
Yap_InitAsmPred("number", 1, _number, p_number, SafePredFlag);
|
||||
Yap_InitAsmPred("var", 1, _var, p_var, SafePredFlag);
|
||||
Yap_InitAsmPred("db_reference", 1, _db_ref, p_db_ref, SafePredFlag);
|
||||
Yap_InitAsmPred("primitive", 1, _primitive, p_primitive, SafePredFlag);
|
||||
Yap_InitAsmPred("compound", 1, _compound, p_compound, SafePredFlag);
|
||||
Yap_InitAsmPred("float", 1, _float, p_float, SafePredFlag);
|
||||
Yap_InitAsmPred("=", 2, _equal, p_equal, SafePredFlag);
|
||||
void
|
||||
Yap_InitInlines(void)
|
||||
{
|
||||
CACHE_REGS
|
||||
Term cm = CurrentModule;
|
||||
Yap_InitAsmPred("$$cut_by", 1, _cut_by, p_cut_by, SafePredFlag);
|
||||
Yap_InitAsmPred("$$save_by", 1, _save_by, p_save_cp, SafePredFlag);
|
||||
Yap_InitAsmPred("atom", 1, _atom, p_atom, SafePredFlag);
|
||||
Yap_InitAsmPred("atomic", 1, _atomic, p_atomic, SafePredFlag);
|
||||
Yap_InitAsmPred("integer", 1, _integer, p_integer, SafePredFlag);
|
||||
Yap_InitAsmPred("nonvar", 1, _nonvar, p_nonvar, SafePredFlag);
|
||||
Yap_InitAsmPred("number", 1, _number, p_number, SafePredFlag);
|
||||
Yap_InitAsmPred("var", 1, _var, p_var, SafePredFlag);
|
||||
Yap_InitAsmPred("db_reference", 1, _db_ref, p_db_ref, SafePredFlag);
|
||||
Yap_InitAsmPred("primitive", 1, _primitive, p_primitive, SafePredFlag);
|
||||
Yap_InitAsmPred("compound", 1, _compound, p_compound, SafePredFlag);
|
||||
Yap_InitAsmPred("float", 1, _float, p_float, SafePredFlag);
|
||||
Yap_InitAsmPred("=", 2, _equal, p_equal, SafePredFlag);
|
||||
#if INLINE_BIG_COMPARISONS
|
||||
Yap_InitAsmPred("\\=", 2, _dif, p_dif, SafePredFlag|TestPredFlag);
|
||||
Yap_InitAsmPred("==", 2, _eq, p_eq, SafePredFlag|TestPredFlag);
|
||||
Yap_InitAsmPred("\\=", 2, _dif, p_dif, SafePredFlag|TestPredFlag);
|
||||
Yap_InitAsmPred("==", 2, _eq, p_eq, SafePredFlag|TestPredFlag);
|
||||
#else
|
||||
Yap_InitCPred("\\=", 2, p_dif, SafePredFlag);
|
||||
Yap_InitCPred("==", 2, p_eq, SafePredFlag);
|
||||
Yap_InitCPred("\\=", 2, p_dif, SafePredFlag);
|
||||
Yap_InitCPred("==", 2, p_eq, SafePredFlag);
|
||||
#endif
|
||||
Yap_InitAsmPred("arg", 3, _arg, p_arg, SafePredFlag);
|
||||
Yap_InitAsmPred("functor", 3, _functor, p_functor, 0);
|
||||
Yap_InitAsmPred("$label_ctl", 2, _p_label_ctl, p_erroneous_call, SafePredFlag);
|
||||
CurrentModule = ARG_MODULE;
|
||||
Yap_InitCPredBack("genarg", 3, 3, genarg, cont_genarg,SafePredFlag);
|
||||
CurrentModule = cm;
|
||||
}
|
||||
Yap_InitAsmPred("arg", 3, _arg, p_arg, SafePredFlag);
|
||||
Yap_InitAsmPred("functor", 3, _functor, p_functor, 0);
|
||||
Yap_InitAsmPred("$label_ctl", 2, _p_label_ctl, p_erroneous_call, SafePredFlag);
|
||||
CurrentModule = ARG_MODULE;
|
||||
Yap_InitCPredBack("genarg", 3, 3, genarg, cont_genarg,SafePredFlag);
|
||||
CurrentModule = cm;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
@}
|
||||
*/
|
||||
|
|
10
C/qlyr.c
10
C/qlyr.c
|
@ -15,6 +15,14 @@
|
|||
* $Log: not supported by cvs2svn $ *
|
||||
* *
|
||||
*************************************************************************/
|
||||
/**
|
||||
*
|
||||
* @file qlyr.c
|
||||
*
|
||||
* @addtogroup SaveRestoreSupport
|
||||
* @{
|
||||
*
|
||||
*/
|
||||
|
||||
#include "absmi.h"
|
||||
#include "alloc.h"
|
||||
|
@ -1084,3 +1092,5 @@ void Yap_InitQLYR(void) {
|
|||
restore_codes();
|
||||
}
|
||||
}
|
||||
|
||||
/// @}
|
||||
|
|
13
C/qlyw.c
13
C/qlyw.c
|
@ -16,6 +16,15 @@
|
|||
* *
|
||||
*************************************************************************/
|
||||
|
||||
/**
|
||||
*
|
||||
* @file qlyr.c
|
||||
*
|
||||
* @addtogroup SaveRestoreSupport
|
||||
* @{
|
||||
*
|
||||
*/
|
||||
|
||||
#include "absmi.h"
|
||||
#include "Foreign.h"
|
||||
#include "alloc.h"
|
||||
|
@ -971,3 +980,7 @@ void Yap_InitQLY(void)
|
|||
restore_codes();
|
||||
}
|
||||
}
|
||||
|
||||
/// @}
|
||||
|
||||
|
||||
|
|
|
@ -204,11 +204,11 @@ Int show_time(USES_REGS1) /* MORE PRECISION */
|
|||
}
|
||||
|
||||
#endif /* BEAM */
|
||||
// @{
|
||||
|
||||
/**
|
||||
@defgroup YAPSetVal
|
||||
@defgroup YAPSetVal Atom to Atomic Family of Built-ins.
|
||||
@ingroup Internal_Database
|
||||
@{
|
||||
|
||||
Maintain a light-weight map where the key is an atom, and the value can be
|
||||
any constant.
|
||||
|
@ -284,7 +284,7 @@ static Int p_values(USES_REGS1) { /* '$values'(Atom,Old,New) */
|
|||
return (TRUE);
|
||||
}
|
||||
|
||||
//@}
|
||||
///@}
|
||||
|
||||
static Int p_opdec(USES_REGS1) { /* '$opdec'(p,type,atom) */
|
||||
/* we know the arguments are integer, atom, atom */
|
||||
|
|
30
CXX/yapa.hh
30
CXX/yapa.hh
|
@ -1,25 +1,34 @@
|
|||
/// @{
|
||||
/// @file yapa.hh
|
||||
///
|
||||
/// @brief C++ Interface to atoms and their properties.
|
||||
|
||||
#ifndef YAPA_HH
|
||||
#define YAPA_HH 1
|
||||
|
||||
/**
|
||||
*
|
||||
* @defgroup yap-cplus-interface An object oriented interface for YAP.
|
||||
* @defgroup yap-cplus-interface-atoms Prolog Atoms
|
||||
*
|
||||
* @ingroup ChYInterface
|
||||
* @brief Symbols and associated propeeties.
|
||||
*
|
||||
* @ingroup yap-cplus-interface
|
||||
* @tableofcontents
|
||||
* @{
|
||||
*
|
||||
*
|
||||
* Prolog operates over constants, called atoms. YAP's stores most data as a list
|
||||
* of properties for atoms. Properties include functors, data-base tecords, predicates. operators,
|
||||
* and more.
|
||||
* Prolog interns symbols, called *atoms* in a Hash table, usually
|
||||
called the atom table_. Each entry in this table stores the atom's
|
||||
name, but also may have a linked list of _properties_ We use
|
||||
properties to represent all kinds of data including. data-base
|
||||
tecords, predicates. operators, and more.
|
||||
*
|
||||
* In a nutshell:
|
||||
* - YAPAtom serves as the gateway to the data-base;
|
||||
*
|
||||
* - YAProp abstracts most data-base objects.
|
||||
*
|
||||
* - PropTag allows distinguishing the different classes of YAPProp.
|
||||
*/
|
||||
/**
|
||||
Tne different tgaas area represented through PropTag.
|
||||
*/
|
||||
enum PropTag {
|
||||
/// predicate
|
||||
PRED_TAG = PEProp, // 0x0000,
|
||||
|
@ -110,7 +119,6 @@ public:
|
|||
};
|
||||
|
||||
|
||||
#endif /* YAPA_HH */
|
||||
|
||||
#endif /* YAPA_HH */
|
||||
/// @}
|
||||
|
||||
|
|
17
CXX/yapdb.hh
17
CXX/yapdb.hh
|
@ -1,21 +1,32 @@
|
|||
/// @file yapdb.hh
|
||||
///
|
||||
/// @brief C++ Interface to generated code.
|
||||
|
||||
|
||||
#ifndef _YAPDB_H
|
||||
#define _YAPDB_H
|
||||
|
||||
#define YAP_CPP_DB_INTERFACE 1
|
||||
|
||||
//! @{
|
||||
|
||||
/**
|
||||
*
|
||||
* @defgroup yap-cplus-db-interface Data-Base Component of YAP interface.
|
||||
*
|
||||
* @ingroup yap-cplus-interface
|
||||
* @{
|
||||
* @tableofcontents
|
||||
*
|
||||
*
|
||||
* These classes define the main data-structures stored in the Data-base component: atoms, functors
|
||||
* and predicates.
|
||||
* These classes define the main data-structures stored to represent compiled
|
||||
* programs:
|
||||
*
|
||||
* + YAPFunctor represents a name/arity combination.
|
||||
*
|
||||
* + YAPModule wraps the YAP module implementation.
|
||||
*
|
||||
* + YAPPredicate and subclasses store the actual program, Preliminary
|
||||
* support covers Prolog and C-defined predicates.
|
||||
*/
|
||||
|
||||
class YAPTerm;
|
||||
|
|
|
@ -935,7 +935,7 @@ YAPPredicate::YAPPredicate(YAPAtom at)
|
|||
ap = RepPredProp(PredPropByAtom(at.a, Yap_CurrentModule()));
|
||||
}
|
||||
|
||||
YAPPredicate::YAPPredicate(YAPAtom at, arity_t arity)
|
||||
YAPPredicate::YAPPredicate(YAPAtom at, uintptr_t arity)
|
||||
{
|
||||
CACHE_REGS
|
||||
if (arity)
|
||||
|
|
39
CXX/yapi.hh
39
CXX/yapi.hh
|
@ -1,4 +1,9 @@
|
|||
/**
|
||||
@file yapi,hh
|
||||
|
||||
@brief entry file for the YAP C++ interface
|
||||
|
||||
*/
|
||||
|
||||
|
||||
#define YAP_CPP_INTERFACE 1
|
||||
|
@ -8,18 +13,22 @@
|
|||
#include <string>
|
||||
#include <iostream>
|
||||
|
||||
//! @{
|
||||
/**
|
||||
/*!
|
||||
*
|
||||
* @{
|
||||
* @ingroup fli_c_cx
|
||||
* @defgroup yap-cplus-interface An object oriented interface for YAP.
|
||||
*
|
||||
* @ingroup yap-cplus-interface
|
||||
* @tableofcontents
|
||||
*
|
||||
*
|
||||
* C++ interface to YAP. Designed to be object oriented and to fit naturally
|
||||
* with the swig interface language generator. It uses ideas from the old YAP
|
||||
* interface and from the SWI foreign language interface.
|
||||
* @short C++ wrapper to terms, predicates and queries
|
||||
*
|
||||
*
|
||||
* This new interface is designed to be object oriented and to fit
|
||||
* naturally with the swig interface language generator. It uses ideas
|
||||
* from the old YAP interface and from the SWI foreign language
|
||||
* interface.
|
||||
*
|
||||
*/
|
||||
#include <stdlib.h>
|
||||
|
@ -63,21 +72,21 @@ extern "C" {
|
|||
#endif
|
||||
|
||||
#if _MSC_VER || defined(__MINGW32__)
|
||||
//#include <windows.h>
|
||||
//#include <windows.h>
|
||||
#endif
|
||||
|
||||
// taken from yap_structs.h
|
||||
// taken from yap_structs.h
|
||||
#include "iopreds.h"
|
||||
|
||||
X_API void YAP_UserCPredicate(const char *, YAP_UserCPred, YAP_Arity arity);
|
||||
X_API void YAP_UserCPredicate(const char *, YAP_UserCPred, YAP_Arity arity);
|
||||
|
||||
/* void UserCPredicateWithArgs(const char *name, int *fn(), unsigned int arity)
|
||||
*/
|
||||
X_API void YAP_UserCPredicateWithArgs(const char *, YAP_UserCPred, YAP_Arity,
|
||||
YAP_Term);
|
||||
/* void UserCPredicateWithArgs(const char *name, int *fn(), unsigned int arity)
|
||||
*/
|
||||
X_API void YAP_UserCPredicateWithArgs(const char *, YAP_UserCPred, YAP_Arity,
|
||||
YAP_Term);
|
||||
|
||||
X_API void UserBackCPredicate(const char *name, int *init(), int *cont(), int
|
||||
arity, int extra);
|
||||
X_API void UserBackCPredicate(const char *name, int *init(), int *cont(), int
|
||||
arity, int extra);
|
||||
|
||||
}
|
||||
|
||||
|
|
11
CXX/yapie.hh
11
CXX/yapie.hh
|
@ -1,15 +1,22 @@
|
|||
/**
|
||||
* @{
|
||||
* @file yapie.hh
|
||||
*
|
||||
* @defgroup yap-cplus-error-hanadlinge Errir Handling in the YAP interface.
|
||||
*
|
||||
* @brief this is an attempt at supporting error
|
||||
*
|
||||
* @ingroup yap-cplus-interface
|
||||
* @tableofcontents
|
||||
*
|
||||
* @{
|
||||
*
|
||||
* These classes define an object that we can then throw when an error
|
||||
* or unexoected event interrupts YAP. Often, the object is built by
|
||||
* YAP itself, but we may generate our own errors.
|
||||
* YAP itself. One can also define one's own error objects.
|
||||
*
|
||||
* Errors will be thrown from the `C++` code, and may be processed in
|
||||
* very different ways. The error object should provide as much data asa
|
||||
* possible.
|
||||
*/
|
||||
|
||||
|
||||
|
|
|
@ -1,14 +1,17 @@
|
|||
/**
|
||||
* @{
|
||||
* @file yapq.hh
|
||||
^
|
||||
* @defgroup yap-cplus-query-hanadlinge Query Handling in the YAP interface.
|
||||
* @brief Engine and Query Management
|
||||
*
|
||||
* @ingroup yap-cplus-interface
|
||||
* @tableofcontents
|
||||
*
|
||||
*
|
||||
* These classes define the concepts of engine ana of query.Ann engine is an environment where we can rum
|
||||
* @{
|
||||
*
|
||||
* These classes wrap engine ana of query.Ann engine is an environment where we can rum
|
||||
* Prolog, that is, where we can run queries.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef YAPQ_HH
|
||||
|
|
16
CXX/yapt.hh
16
CXX/yapt.hh
|
@ -1,15 +1,23 @@
|
|||
/**
|
||||
* @{
|
||||
* @file yapt.hh
|
||||
*/
|
||||
|
||||
/**
|
||||
* @defgroup yap-cplus-term-handling Term Handling in the YAP interface.
|
||||
*
|
||||
* @{
|
||||
*
|
||||
* @ingroup yap-cplus-interface
|
||||
* @tableofcontents
|
||||
* @tableofcontents
|
||||
*
|
||||
*
|
||||
* These classes define a term objectthat can be refined, Currently, all exported terms have an
|
||||
* handle, in the SWI-Prolog style.
|
||||
* These classes offer term construction and access. Terms are seens
|
||||
* as objects that inherit from a virtual class, Currently, all
|
||||
* terms must reside in the stack and may be moved around during
|
||||
* garbage collection. Term objects use an handle, in the SWI-Prolog style.
|
||||
*
|
||||
* Nottce that terms are forcefully destroyed during backtracking.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
|
|
27
H/Foreign.h
27
H/Foreign.h
|
@ -17,15 +17,28 @@
|
|||
#ifndef FOREIGN_H
|
||||
#define FOREIGN_H
|
||||
|
||||
/* Currently load_foreign_files works for the following machines:
|
||||
/**
|
||||
|
||||
AIX: should work for 3.2 and 4.1 at least, using ECOFF;
|
||||
linux: should work both for a.out (untested by me) and ELF;
|
||||
osf: should work, but isn't working yet.
|
||||
sunos4: should work, using A.OUT format;
|
||||
svr4, eg solaris: should work, using ELF format;
|
||||
@:
|
||||
@file Foreign.h
|
||||
|
||||
YAP should be able to load on most BSD Unixes, but you will need to
|
||||
load_foreign_files/3 has works for the following configurations:
|
||||
|
||||
- linux: should work both for a.out (untested by me) and ELF;
|
||||
|
||||
- WIN32: works (notice that symbols are not exported by default)
|
||||
|
||||
- OSX: works using Mach dynamic libs.
|
||||
|
||||
- osf: should work, but isn't working yet.
|
||||
|
||||
- sunos4: should work, using A.OUT format;
|
||||
|
||||
- svr4, eg solaris: should work, using ELF format;
|
||||
|
||||
- AIX: should work for 3.2 and 4.1 at least, using ECOFF;
|
||||
|
||||
YAP should be able to load on most BSD Unixes, but you will need to
|
||||
say that here.
|
||||
|
||||
YAP also supports COFF loading (pretty much the same technique as
|
||||
|
|
19
H/qly.h
19
H/qly.h
|
@ -17,6 +17,15 @@
|
|||
* *
|
||||
*************************************************************************/
|
||||
|
||||
/**
|
||||
*
|
||||
* @file qly.h
|
||||
*
|
||||
* @defgroup SaveRestoreSupport C-support for saved states.
|
||||
* @ingroup YAPSaving
|
||||
*
|
||||
*/
|
||||
|
||||
#define EXPORT_ATOM_TABLE_SIZE (16 * 4096)
|
||||
#define EXPORT_FUNCTOR_TABLE_SIZE (16 * 4096)
|
||||
#define EXPORT_OPCODE_TABLE_SIZE (4096)
|
||||
|
@ -101,11 +110,11 @@ typedef enum {
|
|||
QLY_ATOM_BLOB = 14
|
||||
} qlf_tag_t;
|
||||
|
||||
#define STATIC_PRED_FLAGS \
|
||||
(SourcePredFlag | DynamicPredFlag | LogUpdatePredFlag | CompiledPredFlag | \
|
||||
MultiFileFlag | TabledPredFlag | MegaClausePredFlag | CountPredFlag | \
|
||||
ProfiledPredFlag | ThreadLocalPredFlag | AtomDBPredFlag | \
|
||||
ModuleTransparentPredFlag | NumberDBPredFlag | MetaPredFlag | \
|
||||
#define STATIC_PRED_FLAGS \
|
||||
(SourcePredFlag | DynamicPredFlag | LogUpdatePredFlag | CompiledPredFlag | \
|
||||
MultiFileFlag | TabledPredFlag | MegaClausePredFlag | CountPredFlag | \
|
||||
ProfiledPredFlag | ThreadLocalPredFlag | AtomDBPredFlag | \
|
||||
ModuleTransparentPredFlag | NumberDBPredFlag | MetaPredFlag | \
|
||||
SyncPredFlag | BackCPredFlag)
|
||||
#define EXTRA_PRED_FLAGS \
|
||||
(QuasiQuotationPredFlag | NoTracePredFlag | NoSpyPredFlag)
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
************************************************************************/
|
||||
|
||||
|
||||
/**
|
||||
/**
|
||||
|
||||
@defgroup Parallelism Parallelism in YAP
|
||||
@ingroup extensions
|
||||
|
@ -38,7 +38,7 @@ data-base.
|
|||
parallel execution.
|
||||
|
||||
+ Garbage collection and stack shifting are not supported in
|
||||
*YAPOr*.
|
||||
*YAPOr*.
|
||||
|
||||
+ Built-ins that cause side-effects can only be executed when
|
||||
left-most in the search-tree. There are no primitives to provide
|
||||
|
@ -166,7 +166,7 @@ typedef struct query_goal_answer_frame{
|
|||
** --------------------------------------------- */
|
||||
|
||||
typedef struct table_subgoal_solution_frame{
|
||||
choiceptr generator_choice_point;
|
||||
choiceptr generator_choice_point;
|
||||
volatile int ltt;
|
||||
struct table_subgoal_answer_frame *first_answer_frame;
|
||||
struct table_subgoal_answer_frame *last_answer_frame;
|
||||
|
|
|
@ -1356,42 +1356,42 @@
|
|||
|
||||
|
||||
answer_resolution:
|
||||
INIT_PREFETCH()
|
||||
dep_fr_ptr dep_fr;
|
||||
ans_node_ptr ans_node;
|
||||
dep_fr_ptr dep_fr;
|
||||
ans_node_ptr ans_node;
|
||||
INIT_PREFETCH();
|
||||
|
||||
OPTYAP_ERROR_CHECKING(answer_resolution, SCH_top_shared_cp(B) && B->cp_or_fr->alternative != ANSWER_RESOLUTION);
|
||||
OPTYAP_ERROR_CHECKING(answer_resolution, !SCH_top_shared_cp(B) && B->cp_ap != ANSWER_RESOLUTION);
|
||||
dep_fr = CONS_CP(B)->cp_dep_fr;
|
||||
LOCK_DEP_FR(dep_fr);
|
||||
ans_node = DepFr_last_answer(dep_fr);
|
||||
if (TrNode_child(ans_node)) {
|
||||
/* unconsumed answers */
|
||||
OPTYAP_ERROR_CHECKING(answer_resolution, SCH_top_shared_cp(B) && B->cp_or_fr->alternative != ANSWER_RESOLUTION);
|
||||
OPTYAP_ERROR_CHECKING(answer_resolution, !SCH_top_shared_cp(B) && B->cp_ap != ANSWER_RESOLUTION);
|
||||
dep_fr = CONS_CP(B)->cp_dep_fr;
|
||||
LOCK_DEP_FR(dep_fr);
|
||||
ans_node = DepFr_last_answer(dep_fr);
|
||||
if (TrNode_child(ans_node)) {
|
||||
/* unconsumed answers */
|
||||
#ifdef MODE_DIRECTED_TABLING
|
||||
if (IS_ANSWER_INVALID_NODE(TrNode_child(ans_node))) {
|
||||
ans_node_ptr old_ans_node;
|
||||
old_ans_node = ans_node;
|
||||
if (IS_ANSWER_INVALID_NODE(TrNode_child(ans_node))) {
|
||||
ans_node_ptr old_ans_node;
|
||||
old_ans_node = ans_node;
|
||||
ans_node = TrNode_child(ans_node);
|
||||
do {
|
||||
ans_node = TrNode_child(ans_node);
|
||||
do {
|
||||
ans_node = TrNode_child(ans_node);
|
||||
} while (IS_ANSWER_INVALID_NODE(ans_node));
|
||||
TrNode_child(old_ans_node) = ans_node;
|
||||
} else
|
||||
} while (IS_ANSWER_INVALID_NODE(ans_node));
|
||||
TrNode_child(old_ans_node) = ans_node;
|
||||
} else
|
||||
#endif /* MODE_DIRECTED_TABLING */
|
||||
ans_node = TrNode_child(ans_node);
|
||||
DepFr_last_answer(dep_fr) = ans_node;
|
||||
UNLOCK_DEP_FR(dep_fr);
|
||||
consume_answer_and_procceed(dep_fr, ans_node);
|
||||
}
|
||||
ans_node = TrNode_child(ans_node);
|
||||
DepFr_last_answer(dep_fr) = ans_node;
|
||||
UNLOCK_DEP_FR(dep_fr);
|
||||
consume_answer_and_procceed(dep_fr, ans_node);
|
||||
}
|
||||
UNLOCK_DEP_FR(dep_fr);
|
||||
|
||||
#ifdef YAPOR
|
||||
if (B == DepFr_leader_cp(LOCAL_top_dep_fr)) {
|
||||
/* B is a generator-consumer node **
|
||||
** never here if batched scheduling */
|
||||
TABLING_ERROR_CHECKING(answer_resolution, IS_BATCHED_GEN_CP(B));
|
||||
goto completion;
|
||||
}
|
||||
if (B == DepFr_leader_cp(LOCAL_top_dep_fr)) {
|
||||
/* B is a generator-consumer node **
|
||||
** never here if batched scheduling */
|
||||
TABLING_ERROR_CHECKING(answer_resolution, IS_BATCHED_GEN_CP(B));
|
||||
goto completion;
|
||||
}
|
||||
#endif /* YAPOR */
|
||||
|
||||
/* no unconsumed answers */
|
||||
|
@ -1664,14 +1664,14 @@
|
|||
#ifdef THREADS_CONSUMER_SHARING
|
||||
goto answer_resolution_completion;
|
||||
#endif /* THREADS_CONSUMER_SHARING */
|
||||
INIT_PREFETCH()
|
||||
dep_fr_ptr dep_fr;
|
||||
ans_node_ptr ans_node;
|
||||
dep_fr_ptr dep_fr;
|
||||
ans_node_ptr ans_node;
|
||||
#ifdef YAPOR
|
||||
#ifdef TIMESTAMP_CHECK
|
||||
long timestamp = 0;
|
||||
#endif /* TIMESTAMP_CHECK */
|
||||
int entry_owners = 0;
|
||||
INIT_PREFETCH();
|
||||
|
||||
if (SCH_top_shared_cp(B)) {
|
||||
#ifdef TIMESTAMP_CHECK
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
SET (CODES
|
||||
solarized-light.css
|
||||
theme.css
|
||||
yap.css
|
||||
icons/yap_64x64x32.png
|
||||
icons/yap_256x256x32.png
|
||||
icons/yap_128x128x32.png
|
||||
icons/yap_48x48x32.png
|
||||
solarized-light.css
|
||||
theme.css
|
||||
yap.css
|
||||
icons/yap_64x64x32.png
|
||||
icons/yap_256x256x32.png
|
||||
icons/yap_128x128x32.png
|
||||
icons/yap_48x48x32.png
|
||||
)
|
||||
|
||||
SET (DOCS
|
||||
|
@ -42,14 +42,16 @@ if (WITH_DOCS)
|
|||
|
||||
configure_file(${doxyfile_in} ${doxyfile} @ONLY)
|
||||
|
||||
add_custom_target(doc
|
||||
COMMAND ${DOXYGEN_EXECUTABLE} ${doxyfile}
|
||||
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
|
||||
COMMENT "Generating API documentation with Doxygen"
|
||||
VERBATIM)
|
||||
configure_file(source/conf.py.in source/conf.py)
|
||||
configure_file(source/index.rst source/index.rst)
|
||||
add_custom_target(doc
|
||||
COMMAND ${DOXYGEN_EXECUTABLE} ${doxyfile}
|
||||
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
|
||||
COMMENT "Generating API documentation with Doxygen"
|
||||
VERBATIM)
|
||||
|
||||
install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/html DESTINATION ${docdir})
|
||||
install(FILES ${CODES} DESTINATION ${docdir})
|
||||
install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/html DESTINATION ${docdir})
|
||||
install(FILES ${CODES} DESTINATION ${docdir})
|
||||
|
||||
endif()
|
||||
|
||||
|
|
|
@ -775,7 +775,7 @@ WARN_LOGFILE =
|
|||
# spaces. See also FILE_PATTERNS and EXTENSION_MAPPING
|
||||
# Note: If this tag is empty the current directory is searched.
|
||||
|
||||
INPUT = @PROJECT_SOURCE_DIR@/pl \
|
||||
INPUT = @PROJECT_SOURCE_DIR@/pl \
|
||||
@PROJECT_SOURCE_DIR@/CXX \
|
||||
@PROJECT_SOURCE_DIR@/OPTYap \
|
||||
@PROJECT_SOURCE_DIR@/C \
|
||||
|
@ -829,11 +829,22 @@ RECURSIVE = YES
|
|||
|
||||
EXCLUDE = *pltotex.pl \
|
||||
@PROJECT_SOURCE_DIR@/packages/myddas/sqlite3/src \
|
||||
@PROJECT_SOURCE_DIR@/packages/gecode/4.* \
|
||||
@PROJECT_SOURCE_DIR@/packages/gecode/3.* \
|
||||
@PROJECT_SOURCE_DIR@/packages/gecode/4.4.0 \
|
||||
@PROJECT_SOURCE_DIR@/packages/gecode/4.2.1 \
|
||||
@PROJECT_SOURCE_DIR@/packages/gecode/4.2.0 \
|
||||
@PROJECT_SOURCE_DIR@/packages/gecode/4.0.0 \
|
||||
@PROJECT_SOURCE_DIR@/packages/gecode/3.7.3 \
|
||||
@PROJECT_SOURCE_DIR@/packages/gecode/3.7.2 \
|
||||
@PROJECT_SOURCE_DIR@/packages/gecode/3.7.1 \
|
||||
@PROJECT_SOURCE_DIR@/packages/gecode/3.7.0 \
|
||||
@PROJECT_SOURCE_DIR@/packages/gecode/3.6.0 \
|
||||
@PROJECT_SOURCE_DIR@/packages/gecode/dev \
|
||||
@PROJECT_SOURCE_DIR@/C/traced_absmi_insts.h \
|
||||
/Users/vsc/github/yap-6.3/packages/cplint \
|
||||
/Users/vsc/github/yap-6.3/packages/CLPBN/examples
|
||||
@PROJECT_SOURCE_DIR@/packages/cplint \
|
||||
@PROJECT_SOURCE_DIR@/packages/CLPBN/examples \
|
||||
@PROJECT_SOURCE_DIR@/packages/prosqlite \
|
||||
@PROJECT_SOURCE_DIR@/packages/pyswip \
|
||||
|
||||
|
||||
# The EXCLUDE_SYMLINKS tag can be used to select whether or not files or
|
||||
# directories that are symbolic links (a Unix file system feature) are excluded
|
||||
|
@ -1318,7 +1329,7 @@ BINARY_TOC = NO
|
|||
# The default value is: NO.
|
||||
# This tag requires that the tag GENERATE_HTMLHELP is set to YES.
|
||||
|
||||
TOC_EXPAND = NO
|
||||
TOC_EXPAND = YES
|
||||
|
||||
# If the GENERATE_QHP tag is set to YES and both QHP_NAMESPACE and
|
||||
# QHP_VIRTUAL_FOLDER are set, an additional index file will be generated that
|
||||
|
@ -2032,7 +2043,8 @@ SEARCH_INCLUDES = YES
|
|||
# preprocessor.
|
||||
# This tag requires that the tag SEARCH_INCLUDES is set to YES.
|
||||
|
||||
INCLUDE_PATH =
|
||||
INCLUDE_PATH = @CMAKE_BINARY_DIR@ \
|
||||
@CMAKE_BINARY_DIR@/packages/gecode
|
||||
|
||||
# You can use the INCLUDE_FILE_PATTERNS tag to specify one or more wildcard
|
||||
# patterns (like *.h and *.hpp) to filter out the header-files in the
|
||||
|
@ -2263,7 +2275,7 @@ TEMPLATE_RELATIONS = NO
|
|||
|
||||
INCLUDE_GRAPH = YES
|
||||
|
||||
# If the INCLUDED_BY_GRAPH, ENABLE_PREPROCESSING and SEARCH_INCLUDES tags are
|
||||
# If the INCLUDED_BY_GRAPH, ENABLE_PREPROCESSING and SEARCH_INCLUDES tags are
|
||||
# set to YES then doxygen will generate a graph for each documented file showing
|
||||
# the direct and indirect include dependencies of the file with other documented
|
||||
# files.
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#!/usr/bin/env python3
|
||||
#!/Usr/bin/env python3
|
||||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# YAP documentation build configuration file, created by
|
||||
|
@ -44,7 +44,7 @@ extensions = ['sphinx.ext.autodoc',
|
|||
'breathe'
|
||||
]
|
||||
|
||||
breathe_projects = { "yap": "/Users/vsc/github/yap-6.3/Debug/docs/xml" }
|
||||
breathe_projects = { "yap": "${CMAKE_CURRENT_BINARY_DIR" }
|
||||
breathe_default_project = "yap"
|
||||
|
||||
# Add any paths that contain templates here, relative to this directory.
|
||||
|
|
|
@ -0,0 +1,197 @@
|
|||
#!/Usr/bin/env python3
|
||||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# YAP documentation build configuration file, created by
|
||||
# sphinx-quickstart on Sun Mar 26 10:27:55 2017.
|
||||
#
|
||||
# This file is execfile()d with the current directory set to its
|
||||
# containing dir.
|
||||
#
|
||||
# Note that not all possible configuration values are present in this
|
||||
# autogenerated file.
|
||||
#
|
||||
# All configuration values have a default; values that are commented out
|
||||
# serve to show the default.
|
||||
|
||||
# If extensions (or modules to document with autodoc) are in another directory,
|
||||
# add these directories to sys.path here. If the directory is relative to the
|
||||
# documentation root, use os.path.abspath to make it absolute, like shown here.
|
||||
#
|
||||
# import os
|
||||
# import sys
|
||||
# sys.path.insert(0, os.path.abspath('.'))
|
||||
from recommonmark.parser import CommonMarkParser
|
||||
|
||||
|
||||
# -- General configuration ------------------------------------------------
|
||||
|
||||
# If your documentation needs a minimal Sphinx version, state it here.
|
||||
#
|
||||
# needs_sphinx = '1.0'
|
||||
|
||||
# Add any Sphinx extension module names here, as strings. They can be
|
||||
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
|
||||
# ones.
|
||||
extensions = ['sphinx.ext.autodoc',
|
||||
'sphinx.ext.doctest',
|
||||
'sphinx.ext.intersphinx',
|
||||
'sphinx.ext.todo',
|
||||
'sphinx.ext.coverage',
|
||||
'sphinx.ext.mathjax',
|
||||
'sphinx.ext.ifconfig',
|
||||
'sphinx.ext.viewcode',
|
||||
'sphinx.ext.githubpages',
|
||||
'breathe'
|
||||
]
|
||||
|
||||
breathe_projects = { "yap": "@CMAKE_CURRENT_BINARY_DIR@/xml" }
|
||||
breathe_default_project = "yap"
|
||||
|
||||
# Add any paths that contain templates here, relative to this directory.
|
||||
templates_path = ['_templates']
|
||||
|
||||
# The suffix(es) of source filenames.
|
||||
# You can specify multiple suffix as a list of string:
|
||||
#
|
||||
source_suffix = ['.rst', '.md']
|
||||
# source_suffix = '.rst'
|
||||
|
||||
# The master toctree document.
|
||||
master_doc = 'index'
|
||||
|
||||
# General information about the project.
|
||||
project = 'YAP'
|
||||
copyright = '2017, Vitor Santos Costa'
|
||||
author = 'Vitor Santos Costa'
|
||||
|
||||
# The version info for the project you're documenting, acts as replacement for
|
||||
# |version| and |release|, also used in various other places throughout the
|
||||
# built documents.
|
||||
#
|
||||
# The short X.Y version.
|
||||
version = '6.3'
|
||||
# The full version, including alpha/beta/rc tags.
|
||||
release = '6.3.5'
|
||||
|
||||
# The language for content autogenerated by Sphinx. Refer to documentation
|
||||
# for a list of supported languages.
|
||||
#
|
||||
# This is also used if you do content translation via gettext catalogs.
|
||||
# Usually you set "language" from the command line for these cases.
|
||||
language = None
|
||||
|
||||
# List of patterns, relative to source directory, that match files and
|
||||
# directories to ignore when looking for source files.
|
||||
# This patterns also effect to html_static_path and html_extra_path
|
||||
exclude_patterns = []
|
||||
|
||||
# The name of the Pygments (syntax highlighting) style to use.
|
||||
pygments_style = 'sphinx'
|
||||
|
||||
# If true, `todo` and `todoList` produce output, else they produce nothing.
|
||||
todo_include_todos = True
|
||||
|
||||
source_parsers = {
|
||||
'.md': 'recommonmark.parser.CommonMarkParser',
|
||||
}
|
||||
# -- Options for HTML output ----------------------------------------------
|
||||
|
||||
# The theme to use for HTML and HTML Help pages. See the documentation for
|
||||
# a list of builtin themes.
|
||||
#
|
||||
html_theme = 'alabaster'
|
||||
|
||||
# Theme options are theme-specific and customize the look and feel of a theme
|
||||
# further. For a list of options available for each theme, see the
|
||||
# documentation.
|
||||
#
|
||||
# html_theme_options = {}
|
||||
|
||||
# Add any paths that contain custom static files (such as style sheets) here,
|
||||
# relative to this directory. They are copied after the builtin static files,
|
||||
# so a file named "default.css" will overwrite the builtin "default.css".
|
||||
html_static_path = ['_static']
|
||||
|
||||
|
||||
# -- Options for HTMLHelp output ------------------------------------------
|
||||
|
||||
# Output file base name for HTML help builder.
|
||||
htmlhelp_basename = 'YAPdoc'
|
||||
|
||||
|
||||
# -- Options for LaTeX output ---------------------------------------------
|
||||
|
||||
latex_elements = {
|
||||
# The paper size ('letterpaper' or 'a4paper').
|
||||
#
|
||||
# 'papersize': 'letterpaper',
|
||||
|
||||
# The font size ('10pt', '11pt' or '12pt').
|
||||
#
|
||||
# 'pointsize': '10pt',
|
||||
|
||||
# Additional stuff for the LaTeX preamble.
|
||||
#
|
||||
# 'preamble': '',
|
||||
|
||||
# Latex figure (float) alignment
|
||||
#
|
||||
# 'figure_align': 'htbp',
|
||||
}
|
||||
|
||||
# Grouping the document tree into LaTeX files. List of tuples
|
||||
# (source start file, target name, title,
|
||||
# author, documentclass [howto, manual, or own class]).
|
||||
latex_documents = [
|
||||
(master_doc, 'YAP.tex', 'YAP Documentation',
|
||||
'Vitor Santos Costa', 'manual'),
|
||||
]
|
||||
|
||||
|
||||
# -- Options for manual page output ---------------------------------------
|
||||
|
||||
# One entry per manual page. List of tuples
|
||||
# (source start file, name, description, authors, manual section).
|
||||
man_pages = [
|
||||
(master_doc, 'yap', 'YAP Documentation',
|
||||
[author], 1)
|
||||
]
|
||||
|
||||
|
||||
# -- Options for Texinfo output -------------------------------------------
|
||||
|
||||
# Grouping the document tree into Texinfo files. List of tuples
|
||||
# (source start file, target name, title, author,
|
||||
# dir menu entry, description, category)
|
||||
texinfo_documents = [
|
||||
(master_doc, 'YAP', 'YAP Documentation',
|
||||
author, 'YAP', 'One line description of project.',
|
||||
'Miscellaneous'),
|
||||
]
|
||||
|
||||
|
||||
|
||||
# -- Options for Epub output ----------------------------------------------
|
||||
|
||||
# Bibliographic Dublin Core info.
|
||||
epub_title = project
|
||||
epub_author = author
|
||||
epub_publisher = author
|
||||
epub_copyright = copyright
|
||||
|
||||
# The unique identifier of the text. This can be a ISBN number
|
||||
# or the project homepage.
|
||||
#
|
||||
# epub_identifier = ''
|
||||
|
||||
# A unique identification for the text.
|
||||
#
|
||||
# epub_uid = ''
|
||||
|
||||
# A list of files that should not be packed into the epub file.
|
||||
epub_exclude_files = ['search.html']
|
||||
|
||||
|
||||
|
||||
# Example configuration for intersphinx: refer to the Python standard library.
|
||||
intersphinx_mapping = {'https://docs.python.org/': None}
|
|
@ -1,27 +1,38 @@
|
|||
/*************************************************************************
|
||||
* *
|
||||
* YAP Prolog @(#)c_interface.h 2.2 *
|
||||
* Yap Prolog was developed at NCCUP - Universidade do Porto *
|
||||
* *
|
||||
* Copyright L.Damas, V.S.Costa and Universidade do Porto 1985-1997 *
|
||||
* *
|
||||
**************************************************************************
|
||||
* *
|
||||
* File: YapInterface.h *
|
||||
* Last rev: 19/2/88 *
|
||||
* mods: *
|
||||
* comments: c_interface header file for YAP *
|
||||
* *
|
||||
*************************************************************************/
|
||||
* *
|
||||
* YAP Prolog @(#)c_interface.h 2.2 *
|
||||
* Yap Prolog was developed at NCCUP - Universidade do Porto *
|
||||
* *
|
||||
* Copyright L.Damas, V.S.Costa and Universidade do Porto 1985-1997 *
|
||||
* *
|
||||
**************************************************************************
|
||||
* *
|
||||
* File: YapInterface.h *
|
||||
* Last rev: 19/2/88 *
|
||||
* mods: *
|
||||
* comments: c_interface header file for YAP *
|
||||
* *
|
||||
*************************************************************************/
|
||||
|
||||
/**
|
||||
|
||||
@file YapInterface.h
|
||||
@file YapInterface.h
|
||||
|
||||
@defgroup ChYInterface Foreign Language interface to YAP
|
||||
@{
|
||||
|
||||
@defgroup fli_c_cx Foreign Language interface to YAP
|
||||
|
||||
@toc
|
||||
|
||||
@defgroup ChYInterface C interface to YAP
|
||||
@{
|
||||
|
||||
@ingroup fli_c_cx
|
||||
|
||||
@brief Core interface to YAP.
|
||||
|
||||
@toc
|
||||
|
||||
@brief Core interface to YAP.
|
||||
q
|
||||
*/
|
||||
|
||||
#ifndef _yap_c_interface_h
|
||||
|
|
|
@ -1,13 +1,15 @@
|
|||
|
||||
% File : apply_macros.yap
|
||||
% Author : E. Alphonse from code by Joachim Schimpf
|
||||
% Updated: 15 June 2002
|
||||
% Purpose: Macros to apply a predicate to all elements
|
||||
%% @file apply_macros.yap
|
||||
%% @author E. Alphonse from code by Joachim Schimpf
|
||||
%% @date 15 June 2002
|
||||
%% @nrief Purpose: Macros to apply a predicate to all elements
|
||||
% of a list or to all sub-terms of a term.
|
||||
|
||||
:- module(apply_macros, []).
|
||||
|
||||
/** @defgroup apply_macros Apply Interface to maplist
|
||||
/**
|
||||
|
||||
@defgroup apply_macros Apply Interface to maplist
|
||||
@ingroup library
|
||||
@{
|
||||
|
||||
|
|
|
@ -2,30 +2,15 @@
|
|||
* @file arg.yap
|
||||
* @author VITOR SANTOS COSTA <vsc@VITORs-MBP.lan>
|
||||
* @date Tue Nov 17 01:08:55 2015
|
||||
*
|
||||
* @brief
|
||||
*
|
||||
* @brief
|
||||
*/
|
||||
|
||||
|
||||
|
||||
:- module(arg,
|
||||
[
|
||||
genarg/3,
|
||||
arg0/3,
|
||||
genarg0/3,
|
||||
args/3,
|
||||
args0/3,
|
||||
% project/3
|
||||
path_arg/3
|
||||
]).
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @defgroup arg Term Argument Manipulation.
|
||||
*
|
||||
|
||||
@defgroup arg Term Argument Manipulation.
|
||||
|
||||
@ingroup @library
|
||||
|
||||
|
@ -48,9 +33,22 @@ This file has been included in the YAP library by Vitor Santos Costa, 2008. No e
|
|||
genarg/3.
|
||||
*/
|
||||
|
||||
/**
|
||||
:- module(arg,
|
||||
[
|
||||
genarg/3,
|
||||
arg0/3,
|
||||
genarg0/3,
|
||||
args/3,
|
||||
args0/3,
|
||||
% project/3
|
||||
path_arg/3
|
||||
]).
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @pred arg0( +_Index_, +_Term_ , -_Arg_ )
|
||||
*
|
||||
*
|
||||
* Similar to arg/3, but `arg0(0,_T_,_F_)` unifies _F_ with _T_'s principal functor:
|
||||
|
||||
~~~~~~~~~
|
||||
|
@ -68,9 +66,9 @@ arg0(0,T,A) :- !,
|
|||
arg0(I,T,A) :-
|
||||
arg(I,T,A).
|
||||
|
||||
/**
|
||||
/**
|
||||
* @pred genarg0( +_Index_, +_Term_ , -_Arg_ )
|
||||
*
|
||||
*
|
||||
* Similar to genarg/3, but `genarg0(0,_T_,_F_)` unifies _F_ with _T_'s principal functor:
|
||||
~~~~~~~~~
|
||||
?- genarg0(I,f(a,b),A).
|
||||
|
@ -91,9 +89,9 @@ genarg0(0,T,A) :-
|
|||
genarg0(I,T,A) :-
|
||||
genarg(I,T,A).
|
||||
|
||||
/**
|
||||
/**
|
||||
* @pred args( +_Index_, +_ListOfTerms_ , -_ListOfArgs_ )
|
||||
*
|
||||
*
|
||||
* Succeeds if _ListOfArgs_ unifies with the application of genarg/3 to every element of _ListOfTerms_.
|
||||
|
||||
It corresponds to calling maplist/3 on genarg/3:
|
||||
|
@ -116,9 +114,9 @@ args(I,[T|List],[A|ArgList]) :-
|
|||
genarg(I, T, A),
|
||||
args(I, List, ArgList).
|
||||
|
||||
/**
|
||||
/**
|
||||
* @pred args0( +_Index_, +_ListOfTerms_ , -_ListOfArgs_ )
|
||||
*
|
||||
*
|
||||
* Succeeds if _ListOfArgs_ unifies with the application of genarg0/3 to every element of _ListOfTerms_.
|
||||
|
||||
It corresponds to calling maplist/3 on genarg0/3:
|
||||
|
@ -141,9 +139,9 @@ args0(I,[T|List],[A|ArgList]) :-
|
|||
genarg(I, T, A),
|
||||
args0(I, List, ArgList).
|
||||
|
||||
/**
|
||||
/**
|
||||
* @pred args0( +_ListOfTerms_ , +_Index_, -_ListOfArgs_ )
|
||||
*
|
||||
*
|
||||
* Succeeds if _ListOfArgs_ unifies with the application of genarg0/3 to every element of _ListOfTerms_.
|
||||
|
||||
It corresponds to calling args0/3 but with a different order.
|
||||
|
@ -152,9 +150,9 @@ project(Terms, Index, Args) :-
|
|||
args0(Index, Terms, Args).
|
||||
|
||||
% no error checking here!
|
||||
/**
|
||||
/**
|
||||
* @pred path_arg( +_Path_ , +_Term_, -_Arg_ )
|
||||
*
|
||||
*
|
||||
* Succeeds if _Path_ is empty and _Arg unifies with _Term_, or if _Path_ is a list with _Head_ and _Tail_, genarg/3 succeeds on the current term, and path_arg/3 succeeds on its argument.
|
||||
*
|
||||
* Notice that it can be used to enumerate all possible paths in a term.
|
||||
|
@ -164,5 +162,6 @@ path_arg([Index|Indices], Term, SubTerm) :-
|
|||
genarg(Index, Term, Arg),
|
||||
path_arg(Indices, Arg, SubTerm).
|
||||
|
||||
%%@}
|
||||
%%% @}
|
||||
|
||||
/** @} */
|
||||
|
|
|
@ -474,4 +474,4 @@ write_explicit.
|
|||
write(NodeConnection), nl.
|
||||
*/
|
||||
|
||||
%% @}
|
||||
%% @} @}
|
||||
|
|
|
@ -703,3 +703,6 @@ vertices_without_children((V-[]).Pairs, V.Vertices) :-
|
|||
vertices_without_children(Pairs, Vertices).
|
||||
vertices_without_children(_V-[_|_].Pairs, Vertices) :-
|
||||
vertices_without_children(Pairs, Vertices).
|
||||
|
||||
%% @}/** @} */
|
||||
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
@file swi.h
|
||||
|
||||
@defgroup swi-c-interface SWI-Prolog Foreign Language Interface
|
||||
@ingroup ChYInterface
|
||||
@ingroup fli_c_cx
|
||||
|
||||
*
|
||||
* @tableofcontents
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
* It assumes simple queries and a contiguous interval,
|
||||
* and does not really expect to do non-trivial
|
||||
* constraint propagation and solving.
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
:- module(exo_interval,
|
||||
|
@ -33,7 +33,9 @@
|
|||
op(700, xfx, (#=))]).
|
||||
|
||||
|
||||
/** @defgroup exo_interval Exo Intervals
|
||||
/**
|
||||
|
||||
@defgroup exo_interval Exo Intervals
|
||||
@ingroup library
|
||||
@{
|
||||
|
||||
|
@ -236,3 +238,5 @@ expand_op(A1, A2, A3) :-
|
|||
A1 == max -> A3 = max; A2 == max -> A3 = max;
|
||||
A3 = any
|
||||
).
|
||||
%% @}
|
||||
|
||||
|
|
|
@ -586,4 +586,4 @@ defined_flag(FlagName, FlagGroup, FlagType, DefaultValue, Description, Access, H
|
|||
nonvar(FlagName), nonvar(FlagGroup),
|
||||
'$defined_flag$'(FlagName, FlagGroup, FlagType, DefaultValue, Description, Access, Handler).
|
||||
|
||||
%%@}
|
||||
%% @}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/**
|
||||
* @file hacks.yap
|
||||
* @file library/hacks.yap
|
||||
* @author VITOR SANTOS COSTA <vsc@VITORs-MBP.lan>
|
||||
* @date Tue Nov 17 19:00:25 2015
|
||||
*
|
||||
|
|
|
@ -279,3 +279,5 @@ Succeeds if _Heap_ is an empty heap.
|
|||
empty_heap(t(0,[],t)).
|
||||
|
||||
|
||||
/** @} */
|
||||
|
||||
|
|
|
@ -217,3 +217,5 @@ message and _Data_ with the message itself.
|
|||
mpi_msg_size(Term, Size) :-
|
||||
terms:export_term(Term, Buf, Size),
|
||||
terms:kill_exported_term(Buf).
|
||||
/** @} */
|
||||
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
*************************************************************************/
|
||||
|
||||
/**
|
||||
* @file listing.yap
|
||||
* @file library/listing.yap
|
||||
* @author VITOR SANTOS COSTA <vsc@VITORs-MBP.lan>
|
||||
* @date Tue Nov 17 22:03:59 2015
|
||||
*
|
||||
|
|
|
@ -3,6 +3,10 @@
|
|||
* @author Bob Welham, Lawrence Byrd, and R. A. O'Keefe. Contributions from Vitor Santos Costa, Jan Wielemaker and others.
|
||||
* @date 1999
|
||||
*
|
||||
* @addtogroup library The Prolog Library
|
||||
*
|
||||
* @{
|
||||
*
|
||||
* @brief List Manipulation Predicates
|
||||
*
|
||||
*
|
||||
|
@ -621,3 +625,5 @@ close_list([_|T]) :-
|
|||
|
||||
|
||||
%% @}
|
||||
/** @} */
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/**
|
||||
* @file mapargs.yap
|
||||
* @file library/mapargs.yap
|
||||
* @author Lawrence Byrd + Richard A. O'Keefe, VITOR SANTOS COSTA <vsc@VITORs-MBP.lan>
|
||||
* @author : E. Alphonse from code by Joachim Schimpf, Jan Wielemaker, Vitor Santos Costa
|
||||
* @date 4 August 1984 and Ken Johnson 11-8-87
|
||||
|
|
|
@ -331,7 +331,7 @@ maplist(Pred, [A1|L1], [A2|L2], [A3|L3], [A4|L4]) :-
|
|||
maplist(Pred, L1, L2, L3, L4).
|
||||
|
||||
/**
|
||||
convlist(: _Pred_, + _ListIn_, ? _ListOut_) @anchor convlist
|
||||
convlist(: _Pred_, + _ListIn_, ? _ListOut_) @anchor convlist3
|
||||
|
||||
A combination of maplist/3 and selectlist/3: creates _ListOut_ by
|
||||
applying the predicate _Pred_ to all list elements on which
|
||||
|
@ -355,7 +355,7 @@ convlist(Pred, [_|Olds], News) :-
|
|||
convlist(Pred, Olds, News).
|
||||
|
||||
/**
|
||||
convlist(: Pred, ? ListIn, ?ExtraList, ? ListOut) @anchor convlist
|
||||
convlist(: Pred, ? ListIn, ?ExtraList, ? ListOut) @anchor convlist5
|
||||
|
||||
A combination of maplist/4 and selectlist/3: _ListIn_, _ListExtra_,
|
||||
and _ListOut_ are the sublists so that the predicate _Pred_ succeeds.
|
||||
|
|
|
@ -324,3 +324,5 @@ build_string([S0|S],[C|Lf],L0) :-
|
|||
|
||||
process_arg_entry([],[]) :- !.
|
||||
process_arg_entry(L,['('|L]).
|
||||
/** @} */
|
||||
|
||||
|
|
|
@ -1399,3 +1399,5 @@ ints(A,B,O) :-
|
|||
( A > B -> O = [] ; O = [A|L], A1 is A+1, ints(A1,B,L) ).
|
||||
|
||||
zero(_, 0).
|
||||
/** @} */
|
||||
|
||||
|
|
|
@ -228,3 +228,5 @@ Unify _Size_ with the number of elements in the queue _Queue_.
|
|||
|
||||
|
||||
*/
|
||||
/** @} */
|
||||
|
||||
|
|
|
@ -497,3 +497,5 @@ ord_memberchk(Element, [E|_]) :- E == Element, !.
|
|||
ord_memberchk(Element, [_|Set]) :-
|
||||
ord_memberchk(Element, Set).
|
||||
|
||||
/** @} */
|
||||
|
||||
|
|
|
@ -283,3 +283,5 @@ queue_to_list(Front, Back, Ans) :-
|
|||
queue_to_list([Head|Front], Back, [Head|Tail]) :-
|
||||
queue_to_list(Front, Back, Tail).
|
||||
|
||||
/** @} */
|
||||
|
||||
|
|
|
@ -218,3 +218,5 @@ setrand(rand(X,Y,Z)) :-
|
|||
|
||||
getrand(rand(X,Y,Z)) :-
|
||||
getrand(X,Y,Z).
|
||||
/** @} */
|
||||
|
||||
|
|
|
@ -49,12 +49,11 @@
|
|||
rb_in/3
|
||||
]).
|
||||
|
||||
%%! @{
|
||||
|
||||
/**
|
||||
* @defgroup rbtrees Red-Black Trees
|
||||
* @ingroup library
|
||||
|
||||
|
||||
@{
|
||||
Red-Black trees are balanced search binary trees. They are named because
|
||||
nodes can be classified as either red or black. The code we include is
|
||||
based on "Introduction to Algorithms", second edition, by Cormen,
|
||||
|
@ -96,8 +95,8 @@ form colour(Left, Key, Value, Right), where _colour_ is one of =red= or
|
|||
:- pred next(tree(K,V),K,pair(K,V),V,tree(K,V)).
|
||||
*/
|
||||
|
||||
%% @pred rb_new(-T) is det.
|
||||
% create an empty tree.
|
||||
%% rb_new(-T) is det.
|
||||
%
|
||||
% Create a new Red-Black tree.
|
||||
%
|
||||
|
@ -107,12 +106,12 @@ rb_new(t(Nil,Nil)) :- Nil = black('',_,_,'').
|
|||
|
||||
rb_new(K,V,t(Nil,black(Nil,K,V,Nil))) :- Nil = black('',_,_,'').
|
||||
|
||||
%% rb_empty(?T) is semidet.
|
||||
%% @pred rb_empty(?T) is semidet.
|
||||
%
|
||||
% Succeeds if T is an empty Red-Black tree.
|
||||
rb_empty(t(Nil,Nil)) :- Nil = black('',_,_,'').
|
||||
|
||||
%% rb_lookup(+Key, -Value, +T) is semidet.
|
||||
%% @pred rb_lookup(+Key, -Value, +T) is semidet.
|
||||
%
|
||||
% Backtrack through all elements with key Key in the Red-Black
|
||||
% tree T, returning for each the value Value.
|
||||
|
@ -135,7 +134,7 @@ lookup(<, K, V, Tree) :-
|
|||
lookup(=, _, V, Tree) :-
|
||||
arg(3,Tree,V).
|
||||
|
||||
%% rb_min(+T, -Key, -Value) is semidet.
|
||||
%% @pred rb_min(+T, -Key, -Value) is semidet.
|
||||
%
|
||||
% Key is the minimum key in T, and is associated with Val.
|
||||
|
||||
|
@ -149,7 +148,7 @@ min(red(Right,_,_,_), Key, Val) :-
|
|||
min(black(Right,_,_,_), Key, Val) :-
|
||||
min(Right,Key,Val).
|
||||
|
||||
%% rb_max(+T, -Key, -Value) is semidet.
|
||||
%% @pred rb_max(+T, -Key, -Value) is semidet.
|
||||
%
|
||||
% Key is the maximal key in T, and is associated with Val.
|
||||
|
||||
|
@ -163,7 +162,7 @@ max(red(_,_,_,Left), Key, Val) :-
|
|||
max(black(_,_,_,Left), Key, Val) :-
|
||||
max(Left,Key,Val).
|
||||
|
||||
%% rb_next(+T, +Key, -Next,-Value) is semidet.
|
||||
%% @pred rb_next(+T, +Key, -Next,-Value) is semidet.
|
||||
%
|
||||
% Next is the next element after Key in T, and is associated with
|
||||
% Val.
|
||||
|
@ -193,7 +192,7 @@ next(=, _, _, _, NK, Val, Tree, Candidate) :-
|
|||
Candidate = (NK-Val)
|
||||
).
|
||||
|
||||
%% rb_previous(+T, +Key, -Previous, -Value) is semidet.
|
||||
%% @pred rb_previous(+T, +Key, -Previous, -Value) is semidet.
|
||||
%
|
||||
% Previous is the previous element after Key in T, and is
|
||||
% associated with Val.
|
||||
|
@ -223,8 +222,8 @@ previous(=, _, _, _, K, Val, Tree, Candidate) :-
|
|||
Candidate = (K-Val)
|
||||
).
|
||||
|
||||
%% rb_update(+T, +Key, +NewVal, -TN) is semidet.
|
||||
%% rb_update(+T, +Key, ?OldVal, +NewVal, -TN) is semidet.
|
||||
%% @pred rb_update(+T, +Key, +NewVal, -TN) is semidet.
|
||||
%% @pred rb_update(+T, +Key, ?OldVal, +NewVal, -TN) is semidet.
|
||||
%
|
||||
% Tree TN is tree T, but with value for Key associated with
|
||||
% NewVal. Fails if it cannot find Key in T.
|
||||
|
@ -263,8 +262,8 @@ update(red(Left,Key0,Val0,Right), Key, OldVal, Val, NewTree) :-
|
|||
update(Right, Key, OldVal, Val, NewRight)
|
||||
).
|
||||
|
||||
%% rb_rewrite(+T, +Key, +NewVal) is semidet.
|
||||
%% rb_rewrite(+T, +Key, ?OldVal, +NewVal) is semidet.
|
||||
%% @pred rb_rewrite(+T, +Key, +NewVal) is semidet.
|
||||
%% @pred rb_rewrite(+T, +Key, ?OldVal, +NewVal) is semidet.
|
||||
%
|
||||
% Tree T has value for Key associated with
|
||||
% NewVal. Fails if it cannot find Key in T.
|
||||
|
@ -288,7 +287,7 @@ rewrite(Node, Key, OldVal, Val) :-
|
|||
;
|
||||
rewrite(Right, Key, OldVal, Val)
|
||||
).
|
||||
rewrite(Node, Key, OldVal, Val) :-
|
||||
rewrite(Node, Key, OldVal, Val) :-
|
||||
Node = red(Left,Key0,Val0,Right),
|
||||
Left \= [],
|
||||
compare(Cmp,Key0,Key),
|
||||
|
@ -305,7 +304,7 @@ rewrite(Node, Key, OldVal, Val) :-
|
|||
rewrite(Right, Key, OldVal, Val)
|
||||
).
|
||||
|
||||
%% rb_apply(+T, +Key, :G, -TN) is semidet.
|
||||
%% @pred rb_apply(+T, +Key, :G, -TN) is semidet.
|
||||
%
|
||||
% If the value associated with key Key is Val0 in T, and if
|
||||
% call(G,Val0,ValF) holds, then TN differs from T only in that Key
|
||||
|
|
|
@ -213,3 +213,5 @@ process_opt(I,_,G) :-
|
|||
throw(error(domain_error(flag_value,regexp_options+I),G)).
|
||||
|
||||
|
||||
/** @} */
|
||||
|
||||
|
|
|
@ -3,8 +3,6 @@
|
|||
* @author Nuno A. Fonseca
|
||||
* @date 2008-03-26 23:05:22
|
||||
*
|
||||
* @brief Range-List (RL) tree data structure implementation for YAP
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
|
@ -23,10 +21,10 @@
|
|||
|
||||
|
||||
/**
|
||||
* @defgroup rltrees
|
||||
* @defgroup rltrees Range-List (RL) trees
|
||||
* @ingroup library
|
||||
*
|
||||
* Range-List (RL) tree data structure implementation for YAP
|
||||
* @brief Range-List (RL) tree data structure implementation for YAP
|
||||
*/
|
||||
|
||||
|
||||
|
|
|
@ -274,3 +274,5 @@ join(Left-n(Y, VY, n(X, VX, C, B), NL), n(X, VX, C, n(Y, VY, B, n(Z, VZ, A1, A2)
|
|||
|
||||
splay_init(_).
|
||||
|
||||
/** @} */
|
||||
|
||||
|
|
|
@ -811,3 +811,5 @@ read_link(P,D,F) :-
|
|||
read_link(P, D),
|
||||
absolute_file_name(D, [], F).
|
||||
|
||||
/** @} */
|
||||
|
||||
|
|
|
@ -154,3 +154,5 @@ subsumes_chk(X,Y) :-
|
|||
|
||||
|
||||
|
||||
/** @} */
|
||||
|
||||
|
|
|
@ -102,3 +102,6 @@ time_out(Goal, Time, Result) :-
|
|||
time_out,
|
||||
Result0 = time_out ),
|
||||
Result = Result0.
|
||||
|
||||
%% @}
|
||||
|
||||
|
|
|
@ -243,6 +243,5 @@ tree_to_list(Tree, List) :-
|
|||
list(0, []).
|
||||
list(N, [N|L]) :- M is N-1, list(M, L).
|
||||
|
||||
|
||||
|
||||
%% @}/** @} */
|
||||
|
||||
|
|
|
@ -222,3 +222,6 @@ trie_to_depth_breadth_trie(Trie, DepthBreadthTrie, FinalLabel, OptimizationLevel
|
|||
|
||||
trie_to_depth_breadth_trie(Trie, DepthBreadthTrie, FinalLabel, OptimizationLevel, StartCounter, EndCounter) :-
|
||||
trie_depth_breadth(Trie, DepthBreadthTrie, FinalLabel, OptimizationLevel, StartCounter, EndCounter).
|
||||
|
||||
%% @}
|
||||
|
||||
|
|
|
@ -861,3 +861,5 @@ ugraph_union(<, Head1, Tail1, Head2, Tail2, [Head1|Union]) :-
|
|||
ugraph_union(>, Head1, Tail1, Head2, Tail2, [Head2|Union]) :-
|
||||
ugraph_union([Head1|Tail1], Tail2, Union).
|
||||
|
||||
%% @}
|
||||
|
||||
|
|
|
@ -276,3 +276,5 @@ expand_component([_|Children], Map1, Map, Graph1, NGraph) :-
|
|||
pick_node(Graph,Node,Children,Graph1) :-
|
||||
rb_in(Node,Children,Graph), !,
|
||||
rb_delete(Graph, Node, Graph1).
|
||||
|
||||
%% @}
|
||||
|
|
|
@ -3,102 +3,45 @@
|
|||
* @author VITOR SANTOS COSTA <vsc@VITORs-MBP.lan>
|
||||
* @date 2006
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
:- module( wdgraphs,
|
||||
[
|
||||
wdgraph_new/1,
|
||||
wdgraph_add_edge/5,
|
||||
wdgraph_add_edges/3,
|
||||
wdgraph_add_vertices_and_edges/4,
|
||||
wdgraph_del_edge/5,
|
||||
wdgraph_del_edges/3,
|
||||
wdgraph_del_vertex/3,
|
||||
wdgraph_del_vertices/3,
|
||||
wdgraph_edge/4,
|
||||
wdgraph_to_dgraph/2,
|
||||
dgraph_to_wdgraph/2,
|
||||
wdgraph_neighbors/3,
|
||||
wdgraph_neighbours/3,
|
||||
wdgraph_wneighbors/3,
|
||||
wdgraph_wneighbours/3,
|
||||
wdgraph_transpose/2,
|
||||
wdgraph_transitive_closure/2,
|
||||
wdgraph_symmetric_closure/2,
|
||||
wdgraph_top_sort/2,
|
||||
wdgraph_min_path/5,
|
||||
wdgraph_min_paths/3,
|
||||
wdgraph_max_path/5,
|
||||
wdgraph_path/3,
|
||||
wdgraph_reachable/3]).
|
||||
|
||||
/**
|
||||
* @defgroup wdgraphs Weighted Directed Graphs
|
||||
* @ingroup library
|
||||
*
|
||||
* @brief Weighted Directed Graph Processing Utilities.
|
||||
*
|
||||
* @{
|
||||
*
|
||||
*/
|
||||
|
||||
:- module( wdgraphs,
|
||||
[
|
||||
wdgraph_new/1,
|
||||
wdgraph_add_edge/5,
|
||||
wdgraph_add_edges/3,
|
||||
wdgraph_add_vertices_and_edges/4,
|
||||
wdgraph_del_edge/5,
|
||||
wdgraph_del_edges/3,
|
||||
wdgraph_del_vertex/3,
|
||||
wdgraph_del_vertices/3,
|
||||
wdgraph_edge/4,
|
||||
wdgraph_to_dgraph/2,
|
||||
dgraph_to_wdgraph/2,
|
||||
wdgraph_neighbors/3,
|
||||
wdgraph_neighbours/3,
|
||||
wdgraph_wneighbors/3,
|
||||
wdgraph_wneighbours/3,
|
||||
wdgraph_transpose/2,
|
||||
wdgraph_transitive_closure/2,
|
||||
wdgraph_symmetric_closure/2,
|
||||
wdgraph_top_sort/2,
|
||||
wdgraph_min_path/5,
|
||||
wdgraph_min_paths/3,
|
||||
wdgraph_max_path/5,
|
||||
wdgraph_path/3,
|
||||
wdgraph_reachable/3]).
|
||||
|
||||
:- module( wdgraphs,
|
||||
[
|
||||
wdgraph_new/1,
|
||||
wdgraph_add_edge/5,
|
||||
wdgraph_add_edges/3,
|
||||
wdgraph_add_vertices_and_edges/4,
|
||||
wdgraph_del_edge/5,
|
||||
wdgraph_del_edges/3,
|
||||
wdgraph_del_vertex/3,
|
||||
wdgraph_del_vertices/3,
|
||||
wdgraph_edge/4,
|
||||
wdgraph_to_dgraph/2,
|
||||
dgraph_to_wdgraph/2,
|
||||
wdgraph_neighbors/3,
|
||||
wdgraph_neighbours/3,
|
||||
wdgraph_wneighbors/3,
|
||||
wdgraph_wneighbours/3,
|
||||
wdgraph_transpose/2,
|
||||
wdgraph_transitive_closure/2,
|
||||
wdgraph_symmetric_closure/2,
|
||||
wdgraph_top_sort/2,
|
||||
wdgraph_min_path/5,
|
||||
wdgraph_min_paths/3,
|
||||
wdgraph_max_path/5,
|
||||
wdgraph_path/3,
|
||||
wdgraph_reachable/3]).
|
||||
|
||||
/**
|
||||
* @defgroup wdgraphs Weighted Directed Graph Processing Utilities.
|
||||
|
||||
:- module( wdgraphs,
|
||||
[
|
||||
wdgraph_new/1,
|
||||
wdgraph_add_edge/5,
|
||||
wdgraph_add_edges/3,
|
||||
wdgraph_add_vertices_and_edges/4,
|
||||
wdgraph_del_edge/5,
|
||||
wdgraph_del_edges/3,
|
||||
wdgraph_del_vertex/3,
|
||||
wdgraph_del_vertices/3,
|
||||
wdgraph_edge/4,
|
||||
wdgraph_to_dgraph/2,
|
||||
dgraph_to_wdgraph/2,
|
||||
wdgraph_neighbors/3,
|
||||
wdgraph_neighbours/3,
|
||||
wdgraph_wneighbors/3,
|
||||
wdgraph_wneighbours/3,
|
||||
wdgraph_transpose/2,
|
||||
wdgraph_transitive_closure/2,
|
||||
wdgraph_symmetric_closure/2,
|
||||
wdgraph_top_sort/2,
|
||||
wdgraph_min_path/5,
|
||||
wdgraph_min_paths/3,
|
||||
wdgraph_max_path/5,
|
||||
wdgraph_path/3,
|
||||
wdgraph_reachable/3]).
|
||||
|
||||
/**
|
||||
* @defgroup wdgraphs
|
||||
/**
|
||||
* @defgroup wdgraphs Weighted Directed Graph Processing Utilities.
|
||||
* @ingroup library
|
||||
*
|
||||
*/
|
||||
*/
|
||||
|
||||
|
||||
:- reexport(library(dgraphs),
|
||||
|
@ -527,3 +470,5 @@ reachable([V-_|Vertices], Done0, DoneF, G, [V|EdgesF], Edges0) :-
|
|||
rb_insert(Done0, V, [], Done1),
|
||||
reachable(Kids, Done1, DoneI, G, EdgesF, EdgesI),
|
||||
reachable(Vertices, DoneI, DoneF, G, EdgesI, Edges0).
|
||||
|
||||
%% @}
|
||||
|
|
|
@ -3,8 +3,6 @@
|
|||
* @author VITOR SANTOS COSTA <vsc@VITORs-MBP.lan>
|
||||
* @date 2006
|
||||
*
|
||||
* @brief Weighted Graph Processing Utilities.
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
|
@ -19,8 +17,11 @@ SICStus compatible wgraphs.yap
|
|||
).
|
||||
|
||||
/**
|
||||
* @defgroup wgraphs
|
||||
* @ingroup library
|
||||
* @defgroup wgraphs Weighted Graphs
|
||||
* @ingroup library
|
||||
* @brief Weighted Graph Processing Utilities.
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
|
||||
|
||||
|
@ -56,3 +57,5 @@ vertices_edges_to_wgraph(Vertices, Edges, Graph) :-
|
|||
wdgraph_add_vertices_and_edges(G0, Vertices, Edges, Graph).
|
||||
|
||||
|
||||
%% @}
|
||||
|
||||
|
|
|
@ -2,10 +2,11 @@
|
|||
* @file wundgraphs.yap
|
||||
* @author VITOR SANTOS COSTA <vsc@VITORs-MBP.lan>
|
||||
* @date 2006
|
||||
*
|
||||
* @brief Directed Graph Processing Utilities.
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
:- module( wundgraphs,
|
||||
[
|
||||
wundgraph_add_edge/5,
|
||||
|
@ -16,14 +17,16 @@
|
|||
wundgraph_edges/2,
|
||||
wundgraph_neighbours/3,
|
||||
wundgraph_neighbors/3,
|
||||
wundgraph_wneighbours/3,
|
||||
wundgraph_wneighbours/3,
|
||||
wundgraph_wneighbors/3,
|
||||
wundgraph_min_tree/3,
|
||||
wundgraph_max_tree/3]).
|
||||
|
||||
/**
|
||||
* @defgroup wundgraphs
|
||||
* @defgroup wundgraphs Weighted Undirected Graphs
|
||||
* @ingroup library
|
||||
*
|
||||
* @brief Weighted Undirected Graph Processing Utilities.
|
||||
*/
|
||||
|
||||
|
||||
|
|
|
@ -30,7 +30,7 @@ static char SccsId[] = "%W% %G%";
|
|||
|
||||
|
||||
/**
|
||||
* @defgroup Aliases File Aliases
|
||||
* @defgroup Aliases Aliases to Stream Names
|
||||
* @ingroup InputOutput
|
||||
*
|
||||
* Aliases:
|
||||
|
|
|
@ -28,9 +28,9 @@ static char SccsId[] = "%W% %G%";
|
|||
*
|
||||
*/
|
||||
|
||||
/* @defgroup CharIO Character-Based Input/Output
|
||||
/** @defgroup CharIO Character-Based Input/Output
|
||||
* @ingroup InputOutput
|
||||
*
|
||||
* @{
|
||||
* YAP implements most of the ISO-Prolog built-ins. Input/Output may be
|
||||
*performed on
|
||||
* the current stream or on a specified stream, and it may involve a:
|
||||
|
@ -1220,3 +1220,5 @@ void Yap_InitCharsio(void) {
|
|||
Yap_InitCPred("tab", 2, tab, SafePredFlag | SyncPredFlag);
|
||||
Yap_InitCPred("tab", 1, tab_1, SafePredFlag | SyncPredFlag);
|
||||
}
|
||||
|
||||
/// @}
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
|
||||
/**
|
||||
@defgroup CharacterCodes Character Encoding and Manipulation.
|
||||
@ingroup TextProcessing
|
||||
@ingroup InputOutput
|
||||
@{
|
||||
|
||||
The Prolog library includes a set of built-in predicates designed to
|
||||
|
@ -45,8 +45,8 @@ but are strict in argument checking.
|
|||
+ @ref char_type/2
|
||||
+ @ref code_type/2
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
*/
|
||||
|
||||
/** @predicate char_type(?_Char_ , ?Type)
|
||||
|
@ -238,7 +238,7 @@ prolog:code_type(CH, TYPE) :-
|
|||
between(0,0x10FFFF,CH)
|
||||
),
|
||||
p_code_type( CH, TYPE).
|
||||
|
||||
|
||||
p_code_type( ALNUM, alnum) :-
|
||||
code_type_alnum( ALNUM ).
|
||||
p_code_type( ALPHA, alpha) :-
|
||||
|
@ -1918,4 +1918,4 @@ paren_paren( 0xFF60, 0xFF5F).
|
|||
paren_paren( 0xFF62, 0xFF63).
|
||||
paren_paren( 0xFF63, 0xFF62).
|
||||
|
||||
/// @}
|
||||
/** @} */
|
||||
|
|
|
@ -17,11 +17,11 @@
|
|||
//
|
||||
|
||||
/**
|
||||
* @file memopen.c
|
||||
* @defgroup Memory Streams.
|
||||
* @in.
|
||||
* @return Description of returned value.
|
||||
*/
|
||||
* @file fmemopen.c
|
||||
* @defgroup Memory Streams.
|
||||
* @in.
|
||||
* @return Description of returned value.
|
||||
*/
|
||||
#ifdef __APPLE__
|
||||
|
||||
#include <stdio.h>
|
||||
|
|
|
@ -19,8 +19,10 @@ static char SccsId[] = "%W% %G%";
|
|||
#endif
|
||||
|
||||
/**
|
||||
* @file format.c
|
||||
*
|
||||
* @defgroup FormattedIO Formatted Output
|
||||
* @ingroup YAPIO
|
||||
* @ingroup InputOutput
|
||||
* This file includes the definition of the formatted output predicates.
|
||||
*
|
||||
* @{
|
||||
|
|
|
@ -18,7 +18,9 @@
|
|||
static char SccsId[] = "%W% %G%";
|
||||
#endif
|
||||
|
||||
/*
|
||||
/**
|
||||
*
|
||||
|
||||
* This file includes the definition of a miscellania of standard predicates
|
||||
* for yap refering to: Files and GLOBAL_Streams, Simple Input/Output,
|
||||
*
|
||||
|
|
|
@ -1,68 +0,0 @@
|
|||
#CHECK: JavaLibs
|
||||
|
||||
set (JPL_SOURCES
|
||||
src/c/jpl.c)
|
||||
|
||||
macro_optional_find_package(Java ON)
|
||||
find_package(Java COMPONENTS Development)
|
||||
#find_package(Java COMPONENTS Runtime)
|
||||
macro_log_feature (Java_Development_FOUND "Java"
|
||||
"Use Java System"
|
||||
"http://www.java.org" FALSE)
|
||||
|
||||
if (Java_Development_FOUND)
|
||||
# Java_JAVA_EXECUTABLE = the full path to the Java runtime
|
||||
# Java_JAVAC_EXECUTABLE = the full path to the Java compiler
|
||||
# Java_JAVAH_EXECUTABLE = the full path to the Java header generator
|
||||
# Java_JAVADOC_EXECUTABLE = the full path to the Java documention generator
|
||||
# Java_JAR_EXECUTABLE = the full path to the Java archiver
|
||||
# Java_VERSION_STRING = Version of java found, eg. 1.6.0_12
|
||||
# Java_VERSION_MAJOR = The major version of the package found.
|
||||
# Java_VERSION_MINOR = The minor version of the package found.
|
||||
# Java_VERSION_PATCH = The patch version of the package found.
|
||||
# Java_VERSION_TWEAK = The tweak version of the package found (after '_')
|
||||
# Java_VERSION = This is set to: $major.$minor.$patch(.$tweak)
|
||||
# JAVA_LIBRARIES - path to the java library
|
||||
# JAVA_INCLUDE_PATH - path to where Java.h is found (deprecated)
|
||||
# JAVA_INCLUDE_DIRS - path to where Java.h is found
|
||||
# JAVA_DEBUG_LIBRARIES - path to the debug library (deprecated)
|
||||
# JAVALIBS_VERSION_STRING - version of the Java libs found (since CMake 2.8.8)
|
||||
#
|
||||
#
|
||||
#
|
||||
# The Java_ADDITIONAL_VERSIONS variable can be used to specify a list
|
||||
# of version numbers that should be taken into account when searching
|
||||
# for Java. You need to set this variable before calling
|
||||
# find_package(JavaLibs).
|
||||
#
|
||||
macro_optional_find_package(JNI ON)
|
||||
# JNI_INCLUDE_DIRS = the include dirs to use
|
||||
# JNI_LIBRARIES = the libraries to use
|
||||
# JNI_FOUND = TRUE if JNI headers and libraries were found.
|
||||
# JAVA_AWT_LIBRARY = the path to the jawt library
|
||||
# JAVA_JVM_LIBRARY = the path to the jvm library
|
||||
# JAVA_INCLUDE_PATH = the include path to jni.h
|
||||
# JAVA_INCLUDE_PATH2 = the include path to jni_md.h
|
||||
# JAVA_AWT_INCLUDE_PATH = the include path to jawt.h
|
||||
|
||||
add_library (jplYap SHARED src/c/jpl.c)
|
||||
|
||||
add_subdirectory (src/java)
|
||||
|
||||
include_directories (${JAVA_INCLUDE_DIRS} ${JNI_INCLUDE_DIRS})
|
||||
|
||||
target_link_libraries(jplYap libYap ${JAVA_LIBRARIES} ${JNI_LIBRARIES})
|
||||
|
||||
set_target_properties(jplYap PROPERTIES
|
||||
OUTPUT_NAME jpl )
|
||||
|
||||
install(TARGETS jplYap
|
||||
LIBRARY DESTINATION ${dlls}
|
||||
)
|
||||
|
||||
install(FILES jpl.pl
|
||||
DESTINATION ${libpl}
|
||||
)
|
||||
|
||||
|
||||
endif (Java_Development_FOUND)
|
|
@ -1,105 +0,0 @@
|
|||
[May 21 2008]
|
||||
|
||||
* Enhanced: Bug#247: build test only conditionally. Keri Harris.
|
||||
|
||||
Nov 28, 2006
|
||||
|
||||
* PORT: Bug#357: Updated config.{guess,sub}, needed for development
|
||||
version of FC. Mary Ellen Foster.
|
||||
|
||||
[Jan 30 2008]
|
||||
|
||||
* FIXED: Bug#347: JPL pointer conversion. Mary Ellen Foster.
|
||||
See remark with the bug-report for further info.
|
||||
|
||||
[Jan 23 2008]
|
||||
|
||||
* PORT: Bug#346: Allow overriding COFLAGS and CWFLAGS in package
|
||||
configuration. Keri Harris.
|
||||
Oct 23, 2007
|
||||
|
||||
* ADDED: On Windows, automatically find the JRE is the SDK is not present.
|
||||
Ilmars Poikans.
|
||||
|
||||
Aug 8, 2007
|
||||
|
||||
* FIXED: JRef handling on 64-bit non-Windows platforms.
|
||||
Fixed by Paul Singleton.
|
||||
|
||||
May 24, 2007
|
||||
|
||||
* FIXED: (JW) Exchange of codes 128..255. Lorenz Wallner.
|
||||
|
||||
Mar 16, 2007
|
||||
|
||||
* INSTALL: Really do not require plunit fro normal distribution.
|
||||
|
||||
Apr. 24, 2007
|
||||
|
||||
* FIXED: Bug#263. Crash in 64-bit version. Fixed by Paul Singleton.
|
||||
|
||||
Feb 28, 2007
|
||||
|
||||
* FIXED: Bug#260: errornous integer check. Keri Harris.
|
||||
|
||||
Nov 23, 2006
|
||||
|
||||
* NEW: Integrated Paul Singletons changes. Added test-cases, cleanup
|
||||
of installation, etc. Joint effort of Paul Singleton and Jan Wielemaker.
|
||||
|
||||
Nov 8, 2006
|
||||
|
||||
* PORT: Started work on support for 64-bit linux. Jan Wielemaker.
|
||||
|
||||
Jul 31, 2006
|
||||
|
||||
* CONFIG: Add support for IBM java and Linux/PPC. Keri Harris.
|
||||
|
||||
Jan 31, 2006
|
||||
|
||||
* CONFIG: Windows-XP configure problem on amd64. Keri Harris.
|
||||
|
||||
Oct 28, 2004
|
||||
|
||||
* CONFIG: Bug#197: Handle absolute path for JAVAC. Owen Cliffe.
|
||||
|
||||
Sep 28, 2004
|
||||
|
||||
* CONFIG: Force the use of javac (Sun Java) in configure if nothing is
|
||||
specified by the user.
|
||||
|
||||
May 27, 2004
|
||||
|
||||
* CLEANUP: Made Test2 example stand-alone rather than relying on things
|
||||
wired into jpl.jar and jpl.pl (removed support from there).
|
||||
|
||||
May 26, 2004
|
||||
|
||||
* ADDED: examples/java/SemWeb: Using the SWI-Prolog semantic web library
|
||||
(rdf_db.pl) from Java.
|
||||
|
||||
May 25, 2004
|
||||
|
||||
* ENHANCED: Also use the default engine. This means no engines are created
|
||||
if they are not needed.
|
||||
|
||||
* ENHANCED: Initially only make a single engine. Make upto 10 as they
|
||||
are needed. (JW)
|
||||
|
||||
May 24, 2004
|
||||
|
||||
* ADDED: Initial test suite (check.pl) (JW)
|
||||
|
||||
May 14, 2004
|
||||
|
||||
* JW: Added Makefile for jpl.jar
|
||||
* jpl.c: changed Sprintf() to DEBUG(level, Sdprintf())
|
||||
* exceptions: generate error(java_exception(Ex), ClassName). Provide
|
||||
hook for normal readable error messages.
|
||||
|
||||
May 12, 2004
|
||||
|
||||
* JW: Removed jpl_demo/0
|
||||
* JW: Included library(lists) and removed list predicates
|
||||
* JW: Cleanup of is_pairs/1 and is_pair/1.
|
||||
|
|
@ -1,58 +0,0 @@
|
|||
ELF systems and libpl.so
|
||||
========================
|
||||
|
||||
On Unix systems, SWI-Prolog is normally compiled as an application and
|
||||
static library (lib/$PLARCH/libpl.a). First of all this is easier ported
|
||||
on may Unix systems and second, shared object require position
|
||||
independent code (-fpic) and this is (depending on the processor)
|
||||
generally slower than application code running at a fixed address.
|
||||
|
||||
We link jpl.so using -lpl, so it is linked to the dynamic libpl.so if
|
||||
Prolog is configured using -enable-shared or to the static libpl.a
|
||||
otherwise. On ELF systems that can handle position-dependent (i.e.
|
||||
compiled _without_ -fpic) code in shared objects this works fine. If
|
||||
libjpl.so is loaded directly from Java it will use the Prolog kernel
|
||||
included in libjpl.so. If it is invoked through Prolog, the Prolog
|
||||
application is before libjpl.so in the ELF search path and therefore all
|
||||
Prolog symbols are resolved against the application.
|
||||
|
||||
There are two drawbacks to this approach. The libjpl.so file could have
|
||||
been a small and version independent library, while it is now bulky due
|
||||
to the embedded Prolog engine and version dependent.
|
||||
|
||||
Summarising, if your OS cannot load position dependent .so files you
|
||||
MUST configure SWI-Prolog using --enable-shared. If it can (Linux), the
|
||||
choice is yours and depends on the performance penalty paid on your
|
||||
processor (approx. 7% on an AMD Athon), how you wish to arrange
|
||||
versioning and how keen you are on memory sharing.
|
||||
|
||||
|
||||
Installed components (Unix)
|
||||
===========================
|
||||
|
||||
Make install installs the following components:
|
||||
|
||||
* $PLBASE/library/jpl.pl
|
||||
* $PLBASE/lib/jpl.jar
|
||||
* $PLBASE/lib/$PLARCH/libjpl.so
|
||||
|
||||
The disadvantage of this is that $PLBASE/lib/$PLARCH must be in
|
||||
$LD_LIBRARY_PATH to be able to call Prolog from Java (either when
|
||||
embedding Prolog in Java or using a Prolog -> Java -> Prolog callback).
|
||||
Unfortunately all the other Prolog .so files are loaded by explicitely
|
||||
searching for them.
|
||||
|
||||
|
||||
Finding Java on Windows
|
||||
=======================
|
||||
|
||||
It appears the following keys are relevant for SUN SDK:
|
||||
|
||||
?- win_registry_get_value('HKEY_LOCAL_MACHINE/Software/JavaSoft/Java Development Kit',
|
||||
'CurrentVersion', X).
|
||||
|
||||
X = 1.4
|
||||
|
||||
?- win_registry_get_value('HKEY_LOCAL_MACHINE/Software/JavaSoft/Java Development Kit/1.4', 'JavaHome', X).
|
||||
|
||||
X = 'C:\\j2sdk1.4.2_04'
|
|
@ -1,196 +0,0 @@
|
|||
################################################################
|
||||
# @configure_input@
|
||||
#
|
||||
# Build JPL. Building JPL for Unix currently relies on the following
|
||||
# assumptions:
|
||||
#
|
||||
# * $JAVA_HOME points to the JDK top directory
|
||||
# * $PATH includes $JAVA_HOME/bin
|
||||
# * ELF Dynamic Linker semantics
|
||||
#
|
||||
# Author: Jan Wielemaker, based on shell-scripts from Paul Singleton.
|
||||
################################################################
|
||||
|
||||
PACKAGE=jpl
|
||||
PKGCFLAGS=@JPLCFLAGS@
|
||||
PKGLDFLAGS=@JPLLDFLAGS@
|
||||
|
||||
include ../Makefile.defs
|
||||
|
||||
LIBS=@LIBS@
|
||||
|
||||
JAVA_HOME=@JAVA_HOME@
|
||||
JAVAC=@JAVAC@
|
||||
JAVACFLAGS=@JAVACFLAGS@
|
||||
JAVA=@JAVA@
|
||||
JUNIT=@JUNIT@
|
||||
JAVALIBS=@JAVALIBS@
|
||||
|
||||
LIBPL= $(srcdir)/jpl.pl
|
||||
LIBJPL= @LIBJPL@.@SO@
|
||||
TARGETS= $(LIBJPL)
|
||||
OBJ= src/c/jpl.o
|
||||
|
||||
# YAP has some extra hacks that need to be compiled in.
|
||||
ifeq (@PROLOG_SYSTEM@,yap)
|
||||
src/c/jpl.o: $(srcdir)/src/c/jpl.c $(srcdir)/src/c/hacks.c
|
||||
$(CC) -c $(CFLAGS) $(srcdir)/src/c/jpl.c -o src/c/jpl.o
|
||||
endif
|
||||
|
||||
all: $(TARGETS) jpl.jar exjava-compile jpl_doc
|
||||
|
||||
# linking order counts here: otherwise libjpl.so will not remember
|
||||
# it needs libYap.so
|
||||
@LIBJPL@.@SO@: $(OBJ)
|
||||
$(LD) $(LDSOFLAGS) -o $@ $(OBJ) $(LIBS) $(JAVALIBS) $(LIBPLEMBED)
|
||||
if [ -r @LIBJPL@.@SO@ ]; then \
|
||||
rm -f @LIBJPL@.jnilib && ln -s @LIBJPL@.@SO@ @LIBJPL@.jnilib ; \
|
||||
fi
|
||||
|
||||
jpl.jar::
|
||||
(cd src/java && $(MAKE) jpl_jar)
|
||||
jpl_doc::
|
||||
(cd src/java && $(MAKE) jpl_doc)
|
||||
|
||||
################################################################
|
||||
# Verify the package
|
||||
################################################################
|
||||
|
||||
check: check_pl check_java
|
||||
|
||||
check_pl: jpltest.jar
|
||||
$(PL) -q -f test_jpl.pl -g run_tests,halt -t 'halt(1)'
|
||||
check_java: jpltest.jar
|
||||
JUNIT=$(JUNIT) JAVA=$(JAVA) JAVA_PRELOAD=$(JAVA_PRELOAD) $(srcdir)/test-java.sh
|
||||
|
||||
jpltest.jar:
|
||||
(cd src/java && $(MAKE) test_jar)
|
||||
|
||||
################################################################
|
||||
# Installation
|
||||
################################################################
|
||||
|
||||
DOCDIRS= $(srcdir) $(srcdir)/java_api \
|
||||
$(srcdir)/java_api/javadoc $(srcdir)/java_api/javadoc/jpl \
|
||||
$(srcdir)/java_api/javadoc/jpl/class-use \
|
||||
$(srcdir)/java_api/javadoc/jpl/fli \
|
||||
$(srcdir)/java_api/javadoc/jpl/fli/class-use \
|
||||
$(srcdir)/java_api/javadoc/resources \
|
||||
$(srcdir)/prolog_api \
|
||||
$(srcdir)/prolog_api/overview
|
||||
DOCFILES= $(shell cd $(srcdir)/docs && find . -name '*.html' -o -name '*.gif' -o -name '*.jpg')
|
||||
|
||||
EXPL= $(PKGEXDIR)/jpl/prolog
|
||||
EXPLS= jpl_colour_choose_demo.pl \
|
||||
jpl_jlist_demo.pl \
|
||||
jpl_midi_demo.pl \
|
||||
jpl_table_demo.pl \
|
||||
jpl_text_entry_demo.pl \
|
||||
jpl_versions_demo.pl
|
||||
EXJAVA= $(PKGEXDIR)/jpl/java
|
||||
EXJAVAS= Exceptions Exceptions2 Family FamilyMT Test Test2 Time \
|
||||
Versions Zahed SemWeb
|
||||
|
||||
|
||||
install: all $(LIBPL)
|
||||
mkdir -p $(DESTDIR)$(SOLIBDIR)
|
||||
for f in $(TARGETS); do \
|
||||
$(INSTALL_PROGRAM) "$$f" "$(DESTDIR)$(SOLIBDIR)"; \
|
||||
done
|
||||
ifeq (@SO@,dylib)
|
||||
(cd $(DESTDIR)$(SOLIBDIR) && ln -sf @LIBJPL@.@SO@ @LIBJPL@.jnilib)
|
||||
endif
|
||||
mkdir -p $(DESTDIR)$(PLLIBDIR)
|
||||
mkdir -p $(DESTDIR)$(PLLIBDIR)/jpl
|
||||
for f in $(LIBPL); do \
|
||||
$(INSTALL_DATA) $$f $(DESTDIR)$(PLLIBDIR); \
|
||||
done
|
||||
$(INSTALL_DATA) jpl.jar $(DESTDIR)$(PLLIBDIR)/jpl
|
||||
$(PL) -f none -g make -t halt
|
||||
mkdir -p "$(DESTDIR)$(PLLIBDIR)"
|
||||
for f in $(LIBPL); do \
|
||||
$(INSTALL_DATA) $$f $(DESTDIR)$(PLLIBDIR); \
|
||||
done
|
||||
$(MKINDEX)
|
||||
|
||||
install-examples::
|
||||
expl-install exjava-install
|
||||
|
||||
ln-install::
|
||||
@$(MAKE) INSTALL_DATA='../ln-install' install
|
||||
|
||||
rpm-install: install html-install
|
||||
|
||||
html-install:: expl-install exjava-install
|
||||
mkdir -p $(DESTDIR)$(PKGDOCDIR)/jpl
|
||||
@printf "Creating directories "
|
||||
@for d in $(DOCDIRS); do \
|
||||
mkdir -p $(DESTDIR)$(PKGDOCDIR)/jpl/$$d; printf "."; \
|
||||
done
|
||||
@echo "ok"
|
||||
@printf "Copying documentation files "
|
||||
@for f in $(DOCFILES); do \
|
||||
$(INSTALL_DATA) docs/$$f $(DESTDIR)$(PKGDOCDIR)/jpl/$$f; printf "."; \
|
||||
done
|
||||
@echo "ok"
|
||||
|
||||
expl-install::
|
||||
echo "Installing Prolog examples"
|
||||
mkdir -p $(DESTDIR)$(EXPL)
|
||||
@for f in $(EXPLS) README; do \
|
||||
$(INSTALL_DATA) $(srcdir)/examples/prolog/$$f $(DESTDIR)$(EXPL)/$$f; \
|
||||
done
|
||||
|
||||
exjava-compile: jpl.jar
|
||||
echo "Compiling Java examples"
|
||||
for d in $(EXJAVAS); do \
|
||||
if [ ! -f examples/java/$$d/$$d.class ]; then \
|
||||
echo $$d; \
|
||||
mkdir -p examples/java/$$d; \
|
||||
(cd examples/java/$$d && "$(JAVAC)" $(JAVACFLAGS) -d . -classpath "../../../jpl.jar" $(srcdir)/examples/java/$$d/$$d.java); \
|
||||
fi; \
|
||||
done
|
||||
|
||||
exjava-install: exjava-compile
|
||||
echo "Installing Java examples"
|
||||
mkdir -p "$(DESTDIR)$(EXJAVA)"
|
||||
$(INSTALL_DATA) $(srcdir)/examples/java/README "$(DESTDIR)$(EXJAVA)"
|
||||
$(INSTALL_DATA) $(srcdir)/examples/java/env.@CMDEXT@ "$(DESTDIR)$(EXJAVA)"
|
||||
for d in $(EXJAVAS); do \
|
||||
mkdir -p $(DESTDIR)$(EXJAVA)/$$d; \
|
||||
$(INSTALL_SCRIPT) $(srcdir)/examples/java/$$d/run.@CMDEXT@ "$(DESTDIR)$(EXJAVA)/$$d" ;\
|
||||
$(INSTALL_DATA) $(srcdir)/examples/java/$$d/README "$(DESTDIR)$(EXJAVA)/$$d" ;\
|
||||
$(INSTALL_DATA) $(srcdir)/examples/java/$$d/$$d.java "$(DESTDIR)$(EXJAVA)/$$d" ;\
|
||||
for f in $(srcdir)/examples/java/$$d/*.pl; do \
|
||||
$(INSTALL_DATA) "$$f" "$(DESTDIR)$(EXJAVA)/$$d"; \
|
||||
done ;\
|
||||
$(INSTALL_DATA) examples/java/$$d/$$d*.class $(DESTDIR)$(EXJAVA)/$$d ;\
|
||||
done
|
||||
$(INSTALL_DATA) $(srcdir)/examples/java/SemWeb/test.rdf "$(DESTDIR)$(EXJAVA)/SemWeb"
|
||||
|
||||
pdf-install::
|
||||
mkdir -p $(DESTDIR)$(PKGDOCDIR)
|
||||
$(INSTALL) -m 644 $(DOC).pdf "$(DESTDIR)$(PKGDOCDIR)"
|
||||
|
||||
uninstall::
|
||||
(cd $(PLBASE)/lib/$(PLARCH) && rm -f $(TARGETS))
|
||||
(cd $(PLBASE)/library && rm -f $(LIBPL))
|
||||
$(PL) -f none -g make -t halt
|
||||
|
||||
################################################################
|
||||
# Clean
|
||||
################################################################
|
||||
|
||||
clean:
|
||||
rm -f $(OBJ) *~ *.o *% a.out core config.log
|
||||
rm -f TestJPL.class
|
||||
find examples/java -name '*.class' -delete
|
||||
(cd src/java && $(MAKE) clean)
|
||||
|
||||
distclean: clean
|
||||
rm -rf autom4te.cache
|
||||
rm -f $(TARGETS) config.cache config.h config.status Makefile
|
||||
rm -f $(DOC).aux $(DOC).log $(DOC).out $(DOC).toc
|
||||
rm -rf html
|
||||
(cd src/java && $(MAKE) distclean)
|
||||
|
|
@ -1,119 +0,0 @@
|
|||
################################################################
|
||||
# Build the SWI-Prolog tabling package for MS-Windows
|
||||
#
|
||||
# Author: Jan Wielemaker
|
||||
#
|
||||
# Use:
|
||||
# nmake /f Makefile.mak
|
||||
# nmake /f Makefile.mak install
|
||||
################################################################
|
||||
|
||||
PLHOME=..\..
|
||||
!include ..\..\src\rules.mk
|
||||
JAVA="$(JAVA_HOME)\bin\java"
|
||||
|
||||
PKGDLL=jpl
|
||||
|
||||
EXDIR= $(PKGDOC)\examples\jpl
|
||||
EXPL= $(EXDIR)\prolog
|
||||
EXPLS= jpl_colour_choose_demo.pl \
|
||||
jpl_jlist_demo.pl \
|
||||
jpl_midi_demo.pl \
|
||||
jpl_table_demo.pl \
|
||||
jpl_text_entry_demo.pl \
|
||||
jpl_versions_demo.pl
|
||||
EXJAVA= $(EXDIR)\java
|
||||
EXJAVAS= Exceptions Exceptions2 Family FamilyMT Test Test2 Time \
|
||||
Versions Zahed SemWeb
|
||||
|
||||
|
||||
CFLAGS = $(CFLAGS) \
|
||||
-I"$(JAVA_HOME)\include" \
|
||||
-I"$(JAVA_HOME)\include\win32"
|
||||
LIBS = $(LIBS) "$(JAVA_HOME)\lib\jvm.lib"
|
||||
|
||||
OBJ= src\c\jpl.obj
|
||||
|
||||
all: checkenv $(PKGDLL).dll jar
|
||||
|
||||
jar::
|
||||
chdir src\java & $(MAKE)
|
||||
|
||||
checkenv::
|
||||
@if not exist "$(JAVA_HOME)\lib\jvm.lib" \
|
||||
echo FATAL ERROR: No JAVA_HOME defined? && exit 1
|
||||
|
||||
$(PKGDLL).dll: $(OBJ)
|
||||
$(LD) /dll /out:$@ $(LDFLAGS) $(OBJ) $(PLLIB) $(LIBS)
|
||||
|
||||
!IF "$(CFG)" == "rt"
|
||||
install: idll
|
||||
!ELSE
|
||||
install: idll ilib
|
||||
!ENDIF
|
||||
|
||||
idll::
|
||||
copy $(PKGDLL).dll "$(BINDIR)"
|
||||
ilib::
|
||||
copy jpl.pl "$(PLBASE)\library"
|
||||
copy jpl.jar "$(PLBASE)\lib"
|
||||
$(MAKEINDEX)
|
||||
|
||||
html-install:: expl-install exjava-install
|
||||
@echo CVS > nocopy
|
||||
xcopy /Q /S /I /Y /EXCLUDE:nocopy docs "$(PKGDOC)\jpl"
|
||||
del nocopy
|
||||
|
||||
xpce-install::
|
||||
|
||||
expl-install::
|
||||
if not exist "$(EXDIR)/$(NULL)" $(MKDIR) "$(EXDIR)"
|
||||
if not exist "$(EXPL)/$(NULL)" $(MKDIR) "$(EXPL)"
|
||||
cd examples\prolog & \
|
||||
@for %f in ($(EXPLS)) do @copy %f "$(EXPL)"
|
||||
copy examples\prolog\README "$(EXPL)\README.TXT"
|
||||
|
||||
exjava-install::
|
||||
if not exist "$(EXDIR)/$(NULL)" $(MKDIR) "$(EXDIR)"
|
||||
if not exist "$(EXJAVA)/$(NULL)" $(MKDIR) "$(EXJAVA)"
|
||||
copy examples\java\README "$(EXJAVA)"\README.TXT
|
||||
copy examples\java\env.bat "$(EXJAVA)"
|
||||
for %f in ($(EXJAVAS)) do if not exist "$(EXJAVA)\%f\$(NULL)" mkdir "$(EXJAVA)\%f"
|
||||
for %f in ($(EXJAVAS)) do copy examples\java\%f\run.bat "$(EXJAVA)\%f
|
||||
for %f in ($(EXJAVAS)) do copy examples\java\%f\README "$(EXJAVA)\%f\README.txt
|
||||
for %f in ($(EXJAVAS)) do copy examples\java\%f\%f.java "$(EXJAVA)\%f
|
||||
for %f in ($(EXJAVAS)) do if exist examples\java\%f\*.pl copy examples\java\%f\*.pl "$(EXJAVA)\%f"
|
||||
copy examples\java\SemWeb\test.rdf "$(EXJAVA)\SemWeb"
|
||||
|
||||
uninstall::
|
||||
del "$(PLBASE)\bin\$(PKGDLL).dll"
|
||||
del "$(PLBASE)\library\jpl.pl"
|
||||
del "$(PLBASE)\lib\jpl.jar"
|
||||
$(MAKEINDEX)
|
||||
|
||||
################################################################
|
||||
# Verify the package
|
||||
################################################################
|
||||
|
||||
check: check_pl check_java
|
||||
|
||||
check_pl::
|
||||
"$(PLCON)" -q -f test_jpl.pl -g run_tests,halt -t 'halt(1)'
|
||||
check_java::
|
||||
set CLASSPATH=$(JUNIT);jpl.jar;jpltest.jar
|
||||
$(JAVA) junit.textui.TestRunner jpl.test.TestJUnit
|
||||
|
||||
################################################################
|
||||
# Cleanup
|
||||
################################################################
|
||||
|
||||
clean::
|
||||
if exist $(OBJ) del $(OBJ)
|
||||
if exist *.obj del *.obj
|
||||
if exist *~ del *~
|
||||
chdir src\java & $(MAKE) clean
|
||||
|
||||
distclean: clean
|
||||
-DEL *.dll *.lib *.exp *.pdb *.ilk 2>nul
|
||||
chdir src\java & $(MAKE) distclean
|
||||
|
|
@ -1,23 +0,0 @@
|
|||
# Compiling JPL for MacOS
|
||||
|
||||
Updated: Nov 5, 2013 for MacOS 10.9
|
||||
|
||||
# Using Apple's Java distribution
|
||||
|
||||
Somehow MacOS did not install the Java SDK correctly, so I ended up without
|
||||
jni.h. I did not find a resolution for that.
|
||||
|
||||
# Using Oracle's SDK
|
||||
|
||||
Download from
|
||||
|
||||
- http://www.oracle.com/technetwork/java/javase/downloads/jdk7-downloads-1880260.html
|
||||
|
||||
which installs
|
||||
|
||||
- /Library/Java/JavaVirtualMachines/jdk1.7.0_45.jdk/Contents/Home
|
||||
|
||||
Set $JAVAPREFIX to
|
||||
|
||||
- /Library/Java/JavaVirtualMachines/jdk1.7.0_45.jdk/Contents/Home/bin
|
||||
|
|
@ -1,152 +0,0 @@
|
|||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="CONTENT-TYPE"
|
||||
content="text/html; charset=windows-1252">
|
||||
<title>JPL 3.0 documentation home page</title>
|
||||
<meta name="GENERATOR" content="StarOffice 7 (Win32)">
|
||||
<meta name="AUTHOR" content="Paul Singleton">
|
||||
<meta name="CREATED" content="20040216;23081326">
|
||||
<meta name="CHANGEDBY" content="Paul Singleton">
|
||||
<meta name="CHANGED" content="20040216;23141923">
|
||||
</head>
|
||||
<body lang="en-US" dir="ltr">
|
||||
<h1><span style="font-style: italic;">JPL 3.x</span> documentation home
|
||||
page</h1>
|
||||
<hr>
|
||||
<h2>Introduction</h2>
|
||||
<p><b style="font-style: italic;">JPL 3.x</b> is a dynamic,
|
||||
bidirectional interface
|
||||
between <i>SWI-Prolog 5.2.0</i> or later and <i>Java 2</i>
|
||||
runtimes (see <a href="docs/objectives.html"><span
|
||||
style="font-weight: bold;"><span style="font-style: italic;">JPL 3.x</span>
|
||||
Objectives</span></a>). It offers two APIs: </p>
|
||||
<ul>
|
||||
<li>
|
||||
<p style="margin-bottom: 0cm;"><span style="font-weight: bold;">Java
|
||||
API</span><i> (Java-calls-Prolog)</i>: this
|
||||
interface comprises public Java classes which support: </p>
|
||||
<ul>
|
||||
<li>
|
||||
<p style="margin-bottom: 0cm;">constructing Java
|
||||
representations of Prolog terms and queries </p>
|
||||
</li>
|
||||
<li>
|
||||
<p style="margin-bottom: 0cm;">calling queries within <i>SWI-Prolog</i>
|
||||
engines </p>
|
||||
</li>
|
||||
<li>
|
||||
<p>retrieving (as Java representations of Prolog terms) any
|
||||
bindings created by a call </p>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
<ul>
|
||||
<li>
|
||||
<p style="margin-bottom: 0cm;"><span style="font-weight: bold;">Prolog
|
||||
API</span><i> (Prolog-calls-Java)</i>: this
|
||||
interface comprises Prolog library predicates which support: </p>
|
||||
<ul>
|
||||
<li>
|
||||
<p style="margin-bottom: 0cm;">creating instances (objects) of
|
||||
Java classes (built-in and user-defined) </p>
|
||||
</li>
|
||||
<li>
|
||||
<p style="margin-bottom: 0cm;">calling methods of Java objects
|
||||
(and static methods of classes), perhaps returning values or object
|
||||
references </p>
|
||||
</li>
|
||||
<li>
|
||||
<p>getting and setting the values of fields of Java objects and
|
||||
classes </p>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
<p style="margin-bottom: 0cm;">Calls to the two APIs can be nested,
|
||||
e.g. Java code can call Prolog predicates which call Java methods
|
||||
which call Prolog predicates etc. </p>
|
||||
<hr>
|
||||
<h2>Prerequisites</h2>
|
||||
<p><b><i>JPL 3.x</i></b> currently requires <i>SWI-Prolog 5.2.0</i>
|
||||
or later (it uses multi-threading FLI calls not available in older
|
||||
versions). If you are using <i>SWI-Prolog 5.1.X</i>, then
|
||||
you should probably upgrade to the latest stable <i>5.2.X</i>
|
||||
release. Support for earlier versions may be added in the
|
||||
future. </p>
|
||||
<p><b><i>JPL 3.x</i></b> currently requires a <i>Java 2</i>
|
||||
runtime (or development kit), and has been tested with
|
||||
Sun's <font face="monospace">jdk1.3.1_01</font>. </p>
|
||||
<p><b><i>JPL 3.x</i></b> contains a native library (<font
|
||||
face="monospace">jpl.c</font>)
|
||||
written in <i>ANSI/ISO C</i> and designed to be portable to many
|
||||
operating system platforms for which suitable compilers are
|
||||
available. It has, however, only been tested with <i>Microsoft
|
||||
Visual C/C++ 5</i> under <i>Windows NT 4.0 (SP6a)</i>. I
|
||||
shall be grateful if anyone can (show me how to) tidily adapt the
|
||||
source and makefiles to build for other platforms. </p>
|
||||
<hr>
|
||||
<h2>Documentation</h2>
|
||||
<p>This alpha release of <b><i>JPL 3.x</i></b> contains a
|
||||
hotch-potch of documentation, some left over from Fred Dushin's
|
||||
(Java-calls-Prolog)<i> JPL 1.0.1</i> and now obsolete or misleading,
|
||||
some rewritten for <i>JPL 2.0.2</i> and still mostly applicable,
|
||||
and some written for the first release of my Prolog-calls-Java
|
||||
interface, now part of <b><i>JPL</i></b>, and also mostly still
|
||||
relevant.<br>
|
||||
</p>
|
||||
<p>In addition to this document (index.html in jpl's root folder) there
|
||||
are:<br>
|
||||
</p>
|
||||
<ul>
|
||||
<li><a href="docs/release_notes.html"><b>Release Notes</b></a><b>
|
||||
for 3.0.3, 3.0.2, 3.0.0 and 2.0.2</b></li>
|
||||
<li><a href="docs/installation.html"><b>Installation</b></a></li>
|
||||
<li><b>Java API:<br>
|
||||
</b></li>
|
||||
<ul>
|
||||
<li><a href="docs/java_api/javadoc/index.html"><b>Reference
|
||||
(Javadoc)</b></a></li>
|
||||
<li><a href="docs/java_api/high-level_interface.html"><span
|
||||
style="font-weight: bold;">Overview</span></a></li>
|
||||
<li><b><a href="docs/java_api/gotchas.html"><b>Gotchas</b></a></b></li>
|
||||
<li><b><a href="docs/java_api/getting_started.html"><b>Getting
|
||||
Started</b></a></b></li>
|
||||
</ul>
|
||||
<li><b><b>Prolog API:</b></b></li>
|
||||
<ul>
|
||||
<li><a href="docs/prolog_api/api.html"><span
|
||||
style="font-weight: bold;">Reference</span></a></li>
|
||||
<li><a href="docs/prolog_api/overview/index.html"><b>Overview</b></a></li>
|
||||
<li><a href="docs/prolog_api/gotchas.html"><b>Gotchas</b></a></li>
|
||||
</ul>
|
||||
</ul>
|
||||
<p> </p>
|
||||
<hr>
|
||||
<h2>Installation</h2>
|
||||
<p>Put the three library files (<var>jpl.dll</var>, <var>jpl.jar</var>
|
||||
and <var>jpl.pl</var>) where they can be found by your OS, by your
|
||||
Java apps and by SWI-Prolog respectively; for details, see <a
|
||||
href="docs/installation.html"><b><i>JPL
|
||||
3.x</i> Installation</b></a>.</p>
|
||||
<hr>
|
||||
<h2>Testing</h2>
|
||||
<p>Each of the folders within <font face="monospace">jpl\examples\java</font>
|
||||
contains a simple <i>Java </i>application which tests some
|
||||
aspect of <b><i>JPL</i></b>. These applications are
|
||||
already compiled, and each folder contains a (<i>DOS/Windows</i>)
|
||||
script <font face="monospace">run.bat</font> which announces and
|
||||
runs the demo.<br>
|
||||
<br>
|
||||
Each of the Prolog source files within <span
|
||||
style="font-family: monospace;">jpl/examples/prolog</span> contains a
|
||||
self-contained Prolog application which exercises JPL from within
|
||||
Prolog; start an interactive SWI-Prolog session as usual, and then
|
||||
consult and run these files.<br>
|
||||
</p>
|
||||
<hr>
|
||||
<address><a href="mailto:paul.singleton@bcs.org.uk">Paul Singleton</a></address>
|
||||
<address>February 2004</address>
|
||||
</body>
|
||||
</html>
|
|
@ -1,150 +0,0 @@
|
|||
dnl Modified by Peter Green <plugwash@p10link.net> to correct include paths
|
||||
dnl with OpenJDK on all architectures other than i386 and amd64
|
||||
|
||||
|
||||
dnl Original version is available from the GNU Autoconf Macro Archive at:
|
||||
dnl http://www.gnu.org/software/ac-archive/htmldoc/ac_jni_include_dirs.html
|
||||
dnl
|
||||
|
||||
|
||||
AC_DEFUN([AC_JNI_INCLUDE_DIR],[
|
||||
|
||||
JNI_INCLUDE_DIRS=""
|
||||
|
||||
if test "x$JAVAPREFIX" = x; then
|
||||
test "x$JAVAC" = x && AC_MSG_ERROR(['$JAVAC' undefined])
|
||||
|
||||
case "$JAVAC" in
|
||||
/*) _ACJNI_JAVAC="$JAVAC"
|
||||
;;
|
||||
*) AC_PATH_PROG(_ACJNI_JAVAC, $JAVAC, no)
|
||||
;;
|
||||
esac
|
||||
|
||||
AC_PATH_PROG(_ACJNI_JAVAC, $JAVAC, no)
|
||||
test "x$_ACJNI_JAVAC" = xno && AC_MSG_ERROR([$JAVAC could not be found in path])
|
||||
|
||||
_ACJNI_FOLLOW_SYMLINKS("$_ACJNI_JAVAC")
|
||||
_JTOPDIR=`echo "$_ACJNI_FOLLOWED" | sed -e 's://*:/:g' -e 's:/[[^/]]*$::'`
|
||||
else
|
||||
_JTOPDIR="$(dirname "$JAVAPREFIX")"
|
||||
fi
|
||||
|
||||
found=no
|
||||
while test $found = no; do
|
||||
if test -f "$_JTOPDIR/include/jni.h"; then
|
||||
JNI_INCLUDE_DIRS="$JNI_INCLUDE_DIRS $_JTOPDIR/include"
|
||||
_JINC="$_JTOPDIR/include"
|
||||
found=yes
|
||||
elif test -f "$_JTOPDIR/Headers/jni.h"; then
|
||||
JNI_INCLUDE_DIRS="$JNI_INCLUDE_DIRS $_JTOPDIR/Headers"
|
||||
_JINC="$_JTOPDIR/Headers"
|
||||
found=yes
|
||||
elif test -f "$_JTOPDIR/Contents/Home/include/jni.h"; then
|
||||
_JTOPDIR="$_JTOPDIR/Contents/Home"
|
||||
JNI_INCLUDE_DIRS="$JNI_INCLUDE_DIRS $_JTOPDIR/include"
|
||||
_JINC="$_JTOPDIR/include"
|
||||
found=yes
|
||||
else
|
||||
_JTOPDIR2=`echo "$_JTOPDIR" | sed -e 's:/[[^/]]*$::'`
|
||||
if test "$_JTOPDIR2" = "$_JTOPDIR"; then
|
||||
AC_MSG_ERROR([cannot find java include files])
|
||||
found=oops
|
||||
else
|
||||
_JTOPDIR="$_JTOPDIR2"
|
||||
_JINC="$_JTOPDIR2/include"
|
||||
fi
|
||||
fi
|
||||
done
|
||||
|
||||
AC_MSG_RESULT(_JTOPDIR="$_JTOPDIR")
|
||||
|
||||
# get the likely subdirectories for system specific java includes
|
||||
case "$host_os" in
|
||||
bsdi*) _JNI_INC_SUBDIRS="bsdos";;
|
||||
linux*) _JNI_INC_SUBDIRS="linux genunix";;
|
||||
mingw32*) _JNI_INC_SUBDIRS="win32";;
|
||||
osf*) _JNI_INC_SUBDIRS="alpha";;
|
||||
solaris*) _JNI_INC_SUBDIRS="solaris";;
|
||||
darwin*) _JNI_INC_SUBDIRS="darwin genunix";;
|
||||
*) _JNI_INC_SUBDIRS="genunix";;
|
||||
esac
|
||||
|
||||
# add any subdirectories that are present
|
||||
for JINCSUBDIR in $_JNI_INC_SUBDIRS
|
||||
do
|
||||
if test -d "$_JINC/$JINCSUBDIR"; then
|
||||
JNI_INCLUDE_DIRS="$JNI_INCLUDE_DIRS $_JINC/$JINCSUBDIR"
|
||||
fi
|
||||
done
|
||||
|
||||
case "$host_os" in
|
||||
mingw32*) JNI_CLIENT_DIRS="$_JTOPDIR/lib $_JTOPDIR/jre/bin $_JTOPDIR/jre/bin/server"
|
||||
;;
|
||||
|
||||
*) case "$host_cpu" in
|
||||
i?86)
|
||||
_JNI_LIBDIRS="lib/i386 lib/amd64 lib"
|
||||
_JNI_LIBSUBDIRS="server client"
|
||||
;;
|
||||
x86_64)
|
||||
_JNI_LIBDIRS="lib/amd64"
|
||||
_JNI_LIBSUBDIRS="server"
|
||||
;;
|
||||
powerpc)
|
||||
case "$host_os" in
|
||||
linux*)
|
||||
_JNI_LIBDIRS="lib/ppc bin"
|
||||
_JNI_LIBSUBDIRS="server classic"
|
||||
;;
|
||||
*)
|
||||
_JNI_LIBDIRS=""
|
||||
esac
|
||||
;;
|
||||
*)
|
||||
# Fallback option should work on all architectures except
|
||||
# amd64 and powerpc which are special cased above.
|
||||
_JNI_LIBDIRS="lib/$host_cpu"
|
||||
_JNI_LIBSUBDIRS="server"
|
||||
esac
|
||||
|
||||
for d in $_JNI_LIBDIRS; do
|
||||
for subd in $_JNI_LIBSUBDIRS; do
|
||||
echo "Trying $_JTOPDIR/jre/$d/$subd"
|
||||
if test -d $_JTOPDIR/jre/$d/$subd; then
|
||||
JNI_CLIENT_DIRS="$JNI_CLIENT_DIRS $_JTOPDIR/jre/$d/$subd $_JTOPDIR/jre/$d"
|
||||
case "$target_os" in
|
||||
*linux*)
|
||||
JAVALIBS="$JAVALIBS -Wl,-R$_JTOPDIR/jre/$d/$subd -Wl,-R$_JTOPDIR/jre/$d"
|
||||
;;
|
||||
**)
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
done
|
||||
done
|
||||
|
||||
;;
|
||||
esac
|
||||
|
||||
])
|
||||
|
||||
# _ACJNI_FOLLOW_SYMLINKS <path>
|
||||
# Follows symbolic links on <path>,
|
||||
# finally setting variable _ACJNI_FOLLOWED
|
||||
# --------------------
|
||||
AC_DEFUN([_ACJNI_FOLLOW_SYMLINKS],[
|
||||
# find the include directory relative to the javac executable
|
||||
_cur="$1"
|
||||
while ls -ld "$_cur" 2>/dev/null | grep " -> " >/dev/null; do
|
||||
AC_MSG_CHECKING(symlink for $_cur)
|
||||
_slink=`ls -ld "$_cur" | sed 's/.* -> //'`
|
||||
case "$_slink" in
|
||||
/*) _cur="$_slink";;
|
||||
# 'X' avoids triggering unwanted echo options.
|
||||
*) _cur=`echo "X$_cur" | sed -e 's/^X//' -e 's:[[^/]]*$::'`"$_slink";;
|
||||
esac
|
||||
AC_MSG_RESULT($_cur)
|
||||
done
|
||||
_ACJNI_FOLLOWED="$_cur"
|
||||
])# _ACJNI
|
|
@ -1,15 +0,0 @@
|
|||
dnl Available from the GNU Autoconf Macro Archive at:
|
||||
dnl http://www.gnu.org/software/ac-archive/htmldoc/ac_prog_jar.html
|
||||
dnl
|
||||
AC_DEFUN([AC_PROG_JAR],[
|
||||
AC_REQUIRE([AC_EXEEXT])dnl
|
||||
if test "x$JAR" = x; then
|
||||
if test "x$JAVAPREFIX" = x; then
|
||||
AC_CHECK_PROGS(JAR, jar$EXEEXT)
|
||||
else
|
||||
AC_PATH_PROGS(JAR, jar$EXEEXT, , $JAVAPREFIX)
|
||||
fi
|
||||
fi
|
||||
test "x$JAR" = x && AC_MSG_ERROR([no acceptable jar program found in \$PATH])
|
||||
AC_PROVIDE([$0])dnl
|
||||
])
|
|
@ -1,16 +0,0 @@
|
|||
dnl Available from the GNU Autoconf Macro Archive at:
|
||||
dnl http://www.gnu.org/software/ac-archive/htmldoc/ac_prog_java.html
|
||||
dnl
|
||||
AC_DEFUN([AC_PROG_JAVA],[
|
||||
AC_REQUIRE([AC_EXEEXT])dnl
|
||||
if test "x$JAVA" = x; then
|
||||
if test "x$JAVAPREFIX" = x; then
|
||||
AC_CHECK_PROGS(JAVA, kaffe$EXEEXT java$EXEEXT)
|
||||
else
|
||||
AC_PATH_PROGS(JAVA, kaffe$EXEEXT java$EXEEXT, , $JAVAPREFIX)
|
||||
fi
|
||||
fi
|
||||
test "x$JAVA" = x && AC_MSG_ERROR([no acceptable Java virtual machine found in \$PATH])
|
||||
AC_PROG_JAVA_WORKS
|
||||
AC_PROVIDE([$0])dnl
|
||||
])
|
|
@ -1,31 +0,0 @@
|
|||
dnl Available from the GNU Autoconf Macro Archive at:
|
||||
dnl http://www.gnu.org/software/ac-archive/htmldoc/ac_prog_java_cc.html
|
||||
dnl
|
||||
# AC_PROG_JAVA_CC([COMPILER ...])
|
||||
# --------------------------
|
||||
# COMPILER ... is a space separated list of java compilers to search for.
|
||||
# This just gives the user an opportunity to specify an alternative
|
||||
# search list for the java compiler.
|
||||
AC_DEFUN([AC_PROG_JAVA_CC],
|
||||
[AC_ARG_VAR([JAVA_CC], [java compiler command])dnl
|
||||
AC_ARG_VAR([JAVA_CC_FLAGS], [java compiler flags])dnl
|
||||
m4_ifval([$1],
|
||||
[AC_CHECK_TOOLS(JAVA_CC, [$1])],
|
||||
[AC_CHECK_TOOL(JAVA_CC, gcj)
|
||||
if test -z "$JAVA_CC"; then
|
||||
AC_CHECK_TOOL(JAVA_CC, javac)
|
||||
fi
|
||||
if test -z "$JAVA_CC"; then
|
||||
AC_CHECK_TOOL(JAVA_CC, jikes)
|
||||
fi
|
||||
])
|
||||
|
||||
if test "$JAVA_CC" = "gcj"; then
|
||||
if test "$GCJ_OPTS" = ""; then
|
||||
AC_SUBST(GCJ_OPTS,-C)
|
||||
fi
|
||||
AC_SUBST(JAVA_CC_OPTS, @GCJ_OPTS@,
|
||||
[Define the compilation options for GCJ])
|
||||
fi
|
||||
test -z "$JAVA_CC" && AC_MSG_ERROR([no acceptable java compiler found in \$PATH])
|
||||
])# AC_PROG_JAVA_CC
|
|
@ -1,85 +0,0 @@
|
|||
dnl Available from the GNU Autoconf Macro Archive at:
|
||||
dnl http://www.gnu.org/software/ac-archive/htmldoc/ac_prog_java_works.html
|
||||
dnl
|
||||
AC_DEFUN([AC_PROG_JAVA_WORKS], [
|
||||
AC_CHECK_PROG(uudecode, uudecode$EXEEXT, yes)
|
||||
if test x$uudecode = xyes; then
|
||||
AC_CACHE_CHECK([if uudecode can decode base 64 file], ac_cv_prog_uudecode_base64, [
|
||||
dnl /**
|
||||
dnl * Test.java: used to test if java compiler works.
|
||||
dnl */
|
||||
dnl public class Test
|
||||
dnl {
|
||||
dnl
|
||||
dnl public static void
|
||||
dnl main( String[] argv )
|
||||
dnl {
|
||||
dnl System.exit (0);
|
||||
dnl }
|
||||
dnl
|
||||
dnl }
|
||||
cat << \EOF > Test.uue
|
||||
begin-base64 644 Test.class
|
||||
yv66vgADAC0AFQcAAgEABFRlc3QHAAQBABBqYXZhL2xhbmcvT2JqZWN0AQAE
|
||||
bWFpbgEAFihbTGphdmEvbGFuZy9TdHJpbmc7KVYBAARDb2RlAQAPTGluZU51
|
||||
bWJlclRhYmxlDAAKAAsBAARleGl0AQAEKEkpVgoADQAJBwAOAQAQamF2YS9s
|
||||
YW5nL1N5c3RlbQEABjxpbml0PgEAAygpVgwADwAQCgADABEBAApTb3VyY2VG
|
||||
aWxlAQAJVGVzdC5qYXZhACEAAQADAAAAAAACAAkABQAGAAEABwAAACEAAQAB
|
||||
AAAABQO4AAyxAAAAAQAIAAAACgACAAAACgAEAAsAAQAPABAAAQAHAAAAIQAB
|
||||
AAEAAAAFKrcAErEAAAABAAgAAAAKAAIAAAAEAAQABAABABMAAAACABQ=
|
||||
====
|
||||
EOF
|
||||
if uudecode$EXEEXT Test.uue; then
|
||||
ac_cv_prog_uudecode_base64=yes
|
||||
else
|
||||
echo "configure: __oline__: uudecode had trouble decoding base 64 file 'Test.uue'" >&AC_FD_CC
|
||||
echo "configure: failed file was:" >&AC_FD_CC
|
||||
cat Test.uue >&AC_FD_CC
|
||||
ac_cv_prog_uudecode_base64=no
|
||||
fi
|
||||
rm -f Test.uue])
|
||||
fi
|
||||
if test x$ac_cv_prog_uudecode_base64 != xyes; then
|
||||
rm -f Test.class
|
||||
AC_MSG_WARN([I have to compile Test.class from scratch])
|
||||
if test x$ac_cv_prog_javac_works = xno; then
|
||||
AC_MSG_ERROR([Cannot compile java source. $JAVAC does not work properly])
|
||||
fi
|
||||
if test x$ac_cv_prog_javac_works = x; then
|
||||
AC_PROG_JAVAC
|
||||
fi
|
||||
fi
|
||||
AC_CACHE_CHECK(if $JAVA works, ac_cv_prog_java_works, [
|
||||
JAVA_TEST=Test.java
|
||||
CLASS_TEST=Test.class
|
||||
TEST=Test
|
||||
changequote(, )dnl
|
||||
cat << \EOF > $JAVA_TEST
|
||||
/* [#]line __oline__ "configure" */
|
||||
public class Test {
|
||||
public static void main (String args[]) {
|
||||
System.exit (0);
|
||||
} }
|
||||
EOF
|
||||
changequote([, ])dnl
|
||||
if test x$ac_cv_prog_uudecode_base64 != xyes; then
|
||||
if AC_TRY_COMMAND("$JAVAC" $JAVACFLAGS $JAVA_TEST) && test -s $CLASS_TEST; then
|
||||
:
|
||||
else
|
||||
echo "configure: failed program was:" >&AC_FD_CC
|
||||
cat $JAVA_TEST >&AC_FD_CC
|
||||
AC_MSG_ERROR(The Java compiler $JAVAC failed (see config.log, check the CLASSPATH?))
|
||||
fi
|
||||
fi
|
||||
if AC_TRY_COMMAND("$JAVA" $JAVAFLAGS $TEST) >/dev/null 2>&1; then
|
||||
ac_cv_prog_java_works=yes
|
||||
else
|
||||
echo "configure: failed program was:" >&AC_FD_CC
|
||||
cat $JAVA_TEST >&AC_FD_CC
|
||||
AC_MSG_ERROR(The Java VM $JAVA failed (see config.log, check the CLASSPATH?))
|
||||
fi
|
||||
rm -fr $JAVA_TEST $CLASS_TEST Test.uue
|
||||
])
|
||||
AC_PROVIDE([$0])dnl
|
||||
]
|
||||
)
|
|
@ -1,25 +0,0 @@
|
|||
dnl Available from the GNU Autoconf Macro Archive at:
|
||||
dnl http://www.gnu.org/software/ac-archive/htmldoc/ac_prog_javac.html
|
||||
dnl
|
||||
AC_DEFUN([AC_PROG_JAVAC],[
|
||||
AC_REQUIRE([AC_EXEEXT])dnl
|
||||
if test "x$JAVAC" = x; then
|
||||
if test "x$JAVAPREFIX" = x; then
|
||||
AC_CHECK_PROGS(JAVAC, jikes$EXEEXT javac$EXEEXT gcj$EXEEXT guavac$EXEEXT)
|
||||
else
|
||||
AC_PATH_PROGS(JAVAC, jikes$EXEEXT javac$EXEEXT gcj$EXEEXT guavac$EXEEXT, , "$JAVAPREFIX")
|
||||
fi
|
||||
fi
|
||||
test "x$JAVAC" = x && AC_MSG_ERROR([no acceptable Java compiler found in \$PATH])
|
||||
if test "$JAVAC" = "gcj$EXEEXT"; then
|
||||
case "$JAVACFLAGS" in
|
||||
*-C*)
|
||||
;;
|
||||
*)
|
||||
JAVACFLAGS="$JAVACFLAGS -C"
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
AC_PROG_JAVAC_WORKS
|
||||
AC_PROVIDE([$0])dnl
|
||||
])
|
|
@ -1,23 +0,0 @@
|
|||
dnl Available from the GNU Autoconf Macro Archive at:
|
||||
dnl http://www.gnu.org/software/ac-archive/htmldoc/ac_prog_javac_works.html
|
||||
dnl
|
||||
AC_DEFUN([AC_PROG_JAVAC_WORKS],[
|
||||
AC_CACHE_CHECK([if $JAVAC works], ac_cv_prog_javac_works, [
|
||||
JAVA_TEST=Test.java
|
||||
CLASS_TEST=Test.class
|
||||
cat << \EOF > $JAVA_TEST
|
||||
/* [#]line __oline__ "configure" */
|
||||
public class Test {
|
||||
}
|
||||
EOF
|
||||
if AC_TRY_COMMAND("$JAVAC" $JAVACFLAGS $JAVA_TEST) >/dev/null 2>&1; then
|
||||
ac_cv_prog_javac_works=yes
|
||||
else
|
||||
AC_MSG_ERROR([The Java compiler $JAVAC failed (see config.log, check the CLASSPATH?)])
|
||||
echo "configure: failed program was:" >&AC_FD_CC
|
||||
cat $JAVA_TEST >&AC_FD_CC
|
||||
fi
|
||||
rm -f $JAVA_TEST $CLASS_TEST
|
||||
])
|
||||
AC_PROVIDE([$0])dnl
|
||||
])
|
|
@ -1,16 +0,0 @@
|
|||
dnl Available from the GNU Autoconf Macro Archive at:
|
||||
dnl http://www.gnu.org/software/ac-archive/htmldoc/ac_prog_javadoc.html
|
||||
dnl
|
||||
AC_DEFUN([AC_PROG_JAVADOC],[
|
||||
AC_REQUIRE([AC_EXEEXT])dnl
|
||||
if test "x$JAVADOC" = x; then
|
||||
if test "x$JAVAPREFIX" = x; then
|
||||
AC_CHECK_PROGS(JAVADOC, javadoc$EXEEXT)
|
||||
else
|
||||
AC_PATH_PROGS(JAVADOC, javadoc$EXEEXT, , "$JAVAPREFIX")
|
||||
fi
|
||||
fi
|
||||
test "x$JAVADOC" = x && AC_MSG_ERROR([no acceptable javadoc generator found in \$PATH])
|
||||
AC_PROVIDE([$0])dnl
|
||||
])
|
||||
|
|
@ -1,20 +0,0 @@
|
|||
dnl Available from the GNU Autoconf Macro Archive at:
|
||||
dnl http://www.gnu.org/software/ac-archive/htmldoc/ac_prog_javah.html
|
||||
dnl
|
||||
AC_DEFUN([AC_PROG_JAVAH],[
|
||||
AC_REQUIRE([AC_CANONICAL_SYSTEM])dnl
|
||||
AC_REQUIRE([AC_PROG_CPP])dnl
|
||||
AC_PATH_PROG(JAVAH,javah)
|
||||
if test x"`eval 'echo $ac_cv_path_JAVAH'`" != x ; then
|
||||
AC_TRY_CPP([#include <jni.h>],,[
|
||||
ac_save_CPPFLAGS="$CPPFLAGS"
|
||||
changequote(, )dnl
|
||||
ac_dir=`echo $ac_cv_path_JAVAH | sed 's,\(.*\)/[^/]*/[^/]*$,\1/include,'`
|
||||
ac_machdep=`echo $build_os | sed 's,[-0-9].*,,' | sed 's,cygwin,win32,'`
|
||||
changequote([, ])dnl
|
||||
CPPFLAGS="$ac_save_CPPFLAGS -I$ac_dir -I$ac_dir/$ac_machdep"
|
||||
AC_TRY_CPP([#include <jni.h>],
|
||||
ac_save_CPPFLAGS="$CPPFLAGS",
|
||||
AC_MSG_WARN([unable to include <jni.h>]))
|
||||
CPPFLAGS="$ac_save_CPPFLAGS"])
|
||||
fi])
|
|
@ -1 +0,0 @@
|
|||
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
@ -1,158 +0,0 @@
|
|||
dnl Process this file with autoconf to produce a configure script.
|
||||
|
||||
m4_ifdef([HAS_TOP],[m4_ignore],[ AC_INIT(install-sh)
|
||||
AC_PREREQ([2.50])
|
||||
AC_CONFIG_HEADER(config.h)
|
||||
])
|
||||
|
||||
AC_SUBST(JAVA_HOME)
|
||||
AC_SUBST(JAVACFLAGS)
|
||||
AC_SUBST(JAVALIBS)
|
||||
AC_SUBST(JUNIT)
|
||||
AC_SUBST(JPLCFLAGS)
|
||||
AC_SUBST(JPLLDFLAGS)
|
||||
AC_SUBST(LIBJPL)
|
||||
AC_SUBST(JAVA_PRELOAD)
|
||||
AC_SUBST(CMDEXT)
|
||||
|
||||
m4_ifdef([HAS_TOP],[m4_ignore],[
|
||||
m4_include([../ac_swi_c.m4])
|
||||
])
|
||||
|
||||
CMDEXT=sh
|
||||
|
||||
if test "x$JAVALIBS" = "x"; then
|
||||
case "$PLARCH" in
|
||||
*darwin*)
|
||||
JAVALIBS="-Wl,-framework,JavaVM"
|
||||
;;
|
||||
*powerpc-linux*)
|
||||
JAVALIBS="-ljava -ljvm"
|
||||
;;
|
||||
*win32*|*win64*)
|
||||
JAVALIBS="-ljvm"
|
||||
CMDEXT=bat
|
||||
;;
|
||||
*)
|
||||
JAVALIBS="-ljava -lverify -ljvm"
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
|
||||
case "$PLARCH" in
|
||||
*win32*)
|
||||
JPLLDFLAGS="$JPLLDFLAGS -Wl,--kill-at"
|
||||
LIBJPL=jpl
|
||||
;;
|
||||
*win64*)
|
||||
LIBJPL=jpl
|
||||
;;
|
||||
*)
|
||||
LIBJPL=libjpl
|
||||
;;
|
||||
esac
|
||||
|
||||
dnl ================================================================
|
||||
dnl Java stuff
|
||||
dnl ================================================================
|
||||
|
||||
AC_CANONICAL_HOST dnl needed to get $host_os
|
||||
|
||||
dnl if test "x$JAVACFLAGS" = x; then
|
||||
dnl JAVACFLAGS="-source 1.4 -target 1.4"
|
||||
dnl fi
|
||||
|
||||
m4_include([ac/ac_prog_java.m4])
|
||||
m4_include([ac/ac_prog_java_works.m4])
|
||||
m4_include([ac/ac_prog_javac.m4])
|
||||
m4_include([ac/ac_prog_javac_works.m4])
|
||||
m4_include([ac/ac_prog_javadoc.m4])
|
||||
m4_include([ac/ac_jni_include_dirs.m4])
|
||||
m4_include([ac/ac_prog_jar.m4])
|
||||
|
||||
java_abs_paths=no
|
||||
AC_CHECKING(Java configuration)
|
||||
if test -r /etc/java/java2.conf; then
|
||||
AC_MSG_RESULT(Using /etc/java/java2.conf)
|
||||
eval `grep '\(JAVA\|JRE\|JDK\|SDK\).*=' /etc/java/java2.conf | sed 's/ *= */=/'`
|
||||
if test ! -z "$JAVA_BINDIR"; then
|
||||
PATH="$PATH:$JAVA_BINDIR"
|
||||
java_abs_paths=yes
|
||||
fi
|
||||
fi
|
||||
|
||||
AC_PROG_JAVAC(javac)
|
||||
AC_PROG_JAVA(java)
|
||||
AC_PROG_JAR(jar)
|
||||
AC_PROG_JAVADOC(javadoc)
|
||||
|
||||
escape_space()
|
||||
{ sed -e "s/Program Files/Program-SPACE-Files/g" -e "s/ (x86)/SPACEX86/g"
|
||||
}
|
||||
|
||||
unescape_space()
|
||||
{ sed -e "s/-SPACE-/ /g" -e "s/SPACEX86/ (x86)/g"
|
||||
}
|
||||
|
||||
AC_JNI_INCLUDE_DIR
|
||||
for d in $(echo $JNI_INCLUDE_DIRS | escape_space); do
|
||||
JPLCFLAGS="$JPLCFLAGS -I'$d'"
|
||||
done
|
||||
JPLCFLAGS="$(echo $JPLCFLAGS | unescape_space)"
|
||||
|
||||
for d in $(echo $JNI_CLIENT_DIRS | escape_space); do
|
||||
JPLLDFLAGS="$JPLLDFLAGS -L'$d'"
|
||||
done
|
||||
JPLLDFLAGS="$(echo $JPLLDFLAGS | unescape_space)"
|
||||
|
||||
case "$PLARCH" in
|
||||
*darwin*)
|
||||
;;
|
||||
**)
|
||||
for d in $(echo $JNI_CLIENT_DIRS | escape_space); do
|
||||
if test -f "$d/libjsig.$SO"; then
|
||||
JAVALIBS="-ljsig $JAVALIBS"
|
||||
JAVA_PRELOAD=$d/libjsig.$SO
|
||||
break
|
||||
fi
|
||||
done
|
||||
esac
|
||||
JAVA_PRELOAD="$(echo $JAVA_PRELOAD | unescape_space)"
|
||||
|
||||
if test "$java_abs_paths" = yes; then
|
||||
JAVA_CC="$JAVA_BINDIR/$JAVA_CC"
|
||||
fi
|
||||
|
||||
AC_ARG_WITH(junit, [ --with-junit=PATH Specify location of the junit JAR file],
|
||||
[case "$withval" in
|
||||
yes) JUNIT=/usr/share/java/junit.jar
|
||||
;;
|
||||
no) JUNIT=""
|
||||
;;
|
||||
*) JUNIT="$withval"
|
||||
;;
|
||||
esac
|
||||
],
|
||||
[ if test "x$JUNIT" = "x" -a -r /usr/share/java/junit.jar; then
|
||||
JUNIT=/usr/share/java/junit.jar
|
||||
fi
|
||||
]
|
||||
)
|
||||
|
||||
AC_CHECK_HEADERS(wchar.h)
|
||||
AC_CHECK_SIZEOF(wchar_t, 4)
|
||||
AC_CHECK_SIZEOF(void*, 4)
|
||||
AC_CHECK_SIZEOF(long, 4)
|
||||
AC_CHECK_SIZEOF(long long, 8)
|
||||
|
||||
if test $i_am_cross_compiling = yes
|
||||
then
|
||||
#mingw: we know where things are
|
||||
JPLCFLAGS="-I \"$yap_cv_java\"/include -I \"$yap_cv_java\"/include/win32"
|
||||
JAVALIBS="-L \"$yap_cv_java\"/jre/bin/server -L \"$yap_cv_java\"/jre/bin/client -ljvm"
|
||||
fi
|
||||
|
||||
|
||||
|
||||
m4_ifdef([HAS_TOP],[m4_ignore], [AC_OUTPUT(Makefile src/java/Makefile)])
|
||||
|
|
@ -1,28 +0,0 @@
|
|||
:- asserta(file_search_path(foreign, '.')).
|
||||
:- asserta(file_search_path(jpl_examples, 'examples/prolog')).
|
||||
:- asserta(file_search_path(jar, '.')).
|
||||
:- asserta(file_search_path(library, '.')).
|
||||
|
||||
:- use_module(library(jpl)).
|
||||
|
||||
/*******************************
|
||||
* DEMOS *
|
||||
*******************************/
|
||||
|
||||
jpl_demo :-
|
||||
absolute_file_name(jpl_examples(.),
|
||||
[ file_type(directory),
|
||||
access(read)
|
||||
],
|
||||
ExampleDir),
|
||||
atom_concat(ExampleDir, '/*.pl', Pattern),
|
||||
expand_file_name(Pattern, Examples),
|
||||
tag_basename(Examples, Entries),
|
||||
menu('Select JPL example', Entries, Example),
|
||||
consult(Example).
|
||||
|
||||
tag_basename([], []).
|
||||
tag_basename([H|T0], [H:B|T]) :-
|
||||
file_base_name(H, B),
|
||||
tag_basename(T0, T).
|
||||
|
|
@ -1,45 +0,0 @@
|
|||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
|
||||
|
||||
<html>
|
||||
<head>
|
||||
<title>JPL: A bidirectional Prolog/Java interface</title>
|
||||
</head>
|
||||
<body>
|
||||
<h1 align=center>JPL: A bidirectional Prolog/Java interface</h1>
|
||||
|
||||
<blockquote>
|
||||
<hr>
|
||||
This version of the documentation is a quick and dirty collection of
|
||||
the available documentation. It contains error, references to obsolete
|
||||
constructs, limitations that have been removed, etc. We hope this situation
|
||||
will improve soon.
|
||||
<hr>
|
||||
</blockquote>
|
||||
|
||||
<p>
|
||||
JPL is a library using the SWI-Prolog foreign interface and the Java jni
|
||||
interface providing a bidirectional interface between Java and Prolog
|
||||
that can be used to embed Prolog in Java as well as for embedding Java
|
||||
in Prolog. In both setups it provides a reentrant bidirectional interface.
|
||||
|
||||
<ul>
|
||||
<li><a href="objectives.html">Objectives</a>
|
||||
<li><a href="java_api/index.html">Using Prolog from Java</a>
|
||||
<li>Using Java from Prolog
|
||||
<ul>
|
||||
<li><a href="prolog_api/overview.html">User guide</a>
|
||||
<li><a href="prolog_api/api.html">API reference</a>
|
||||
<li><a href="prolog_api/gotchas.html">Gotchas</a>
|
||||
</ul>
|
||||
<li><a href="installation.html">Installation</a>
|
||||
<li><a href="release_notes.html">Release notes</a>
|
||||
</ul>
|
||||
|
||||
<address>
|
||||
<a href="mailto:paul.singleton@bcs.org.uk">Paul Singleton</a><br>
|
||||
Fred Dushin<br>
|
||||
Jan Wielemaker
|
||||
</address>
|
||||
|
||||
</body>
|
||||
</html>
|
|
@ -1,181 +0,0 @@
|
|||
<!DOCTYPE html PUBLIC "-//w3c//dtd html 4.0 transitional//en">
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type"
|
||||
content="text/html; charset=iso-8859-1">
|
||||
<meta name="Author" content="Paul Singleton">
|
||||
<meta name="GENERATOR"
|
||||
content="Mozilla/4.74 [en] (WinNT; U) [Netscape]">
|
||||
<title>JPL 3.x installation</title>
|
||||
</head>
|
||||
<body>
|
||||
<h1><span style="font-style: italic;">
|
||||
JPL 3.x</span> installation</h1>
|
||||
<hr width="100%">
|
||||
First check that the prerequisites (see the home page) are satisfied
|
||||
(you have SWI-Prolog 5.2.0 or later, a Java 2 SDK, and a compatible
|
||||
operating
|
||||
system).
|
||||
<p>Unzip <span style="font-family: monospace;">jpl.zip</span>
|
||||
somewhere
|
||||
safe (maybe into the <span style="font-family: monospace;">\pl</span>
|
||||
folder of your <span style="font-style: italic;">SWI-Prolog</span>
|
||||
installation): it creates a folder <span
|
||||
style="font-family: monospace;">\jpl</span>
|
||||
which you should retain.
|
||||
</p>
|
||||
<p>Inspect your new <span style="font-family: monospace;">\jpl</span>
|
||||
folder: it should contain
|
||||
</p>
|
||||
<pre style="margin-left: 40px;">jpl<br> +--- examples<br> | +--- Exceptions<br> | +--- Exceptions2<br> | +--- Family<br> | +--- Test<br> | +--- Test2<br> | +--- Time<br> | +--- Zahed<br> | +--- <i>(and maybe more...)<br> |<br></i> +--- docs <span
|
||||
style="font-style: italic;"> (HTML files in here are accessible via links from the home page)</span><br> |<br> +--- src<br> | +--- c<br> | | +--- build.bat <span
|
||||
style="font-style: italic;">(Windows script to recompile jpl.c to jpl.dll)</span><br> | | +--- build.sh <span
|
||||
style="font-style: italic;">(Linux script to recompile jpl.c to libjpl.so)</span><br> | +--- java<br> |<br> +--- jpl.dll <span
|
||||
style="font-style: italic;">(a native library - for Windows in this case)</span>
|
||||
|
|
||||
+--- jpl.jar <span
|
||||
style="font-style: italic;"> (a Java library)</span>
|
||||
|
|
||||
+--- jpl.pl <span
|
||||
style="font-style: italic;">(a Prolog library)</span>
|
||||
|
|
||||
+--- README.html <span
|
||||
style="font-style: italic;">(<span style="font-weight: bold; font-style: italic;">JPL</span>'s documentation "home page")</span>
|
||||
|
||||
</pre>
|
||||
Put the three library files (<span style="font-family: monospace;">jpl.dll</span>,<span
|
||||
style="font-family: monospace;"> jpl.jar</span>
|
||||
and <span style="font-family: monospace;">jpl.pl</span>) where
|
||||
each
|
||||
can be found:
|
||||
<ul>
|
||||
<li> <span style="font-family: monospace;">jpl.dll</span> must be
|
||||
found
|
||||
by the <span style="font-style: italic;">Windows </span>kernel,
|
||||
and can go in any folder on your <span
|
||||
style="font-family: monospace;">PATH</span>;
|
||||
perhaps <span style="font-family: monospace;">%SWI_HOME_DIR%\bin</span>
|
||||
or your Windows system folder<span style="font-family: monospace;"></span></li>
|
||||
<li> <span style="font-family: monospace;">jpl.jar</span> must be
|
||||
found
|
||||
by any <span style="font-style: italic;">Java </span>VMs
|
||||
(and compilers) used with <span
|
||||
style="font-weight: bold; font-style: italic;">JPL</span>;
|
||||
one possibility is to put it on your global <span
|
||||
style="font-family: monospace;">CLASSPATH</span></li>
|
||||
<li> <span style="font-family: monospace;">jpl.pl</span> is a Prolog
|
||||
source
|
||||
module, and must be found by any <span style="font-style: italic;">SWI-Prolog</span>
|
||||
engines used with <span
|
||||
style="font-weight: bold; font-style: italic;">JPL</span>:
|
||||
I suggest putting it in <span style="font-family: monospace;">%SWI_HOME_DIR%\library</span>
|
||||
and then invoking <span
|
||||
style="font-family: helvetica,arial,sans-serif;">make_library_index/1</span>
|
||||
on that folder (see a<span style="font-style: italic;"> SWI-Prolog</span>
|
||||
manual for details) so that the autoloader can find it.</li>
|
||||
</ul>
|
||||
For <span style="font-style: italic;">SWI-Prolog</span> to
|
||||
initialise
|
||||
(or make the first call) to <span
|
||||
style="font-weight: bold; font-style: italic;">JPL</span>,
|
||||
it is necessary that a folder containing the <span
|
||||
style="font-style: italic;">JVM</span>library
|
||||
(<span style="font-family: monospace;">jvm.dll</span>) is on your PATH;
|
||||
if you are using a recent <span style="font-style: italic;">Sun </span>JRE,
|
||||
look for a PATH entry of the form <span
|
||||
style="font-family: monospace;">C:\jdk1.3.1_01\jre\bin\hotspot;</span>
|
||||
or <span style="font-family: monospace;">C:\jdk1.3.1_01\jre\bin\client;
|
||||
<br>
|
||||
</span><br>
|
||||
If your applications start in Java, and then call <span
|
||||
style="font-style: italic;">SWI-Prolog</span>,
|
||||
it is necessary that the <span style="font-style: italic;">SWI-Prolog</span>
|
||||
library <span style="font-family: courier new,courier,monospace;"><font
|
||||
size="-1">libpl.dll</font></span>
|
||||
is in a folder on the PATH<br>
|
||||
<br>
|
||||
Try the Java example in
|
||||
<pre style="margin-left: 40px;">examples/java/Versions</pre>
|
||||
or the Prolog example in
|
||||
<pre style="margin-left: 40px;">examples/prolog/jpl_versions_demo.pl<br></pre>
|
||||
to confirm that all three libraries are installed and compatible.<br>
|
||||
<h3>Installation troubleshooting</h3>
|
||||
If the example programs don't run successfully, look carefully at any
|
||||
error
|
||||
messages; they typically indicate where the problem lies. Then
|
||||
check
|
||||
the installation instruction s and prerequisites carefully.
|
||||
<br>
|
||||
|
||||
<ul>
|
||||
<li>If you get a message about</li>
|
||||
</ul>
|
||||
<pre style="margin-left: 80px; font-weight: bold; font-style: italic;">... jpl.dll ... Access is denied ...</pre>
|
||||
<div style="margin-left: 40px;">then you may have lost execute
|
||||
permission
|
||||
on <span style="font-family: courier new,courier,monospace;"><font
|
||||
size="-1">jpl.dll</font></span>
|
||||
(please consult local <span style="font-style: italic;">Windows </span>expertise
|
||||
if you don't know how to correct this).</div>
|
||||
<ul>
|
||||
<li>If <span style="font-family: courier new,courier,monospace;"><font
|
||||
size="-1">jpl_examples/0</font></span>
|
||||
complains that</li>
|
||||
</ul>
|
||||
<div style="margin-left: 80px;"><span
|
||||
style="font-weight: bold; font-style: italic;">The
|
||||
dynamic link library jvm.dll could not be found in the specified path</span>
|
||||
<br>
|
||||
</div>
|
||||
<div style="margin-left: 40px;">then you should locate jvm.dll within
|
||||
the
|
||||
Java runtime which you intend to use, and ensure that its directory is
|
||||
within the PATH.</div>
|
||||
<ul>
|
||||
<li>if the Java examples (e.g. <span
|
||||
style="font-family: courier new,courier,monospace;"><font size="-1">jpl\examples\Exception\run.bat</font></span>)
|
||||
complain that</li>
|
||||
</ul>
|
||||
<div style="margin-left: 80px;"><span style="font-weight: bold;"><span
|
||||
style="font-style: italic;">The
|
||||
name specified is not recognized as an internal or external command,
|
||||
operable
|
||||
program or batch file.</span>
|
||||
<br>
|
||||
</span></div>
|
||||
<div style="margin-left: 40px;">
|
||||
<br>
|
||||
then there is no Java executable <span
|
||||
style="font-family: courier new,courier,monospace;"><font size="-1">java.exe</font></span>
|
||||
in any folder on your PATH: you should have a PATH entry such as <span
|
||||
style="font-family: courier new,courier,monospace;"><font size="-1">C:\jdk1.3.1_01\bin;</font></span></div>
|
||||
<ul>
|
||||
<li>if the Java examples complain that</li>
|
||||
</ul>
|
||||
<div style="margin-left: 80px;"><span
|
||||
style="font-weight: bold; font-style: italic;">The
|
||||
dynamic link library libpl.dll could not be found in the specified path</span></div>
|
||||
<div style="margin-left: 40px;">or</div>
|
||||
<div style="margin-left: 80px;"><span
|
||||
style="font-weight: bold; font-style: italic;">Exception
|
||||
in thread "main" java.lang.UnsatisfiedLinkError: C:\paul\bin\jpl.dll:
|
||||
Can't
|
||||
find dependent libraries
|
||||
<br>
|
||||
</span></div>
|
||||
<div style="margin-left: 40px;">then there is no SWI-Prolog
|
||||
library <span style="font-family: courier new,courier,monospace;"><font
|
||||
size="-1">libpl.dll</font></span>
|
||||
in any folder on your PATH: you should have a PATH entry such as <span
|
||||
style="font-family: courier new,courier,monospace;">C:\Program
|
||||
Files\pl\bin</span><br>
|
||||
</div>
|
||||
<br>
|
||||
<hr style="width: 100%; height: 2px;">
|
||||
<address><a href="mailto:paul.singleton@bcs.org.uk">Paul Singleton</a></address>
|
||||
<address>
|
||||
February 2004</address>
|
||||
<br>
|
||||
|
||||
</body>
|
||||
</html>
|
|
@ -1,289 +0,0 @@
|
|||
<!DOCTYPE html PUBLIC "-//w3c//dtd html 4.0 transitional//en">
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type"
|
||||
content="text/html; charset=iso-8859-1">
|
||||
<meta name="GENERATOR"
|
||||
content="Mozilla/4.74 [en] (WinNT; U) [Netscape]">
|
||||
<meta name="Author" content="Fred Dushin">
|
||||
<meta name="Keywords" content="JPL,java,prolog">
|
||||
<title>Getting Started</title>
|
||||
</head>
|
||||
<body text="#000000" bgcolor="#ffffff" link="#00009c" vlink="#ce31ce"
|
||||
alink="#ff0000">
|
||||
<center>
|
||||
<h1 style="text-align: left;"><span style="font-style: italic;">JPL 2.x</span>
|
||||
Getting Started</h1>
|
||||
<hr style="width: 100%; height: 2px;">
|
||||
<div style="text-align: left;">This section provides a tutorial
|
||||
introduction to <span style="font-weight: bold; font-style: italic;">JPL</span>
|
||||
through its <a href="high-level_interface.html"><b><span
|
||||
style="font-style: italic;">JPL 2.x</span> Java API overview</b></a>,
|
||||
the
|
||||
interface most programmers are likely to use.
|
||||
The source code described here can be found in the <span
|
||||
style="font-family: courier new,courier,monospace;">examples</span>
|
||||
directory of
|
||||
the
|
||||
JPL distribution. Feel free to consult the source files and run
|
||||
the
|
||||
demonstration program as you read this section.
|
||||
</div>
|
||||
</center>
|
||||
<h3>Verifying the installation</h3>
|
||||
To confirm that <b><i>JPL</i></b> and SWI-Prolog are basically able to
|
||||
work together, open a console window and go into this directory:
|
||||
<blockquote>
|
||||
<pre>jpl/examples/</pre>
|
||||
</blockquote>
|
||||
read the README.txt file, and run the various examples which it
|
||||
describes.<br>
|
||||
<br>
|
||||
Each Java example will run as an application (i.e. each has a <tt>main()</tt>
|
||||
method), exercises SWI-Prolog, and writes something to <b>System.out</b>
|
||||
or <b>System.err</b>.
|
||||
<p>If you see some plausible output, with no serious error messages,
|
||||
then
|
||||
all may be well.
|
||||
</p>
|
||||
<h3>Creating a Prolog database in a text file</h3>
|
||||
To experiment with <b><i>JPL</i></b>, we'll first create a Prolog
|
||||
database
|
||||
in a text file. We will eventually load this database into the
|
||||
Prolog
|
||||
engine through the <a
|
||||
href="file:///D:/jpl/docs/java_api/high-level_interface.html"><b><span
|
||||
style="font-style: italic;">JPL 2.x</span> Java API overview</b></a>.
|
||||
<p>Type the following in a text editor and save the result in a file
|
||||
called
|
||||
<i>test.pl</i>
|
||||
</p>
|
||||
<blockquote><tt><font size="+1">child_of(joe, ralf).</font></tt> <br>
|
||||
<tt><font size="+1">child_of(mary, joe).</font></tt> <br>
|
||||
<tt><font size="+1">child_of(steve, joe).</font></tt>
|
||||
<p><tt><font size="+1">descendent_of(X, Y) :-</font></tt> <br>
|
||||
<tt><font size="+1"> child_of(X, Y).</font></tt> <br>
|
||||
<tt><font size="+1">descendent_of(X, Y) :-</font></tt> <br>
|
||||
<tt><font size="+1"> child_of(Z, Y),</font></tt> <br>
|
||||
<tt><font size="+1"> descendent_of(X, Z).</font></tt></p>
|
||||
</blockquote>
|
||||
You may wish to load this database into an interactive Prolog session
|
||||
to
|
||||
experiment with the predicates in this database before experimenting
|
||||
with
|
||||
<b><i>JPL</i></b>.
|
||||
<h3>Initializing The Prolog engine</h3>
|
||||
Although the <b>jpl.JPL</b> class provides a number of methods for
|
||||
initializing
|
||||
the Prolog engine from within Java, their use is not usually necessary:
|
||||
Prolog will be automatically initialised with default parameters
|
||||
at the first attempt to use it.
|
||||
<h3>Consulting the Prolog database from its text file</h3>
|
||||
In an ordinary interactive Prolog session, we'd load the above Prolog
|
||||
database
|
||||
using the Prolog <tt><font size="+1">consult/1</font></tt> predicate,
|
||||
a built-in
|
||||
predicate in standard Prolog. Note, however, that as a Prolog
|
||||
predicate,
|
||||
"calling" <tt><font size="+1">consult/1</font></tt> is just an example
|
||||
of making
|
||||
a Prolog query, and this is how we perform it with <b><i>JPL</i></b>.
|
||||
<p>First we construct an instance of <b>jpl.Query</b>, whose name is <b><tt><font
|
||||
size="+1">consult</font></tt></b>
|
||||
and whose arguments (just one) comprise the atom <b><tt><font size="+1">'test.pl'</font></tt></b>:
|
||||
</p>
|
||||
<blockquote><tt><font size="+1">Query q1 =</font></tt> <br>
|
||||
<tt><font size="+1"> new Query(</font></tt> <br>
|
||||
<tt><font size="+1">
|
||||
"consult",</font></tt> <br>
|
||||
<tt><font size="+1"> new
|
||||
Term[]
|
||||
{new Atom("test.pl")}</font></tt> <br>
|
||||
<tt><font size="+1"> );</font></tt></blockquote>
|
||||
Then we call the <b>query()</b> method of this <b>Query</b> object,
|
||||
which
|
||||
returns a Boolean value indicating its success:
|
||||
<blockquote><tt><font size="+1">System.out.println( "consult " +
|
||||
(q1.query()
|
||||
? "succeeded" : "failed"));</font></tt></blockquote>
|
||||
At this point, this process may seem a bit long-winded; however, you
|
||||
should
|
||||
soon see that the classes are sufficiently general that they provide a
|
||||
robust and powerful interface into the Prolog engine. There is
|
||||
also
|
||||
considerable scope for writing "convenience" classes and methods, but
|
||||
in
|
||||
this introduction we deliberately employ the general, primitive
|
||||
facilities
|
||||
of the <a
|
||||
href="file:///D:/jpl/docs/java_api/high-level_interface.html"><b><span
|
||||
style="font-style: italic;">JPL 2.x</span> Java API overview</b></a>.
|
||||
<h3>Querying the Database</h3>
|
||||
Using the same technique, we can query the Prolog database about
|
||||
inferences
|
||||
it can make. To ask whether the Prolog query <tt><font size="+1">child_of(joe,ralf)</font></tt>is
|
||||
true, given the above Prolog database, for example, we write:
|
||||
<blockquote><tt><font size="+1">Query q2 =</font></tt> <br>
|
||||
<tt><font size="+1"> new Query(</font></tt> <br>
|
||||
<tt><font size="+1">
|
||||
"child_of",</font></tt> <br>
|
||||
<tt><font size="+1"> new
|
||||
Term[]
|
||||
{new Atom("joe"),new Atom("ralf")}</font></tt> <br>
|
||||
<tt><font size="+1"> );</font></tt>
|
||||
<p><tt><font size="+1">System.out.println(</font></tt> <br>
|
||||
<tt><font size="+1"> "child_of(joe,ralf) is " +</font></tt>
|
||||
<br>
|
||||
<tt><font size="+1"> ( q2.query() ? "provable" :
|
||||
"not
|
||||
provable" )</font></tt> <br>
|
||||
<tt><font size="+1">);</font></tt></p>
|
||||
</blockquote>
|
||||
To take an example that requires a bit more work on the part of the
|
||||
Prolog
|
||||
engine, on the other hand, we can ask whether <tt><font size="+1">descendent_of(steve,ralf)</font></tt>
|
||||
is true:
|
||||
<blockquote><tt><font size="+1">Query q3 =</font></tt> <br>
|
||||
<tt><font size="+1"> new Query(</font></tt> <br>
|
||||
<tt><font size="+1">
|
||||
"descendent_of",</font></tt> <br>
|
||||
<tt><font size="+1"> new
|
||||
Term[]
|
||||
{new Atom("steve"),new Atom("ralf")}</font></tt> <br>
|
||||
<tt><font size="+1"> );</font></tt>
|
||||
<p><tt><font size="+1">System.out.println(</font></tt> <br>
|
||||
<tt><font size="+1"> "descendent_of(joe,ralf) is "
|
||||
+</font></tt> <br>
|
||||
<tt><font size="+1"> ( q3.query() ? "provable" :
|
||||
"not
|
||||
provable" )</font></tt> <br>
|
||||
<tt><font size="+1">);</font></tt></p>
|
||||
</blockquote>
|
||||
<h3>
|
||||
Querying with Variables</h3>
|
||||
A ground query is relatively straightforward; it is essentially
|
||||
either provable or not, and there is typically no point in
|
||||
backtracking.
|
||||
Once we use variables, however, things get
|
||||
a bit more complicated.
|
||||
<p>Using the <b>jpl.Variable</b> class, we can construct a non ground
|
||||
query;
|
||||
and using other methods of <b>Query</b> we can obtain a <i>solution</i>
|
||||
in the form of a <b>java.util.Hashtable</b>. If the
|
||||
<b>Query</b> has one or more solutions, then its
|
||||
<b>Query.</b><b>oneSolution()</b>
|
||||
method returns a <b>Hashtable</b> representing
|
||||
the first solution, otherwise
|
||||
it returns <b>null</b>:
|
||||
</p>
|
||||
<blockquote><tt><font size="+1">Variable <b>X</b> = new Variable();</font></tt>
|
||||
<p><tt><font size="+1">Query <b>q4</b> =</font></tt> <br>
|
||||
<tt><font size="+1"> new Query(</font></tt> <br>
|
||||
<tt><font size="+1">
|
||||
"descendent_of",</font></tt> <br>
|
||||
<tt><font size="+1"> new
|
||||
Term[]
|
||||
{<b>X</b>,new Atom("ralf")}</font></tt> <br>
|
||||
<tt><font size="+1"> );</font></tt> </p>
|
||||
<p><tt><font size="+1">java.util.Hashtable solution;</font></tt> </p>
|
||||
<p><tt><font size="+1">solution = <b>q4</b>.oneSolution();</font></tt>
|
||||
</p>
|
||||
<p><tt><font size="+1">System.out.println( "first solution of
|
||||
descendent_of(X,
|
||||
ralf)");</font></tt> <br>
|
||||
<tt><font size="+1">System.out.println( "X = " + solution.get(<b>X</b>));</font></tt></p>
|
||||
</blockquote>
|
||||
The <b>HashTable</b> contains bindings in the form of <b>Term</b>s,
|
||||
each
|
||||
of which is indexed by its corresponding <b>Variable</b> in the <b>Query</b>.
|
||||
<h3>
|
||||
Finding all solutions</h3>
|
||||
The previous query finds only the first solution. Often, however,
|
||||
one wants all solutions, or at least more than just the first.
|
||||
The
|
||||
<b>Query</b>
|
||||
class also provides the <b>allSolutions()</b> method, which returns an
|
||||
array of zero or more <b>Hashtable</b>s, each of which represents a
|
||||
given
|
||||
solution.
|
||||
<p>In this example we reuse the query <b><tt><font size="+1">q4</font></tt></b>,
|
||||
which was reset to its initial state by the call of <b><tt><font
|
||||
size="+1">oneSolution()</font></tt></b>,
|
||||
and instead call <b><tt><font size="+1">allSolutions()</font></tt></b>,
|
||||
which
|
||||
returns an array of solutions:
|
||||
</p>
|
||||
<blockquote><tt><font size="+1">java.util.Hashtable[] solutions = <b>q4</b>.allSolutions();</font></tt>
|
||||
<p><tt><font size="+1">for ( int i=0 ; i<solutions.length ; i++ ) {</font></tt>
|
||||
<br>
|
||||
<tt><font size="+1"> System.out.println( "X = " +
|
||||
solutions[i].get(<b>X</b>));</font></tt> <br>
|
||||
<tt><font size="+1">}</font></tt></p>
|
||||
</blockquote>
|
||||
Equivalently, one can obtain each solution by exploiting the <b>Enumeration</b>
|
||||
interface, which the <b>Query</b> class implements. In this
|
||||
example,
|
||||
we iteratively call hasMoreSolutions() and nextSolution() to
|
||||
exhaustion:
|
||||
<blockquote>
|
||||
<pre><tt><font size="+1">System.out.println( "each solution of descendent_of(X, ralf)");</font></tt></pre>
|
||||
<pre><tt><font size="+1">while ( q4.hasMoreSolutions() ){<br> solution = q4.nextSolution();<br> System.out.println( "X = " + solution.get(X));<br>}</font></tt></pre>
|
||||
</blockquote>
|
||||
In this final example, we reuse the previous variable <b><tt><font
|
||||
size="+1">X</font></tt></b>
|
||||
with a new variable <b><tt><font size="+1">Y</font></tt></b> in a new
|
||||
query
|
||||
<b><tt><font size="+1">q5</font></tt></b>:
|
||||
<blockquote><tt><font size="+1">Variable <b>Y</b> = new Variable();</font></tt>
|
||||
<p><tt><font size="+1">Query <b>q5</b> =</font></tt> <br>
|
||||
<tt><font size="+1"> new Query(</font></tt> <br>
|
||||
<tt><font size="+1">
|
||||
"descendent_of",</font></tt> <br>
|
||||
<tt><font size="+1"> new
|
||||
Term[]
|
||||
{<b>X</b>,<b>Y</b>}</font></tt> <br>
|
||||
<tt><font size="+1"> );</font></tt> </p>
|
||||
<p><tt><font size="+1">while ( <b>q5</b>.hasMoreSolutions() ){</font></tt>
|
||||
<br>
|
||||
<tt><font size="+1"> solution = <b>q5</b>.nextSolution();</font></tt>
|
||||
<br>
|
||||
<tt><font size="+1"> System.out.println( "X = " +
|
||||
solution.get(<b>X</b>)
|
||||
+ ", Y = " + solution.get(<b>Y</b>));</font></tt> <br>
|
||||
<tt><font size="+1">}</font></tt></p>
|
||||
</blockquote>
|
||||
The <b>hasMoreSolutions</b> method of the <b>Query</b> class returns
|
||||
a
|
||||
<b>boolean</b>,
|
||||
indicating whether there are any solutions "left" in the query.
|
||||
If
|
||||
the answer to this is 'yes', then the solution can be obtained in the
|
||||
form
|
||||
of a <b>Hashtable</b> by the <b>nextSolution</b> method.
|
||||
<blockquote><i><font size="-1"><b>Note.</b> By calling <b>hasMoreSolutions</b>
|
||||
you are actually making the query to the Prolog engine; the "answer" to
|
||||
the query is cached in the <b>Query</b> class instance and returned
|
||||
from <b>nextSolution</b>.</font></i></blockquote>
|
||||
<h3>
|
||||
Where to Go From Here</h3>
|
||||
This section provides a brief tutorial on getting started with the
|
||||
High-Level
|
||||
Interface. You should read the <a
|
||||
href="file:///D:/jpl/docs/java_api/high-level_interface.html"><b><span
|
||||
style="font-style: italic;">JPL 2.x</span> Java API overview</b></a>
|
||||
section for more information about using these
|
||||
interfaces.
|
||||
Feel free to consult the <a href="javadoc/index.html"><span
|
||||
style="font-style: italic;">JPL 3.x</span> Java API reference</a>
|
||||
section
|
||||
for detailed information about particular classes.
|
||||
<br>
|
||||
<div align="right">
|
||||
<hr noshade="noshade" width="100%">
|
||||
<div style="text-align: left;">
|
||||
<address>December 2003 (revised)</address>
|
||||
<br>
|
||||
<span style="text-decoration: underline;"></span></div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
|
@ -1,45 +0,0 @@
|
|||
<!DOCTYPE html PUBLIC "-//w3c//dtd html 4.0 transitional//en">
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type"
|
||||
content="text/html; charset=iso-8859-1">
|
||||
<meta name="GENERATOR"
|
||||
content="Mozilla/4.74 [en] (WinNT; U) [Netscape]">
|
||||
<title>JPL 3.x Java-calls-Prolog gotchas</title>
|
||||
</head>
|
||||
<body>
|
||||
<h1><span style="font-style: italic;">
|
||||
JPL 3.x</span> Java API gotchas
|
||||
</h1>
|
||||
<hr width="100%">
|
||||
<h2>arg indexing</h2>
|
||||
<blockquote>the <span style="font-weight: bold;">Term[]</span> args of
|
||||
a <span style="font-weight: bold;">Compound</span> are indexed (like
|
||||
all Java arrays) from zero, whereas in Prolog the args of a structure
|
||||
are conventionally numbered from one.<br>
|
||||
</blockquote>
|
||||
<h2>representing <span style="font-family: monospace;">@(null)</span><br>
|
||||
</h2>
|
||||
<blockquote>there is no <span style="font-weight: bold;">jpl.JNull</span>
|
||||
class: instead, use <span style="font-family: monospace;">new
|
||||
JRef(null)</span> to represent <span style="font-family: monospace;">@(null)</span>
|
||||
(which itself represents Java's <span style="font-style: italic;">null</span>).
|
||||
If you don't know what this all means, don't worry: it only affects
|
||||
those writing hybrid Java+Prolog programs which call each other
|
||||
nestedly.<br>
|
||||
</blockquote>
|
||||
<h2>all solutions of a Query with no solutions</h2>
|
||||
<div style="margin-left: 40px;"><span style="font-weight: bold;">Query.allSolutions()</span>
|
||||
now returns an empty array of <span style="font-weight: bold;">Map</span>
|
||||
if the <span style="font-weight: bold;">Query</span> has no solutions
|
||||
(in 1.x versions it inconsistently returned null).<br>
|
||||
</div>
|
||||
<br>
|
||||
<hr style="width: 100%; height: 2px;">
|
||||
<address><a href="mailto:p.singleton@keele.ac.uk">Paul Singleton</a></address>
|
||||
<address>
|
||||
drafted Wednesday 4th February 2004<br>
|
||||
<br>
|
||||
</address>
|
||||
</body>
|
||||
</html>
|
|
@ -1,537 +0,0 @@
|
|||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="CONTENT-TYPE"
|
||||
content="text/html; charset=windows-1252">
|
||||
<title>High-Level Interface</title>
|
||||
<meta name="GENERATOR" content="StarOffice 7 (Win32)">
|
||||
<meta name="AUTHOR" content="Fred Dushin">
|
||||
<meta name="CREATED" content="20040216;23165440">
|
||||
<meta name="CHANGEDBY" content="Paul Singleton">
|
||||
<meta name="CHANGED" content="20040216;23225011">
|
||||
<meta name="KEYWORDS" content="JPL,java,prolog">
|
||||
<style>
|
||||
<!--
|
||||
P { color: #000000 }
|
||||
H3 { color: #000000 }
|
||||
BLOCKQUOTE { color: #000000 }
|
||||
PRE { color: #000000 }
|
||||
H4 { color: #000000 }
|
||||
A:link { color: #00009c }
|
||||
A:visited { color: #ce31ce }
|
||||
-->
|
||||
</style>
|
||||
</head>
|
||||
<body lang="en-US" text="#000000" link="#00009c" vlink="#ce31ce"
|
||||
bgcolor="#ffffff" dir="ltr">
|
||||
<h1><b><span style="font-style: italic;">JPL 3.x</span>
|
||||
Java API overview</b><font size="7"><b><br>
|
||||
</b></font></h1>
|
||||
<hr style="width: 100%; height: 2px;">
|
||||
<h3>Table of Contents</h3>
|
||||
<ul>
|
||||
<li>
|
||||
<p style="margin-bottom: 0cm;"><a href="#Introduction">Introduction</a>
|
||||
</p>
|
||||
</li>
|
||||
<li>
|
||||
<p style="margin-bottom: 0cm;"><a href="#The%20Class%20Hierarchy">The
|
||||
Class Hierarchy</a> </p>
|
||||
</li>
|
||||
<li>
|
||||
<p style="margin-bottom: 0cm;"><a
|
||||
href="#Initializing%20and%20Terminating%20Prolog">Initializing Prolog</a>
|
||||
</p>
|
||||
</li>
|
||||
<li>
|
||||
<p style="margin-bottom: 0cm;"><a href="#Creating%20Terms">Creating
|
||||
Terms</a> </p>
|
||||
<ul>
|
||||
<li>
|
||||
<p style="margin-bottom: 0cm;"><a href="#Atoms">Atoms</a> </p>
|
||||
</li>
|
||||
<li>
|
||||
<p style="margin-bottom: 0cm;"><a href="#Variables">Variables</a>
|
||||
</p>
|
||||
</li>
|
||||
<li>
|
||||
<p style="margin-bottom: 0cm;"><a href="#Integers">Integers</a>
|
||||
</p>
|
||||
</li>
|
||||
<li>
|
||||
<p style="margin-bottom: 0cm;"><a href="#Floats">Floats</a> </p>
|
||||
</li>
|
||||
<li>
|
||||
<p style="margin-bottom: 0cm;"><a href="#Compound%20Terms">Compound
|
||||
Terms</a> </p>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li>
|
||||
<p style="margin-bottom: 0cm;"><a href="#Creating%20Queries">Creating
|
||||
Queries</a> </p>
|
||||
</li>
|
||||
<li>
|
||||
<p style="margin-bottom: 0cm;"><a href="#The%20Util%20Class">The
|
||||
Util Class</a> </p>
|
||||
</li>
|
||||
<li>
|
||||
<p style="margin-bottom: 0cm;"><a href="#Querying%20Prolog">Querying
|
||||
Prolog</a> </p>
|
||||
<ul>
|
||||
<li>
|
||||
<p style="margin-bottom: 0cm;"><a
|
||||
href="#Obtaining%20one%20Solution">Obtaining One Solution</a> </p>
|
||||
</li>
|
||||
<li>
|
||||
<p style="margin-bottom: 0cm;"><a
|
||||
href="#Obtaining%20all%20Solutions">Obtaining all Solutions</a> </p>
|
||||
</li>
|
||||
<li>
|
||||
<p style="margin-bottom: 0cm;"><a href="#Ground%20Queries">Discovering
|
||||
whether a Query has any Solutions</a></p>
|
||||
</li>
|
||||
<li>
|
||||
<p style="margin-bottom: 0cm;"><a href="#Terminating%20Queries">Terminating
|
||||
Queries</a> </p>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li>
|
||||
<p style="margin-bottom: 0cm;"><a href="#Multi-Threaded%20Queries">Multi-Threaded
|
||||
Queries</a> </p>
|
||||
</li>
|
||||
<li>
|
||||
<p style="margin-bottom: 0cm;"><a href="#Exceptions">Exceptions</a>
|
||||
</p>
|
||||
</li>
|
||||
<li>
|
||||
<p style="margin-bottom: 0cm;"><a href="#Debugging">Debugging</a> </p>
|
||||
</li>
|
||||
<li>
|
||||
<p style="margin-bottom: 0cm;"><a href="#Version">Version
|
||||
information</a></p>
|
||||
</li>
|
||||
<li>
|
||||
<p><a href="#What%27s%20Missing">What's Missing</a> </p>
|
||||
</li>
|
||||
</ul>
|
||||
<hr size="4" noshade="noshade">
|
||||
<h3><a name="Introduction"></a>Introduction</h3>
|
||||
<p>The <b><i>JPL 3.0.1 Java-calls-Prolog API</i></b> provides a set
|
||||
of classes that hide almost all of the messy detail in the <a
|
||||
href="low-level_interface.html">Low-Level
|
||||
Interface</a>. It is less flexible than the Low-Level
|
||||
Interface, but it also has less of a learning curve, and in many ways
|
||||
is more natural and Prolog-like than the Low-Level Interface. </p>
|
||||
<p>The Java package <b>jpl</b> contains all of the classes in this
|
||||
interface. None of the classes correspond with any of the data
|
||||
types in the Prolog Foreign Language Interface (FLI). <br>
|
||||
</p>
|
||||
<h3><a name="The Class Hierarchy"></a>The Class Hierarchy</h3>
|
||||
<p>The <b><i>API</i></b> consists of the following class hierarchy: </p>
|
||||
<pre style="margin-left: 3cm; margin-right: 3cm;">Term<br> |<br> +--- Variable<br> |<br> +--- Compound<br> | |<br> | +--- Atom<br> |<br> +--- Integer<br> |<br> +--- Float<br> <br>Query<br> <br>JPLException<br> |<br> +-- PrologException</pre>
|
||||
<p><b>Term</b> is an abstract class: only its subclasses can be
|
||||
instantiated. </p>
|
||||
<p>Each instance of <b>Query</b> contains a <b>Term</b> (denoting the
|
||||
goal which is to be proven), and much more besides. </p>
|
||||
<p>Each instance of <b>Compound</b> has a (java.lang.String) name and
|
||||
an array of (<b>Term</b>) arguments (it must have at least one). </p>
|
||||
<p><b>Atom</b> is a specialisation of <b>Compound</b> with zero
|
||||
arguments. <br>
|
||||
</p>
|
||||
<h3><a name="Initializing and Terminating Prolog"></a>Initializing
|
||||
Prolog</h3>
|
||||
<p>The <b>jpl.JPL</b> class initializes the Prolog VM (e.g.
|
||||
<tt>libpl.dll</tt> in Win32), if necessary, when the first <b>Query</b>
|
||||
is activated, using default parameter values. Before
|
||||
initialization takes place, these default values can be read, and
|
||||
altered. </p>
|
||||
<pre style="margin-left: 1cm; margin-right: 1cm;">public String[] getDefaultInitArgs();<br>public void setDefaultInitArgs(String[] args);</pre>
|
||||
<p>After initialization, the parameter values which were actually used
|
||||
can be read. </p>
|
||||
<pre style="margin-left: 1cm; margin-right: 1cm; margin-bottom: 0.5cm;">public String[] getActualInitArgs();</pre>
|
||||
<p>(This method returns <tt>null</tt> if initialization has not
|
||||
occurred, and thus it can be used as a test.) <br>
|
||||
This allows Java
|
||||
library classes to employ <b><i>JPL</i></b> without placing any
|
||||
burden of initialization upon the applications which use them.
|
||||
It can also ensure that the Prolog VM is initialized only if and when
|
||||
it is
|
||||
needed. </p>
|
||||
<p>Explicit initialization is supported as in <b><i>JPL 1.0.1</i></b>:
|
||||
</p>
|
||||
<pre style="margin-left: 1cm; margin-right: 1cm;">public void init();<br>public void init( String args[] );</pre>
|
||||
<p>Java code which requires a Prolog VM to be initialized in a
|
||||
particular way can check whether initialization has already occurred:
|
||||
if not, it can specify parameters and force it to be attempted; if
|
||||
so, it can retrieve and check the initialisation parameters actually
|
||||
used, to determine whether the initialization meets its requirements.
|
||||
<br>
|
||||
<br>
|
||||
This version of <span style="font-weight: bold; font-style: italic;">JPL</span>
|
||||
does not support reinitialization of a Prolog VM. </p>
|
||||
<p>For details about the legal parameter values, see your local
|
||||
Prolog documentation. Most users will rely on automatic
|
||||
initialization. <br>
|
||||
</p>
|
||||
<h3><a name="Creating Terms"></a>Creating Terms</h3>
|
||||
<p>The <b>Term</b>-based classes in the <span
|
||||
style="font-weight: bold;">jpl</span> package are best
|
||||
thought of as a structured concrete syntax for Prolog terms: they do
|
||||
not correspond to any particular terms within the Prolog engine;
|
||||
rather, they are a means for constructing queries which can called
|
||||
within Prolog, and they are also a means for representing (and
|
||||
exploring) the results
|
||||
of such calls. <br>
|
||||
<b>Term</b> instances are never changed by any
|
||||
activity within the Prolog engine: indeed; it doesn't know of their
|
||||
existence. <br>
|
||||
The <b>Term</b> class is
|
||||
abstract, so it cannot be directly instantiated; to create a Term,
|
||||
create an instance of one of its five subclasses. </p>
|
||||
<blockquote><font size="2"><b><i>Note.</i></b> <i>A <b>Term</b> in
|
||||
the <span style="font-weight: bold;">jpl</span> packagee is not to be
|
||||
confused with a <b>term_t</b> in
|
||||
the <span style="font-weight: bold;">jpl.fli</span> package. The
|
||||
latter has an important internal role in
|
||||
managing state in the Prolog stack; the former is just a data
|
||||
structure in the Java heap.</i></font></blockquote>
|
||||
<h4><a name="Atoms"></a>Atoms</h4>
|
||||
<p>An <b>Atom</b> is a <b>Compound</b> with zero arguments. To
|
||||
create an <b>Atom</b>, pass a (String) name to its constructor: </p>
|
||||
<pre style="margin-left: 1cm; margin-right: 1cm;">Atom aristotle = new Atom("aristotle");<br>Atom alexander = new Atom("alexander");</pre>
|
||||
<blockquote><i><font size="2"><b>Note.</b> Two <b>Atom</b>s by
|
||||
the same name
|
||||
are effectively identical. Feel free to reuse <b>Atom</b>
|
||||
instances when constructing compound <b>Term</b>s.</font></i> <br>
|
||||
<i><font size="2"><b>Note.</b>
|
||||
The name in an <b>Atom</b> need not be lower case: it can be any
|
||||
UTF-8 string (?).</font></i></blockquote>
|
||||
<p>The <b>Atom</b> class inherits <b>Compound</b>'s <b>name()</b>
|
||||
accessor to obtain the name of the <b>Atom</b> (it also inherits
|
||||
<b>Compound</b>'s <b>arity()</b> accessor, but this always returns
|
||||
zero for an <b>Atom)</b>. <span style="font-weight: bold;">Atom</span>'s
|
||||
<span style="font-weight: bold;">toString()</span> method yields a
|
||||
String form of the atom's name which is quoted, iff necessary,
|
||||
according to Prolog source text syntax, and can thus be used when
|
||||
constructing fragments of Prolog source text, e.g. new queries.<br>
|
||||
</p>
|
||||
<h4><a name="Variables"></a>Variables</h4>
|
||||
<p><b>Variable</b>s have identifying
|
||||
names, which must comply with conventional Prolog source text syntax. </p>
|
||||
<pre style="margin-left: 1cm; margin-right: 1cm; margin-bottom: 0.5cm;">Variable X = new Variable("X"); // a regular variable</pre>
|
||||
<pre style="margin-left: 1cm; margin-right: 1cm; margin-bottom: 0.5cm;">Variable X = new Variable("_"); // an "anonymous" variable</pre>
|
||||
<pre style="margin-left: 1cm; margin-right: 1cm; margin-bottom: 0.5cm;">Variable X = new Variable("_Y"); // a "dont-tell-me" variable, whose bindings we don't want to know</pre>
|
||||
<h4><a name="Integers"></a>Integers</h4>
|
||||
<p>An <b>Integer</b> is a specialized <b>Term</b> that holds a Java <b>long</b>
|
||||
value. This class corresponds to the Prolog <i>integer</i>
|
||||
type (SWI-Prolog integers are 32-bit for now, but we are looking ahead
|
||||
and beyond...). </p>
|
||||
<pre style="margin-left: 1cm; margin-right: 1cm; margin-bottom: 0.5cm;">jpl.Integer i = new jpl.Integer(5);</pre>
|
||||
<p>Be careful to avoid confusion with <tt>java.lang.integer</tt>, e.g.
|
||||
by always qualifying the class name as in the example above. </p>
|
||||
<p>The <b>jpl.Integer</b> class has an <b>intValue()</b> accessor to
|
||||
obtain the <b>int</b> value of an instance, and also <span
|
||||
style="font-weight: bold;">longValue()</span>, <span
|
||||
style="font-weight: bold;">floatValue()</span> and <span
|
||||
style="font-weight: bold;">doubleValue()</span> (just like
|
||||
java.lang.Integer has). </p>
|
||||
<h4><a name="Floats"></a>Floats</h4>
|
||||
<p>A <b>Float</b> is a specialized <b>Term</b> that holds a Java
|
||||
<b>double</b> value. This class corresponds to the Prolog float
|
||||
type (SWI-Prolog floats are 64-bit ISO/IEC), on which arithmetic
|
||||
operations can be performed. </p>
|
||||
<pre style="margin-left: 1cm; margin-right: 1cm; margin-bottom: 0.5cm;">jpl.Float f = new jpl.Float(3.14159265);</pre>
|
||||
<p>As with integers, avoid confusion between <b>jpl.Float</b> and
|
||||
<b>java.lang.Float</b>. </p>
|
||||
<p>The <b>jpl.Float</b> class has a <b>doubleValue()</b> accessor to
|
||||
obtain
|
||||
the <b>double</b> value of an instance, and also a <span
|
||||
style="font-weight: bold;">floatValue()</span> accessor. </p>
|
||||
<h4><a name="Compound Terms"></a>Compounds</h4>
|
||||
<p>A <b>Compound</b> is a <b>Term</b> that contains a name and a
|
||||
sequence (array) of <b>Term</b> arguments, as reflected in this
|
||||
class's constructor: </p>
|
||||
<pre style="margin-left: 1cm; margin-right: 1cm;">Compound teacher_of = new Compound(<br> "teacher_of",<br> new Term[] {<br> new Atom("aristotle"),<br> new Atom("alexander")<br> }<br> );</pre>
|
||||
<p>Note the use of Java's <i>anonymous array</i> syntax</p>
|
||||
<pre style="margin-left: 0.85cm; margin-bottom: 0.5cm;">new Term[] { ..., ... }</pre>
|
||||
<p>to specify the arguments (any quantity >= 1) of the <b>Compound</b>.<br>
|
||||
<br>
|
||||
In
|
||||
this example, the Java variable <tt>teacher_of</tt> refers to a
|
||||
<b>Compound</b> instance, which represents the Prolog term
|
||||
<i>teacher_of(aristotle,alexander).</i> </p>
|
||||
<blockquote><a name="Note.vars"></a><font size="2"><i><b>Note.</b> Care
|
||||
should be taken in creating <b>Compound</b> <b>Term</b>s, especially
|
||||
if <b>Variable</b> references are used. For example, the
|
||||
following construction:</i></font></blockquote>
|
||||
<pre style="margin-left: 2cm; margin-right: 2cm;"><font size="2"><i>Variable X = new Variable();</i></font>
|
||||
<font size="2"><i>Variable Y = new Variable();</i></font>
|
||||
<font size="2"><i>Compound father_of = new Compound( "teacher_of", new Term[]{X,Y});</i></font></pre>
|
||||
<blockquote><font size="2"><i>corresponds with the Prolog term </i><font
|
||||
face="monospace">teacher_of(X,Y)</font><i>,
|
||||
whereas</i></font> </blockquote>
|
||||
<pre style="margin-left: 2cm; margin-right: 2cm;"><font size="2"><i>Variable X = new Variable();</i></font>
|
||||
<font size="2"><i>Compound father_of = new Compound( "teacher_of", new Term[]{X,X});</i></font></pre>
|
||||
<blockquote><font size="2"><i>corresponds with the Prolog term </i><font
|
||||
face="monospace">teacher_of(X,X)</font><i>,
|
||||
two terms that can resolve very differently depending on the Prolog
|
||||
database. The general rule of thumb should be, reuse </i><b>Term</b>
|
||||
<i>references that are or contain <b>Variable</b>s only if you know
|
||||
that that is what you mean.</i></font></blockquote>
|
||||
<p>To obtain the (String) name of a <b>Compound</b>, use the <b>name()</b>
|
||||
accessor method. </p>
|
||||
<pre style="margin-left: 1cm; margin-right: 1cm; margin-bottom: 0.5cm;">public String name();</pre>
|
||||
<p>To obtain the arity of a <b>Compound</b>, use the <b>arity()</b>
|
||||
accessor method. </p>
|
||||
<pre style="margin-left: 1cm; margin-right: 1cm; margin-bottom: 0.5cm;">public int arity();</pre>
|
||||
<p>To obtain an array of a <b>Compound</b>'s arguments, use the <b>args()</b>
|
||||
accessor method. </p>
|
||||
<pre style="margin-left: 1cm; margin-right: 1cm; margin-bottom: 0.5cm;">public Term[] args();</pre>
|
||||
<p>To obtain the <i>ith</i> argument of a compound (numbered from 1),
|
||||
use the <b>arg() </b>accessor method (with an <b>int </b>parameter
|
||||
value between 1 and Arity inclusive). </p>
|
||||
<pre style="margin-left: 1cm; margin-right: 1cm; margin-bottom: 0.5cm;">public Term arg( int i);</pre>
|
||||
<p>To obtain the <i>ith</i> argument of a compound (numbered from 0),
|
||||
use the <b>arg0() </b>accessor method (with an <b>int </b>parameter
|
||||
value between 0 and Arity-1 inclusive). </p>
|
||||
<pre style="margin-left: 1cm; margin-right: 1cm; margin-bottom: 0.5cm;">public Term arg0( int i);</pre>
|
||||
<h3><a name="Creating Queries"></a>Queries</h3>
|
||||
<p>A <b>Query</b> contains a <b>Term</b>, representing a Prolog goal:
|
||||
</p>
|
||||
<pre style="margin-left: 1cm; margin-right: 1cm;">Term goal = new Compound( "teacher_of", new Term[]{new Atom("aristotle"),new Atom("alexander")});<br>Query q = new Query( goal );</pre>
|
||||
<p>The <b>Query</b> <b>q</b> in this example represents the Prolog
|
||||
query
|
||||
</p>
|
||||
<blockquote><i>?- teacher_of(aristotle,alexander).</i></blockquote>
|
||||
<h3><a name="The Util Class"></a>The Util Class</h3>
|
||||
<p>The <b>Util</b> class provides various static utility methods for
|
||||
managing <b><i>JPL</i></b> <b>Term</b>s. </p>
|
||||
<pre style="margin-left: 1cm; margin-right: 1cm; margin-bottom: 0.5cm;">Term termArrayToList( Term t[])<br>Term[] listToTermArray( Term t)<br>Term[] bindingsToTermArray( Hashtable bs)</pre>
|
||||
<h3><a name="Querying Prolog"></a>Querying Prolog</h3>
|
||||
<p>To ask the Prolog engine a query via the High-Level Interface, one
|
||||
first constructs a <b>Query</b> instance, as in the above example,
|
||||
and then uses the <b>java.util.Enumeration</b> interface, which the
|
||||
<b>Query</b> class implements, to obtain solutions (where a
|
||||
"solution" is what is known in logic programming jargon as
|
||||
a <i>substitution</i>, which is a collection of <i>bindings</i>, each
|
||||
of which relates one of the <b>Variables</b> within the <b>Query</b>'s
|
||||
goal to a <b>Term</b> representation of the Prolog term to which the
|
||||
corresponding Prolog variable was bound by the proof). </p>
|
||||
<pre style="margin-left: 1cm; margin-right: 1cm;">public interface Enumeration {<br> public boolean hasMoreElements();<br> public Object nextElement();<br>}</pre>
|
||||
<p>The <b>hasMoreElements()</b> method can be used to determine
|
||||
whether
|
||||
a <b>Query</b> has any (or any further) solutions. In the above
|
||||
example, the method call </p>
|
||||
<pre style="margin-left: 1cm; margin-right: 1cm; margin-bottom: 0.5cm;">q.hasMoreElements()</pre>
|
||||
<p>returns <b>true</b> if the Prolog query <i>teaches(aristotle,alexander)</i>
|
||||
is provable, and <b>false</b> otherwise. In this example, the
|
||||
Prolog query is a ground term, so the "solution" to the
|
||||
<b>Query</b> is merely a truth value, and is given by the
|
||||
<b>hasMoreElements()</b> method. </p>
|
||||
<p>Where a <b>Query</b>'s goal contains <b>Variable</b>s, on the
|
||||
other hand, its execution yields a sequence of bindings of these
|
||||
<b>Variable</b>s to <b>Term</b>s. The High-Level interface uses
|
||||
a <b>java.util.Hashtable</b> to represent these bindings; the <b>Object</b>s
|
||||
in the table are <b>Term</b>s, keyed (uniquely) by <b>Variable</b>
|
||||
instances. </p>
|
||||
<p>For example, to print all of Aristotle's pupils, i.e., all the
|
||||
bindings of <b>X</b> which satisfy <i>teaches(aristotle,X)</i>, one
|
||||
could write </p>
|
||||
<pre style="margin-left: 1cm; margin-right: 1cm;">Variable X = new Variable();<br>Query q = new Query( "teaches", new Term[]{new Atom("aristotle"),X});<br>while ( q.hasMoreElements() ) {<br> Hashtable binding = (Hashtable) q.nextElement();<br> Term t = (Term) binding.get( X);<br> System.out.println( t);<br>}</pre>
|
||||
<blockquote><i><font size="2"><b>Note.</b> If a <b>Query</b>'s
|
||||
goal contains
|
||||
no variables (i.e. it is "ground"), the <b>Query.
|
||||
nextElement() </b>method will still return a <b>Hashtable</b> for
|
||||
each solution, although each table will be empty.</font></i> <br>
|
||||
<i><font size="2"><b>Note.</b>
|
||||
If a <b>Query</b>'s goal contains more than one occurrence of some <b>Variable</b>,
|
||||
then each solution <b>Hashtable</b> will have
|
||||
only one binding for that <b>Variable</b>.</font></i></blockquote>
|
||||
<p>For convenience, the <b>Query</b> class provides a
|
||||
<b>hasMoreSolutions()</b> and <b>nextSolution() </b>method with the
|
||||
following signatures: </p>
|
||||
<pre style="margin-left: 1cm; margin-right: 1cm;">public boolean hasMoreSolutions();<br>public Hashtable nextSolution();</pre>
|
||||
<p>Using the <b>nextSolution()</b> method avoids having to cast the
|
||||
result of the <b>nextElement() </b>method to <b>Hashtable</b>. </p>
|
||||
<h4><a name="Obtaining one Solution"></a>Obtaining one Solution</h4>
|
||||
<p>Often, you'll just want just the first solution to a query.
|
||||
The <b>Query</b> class provides a method for this: </p>
|
||||
<pre style="margin-left: 1cm; margin-right: 1cm; margin-bottom: 0.5cm;">public Hashtable oneSolution();</pre>
|
||||
<p>If the <b>Query</b> has no solutions, this method returns <b>null</b>;
|
||||
otherwise, a non-null return indicates success. If the <b>Query</b>
|
||||
is a ground query (i.e. contains no variables), the returned
|
||||
<b>Hashtable</b> will be empty (i.e. will contain no bindings). </p>
|
||||
<h4><a name="Obtaining all Solutions"></a>Obtaining all Solutions</h4>
|
||||
<p>You may want all solutions to a query. The <b>Query</b>
|
||||
class provides a method for this: </p>
|
||||
<pre style="margin-left: 1cm; margin-right: 1cm; margin-bottom: 0.5cm;">public Hashtable[] allSolutions();</pre>
|
||||
<p>The returned array will contain all the <b>Query</b>'s solutions,
|
||||
in
|
||||
the order they were obtained (as with Prolog's findall/3, duplicates
|
||||
are not removed). If the <b>Query</b> has no solutions, this
|
||||
method returns an empty array (N.B. not <b>null</b> as in <b>JPL
|
||||
1.0.1</b>). </p>
|
||||
<h4><a name="Ground Queries"></a>Discovering whether a query has any
|
||||
solutions</h4>
|
||||
<p>Sometimes an application is interested only in whether or not a
|
||||
query is provable, but not in any details of its possible
|
||||
solutions.
|
||||
The <b>Query</b> class provides the <b>hasSolution</b> method for
|
||||
this common special case: </p>
|
||||
<pre style="margin-left: 1cm; margin-right: 1cm; margin-bottom: 0.5cm;">public boolean hasSolution();</pre>
|
||||
<p>This method is equivalent to (but sometimes more efficient than)
|
||||
calling <b>oneSolution</b> and asking whether the return value is
|
||||
non-<b>null</b> (i.e. whether the query succeeded). </p>
|
||||
<h4><a name="Terminating Queries"></a>Terminating Queries</h4>
|
||||
<p>Queries terminate automatically when the <b>hasMoreSolutions()
|
||||
</b>method returns <b>false</b>, and once a <b>Query</b> is
|
||||
terminated, another can be started. Unfortunately, the Prolog
|
||||
engine is currently such that it can handle only one query at a
|
||||
time. As a result, <i>it is not possible, in the High-Level
|
||||
Interface, to ask two different <b>Query</b> objects whether they
|
||||
have any solutions without first exhausting all of the solutions of
|
||||
one.</i> Therefore, programmers must take care to ensure that
|
||||
all solutions are exhausted before starting new queries. This
|
||||
has particular importance in multi-threaded contexts, but it can also
|
||||
present difficulties even in single-threaded programs. See the
|
||||
<a href="#Multi-Threaded%20Queries">Multi-Threaded Queries</a> section
|
||||
for a discussion of how to manage Queries in multi-threaded contexts.
|
||||
</p>
|
||||
<p>To terminate a <b>Query</b> before all of its solutions have been
|
||||
exhausted, use the <b>rewind()</b> method: </p>
|
||||
<pre style="margin-left: 1cm; margin-right: 1cm; margin-bottom: 0.5cm;">public void rewind();</pre>
|
||||
<p>This method stops a <b>Query</b>, setting it back into a state
|
||||
where
|
||||
it can be restarted. It also permits other queries to be
|
||||
started. Here is an example in which the first three solutions
|
||||
to the <b>Query</b> are obtained: </p>
|
||||
<pre style="margin-left: 1cm; margin-right: 1cm;">Query query = // obtain Query somehow<br>for ( int i = 0; i < 3 && query.hasMoreSolutions(); ++i ){<br> Hashtable solution = query.nextSolution();<br> // process solution...<br>}<br>query.rewind();</pre>
|
||||
<p>You may call <b>rewind()</b> on an inactive <b>Query</b> without
|
||||
ill-effect, and you should <i>always</i> call rewind if you have not
|
||||
exhausted all solutions to a <b>Query</b>. </p>
|
||||
<p>If you are using the <b>query()</b>, <b>oneSolution()</b>, or
|
||||
<b>allSolutions() </b>methods, you need not worry about rewinding the
|
||||
<b>Query</b>; it is done automatically for you. <br>
|
||||
</p>
|
||||
<h3><a name="Multi-Threaded Queries"></a>Multi-Threaded Queries</h3>
|
||||
<p>The Prolog engine can only have one query open at a time.
|
||||
This presents difficulties for multi-threaded programs in which the
|
||||
programmer has no control over when Queries are executed. <b><i>JPL</i></b>
|
||||
makes as much of the High-Level Interface thread-safe as it can.
|
||||
Unfortunately, the programmer must take responsibility in a limited
|
||||
set of circumstances to ensure that all calls to the High-Level
|
||||
Interface are thread safe. </p>
|
||||
<p>It is worth noting that if the programmer confines use of Query
|
||||
methods to <b>hasSolution()</b>, <b>oneSolution()</b>, and
|
||||
<b>allSolutions()</b>, that subset of the <b>Query</b> interface <i>is</i>
|
||||
thread-safe. For many programmers, these methods suffice.
|
||||
However, if the <b>hasMoreSolutions()</b>, <b>hasMoreElements()</b>,
|
||||
<b>nextSolution()</b>, <b>nextElement()</b>, or <b>rewind()</b>
|
||||
methods are explicitly invoked, thread-safety is lost. The
|
||||
problem is that while the blocks of these programs are synchronized
|
||||
so that in effect no two <b>Query</b> objects can invoke any of these
|
||||
methods concurrently, there is nothing that prevents a <b>Query</b>
|
||||
object in one thread from calling one of these methods, and another
|
||||
<b>Query</b> object in a different thread from calling this same
|
||||
method, or even another that could produce indeterminate results. </p>
|
||||
<p>The <b>Query</b> class, however, does make synchronization around
|
||||
these methods possible by providing a reference to the monitor object
|
||||
that locks competing threads from executing critical code. The
|
||||
reference is obtained by the static method </p>
|
||||
<pre style="margin-left: 1cm; margin-right: 1cm; margin-bottom: 0.5cm;">public static Object lock();</pre>
|
||||
<p>Thus, programmers can wrap calls to these non-thread-safe methods in
|
||||
synchronized blocks, using the lock object to prevent other threads
|
||||
from entering any of these methods. To write a thread-safe loop
|
||||
to process all of a <b>Query</b>'s solutions, for example, one might
|
||||
write </p>
|
||||
<pre style="margin-left: 1cm; margin-right: 1cm;">Query query = // obtain Query<br>synchronized ( Query.lock() ){<br> while ( query.hasMoreSolutions() ){<br> Hashtable solution = query.nextSolution();<br> // process solution...<br> }<br>}</pre>
|
||||
<p><br>
|
||||
Note that the <b>query()</b>, <b>oneSolution()</b>, and
|
||||
<b>allSolutions() </b>methods effectively do the same as the above
|
||||
code snippet, so there is no need to explicitly synchronized on the
|
||||
<b>Query</b>'s monitor object when these methods are called. <br>
|
||||
|
||||
</p>
|
||||
<h3><a name="Exceptions"></a>Exceptions</h3>
|
||||
<p>The <b><i>JPL</i></b> package provides fairly crude exception
|
||||
handling. The base class for all <b><i>JPL</i></b> Exceptions
|
||||
is <b>JPLException</b>, which is a <b>java.lang.RuntimeException</b>
|
||||
(and hence need not be declared), and which will be thrown in the
|
||||
absence of any other kind of exception that can be thrown, usually as
|
||||
the result of some programming error. Converting the exception
|
||||
to a <b>java.lang.String</b> should provide some descriptive
|
||||
information about the reason for the error. All other <b><i>JPL</i></b>
|
||||
excpetion classes extend this class. Currently there are two,
|
||||
the <b>QueryInProgressException</b> class and the <b>PrologException</b>
|
||||
class. </p>
|
||||
<p>A <b>QueryInProgressException</b> is thrown when a <b>Query</b> is
|
||||
opened while another is in progress; this exception can be caught in
|
||||
multi-threaded situations, but a better strategy for managing
|
||||
multi-threaded situations is discussed in the <a
|
||||
href="#Multi-Threaded%20Queries">Multi-Threaded
|
||||
Queries</a> section. If you obey the rules discussed in this
|
||||
section, you should have no reason to catch this exception. </p>
|
||||
<p>A <b>PrologException</b> is thrown either during execution of a
|
||||
Prolog built-in predicate or by an explicit call, by Prolog
|
||||
application code, of the Prolog predicate <i>throw/1.</i> </p>
|
||||
<p>There is currently no means of gracefully handling exceptions
|
||||
caused by malformed parameters (e.g., undefined predicates) passed
|
||||
through the High-Level Interface to the Prolog engine (?). <br>
|
||||
|
||||
</p>
|
||||
<h3><a name="Debugging"></a>Debugging</h3>
|
||||
<p>Each <b>Term</b> type (together with the <b>Query</b> class)
|
||||
supports an implementation of <b>toString()</b> which returns a
|
||||
more-or-less familiar Prolog textual representation of the <b>Term</b>
|
||||
or <b>Query</b>. </p>
|
||||
<p>Sometimes, however, this information is not sufficient, so we have
|
||||
provided a method <b>debugString()</b> which provides a more verbose
|
||||
and explicit representation, including the types (atom, integer etc)
|
||||
of each term and subterm. </p>
|
||||
<p>In general, <b>Term</b> and <b>Query</b> instances are represented
|
||||
in the form (<i>type data</i>), where <i>type</i> is the name of the
|
||||
type (e.g., <b>Atom</b>, <b>Compound</b>, <b>Tuple</b>, etc.), and
|
||||
<i>data</i> is a representation of the contents of the <b>Term</b>.
|
||||
For example, if the <b>Term</b> is an <b>Atom</b>, the data is the
|
||||
<b>Atom</b>'s name. The arguments of <b>Compounds</b> are
|
||||
represented by comma-separated lists within square brackets ('['
|
||||
']'). </p>
|
||||
<p>Viewing the structure of a <b>Term</b> or <b>Query</b> can be
|
||||
useful in determining whether an error lies on the Prolog or Java
|
||||
side of your JPL applications. </p>
|
||||
<p>Perhaps better still, <b>Term</b> implements (in a basic but
|
||||
adequate way) the <b>javax.swing.TreeModel</b> interface, and its
|
||||
<b>display()</b> method creates a <b>JFrame</b> containing a
|
||||
browseable <b>JTree</b> representation of the term. <br>
|
||||
</p>
|
||||
<h3><a name="Version"></a>Version information</h3>
|
||||
<p>To obtain the current version of <b><i>JPL</i></b> you are using,
|
||||
you may obtain a reference to the <b>jpl.Version</b> static instance
|
||||
of the <b><i>JPL</i></b> class by calling the <b>JPL.version() </b>static
|
||||
method. This will return a <b>jpl.Version</b> structure, which
|
||||
has the following final fields: </p>
|
||||
<pre style="margin-left: 1cm; margin-right: 1cm;">package jpl;<br>public class Version {<br> public final int major; // e.g. 2<br> public final int minor; // e.g. 0<br> public final int patch; // e.g. 2<br> public final java.lang.String status; // e.g. "alpha"<br>}</pre>
|
||||
<p>You may wish to use this class instance to obtain fine-grained
|
||||
information about the current JPL version, e.g.</p>
|
||||
<pre style="margin-left: 0.85cm; margin-bottom: 0.5cm;">if ( JPL.version().major == 2 ) {</pre>
|
||||
<p>You may also simply call the <b>version_string() </b>static method
|
||||
of
|
||||
the <b>jpl.JPL</b> class. This will return a <b>java.lang.String</b>
|
||||
representation of the current <b><i>JPL</i></b> version. </p>
|
||||
<p>The version string can be written to the standard output stream by
|
||||
running the <b>main()</b> method of the <b>jpl.JPL</b> class. </p>
|
||||
<pre style="margin-left: 1cm; margin-right: 1cm;">linux% java jpl.JPL<br>JPL 2.0.2-alpha</pre>
|
||||
<h3><a name="What's Missing"></a>What's Missing</h3>
|
||||
<p style="margin-bottom: 0cm;">The current implementation of the
|
||||
High-Level Interface lacks support for modules, and for multiple
|
||||
Prolog engines.<br>
|
||||
<br>
|
||||
</p>
|
||||
<hr size="4" noshade="noshade">
|
||||
<p align="right" style="margin-bottom: 0cm;"><a href="index.html">up</a>
|
||||
<a href="low-level_interface.html">prev</a> next <a
|
||||
href="api/packages.html">API</a></p>
|
||||
</body>
|
||||
</html>
|
|
@ -1,166 +0,0 @@
|
|||
<!DOCTYPE doctype PUBLIC "-//w3c//dtd html 4.0 transitional//en">
|
||||
<html>
|
||||
<head>
|
||||
|
||||
<meta http-equiv="Content-Type"
|
||||
content="text/html; charset=iso-8859-1">
|
||||
|
||||
<meta name="GENERATOR"
|
||||
content="Mozilla/4.7 [en] (WinNT; I) [Netscape]">
|
||||
|
||||
<meta name="Author" content="Fred Dushin">
|
||||
|
||||
<meta name="Keywords" content="java,prolog">
|
||||
<title>JPL A Java Interface to Prolog</title>
|
||||
</head>
|
||||
<body text="#000000" bgcolor="#ffffff" link="#00009c" vlink="#ce31ce"
|
||||
alink="#ff0000">
|
||||
|
||||
<hr noshade="noshade" width="100%">
|
||||
<center>
|
||||
<p><img src="logo.jpg" nosave="" height="113" width="204">
|
||||
<br>
|
||||
<i>A Java Interface to Prolog</i></p>
|
||||
</center>
|
||||
|
||||
<h3> <a name="News"></a>News</h3>
|
||||
March 18, 2003
|
||||
<ul>
|
||||
<li> JPL 2.0.2 re-released.</li>
|
||||
|
||||
<ul>
|
||||
<li>see <a href="release_notes_202.html">Release Notes</a></li>
|
||||
|
||||
</ul>
|
||||
|
||||
</ul>
|
||||
May 5, 1999
|
||||
<ul>
|
||||
<li> JPL 1.0.1 released. This release contains the following changes:</li>
|
||||
|
||||
<ul>
|
||||
<li> Fixed a bug with the representation of Tuples. They are now
|
||||
<i>always</i> binary terms, though generally structured as binary
|
||||
trees. The interface is the same, except we now require that Tuples
|
||||
contain <i>at least</i> two elements. (The single element constructor
|
||||
has been removed, but I consider this a patch, not an interface change)</li>
|
||||
<li> Added an ith() accessor to the Compound and Query classes. This is
|
||||
used to obtain the ith element in the array of Terms in the Compound or Query.</li>
|
||||
<li> Added a debugString() method to the Term and Query classes.
|
||||
This is used to obtain more detailed information about the structure of the
|
||||
Term or Query.</li>
|
||||
<li> Updated and fixed some of the documentation.</li>
|
||||
<li> JPL is now released under the terms of the Gnu Library Public License,
|
||||
not the Gnu General Public License. All relevant files have been updated.</li>
|
||||
|
||||
</ul>
|
||||
|
||||
</ul>
|
||||
See the <a href="#Copyright%20and%20License%20Information">Copyright and
|
||||
License Information</a> section for more information.
|
||||
<p>Feb 25, 1999 </p>
|
||||
|
||||
<ul>
|
||||
<li> JPL 1.0.0 is out. Check the <a href="#Download">download</a>
|
||||
section for information about how to retrieve it. I <i>hope</i> most
|
||||
of the core interfaces are frozen.</li>
|
||||
<li> I am in need of Solaris testers! I have access to a Solaris
|
||||
box, but it has ancient and outdated compilers, libs, etc. If anyone
|
||||
gets this to compile on any platform other than Linux, please send me patches.</li>
|
||||
<li> Eventually I'd like to work out some config scripts. For now
|
||||
you must config manually. Sorry.</li>
|
||||
<li> I have not even tried getting this to run under Windows. Anyone
|
||||
with more expertise (and patience) than I is welcome to give it a go!</li>
|
||||
|
||||
</ul>
|
||||
|
||||
<h3> <a name="General Description"></a>General Description</h3>
|
||||
JPL is a set of Java classes and C functions providing an interface between
|
||||
Java and Prolog. JPL uses the Java Native Interface (JNI) to connect
|
||||
to a Prolog engine through the Prolog Foreign Language Interface (FLI),
|
||||
which is more or less in the process of being standardized in various implementations
|
||||
of Prolog. JPL is not a pure Java implementation of Prolog; it makes
|
||||
extensive use of native implementations of Prolog on supported platforms.
|
||||
The current version of JPL only works with SWI-Prolog.
|
||||
<p>Currently, JPL only supports the embedding of a Prolog engine within the
|
||||
Java VM. Future versions may support the embedding of a Java VM within
|
||||
Prolog, so that, for example, one could take advantage of the rich class structure
|
||||
of the Java environment from within Prolog. </p>
|
||||
|
||||
<p>JPL is designed in two layers, a low-level interface to the Prolog FLI
|
||||
and a high-level Java interface for the Java programmer who is not concerned
|
||||
with the details of the Prolog FLI. The low-level interface is provided
|
||||
for C programmers who may wish to port their C implementations which use
|
||||
the FLI to Java with minimal fuss. </p>
|
||||
|
||||
<h3> <a name="Requirements"></a>Requirements</h3>
|
||||
JPL now requires SWI-Prolog version 3.1.0 or later, which is available
|
||||
at the following URL:
|
||||
<blockquote><a href="http://www.swi-prolog.org/">http://www.swi-prolog.org/</a></blockquote>
|
||||
SWI-Prolog license information is available here:
|
||||
<blockquote><a href="http://www.swi-prolog.org/license.html">http://www.swi-prolog.org/license.html</a></blockquote>
|
||||
You will also need a Java development environment. Sun's Java website
|
||||
is a good place to start:
|
||||
<blockquote><a href="http://java.sun.com/">http://java.sun.com/</a></blockquote>
|
||||
JPL 2.0.2 was developed and tested on Windows NT4, and has not yet been compiled
|
||||
on any non-Windows platform<br>
|
||||
JPL1.0.1 was written and tested on Linux kernel 2.1.24. It should compile
|
||||
on any other UNIX system with a full suite of gnu tools.
|
||||
<h3> <a name="Copyright and License Information"></a>Copyright and License
|
||||
Information</h3>
|
||||
JPL is released under the terms of the Gnu Library Public License:
|
||||
<blockquote><i>Copyright (c) 2003 Paul Singleton. All rights reserved.</i>
|
||||
<i><br>
|
||||
Copyright (c) 1998 Fred Dushin. All rights reserved.</i>
|
||||
<p><i><font size="-1">This library is free software; you can redistribute
|
||||
it and/or modify it under the terms of the GNU Library Public License as
|
||||
published by the Free Software Foundation; either version 2 of the License,
|
||||
or (at your option) any later version.</font></i> </p>
|
||||
|
||||
<p><i><font size="-1">This library is distributed in the hope that it will
|
||||
be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library
|
||||
Public License for more details.</font></i></p>
|
||||
</blockquote>
|
||||
This means, among other things, that you may <i>use</i> this software in
|
||||
commercial products without being required to distribute your software under
|
||||
the same licensing terms. See the <a href="lgpl.html">License</a> for
|
||||
more details.
|
||||
<h3> <a name="Documentation"></a>Documentation</h3>
|
||||
The Documentation for JPL is organized into the following sections:
|
||||
<ol>
|
||||
<li> <a href="getting_started.html">Getting Started</a></li>
|
||||
<li> <a href="low-level_interface.html">The Low-Level Interface</a></li>
|
||||
<li> <a href="high-level_interface.html">The High-Level Interface</a></li>
|
||||
<li> <a href="gpl.html">Gnu Public License</a></li>
|
||||
<li> <a href="javadoc/index.html">The JPL API</a></li>
|
||||
|
||||
</ol>
|
||||
|
||||
<h3> <a name="Download"></a>Download (this section is obsolete)</h3>
|
||||
Gnu-zipped, UNIX compressed, and Zipped versions of the source distribution
|
||||
are available at:
|
||||
<blockquote><a
|
||||
href="http://blackcat.cat.syr.edu/%7Efadushin/software/jpl/download">http://blackcat.cat.syr.edu/~fadushin/software/jpl/download</a></blockquote>
|
||||
You may be interested in viewing the <a href="ChangeLog">ChangeLog</a>.
|
||||
|
||||
<p>The latest version of JPL is available by the World Wide Web at the following
|
||||
URL: </p>
|
||||
|
||||
<blockquote><a
|
||||
href="http://blackcat.cat.syr.edu/%7Efadushin/software/jpl">http://blackcat.cat.syr.edu/~fadushin/software/jpl</a></blockquote>
|
||||
Writing free software is only gratifying if you hear from users.
|
||||
Please feel free to contact the author, Fred Dushin, at the following address:
|
||||
|
||||
<blockquote><a href="mailto:fadushin@top.cis.syr.edu">fadushin@top.cis.syr.edu</a></blockquote>
|
||||
|
||||
<div align="right"><font size="-2">Happy Prologging.</font></div>
|
||||
|
||||
<hr noshade="noshade" width="100%"> <br>
|
||||
These pages were created using <a href="http://www.netscape.com">Netscape</a>
|
||||
Communicator, 4.5 for <a href="http://www.linuxppc.org">Linux </a>on the
|
||||
<a href="http://www.chips.ibm.com/products/powerpc/">PowerPC</a>. The
|
||||
JPL logo was made by the <a href="http://www.gimp.org">Gimp</a>. <br>
|
||||
<br>
|
||||
</body>
|
||||
</html>
|
|
@ -1,471 +0,0 @@
|
|||
<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
|
||||
<meta name="GENERATOR" content="Mozilla/4.5 [en] (X11; I; Linux 2.1.24 ppc) [Netscape]">
|
||||
<title>GNU Library General Public License - GNU Project - Free Software Foundation (FSF)</title>
|
||||
<link REV="made" HREF="mailto:webmasters@www.gnu.org">
|
||||
</head>
|
||||
<body text="#000000" bgcolor="#FFFFFF" link="#1F00FF" vlink="#9900DD" alink="#FF0000">
|
||||
|
||||
<h1>
|
||||
GNU Library General Public License</h1>
|
||||
<a href="philosophical-gnu-sm.jpg"><img SRC="philosophical-gnu-sm.jpg" ALT="[image of a Philosophical Gnu]" height=200 width=160></a><a href="/graphics/philosophical-gnu-sm.jpg">
|
||||
(jpeg 7k)</a><a href="/graphics/philosophical-gnu.jpg">(jpeg 141k)</a><a href="/philosophy/gif.html">no
|
||||
gifs due to patent problems</a>
|
||||
<p>
|
||||
<hr>
|
||||
<h2>
|
||||
Table of Contents</h2>
|
||||
|
||||
<ul>
|
||||
<li>
|
||||
<a NAME="TOC1" HREF="lgpl.html#SEC1"></a><a href="lgpl.html#SEC1" NAME="TOC1">GNU
|
||||
LIBRARY GENERAL PUBLIC LICENSE</a></li>
|
||||
|
||||
<ul>
|
||||
<li>
|
||||
<a NAME="TOC2" HREF="lgpl.html#SEC2"></a><a href="lgpl.html#SEC2" NAME="TOC2">Preamble</a></li>
|
||||
|
||||
<li>
|
||||
<a NAME="TOC3" HREF="lgpl.html#SEC3"></a><a href="lgpl.html#SEC3" NAME="TOC3">TERMS
|
||||
AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION</a></li>
|
||||
|
||||
<li>
|
||||
<a NAME="TOC4" HREF="lgpl.html#SEC4"></a><a href="lgpl.html#SEC4" NAME="TOC4">How
|
||||
to Apply These Terms to Your New Libraries</a></li>
|
||||
</ul>
|
||||
</ul>
|
||||
|
||||
<hr>
|
||||
<h2>
|
||||
<a NAME="SEC1" HREF="lgpl.html#TOC1"></a><a href="lgpl.html#TOC1" NAME="SEC1">GNU
|
||||
LIBRARY GENERAL PUBLIC LICENSE</a></h2>
|
||||
Version 2, June 1991
|
||||
<pre>Copyright (C) 1991 Free Software Foundation, Inc.
|
||||
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
[This is the first released version of the library GPL. It is
|
||||
numbered 2 because it goes with version 2 of the ordinary GPL.]</pre>
|
||||
|
||||
<h2>
|
||||
<a NAME="SEC2" HREF="lgpl.html#TOC2"></a><a href="lgpl.html#TOC2" NAME="SEC2">Preamble</a></h2>
|
||||
The licenses for most software are designed to take away your freedom to
|
||||
share and change it. By contrast, the GNU General Public Licenses are intended
|
||||
to guarantee your freedom to share and change free software--to make sure
|
||||
the software is free for all its users.
|
||||
<p>This license, the Library General Public License, applies to some specially
|
||||
designated Free Software Foundation software, and to any other libraries
|
||||
whose authors decide to use it. You can use it for your libraries, too.
|
||||
<p>When we speak of free software, we are referring to freedom, not price.
|
||||
Our General Public Licenses are designed to make sure that you have the
|
||||
freedom to distribute copies of free software (and charge for this service
|
||||
if you wish), that you receive source code or can get it if you want it,
|
||||
that you can change the software or use pieces of it in new free programs;
|
||||
and that you know you can do these things.
|
||||
<p>To protect your rights, we need to make restrictions that forbid anyone
|
||||
to deny you these rights or to ask you to surrender the rights. These restrictions
|
||||
translate to certain responsibilities for you if you distribute copies
|
||||
of the library, or if you modify it.
|
||||
<p>For example, if you distribute copies of the library, whether gratis
|
||||
or for a fee, you must give the recipients all the rights that we gave
|
||||
you. You must make sure that they, too, receive or can get the source code.
|
||||
If you link a program with the library, you must provide complete object
|
||||
files to the recipients so that they can relink them with the library,
|
||||
after making changes to the library and recompiling it. And you must show
|
||||
them these terms so they know their rights.
|
||||
<p>Our method of protecting your rights has two steps: (1) copyright the
|
||||
library, and (2) offer you this license which gives you legal permission
|
||||
to copy, distribute and/or modify the library.
|
||||
<p>Also, for each distributor's protection, we want to make certain that
|
||||
everyone understands that there is no warranty for this free library. If
|
||||
the library is modified by someone else and passed on, we want its recipients
|
||||
to know that what they have is not the original version, so that any problems
|
||||
introduced by others will not reflect on the original authors' reputations.
|
||||
<p>Finally, any free program is threatened constantly by software patents.
|
||||
We wish to avoid the danger that companies distributing free software will
|
||||
individually obtain patent licenses, thus in effect transforming the program
|
||||
into proprietary software. To prevent this, we have made it clear that
|
||||
any patent must be licensed for everyone's free use or not licensed at
|
||||
all.
|
||||
<p>Most GNU software, including some libraries, is covered by the ordinary
|
||||
GNU General Public License, which was designed for utility programs. This
|
||||
license, the GNU Library General Public License, applies to certain designated
|
||||
libraries. This license is quite different from the ordinary one; be sure
|
||||
to read it in full, and don't assume that anything in it is the same as
|
||||
in the ordinary license.
|
||||
<p>The reason we have a separate public license for some libraries is that
|
||||
they blur the distinction we usually make between modifying or adding to
|
||||
a program and simply using it. Linking a program with a library, without
|
||||
changing the library, is in some sense simply using the library, and is
|
||||
analogous to running a utility program or application program. However,
|
||||
in a textual and legal sense, the linked executable is a combined work,
|
||||
a derivative of the original library, and the ordinary General Public License
|
||||
treats it as such.
|
||||
<p>Because of this blurred distinction, using the ordinary General Public
|
||||
License for libraries did not effectively promote software sharing, because
|
||||
most developers did not use the libraries. We concluded that weaker conditions
|
||||
might promote sharing better.
|
||||
<p>However, unrestricted linking of non-free programs would deprive the
|
||||
users of those programs of all benefit from the free status of the libraries
|
||||
themselves. This Library General Public License is intended to permit developers
|
||||
of non-free programs to use free libraries, while preserving your freedom
|
||||
as a user of such programs to change the free libraries that are incorporated
|
||||
in them. (We have not seen how to achieve this as regards changes in header
|
||||
files, but we have achieved it as regards changes in the actual functions
|
||||
of the Library.) The hope is that this will lead to faster development
|
||||
of free libraries.
|
||||
<p>The precise terms and conditions for copying, distribution and modification
|
||||
follow. Pay close attention to the difference between a "work based on
|
||||
the library" and a "work that uses the library". The former contains code
|
||||
derived from the library, while the latter only works together with the
|
||||
library.
|
||||
<p>Note that it is possible for a library to be covered by the ordinary
|
||||
General Public License rather than by this special one.
|
||||
<h2>
|
||||
<a NAME="SEC3" HREF="lgpl.html#TOC3"></a><a href="lgpl.html#TOC3" NAME="SEC3">TERMS
|
||||
AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION</a></h2>
|
||||
<b>0.</b> This License Agreement applies to any software library which
|
||||
contains a notice placed by the copyright holder or other authorized party
|
||||
saying it may be distributed under the terms of this Library General Public
|
||||
License (also called "this License"). Each licensee is addressed as "you".
|
||||
<p>A "library" means a collection of software functions and/or data prepared
|
||||
so as to be conveniently linked with application programs (which use some
|
||||
of those functions and data) to form executables.
|
||||
<p>The "Library", below, refers to any such software library or work which
|
||||
has been distributed under these terms. A "work based on the Library" means
|
||||
either the Library or any derivative work under copyright law: that is
|
||||
to say, a work containing the Library or a portion of it, either verbatim
|
||||
or with modifications and/or translated straightforwardly into another
|
||||
language. (Hereinafter, translation is included without limitation in the
|
||||
term "modification".)
|
||||
<p>"Source code" for a work means the preferred form of the work for making
|
||||
modifications to it. For a library, complete source code means all the
|
||||
source code for all modules it contains, plus any associated interface
|
||||
definition files, plus the scripts used to control compilation and installation
|
||||
of the library.
|
||||
<p>Activities other than copying, distribution and modification are not
|
||||
covered by this License; they are outside its scope. The act of running
|
||||
a program using the Library is not restricted, and output from such a program
|
||||
is covered only if its contents constitute a work based on the Library
|
||||
(independent of the use of the Library in a tool for writing it). Whether
|
||||
that is true depends on what the Library does and what the program that
|
||||
uses the Library does.
|
||||
<p><b>1.</b> You may copy and distribute verbatim copies of the Library's
|
||||
complete source code as you receive it, in any medium, provided that you
|
||||
conspicuously and appropriately publish on each copy an appropriate copyright
|
||||
notice and disclaimer of warranty; keep intact all the notices that refer
|
||||
to this License and to the absence of any warranty; and distribute a copy
|
||||
of this License along with the Library.
|
||||
<p>You may charge a fee for the physical act of transferring a copy, and
|
||||
you may at your option offer warranty protection in exchange for a fee.
|
||||
<p><b>2.</b> You may modify your copy or copies of the Library or any portion
|
||||
of it, thus forming a work based on the Library, and copy and distribute
|
||||
such modifications or work under the terms of Section 1 above, provided
|
||||
that you also meet all of these conditions: <!-- we use this doubled UL to get the sub-sections indented, --><!-- while making the bullets as unobvious as possible. -->
|
||||
<ul>
|
||||
<li>
|
||||
<b>a)</b> The modified work must itself be a software library.</li>
|
||||
|
||||
<li>
|
||||
<b>b)</b> You must cause the files modified to carry prominent notices
|
||||
stating that you changed the files and the date of any change.</li>
|
||||
|
||||
<li>
|
||||
<b>c)</b> You must cause the whole of the work to be licensed at no charge
|
||||
to all third parties under the terms of this License.</li>
|
||||
|
||||
<li>
|
||||
<b>d)</b> If a facility in the modified Library refers to a function or
|
||||
a table of data to be supplied by an application program that uses the
|
||||
facility, other than as an argument passed when the facility is invoked,
|
||||
then you must make a good faith effort to ensure that, in the event an
|
||||
application does not supply such function or table, the facility still
|
||||
operates, and performs whatever part of its purpose remains meaningful.
|
||||
(For example, a function in a library to compute square roots has a purpose
|
||||
that is entirely well-defined independent of the application. Therefore,
|
||||
Subsection 2d requires that any application-supplied function or table
|
||||
used by this function must be optional: if the application does not supply
|
||||
it, the square root function must still compute square roots.)</li>
|
||||
</ul>
|
||||
These requirements apply to the modified work as a whole. If identifiable
|
||||
sections of that work are not derived from the Library, and can be reasonably
|
||||
considered independent and separate works in themselves, then this License,
|
||||
and its terms, do not apply to those sections when you distribute them
|
||||
as separate works. But when you distribute the same sections as part of
|
||||
a whole which is a work based on the Library, the distribution of the whole
|
||||
must be on the terms of this License, whose permissions for other licensees
|
||||
extend to the entire whole, and thus to each and every part regardless
|
||||
of who wrote it.
|
||||
<p>Thus, it is not the intent of this section to claim rights or contest
|
||||
your rights to work written entirely by you; rather, the intent is to exercise
|
||||
the right to control the distribution of derivative or collective works
|
||||
based on the Library.
|
||||
<p>In addition, mere aggregation of another work not based on the Library
|
||||
with the Library (or with a work based on the Library) on a volume of a
|
||||
storage or distribution medium does not bring the other work under the
|
||||
scope of this License.
|
||||
<p><b>3.</b> You may opt to apply the terms of the ordinary GNU General
|
||||
Public License instead of this License to a given copy of the Library.
|
||||
To do this, you must alter all the notices that refer to this License,
|
||||
so that they refer to the ordinary GNU General Public License, version
|
||||
2, instead of to this License. (If a newer version than version 2 of the
|
||||
ordinary GNU General Public License has appeared, then you can specify
|
||||
that version instead if you wish.) Do not make any other change in these
|
||||
notices.
|
||||
<p>Once this change is made in a given copy, it is irreversible for that
|
||||
copy, so the ordinary GNU General Public License applies to all subsequent
|
||||
copies and derivative works made from that copy.
|
||||
<p>This option is useful when you wish to copy part of the code of the
|
||||
Library into a program that is not a library.
|
||||
<p><b>4.</b> You may copy and distribute the Library (or a portion or derivative
|
||||
of it, under Section 2) in object code or executable form under the terms
|
||||
of Sections 1 and 2 above provided that you accompany it with the complete
|
||||
corresponding machine-readable source code, which must be distributed under
|
||||
the terms of Sections 1 and 2 above on a medium customarily used for software
|
||||
interchange.
|
||||
<p>If distribution of object code is made by offering access to copy from
|
||||
a designated place, then offering equivalent access to copy the source
|
||||
code from the same place satisfies the requirement to distribute the source
|
||||
code, even though third parties are not compelled to copy the source along
|
||||
with the object code.
|
||||
<p><b>5.</b> A program that contains no derivative of any portion of the
|
||||
Library, but is designed to work with the Library by being compiled or
|
||||
linked with it, is called a "work that uses the Library". Such a work,
|
||||
in isolation, is not a derivative work of the Library, and therefore falls
|
||||
outside the scope of this License.
|
||||
<p>However, linking a "work that uses the Library" with the Library creates
|
||||
an executable that is a derivative of the Library (because it contains
|
||||
portions of the Library), rather than a "work that uses the library". The
|
||||
executable is therefore covered by this License. Section 6 states terms
|
||||
for distribution of such executables.
|
||||
<p>When a "work that uses the Library" uses material from a header file
|
||||
that is part of the Library, the object code for the work may be a derivative
|
||||
work of the Library even though the source code is not. Whether this is
|
||||
true is especially significant if the work can be linked without the Library,
|
||||
or if the work is itself a library. The threshold for this to be true is
|
||||
not precisely defined by law.
|
||||
<p>If such an object file uses only numerical parameters, data structure
|
||||
layouts and accessors, and small macros and small inline functions (ten
|
||||
lines or less in length), then the use of the object file is unrestricted,
|
||||
regardless of whether it is legally a derivative work. (Executables containing
|
||||
this object code plus portions of the Library will still fall under Section
|
||||
6.)
|
||||
<p>Otherwise, if the work is a derivative of the Library, you may distribute
|
||||
the object code for the work under the terms of Section 6. Any executables
|
||||
containing that work also fall under Section 6, whether or not they are
|
||||
linked directly with the Library itself.
|
||||
<p><b>6.</b> As an exception to the Sections above, you may also compile
|
||||
or link a "work that uses the Library" with the Library to produce a work
|
||||
containing portions of the Library, and distribute that work under terms
|
||||
of your choice, provided that the terms permit modification of the work
|
||||
for the customer's own use and reverse engineering for debugging such modifications.
|
||||
<p>You must give prominent notice with each copy of the work that the Library
|
||||
is used in it and that the Library and its use are covered by this License.
|
||||
You must supply a copy of this License. If the work during execution displays
|
||||
copyright notices, you must include the copyright notice for the Library
|
||||
among them, as well as a reference directing the user to the copy of this
|
||||
License. Also, you must do one of these things: <!-- we use this doubled UL to get the sub-sections indented, --><!-- while making the bullets as unobvious as possible. -->
|
||||
<ul>
|
||||
<li>
|
||||
<b>a)</b> Accompany the work with the complete corresponding machine-readable
|
||||
source code for the Library including whatever changes were used in the
|
||||
work (which must be distributed under Sections 1 and 2 above); and, if
|
||||
the work is an executable linked with the Library, with the complete machine-readable
|
||||
"work that uses the Library", as object code and/or source code, so that
|
||||
the user can modify the Library and then relink to produce a modified executable
|
||||
containing the modified Library. (It is understood that the user who changes
|
||||
the contents of definitions files in the Library will not necessarily be
|
||||
able to recompile the application to use the modified definitions.)</li>
|
||||
|
||||
<li>
|
||||
<b>b)</b> Accompany the work with a written offer, valid for at least three
|
||||
years, to give the same user the materials specified in Subsection 6a,
|
||||
above, for a charge no more than the cost of performing this distribution.</li>
|
||||
|
||||
<li>
|
||||
<b>c)</b> If distribution of the work is made by offering access to copy
|
||||
from a designated place, offer equivalent access to copy the above specified
|
||||
materials from the same place.</li>
|
||||
|
||||
<li>
|
||||
<b>d)</b> Verify that the user has already received a copy of these materials
|
||||
or that you have already sent this user a copy.</li>
|
||||
</ul>
|
||||
For an executable, the required form of the "work that uses the Library"
|
||||
must include any data and utility programs needed for reproducing the executable
|
||||
from it. However, as a special exception, the source code distributed need
|
||||
not include anything that is normally distributed (in either source or
|
||||
binary form) with the major components (compiler, kernel, and so on) of
|
||||
the operating system on which the executable runs, unless that component
|
||||
itself accompanies the executable.
|
||||
<p>It may happen that this requirement contradicts the license restrictions
|
||||
of other proprietary libraries that do not normally accompany the operating
|
||||
system. Such a contradiction means you cannot use both them and the Library
|
||||
together in an executable that you distribute.
|
||||
<p><b>7.</b> You may place library facilities that are a work based on
|
||||
the Library side-by-side in a single library together with other library
|
||||
facilities not covered by this License, and distribute such a combined
|
||||
library, provided that the separate distribution of the work based on the
|
||||
Library and of the other library facilities is otherwise permitted, and
|
||||
provided that you do these two things: <!-- we use this doubled UL to get the sub-sections indented, --><!-- while making the bullets as unobvious as possible. -->
|
||||
<ul>
|
||||
<li>
|
||||
<b>a)</b> Accompany the combined library with a copy of the same work based
|
||||
on the Library, uncombined with any other library facilities. This must
|
||||
be distributed under the terms of the Sections above.</li>
|
||||
|
||||
<li>
|
||||
<b>b)</b> Give prominent notice with the combined library of the fact that
|
||||
part of it is a work based on the Library, and explaining where to find
|
||||
the accompanying uncombined form of the same work.</li>
|
||||
</ul>
|
||||
<b>8.</b> You may not copy, modify, sublicense, link with, or distribute
|
||||
the Library except as expressly provided under this License. Any attempt
|
||||
otherwise to copy, modify, sublicense, link with, or distribute the Library
|
||||
is void, and will automatically terminate your rights under this License.
|
||||
However, parties who have received copies, or rights, from you under this
|
||||
License will not have their licenses terminated so long as such parties
|
||||
remain in full compliance.
|
||||
<p><b>9.</b> You are not required to accept this License, since you have
|
||||
not signed it. However, nothing else grants you permission to modify or
|
||||
distribute the Library or its derivative works. These actions are prohibited
|
||||
by law if you do not accept this License. Therefore, by modifying or distributing
|
||||
the Library (or any work based on the Library), you indicate your acceptance
|
||||
of this License to do so, and all its terms and conditions for copying,
|
||||
distributing or modifying the Library or works based on it.
|
||||
<p><b>10.</b> Each time you redistribute the Library (or any work based
|
||||
on the Library), the recipient automatically receives a license from the
|
||||
original licensor to copy, distribute, link with or modify the Library
|
||||
subject to these terms and conditions. You may not impose any further restrictions
|
||||
on the recipients' exercise of the rights granted herein. You are not responsible
|
||||
for enforcing compliance by third parties to this License.
|
||||
<p><b>11.</b> If, as a consequence of a court judgment or allegation of
|
||||
patent infringement or for any other reason (not limited to patent issues),
|
||||
conditions are imposed on you (whether by court order, agreement or otherwise)
|
||||
that contradict the conditions of this License, they do not excuse you
|
||||
from the conditions of this License. If you cannot distribute so as to
|
||||
satisfy simultaneously your obligations under this License and any other
|
||||
pertinent obligations, then as a consequence you may not distribute the
|
||||
Library at all. For example, if a patent license would not permit royalty-free
|
||||
redistribution of the Library by all those who receive copies directly
|
||||
or indirectly through you, then the only way you could satisfy both it
|
||||
and this License would be to refrain entirely from distribution of the
|
||||
Library.
|
||||
<p>If any portion of this section is held invalid or unenforceable under
|
||||
any particular circumstance, the balance of the section is intended to
|
||||
apply, and the section as a whole is intended to apply in other circumstances.
|
||||
<p>It is not the purpose of this section to induce you to infringe any
|
||||
patents or other property right claims or to contest validity of any such
|
||||
claims; this section has the sole purpose of protecting the integrity of
|
||||
the free software distribution system which is implemented by public license
|
||||
practices. Many people have made generous contributions to the wide range
|
||||
of software distributed through that system in reliance on consistent application
|
||||
of that system; it is up to the author/donor to decide if he or she is
|
||||
willing to distribute software through any other system and a licensee
|
||||
cannot impose that choice.
|
||||
<p>This section is intended to make thoroughly clear what is believed to
|
||||
be a consequence of the rest of this License.
|
||||
<p><b>12.</b> If the distribution and/or use of the Library is restricted
|
||||
in certain countries either by patents or by copyrighted interfaces, the
|
||||
original copyright holder who places the Library under this License may
|
||||
add an explicit geographical distribution limitation excluding those countries,
|
||||
so that distribution is permitted only in or among countries not thus excluded.
|
||||
In such case, this License incorporates the limitation as if written in
|
||||
the body of this License.
|
||||
<p><b>13.</b> The Free Software Foundation may publish revised and/or new
|
||||
versions of the Library General Public License from time to time. Such
|
||||
new versions will be similar in spirit to the present version, but may
|
||||
differ in detail to address new problems or concerns.
|
||||
<p>Each version is given a distinguishing version number. If the Library
|
||||
specifies a version number of this License which applies to it and "any
|
||||
later version", you have the option of following the terms and conditions
|
||||
either of that version or of any later version published by the Free Software
|
||||
Foundation. If the Library does not specify a license version number, you
|
||||
may choose any version ever published by the Free Software Foundation.
|
||||
<p><b>14.</b> If you wish to incorporate parts of the Library into other
|
||||
free programs whose distribution conditions are incompatible with these,
|
||||
write to the author to ask for permission. For software which is copyrighted
|
||||
by the Free Software Foundation, write to the Free Software Foundation;
|
||||
we sometimes make exceptions for this. Our decision will be guided by the
|
||||
two goals of preserving the free status of all derivatives of our free
|
||||
software and of promoting the sharing and reuse of software generally.
|
||||
<p><b>NO WARRANTY</b>
|
||||
<p><b>15.</b> BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS
|
||||
NO WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
|
||||
EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER
|
||||
PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER
|
||||
EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK
|
||||
AS TO THE QUALITY AND PERFORMANCE OF THE LIBRARY IS WITH YOU. SHOULD THE
|
||||
LIBRARY PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
|
||||
REPAIR OR CORRECTION.
|
||||
<p><b>16.</b> IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO
|
||||
IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
|
||||
AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU FOR
|
||||
DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES
|
||||
ARISING OUT OF THE USE OR INABILITY TO USE THE LIBRARY (INCLUDING BUT NOT
|
||||
LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED
|
||||
BY YOU OR THIRD PARTIES OR A FAILURE OF THE LIBRARY TO OPERATE WITH ANY
|
||||
OTHER SOFTWARE), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF
|
||||
THE POSSIBILITY OF SUCH DAMAGES.
|
||||
<h2>
|
||||
END OF TERMS AND CONDITIONS</h2>
|
||||
|
||||
<h2>
|
||||
<a NAME="SEC4" HREF="lgpl.html#TOC4"></a><a href="lgpl.html#TOC4" NAME="SEC4">How
|
||||
to Apply These Terms to Your New Libraries</a></h2>
|
||||
If you develop a new library, and you want it to be of the greatest possible
|
||||
use to the public, we recommend making it free software that everyone can
|
||||
redistribute and change. You can do so by permitting redistribution under
|
||||
these terms (or, alternatively, under the terms of the ordinary General
|
||||
Public License).
|
||||
<p>To apply these terms, attach the following notices to the library. It
|
||||
is safest to attach them to the start of each source file to most effectively
|
||||
convey the exclusion of warranty; and each file should have at least the
|
||||
"copyright" line and a pointer to where the full notice is found.
|
||||
<pre><i>one line to give the library's name and an idea of what it does.
|
||||
</i>Copyright (C) <i>year</i> <i>name of author
|
||||
|
||||
</i>This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with this library; if not, write to the
|
||||
Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
Boston, MA 02111-1307, USA.</pre>
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
<p>You should also get your employer (if you work as a programmer) or your
|
||||
school, if any, to sign a "copyright disclaimer" for the library, if necessary.
|
||||
Here is a sample; alter the names:
|
||||
<pre>Yoyodyne, Inc., hereby disclaims all copyright interest in
|
||||
the library `Frob' (a library for tweaking knobs) written
|
||||
by James Random Hacker.
|
||||
|
||||
<i>signature of Ty Coon</i>, 1 April 1990
|
||||
Ty Coon, President of Vice</pre>
|
||||
That's all there is to it!
|
||||
<hr>Return to <a href="/home.html">GNU's home page</a>.
|
||||
<p>FSF & GNU inquiries & questions to
|
||||
<i><a href="mailto:gnu@gnu.org">gnu@gnu.org</a></i>.
|
||||
Other <a href="/home.html#ContactInfo">ways to contact</a> the FSF.
|
||||
<p>Comments on these web pages to
|
||||
<i><a href="mailto:webmasters@www.gnu.org">webmasters@www.gnu.org</a></i>,
|
||||
send other questions to
|
||||
<i><a href="mailto:gnu@gnu.org">gnu@gnu.org</a></i>.
|
||||
<p>Copyright notice above.
|
||||
<br>Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
|
||||
MA 02111, USA
|
||||
<p>Updated:<!-- hhmts start -->16 Feb 1998 tower<!-- hhmts end -->
|
||||
<hr>
|
||||
</body>
|
||||
</html>
|
Binary file not shown.
Before Width: | Height: | Size: 12 KiB |
|
@ -1,311 +0,0 @@
|
|||
<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
|
||||
<meta name="GENERATOR" content="Mozilla/4.74 [en] (WinNT; U) [Netscape]">
|
||||
<meta name="Author" content="Fred Dushin">
|
||||
<meta name="Keywords" content="JPL,java,prolog">
|
||||
<title>Low-Level Interface</title>
|
||||
</head>
|
||||
<body text="#000000" bgcolor="#FFFFFF" link="#00009C" vlink="#CE31CE" alink="#FF0000">
|
||||
|
||||
<div align=right><a href="index.html">up</a> <a href="getting_started.html">prev</a>
|
||||
|
||||
<a href="high-level_interface.html">next</a> <a href="api/packages.html">API</a>
|
||||
<hr NOSHADE WIDTH="100%"></div>
|
||||
|
||||
<center>
|
||||
<p><br><b><font size=+4>JPL 2.0.2 Low-Level Interface</font></b></center>
|
||||
|
||||
<p><br>
|
||||
<br>
|
||||
<h3>
|
||||
Table of Contents</h3>
|
||||
|
||||
<ul>
|
||||
<li>
|
||||
<a href="#Introduction">Introduction</a></li>
|
||||
|
||||
<li>
|
||||
<a href="#Supported Data Types">Supported Data Types</a></li>
|
||||
|
||||
<li>
|
||||
<a href="#jpl.fli.Prolog">jpl.fli.Prolog</a></li>
|
||||
|
||||
<li>
|
||||
<a href="#Using the Low-Level Interface">Using the Low-Level Interface</a></li>
|
||||
|
||||
<li>
|
||||
<a href="#Caveats">Caveats</a></li>
|
||||
|
||||
<ul>
|
||||
<li>
|
||||
<a href="#Sequential Term References">Sequential Term References</a></li>
|
||||
|
||||
<li>
|
||||
<a href="#Variable-length Argument Lists">Variable-length Argument Lists</a></li>
|
||||
|
||||
<li>
|
||||
<a href="#currently unsupported fli functions">Currently unsupported FLI
|
||||
functions</a></li>
|
||||
|
||||
<li>
|
||||
<a href="#unsupportable fli functions">Unsupportable FLI functions</a></li>
|
||||
</ul>
|
||||
</ul>
|
||||
|
||||
<hr NOSHADE WIDTH="100%">
|
||||
<h3>
|
||||
<a NAME="Introduction"></a>Introduction</h3>
|
||||
<i>[Note: if you just want to build hybrid Java+Prolog applications, you
|
||||
probably don't need to know about this interface: see the <a href="high-level_interface.html">High-Level
|
||||
interface</a> documentation]</i>
|
||||
<br>
|
||||
<br>The <b><i>JPL</i></b> Low-Level interface is implemented by the Java
|
||||
package <b>jpl.fli</b>. This package contains a set of classes that
|
||||
mirror the data types in the SWI-Prolog <i>Foreign Language Interface</i>
|
||||
(FLI), together with a class <b>jpl.fli.Prolog</b>, which contains static
|
||||
variables and static native methods which reflect the constants and functions
|
||||
in the FLI. The package is designed to serve as a direct translation
|
||||
of the Prolog FLI and is generally not intended for the average user.
|
||||
Its main purpose is to support the High-Level interface (q.v.), use of
|
||||
which is preferable in most applications.
|
||||
<p>This section provides a detailed description of the Low-Level interface
|
||||
for the programmer who may wish to use it much as he or she would the FLI.
|
||||
As such, it presumes familiarity with the Prolog FLI. <i>This document
|
||||
is not a tutorial on how to use the Prolog FLI; </i>consult your local
|
||||
Prolog documentation for how to use the FLI. Programmers who wish
|
||||
to use <b><i>JPL</i></b> without having to know any of the nitty gritty
|
||||
details of the Low-Level interface may skip this section and read the <a href="high-level_interface.html">High-Level</a>
|
||||
interface section. For information about the SWI-Prolog FLI, see
|
||||
your local SWI-Prolog documentation.
|
||||
<br>
|
||||
<br>The <b><i>JPL</i></b> Low-Level interface is highly SWI-Prolog specific,
|
||||
unlike the High-Level interface (which could potentially be implemented
|
||||
on top of at least some other Prolog systems).
|
||||
<br>
|
||||
<h3>
|
||||
<a NAME="Supported Data Types"></a>Supported Data Types</h3>
|
||||
The Low-Level interface provides definitions for the following support
|
||||
classes, which are essentially "holder" classes for the corresponding data
|
||||
types in the FLI:
|
||||
<ul>
|
||||
<pre>LongHolder
|
||||
|
|
||||
+--- term_t
|
||||
|
|
||||
+-- atom_t
|
||||
|
|
||||
+-- functor_t
|
||||
|
|
||||
+-- qid_t
|
||||
|
|
||||
+-- fid_t
|
||||
|
||||
PointerHolder
|
||||
|
|
||||
+-- predicate_t
|
||||
|
|
||||
+-- module_t</pre>
|
||||
</ul>
|
||||
With the exception of <b>predicate_t</b> and <b>module_t</b>, these classes
|
||||
hold Java long (signed 64-bit) values, corresponding to the C types in
|
||||
the FLI by the same name (unsigned long values). The <b>module_t</b>
|
||||
and <b>predicate_t</b> classes also hold long values, but their values
|
||||
are understood to be C pointers (void *).
|
||||
<blockquote><i><font size=-1><b>Note. </b> The fact that we are using
|
||||
signed values to represent unsigned values should not be a problem, since
|
||||
we are not using these values in arithmetic expressions that could cause
|
||||
errors as a result of casts. However, any SWI-Prolog implementation
|
||||
that has a word size larger than 4 bytes is not guaranteed to work correctly
|
||||
with this version of the Low-Level interface.</font></i></blockquote>
|
||||
The Low-Level interface also provides the following convenience classes
|
||||
used to get information back to the JavaVM from Prolog:
|
||||
<ul>
|
||||
<li>
|
||||
<b>IntHolder</b></li>
|
||||
|
||||
<li>
|
||||
<b>LongHolder</b></li>
|
||||
|
||||
<li>
|
||||
<b>DoubleHolder</b></li>
|
||||
|
||||
<li>
|
||||
<b>StringHolder</b></li>
|
||||
|
||||
<li>
|
||||
<b>PointerHolder</b></li>
|
||||
</ul>
|
||||
These classes are for use where a SWI-Prolog FLI function takes modifiable
|
||||
(by reference) parameters.
|
||||
<h3>
|
||||
<a NAME="jpl.fli.Prolog"></a>jpl.fli.Prolog</h3>
|
||||
The class <b>jpl.fli.Prolog</b> contains a set of Java constant (static
|
||||
final) and static native method declarations. These declarations
|
||||
more or less mirror those in the header files for the FLI (in SWI-Prolog,
|
||||
<i>SWI-Prolog.h</i>), and can all be found in the C source file <i>jpl_fli_Prolog.c</i>.
|
||||
<p>The general rule of thumb is as follows:
|
||||
<ul>
|
||||
<li>
|
||||
All constant and function names (with a few notable exceptions) are the
|
||||
same as those in the FLI, with the Prolog implementation-specific prefix
|
||||
(in the case of SWI-Prolog, <font face="Courier New,Courier">PL_</font>)
|
||||
removed. For example, the constant <font face="Courier New,Courier">PL_VARIABLE</font>
|
||||
in the FLI becomes just <font face="Courier New,Courier">VARIABLE</font>,
|
||||
and the FLI function <font face="Courier New,Courier">PL_new_term_ref()</font>
|
||||
becomes just <font face="Courier New,Courier">new_term_ref()</font>.
|
||||
A notable exception is the <font face="Courier New,Courier">throw</font>
|
||||
FLI function, which is renamed to <b>_throw</b> in the FLI; <i>throw</i>
|
||||
is a reserved word in Java.</li>
|
||||
|
||||
<li>
|
||||
All the constant values are the same in the Low-Level interface as they
|
||||
are in the FLI.</li>
|
||||
|
||||
<li>
|
||||
The signatures of FLI functions (with a few notable exceptions) are preserved
|
||||
in the Low-Level interface. The Low-Level interface provides the
|
||||
above types for this purpose.</li>
|
||||
|
||||
<li>
|
||||
Read parameters of the primitive Java types (e.g., <b>int</b>, <b>float</b>,
|
||||
<b>long</b>,
|
||||
etc.) are preserved.</li>
|
||||
|
||||
<li>
|
||||
Modify parameters of the primitive Java types take Holder classes (e.g.,
|
||||
<b>IntHolder</b>,
|
||||
<b>DoubleHolder</b>,
|
||||
<b>LongHolder</b>,
|
||||
etc.) in which the values are written, instead of pointers to these types.</li>
|
||||
|
||||
<li>
|
||||
Parameters of other types that are read and read/modify parameters in the
|
||||
FLI still take structures (e.g., <b>jpl.fli.term_t</b>) as arguments in
|
||||
the Low-Level interface. This preserves the signature of these methods
|
||||
as much as possible. A notable exception is the FLI <font face="Courier New,Courier">strip_module</font>
|
||||
function, which takes a <font face="Courier New,Courier">module_t *</font>
|
||||
as a parameter; in the Low-Level interface, the <b>strip_module</b> method
|
||||
takes a <b>module_t</b>, not a Holder for this type.</li>
|
||||
</ul>
|
||||
|
||||
<h3>
|
||||
<a NAME="Using the Low-Level Interface"></a>Using the Low-Level Interface</h3>
|
||||
Programmers already comfortable with the FLI should find no surprises.
|
||||
For example, to create a <b>term_t</b> in Java, one would do the same as
|
||||
one would do in C:
|
||||
<blockquote>
|
||||
<pre>term_t t = Prolog.new_term_ref();</pre>
|
||||
</blockquote>
|
||||
The difference is that the Java method is now a static native method of
|
||||
the Prolog class, so the syntax is slightly different than the corresponding
|
||||
call in C. Moreover, many of the same rules in the FLI apply to the
|
||||
Low-Level interface, as well. To make a term reference which contains
|
||||
an atom, for example, one must first create the <b>term_t</b>, then an
|
||||
<b>atom_t</b>,
|
||||
and then put the atom into the term, as in the FLI:
|
||||
<blockquote>
|
||||
<pre>term_t term = Prolog.new_term_ref();
|
||||
atom_t atom = Prolog.new_atom( "foo" );
|
||||
Prolog.put_atom( term, atom );</pre>
|
||||
</blockquote>
|
||||
|
||||
<h3>
|
||||
<a NAME="Caveats"></a>Caveats</h3>
|
||||
There is nothing special about the Low-Level interface; it is really just
|
||||
a straight Java mapping of the FLI, and C programmers familiar with the
|
||||
FLI should have little difficulty using it. On the other hand, translating
|
||||
the FLI to Java raises some peculiarities that should be mentioned.
|
||||
<h4>
|
||||
<a NAME="Sequential Term References"></a>Sequential Term References</h4>
|
||||
In the FLI, one can create sequential term references via the <font face="Courier New,Courier">new_term_refs</font>
|
||||
function:
|
||||
<blockquote>
|
||||
<pre>term_t t0 = Prolog.new_term_refs( n);</pre>
|
||||
</blockquote>
|
||||
Subsequent references are obtained by <b>t0+1</b>, <b>t0+2</b>, etc.
|
||||
However, Java does not support operator overloading, so we can't obtain
|
||||
subsequent term references by offsetting an initial reference. We
|
||||
can, however, obtain the value field of a <b>term_t</b> structure an compute
|
||||
subsequent references off that value, as in, for example, <b>t0.value+1</b>,
|
||||
<b>t0.value+2</b>,
|
||||
etc.
|
||||
<h4>
|
||||
<a NAME="Variable-length Argument Lists"></a>Variable-length Argument Lists</h4>
|
||||
Some of the C functions in the FLI (e.g, <b>PL_cons_functor()</b>) take
|
||||
variable-length arguments, function definitions whose argument lengths
|
||||
are not known at compile time. However, Java has no support for such
|
||||
definitions; all method definitions must have determinable signatures at
|
||||
compile time.
|
||||
<br>
|
||||
<br>JPL 1.0.1 was designed and implemented before Java acquired <i>anonymous
|
||||
array</i> syntax (in Java 1.1), which make it feasible to redefine a method
|
||||
to take an array of arguments in place of a variable-length argument list.
|
||||
Since the SWI-Prolog FLI provides alternative functions that are equivalent
|
||||
to these variable-length argument functions, <i>JPL 1.0.1</i> implemented
|
||||
these. The High-Level interface exploits anonymous array syntax (e.g.
|
||||
when constructing a <b>Compound</b>), but it has not been considered necessary
|
||||
to revise the implementation of the Low-Level interface.
|
||||
<br>
|
||||
<h4>
|
||||
<a NAME="currently unsupported fli functions"></a>Currently unsupported
|
||||
FLI functions</h4>
|
||||
A number of SWI-Prolog FLI functions are currently unsupported, and not
|
||||
needed by the High-Level interface, but could and might be supported in
|
||||
future versions (preference is likely to be given to those which can sensibly
|
||||
be made available to applications via the High-Level interface, or which
|
||||
are necessary to support future extensions to the High-Level interface).
|
||||
<br>
|
||||
<h4>
|
||||
<a NAME="unsupportable fli functions"></a>Unsupportable FLI functions</h4>
|
||||
Some SWI-Prolog FLI functions seem inherently unsupportable within this
|
||||
interface:
|
||||
<dl>
|
||||
<dl>
|
||||
<dt>
|
||||
<b>PL_signal()</b></dt>
|
||||
|
||||
<dd>
|
||||
Java can't feasibly register a C function as s signal handler<br>
|
||||
<BR></dd>
|
||||
|
||||
<dt>
|
||||
<b>PL_action()</b></dt>
|
||||
|
||||
<dd>
|
||||
problems with the argument types and qty; some of these actions may be
|
||||
useful...<br>
|
||||
<BR></dd>
|
||||
|
||||
<dt>
|
||||
<b>PL_query()</b></dt>
|
||||
|
||||
<dd>
|
||||
the ARGC, ARGV, MAX_INTEGER, MIN_INTEGER options are redundant</dd>
|
||||
|
||||
<dd>
|
||||
QUERY_VERSION might be useful...</dd>
|
||||
|
||||
<dd>
|
||||
SYMBOLFILE ?<br>
|
||||
<BR></dd>
|
||||
|
||||
<dt>
|
||||
<b>PL_dispatch_hook()<br>
|
||||
PL_abort_hook()<br>
|
||||
PL_abort_unhook()<br>
|
||||
PL_on_halt()<br>
|
||||
PL_agc_hook()</b></dt>
|
||||
|
||||
<dd>
|
||||
these are of little value within Java (unless we can install Java methods?!)</dd>
|
||||
</dl>
|
||||
</dl>
|
||||
|
||||
<div align=right>
|
||||
<hr NOSHADE WIDTH="100%"><a href="index.html">up</a> <a href="getting_started.html">prev</a>
|
||||
<a href="high-level_interface.html">next </a> <a href="api/packages.html">API</a></div>
|
||||
|
||||
</body>
|
||||
</html>
|
Binary file not shown.
Before Width: | Height: | Size: 6.0 KiB |
|
@ -1,135 +0,0 @@
|
|||
<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
|
||||
<meta name="GENERATOR" content="Mozilla/4.5 [en] (X11; I; Linux 2.1.24 ppc) [Netscape]">
|
||||
<meta name="Author" content="Fred Dushin">
|
||||
<meta name="Keywords" content="JPL,java,prolog">
|
||||
<title>Programming Notes</title>
|
||||
</head>
|
||||
<body text="#000000" bgcolor="#FFFFFF" link="#00009C" vlink="#CE31CE" alink="#FF0000">
|
||||
|
||||
<div align=right><a href="index.html">up</a> <a href="high-level_interface.html">prev</a>
|
||||
next <a href="api/packages.html">API</a>
|
||||
<hr NOSHADE WIDTH="100%"></div>
|
||||
|
||||
<center>
|
||||
<p><br><b><font size=+4>Programming Notes</font></b></center>
|
||||
|
||||
<p><br>
|
||||
<br>
|
||||
<br>
|
||||
<br>
|
||||
<br>
|
||||
<br>
|
||||
<br>
|
||||
<p>This section provides a description of some of the nitty-gritty involved
|
||||
in getting the high-level interface to work. It presumes <i>extensive</i>
|
||||
familiarity with the High-Level interface, in addition to the Low-Level
|
||||
Interface and the Prolog Foreign Language Interface (FLI).
|
||||
<h3>
|
||||
Overview</h3>
|
||||
The High-Level Interface provides, in essence, a set of Java data structures
|
||||
for invoking queries on a Prolog engine. By itself, the High-Level
|
||||
interface makes no direct calls to the Prolog Abstract Machine (AM).
|
||||
Instead, the High-Level interface rests entirely on top of the Low-LevelInterface,
|
||||
a Java implementation of the FLI. The Low-Level interface is more
|
||||
or less in 1-1 correspondence with the FLI (barring methods that do not
|
||||
make sense in the Java environment).
|
||||
<p>The following describes a typical execution of a Prolog query using
|
||||
the interfaces described in the jpl.Query class. Assume the High-Level
|
||||
Interface programmer (hereafter, just 'the programmer') has constructed
|
||||
a jpl.Term structure (assume, for simplicity, that the programmer is invoking
|
||||
a predicate of arity 1), and is about to use the Query class to make a
|
||||
query using the hasMoreSolutions/nextSolution protocol. Roughly the
|
||||
following sequence of events occurs.
|
||||
<ol>
|
||||
<li>
|
||||
The <b>jpl.Term</b> is converted to a <b>jpl.fli.term_t</b></li>
|
||||
|
||||
<li>
|
||||
A call to the Prolog AM is opened using the Low-Level Interface <b>Prolog.open_query</b>
|
||||
method with the predicate name and <b>term_t</b> just created</li>
|
||||
|
||||
<li>
|
||||
For any <b>jpl.Variable</b> occurrence (i.e., instance) in the original
|
||||
<b>jpl.Term</b>
|
||||
given to the <b>Query</b>, convert the <b>term_t</b>s that are bound to
|
||||
those variables o <b>jpl.Term</b>s, and construct a
|
||||
<b>Hashtable</b> of
|
||||
these <b>Term</b>s, indexed by the <b>Variable</b>s in the <b>Query</b>.</li>
|
||||
|
||||
<li>
|
||||
Close the query using the Low-Level Interface <b>Prolog.close_query</b>
|
||||
method if there are no more solutions. Otherwise, keep the query
|
||||
open for subsequent calls to <b>hasMoreSolutions</b>.</li>
|
||||
</ol>
|
||||
Significantly more bookeeping is required to prevent the programmer from
|
||||
opening a query while another is open, maintaining state about the status
|
||||
of the query, and so forth, but the above gives a rough approximation of
|
||||
what occurs in typical "successful" calls to the Prolog AM. The remainder
|
||||
of this section describes these steps in some detail.
|
||||
<h3>
|
||||
Translating Terms to term_ts</h3>
|
||||
Translating <b>jpl.Term</b>s to <b>jpl.fli.term_t</b>s is relatively straightforward.
|
||||
Each <b>Term</b> subclass knows more or less how to convert itself to a
|
||||
term_t via its <b>pack</b> method, and the top-level <b>Term</b> static
|
||||
method <b>terms_to_term_ts </b>takes an array of <b>Term</b>s and performs
|
||||
the conversion for the <b>Query</b>. The following features of the
|
||||
FLI, however, help explain the perhaps mysterious signature of <b>pack</b>.
|
||||
<ul>
|
||||
<li>
|
||||
The Prolog FLI requires that <i>term_t</i> references first be created,
|
||||
and then data of an appropriate type be "put" into the <i>term_t </i>reference
|
||||
using one of the FLI <i>_put</i> functions. For example, to create
|
||||
an atom in the FLI, one first creates a <i>term_t,</i> and then "puts"
|
||||
an <i>atom_t </i>into the <i>term_t.</i></li>
|
||||
|
||||
<p><br><font face="Courier New,Courier"><font size=+1>
|
||||
term_t t = PL_new_term_ref();</font></font>
|
||||
<br><font face="Courier New,Courier"><font size=+1> atom_t
|
||||
a = PL_new_atom( "a" );</font></font>
|
||||
<br><font face="Courier New,Courier"><font size=+1> PL_put_atom(
|
||||
t, a );</font></font>
|
||||
<p>Translating a Term to a term_t requires mimicking this behavior.
|
||||
<li>
|
||||
In the case of Compound Terms,</li>
|
||||
|
||||
<li>
|
||||
A <i>term_t</i> in the Prolog FLI is, literally, an unsigned long value.
|
||||
It is essentially an index into the Prolog AM. A sequence of <i>term_t</i>s
|
||||
is a set of <i>consecutive</i> long values, typically created via the FLI
|
||||
C funtion <i>PL_new_term_refs().</i> In order to construct a compound
|
||||
<i>term_t,</i> in the FLI, one must create such a sequence of <i>term_t</i>s
|
||||
(as many as the arity of the compound), and then use the various FLI <i>_put
|
||||
</i>functions to put terms into the term_ts that have just been created.</li>
|
||||
|
||||
<br> </ul>
|
||||
|
||||
<h3>
|
||||
Computing Substitutions</h3>
|
||||
|
||||
<p><br>Translating term_ts to Terms
|
||||
<h3>
|
||||
Terms</h3>
|
||||
A <b>jpl.Term</b> structure holds, as an element, a <b>jpl.fli.term_t</b>
|
||||
structure, which itself is a class which holds a long value. This
|
||||
long value is in fact a pointer (though not a C pointer) to Prolog term
|
||||
in the Prolog Abstract Machine (AM). Unfortunately, these low-level
|
||||
values are not really valid throughout the life of the jpl.Term.
|
||||
Indeed, they are only valid pointers into the Prolog AM <i>during the execution
|
||||
of a Prolog query. </i>They must, therefore, be treated with exceptional
|
||||
caution, and are consequently kept well-hidden from the user of the High-Level
|
||||
Interface.
|
||||
<br>
|
||||
<br>
|
||||
<br>
|
||||
<br>
|
||||
<div align=right>
|
||||
<hr NOSHADE WIDTH="100%"><a href="index.html">up</a>
|
||||
<a href="high-level_interface.html">prev</a>
|
||||
next
|
||||
<a href="api/packages.html">API</a></div>
|
||||
|
||||
</body>
|
||||
</html>
|
|
@ -1,42 +0,0 @@
|
|||
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
||||
<html>
|
||||
<head>
|
||||
<title>JPL 3.x objectives</title>
|
||||
<meta name="author" content="Paul Singleton">
|
||||
</head>
|
||||
<body>
|
||||
<h1><span style="font-style: italic;">JPL 3.x</span> Objectives</h1>
|
||||
<hr style="width: 100%; height: 2px;">
|
||||
<ul>
|
||||
<li>enable Prolog applications to exploit <span
|
||||
style="font-style: italic;">any </span>Java classes, instances,
|
||||
methods etc. (without requiring any wrappers, metadata etc. to be set
|
||||
up first)</li>
|
||||
<li>enable Java applications to manipulate <span
|
||||
style="font-style: italic;">any </span>Standard Prolog libraries,
|
||||
predicates, etc. (without requiring any wrappers, metadata etc. to be
|
||||
set up first)</li>
|
||||
<li>enable hybrid Prolog+Java applications to be designed and
|
||||
implemented so as to take best advantage of both language systems, and
|
||||
to be testable, debuggable, maintainable etc.</li>
|
||||
<li>minimum <span style="font-style: italic;">impact </span>deployability:
|
||||
runtime support for Prolog+Java apps must be a position-independent,
|
||||
self-sufficient filestore tree, requiring no changes to registries,
|
||||
system libraries, system configuration files etc.<br>
|
||||
</li>
|
||||
<li>minimum <span style="font-style: italic;">dependency </span>deployability:
|
||||
as with JVMs, the Prolog+Java runtime support must depend upon nothing
|
||||
which cannot be taken for granted in healthy OS installations</li>
|
||||
<li>minimum <span style="font-style: italic;">vulnerability </span>deployability:
|
||||
the Prolog+Java runtime support must be immune to legitimate variations
|
||||
in its environment (PATH settings, other applications and libraries
|
||||
including other Prolog+Java apps, etc.)</li>
|
||||
<li><span style="font-style: italic;">(to be developed...)</span><br>
|
||||
</li>
|
||||
</ul>
|
||||
<hr style="width: 100%; height: 2px;">
|
||||
<address><a href="mailto:paul.singleton@bcs.org.uk">Paul Singleton</a></address>
|
||||
<address>drafted 19th February 2004</address>
|
||||
<br>
|
||||
</body>
|
||||
</html>
|
|
@ -1,382 +0,0 @@
|
|||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="CONTENT-TYPE"
|
||||
content="text/html; charset=windows-1252">
|
||||
<title>api</title>
|
||||
<meta name="GENERATOR" content="StarOffice 7 (Win32)">
|
||||
<meta name="AUTHOR" content="Paul Singleton">
|
||||
<meta name="CREATED" content="20040218;18025294">
|
||||
<meta name="CHANGED" content="16010101;0">
|
||||
<style>
|
||||
<!--
|
||||
@page { size: 21cm 29.7cm }
|
||||
-->
|
||||
</style>
|
||||
</head>
|
||||
<body lang="en-US" dir="ltr">
|
||||
<h1><span style="font-style: italic;">JPL 3.x</span> Prolog API
|
||||
reference</h1>
|
||||
<hr style="width: 100%; height: 2px;">
|
||||
<dl>
|
||||
<dt> <a name="jpl_new/3"></a><b>jpl_new</b>( <var>+ClassOrType,
|
||||
+Params, -Result</var>) </dt>
|
||||
<dd> unifies <i>Result</i> with a <span
|
||||
style="font-weight: bold; font-style: italic;">JPL</span> reference to
|
||||
a new instance of <var>ClassOrType</var>, constructed with <var>Params</var>,
|
||||
e.g. <code>jpl_new('javax.swing.JFrame', ['JPL demo'], F)</code>.
|
||||
There are many other ways to call this predicate: see <a
|
||||
href="overview/index.html">BlahBlah</a>.<br>
|
||||
<br>
|
||||
</dd>
|
||||
<dt><a name="jpl_call/4"></a><b>jpl_call</b>( <i>+Object,
|
||||
+Method, +Params, -Result</i>) </dt>
|
||||
<dd> unifies <i>Result</i> with a <span
|
||||
style="font-weight: bold; font-style: italic;">JPL</span> reference to
|
||||
(or value of) the result of calling the named method of <var>Object</var>
|
||||
with <var>Params</var>, e.g. <code>jpl_call(F, setVisible, [@(true)],
|
||||
_)</code>. There are many other ways to call this predicate: see <a
|
||||
href="file:///D:/jpl/doc/prolog_calls_java/overview/index.html">BlahBlah</a>.<br>
|
||||
<br>
|
||||
</dd>
|
||||
<dt><a name="jpl_get/3"></a><b>jpl_get</b>( <i>+Object,
|
||||
+Field, -Value</i>) </dt>
|
||||
<dd> unifies <i>Value</i> to the value of, or a reference to, the
|
||||
named field of Object. There are many other ways to call this
|
||||
predicate: see <a href="overview/index.html">BlahBlah</a>..<br>
|
||||
<br>
|
||||
</dd>
|
||||
<dt><a name="jpl_get/3"></a><b>jpl_set</b>( <i>+Object,
|
||||
+Field, +Value</i>) </dt>
|
||||
<dd>sets the named field of <var>Object</var> to <var>Value</var>
|
||||
(a <span style="font-weight: bold; font-style: italic;">JPL</span>
|
||||
reference or value). There are many other ways to call this
|
||||
predicate: see <a href="overview/index.html">BlahBlah</a>..<br>
|
||||
<br>
|
||||
</dd>
|
||||
</dl>
|
||||
<h2><br>
|
||||
Java inspection</h2>
|
||||
<dl>
|
||||
<dt><a name="jpl_class_to_classname"></a><b>jpl_class_to_classname</b>(
|
||||
<var>+Class, -Classname</var>) </dt>
|
||||
<dd><var>Class</var> must be a <span
|
||||
style="font-weight: bold; font-style: italic;">JPL</span> reference to
|
||||
a Java class object (i.e. an instance of <span
|
||||
style="font-style: italic;">java.lang.Class</span>); <var>Classname</var>
|
||||
is its canonical dotted name, e.g. <code>'java.util.Date'</code>.<br>
|
||||
</dd>
|
||||
<dt><a name="jpl_class_to_type"></a><b>jpl_class_to_type</b>( <var>+Class,
|
||||
-Type)</var></dt>
|
||||
<dd><var>Class</var> must be a <span
|
||||
style="font-weight: bold; font-style: italic;">JPL</span> reference to
|
||||
a Java class object (i.e. an instance of <span
|
||||
style="font-style: italic;">java.lang.Class</span>); <var>Type</var>
|
||||
is its <span style="font-weight: bold; font-style: italic;">JPL</span>
|
||||
type, e.g. <code>class([java,util],['Date'])</code>
|
||||
or <code>array(double)</code>.<br>
|
||||
</dd>
|
||||
<dt><a name="jpl_classname_to_class"></a><b>jpl_classname_to_class</b>(
|
||||
<var>+Classname, -Class</var>)</dt>
|
||||
<dd><var> Classname</var> must be a canonical dotted name (an atom)
|
||||
of a
|
||||
Java class, e.g. <code>'java.util.Date'</code>; <var>Class</var> is a
|
||||
<span style="font-weight: bold; font-style: italic;">JPL</span>
|
||||
reference to a corresponding Java class object (i.e. an instance of
|
||||
java.lang.Class).<br>
|
||||
</dd>
|
||||
<dt><a name="jpl_classname_to_type"></a><b>jpl_classname_to_type</b>(
|
||||
<var>+Classname, -Type</var>)</dt>
|
||||
<dd><var> Classname</var> must be a canonical dotted name (an atom)
|
||||
of a Java class, e.g. <code>'java.util.Date'</code>; <var>Type</var>
|
||||
is its <span style="font-weight: bold; font-style: italic;">JPL</span>
|
||||
type, e.g. <code>class([java,util],['Date'])</code>.<br>
|
||||
</dd>
|
||||
<dt><a name="jpl_datum_to_type"></a><b>jpl_datum_to_type</b>( <var>+Datum,
|
||||
-Type</var>)</dt>
|
||||
<dd><var>Datum</var> must be a valid <span
|
||||
style="font-weight: bold; font-style: italic;">JPL</span>
|
||||
representation of some Java object or value e.g. <code>3</code>, <code>fred</code>,
|
||||
<code>@(false)</code>; <var>Type</var> is its <span
|
||||
style="font-weight: bold; font-style: italic;">JPL</span> type, e.g. <code>char_byte</code>,
|
||||
<code>class([java,lang],['String'])</code>, <code>boolean</code>.<br>
|
||||
</dd>
|
||||
<dt><a name="jpl_false"></a><b>jpl_false</b>( <var>-Datum</var>)</dt>
|
||||
<dd><var>Datum</var> is the <span
|
||||
style="font-weight: bold; font-style: italic;">JPL</span>
|
||||
representation of the Java boolean value <span
|
||||
style="font-style: italic;">false</span>, i.e. <code>@(false)</code>.<br>
|
||||
</dd>
|
||||
<dt><a name="jpl_is_class"></a><b>jpl_is_class</b>( <var>?Term</var>)
|
||||
</dt>
|
||||
<dd><var>Term</var> is a <span
|
||||
style="font-weight: bold; font-style: italic;">JPL</span> reference to
|
||||
a Java class object, i.e. to an instance of <span
|
||||
style="font-style: italic;">java.lang.Class</span>. No further
|
||||
instantiation of <var>Term</var> will take place; if it is not ground,
|
||||
this predicate fails.<br>
|
||||
</dd>
|
||||
<dt><a name="jpl_is_false"></a><b>jpl_is_false</b>( <var>?Term</var>)
|
||||
</dt>
|
||||
<dd><var>Term</var> is the <span
|
||||
style="font-weight: bold; font-style: italic;">JPL</span>
|
||||
representation of the Java boolean value <span
|
||||
style="font-style: italic;">false</span>. No further instantiation of <var>Term</var>
|
||||
will take place; if it is not ground, this predicate fails.<br>
|
||||
</dd>
|
||||
<dt><a name="jpl_is_null"></a><b>jpl_is_null</b>( <var>?Term</var>) </dt>
|
||||
<dd><var>Term</var> is a <span
|
||||
style="font-style: italic; font-weight: bold;">JPL</span>
|
||||
representation of the Java boolean value <span
|
||||
style="font-style: italic;">null</span>. No further instantiation of <var>Term</var>
|
||||
will take place; if it is not ground, this predicate fails.<br>
|
||||
</dd>
|
||||
<dt><a name="jpl_is_object"></a><b>jpl_is_object</b>( <var>?Term</var>)
|
||||
</dt>
|
||||
<dd><var>Term</var> is a <span
|
||||
style="font-weight: bold; font-style: italic;">JPL</span> reference to
|
||||
a Java object. No further instantiation of <var>Term</var> will take
|
||||
place; if it is not ground, this predicate fails.<br>
|
||||
</dd>
|
||||
<dt><a name="jpl_is_object_type"></a><b>jpl_is_object_type</b>( <var>?Term</var>)
|
||||
</dt>
|
||||
<dd><var>Term</var> is a <span
|
||||
style="font-weight: bold; font-style: italic;">JPL</span> class or
|
||||
array type (but not <code>null</code>, <code>void</code>, or one of
|
||||
the primitive types). No further instantiation of <var>Term</var>
|
||||
will take place; if it is not ground, this predicate fails.<br>
|
||||
<br>
|
||||
</dd>
|
||||
<dt> <a name="jpl_is_ref"></a><b>jpl_is_ref</b>( <var>?Term</var>)
|
||||
</dt>
|
||||
<dd><var>Term</var> is a <span
|
||||
style="font-weight: bold; font-style: italic;">JPL</span> class or
|
||||
array type, or is <code>null</code> (i.e. the <span
|
||||
style="font-weight: bold; font-style: italic;">JPL</span> type of
|
||||
Java's null reference) (but not <code>void</code> or one of the
|
||||
primitive types). No further instantiation of <var>Term</var>
|
||||
will take place; if it is not ground, this predicate fails.<br>
|
||||
<br>
|
||||
</dd>
|
||||
<dt> <a name="jpl_is_true"></a><b>jpl_is_true</b>( <var>?Term</var>)
|
||||
</dt>
|
||||
<dd><var>Term</var> is the <span
|
||||
style="font-weight: bold; font-style: italic;">JP</span>L
|
||||
representation of the Java boolean value <span
|
||||
style="font-style: italic;">true</span>. No further
|
||||
instantiation of <var>Term</var> will take place; if it is not ground,
|
||||
this predicate fails.<br>
|
||||
</dd>
|
||||
<dt><a name="jpl_is_type"></a><b>jpl_is_type</b>( <var>?Term</var>) </dt>
|
||||
<dd><var>Term</var> is a <span
|
||||
style="font-weight: bold; font-style: italic;">JPL</span> type, e.g. <code>char_byte</code>,
|
||||
<code>float</code>, <code>array(int)</code>. No further
|
||||
instantiation of <var>Term</var> will take place; if it not ground,
|
||||
this predicate fails.<br>
|
||||
</dd>
|
||||
<dt><a name="jpl_is_void"></a><b>jpl_is_void</b>( <var>?Term</var>) </dt>
|
||||
<dd><var>Term</var> is the <span
|
||||
style="font-weight: bold; font-style: italic;">JPL</span>
|
||||
representation of the (notional but convenient) Java value <span
|
||||
style="font-style: italic;">void</span>, i.e. <code>@(void)</code>.
|
||||
No further instantiation of <var>Term</var> will take place; if it not
|
||||
ground, this predicate fails.<br>
|
||||
</dd>
|
||||
<dt><a name="jpl_null"></a><b>jpl_null</b>( <var>-Datum</var>) </dt>
|
||||
<dd><var>Datum</var> is the <span
|
||||
style="font-weight: bold; font-style: italic;">JPL</span>
|
||||
representation of the Java null reference <span
|
||||
style="font-style: italic;">null</span>.<br>
|
||||
</dd>
|
||||
<dt><a name="jpl_object_to_class"></a><b>jpl_object_to_class</b>( <var>+Object,
|
||||
-Class</var>) </dt>
|
||||
<dd><var>Object</var> is a <span
|
||||
style="font-weight: bold; font-style: italic;">JPL</span> reference to
|
||||
a Java object; <var>Class</var> is a <span
|
||||
style="font-weight: bold; font-style: italic;">JPL</span> reference to
|
||||
a Java class object (an instance of <span style="font-style: italic;">java.lang.Class</span>)
|
||||
which represents <var>Object</var>'s class.<br>
|
||||
</dd>
|
||||
<dt><a name="jpl_object_to_type"></a><b>jpl_object_to_type</b>( <var>+Object,
|
||||
-Type</var>) </dt>
|
||||
<dd><var>Object</var> is a <span
|
||||
style="font-weight: bold; font-style: italic;">JPL</span> reference to
|
||||
a Java object; <var>Type</var> is its <span
|
||||
style="font-weight: bold; font-style: italic;">JPL</span> type, e.g. <code>array(boolean)</code>,
|
||||
<code>class([javax,sql],['Timestamp'])</code>.<br>
|
||||
</dd>
|
||||
<dt><a name="jpl_primitive_type"></a><b>jpl_primitive_type</b>( <var>-Type</var>)
|
||||
</dt>
|
||||
<dd><var>Type</var> is one of the <span
|
||||
style="font-weight: bold; font-style: italic;">JPL</span> primitive
|
||||
types <code>boolean</code>, <code>char</code>, <code>byte</code>, <code>short</code>,
|
||||
<code>int</code>, <code>long</code>, <code>float</code>, <code>double</code>.<br>
|
||||
</dd>
|
||||
<dt><a name="jpl_ref_to_type"></a><b>jpl_ref_to_type</b>( <var>+Ref,
|
||||
-Type</var>) </dt>
|
||||
<dd><var>Ref</var> is a <span
|
||||
style="font-weight: bold; font-style: italic;">JPL</span> reference to
|
||||
a Java object; <var>Typ</var>e is the <span
|
||||
style="font-weight: bold; font-style: italic;">JPL</span> type of <var>Object</var>,
|
||||
e.g. <code>array(boolean)</code>, <code>class([javax,sql],['Timestamp'])</code>.<br>
|
||||
</dd>
|
||||
<dt><a name="jpl_true"></a><b>jpl_true</b>( <var>-Datum</var>) </dt>
|
||||
<dd><var>Datum</var> is the <span
|
||||
style="font-weight: bold; font-style: italic;">JPL</span>
|
||||
representation of the Java boolean value <span
|
||||
style="font-style: italic;">true</span>.<br>
|
||||
</dd>
|
||||
<dt><a name="jpl_type_to_class"></a><b>jpl_type_to_class</b>( <var>+Type,
|
||||
-Class</var>) </dt>
|
||||
<dd><var>Type</var> is a <span
|
||||
style="font-weight: bold; font-style: italic;">JPL</span> class (or
|
||||
array) type, e.g. <code>class([javax,sql],['Timestamp'])</code> or <code>array(boolean)</code>;
|
||||
<var>Class</var> is a <span
|
||||
style="font-weight: bold; font-style: italic;">JPL</span> reference to
|
||||
a Java class object (an instance of <span style="font-style: italic;">java.lang.Class</span>)
|
||||
which corresponds to <var>Type</var>.<br>
|
||||
</dd>
|
||||
<dt><a name="jpl_type_to_classname"></a><b>jpl_type_to_classname</b>(
|
||||
<var>+Type, -Classname</var>) </dt>
|
||||
<dd><var>Type</var> is a <span
|
||||
style="font-weight: bold; font-style: italic;">JPL</span> class (or
|
||||
array) type, e.g. <code>class([javax,sql],['Timestamp'])</code> or <code>array(boolean)</code>;
|
||||
<var>Classname</var> is its canonical dotted name (an atom).<br>
|
||||
<br>
|
||||
</dd>
|
||||
<dt> <a name="jpl_void"></a><b>jpl_void</b>( <var>-Datum</var>)
|
||||
</dt>
|
||||
<dd><var>Datum</var> is the <span
|
||||
style="font-weight: bold; font-style: italic;">JPL</span>
|
||||
representation of the (notional but convenient) Java value <span
|
||||
style="font-style: italic;">void</span>, i.e. <code>@(void)</code>.<br>
|
||||
</dd>
|
||||
</dl>
|
||||
<h2><br>
|
||||
Utilities</h2>
|
||||
<dl>
|
||||
<dt> <a name="jpl_array_to_length"></a><b>jpl_array_to_length</b>(
|
||||
<var>+Array,
|
||||
-Length</var>) </dt>
|
||||
<dd><var>Array</var> is a <span
|
||||
style="font-weight: bold; font-style: italic;">JPL</span> reference to
|
||||
a Java array; <var>Length</var> is its length (an integer).<br>
|
||||
<br>
|
||||
</dd>
|
||||
<dt> <a name="jpl_array_to_list"></a><b>jpl_array_to_list</b>( <var>+Array,
|
||||
-ListOfDatums</var>) </dt>
|
||||
<dd><var>Array</var> is a <span
|
||||
style="font-weight: bold; font-style: italic;">JPL</span> reference to
|
||||
a Java array (of any base type); <var>ListOfDatums</var> is a (Prolog)
|
||||
list of <span style="font-weight: bold; font-style: italic;">JPL</span>
|
||||
references to, or values of, its respective elements.<br>
|
||||
</dd>
|
||||
<dt><a name="jpl_datums_to_array"></a><b>jpl_datums_to_array</b>( <var>+ListOfDatums,
|
||||
-Array</var>) </dt>
|
||||
<dd><var> ListOfDatums</var> is a (Prolog) list of <span
|
||||
style="font-weight: bold; font-style: italic;">JPL</span> references
|
||||
or values; <var>Array</var> is a <span
|
||||
style="font-weight: bold; font-style: italic;">JPL</span> reference to
|
||||
a Java array of corresponding objects or values. The base type of
|
||||
<var>Array</var> is the most specific Java type of which each
|
||||
member of<var> ListOfDatums</var> is (directly or indirectly) an
|
||||
instance. If there is no such type, this predicate fails. Values of
|
||||
Java primitive types are not automatically "boxed". Lists which are
|
||||
mixtures of numbers, booleans and object references cannot be converted
|
||||
to Java arrays with this predicate.<br>
|
||||
<br>
|
||||
</dd>
|
||||
<dt> <a name="jpl_enumeration_element"></a><b>jpl_enumeration_element</b>(
|
||||
<var>+Enumeration, -Element</var>) </dt>
|
||||
<dd> <var>Enumeration</var> is a <span
|
||||
style="font-weight: bold; font-style: italic;">JPL</span> reference to
|
||||
a Java object whose class implements the <span
|
||||
style="font-style: italic;">java.util.Enumeration</span> interface; <var>Element</var>
|
||||
is an element of <var>Enumeration</var>. This predicate can
|
||||
generate each element of an enumeration.<br>
|
||||
<br>
|
||||
</dd>
|
||||
<dt> <a name="jpl_enumeration_to_list"></a><b>jpl_enumeration_to_list</b>(
|
||||
<var>+Enumeration, -ListOfElement</var>) </dt>
|
||||
<dd><var>Enumeration</var> is a <span
|
||||
style="font-weight: bold; font-style: italic;">JPL</span> reference to
|
||||
a Java object whose class implements the <span
|
||||
style="font-style: italic;">java.util.Enumeration</span>
|
||||
interface; <var>ListOfElement</var> is a list of <span
|
||||
style="font-weight: bold; font-style: italic;">JPL</span> references
|
||||
to each element of <var>Enumeration</var>.<br>
|
||||
<br>
|
||||
</dd>
|
||||
<dt> <a name="jpl_hashtable_pair"></a><b>jpl_hashtable_pair</b>(
|
||||
<var>+Hashtable,
|
||||
-KeyValuePair</var>) </dt>
|
||||
<dd><var>Hashtable</var> is a <span
|
||||
style="font-weight: bold; font-style: italic;">JPL</span> reference to
|
||||
a Java hashtable object (an instance of <span
|
||||
style="font-style: italic;">java.util.Hashtable</span>); <var>KeyValuePair</var>
|
||||
is a <code>-/2</code> compound term whose first arg is a key (atom or
|
||||
ref) from <var>Hashtable</var>, and whose second arg is its
|
||||
corresponding value (atom or ref), e.g.<code>fred-@'J#0008127852'</code>.<br>
|
||||
</dd>
|
||||
<dt><a name="jpl_iterator_element"></a><b>jpl_iterator_element</b>( <var>+Iterator,
|
||||
-Element</var>) </dt>
|
||||
<dd><var>Iterator</var> is a <span
|
||||
style="font-weight: bold; font-style: italic;">JPL</span> reference to
|
||||
a Java object whose class implements the <span
|
||||
style="font-style: italic;">java.util.Iterator interface</span>; <var>Element</var>
|
||||
is a <span style="font-weight: bold; font-style: italic;">JPL</span>
|
||||
reference to one of its elements. This predicate can generate all
|
||||
elements.<br>
|
||||
</dd>
|
||||
<dt><a name="jpl_list_to_array"></a><b>jpl_list_to_array</b>( <var>+ListOfDatum,
|
||||
-Array</var>) </dt>
|
||||
<dd>This is a synonym for <a href="#jpl_datums_to_array"><span
|
||||
style="font-weight: bold;">jpl_datums_to_array/2</span></a>, in case
|
||||
you forget that <span style="font-weight: bold; font-style: italic;">JPL</span>
|
||||
values and references are called "datums".<br>
|
||||
</dd>
|
||||
<dt><a name="jpl_map_element"></a><b>jpl_map_element</b>( <var>+Map,
|
||||
-KeyValuePair</var>) </dt>
|
||||
<dd><var>Map</var> is a <span
|
||||
style="font-weight: bold; font-style: italic;">JPL</span> reference to
|
||||
a Java object whose class implements the <span
|
||||
style="font-style: italic;">java.util.Map</span> interface; <var>KeyValuePair</var>
|
||||
is a <code>-/2</code> compound term whose first arg is a key (atom or
|
||||
ref) from <var>Map</var>, and whose second arg is its corresponding
|
||||
value (atom or ref), e.g.<code> -(fred,@'J#0008127852'</code>), or <code>fred-@'J#0008127852'</code>
|
||||
using conventional operator definitions.<br>
|
||||
</dd>
|
||||
<dt><a name="jpl_set_element"></a><b>jpl_set_element</b>( <var>+Set,
|
||||
-Element</var>) </dt>
|
||||
<dd><var>Set</var> is a <span
|
||||
style="font-weight: bold; font-style: italic;">JPL</span> reference to
|
||||
a Java object whose class implements the <span
|
||||
style="font-style: italic;">java.util.Set</span> interface; <var>Element</var>
|
||||
is a <span style="font-weight: bold; font-style: italic;">JPL</span>
|
||||
reference to an object (or null) within <var>Set</var>. This
|
||||
predicate can generate all elements of <var>Set</var></dd>
|
||||
</dl>
|
||||
<h2><br>
|
||||
Miscellaneous</h2>
|
||||
<dl>
|
||||
<dt><a name="jpl_c_lib_version/1"></a><b>jpl_c_lib_version</b>( <i>-Version</i>)
|
||||
</dt>
|
||||
<dd> unifies <i>Version</i> to an atom (e.g. <tt>'3.0.1-alpha'</tt>)
|
||||
whose name is the version identifier of the 'C' library which JPL is
|
||||
using.<br>
|
||||
<br>
|
||||
</dd>
|
||||
<dt> <a name="jpl_c_lib_version/4"></a><b>jpl_c_lib_version</b>( <i>-Major</i>,
|
||||
<i>-Minor</i>, <i>-Patch</i>, <i>-Status</i>) </dt>
|
||||
<dd> unifies <i>Major</i>, <i>Minor</i>, <i>Patch</i> and <i>Status</i>
|
||||
to the corresponding components (e.g. <tt>3</tt>, <tt>0</tt>, <tt>1</tt>
|
||||
and <tt>alpha</tt>) of the version identifier of the 'C' library which
|
||||
JPL is using.<br>
|
||||
</dd>
|
||||
</dl>
|
||||
<hr style="width: 100%; height: 2px;">
|
||||
<address><a href="mailto:paul.singleton@bcs.org.uk">Paul Singleton</a></address>
|
||||
<address>drafted 18th February 2004<br>
|
||||
</address>
|
||||
</body>
|
||||
</html>
|
|
@ -1,40 +0,0 @@
|
|||
<!DOCTYPE html PUBLIC "-//w3c//dtd html 4.0 transitional//en">
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type"
|
||||
content="text/html; charset=iso-8859-1">
|
||||
<meta name="GENERATOR"
|
||||
content="Mozilla/4.74 [en] (WinNT; U) [Netscape]">
|
||||
<title>JPL 3.x Prolog-calls-Java gotchas</title>
|
||||
</head>
|
||||
<body>
|
||||
<h1><span style="font-style: italic;">
|
||||
JPL 3.x</span> Prolog API gotchas
|
||||
</h1>
|
||||
<hr width="100%">
|
||||
<h2>calling methods with no parameters
|
||||
</h2>
|
||||
<blockquote>you must pass an empty parameter list when calling Java
|
||||
methods which take no parameters, e.g.<br>
|
||||
<pre style="margin-left: 40px;">jpl_call('java.lang.System', gc, [], _)<br></pre>
|
||||
</blockquote>
|
||||
<h2>calling void methods
|
||||
</h2>
|
||||
<blockquote>you must accept an @(void) result when calling void Java
|
||||
methods, e.g. either<br>
|
||||
<pre style="margin-left: 40px;">jpl_call('java.lang.System', gc, [], @(void))</pre>
|
||||
which explicitly matches the expected result, or<br>
|
||||
<pre style="margin-left: 40px;">jpl_call('java.lang.System', gc, [], _)</pre>
|
||||
which uses an anonymous variable to ignore the result.<br>
|
||||
</blockquote>
|
||||
<h2><span style="font-style: italic;">(more to come...)</span><br>
|
||||
</h2>
|
||||
<blockquote></blockquote>
|
||||
<hr style="width: 100%; height: 2px;">
|
||||
<address><a href="mailto:p.singleton@keele.ac.uk">Paul Singleton</a></address>
|
||||
<address>
|
||||
drafted Wednesday 4th February 2004<br>
|
||||
<br>
|
||||
</address>
|
||||
</body>
|
||||
</html>
|
|
@ -1,973 +0,0 @@
|
|||
<!DOCTYPE doctype PUBLIC "-//w3c//dtd html 4.0 transitional//en">
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type"
|
||||
content="text/html; charset=iso-8859-1">
|
||||
<meta name="Author" content="Paul Singleton">
|
||||
<meta name="GENERATOR"
|
||||
content="Mozilla/4.74 [en] (WinNT; U) [Netscape]">
|
||||
<title>A SWI-Prolog to Java interface</title>
|
||||
</head>
|
||||
<body>
|
||||
<h1><span style="font-style: italic;"> JPL 3.x</span> Prolog API
|
||||
overview</h1>
|
||||
<hr style="width: 100%; height: 2px;">
|
||||
<ul>
|
||||
<li><a href="#Introduction">Introduction</a></li>
|
||||
<li><a href="#JPL_types_Java_types_as_seen_by">JPL types (Java types,
|
||||
as seen by Prolog)</a><a href="#Java_types_as_seen_by_Prolog"></a></li>
|
||||
<li><a href="#representation_of_Java_values...">representation of
|
||||
Java values and references within Prolog</a></li>
|
||||
<li><a href="#repn_of_Java_types_1_structured">representation of Java
|
||||
types within Prolog (1): <i>structured</i> notation</a></li>
|
||||
<li><a href="#repn_of_Java_types_2_descriptor">representation of Java
|
||||
types within Prolog (2): <i>descriptor</i> notation</a></li>
|
||||
<li><a href="#repn_of_Java_types_3_classname">representation of Java
|
||||
types within Prolog (3): classname notation</a></li>
|
||||
<li><a href="#creating_instances_of_Java_classes">creating instances
|
||||
of Java classes</a></li>
|
||||
<li><a href="#calling_methods_of_Java_objects_...">calling methods of
|
||||
Java objects or classes</a></li>
|
||||
<li><a href="#fetching_field_values_of_Java_objects...">fetching
|
||||
field values of Java objects or classes</a></li>
|
||||
<li><a href="#setting_field_values_of_Java_objects...">setting field
|
||||
values of Java objects or classes</a></li>
|
||||
<li><a href="#a_slightly_longer_example">a slightly longer example</a></li>
|
||||
<li><a href="#jpl_new3">jpl_new/3</a></li>
|
||||
<li><a href="#jpl_call4">jpl_call/4</a></li>
|
||||
<li><a href="#jpl_set3">jpl_set/3</a></li>
|
||||
<li><a href="#jpl_get3">jpl_get/3</a></li>
|
||||
<li><a href="#exceptions">exceptions thrown by Java</a></li>
|
||||
<li><a href="#testing">testing</a></li>
|
||||
<li><a href="#to_do">to do</a><br>
|
||||
</li>
|
||||
</ul>
|
||||
<hr width="100%">
|
||||
<h2><font face="Arial,Helvetica"><a name="Introduction"></a>Introduction</font></h2>
|
||||
<font face="Arial,Helvetica">This is an overview of
|
||||
an interface which allows SWI-Prolog programs to dynamically create and
|
||||
manipulate Java objects.</font>
|
||||
<p><font face="Arial,Helvetica">Here are some significant features of
|
||||
the interface and its implementation:</font> </p>
|
||||
<ul>
|
||||
</ul>
|
||||
<ul>
|
||||
<li><font face="Arial,Helvetica">it is completely dynamic: no
|
||||
precompilation is required to manipulate any Java classes which can be
|
||||
found at run time, and any objects which can be instantiated from them<br>
|
||||
</font></li>
|
||||
</ul>
|
||||
<font face="Arial,Helvetica"></font>
|
||||
<ul>
|
||||
<li><font face="Arial,Helvetica">it is interoperable with <span
|
||||
style="font-weight: bold; font-style: italic;">JPL</span>'s Java API
|
||||
(which has evolved from Fred Dushin's <span style="font-style: italic;">JPL
|
||||
1.0.1</span>)</font></li>
|
||||
</ul>
|
||||
<font face="Arial,Helvetica"></font>
|
||||
<ul>
|
||||
<li><font face="Arial,Helvetica">it requires a Java 2 JVM and class
|
||||
libraries (although it doesn't depend on any Java 2-specific
|
||||
facilities, and originally was developed for use with both 1.1 and 1.2
|
||||
JVMs, I haven't tested it with 1.1 recently, and don't support this)</font></li>
|
||||
</ul>
|
||||
<ul>
|
||||
<li> <font face="Arial,Helvetica">it exploits the <i>Invocation API</i>
|
||||
of the <i>Java Native Interface</i>: this is a mandatory feature of
|
||||
any compliant
|
||||
JVM (even the now defunct "Microsoft Virtual Machine" supported JNI,
|
||||
although they seemed to want to keep that a secret :-)</font></li>
|
||||
</ul>
|
||||
<ul>
|
||||
<li> <font face="Arial,Helvetica">it is implemented with a fair
|
||||
amount of
|
||||
Prolog code in one module (<span style="font-style: italic;">jpl.pl</span>)
|
||||
(which I believe to be ISO Standard Prolog compliant
|
||||
and portable) and a SWI-Prolog-specific foreign library (<span
|
||||
style="font-style: italic;">jpl.dll</span> for Windows), implemented
|
||||
in ANSI C but making a lot of use of the SWI-Prolog <i>Foreign
|
||||
Language Interface</i></font></li>
|
||||
</ul>
|
||||
<ul>
|
||||
<li> <font face="Arial,Helvetica">the foreign-language part has so
|
||||
far been tested only under Windows NT4, but is believed to be readily
|
||||
portable to SWI-Prolog
|
||||
on other platforms</font></li>
|
||||
</ul>
|
||||
<ul>
|
||||
<li> <font face="Arial,Helvetica">as far as is feasible, Java data
|
||||
values and
|
||||
object references are represented within Prolog canonically and without
|
||||
loss
|
||||
of information (minor exceptions: Java <span
|
||||
style="font-style: italic;">float </span>and <span
|
||||
style="font-style: italic;">double</span> values are both converted to
|
||||
Prolog <span style="font-style: italic;">float </span>values; Java <span
|
||||
style="font-style: italic;">byte</span>, <span
|
||||
style="font-style: italic;">char</span>, <span
|
||||
style="font-style: italic;">short</span>, <span
|
||||
style="font-style: italic;">int</span> and <span
|
||||
style="font-style: italic;">long</span> values are all converted to
|
||||
Prolog <span style="font-style: italic;">integer</span> values; the
|
||||
type distinctions which are lost are normally of no significance)<br>
|
||||
</font></li>
|
||||
</ul>
|
||||
<ul>
|
||||
<li> <font face="Arial,Helvetica">references within Prolog to Java
|
||||
objects:</font></li>
|
||||
<ul>
|
||||
<li> <font face="Arial,Helvetica">should be treated as opaque
|
||||
handles</font></li>
|
||||
<li> <font face="Arial,Helvetica">are canonical (two references
|
||||
are ==/2
|
||||
equal if-and-only-if they refer to the <span
|
||||
style="font-style: italic;">same
|
||||
object</span> within the JVM)</font></li>
|
||||
<li> <font face="Arial,Helvetica">are represented as structures
|
||||
containing
|
||||
a distinctive atom so as to exploit SWI-Prolog's atom garbage
|
||||
collection: when an object reference is garbage-collected in Prolog,
|
||||
the JVM garbage collector
|
||||
is informed, so there is sound and complete overall garbage collection
|
||||
of
|
||||
Java objects within the combined Prolog+Java system</font></li>
|
||||
</ul>
|
||||
</ul>
|
||||
<ul>
|
||||
<li> <font face="Arial,Helvetica">Java class methods can be called
|
||||
by name: <i style="font-weight: bold;">JPL</i> invisibly fetches (and
|
||||
caches) essential
|
||||
details of method invocation, exploiting <i>Java Reflection</i>
|
||||
facilities</font></li>
|
||||
</ul>
|
||||
<ul>
|
||||
<li> <font face="Arial,Helvetica">the API is similar to that of
|
||||
XPCE: the
|
||||
four main interface calls are <i>jsp_new</i>, </font><font
|
||||
face="Arial,Helvetica"><i>jsp_call, </i></font><font
|
||||
face="Arial,Helvetica"><i>jsp_set</i> and </font><font
|
||||
face="Arial,Helvetica"><i>jsp_get</i> (there is no <i>jsp_free</i>,
|
||||
since Java's garbage collection
|
||||
is extended transparently into Prolog)</font></li>
|
||||
</ul>
|
||||
<ul>
|
||||
<li> <font face="Arial,Helvetica"><i>jsp_call</i> resolves
|
||||
overloaded methods automatically and dynamically, inferring the types
|
||||
of the call's actual parameters,
|
||||
and identifying the most specific of the applicable method
|
||||
implementations
|
||||
(similarly, <i>jsp_new</i> resolves overloaded constructors)</font></li>
|
||||
</ul>
|
||||
<ul>
|
||||
<li> <font face="Arial,Helvetica">Prolog code which uses the API
|
||||
calls is
|
||||
responsible for passing suitably-typed values and references, since the
|
||||
JNI
|
||||
doesn't perform complete dynamic type-checking, and nor currently does <span
|
||||
style="font-weight: bold; font-style: italic;">JPL</span> (although
|
||||
the <i>overloaded method resolution</i> mechanism could probably be
|
||||
adapted to do this)</font></li>
|
||||
</ul>
|
||||
<ul>
|
||||
<li> <font face="Arial,Helvetica">Prolog code can reason about the
|
||||
types
|
||||
of Java data values, object references, fields and methods: <span
|
||||
style="font-weight: bold; font-style: italic;">JPL</span> supports a
|
||||
canonical
|
||||
representation of all Java types as structured terms (e.g. </font><b><tt>array(array(byte))</tt></b><font
|
||||
face="Arial,Helvetica">) and also as atomic JVM signatures</font></li>
|
||||
</ul>
|
||||
<ul>
|
||||
<li> <font face="Arial,Helvetica">the Prolog-calls-Java (mine) and
|
||||
Java-calls-Prolog (Fred's) parts of <span
|
||||
style="font-weight: bold; font-style: italic;">JPL</span>
|
||||
are largely independent; mine concentrates on representing all Java
|
||||
data
|
||||
values and objects within Prolog, and supporting manipulation of
|
||||
objects;
|
||||
Fred's concentrates on representing any Prolog term within Java, and
|
||||
supporting
|
||||
the calling of goals within Prolog and the retrieving of results back
|
||||
into
|
||||
Java</font></li>
|
||||
</ul>
|
||||
<ul style="font-family: helvetica,arial,sans-serif;">
|
||||
<li>when called from Prolog, <span style="font-style: italic;">void</span>
|
||||
methods return a <span style="font-style: italic;">void</span> value
|
||||
(which is distinct from all other <span
|
||||
style="font-weight: bold; font-style: italic;">JPL</span> values and
|
||||
references)</li>
|
||||
</ul>
|
||||
<ul>
|
||||
<li><font face="Arial,Helvetica">it uses </font><b><tt><font
|
||||
size="+1">@/1</font></tt></b><font face="Arial,Helvetica"> to
|
||||
construct representations of certain Java values; if </font><b><tt><font
|
||||
size="+1">@/1</font></tt></b><font face="Arial,Helvetica"> is defined
|
||||
as a
|
||||
prefix operator (as used by XPCE), then you can write </font><b><tt><font
|
||||
size="+1">@false</font></tt></b><font face="Arial,Helvetica">, </font><b><tt><font
|
||||
size="+1">@true</font></tt></b><font face="Arial,Helvetica">, </font><b><tt><font
|
||||
size="+1">@null</font></tt></b><font face="Arial,Helvetica"> etc. in
|
||||
your
|
||||
source code; </font><font face="Arial,Helvetica">otherwise (and for
|
||||
portability) you'll have to write e.g. </font><b><tt><font size="+1">@(true)</font></tt></b><font
|
||||
face="Arial,Helvetica"> etc.</font></li>
|
||||
</ul>
|
||||
<hr width="100%">
|
||||
<h2><a name="JPL_types_Java_types_as_seen_by"></a>JPL types (Java
|
||||
types, as seen by Prolog)</h2>
|
||||
<blockquote><font face="Arial,Helvetica">All Java values and object
|
||||
references which are passed between Prolog engines and Java VMs via <span
|
||||
style="font-weight: bold; font-style: italic;">JPL</span>'s Prolog API
|
||||
are seen as instances of types within this simplified <span
|
||||
style="font-weight: bold; font-style: italic;">JPL</span> type system:<br>
|
||||
<br>
|
||||
a <b><i>datum</i></b> (this term is introduced, out of
|
||||
necessity, to refer jointly to <span style="font-style: italic;">values
|
||||
</span>and <span style="font-style: italic;">refs</span>)</font>
|
||||
<blockquote><font face="Arial,Helvetica">is a <b><i>value</i></b>
|
||||
(values are copied between Prolog and the JVM)</font></blockquote>
|
||||
</blockquote>
|
||||
<blockquote>
|
||||
<blockquote>
|
||||
<blockquote><font face="Arial,Helvetica">is a <b><i>boolean</i></b></font></blockquote>
|
||||
</blockquote>
|
||||
</blockquote>
|
||||
<blockquote>
|
||||
<blockquote>
|
||||
<blockquote><font face="Arial,Helvetica">or a <b><i>char</i></b></font></blockquote>
|
||||
</blockquote>
|
||||
</blockquote>
|
||||
<blockquote>
|
||||
<blockquote>
|
||||
<blockquote><font face="Arial,Helvetica">or a <b><i>long</i></b>, <b><i>int</i></b>,
|
||||
<b><i>short</i></b> or <b><i>byte</i></b></font></blockquote>
|
||||
</blockquote>
|
||||
</blockquote>
|
||||
<blockquote>
|
||||
<blockquote>
|
||||
<blockquote><font face="Arial,Helvetica">or a <b><i>double</i></b>
|
||||
or <b><i>float</i></b></font></blockquote>
|
||||
</blockquote>
|
||||
</blockquote>
|
||||
<blockquote>
|
||||
<blockquote>
|
||||
<blockquote><font face="Arial,Helvetica">or a <b><i>string</i></b>
|
||||
(an instance of <span style="font-style: italic;">java.lang.String</span>)</font></blockquote>
|
||||
</blockquote>
|
||||
</blockquote>
|
||||
<blockquote>
|
||||
<blockquote>
|
||||
<blockquote><font face="Arial,Helvetica">or a <b><i>void</i></b>
|
||||
(an artificial value returned by calls to Java void methods)</font></blockquote>
|
||||
<font face="Arial,Helvetica">or a <b><i>ref</i></b></font>
|
||||
<blockquote><font face="Arial,Helvetica">is <b><i>null</i></b></font></blockquote>
|
||||
</blockquote>
|
||||
</blockquote>
|
||||
<blockquote>
|
||||
<blockquote>
|
||||
<blockquote><font face="Arial,Helvetica">or an <b><i>object</i></b>
|
||||
(held within the JVM, and represented in Prolog by a canonical
|
||||
reference)</font>
|
||||
<blockquote><font face="Arial,Helvetica">is an <b><i>array</i></b></font></blockquote>
|
||||
</blockquote>
|
||||
</blockquote>
|
||||
</blockquote>
|
||||
<blockquote>
|
||||
<blockquote>
|
||||
<blockquote>
|
||||
<blockquote><font face="Arial,Helvetica">or a <b><i>class
|
||||
instance</i></b> (other than of <span style="font-style: italic;">java.lang.String</span>)<b><i><br>
|
||||
</i></b></font></blockquote>
|
||||
</blockquote>
|
||||
</blockquote>
|
||||
</blockquote>
|
||||
<hr width="100%">
|
||||
<h2><a name="representation_of_Java_values..."></a> representation of
|
||||
Java values and references within Prolog</h2>
|
||||
<span style="font-family: helvetica,arial,sans-serif;">Instances of <span
|
||||
style="font-weight: bold; font-style: italic;">JPL</span> types are
|
||||
represented within Prolog as follows:</span><br
|
||||
style="font-family: helvetica,arial,sans-serif;">
|
||||
<blockquote><font face="Arial,Helvetica"><b><i>boolean</i></b> has two
|
||||
values,
|
||||
represented by </font><b><tt><font size="+1">@(true)</font></tt></b><font
|
||||
face="Arial,Helvetica"> and </font><b><tt><font size="+1">@(false)</font></tt></b>
|
||||
<p><font face="Arial,Helvetica"><b><i>char</i></b> values are
|
||||
represented by corresponding Prolog <i>integers</i></font> </p>
|
||||
<p><font face="Arial,Helvetica"><b><i>int</i></b>, <b><i>short</i></b>
|
||||
and <b><i>byte</i></b> values are represented by corresponding Prolog <i>integers</i></font>
|
||||
</p>
|
||||
<p><font face="Arial,Helvetica"><b><i>long</i></b> values are
|
||||
represented as Prolog <i>integers</i> if possible (32-bit in current
|
||||
SWI-Prolog), else as </font><b><tt><font size="+1">jlong(Hi,Lo)</font></tt></b><font
|
||||
face="Arial,Helvetica"> where </font><b><tt><font size="+1">Hi</font></tt></b><font
|
||||
face="Arial,Helvetica"> is an <i>integer</i> corresponding to the
|
||||
top32
|
||||
bits of the long, and </font><b><tt><font size="+1">Lo</font></tt></b><font
|
||||
face="Arial,Helvetica"> similarly represents the lower 32 bits</font> </p>
|
||||
<p><font face="Arial,Helvetica"><b><i>double</i></b> and <b><i>float</i></b>
|
||||
values are represented as Prolog floats (which are equivalent to Java
|
||||
doubles) (there may be minor rounding, normalisation or
|
||||
loss-of-precision issues when
|
||||
a Java float is widened to a Prolog float then narrowed back again, but
|
||||
what
|
||||
the heck)</font> </p>
|
||||
<p><font face="Arial,Helvetica"><b><i>string</i></b> values
|
||||
(immutable instances
|
||||
of <span style="font-style: italic;">java.lang.Stri</span>ng) are
|
||||
represented as Prolog <i>atoms</i> (in UTF-8 encoding)</font> </p>
|
||||
<p><font face="Arial,Helvetica"><b><i>null</i></b> has only one
|
||||
value, represented
|
||||
as </font><b><tt><font size="+1">@(null)</font></tt></b> </p>
|
||||
<p><font face="Arial,Helvetica"><b><i>void</i></b> has only one
|
||||
value, represented
|
||||
as </font><b><tt><font size="+1">@(void)</font></tt></b> </p>
|
||||
<p><font face="Arial,Helvetica"><b><i>array</i></b> and <b><i>class
|
||||
instance</i></b> references are currently represented as </font><b><tt><font
|
||||
size="+1">@(Tag)</font></tt></b><font face="Arial,Helvetica">, where
|
||||
Tag ia an <i>atom</i> whose name encodes
|
||||
a JNI global reference value; this may change, but won't affect Prolog
|
||||
programs
|
||||
which respect the opacity of references</font></p>
|
||||
</blockquote>
|
||||
<hr width="100%">
|
||||
<h2><a name="repn_of_Java_types_1_structured"></a> representation of
|
||||
Java types within Prolog (1): <i>structured</i> notation</h2>
|
||||
<font face="Arial,Helvetica">The <span
|
||||
style="font-weight: bold; font-style: italic;">JPL Prolog API</span>
|
||||
allows Prolog
|
||||
applications to inspect, manipulate, and reason about the types of Java
|
||||
values, references,
|
||||
methods etc., and this section describes how these types themselves (as
|
||||
opposed to instances thereof) are represented. Predicates which
|
||||
pass these type representations include </font><b><a
|
||||
href="api.html#jpl_class_to_type/2">jpl_class_to_type/2</a>, </b><b><a
|
||||
href="api.html#jpl_classname_to_type/2">jpl_classname_to_type/2</a>,
|
||||
</b><b><a href="api.html#jpl_datum_to_type/2">jpl_datum_to_type/2</a>,
|
||||
</b><b><a href="api.html#jpl_is_object_type/1">jpl_is_object_type/1</a>,
|
||||
</b><b><a href="api.html#jpl_is_type/1">jpl_is_type/1</a>, </b><a
|
||||
href="api.html#jpl_object_to_type/2" style="font-weight: bold;">jpl_object_to_type/2</a><b>,
|
||||
</b><b><a href="api.html#jpl_primitive_type/1">jpl_primitive_type/1</a>,
|
||||
</b><b><a href="api.html#jpl_ref_to_type/2">jpl_ref_to_type/2</a>, </b><b><a
|
||||
href="api.html#jpl_type_to_class/2">jpl_type_to_class/2</a>. </b><b><a
|
||||
href="api.html#jpl_type_to_classname/2">jpl_type_to_classname/2</a>.</b>
|
||||
<blockquote><font face="Arial,Helvetica"><b><i>void</i></b> is
|
||||
represented as </font><b><tt><font size="+1">void</font></tt></b></blockquote>
|
||||
<blockquote><font face="Arial,Helvetica"><b><i>null</i></b> is
|
||||
represented as </font><b><tt><font size="+1">null</font></tt></b></blockquote>
|
||||
<blockquote><font face="Arial,Helvetica">the primitive types are
|
||||
represented as </font><b><tt><font size="+1">boolean</font></tt></b><font
|
||||
face="Arial,Helvetica">, </font><b><tt><font size="+1">char</font></tt></b><font
|
||||
face="Arial,Helvetica">, </font><b><tt><font size="+1">byte</font></tt></b><font
|
||||
face="Arial,Helvetica">, </font><b><tt><font size="+1">short</font></tt></b><font
|
||||
face="Arial,Helvetica">, </font><b><tt><font size="+1">int</font></tt></b><font
|
||||
face="Arial,Helvetica">, </font><b><tt><font size="+1">long</font></tt></b><font
|
||||
face="Arial,Helvetica">, </font><b><tt><font size="+1">float</font></tt></b><font
|
||||
face="Arial,Helvetica">, </font><b><tt><font size="+1">double</font></tt></b></blockquote>
|
||||
<blockquote><font face="Arial,Helvetica"><b><i>classes</i></b> are
|
||||
represented as </font><b><tt><font size="+1">class(</font></tt></b><i><font
|
||||
face="Arial,Helvetica">package_parts</font></i><b><tt><font size="+1">,</font></tt></b><i><font
|
||||
face="Arial,Helvetica">classname_parts</font></i><b><tt><font size="+1">)</font></tt></b>
|
||||
<blockquote><font face="Arial,Helvetica">e.g. </font><b><tt><font
|
||||
size="+1">class([java,util],['Date'])</font></tt></b></blockquote>
|
||||
<font face="Arial,Helvetica"><b><i>array</i></b> types are
|
||||
represented as </font><b><tt><font size="+1">array(</font></tt></b><i><font
|
||||
face="Arial,Helvetica">type</font></i><b><tt><font size="+1">)</font></tt></b>
|
||||
<blockquote>e.g. <b><tt><font size="+1">array(boolean)</font></tt></b></blockquote>
|
||||
</blockquote>
|
||||
<blockquote>
|
||||
<blockquote>e.g. <b><tt><font size="+1">array(class([java,lang],['String'])<br>
|
||||
</font></tt></b></blockquote>
|
||||
</blockquote>
|
||||
<span style="font-family: helvetica,arial,sans-serif;">This <span
|
||||
style="font-style: italic;">structured </span>notation for Java types
|
||||
is designed to be convenient for composition and decomposition by
|
||||
matching (unification).</span><br>
|
||||
<hr width="100%" style="font-family: helvetica,arial,sans-serif;">
|
||||
<h2><a name="repn_of_Java_types_2_descriptor"></a> representation of
|
||||
Java types within Prolog (2): <i>descriptor</i> notation</h2>
|
||||
<font face="Arial,Helvetica">The <i>descriptor</i> notation for Java
|
||||
types is one of two textual notations employed by the JVM and the Java
|
||||
class libraries; <span style="font-weight: bold; font-style: italic;">JPL</span>
|
||||
(necessarily)
|
||||
supports both (and supports conversion between all three
|
||||
representations).</font>
|
||||
<p><font face="Arial,Helvetica">Examples:</font> </p>
|
||||
<blockquote><b><tt><font size="+1">'Z'</font></tt></b><font
|
||||
face="Arial,Helvetica"> denotes <b><i>boolean</i></b></font>
|
||||
<p><b><tt><font size="+1">'B'</font></tt></b><font
|
||||
face="Arial,Helvetica"> denotes <b><i>byte</i></b></font> </p>
|
||||
<p><b><tt><font size="+1">'C'</font></tt></b><font
|
||||
face="Arial,Helvetica"> denotes <b><i>char</i></b></font> </p>
|
||||
<p><b><tt><font size="+1">'S'</font></tt></b><font
|
||||
face="Arial,Helvetica"> denotes <b><i>short</i></b></font> </p>
|
||||
<p><b><tt><font size="+1">'I'</font></tt></b><font
|
||||
face="Arial,Helvetica"> denotes <b><i>int</i></b></font> </p>
|
||||
<p><b><tt><font size="+1">'J'</font></tt></b><font
|
||||
face="Arial,Helvetica"> denotes <b><i>long</i></b></font> </p>
|
||||
<p><b><tt><font size="+1">'F'</font></tt></b><font
|
||||
face="Arial,Helvetica"> denotes <b><i>float</i></b></font> </p>
|
||||
<p><b><tt><font size="+1">'D'</font></tt></b><font
|
||||
face="Arial,Helvetica"> denotes <b><i>double</i></b></font> </p>
|
||||
<p><b><tt><font size="+1">'Ljava/util/Date;'</font></tt></b><font
|
||||
face="Arial,Helvetica"> (for example) deno<span
|
||||
style="font-family: helvetica,arial,sans-serif;">tes the Jav</span>a
|
||||
clas<span style="font-family: helvetica,arial,sans-serif;">s </span></font><span
|
||||
style="font-family: helvetica,arial,sans-serif; font-style: italic;">java.util.Date</span>
|
||||
</p>
|
||||
<p><b><tt><font size="+1">'[</font></tt></b><i><font
|
||||
face="Arial,Helvetica">type</font></i><b><tt><font size="+1">'</font></tt></b><font
|
||||
face="Arial,Helvetica"> denotes an <b><i>array</i></b> of <i>type</i></font>
|
||||
</p>
|
||||
<p><b><tt><font size="+1">'(</font></tt></b><i><font
|
||||
face="Arial,Helvetica">argument_types</font></i><b><tt><font size="+1">)</font></tt></b><i><font
|
||||
face="Arial,Helvetica">return_type</font></i><b><tt><font size="+1">'</font></tt></b><font
|
||||
face="Arial,Helvetica"> denotes the type of a method</font></p>
|
||||
</blockquote>
|
||||
<hr width="100%">
|
||||
<h2><a name="repn_of_Java_types_3_classname"></a> representation of
|
||||
Java types within Prolog (3): <i>classname</i> notation</h2>
|
||||
<font face="Arial,Helvetica">The <i>classname</i> notation for Java
|
||||
types is the other textual notation employed by the JVM and the Java
|
||||
class libraries. It is a (seemingly unnecessary) variation on the
|
||||
<i>descriptor</i> notation, used by a few JNI routines. It has
|
||||
the slight advantage that, in the
|
||||
case of simple class types only, it resembles the Java source text
|
||||
notation for classes. This representation is supported only
|
||||
because certain JNI functions use it; it is used within <span
|
||||
style="font-weight: bold; font-style: italic;">JPL</span>'s
|
||||
implementation of <span style="font-weight: bold;">jpl_call/4</span>
|
||||
etc. You may encounter this notation when tracing <span
|
||||
style="font-weight: bold; font-style: italic;">JPL</span> activity,
|
||||
but otherwise you need not know about it.</font>
|
||||
<p><font face="Arial,Helvetica">Examples:</font> </p>
|
||||
<blockquote><b><tt><font size="+1">'java.util.Vector'</font></tt></b><font
|
||||
face="Arial,Helvetica"> denotes the Java class </font><tt><font
|
||||
size="+1">java.util.Vector</font></tt></blockquote>
|
||||
<blockquote><b><tt><font size="+1">'[B'</font></tt></b><font
|
||||
face="Arial,Helvetica"> denotes an <b><i>array</i></b> of <b><i>boolean</i></b></font></blockquote>
|
||||
<blockquote><b><tt><font size="+1">'[Ljava.lang.String;'</font></tt></b><font
|
||||
face="Arial,Helvetica"> denotes an <b><i>array</i></b> of <b><i>string</i></b></font></blockquote>
|
||||
<hr width="100%">
|
||||
<h1>Using the <span style="font-style: italic;">JPL 3.x</span> Prolog
|
||||
API<br>
|
||||
</h1>
|
||||
<h2><a name="creating_instances_of_Java_classes"></a> creating
|
||||
instances of Java classes</h2>
|
||||
<font face="Arial,Helvetica">To create an instance of a Java class from
|
||||
within Prolog,
|
||||
call <b>jpl_new(+Class,+Params,-Ref)</b> with a classname, a list of
|
||||
actual parameters for the
|
||||
constructor, and a variable to be bound to the new reference, e.g.</font>
|
||||
<blockquote><b><tt><font size="+1">jpl_new( 'javax.swing.JFrame',
|
||||
['frame with dialog'], F)</font></tt></b></blockquote>
|
||||
<font face="Arial,Helvetica">which binds <b>F</b> to a new object
|
||||
reference, e.g.</font>
|
||||
<blockquote><font face="Arial,Helvetica"> </font><b><tt><font
|
||||
size="+1">@('J#0008272420')</font></tt></b></blockquote>
|
||||
<font face="Arial,Helvetica">(not that the details of this structure
|
||||
are of any necessary concern to the Prolog programmer or to the
|
||||
applications she
|
||||
writes).<br>
|
||||
NB for convenience, this predicate is overloaded: <span
|
||||
style="font-weight: bold;">Class</span> can also be a class type in <span
|
||||
style="font-style: italic;">structured </span>notation, e.g. <code>array(boolean)</code>.<br>
|
||||
</font>
|
||||
<p> </p>
|
||||
<hr width="100%">
|
||||
<h2><a name="calling_methods_of_Java_objects_..."></a> calling methods
|
||||
of Java objects or classes</h2>
|
||||
<font face="Arial,Helvetica">The object reference generated by the <b>jpl_new/3</b>
|
||||
call (above) can be passed to other <span
|
||||
style="font-weight: bold; font-style: italic;">JPL</span> API
|
||||
predicates such as <br>
|
||||
</font>
|
||||
<blockquote><b><tt><font size="+1">jpl_call( +Ref, +Method, +Params,
|
||||
-Result)</font></tt></b></blockquote>
|
||||
<font face="Arial,Helvetica">e.g.</font>
|
||||
<blockquote><b><tt><font size="+1">jpl_call( F, setVisible, [@(true)],
|
||||
_)</font></tt></b></blockquote>
|
||||
<font face="Arial,Helvetica">which calls the <b>setVisible</b> method
|
||||
of the object to which <b>F</b> refers, effectively passing it the
|
||||
Java value <span style="font-style: italic;">true.</span></font>
|
||||
<p><font face="Arial,Helvetica">(This call should display the new <b>JFrame</b>
|
||||
in the top left corner of the desktop.)</font> </p>
|
||||
<p><font face="Arial,Helvetica">Note the anonymous variable passed as
|
||||
the fourth argument to <b>jsp_call/4. </b> A variable in this
|
||||
position receives
|
||||
the result of the method call: either a value or a reference.
|
||||
Since
|
||||
</font><b><tt><font size="+1">SetVisible()</font></tt></b><font
|
||||
face="Arial,Helvetica"> is a void method, the call returns the
|
||||
(artificial)
|
||||
reference </font><b><tt><font size="+1">@(void)</font></tt></b><font
|
||||
face="Arial,Helvetica">.</font> </p>
|
||||
<p><font face="Arial,Helvetica">Some may prefer to code this call thus:</font>
|
||||
</p>
|
||||
<blockquote><b><tt><font size="+1">jpl_call( F, setVisible, [@true],
|
||||
@void)</font></tt></b></blockquote>
|
||||
<font face="Arial,Helvetica">which documents the programmer's
|
||||
understanding that this is a <span style="font-style: italic;">void </span>method
|
||||
(and fails if it isn't :-).</font><font face="Arial,Helvetica"><br>
|
||||
</font> <br>
|
||||
<font face="Arial,Helvetica">If the <span
|
||||
style="font-family: helvetica,arial,sans-serif; font-weight: bold;">+Ref</span>
|
||||
argument represents a class, then the named static method of that
|
||||
class is called.</font>
|
||||
<p> </p>
|
||||
<hr width="100%">
|
||||
<h2><a name="fetching_field_values_of_Java_objects..."></a> fetching
|
||||
field values of Java objects or classes</h2>
|
||||
<font face="Arial,Helvetica">The <b>jpl_get/3</b> API predicate can
|
||||
retrieve the value of an instance field or a static field, e.g.</font>
|
||||
<blockquote><b><tt><font size="+1">jpl_get( 'java.awt.Color', pink,
|
||||
Pink)</font></tt></b></blockquote>
|
||||
<font face="Arial,Helvetica">which binds the Prolog variable </font><b><tt><font
|
||||
size="+1">Pink</font></tt></b><font face="Arial,Helvetica"> to a
|
||||
reference to the predefined <b>java.awt.Color</b>
|
||||
"constant" which is held in the static final <b>.pink</b> field of the
|
||||
<b>java.awt.Color</b>
|
||||
class.</font>
|
||||
<p><font face="Arial,Helvetica">More generally, <b>jpl_get/3</b> has
|
||||
the following
|
||||
interface:</font> </p>
|
||||
<blockquote><b><tt><font size="+1">jpl_get( +Class_or_Object, +Field,
|
||||
-Datum)</font></tt></b></blockquote>
|
||||
<font face="Arial,Helvetica">If the first argument represents a class,
|
||||
then
|
||||
a static field of that class with FieldName is accessed.</font>
|
||||
<p> </p>
|
||||
<hr width="100%">
|
||||
<h2><a name="setting_field_values_of_Java_objects..."></a> setting
|
||||
field values of Java objects or classes</h2>
|
||||
<font face="Arial,Helvetica">Object and class fields can be set (i.e.
|
||||
have values or references assigned to them) by the <b>jpl_set/3</b>
|
||||
API procedure, which has the following interface:</font>
|
||||
<blockquote><b><tt><font size="+1">jpl_set( +Class_or_Object, +Field,
|
||||
+Datum)</font></tt></b></blockquote>
|
||||
<font face="Arial,Helvetica">where <b>Datum</b> must be a value or
|
||||
reference of a type suitable for assignment to the named field of the
|
||||
class or object.</font>
|
||||
<p> </p>
|
||||
<hr width="100%">
|
||||
<h2><a name="a_slightly_longer_example"></a> a slightly longer example</h2>
|
||||
<font face="Arial,Helvetica">This code fragment</font>
|
||||
<pre><b><tt><font size="+1"> findall(<br> Ar,<br> ( current_prolog_flag( N, V),<br> term_to_atom( V, Va),<br> jpl_new( '[Ljava.lang.String;', [N,Va], Ar)<br> ),<br> Ars<br> ),<br> jpl_new( '[[Ljava.lang.String;', Ars, Ac),<br> jpl_datums_to_array( [name,value], Ah),<br> jpl_new( 'javax.swing.JFrame', ['current_prolog_flag'], F),<br> jpl_call( F, getContentPane, [], CP),<br> jpl_new( 'javax.swing.JTable', [Ac,Ah], T),<br> jpl_new( 'javax.swing.JScrollPane', [T], SP),<br> jpl_call( CP, add, [SP,'Center'], _),<br> jpl_call( F, setSize, [600,400], _),</font></tt></b></pre>
|
||||
<font face="Arial,Helvetica">builds an array of arrays of strings
|
||||
containing the names and values of the current SWI-Prolog "flags", and
|
||||
displays it in
|
||||
a JTable within a ScrollPane within a JFrame:</font>
|
||||
<blockquote><img src="screendump.jpg" height="269" width="524"></blockquote>
|
||||
<font face="Arial,Helvetica">In addition to <span
|
||||
style="font-weight: bold; font-style: italic;">JPL</span> API calls,
|
||||
this
|
||||
code calls <b>jpl_datums_to_array/2</b>, a utility which converts any
|
||||
list
|
||||
of valid representations of Java values (or objects) into a new Java
|
||||
array,
|
||||
whose base type is the most specialised type of which all list members
|
||||
are
|
||||
instances, and which is defined thus:</font>
|
||||
<blockquote>
|
||||
<pre><b><tt><font size="+1">jpl_datums_to_array( Ds, A) :-<br> ground( Ds),<br> jpl_datums_to_most_specific_common_ancestor_type( Ds, T),<br> jpl_new( array(T), Ds, A).</font></tt></b></pre>
|
||||
</blockquote>
|
||||
<font face="Arial,Helvetica">Having found the "most specific common
|
||||
ancestor type" (my phrase :-), a new array of this type is created,
|
||||
whose elements are initialised to the successive members of the list of
|
||||
datums.</font>
|
||||
<p><font face="Arial,Helvetica">This illustrates another mode of
|
||||
operation of <b>jpl_new/3</b>:</font> </p>
|
||||
<blockquote><b><tt><font size="+1">jpl_new( +ArrayType, +InitialValues,
|
||||
-ArrayRef)</font></tt></b></blockquote>
|
||||
<font face="Arial,Helvetica">See the relevant Appendix for fuller
|
||||
details of the API procedures.</font>
|
||||
<p><font face="Arial,Helvetica">Don't forget the possibility of writing
|
||||
and
|
||||
manipulating new Java classes to serve your Prolog applications: this
|
||||
interface
|
||||
is not designed to make Java programming redundant :-)</font> </p>
|
||||
<p> </p>
|
||||
<hr width="100%"> <br>
|
||||
<b><tt><font size="+2"><a name="jpl_new3"></a>jpl_new( +X, +Argz, -V) :-</font></tt></b>
|
||||
<blockquote><b><tt><font size="+1">X</font></tt></b><font
|
||||
face="Arial,Helvetica"> can be:</font>
|
||||
<ul>
|
||||
<li> <font face="Arial,Helvetica">a suitable <i>type</i></font></li>
|
||||
<ul>
|
||||
<li> <font face="Arial,Helvetica">i.e. any </font><b><tt><font
|
||||
size="+1">class(_,_)</font></tt></b><font face="Arial,Helvetica">, </font><b><tt><font
|
||||
size="+1">array(_)</font></tt></b><font face="Arial,Helvetica"> or
|
||||
primitive
|
||||
type (e.g. </font><b><tt><font size="+1">byte</font></tt></b><font
|
||||
face="Arial,Helvetica"> but not </font><b><tt><font size="+1">void</font></tt></b><font
|
||||
face="Arial,Helvetica">)</font></li>
|
||||
</ul>
|
||||
<li> <font face="Arial,Helvetica">an atomic <i>classname</i></font></li>
|
||||
<ul>
|
||||
<li> <font face="Arial,Helvetica">e.g. </font><b><tt><font
|
||||
size="+1">'java.lang.String'</font></tt></b></li>
|
||||
<li> <font face="Arial,Helvetica">e.g. </font><b><tt><font
|
||||
size="+1">'Ljava.lang.String;'</font></tt></b><font
|
||||
face="Arial,Helvetica"> (a redundant but legitimate form)</font></li>
|
||||
</ul>
|
||||
<li> <font face="Arial,Helvetica">an atomic <i>descriptor</i></font></li>
|
||||
<ul>
|
||||
<li> <font face="Arial,Helvetica">e.g. </font><b><tt><font
|
||||
size="+1">'[I'</font></tt></b></li>
|
||||
</ul>
|
||||
<li> <font face="Arial,Helvetica">a class object</font></li>
|
||||
<ul>
|
||||
<li> <font face="Arial,Helvetica">i.e. an object whose type
|
||||
is </font><b><tt><font size="+1">class([java,lang],['Class'])</font></tt></b></li>
|
||||
</ul>
|
||||
</ul>
|
||||
</blockquote>
|
||||
<blockquote><font face="Arial,Helvetica">if </font><b><tt><font
|
||||
size="+1">X</font></tt></b><font face="Arial,Helvetica"> denotes a
|
||||
primitive
|
||||
type and </font><b><tt><font size="+1">Argz</font></tt></b><font
|
||||
face="Arial,Helvetica"> is castable to a value of that type, then </font><b><tt><font
|
||||
size="+1">V</font></tt></b><font face="Arial,Helvetica"> is that value
|
||||
(a
|
||||
pointless mode of operation, but somehow complete...)</font></blockquote>
|
||||
<blockquote><font face="Arial,Helvetica">if </font><b><tt><font
|
||||
size="+1">X</font></tt></b><font face="Arial,Helvetica"> denotes an
|
||||
array
|
||||
type and </font><b><tt><font size="+1">Argz</font></tt></b><font
|
||||
face="Arial,Helvetica"> is a non-negative integer, then </font><b><tt><font
|
||||
size="+1">V</font></tt></b><font face="Arial,Helvetica"> is a new
|
||||
array
|
||||
of that many elements, initialised to the appropriate default value</font></blockquote>
|
||||
<blockquote><font face="Arial,Helvetica">if </font><b><tt><font
|
||||
size="+1">X</font></tt></b><font face="Arial,Helvetica"> denotes an
|
||||
array
|
||||
type and </font><b><tt><font size="+1">Argz</font></tt></b><font
|
||||
face="Arial,Helvetica"> is a list of datums, each of which is
|
||||
(independently)
|
||||
castable to the array element type, then </font><b><tt><font size="+1">V</font></tt></b><font
|
||||
face="Arial,Helvetica"> is a new array of as many elements as </font><b><tt><font
|
||||
size="+1">Argz</font></tt></b><font face="Arial,Helvetica"> has
|
||||
members,
|
||||
initialised to the results of casting the respective members of </font><b><tt><font
|
||||
size="+1">Argz</font></tt></b></blockquote>
|
||||
<blockquote><font face="Arial,Helvetica">if </font><b><tt><font
|
||||
size="+1">X</font></tt></b><font face="Arial,Helvetica"> denotes a
|
||||
non-array
|
||||
object type and </font><b><tt><font size="+1">Argz</font></tt></b><font
|
||||
face="Arial,Helvetica"> is a list of datums, then </font><b><tt><font
|
||||
size="+1">V</font></tt></b><font face="Arial,Helvetica"> is the result
|
||||
of
|
||||
an invocation of that type's most specifically-typed constructor to
|
||||
whose
|
||||
respective parameters the members of </font><b><tt><font size="+1">Argz</font></tt></b><font
|
||||
face="Arial,Helvetica"> are assignable</font></blockquote>
|
||||
<hr width="100%"> <br>
|
||||
<b><tt><font size="+2"><a name="jpl_call4"></a>jpl_call( +X, +Method,
|
||||
+Args, -R) :-</font></tt></b>
|
||||
<blockquote><b><tt><font size="+1">X</font></tt></b><font
|
||||
face="Arial,Helvetica"> can be:</font>
|
||||
<blockquote> <li> <font face="Arial,Helvetica">a <i>type</i>, <i>class
|
||||
object</i> or <i>classname</i> (for static methods of the denoted
|
||||
class,
|
||||
or for static or instance methods of java.lang.Class)</font></li>
|
||||
</blockquote>
|
||||
</blockquote>
|
||||
<blockquote>
|
||||
<blockquote> <li> <font face="Arial,Helvetica">a class instance or
|
||||
array
|
||||
(for static or instance methods)</font></li>
|
||||
</blockquote>
|
||||
<b><tt><font size="+1">Method</font></tt></b><font
|
||||
face="Arial,Helvetica"> can be:</font>
|
||||
<blockquote> <li> <font face="Arial,Helvetica">an atomic method
|
||||
name (if this name is ambiguous, as a result of method overloading,
|
||||
then it will be resolved by considering the types of <span
|
||||
style="font-weight: bold;">Args</span>, as far as they can be inferred)</font></li>
|
||||
</blockquote>
|
||||
</blockquote>
|
||||
<blockquote>
|
||||
<blockquote> <li> <font face="Arial,Helvetica">an integral method
|
||||
index
|
||||
(untested: for static overload resolution)</font></li>
|
||||
</blockquote>
|
||||
</blockquote>
|
||||
<blockquote>
|
||||
<blockquote> <li> <font face="Arial,Helvetica">a </font><b><tt><font
|
||||
size="+1">methodID/1</font></tt></b><font face="Arial,Helvetica">
|
||||
structure
|
||||
(ditto)</font></li>
|
||||
</blockquote>
|
||||
<b><tt><font size="+1">Args</font></tt></b><font
|
||||
face="Arial,Helvetica"> must be</font>
|
||||
<ul>
|
||||
<li> <font face="Arial,Helvetica">a proper list (possibly empty)
|
||||
of ground
|
||||
arguments</font></li>
|
||||
</ul>
|
||||
<font face="Arial,Helvetica">Finally, an attempt will be made to
|
||||
unify </font><b><tt><font size="+1">R</font></tt></b><font
|
||||
face="Arial,Helvetica"> with the returned
|
||||
result.</font></blockquote>
|
||||
<hr width="100%"> <br>
|
||||
<b><tt><font size="+2"><a name="jpl_set3"></a>jpl_set( +X, +Field, +V)
|
||||
:-</font></tt></b>
|
||||
<blockquote><font face="Arial,Helvetica">basically, sets the </font><b><tt><font
|
||||
size="+1">Fspec</font></tt></b><font face="Arial,Helvetica">-th field
|
||||
of
|
||||
object </font><b><tt><font size="+1">X</font></tt></b><font
|
||||
face="Arial,Helvetica"> to value </font><b><tt><font size="+1">V</font></tt></b>
|
||||
<p><b><tt><font size="+1">X</font></tt></b><font
|
||||
face="Arial,Helvetica"> can be:</font> </p>
|
||||
<ul>
|
||||
<li> <font face="Arial,Helvetica">a <i>class object</i>, a <i>classname</i>,
|
||||
or an (object or array) <i>type</i> (for static fields, or
|
||||
java.lang.Class fields)</font></li>
|
||||
</ul>
|
||||
</blockquote>
|
||||
<blockquote>
|
||||
<ul>
|
||||
<li> <font face="Arial,Helvetica">a <i>class instance</i> (for
|
||||
non-static
|
||||
fields)</font></li>
|
||||
</ul>
|
||||
</blockquote>
|
||||
<blockquote>
|
||||
<ul>
|
||||
<li> <font face="Arial,Helvetica">an <i>array</i> (for indexed
|
||||
element or
|
||||
subrange assignment)</font></li>
|
||||
</ul>
|
||||
</blockquote>
|
||||
<blockquote>
|
||||
<ul>
|
||||
<li> <font face="Arial,Helvetica">but not a <i>string</i> (no
|
||||
fields to
|
||||
retrieve)</font></li>
|
||||
</ul>
|
||||
<b><tt><font size="+1">Field</font></tt></b><font
|
||||
face="Arial,Helvetica"> can be:</font>
|
||||
<ul>
|
||||
<li> <font face="Arial,Helvetica">an atomic field name
|
||||
(overloading will
|
||||
be resolved dynamically, by considering the inferred type of <span
|
||||
style="font-family: helvetica,arial,sans-serif; font-weight: bold;">V</span>)</font></li>
|
||||
</ul>
|
||||
</blockquote>
|
||||
<blockquote>
|
||||
<ul>
|
||||
<li> <font face="Arial,Helvetica">an integral field index (static
|
||||
resolution: not tried yet)</font></li>
|
||||
</ul>
|
||||
</blockquote>
|
||||
<blockquote>
|
||||
<ul>
|
||||
<li> <font face="Arial,Helvetica">a </font><b><tt><font size="+1">fieldID/1</font></tt></b><font
|
||||
face="Arial,Helvetica"> (static resolution: not tried yet)</font></li>
|
||||
</ul>
|
||||
</blockquote>
|
||||
<blockquote>
|
||||
<ul>
|
||||
<li> <font face="Arial,Helvetica">a variable (field names, or
|
||||
array indices, are generated)(?!)</font></li>
|
||||
</ul>
|
||||
</blockquote>
|
||||
<blockquote>
|
||||
<ul>
|
||||
<li> <font face="Arial,Helvetica">an array index </font><b><tt><font
|
||||
size="+1">I</font></tt></b><font face="Arial,Helvetica"> (</font><b><tt><font
|
||||
size="+1">X</font></tt></b><font face="Arial,Helvetica"> must be an
|
||||
array
|
||||
object: </font><b><tt><font size="+1">X[I]</font></tt></b><font
|
||||
face="Arial,Helvetica"> is assigned </font><b><tt><font size="+1">V</font></tt></b><font
|
||||
face="Arial,Helvetica">)</font></li>
|
||||
</ul>
|
||||
</blockquote>
|
||||
<blockquote>
|
||||
<ul>
|
||||
<li> <font face="Arial,Helvetica">a pair </font><b><tt><font
|
||||
size="+1">I-J</font></tt></b><font face="Arial,Helvetica"> of integers
|
||||
(</font><b><tt><font size="+1">J</font></tt></b><font
|
||||
face="Arial,Helvetica"> can be a variable) (</font><b><tt><font
|
||||
size="+1">X</font></tt></b><font face="Arial,Helvetica"> must be an
|
||||
array
|
||||
object, </font><b><tt><font size="+1">V</font></tt></b><font
|
||||
face="Arial,Helvetica"> must be a list of values: </font><b><tt><font
|
||||
size="+1">X[I-J]</font></tt></b><font face="Arial,Helvetica"> will be
|
||||
assigned </font><b><tt><font size="+1">V</font></tt></b><font
|
||||
face="Arial,Helvetica">)</font></li>
|
||||
</ul>
|
||||
<b><tt><font size="+1">V</font></tt></b><font face="Arial,Helvetica">
|
||||
must be ground (although one day we may pass variables to <span
|
||||
style="font-weight: bold; font-style: italic;">JPL</span>?!)</font></blockquote>
|
||||
<hr width="100%"> <br>
|
||||
<b><tt><font size="+2"><a name="jpl_get3"></a>jpl_get( +X, +Field, -V)
|
||||
:-</font></tt></b>
|
||||
<blockquote><b><tt><font size="+1">X</font></tt></b><font
|
||||
face="Arial,Helvetica"> can be:</font>
|
||||
<ul>
|
||||
<li> <font face="Arial,Helvetica">a <i>class object</i>, a <i>classname</i>,
|
||||
or an (object or array) <i>type</i> (for static fields, or
|
||||
java.lang.Class fields)</font></li>
|
||||
</ul>
|
||||
</blockquote>
|
||||
<blockquote>
|
||||
<ul>
|
||||
<li> <font face="Arial,Helvetica">a <i>class instance</i> (for
|
||||
non-static
|
||||
fields)</font></li>
|
||||
</ul>
|
||||
</blockquote>
|
||||
<blockquote>
|
||||
<ul>
|
||||
<li> <font face="Arial,Helvetica">an <i>array</i> (for the
|
||||
'length' pseudo
|
||||
field, or for indexed element retrieval)</font></li>
|
||||
</ul>
|
||||
</blockquote>
|
||||
<blockquote>
|
||||
<ul>
|
||||
<li> <font face="Arial,Helvetica">but not a String (clashes with
|
||||
classname; anyway, java.lang.String has no fields to retrieve)</font></li>
|
||||
</ul>
|
||||
<b><tt><font size="+1">Field</font></tt></b><font
|
||||
face="Arial,Helvetica"> can be</font>
|
||||
<ul>
|
||||
<li> <font face="Arial,Helvetica">an atomic field name</font></li>
|
||||
</ul>
|
||||
</blockquote>
|
||||
<blockquote>
|
||||
<ul>
|
||||
<li> <font face="Arial,Helvetica">or an integral field index
|
||||
(these are
|
||||
a secret :-)</font></li>
|
||||
</ul>
|
||||
</blockquote>
|
||||
<blockquote>
|
||||
<ul>
|
||||
<li> <font face="Arial,Helvetica">or a </font><b><tt><font
|
||||
size="+1">fieldID/1</font></tt></b><font face="Arial,Helvetica"> (not
|
||||
for general consumption :-)</font></li>
|
||||
</ul>
|
||||
</blockquote>
|
||||
<blockquote>
|
||||
<ul>
|
||||
<li> <font face="Arial,Helvetica">or an integral array index
|
||||
(high-bound
|
||||
checking is done by JVM, maybe throwing an exception)</font></li>
|
||||
</ul>
|
||||
</blockquote>
|
||||
<blockquote>
|
||||
<ul>
|
||||
<li> <font face="Arial,Helvetica">or a variable (field names, or
|
||||
array indices, are generated)</font></li>
|
||||
</ul>
|
||||
</blockquote>
|
||||
<blockquote>
|
||||
<ul>
|
||||
<li> <font face="Arial,Helvetica">or a pair </font><b><tt><font
|
||||
size="+1">I-J</font></tt></b><font face="Arial,Helvetica"> of integers
|
||||
or
|
||||
variables (array subranges are generated) (relational or what?!)<br>
|
||||
</font></li>
|
||||
</ul>
|
||||
<font face="Arial,Helvetica">Immediately before <span
|
||||
style="font-weight: bold;">jpl_get/4</span> returns</font><font
|
||||
face="Arial,Helvetica">, an attempt will be made to unify </font><b><tt><font
|
||||
size="+1">V</font></tt></b><font face="Arial,Helvetica"> with the
|
||||
internally computed result.</font></blockquote>
|
||||
<hr width="100%">
|
||||
<h2><a name="exceptions"></a> exceptions thrown by Java<br>
|
||||
</h2>
|
||||
<font face="Arial,Helvetica">Uncaught exceptions thrown by the JVM in
|
||||
the course of
|
||||
handling a <span style="font-weight: bold; font-style: italic;">JPL</span><span
|
||||
style="font-weight: bold;">
|
||||
3.x Prolog API</span> call are mapped onto Standard Prolog exceptions,
|
||||
e.g.</font>
|
||||
<blockquote>
|
||||
<pre><b><tt><font size="+1">jpl_new( 'java.util.Date', [yesterday], D)</font></tt></b></pre>
|
||||
</blockquote>
|
||||
<font face="Arial,Helvetica">raises the Prolog exception</font>
|
||||
<blockquote><b><tt><font size="+1">java_exception('java.lang.IllegalArgumentException',
|
||||
@'J#0008408972')</font></tt></b></blockquote>
|
||||
<font face="Arial,Helvetica">because, as the exception suggests, <span
|
||||
style="font-weight: bold;">yesterday </span>is not a valid
|
||||
constructor argument.</font><br>
|
||||
<br>
|
||||
<span style="font-family: helvetica,arial,sans-serif;">Java exceptions
|
||||
are always returned as Prolog exceptions with this structure:</span><br
|
||||
style="font-family: helvetica,arial,sans-serif;">
|
||||
<blockquote><b><tt><font size="+1">java_exception( <span
|
||||
style="font-style: italic;">classname</span>, <span
|
||||
style="font-style: italic;">reference_to_exception_object</span>)</font></tt></b></blockquote>
|
||||
<hr width="100%">
|
||||
<h2><a name="testing"></a>testing</h2>
|
||||
<font face="Arial,Helvetica">For a rudimentary test, run</font>
|
||||
<blockquote>
|
||||
<pre><b><tt><font size="+1">?- jpl_demo.</font></tt></b></pre>
|
||||
</blockquote>
|
||||
<font face="Arial,Helvetica">and wait patiently for some Swing windows
|
||||
to
|
||||
appear (but not too patiently, in case something is wrong...)</font>
|
||||
<p> </p>
|
||||
<hr width="100%">
|
||||
<h2><a name="to_do"></a> to do</h2>
|
||||
<font face="Arial,Helvetica">Apart from any bugs I don't know about,
|
||||
this interface is usable and useful as it stands. Nevertheless
|
||||
there are some things "to do" at some stage in the future, e.g.</font>
|
||||
<ul>
|
||||
<li> <font face="Arial,Helvetica">support non-virtual method calls
|
||||
(i.e.
|
||||
explicitly call a method of some ancestor class despite there being an
|
||||
overriding method (i.e. of the same name etc.) in a "nearer" class).
|
||||
I believe
|
||||
this is a fairly arcane Java feature, but it is needed for
|
||||
completeness;
|
||||
I want to accommodate it without complicating the syntax of regular
|
||||
method
|
||||
calls.</font></li>
|
||||
</ul>
|
||||
<ul>
|
||||
<li> <font face="Arial,Helvetica">map the JVM's </font><b><tt><font
|
||||
size="+1">vprintf()</font></tt></b><font face="Arial,Helvetica">
|
||||
messages
|
||||
onto something in SWI-Prolog (the user_error stream?)</font></li>
|
||||
</ul>
|
||||
<ul>
|
||||
<li> <font face="Arial,Helvetica">catch the JVM's </font><b><tt><font
|
||||
size="+1">abort()</font></tt></b><font face="Arial,Helvetica"> and </font><b><tt><font
|
||||
size="+1">exit()</font></tt></b><font face="Arial,Helvetica"> events,
|
||||
and
|
||||
handle them appropriately (e.g. stop a Java <i>abort</i> from killing
|
||||
the
|
||||
SWI-Prolog process)</font></li>
|
||||
</ul>
|
||||
<ul>
|
||||
<li> <font face="Arial,Helvetica">propagate SWI-Prolog's ABORT
|
||||
action into
|
||||
the JVM as appropriate, e.g. to interrupt a pending <span
|
||||
style="font-weight: bold; font-style: italic;">JPL</span> call</font></li>
|
||||
</ul>
|
||||
<ul>
|
||||
<li> <font face="Arial,Helvetica">reduce the (extravagant) overheads
|
||||
of
|
||||
each <span style="font-weight: bold; font-style: italic;">JPL</span>
|
||||
call
|
||||
(without compromising functionality or safety)</font></li>
|
||||
</ul>
|
||||
<hr width="100%">
|
||||
<address> <font size="+1"><a href="mailto:paul.singleton@bcs.org.uk">Paul
|
||||
Singleton</a></font></address>
|
||||
<address> <font size="+1">drafted 10th November 2000</font></address>
|
||||
<address> <font size="+1">revised 14th December 2000<br>
|
||||
</font>
|
||||
</address>
|
||||
<address> <font size="+1">revised 11th March 2003<br>
|
||||
revised 18th February 2004<br>
|
||||
<br>
|
||||
</font></address>
|
||||
<br>
|
||||
<br>
|
||||
</body>
|
||||
</html>
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue