[PPL-devel] [GIT] ppl/ppl(master): Added a few missing accessor methods to Java interface classes.

Enea Zaffanella zaffanella at cs.unipr.it
Thu May 14 23:38:15 CEST 2009


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

Author: Enea Zaffanella <zaffanella at cs.unipr.it>
Date:   Thu May 14 23:35:26 2009 +0200

Added a few missing accessor methods to Java interface classes.
Affected classes are Congruence, Generator and Grid_Generator.

---

 interfaces/Java/jni/ppl_java_common.cc             |   10 ++++----
 interfaces/Java/jni/ppl_java_common.defs.hh        |    2 +-
 interfaces/Java/jni/ppl_java_globals.cc            |    4 +-
 .../Java/parma_polyhedra_library/Congruence.java   |   19 +++++++++++++-
 .../Java/parma_polyhedra_library/Generator.java    |   10 +++++++
 .../parma_polyhedra_library/Grid_Generator.java    |   26 ++++++++++++++++++++
 6 files changed, 61 insertions(+), 10 deletions(-)

diff --git a/interfaces/Java/jni/ppl_java_common.cc b/interfaces/Java/jni/ppl_java_common.cc
index 2e29806..d2b9675 100644
--- a/interfaces/Java/jni/ppl_java_common.cc
+++ b/interfaces/Java/jni/ppl_java_common.cc
@@ -328,14 +328,14 @@ build_java_poly_con_relation(JNIEnv* env, Poly_Con_Relation& r) {
 
 Congruence
 build_cxx_congruence(JNIEnv* env, jobject j_congruence) {
-  jobject j_modulus
-    = env->GetObjectField(j_congruence, cached_FMIDs.Congruence_modulus_ID);
+  jobject j_mod
+    = env->GetObjectField(j_congruence, cached_FMIDs.Congruence_mod_ID);
   jobject j_lhs
     = env->GetObjectField(j_congruence, cached_FMIDs.Congruence_lhs_ID);
   jobject j_rhs
     = env->GetObjectField(j_congruence, cached_FMIDs.Congruence_rhs_ID);
   PPL_DIRTY_TEMP_COEFFICIENT(ppl_modulus);
-  ppl_modulus = build_cxx_coeff(env, j_modulus);
+  ppl_modulus = build_cxx_coeff(env, j_mod);
   Linear_Expression lhs = build_cxx_linear_expression(env, j_lhs);
   Linear_Expression rhs = build_cxx_linear_expression(env, j_rhs);
   return (lhs %= rhs) / ppl_modulus;
@@ -831,13 +831,13 @@ build_java_constraint(JNIEnv* env, const Constraint& c) {
 
 jobject
 build_java_congruence(JNIEnv* env, const Congruence& cg) {
-  jobject j_modulus = build_java_coeff(env, cg.modulus());
+  jobject j_mod = build_java_coeff(env, cg.modulus());
   jobject j_lhs = build_linear_expression(env, cg);
   jobject j_rhs
     = build_java_linear_expression_coefficient(env, -cg.inhomogeneous_term());
   jobject ret = env->NewObject(cached_classes.Congruence,
                                cached_FMIDs.Congruence_init_ID,
-			       j_lhs, j_rhs, j_modulus);
+			       j_lhs, j_rhs, j_mod);
   CHECK_RESULT_THROW(env, ret);
   return ret;
 }
diff --git a/interfaces/Java/jni/ppl_java_common.defs.hh b/interfaces/Java/jni/ppl_java_common.defs.hh
index 4e7020b..6c52441 100644
--- a/interfaces/Java/jni/ppl_java_common.defs.hh
+++ b/interfaces/Java/jni/ppl_java_common.defs.hh
@@ -250,7 +250,7 @@ struct Java_FMID_Cache {
   // Complexity_Class.
   jmethodID Complexity_Class_ordinal_ID;
   // Congruence.
-  jfieldID Congruence_modulus_ID;
+  jfieldID Congruence_mod_ID;
   jfieldID Congruence_lhs_ID;
   jfieldID Congruence_rhs_ID;
   jmethodID Congruence_init_ID;
diff --git a/interfaces/Java/jni/ppl_java_globals.cc b/interfaces/Java/jni/ppl_java_globals.cc
index b6cd4a5..071d4c1 100644
--- a/interfaces/Java/jni/ppl_java_globals.cc
+++ b/interfaces/Java/jni/ppl_java_globals.cc
@@ -135,10 +135,10 @@ JNIEXPORT void JNICALL
 Java_parma_1polyhedra_1library_Congruence_initIDs
 (JNIEnv* env, jclass j_congruence_class) {
   jfieldID fID;
-  fID = env->GetFieldID(j_congruence_class, "modulus",
+  fID = env->GetFieldID(j_congruence_class, "mod",
                         "Lparma_polyhedra_library/Coefficient;");
   CHECK_RESULT_ASSERT(env, fID);
-  cached_FMIDs.Congruence_modulus_ID = fID;
+  cached_FMIDs.Congruence_mod_ID = fID;
   fID = env->GetFieldID(j_congruence_class, "lhs",
                         "Lparma_polyhedra_library/Linear_Expression;");
   CHECK_RESULT_ASSERT(env, fID);
diff --git a/interfaces/Java/parma_polyhedra_library/Congruence.java b/interfaces/Java/parma_polyhedra_library/Congruence.java
index bb67259..b370795 100644
--- a/interfaces/Java/parma_polyhedra_library/Congruence.java
+++ b/interfaces/Java/parma_polyhedra_library/Congruence.java
@@ -41,7 +41,7 @@ import java.io.IOException;
 public class Congruence {
 
     //! The modulus of the congruence.
-    protected Coefficient modulus;
+    protected Coefficient mod;
 
     //! The value of the left hand side of \p this.
     Linear_Expression lhs;
@@ -55,11 +55,26 @@ public class Congruence {
     */
     public Congruence(Linear_Expression e1, Linear_Expression e2,
 		      Coefficient m) {
-	modulus = new Coefficient(m);
+	mod = new Coefficient(m);
 	lhs = e1.clone();
 	rhs = e2.clone();
     }
 
+    //! Returns the left hand side of \p this.
+    public Linear_Expression left_hand_side() {
+	return lhs;
+    }
+
+    //! Returns the right hand side of \p this.
+    public Linear_Expression right_hand_side() {
+	return rhs;
+    }
+
+    //! Returns the relation symbol of \p this.
+    public Coefficient modulus() {
+	return mod;
+    }
+
     //! Returns an ascii formatted internal representation of \p this.
     public native String ascii_dump();
 
diff --git a/interfaces/Java/parma_polyhedra_library/Generator.java b/interfaces/Java/parma_polyhedra_library/Generator.java
index 99a3980..a4e0f8f 100644
--- a/interfaces/Java/parma_polyhedra_library/Generator.java
+++ b/interfaces/Java/parma_polyhedra_library/Generator.java
@@ -110,6 +110,16 @@ public class Generator {
         return new Generator(e, Generator_Type.RAY);
     }
 
+    //! Returns the generator type.
+    public Generator_Type type() {
+        return gt;
+    }
+
+    //! Returns the linear expression in \p this.
+    public Linear_Expression linear_expression() {
+        return le;
+    }
+
     //! If \p this is either a point or a closure point, returns its divisor.
     /*!
       \exception RuntimeErrorException
diff --git a/interfaces/Java/parma_polyhedra_library/Grid_Generator.java b/interfaces/Java/parma_polyhedra_library/Grid_Generator.java
index dc5cf33..379082f 100644
--- a/interfaces/Java/parma_polyhedra_library/Grid_Generator.java
+++ b/interfaces/Java/parma_polyhedra_library/Grid_Generator.java
@@ -24,6 +24,7 @@ package parma_polyhedra_library;
 
 import java.io.Writer;
 import java.io.IOException;
+import javax.management.RuntimeErrorException;
 
 //! A grid line, parameter or grid point.
 /*! \ingroup PPL_Java_interface
@@ -84,6 +85,31 @@ public class Grid_Generator {
 	return new Grid_Generator(e, d, Grid_Generator_Type.POINT);
     }
 
+    //! Returns the generator type.
+    public Grid_Generator_Type type() {
+        return gt;
+    }
+
+    //! Returns the linear expression in \p this.
+    public Linear_Expression linear_expression() {
+        return le;
+    }
+
+    //! If \p this is either a grid point or a parameter, returns its divisor.
+    /*!
+      \exception RuntimeErrorException
+      Thrown if \p this is a line.
+    */
+    public Coefficient divisor() {
+        if (this.gt != Grid_Generator_Type.LINE)
+	    return div;
+	Error cause = new Error("parma_polyhedra_library."
+                                + "Grid_Generator::divisor:\n"
+				+ "this is neither a grid point"
+				+ " nor a parameter.");
+	throw new RuntimeErrorException(cause);
+    }
+
     //! Returns an ascii formatted internal representation of \p this.
     public native String ascii_dump();
 




More information about the PPL-devel mailing list