
Module: ppl/ppl Branch: devel Commit: 047cdfd61b32f26e748189e859dbe113af714e8c URL: http://www.cs.unipr.it/git/gitweb.cgi?p=ppl/ppl.git;a=commit;h=047cdfd61b32f...
Author: Abramo Bagnara abramo.bagnara@bugseng.com Date: Fri Feb 12 13:12:34 2021 +0100
Use size_t for Prolog terms arity.
---
interfaces/Prolog/Ciao/ciao_cfli.hh | 2 +- interfaces/Prolog/GNU/gprolog_cfli.hh | 6 ++++-- interfaces/Prolog/SICStus/sicstus_cfli.h | 2 +- interfaces/Prolog/SICStus/sicstus_cfli.ic | 7 +++++-- interfaces/Prolog/SWI/swi_cfli.hh | 11 ++++++++++- interfaces/Prolog/XSB/xsb_cfli.hh | 2 +- interfaces/Prolog/YAP/yap_cfli.hh | 2 +- .../Prolog/ppl_interface_generator_prolog_cc_code.m4 | 2 +- interfaces/Prolog/ppl_prolog_common.cc | 16 ++++++++-------- 9 files changed, 32 insertions(+), 18 deletions(-)
diff --git a/interfaces/Prolog/Ciao/ciao_cfli.hh b/interfaces/Prolog/Ciao/ciao_cfli.hh index fcea5dcd0..f0159776f 100644 --- a/interfaces/Prolog/Ciao/ciao_cfli.hh +++ b/interfaces/Prolog/Ciao/ciao_cfli.hh @@ -306,7 +306,7 @@ Prolog_get_atom_name(Prolog_term_ref t, Prolog_atom* ap) { The behavior is undefined if \p t is not a Prolog compound term. */ inline int -Prolog_get_compound_name_arity(Prolog_term_ref t, Prolog_atom* ap, int* ip) { +Prolog_get_compound_name_arity(Prolog_term_ref t, Prolog_atom* ap, size_t* ip) { assert(Prolog_is_compound(t)); *ap = ciao_structure_name(t); *ip = ciao_structure_arity(t); diff --git a/interfaces/Prolog/GNU/gprolog_cfli.hh b/interfaces/Prolog/GNU/gprolog_cfli.hh index b4f8490bf..b04c82601 100644 --- a/interfaces/Prolog/GNU/gprolog_cfli.hh +++ b/interfaces/Prolog/GNU/gprolog_cfli.hh @@ -420,9 +420,11 @@ Prolog_get_atom_name(Prolog_term_ref t, Prolog_atom* ap) { The behavior is undefined if \p t is not a Prolog compound term. */ inline int -Prolog_get_compound_name_arity(Prolog_term_ref t, Prolog_atom* ap, int* ip) { +Prolog_get_compound_name_arity(Prolog_term_ref t, Prolog_atom* ap, size_t* ip) { assert(Prolog_is_compound(t)); - Rd_Compound_Check(t, ap, ip); + int i; + Rd_Compound_Check(t, ap, &i); + *ip = i; return 1; }
diff --git a/interfaces/Prolog/SICStus/sicstus_cfli.h b/interfaces/Prolog/SICStus/sicstus_cfli.h index 2110c8c71..ef0cbbdb5 100644 --- a/interfaces/Prolog/SICStus/sicstus_cfli.h +++ b/interfaces/Prolog/SICStus/sicstus_cfli.h @@ -134,7 +134,7 @@ Prolog_get_atom_name(Prolog_term_ref t, Prolog_atom& name);
PCFLI_DECLSPEC int Prolog_get_compound_name_arity(Prolog_term_ref t, - Prolog_atom& name, int& arity); + Prolog_atom& name, size_t* arity);
PCFLI_DECLSPEC int Prolog_get_arg(int i, Prolog_term_ref t, Prolog_term_ref a); diff --git a/interfaces/Prolog/SICStus/sicstus_cfli.ic b/interfaces/Prolog/SICStus/sicstus_cfli.ic index f9d5609ed..40d4efe19 100644 --- a/interfaces/Prolog/SICStus/sicstus_cfli.ic +++ b/interfaces/Prolog/SICStus/sicstus_cfli.ic @@ -262,9 +262,12 @@ Prolog_get_atom_name(Prolog_term_ref t, Prolog_atom* ap) { The behavior is undefined if \p t is not a Prolog compound term. */ PCFLI_EXTERN_INLINE int -Prolog_get_compound_name_arity(Prolog_term_ref t, Prolog_atom* ap, int* ip) { +Prolog_get_compound_name_arity(Prolog_term_ref t, Prolog_atom* ap, size_t* ip) { assert(Prolog_is_compound(t)); - return SP_get_functor(t, ap, ip); + int i; + int r = SP_get_functor(t, ap, &i); + *ip = i; + return r; }
/*! diff --git a/interfaces/Prolog/SWI/swi_cfli.hh b/interfaces/Prolog/SWI/swi_cfli.hh index 49cb7c5ed..2a82a323c 100644 --- a/interfaces/Prolog/SWI/swi_cfli.hh +++ b/interfaces/Prolog/SWI/swi_cfli.hh @@ -346,9 +346,18 @@ Prolog_get_atom_name(Prolog_term_ref t, Prolog_atom* ap) { The behavior is undefined if \p t is not a Prolog compound term. */ inline int -Prolog_get_compound_name_arity(Prolog_term_ref t, Prolog_atom* ap, int* ip) { +Prolog_get_compound_name_arity(Prolog_term_ref t, Prolog_atom* ap, size_t* ip) { assert(Prolog_is_compound(t)); +#if PLVERSION >= 80129 return PL_get_name_arity(t, ap, ip); +#elif PLVERSION >= 70312 + return PL_get_name_arity_sz(t, ap, ip); +#else + int i; + if bool r = PL_get_name_arity(t, ap, &i); + *ip = i; + return r; +#endif }
/*! diff --git a/interfaces/Prolog/XSB/xsb_cfli.hh b/interfaces/Prolog/XSB/xsb_cfli.hh index 314102200..cf1dc8a9b 100644 --- a/interfaces/Prolog/XSB/xsb_cfli.hh +++ b/interfaces/Prolog/XSB/xsb_cfli.hh @@ -314,7 +314,7 @@ Prolog_get_atom_name(Prolog_term_ref t, Prolog_atom* ap) { The behavior is undefined if \p t is not a Prolog compound term. */ inline int -Prolog_get_compound_name_arity(Prolog_term_ref t, Prolog_atom* ap, int* ip) { +Prolog_get_compound_name_arity(Prolog_term_ref t, Prolog_atom* ap, size_t* ip) { assert(Prolog_is_compound(t)); *ap = p2c_functor(t); *ip = p2c_arity(t); diff --git a/interfaces/Prolog/YAP/yap_cfli.hh b/interfaces/Prolog/YAP/yap_cfli.hh index e3f978593..77e11ae6a 100644 --- a/interfaces/Prolog/YAP/yap_cfli.hh +++ b/interfaces/Prolog/YAP/yap_cfli.hh @@ -313,7 +313,7 @@ Prolog_get_atom_name(Prolog_term_ref t, Prolog_atom* ap) { The behavior is undefined if \p t is not a Prolog compound term. */ inline int -Prolog_get_compound_name_arity(Prolog_term_ref t, Prolog_atom* ap, int* ip) { +Prolog_get_compound_name_arity(Prolog_term_ref t, Prolog_atom* ap, size_t* ip) { assert(Prolog_is_compound(t)); YAP_Functor f = YAP_FunctorOfTerm(t); *ap = YAP_NameOfFunctor(f); diff --git a/interfaces/Prolog/ppl_interface_generator_prolog_cc_code.m4 b/interfaces/Prolog/ppl_interface_generator_prolog_cc_code.m4 index d722ad747..de9a1ad13 100644 --- a/interfaces/Prolog/ppl_interface_generator_prolog_cc_code.m4 +++ b/interfaces/Prolog/ppl_interface_generator_prolog_cc_code.m4 @@ -1936,7 +1936,7 @@ m4_define(`ppl_@CLASS@_map_space_dimensions_code', while (Prolog_is_cons(t_pfunc)) { Prolog_get_cons(t_pfunc, t_pair, t_pfunc); Prolog_atom functor; - int arity; + size_t arity; Prolog_get_compound_name_arity(t_pair, &functor, &arity); if (arity != 2 || functor != a_minus) return PROLOG_FAILURE; diff --git a/interfaces/Prolog/ppl_prolog_common.cc b/interfaces/Prolog/ppl_prolog_common.cc index 9ae05ab1a..febced8d4 100644 --- a/interfaces/Prolog/ppl_prolog_common.cc +++ b/interfaces/Prolog/ppl_prolog_common.cc @@ -937,7 +937,7 @@ build_linear_expression(Prolog_term_ref t, const char* where) { return Linear_Expression(integer_term_to_Coefficient(t)); else if (Prolog_is_compound(t)) { Prolog_atom functor; - int arity; + size_t arity; Prolog_get_compound_name_arity(t, &functor, &arity); switch (arity) { case 1: @@ -1000,7 +1000,7 @@ Constraint build_constraint(Prolog_term_ref t, const char* where) { if (Prolog_is_compound(t)) { Prolog_atom functor; - int arity; + size_t arity; Prolog_get_compound_name_arity(t, &functor, &arity); if (arity == 2) { Prolog_term_ref arg1 = Prolog_new_term_ref(); @@ -1073,7 +1073,7 @@ Congruence build_congruence(Prolog_term_ref t, const char* where) { if (Prolog_is_compound(t)) { Prolog_atom functor; - int arity; + size_t arity; Prolog_get_compound_name_arity(t, &functor, &arity); if (arity == 2) { Prolog_term_ref arg1 = Prolog_new_term_ref(); @@ -1084,7 +1084,7 @@ build_congruence(Prolog_term_ref t, const char* where) { // / if (Prolog_is_integer(arg2)) { Prolog_atom functor1; - int arity1; + size_t arity1; Prolog_get_compound_name_arity(arg1, &functor1, &arity1); if (arity1 == 2) { if (functor1 == a_is_congruent_to) { @@ -1137,7 +1137,7 @@ Generator build_generator(Prolog_term_ref t, const char* where) { if (Prolog_is_compound(t)) { Prolog_atom functor; - int arity; + size_t arity; Prolog_get_compound_name_arity(t, &functor, &arity); if (arity == 1) { Prolog_term_ref arg = Prolog_new_term_ref(); @@ -1174,7 +1174,7 @@ Grid_Generator build_grid_generator(Prolog_term_ref t, const char* where) { if (Prolog_is_compound(t)) { Prolog_atom functor; - int arity; + size_t arity; Prolog_get_compound_name_arity(t, &functor, &arity); if (arity == 1) { Prolog_term_ref arg = Prolog_new_term_ref(); @@ -1406,7 +1406,7 @@ Variable term_to_Variable(Prolog_term_ref t, const char* where) { if (Prolog_is_compound(t)) { Prolog_atom functor; - int arity; + size_t arity; Prolog_get_compound_name_arity(t, &functor, &arity); if (functor == a_dollar_VAR && arity == 1) { Prolog_term_ref arg = Prolog_new_term_ref(); @@ -1554,7 +1554,7 @@ term_to_boundary(Prolog_term_ref t_b, Boundary_Kind kind, return false;
Prolog_atom functor; - int arity; + size_t arity;
Prolog_get_compound_name_arity(t_b, &functor, &arity); // A boundary term is either of the form c(Limit) or o(Limit).