[PPL-devel] [GIT] ppl/ppl(master): Fixed Java interface for PIP_Decision_Node:: child_node(branch).

Enea Zaffanella zaffanella at cs.unipr.it
Mon Apr 5 18:46:47 CEST 2010


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

Author: Enea Zaffanella <zaffanella at cs.unipr.it>
Date:   Mon Apr  5 18:44:27 2010 +0200

Fixed Java interface for PIP_Decision_Node::child_node(branch).
New interface has a (unboxed) boolean parameter.

---

 interfaces/Java/jni/ppl_java_globals.cc            |   14 +++++++-------
 .../parma_polyhedra_library/PIP_Decision_Node.java |    7 +++----
 interfaces/Java/tests/PIP_Problem_test1.java       |    8 ++++----
 3 files changed, 14 insertions(+), 15 deletions(-)

diff --git a/interfaces/Java/jni/ppl_java_globals.cc b/interfaces/Java/jni/ppl_java_globals.cc
index 457ea45..8b28785 100644
--- a/interfaces/Java/jni/ppl_java_globals.cc
+++ b/interfaces/Java/jni/ppl_java_globals.cc
@@ -2012,15 +2012,15 @@ Java_parma_1polyhedra_1library_PIP_1Tree_1Node_artificials
 
 JNIEXPORT jobject JNICALL
 Java_parma_1polyhedra_1library_PIP_1Decision_1Node_child_1node
-(JNIEnv* env, jobject j_this, jobject j_branch) {
+(JNIEnv* env, jobject j_this, jboolean j_branch) {
   try {
-    PIP_Decision_Node* pip
+    PIP_Decision_Node* dec_node
       = reinterpret_cast<PIP_Decision_Node*>(get_ptr(env, j_this));
-    unsigned u = jtype_to_unsigned<unsigned>(j_integer_to_j_int(env, j_branch));
-    bool b = (u == 0) ? false : true;
-    const PIP_Tree_Node* child
-      = pip->child_node(b);
-
+    const PIP_Tree_Node* child = dec_node->child_node(j_branch);
+    if (child == 0) {
+      jobject null = 0;
+      return null;
+    }
     jclass j_class_s = env->FindClass("parma_polyhedra_library/PIP_Tree_Node");
     CHECK_RESULT_ASSERT(env, j_class_s);
     jmethodID j_ctr_id_s = env->GetMethodID(j_class_s, "<init>", "()V");
diff --git a/interfaces/Java/parma_polyhedra_library/PIP_Decision_Node.java b/interfaces/Java/parma_polyhedra_library/PIP_Decision_Node.java
index d13ac53..3af54da 100644
--- a/interfaces/Java/parma_polyhedra_library/PIP_Decision_Node.java
+++ b/interfaces/Java/parma_polyhedra_library/PIP_Decision_Node.java
@@ -30,9 +30,8 @@ import java.io.IOException;
 public class PIP_Decision_Node extends PIP_Tree_Node {
 
     /*! \brief
-      Returns a the true branch (if \p b is not zero)
-      or the false branch (if \p b is zero) of \p pip_dec.
+      Returns the true branch (if \p branch is true)
+      or the false branch (if \p branch is false) of \p this.
     */
-    /* FIXME: j_branch should be a boolean. */
-    public native PIP_Tree_Node child_node(Integer j_branch);
+    public native PIP_Tree_Node child_node(boolean branch);
 }
diff --git a/interfaces/Java/tests/PIP_Problem_test1.java b/interfaces/Java/tests/PIP_Problem_test1.java
index 78e5621..d36b8e7 100644
--- a/interfaces/Java/tests/PIP_Problem_test1.java
+++ b/interfaces/Java/tests/PIP_Problem_test1.java
@@ -380,7 +380,7 @@ static {
         if (relsym != Relation_Symbol.GREATER_OR_EQUAL
             || (le_left.is_zero()) || (le_right.is_zero()))
           return false;
-        PIP_Tree_Node root_true_branch = root.child_node(1);
+        PIP_Tree_Node root_true_branch = root.child_node(true);
         if (root_true_branch == null)
           return false;
 
@@ -406,9 +406,9 @@ static {
           || (le_left2.is_zero()) || (le_right2.is_zero()))
           return false;
 
-        if (t_child.child_node(1) == null)
+        if (t_child.child_node(true) == null)
           return false;
-        PIP_Solution_Node t_t_child = t_child.child_node(1).as_solution();
+        PIP_Solution_Node t_t_child = t_child.child_node(true).as_solution();
         if (t_t_child == null || !t_t_child.OK())
           return false;
 
@@ -421,7 +421,7 @@ static {
         Linear_Expression v_i = t_t_child.parametric_values(I);
         Linear_Expression v_j = t_t_child.parametric_values(J);
 
-        PIP_Solution_Node t_f_child = t_child.child_node(0).as_solution();
+        PIP_Solution_Node t_f_child = t_child.child_node(false).as_solution();
         if (t_f_child == null || !t_f_child.OK())
           return false;
 




More information about the PPL-devel mailing list