[PPL-devel] [GIT] ppl/ppl(master): Add ppl_Coefficient_bits to Prolog and OCaml interfaces.

Enea Zaffanella zaffanella at cs.unipr.it
Thu Apr 15 11:34:47 CEST 2010


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

Author: Enea Zaffanella <zaffanella at cs.unipr.it>
Date:   Thu Apr 15 11:33:29 2010 +0200

Add ppl_Coefficient_bits to Prolog and OCaml interfaces.
Renamed corresponding static method in Java interface.

---

 interfaces/Java/jni/ppl_java_globals.cc            |    2 +-
 .../Java/parma_polyhedra_library/Coefficient.java  |    2 +-
 interfaces/Java/tests/PIP_Problem_test1.java       |    2 +-
 interfaces/OCaml/OCaml_interface.dox               |    4 ++++
 interfaces/OCaml/ppl_ocaml_common.cc               |    8 ++++++++
 interfaces/OCaml/ppl_ocaml_globals.ml              |    3 +++
 interfaces/OCaml/ppl_ocaml_globals.mli             |    3 +++
 interfaces/Prolog/Prolog_interface.dox             |    5 +++++
 interfaces/Prolog/ppl_prolog_common.cc             |    9 +++++++++
 interfaces/Prolog/ppl_prolog_common.defs.hh        |    3 +++
 10 files changed, 38 insertions(+), 3 deletions(-)

diff --git a/interfaces/Java/jni/ppl_java_globals.cc b/interfaces/Java/jni/ppl_java_globals.cc
index 467ac21..14b32e1 100644
--- a/interfaces/Java/jni/ppl_java_globals.cc
+++ b/interfaces/Java/jni/ppl_java_globals.cc
@@ -97,7 +97,7 @@ Java_parma_1polyhedra_1library_By_1Reference_initIDs
 }
 
 JNIEXPORT jint JNICALL
-Java_parma_1polyhedra_1library_Coefficient_ppl_1bits(JNIEnv*, jclass) {
+Java_parma_1polyhedra_1library_Coefficient_bits(JNIEnv*, jclass) {
   return PPL_COEFFICIENT_BITS;
 }
 
diff --git a/interfaces/Java/parma_polyhedra_library/Coefficient.java b/interfaces/Java/parma_polyhedra_library/Coefficient.java
index 4b89bcb..c8cdd8f 100644
--- a/interfaces/Java/parma_polyhedra_library/Coefficient.java
+++ b/interfaces/Java/parma_polyhedra_library/Coefficient.java
@@ -75,7 +75,7 @@ public class Coefficient {
     }
 
     //! Returns the number of bits of PPL coefficients; 0 if unbounded.
-    public static native int ppl_bits();
+    public static native int bits();
 
     private static native void initIDs();
     static {
diff --git a/interfaces/Java/tests/PIP_Problem_test1.java b/interfaces/Java/tests/PIP_Problem_test1.java
index 1140207..a5b1121 100644
--- a/interfaces/Java/tests/PIP_Problem_test1.java
+++ b/interfaces/Java/tests/PIP_Problem_test1.java
@@ -362,7 +362,7 @@ static {
             pip.solve();
         }
         catch (Overflow_Error_Exception ex) {
-            if (Coefficient.ppl_bits() != 8)
+            if (Coefficient.bits() != 8)
                 throw ex;
             PPL_Test.println_if_noisy("Expected overflow exception caught:");
             PPL_Test.println_if_noisy(ex.getMessage());
diff --git a/interfaces/OCaml/OCaml_interface.dox b/interfaces/OCaml/OCaml_interface.dox
index affac00..5e68e03 100644
--- a/interfaces/OCaml/OCaml_interface.dox
+++ b/interfaces/OCaml/OCaml_interface.dox
@@ -177,6 +177,10 @@ included with all instantiations of the OCaml interfaces.
 <H2><CODE> ppl_max_space_dimension </CODE></H2>
   Returns the maximum space dimension the C++ interface can handle.
 
+<H2><CODE> ppl_Coefficient_bits </CODE></H2>
+  Returns the number of bits used in the C++ interface for PPL coefficients;
+  0 if unbounded.
+
 <H2><CODE> ppl_Coefficient_is_bounded </CODE></H2>
   Returns true if and only if the coefficients in the C++ interface
   are bounded.
diff --git a/interfaces/OCaml/ppl_ocaml_common.cc b/interfaces/OCaml/ppl_ocaml_common.cc
index a852f53..76a04ca 100644
--- a/interfaces/OCaml/ppl_ocaml_common.cc
+++ b/interfaces/OCaml/ppl_ocaml_common.cc
@@ -1752,6 +1752,14 @@ CATCH_ALL
 
 extern "C"
 CAMLprim value
+ppl_Coefficient_bits(value unit) try {
+  CAMLparam1(unit);
+  CAMLreturn(Val_long(PPL_COEFFICIENT_BITS));
+}
+CATCH_ALL
+
+extern "C"
+CAMLprim value
 ppl_Coefficient_is_bounded(value unit) try {
   CAMLparam1(unit);
   CAMLreturn(std::numeric_limits<Coefficient>::is_bounded
diff --git a/interfaces/OCaml/ppl_ocaml_globals.ml b/interfaces/OCaml/ppl_ocaml_globals.ml
index 408febf..a8e6b79 100644
--- a/interfaces/OCaml/ppl_ocaml_globals.ml
+++ b/interfaces/OCaml/ppl_ocaml_globals.ml
@@ -156,6 +156,9 @@ string -> int -> int -> int -> string = "ppl_io_wrap_string"
 external ppl_max_space_dimension:
 unit -> int = "ppl_max_space_dimension"
 
+external ppl_Coefficient_bits:
+unit -> int = "ppl_Coefficient_bits"
+
 external ppl_Coefficient_is_bounded:
 unit -> bool = "ppl_Coefficient_is_bounded"
 
diff --git a/interfaces/OCaml/ppl_ocaml_globals.mli b/interfaces/OCaml/ppl_ocaml_globals.mli
index 79cff49..f76d8a8 100644
--- a/interfaces/OCaml/ppl_ocaml_globals.mli
+++ b/interfaces/OCaml/ppl_ocaml_globals.mli
@@ -151,6 +151,9 @@ val ppl_io_wrap_string:
 val ppl_max_space_dimension:
   unit -> int
 
+val ppl_Coefficient_bits:
+  unit -> int
+
 val ppl_Coefficient_is_bounded:
   unit -> bool
 
diff --git a/interfaces/Prolog/Prolog_interface.dox b/interfaces/Prolog/Prolog_interface.dox
index 485b13f..7a442e4 100644
--- a/interfaces/Prolog/Prolog_interface.dox
+++ b/interfaces/Prolog/Prolog_interface.dox
@@ -389,6 +389,11 @@ that are included with all instantiations of the Prolog interfaces.
   warranty whatsoever, the C++ compiler used to build the library,
   where to report bugs and where to look for further information.</EM>
 
+<P><CODE> ppl_Coefficient_bits </CODE><BR>
+
+  <EM>Unifies the argument with the number of bits used to encode a
+  Coefficient in the C++ interface; 0 if unbounded.</EM>
+
 <P><CODE> ppl_Coefficient_is_bounded </CODE><BR>
 
   <EM>Succeeds if and only if the Coefficients in the C++ interface are bounded.</EM>
diff --git a/interfaces/Prolog/ppl_prolog_common.cc b/interfaces/Prolog/ppl_prolog_common.cc
index cf55e9a..cd49635 100644
--- a/interfaces/Prolog/ppl_prolog_common.cc
+++ b/interfaces/Prolog/ppl_prolog_common.cc
@@ -1977,6 +1977,15 @@ ppl_reset_deterministic_timeout() {
 }
 
 extern "C" Prolog_foreign_return_type
+ppl_Coefficient_bits(Prolog_term_ref t_bits) {
+  try {
+    if (unify_ulong(t_bits, PPL_COEFFICIENT_BITS))
+      return PROLOG_SUCCESS;
+  }
+  CATCH_ALL;
+}
+
+extern "C" Prolog_foreign_return_type
 ppl_Coefficient_is_bounded() {
   try {
     if (std::numeric_limits<Coefficient>::is_bounded)
diff --git a/interfaces/Prolog/ppl_prolog_common.defs.hh b/interfaces/Prolog/ppl_prolog_common.defs.hh
index 53a9b63..bf1dfe0 100644
--- a/interfaces/Prolog/ppl_prolog_common.defs.hh
+++ b/interfaces/Prolog/ppl_prolog_common.defs.hh
@@ -839,6 +839,9 @@ extern "C" Prolog_foreign_return_type
 ppl_reset_deterministic_timeout();
 
 extern "C" Prolog_foreign_return_type
+ppl_Coefficient_bits(Prolog_term_ref t_bits);
+
+extern "C" Prolog_foreign_return_type
 ppl_Coefficient_is_bounded();
 
 extern "C" Prolog_foreign_return_type




More information about the PPL-devel mailing list