
Module: ppl/ppl Branch: master Commit: 9784b8165b6cb1dea5eb6d20b4cebca7ecc780fd URL: http://www.cs.unipr.it/git/gitweb.cgi?p=ppl/ppl.git;a=commit;h=9784b8165b6cb...
Author: Roberto Bagnara bagnara@cs.unipr.it Date: Sat Dec 19 11:46:22 2009 +0100
Added support for SWI-Prolog version 5.8 and later.
---
interfaces/Prolog/SWI/swi_cfli.hh | 48 +++++++++++++++++++++++++++++++++++++ interfaces/Prolog/SWI/swi_efli.cc | 9 ++++++- 2 files changed, 56 insertions(+), 1 deletions(-)
diff --git a/interfaces/Prolog/SWI/swi_cfli.hh b/interfaces/Prolog/SWI/swi_cfli.hh index 98d2092..e09fde7 100644 --- a/interfaces/Prolog/SWI/swi_cfli.hh +++ b/interfaces/Prolog/SWI/swi_cfli.hh @@ -52,8 +52,12 @@ Prolog_new_term_ref() { */ inline int Prolog_put_term(Prolog_term_ref t, Prolog_term_ref u) { +#if PLVERSION >= 50800 + return PL_put_term(t, u); +#else PL_put_term(t, u); return 1; +#endif }
/*! @@ -61,8 +65,12 @@ Prolog_put_term(Prolog_term_ref t, Prolog_term_ref u) { */ inline int Prolog_put_long(Prolog_term_ref t, long l) { +#if PLVERSION >= 50800 + return PL_put_integer(t, l); +#else PL_put_integer(t, l); return 1; +#endif }
static int tmp_mpz_t_initialized = 0; @@ -89,12 +97,20 @@ Prolog_put_big_ulong(Prolog_term_ref t, unsigned long ul) { inline int Prolog_put_ulong(Prolog_term_ref t, unsigned long ul) { if (ul <= LONG_MAX) { +#if PLVERSION >= 50800 + return PL_put_integer(t, ul); +#else PL_put_integer(t, ul); return 1; +#endif } else if (ul <= (uint64_t) INT64_MAX) { +#if PLVERSION >= 50800 + return PL_put_int64(t, (int64_t) ul); +#else PL_put_int64(t, (int64_t) ul); return 1; +#endif } else return Prolog_put_big_ulong(t, ul); @@ -106,8 +122,12 @@ Prolog_put_ulong(Prolog_term_ref t, unsigned long ul) { */ inline int Prolog_put_atom_chars(Prolog_term_ref t, const char* s) { +#if PLVERSION >= 50800 + return PL_put_atom_chars(t, s); +#else PL_put_atom_chars(t, s); return 1; +#endif }
/*! @@ -115,8 +135,12 @@ Prolog_put_atom_chars(Prolog_term_ref t, const char* s) { */ inline int Prolog_put_atom(Prolog_term_ref t, Prolog_atom a) { +#if PLVERSION >= 50800 + return PL_put_atom(t, a); +#else PL_put_atom(t, a); return 1; +#endif }
/*! @@ -124,8 +148,12 @@ Prolog_put_atom(Prolog_term_ref t, Prolog_atom a) { */ inline int Prolog_put_address(Prolog_term_ref t, void* p) { +#if PLVERSION >= 50800 + return PL_put_pointer(t, p); +#else PL_put_pointer(t, p); return 1; +#endif }
/*! @@ -143,8 +171,12 @@ Prolog_atom_from_string(const char* s) { inline int Prolog_construct_compound(Prolog_term_ref t, Prolog_atom f, Prolog_term_ref a1) { +#if PLVERSION >= 50800 + return PL_cons_functor(t, PL_new_functor(f, 1), a1); +#else PL_cons_functor(t, PL_new_functor(f, 1), a1); return 1; +#endif }
/*! @@ -154,8 +186,12 @@ Prolog_construct_compound(Prolog_term_ref t, Prolog_atom f, inline int Prolog_construct_compound(Prolog_term_ref t, Prolog_atom f, Prolog_term_ref a1, Prolog_term_ref a2) { +#if PLVERSION >= 50800 + return PL_cons_functor(t, PL_new_functor(f, 2), a1, a2); +#else PL_cons_functor(t, PL_new_functor(f, 2), a1, a2); return 1; +#endif }
/*! @@ -166,8 +202,12 @@ inline int Prolog_construct_compound(Prolog_term_ref t, Prolog_atom f, Prolog_term_ref a1, Prolog_term_ref a2, Prolog_term_ref a3) { +#if PLVERSION >= 50800 + return PL_cons_functor(t, PL_new_functor(f, 3), a1, a2, a3); +#else PL_cons_functor(t, PL_new_functor(f, 3), a1, a2, a3); return 1; +#endif }
/*! @@ -178,8 +218,12 @@ inline int Prolog_construct_compound(Prolog_term_ref t, Prolog_atom f, Prolog_term_ref a1, Prolog_term_ref a2, Prolog_term_ref a3, Prolog_term_ref a4) { +#if PLVERSION >= 50800 + return PL_cons_functor(t, PL_new_functor(f, 4), a1, a2, a3, a4); +#else PL_cons_functor(t, PL_new_functor(f, 4), a1, a2, a3, a4); return 1; +#endif }
/*! @@ -188,8 +232,12 @@ Prolog_construct_compound(Prolog_term_ref t, Prolog_atom f, inline int Prolog_construct_cons(Prolog_term_ref c, Prolog_term_ref h, Prolog_term_ref t) { +#if PLVERSION >= 50800 + return PL_cons_list(c, h, t); +#else PL_cons_list(c, h, t); return 1; +#endif }
/*! diff --git a/interfaces/Prolog/SWI/swi_efli.cc b/interfaces/Prolog/SWI/swi_efli.cc index 01b197c..48a569e 100644 --- a/interfaces/Prolog/SWI/swi_efli.cc +++ b/interfaces/Prolog/SWI/swi_efli.cc @@ -50,10 +50,17 @@ ppl_Prolog_sysdep_deinit() { int Prolog_get_Coefficient(Prolog_term_ref t, Coefficient& n) { assert(Prolog_is_integer(t)); + // FIXME: avoid the temporary when Coefficient is mpz_class. PPL_DIRTY_TEMP0(mpz_class, tmp); + int r; +#if PLVERSION >= 50800 + r = PL_get_mpz(t, tmp.get_mpz_t()); +#else PL_get_mpz(t, tmp.get_mpz_t()); + r = 1; +#endif n = tmp; - return 1; + return r; }
int