[PPL-devel] [GIT] ppl/ppl(master): Added Box method has_{upper. lower}_bound to OCaml and Prolog lang interfaces.

Enea Zaffanella zaffanella at cs.unipr.it
Mon Mar 19 17:49:14 CET 2012


Module: ppl/ppl
Branch: master
Commit: 047c37cda2bb8b73e4529647e4bbddd3c0ef8e89
URL:    http://www.cs.unipr.it/git/gitweb.cgi?p=ppl/ppl.git;a=commit;h=047c37cda2bb8b73e4529647e4bbddd3c0ef8e89

Author: Enea Zaffanella <zaffanella at cs.unipr.it>
Date:   Mon Mar 19 17:47:44 2012 +0100

Added Box method has_{upper.lower}_bound to OCaml and Prolog lang interfaces.

---

 .../OCaml/ppl_interface_generator_ocaml_cc_code.m4 |   24 ++++++++++++++++
 .../OCaml/ppl_interface_generator_ocaml_ml_code.m4 |    9 ++++++
 .../ppl_interface_generator_ocaml_mli_code.m4      |    8 +++++
 .../ppl_interface_generator_prolog_cc_code.m4      |   29 ++++++++++++++++++++
 .../ppl_interface_generator_prolog_hh_code.m4      |    9 ++++++
 5 files changed, 79 insertions(+), 0 deletions(-)

diff --git a/interfaces/OCaml/ppl_interface_generator_ocaml_cc_code.m4 b/interfaces/OCaml/ppl_interface_generator_ocaml_cc_code.m4
index 067ec1e..1b282b9 100644
--- a/interfaces/OCaml/ppl_interface_generator_ocaml_cc_code.m4
+++ b/interfaces/OCaml/ppl_interface_generator_ocaml_cc_code.m4
@@ -720,6 +720,30 @@ CATCH_ALL
 
 ')
 
+m4_define(`ppl_ at CLASS@_has_ at UPPERLOWER@_bound_code',
+`dnl
+extern "C"
+CAMLprim value
+ppl_ at CLASS@_has_ at UPPERLOWER@_bound(value ph, value var) try {
+  CAMLparam2(ph, var);
+  CAMLlocal1(caml_return_value);
+  PPL_DIRTY_TEMP_COEFFICIENT(num);
+  PPL_DIRTY_TEMP_COEFFICIENT(den);
+  bool is_closed = false;
+  @CPP_CLASS@& pph = *p_ at CLASS@_val(ph);
+  dimension_type dd = value_to_ppl_dimension(var);
+  bool ppl_return_value = pph.has_ at UPPERLOWER@_bound(dd, is_closed, num, den);
+  caml_return_value = caml_alloc(4, 0);
+  Store_field(caml_return_value, 0, Val_bool(ppl_return_value));
+  Store_field(caml_return_value, 1, Val_bool(is_closed));
+  Store_field(caml_return_value, 2, build_ocaml_coefficient(num));
+  Store_field(caml_return_value, 3, build_ocaml_coefficient(den));
+  CAMLreturn(caml_return_value);
+}
+CATCH_ALL
+
+')
+
 m4_define(`ppl_ at CLASS@_ at MAXMIN@_code',
 `dnl
 extern "C"
diff --git a/interfaces/OCaml/ppl_interface_generator_ocaml_ml_code.m4 b/interfaces/OCaml/ppl_interface_generator_ocaml_ml_code.m4
index 5620b37..6058f7a 100644
--- a/interfaces/OCaml/ppl_interface_generator_ocaml_ml_code.m4
+++ b/interfaces/OCaml/ppl_interface_generator_ocaml_ml_code.m4
@@ -359,6 +359,15 @@ external ppl_ at CLASS@_ at LIMITEDBOUNDED@_ at WIDENEXPN@_extrapolation_assign_with_toke
 ')
 
 
+m4_define(`ppl_ at CLASS@_has_ at UPPERLOWER@_bound_code',
+`dnl
+external ppl_ at CLASS@_has_ at UPPERLOWER@_bound:
+  @!CLASS@ -> int
+  -> bool * bool * Z.t * Z.t
+  = "ppl_ at CLASS@_has_ at UPPERLOWER@_bound"
+
+')
+
 m4_define(`ppl_ at CLASS@_ at MAXMIN@_code',
 `dnl
 external ppl_ at CLASS@_ at MAXMIN@:
diff --git a/interfaces/OCaml/ppl_interface_generator_ocaml_mli_code.m4 b/interfaces/OCaml/ppl_interface_generator_ocaml_mli_code.m4
index fc461db..d12e6f5 100644
--- a/interfaces/OCaml/ppl_interface_generator_ocaml_mli_code.m4
+++ b/interfaces/OCaml/ppl_interface_generator_ocaml_mli_code.m4
@@ -321,6 +321,14 @@ val ppl_ at CLASS@_ at LIMITEDBOUNDED@_ at WIDENEXPN@_extrapolation_assign:
 
 ')
 
+m4_define(`ppl_ at CLASS@_has_ at UPPERLOWER@_bound_code',
+`dnl
+val ppl_ at CLASS@_has_ at UPPERLOWER@_bound:
+  @!CLASS@ -> int
+  -> bool * bool * Z.t * Z.t
+
+')
+
 m4_define(`ppl_ at CLASS@_ at MAXMIN@_code',
 `dnl
 val ppl_ at CLASS@_ at MAXMIN@:
diff --git a/interfaces/Prolog/ppl_interface_generator_prolog_cc_code.m4 b/interfaces/Prolog/ppl_interface_generator_prolog_cc_code.m4
index fd540f3..0c372fd 100644
--- a/interfaces/Prolog/ppl_interface_generator_prolog_cc_code.m4
+++ b/interfaces/Prolog/ppl_interface_generator_prolog_cc_code.m4
@@ -802,6 +802,35 @@ m4_define(`ppl_ at CLASS@_bounds_from_ at ABOVEBELOW@_code',
 
 ')
 
+m4_define(`ppl_ at CLASS@_has_ at UPPERLOWER@_bound_code',
+  `extern "C" Prolog_foreign_return_type
+  ppl_ at CLASS@_has_ at UPPERLOWER@_bound(Prolog_term_ref t_ph,
+                       Prolog_term_ref t_v,
+                       Prolog_term_ref t_closed,
+                       Prolog_term_ref t_n, Prolog_term_ref t_d) {
+  static const char* where = "ppl_ at CLASS@_has_ at UPPERLOWER@_bound/5";
+  try {
+    const @CPP_CLASS@* ph = term_to_handle<@CPP_CLASS@ >(t_ph, where);
+    PPL_CHECK(ph);
+    const Variable v = term_to_Variable(t_v, where);
+    bool closed;
+    PPL_DIRTY_TEMP_COEFFICIENT(n);
+    PPL_DIRTY_TEMP_COEFFICIENT(d);
+    if (ph->has_ at UPPERLOWER@_bound(v, closed, n, d)) {
+      Prolog_term_ref t = Prolog_new_term_ref();
+      Prolog_atom a = (closed ? a_true : a_false);
+      Prolog_put_atom(t, a);
+      if (Prolog_unify_Coefficient(t_n, n)
+          && Prolog_unify_Coefficient(t_d, d)
+          && Prolog_unify(t_closed, t))
+        return PROLOG_SUCCESS;
+    }
+  }
+  CATCH_ALL;
+}
+
+')
+
 m4_define(`ppl_ at CLASS@_ at MAXMIN@_code',
   `extern "C" Prolog_foreign_return_type
   ppl_ at CLASS@_ at MAXMIN@(Prolog_term_ref t_ph, Prolog_term_ref t_le_expr,
diff --git a/interfaces/Prolog/ppl_interface_generator_prolog_hh_code.m4 b/interfaces/Prolog/ppl_interface_generator_prolog_hh_code.m4
index b1a11c3..dc18944 100644
--- a/interfaces/Prolog/ppl_interface_generator_prolog_hh_code.m4
+++ b/interfaces/Prolog/ppl_interface_generator_prolog_hh_code.m4
@@ -215,6 +215,15 @@ m4_define(`ppl_ at CLASS@_bounds_from_ at ABOVEBELOW@_code',
 
 ')
 
+m4_define(`ppl_ at CLASS@_has_ at UPPERLOWER@_bound_code',
+  `extern "C" Prolog_foreign_return_type
+  ppl_ at CLASS@_has_ at UPPERLOWER@_bound(Prolog_term_ref t_ph,
+                       Prolog_term_ref t_v,
+		       Prolog_term_ref t_closed,
+		       Prolog_term_ref t_n, Prolog_term_ref t_d);
+
+')
+
 m4_define(`ppl_ at CLASS@_ at MAXMIN@_code',
   `extern "C" Prolog_foreign_return_type
   ppl_ at CLASS@_ at MAXMIN@(Prolog_term_ref t_ph, Prolog_term_ref t_le_expr,




More information about the PPL-devel mailing list