iyap2swi interface
git-svn-id: https://yap.svn.sf.net/svnroot/yap/trunk@485 b08c6af1-5177-4d33-ba66-4b1c6b8b522a
This commit is contained in:
parent
6fa55d4394
commit
c98c8fa804
91
library/yap2swi/Makefile.in
Normal file
91
library/yap2swi/Makefile.in
Normal file
@ -0,0 +1,91 @@
|
|||||||
|
#
|
||||||
|
# default base directory for YAP installation
|
||||||
|
# (EROOT for architecture-dependent files)
|
||||||
|
#
|
||||||
|
prefix = @prefix@
|
||||||
|
ROOTDIR = $(prefix)
|
||||||
|
EROOTDIR = @exec_prefix@
|
||||||
|
#
|
||||||
|
# where the binary should be
|
||||||
|
#
|
||||||
|
BINDIR = $(EROOTDIR)/bin
|
||||||
|
#
|
||||||
|
# where YAP should look for libraries
|
||||||
|
#
|
||||||
|
LIBDIR=$(EROOTDIR)/lib/Yap
|
||||||
|
#
|
||||||
|
#
|
||||||
|
CC=@CC@
|
||||||
|
CFLAGS= @CFLAGS@ $(YAP_EXTRAS) $(DEFS) -I$(srcdir) -I../.. -I$(srcdir)/../../include
|
||||||
|
#
|
||||||
|
#
|
||||||
|
# You shouldn't need to change what follows.
|
||||||
|
#
|
||||||
|
INSTALL=@INSTALL@
|
||||||
|
INSTALL_DATA=@INSTALL_DATA@
|
||||||
|
INSTALL_PROGRAM=@INSTALL_PROGRAM@
|
||||||
|
SHELL=/bin/sh
|
||||||
|
RANLIB=@RANLIB@
|
||||||
|
srcdir=@srcdir@
|
||||||
|
SHLIB_CFLAGS=@SHLIB_CFLAGS@
|
||||||
|
SHLIB_SUFFIX=@SHLIB_SUFFIX@
|
||||||
|
#4.1VPATH=@srcdir@:@srcdir@/OPTYap
|
||||||
|
CWD=$(PWD)
|
||||||
|
#
|
||||||
|
|
||||||
|
OBJS=yap2swi.o
|
||||||
|
SOBJS=yap2swi@SHLIB_SUFFIX@
|
||||||
|
|
||||||
|
#in some systems we just create a single object, in others we need to
|
||||||
|
# create a libray
|
||||||
|
|
||||||
|
all: @NEWSHOBJ@
|
||||||
|
|
||||||
|
sobjs: $(SOBJS)
|
||||||
|
|
||||||
|
dll: yap2swi@SHLIB_SUFFIX@
|
||||||
|
|
||||||
|
yap2swi.o: $(srcdir)/yap2swi.c
|
||||||
|
$(CC) -c $(CFLAGS) $(SHLIB_CFLAGS) $(srcdir)/yap2swi.c -o yap2swi.o
|
||||||
|
|
||||||
|
@DO_SECOND_LD@@DO_SECOND_LD@%@SHLIB_SUFFIX@: %.o
|
||||||
|
@DO_SECOND_LD@ @SHLIB_LD@ -o $@ $<
|
||||||
|
|
||||||
|
@DO_SECOND_LD@yap2swi@SHLIB_SUFFIX@: yap2swi.o
|
||||||
|
@DO_SECOND_LD@ @SHLIB_LD@ -o yap2swi@SHLIB_SUFFIX@ yap2swi.o
|
||||||
|
|
||||||
|
#
|
||||||
|
# create a new DLL library on cygwin environments
|
||||||
|
#
|
||||||
|
# DLLNAME: name of the new dll
|
||||||
|
# OBJS: list of object files I want to put in
|
||||||
|
# LIBS: list of libraries to link with
|
||||||
|
# DEFFILE is the name of the definitions file.
|
||||||
|
# BASEFILE temporary
|
||||||
|
# EXPFILE temporary
|
||||||
|
# ENTRY is the entry point int WINAPI startup (HINSTANCE, DWORD, LPVOID)
|
||||||
|
#
|
||||||
|
DLLTOOL=dlltool
|
||||||
|
DLLNAME=yap2swi.dll
|
||||||
|
DLL_LIBS=-L /usr/lib/mingw -lmoldname -lcrtdll -lkernel32 -L../.. -lWYap
|
||||||
|
BASE_FILE=yap2swi.base
|
||||||
|
EXP_FILE=yap2swi.exp
|
||||||
|
DEF_FILE=$(srcdir)/yap2swi.def
|
||||||
|
ENTRY_FUNCTION=_win_yap2swi@12
|
||||||
|
#
|
||||||
|
yap2swi.dll: $(OBJS)
|
||||||
|
$(LD) -s --base-file $(BASE_FILE) --dll -o $(DLLNAME) $(OBJS) $(DLL_LIBS) -e $(ENTRY_FUNCTION)
|
||||||
|
$(DLLTOOL) --as=$(AS) --dllname $(DLLNAME) --def $(DEF_FILE) --base-file $(BASE_FILE) --output-exp $(EXP_FILE)
|
||||||
|
$(LD) -s --base-file $(BASE_FILE) $(EXP_FILE) -dll -o $(DLLNAME) $(OBJS) $(DLL_LIBS) -e $(ENTRY_FUNCTION)
|
||||||
|
$(DLLTOOL) --as=$(AS) --dllname $(DLLNAME) --def $(DEF_FILE) --base-file $(BASE_FILE) --output-exp $(EXP_FILE)
|
||||||
|
$(LD) $(EXP_FILE) --dll -o $(DLLNAME) $(OBJS) $(DLL_LIBS) -e $(ENTRY_FUNCTION)
|
||||||
|
|
||||||
|
install: all
|
||||||
|
$(INSTALL_PROGRAM) $(SOBJS) $(DESTDIR)$(LIBDIR)
|
||||||
|
|
||||||
|
install_win32: dll
|
||||||
|
$(INSTALL_PROGRAM) -m 755 yap2swi.dll $(LIBDIR)/yap2swi.dll
|
||||||
|
|
||||||
|
clean:
|
||||||
|
rm -f *.o *~ $(OBJS) $(SOBJS) *.BAK
|
||||||
|
|
1120
library/yap2swi/yap2swi.c
Normal file
1120
library/yap2swi/yap2swi.c
Normal file
File diff suppressed because it is too large
Load Diff
82
library/yap2swi/yap2swi.def
Normal file
82
library/yap2swi/yap2swi.def
Normal file
@ -0,0 +1,82 @@
|
|||||||
|
EXPORTS
|
||||||
|
PL_agc_hook
|
||||||
|
PL_atom_chars
|
||||||
|
PL_copy_term_ref
|
||||||
|
PL_new_term_ref
|
||||||
|
PL_new_term_refs
|
||||||
|
PL_reset_term_refs
|
||||||
|
PL_get_arg
|
||||||
|
PL_get_atom
|
||||||
|
PL_get_atom_chars
|
||||||
|
PL_get_chars
|
||||||
|
PL_get_functor
|
||||||
|
PL_get_float
|
||||||
|
PL_get_head
|
||||||
|
PL_get_integer
|
||||||
|
PL_get_list
|
||||||
|
PL_get_long
|
||||||
|
PL_get_list_chars
|
||||||
|
PL_get_module
|
||||||
|
PL_get_name_arity
|
||||||
|
PL_get_nil
|
||||||
|
PL_get_pointer
|
||||||
|
PL_get_string
|
||||||
|
PL_get_tail
|
||||||
|
PL_new_atom
|
||||||
|
PL_new_functor
|
||||||
|
PL_functor_name
|
||||||
|
PL_functor_arity
|
||||||
|
PL_cons_functor
|
||||||
|
PL_cons_functor_v
|
||||||
|
PL_cons_list
|
||||||
|
PL_put_atom
|
||||||
|
PL_put_atom_chars
|
||||||
|
PL_put_float
|
||||||
|
PL_put_functor
|
||||||
|
PL_put_integer
|
||||||
|
PL_put_list
|
||||||
|
PL_put_nil
|
||||||
|
PL_put_pointer
|
||||||
|
PL_put_string_chars
|
||||||
|
PL_put_term
|
||||||
|
PL_put_variable
|
||||||
|
PL_unify
|
||||||
|
PL_unify_atom
|
||||||
|
PL_unify_atom_chars
|
||||||
|
PL_unify_float
|
||||||
|
PL_unify_integer
|
||||||
|
PL_unify_list
|
||||||
|
PL_unify_list_chars
|
||||||
|
PL_unify_nil
|
||||||
|
PL_unify_pointer
|
||||||
|
PL_unify_string_chars
|
||||||
|
PL_unify_term
|
||||||
|
PL_is_atom
|
||||||
|
PL_is_atomic
|
||||||
|
PL_is_compound
|
||||||
|
PL_is_float
|
||||||
|
PL_is_functor
|
||||||
|
PL_is_integer
|
||||||
|
PL_is_list
|
||||||
|
PL_is_number
|
||||||
|
PL_is_string
|
||||||
|
PL_is_variable
|
||||||
|
PL_term_type
|
||||||
|
PL_halt
|
||||||
|
PL_initialise
|
||||||
|
PL_close_foreign_frame
|
||||||
|
PL_discard_foreign_frame
|
||||||
|
PL_open_foreign_frame
|
||||||
|
PL_raise_exception
|
||||||
|
PL_unregister_atom
|
||||||
|
PL_pred
|
||||||
|
PL_predicate
|
||||||
|
PL_predicate_info
|
||||||
|
PL_open_query
|
||||||
|
PL_next_solution
|
||||||
|
PL_cut_query
|
||||||
|
PL_close_query
|
||||||
|
PL_exception
|
||||||
|
PL_call_predicate
|
||||||
|
PL_call
|
||||||
|
PL_register_extensions
|
187
library/yap2swi/yap2swi.h
Normal file
187
library/yap2swi/yap2swi.h
Normal file
@ -0,0 +1,187 @@
|
|||||||
|
/* yap2swi.h */
|
||||||
|
/*
|
||||||
|
* Project: jpl for Yap Prolog
|
||||||
|
* Author: Steve Moyle and Vitor Santos Costa
|
||||||
|
* Email: steve.moyle@comlab.ox.ac.uk
|
||||||
|
* Date: 21 January 2002
|
||||||
|
|
||||||
|
* Copyright (c) 2002 Steve Moyle and Vitor Santos Costa. All rights reserved.
|
||||||
|
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
//=== includes ===============================================================
|
||||||
|
#include <c_interface.h>
|
||||||
|
#include <stdarg.h>
|
||||||
|
|
||||||
|
#if defined(_MSC_VER) && defined(YAP_EXPORTS)
|
||||||
|
#define X_API __declspec(dllexport)
|
||||||
|
#else
|
||||||
|
#define X_API
|
||||||
|
#endif
|
||||||
|
|
||||||
|
typedef unsigned int fid_t;
|
||||||
|
typedef unsigned int term_t;
|
||||||
|
typedef int module_t;
|
||||||
|
typedef Atom atom_t;
|
||||||
|
typedef Term *predicate_t;
|
||||||
|
typedef struct open_query_struct *qid_t;
|
||||||
|
typedef long functor_t;
|
||||||
|
|
||||||
|
typedef int (*CPredicate)(void);
|
||||||
|
|
||||||
|
typedef struct _PL_extension
|
||||||
|
{ char *predicate_name; /* Name of the predicate */
|
||||||
|
short arity; /* Arity of the predicate */
|
||||||
|
CPredicate function; /* Implementing functions */
|
||||||
|
short flags; /* Or of PL_FA_... */
|
||||||
|
} PL_extension;
|
||||||
|
|
||||||
|
#define PL_FA_NOTRACE (0x01) /* foreign cannot be traced */
|
||||||
|
#define PL_FA_TRANSPARENT (0x02) /* foreign is module transparent */
|
||||||
|
#define PL_FA_NONDETERMINISTIC (0x04) /* foreign is non-deterministic */
|
||||||
|
#define PL_FA_VARARGS (0x08) /* call using t0, ac, ctx */
|
||||||
|
|
||||||
|
/* begin from pl-itf.h */
|
||||||
|
#define PL_VARIABLE (1) /* nothing */
|
||||||
|
#define PL_ATOM (2) /* const char * */
|
||||||
|
#define PL_INTEGER (3) /* int */
|
||||||
|
#define PL_FLOAT (4) /* double */
|
||||||
|
#define PL_STRING (5) /* const char * */
|
||||||
|
#define PL_TERM (6)
|
||||||
|
|
||||||
|
/* PL_unify_term() */
|
||||||
|
#define PL_FUNCTOR (10) /* functor_t, arg ... */
|
||||||
|
#define PL_LIST (11) /* length, arg ... */
|
||||||
|
#define PL_CHARS (12) /* const char * */
|
||||||
|
#define PL_POINTER (13) /* void * */
|
||||||
|
/* PlArg::PlArg(text, type) */
|
||||||
|
#define PL_CODE_LIST (14) /* [ascii...] */
|
||||||
|
#define PL_CHAR_LIST (15) /* [h,e,l,l,o] */
|
||||||
|
#define PL_BOOL (16) /* PL_set_feature() */
|
||||||
|
#define PL_FUNCTOR_CHARS (17) /* PL_unify_term() */
|
||||||
|
#define PL_PREDICATE_INDICATOR (18) /* predicate_t (Procedure) */
|
||||||
|
#define PL_SHORT (19) /* short */
|
||||||
|
#define PL_INT (20) /* int */
|
||||||
|
#define PL_LONG (21) /* long */
|
||||||
|
#define PL_DOUBLE (22) /* double */
|
||||||
|
|
||||||
|
#define CVT_ATOM 0x0001
|
||||||
|
#define CVT_STRING 0x0002
|
||||||
|
#define CVT_LIST 0x0004
|
||||||
|
#define CVT_INTEGER 0x0008
|
||||||
|
#define CVT_FLOAT 0x0010
|
||||||
|
#define CVT_VARIABLE 0x0020
|
||||||
|
#define CVT_NUMBER (CVT_INTEGER|CVT_FLOAT)
|
||||||
|
#define CVT_ATOMIC (CVT_NUMBER|CVT_ATOM|CVT_STRING)
|
||||||
|
#define CVT_WRITE 0x0040 /* as of version 3.2.10 */
|
||||||
|
#define CVT_ALL (CVT_ATOMIC|CVT_LIST)
|
||||||
|
#define CVT_MASK 0x00ff
|
||||||
|
|
||||||
|
#define BUF_DISCARDABLE 0x0000
|
||||||
|
#define BUF_RING 0x0100
|
||||||
|
#define BUF_MALLOC 0x0200
|
||||||
|
|
||||||
|
/* end from pl-itf.h */
|
||||||
|
|
||||||
|
|
||||||
|
extern X_API void PL_agc_hook(void);
|
||||||
|
extern X_API char* PL_atom_chars(atom_t);
|
||||||
|
extern X_API term_t PL_copy_term_ref(term_t);
|
||||||
|
extern X_API term_t PL_new_term_ref(void);
|
||||||
|
extern X_API term_t PL_new_term_refs(int);
|
||||||
|
extern X_API void PL_reset_term_refs(term_t);
|
||||||
|
/* begin PL_get_* functions =============================*/
|
||||||
|
extern X_API int PL_get_arg(int, term_t, term_t);
|
||||||
|
extern X_API int PL_get_atom(term_t, Atom *);
|
||||||
|
extern X_API int PL_get_atom_chars(term_t, char **);
|
||||||
|
extern X_API int PL_get_chars(term_t, char **, unsigned);
|
||||||
|
extern X_API int PL_get_functor(term_t, functor_t *);
|
||||||
|
extern X_API int PL_get_float(term_t, double *);
|
||||||
|
extern X_API int PL_get_head(term_t, term_t);
|
||||||
|
extern X_API int PL_get_integer(term_t, int *);
|
||||||
|
extern X_API int PL_get_list(term_t, term_t, term_t);
|
||||||
|
extern X_API int PL_get_long(term_t, long *);
|
||||||
|
extern X_API int PL_get_list_chars(term_t, char **, unsigned);
|
||||||
|
extern X_API int PL_get_module(term_t, module_t *);
|
||||||
|
extern X_API int PL_get_name_arity(term_t, atom_t *, int *);
|
||||||
|
extern X_API int PL_get_nil(term_t);
|
||||||
|
extern X_API int PL_get_pointer(term_t, void **);
|
||||||
|
extern X_API int PL_get_string(term_t, char **, int *);
|
||||||
|
extern X_API int PL_get_tail(term_t, term_t);
|
||||||
|
/* end PL_get_* functions =============================*/
|
||||||
|
/* begin PL_new_* functions =============================*/
|
||||||
|
extern X_API atom_t PL_new_atom(const char *);
|
||||||
|
extern X_API functor_t PL_new_functor(atom_t, int);
|
||||||
|
extern X_API atom_t PL_functor_name(functor_t);
|
||||||
|
extern X_API int PL_functor_arity(functor_t);
|
||||||
|
/* end PL_new_* functions =============================*/
|
||||||
|
/* begin PL_put_* functions =============================*/
|
||||||
|
extern X_API void PL_cons_functor(term_t, functor_t,...);
|
||||||
|
extern X_API void PL_cons_functor_v(term_t, functor_t,term_t);
|
||||||
|
extern X_API void PL_cons_list(term_t, term_t, term_t);
|
||||||
|
extern X_API void PL_put_atom(term_t, atom_t);
|
||||||
|
extern X_API void PL_put_atom_chars(term_t, const char *);
|
||||||
|
extern X_API void PL_put_float(term_t, double);
|
||||||
|
extern X_API void PL_put_functor(term_t, functor_t t);
|
||||||
|
extern X_API void PL_put_integer(term_t, long);
|
||||||
|
extern X_API void PL_put_list(term_t);
|
||||||
|
extern X_API void PL_put_nil(term_t);
|
||||||
|
extern X_API void PL_put_pointer(term_t, void *);
|
||||||
|
extern X_API void PL_put_string_chars(term_t, const char *);
|
||||||
|
extern X_API void PL_put_term(term_t, term_t);
|
||||||
|
extern X_API void PL_put_variable(term_t);
|
||||||
|
/* end PL_put_* functions =============================*/
|
||||||
|
/* begin PL_unify_* functions =============================*/
|
||||||
|
extern X_API int PL_unify(term_t, term_t);
|
||||||
|
extern X_API int PL_unify_atom(term_t, atom_t);
|
||||||
|
extern X_API int PL_unify_atom_chars(term_t, const char *);
|
||||||
|
extern X_API int PL_unify_float(term_t, double);
|
||||||
|
extern X_API int PL_unify_integer(term_t, long);
|
||||||
|
extern X_API int PL_unify_list(term_t, term_t, term_t);
|
||||||
|
extern X_API int PL_unify_list_chars(term_t, const char *);
|
||||||
|
extern X_API int PL_unify_nil(term_t);
|
||||||
|
extern X_API int PL_unify_pointer(term_t, void *);
|
||||||
|
extern X_API int PL_unify_string_chars(term_t, const char *);
|
||||||
|
extern X_API int PL_unify_term(term_t,...);
|
||||||
|
/* end PL_unify_* functions =============================*/
|
||||||
|
/* begin PL_is_* functions =============================*/
|
||||||
|
extern X_API int PL_is_atom(term_t);
|
||||||
|
extern X_API int PL_is_atomic(term_t);
|
||||||
|
extern X_API int PL_is_compound(term_t);
|
||||||
|
extern X_API int PL_is_float(term_t);
|
||||||
|
extern X_API int PL_is_functor(term_t, functor_t);
|
||||||
|
extern X_API int PL_is_integer(term_t);
|
||||||
|
extern X_API int PL_is_list(term_t);
|
||||||
|
extern X_API int PL_is_number(term_t);
|
||||||
|
extern X_API int PL_is_string(term_t);
|
||||||
|
extern X_API int PL_is_variable(term_t);
|
||||||
|
extern X_API int PL_term_type(term_t);
|
||||||
|
/* end PL_is_* functions =============================*/
|
||||||
|
extern X_API void PL_halt(int);
|
||||||
|
extern X_API int PL_initialise(int, char **, char **);
|
||||||
|
extern X_API void PL_close_foreign_frame(fid_t);
|
||||||
|
extern X_API void PL_discard_foreign_frame(fid_t);
|
||||||
|
extern X_API fid_t PL_open_foreign_frame(void);
|
||||||
|
extern X_API int PL_raise_exception(term_t);
|
||||||
|
extern X_API void PL_unregister_atom(atom_t);
|
||||||
|
extern X_API predicate_t PL_pred(functor_t, module_t);
|
||||||
|
extern X_API predicate_t PL_predicate(const char *, int, const char *);
|
||||||
|
extern X_API void PL_predicate_info(predicate_t, atom_t *, int *, module_t *);
|
||||||
|
extern X_API qid_t PL_open_query(module_t, int, predicate_t, term_t);
|
||||||
|
extern X_API int PL_next_solution(qid_t);
|
||||||
|
extern X_API void PL_cut_query(qid_t);
|
||||||
|
extern X_API void PL_close_query(qid_t);
|
||||||
|
extern X_API term_t PL_exception(qid_t);
|
||||||
|
extern X_API int PL_call_predicate(module_t, int, predicate_t, term_t);
|
||||||
|
extern X_API int PL_call(term_t, module_t);
|
||||||
|
extern X_API void PL_register_extensions(PL_extension *e);
|
||||||
|
|
||||||
|
|
||||||
|
extern X_API int Sprintf(char *,...);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
Reference in New Issue
Block a user