public inbox for frysk-cvs@sourceware.org
help / color / mirror / Atom feed
From: cagney@sourceware.org
To: frysk-cvs@sourceware.org
Subject: [SCM]  master: Re-implement frysk:rsl bindings using generated jnixx code.
Date: Thu, 01 May 2008 15:58:00 -0000	[thread overview]
Message-ID: <20080501155840.27396.qmail@sourceware.org> (raw)

The branch, master has been updated
       via  3a720966fdb848db7f8319e81374788d4d8e7e68 (commit)
      from  40930462dc547ccb74ba3f809ae32c8a40221429 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email.

- Log -----------------------------------------------------------------
commit 3a720966fdb848db7f8319e81374788d4d8e7e68
Author: Andrew Cagney <cagney@redhat.com>
Date:   Thu May 1 11:57:20 2008 -0400

    Re-implement frysk:rsl bindings using generated jnixx code.
    
    frysk-sys/frysk/ChangeLog
    2008-05-01  Andrew Cagney  <cagney@redhat.com>
    
    	* jni/jnixx.java: Use findClass and frysk/jni/xx.hxx; throw
    	jnixx_exception.
    	* jni/xx.hxx: Replace jni/members.hxx.
    	* jni/xx.cxx: Replace jni/members.cxx.
    
    frysk-sys/frysk/rsl/ChangeLog
    2008-05-01  Andrew Cagney  <cagney@redhat.com>
    
    	* jni/Log.cxx: Re-implement using jnixx generated stubs.
    	* jni/Log.hxx: Ditto.

-----------------------------------------------------------------------

Summary of changes:
 frysk-sys/frysk/ChangeLog       |    5 +
 frysk-sys/frysk/jni/jnixx.java  |   14 +--
 frysk-sys/frysk/jni/members.cxx |  239 ---------------------------------------
 frysk-sys/frysk/jni/members.hxx |   96 ----------------
 frysk-sys/frysk/rsl/ChangeLog   |    5 +
 frysk-sys/frysk/rsl/jni/Log.cxx |   58 +++-------
 frysk-sys/frysk/rsl/jni/Log.hxx |    8 +-
 7 files changed, 34 insertions(+), 391 deletions(-)
 delete mode 100644 frysk-sys/frysk/jni/members.cxx
 delete mode 100644 frysk-sys/frysk/jni/members.hxx

First 500 lines of diff:
diff --git a/frysk-sys/frysk/ChangeLog b/frysk-sys/frysk/ChangeLog
index dd4a952..6472df8 100644
--- a/frysk-sys/frysk/ChangeLog
+++ b/frysk-sys/frysk/ChangeLog
@@ -1,5 +1,10 @@
 2008-05-01  Andrew Cagney  <cagney@redhat.com>
 
+	* jni/jnixx.java: Use findClass and frysk/jni/xx.hxx; throw
+	jnixx_exception.
+	* jni/xx.hxx: Replace jni/members.hxx.
+	* jni/xx.cxx: Replace jni/members.cxx.
+
 	* jni/jnixx.java: Generate Class(JNIEnv*) method; drop jclass
 	parameter; don't new the exception.
 
diff --git a/frysk-sys/frysk/jni/jnixx.java b/frysk-sys/frysk/jni/jnixx.java
index d6e280f..43a6f1b 100644
--- a/frysk-sys/frysk/jni/jnixx.java
+++ b/frysk-sys/frysk/jni/jnixx.java
@@ -346,7 +346,7 @@ class jnixx {
 	print("(");
 	printActualCxxParameters(method);
 	println(");");
-	println("  } catch (const std::exception& e) {");
+	println("  } catch (jnixx_exception) {");
 	if (method.getReturnType() != Void.TYPE) {
 	    println("    return 0;");
 	}
@@ -401,7 +401,7 @@ class jnixx {
 	printActualJniParameters(method);
 	println(");");
 	println("  if (env->ExceptionCheck())");
-	println("    throw std::exception();");
+	println("    throw jnixx_exception();");
 	if (returnType != Void.TYPE) {
 	    println("  return ret;");
 	}
@@ -409,11 +409,8 @@ class jnixx {
     }
 
     static void printCxxFile(Class klass) {
-	println("#include <jni.h>");
-	println();
-	println("#include <exception>");
+	println("#include \"frysk/jni/xx.hxx\"");
 	println();
-	println("#include \"frysk/jni/members.hxx\"");
 	print("#include \"");
 	print(klass.getName().replaceAll("\\.", "/"));
 	print("-jni.hxx\"");
@@ -428,11 +425,8 @@ class jnixx {
 	printCxxName(klass);
 	println("::Class(JNIEnv* env) {");
 	println("  if (_Class == NULL) {");
-	println("    _Class = env->FindClass(\""
+	println("    _Class = findClass(env, \""
 		+ klass.getName().replace("\\.", "/") + "\");");
-	println("    if (_Class == NULL) {");
-	println("      throw std::exception();");
-	println("    }");
 	println("  }");
 	println("  return _Class;");
 	println("}");
diff --git a/frysk-sys/frysk/jni/members.cxx b/frysk-sys/frysk/jni/members.cxx
deleted file mode 100644
index ccca57f..0000000
--- a/frysk-sys/frysk/jni/members.cxx
+++ /dev/null
@@ -1,239 +0,0 @@
-// This file is part of the program FRYSK.
-//
-// Copyright 2008, Red Hat Inc.
-//
-// FRYSK is free software; you can redistribute it and/or modify it
-// under the terms of the GNU General Public License as published by
-// the Free Software Foundation; version 2 of the License.
-//
-// FRYSK is distributed in the hope that it will be useful, but
-// WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// General Public License for more details.
-// 
-// You should have received a copy of the GNU General Public License
-// along with FRYSK; if not, write to the Free Software Foundation,
-// Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
-// 
-// In addition, as a special exception, Red Hat, Inc. gives You the
-// additional right to link the code of FRYSK with code not covered
-// under the GNU General Public License ("Non-GPL Code") and to
-// distribute linked combinations including the two, subject to the
-// limitations in this paragraph. Non-GPL Code permitted under this
-// exception must only link to the code of FRYSK through those well
-// defined interfaces identified in the file named EXCEPTION found in
-// the source code files (the "Approved Interfaces"). The files of
-// Non-GPL Code may instantiate templates or use macros or inline
-// functions from the Approved Interfaces without causing the
-// resulting work to be covered by the GNU General Public
-// License. Only Red Hat, Inc. may make changes or additions to the
-// list of Approved Interfaces. You must obey the GNU General Public
-// License in all respects for all of the FRYSK code and other code
-// used in conjunction with FRYSK except the Non-GPL Code covered by
-// this exception. If you modify this file, you may extend this
-// exception to your version of the file, but you are not obligated to
-// do so. If you do not wish to provide this exception without
-// modification, you must delete this exception statement from your
-// version and license this file solely under the GPL without
-// exception.
-
-#include <jni.h>
-
-#include "frysk/jni/members.hxx"
-
-jmethodID
-getMethodID(JNIEnv* env, jobject object, const char* name,
-	    const char* signature) {
-  jclass klass = env->GetObjectClass(object);
-  if (klass == NULL) {
-    fprintf(stderr, "frysk: failed to find class for method %s%s\n",
-	    name, signature);
-    return NULL;
-  }
-  return getMethodID(env, klass, name, signature);
-}
-
-jmethodID
-getMethodID(JNIEnv* env, jclass klass, const char* name,
-	    const char* signature) {
-  jmethodID methodID = env->GetMethodID(klass, name, signature);
-  if (methodID == NULL) {
-    fprintf(stderr, "frysk: failed to find method %s%s\n",
-	    name, signature);
-    return NULL;
-  }
-  return methodID;
-}
-
-jmethodID
-getStaticMethodID(JNIEnv* env, jobject object, const char* name,
-		  const char* signature) {
-  jclass klass = env->GetObjectClass(object);
-  if (klass == NULL) {
-    fprintf(stderr, "frysk: failed to find class for method %s%s\n",
-	    name, signature);
-    return NULL;
-  }
-  return getStaticMethodID(env, klass, name, signature);
-}
-
-jmethodID
-getStaticMethodID(JNIEnv* env, jclass klass, const char* name,
-		  const char* signature) {
-  jmethodID methodID = env->GetStaticMethodID(klass, name, signature);
-  if (methodID == NULL) {
-    fprintf(stderr, "frysk: failed to find method %s%s\n",
-	    name, signature);
-    return NULL;
-  }
-  return methodID;
-}
-
-jfieldID
-getFieldID(JNIEnv* env, jobject object, const char* name,
-	   const char* signature) {
-    jclass klass = env->GetObjectClass(object);
-    if (klass == NULL) {
-      fprintf(stderr, "frysk: failed to find class for field %s%s\n",
-	      name, signature);
-      return NULL;
-    }
-    return getFieldID(env, klass, name, signature);
-}
-
-jfieldID
-getFieldID(JNIEnv* env, jclass klass, const char* name,
-	   const char* signature) {
-    jfieldID fieldID = env->GetFieldID(klass, name, signature);
-    if (fieldID == NULL) {
-      fprintf(stderr, "frysk: failed to find field %s%s\n",
-	      name, signature);
-      return NULL;
-    }
-    return fieldID;
-}
-
-jfieldID
-getStaticFieldID(JNIEnv* env, jobject object, const char* name,
-		 const char* signature) {
-    jclass klass = env->GetObjectClass(object);
-    if (klass == NULL) {
-      fprintf(stderr, "frysk: failed to find class for field %s%s\n",
-	      name, signature);
-      return NULL;
-    }
-    return getStaticFieldID(env, klass, name, signature);
-}
-
-jfieldID
-getStaticFieldID(JNIEnv* env, jclass klass, const char* name,
-		 const char* signature) {
-  jfieldID fieldID = env->GetStaticFieldID(klass, name, signature);
-  if (fieldID == NULL) {
-    fprintf(stderr, "frysk: failed to find static field %s%s\n",
-	    name, signature);
-    return NULL;
-  }
-  return fieldID;
-}
-
-
-jboolean
-getMethodID(jmethodID* id, JNIEnv* env, jobject object,
-	    const char* name, const char* signature) {
-  if (*id == NULL) {
-    *id = getMethodID(env, object, name, signature);
-    if (*id == NULL) {
-      return JNI_FALSE;
-    }
-  }
-  return JNI_TRUE;
-}
-
-jboolean
-getMethodID(jmethodID* id, JNIEnv* env, jclass klass,
-	    const char* name, const char* signature) {
-  if (*id == NULL) {
-    *id = getMethodID(env, klass, name, signature);
-    if (*id == NULL) {
-      return JNI_FALSE;
-    }
-  }
-  return JNI_TRUE;
-}
-
-
-jboolean
-getFieldID(jfieldID* id, JNIEnv* env, jobject object,
-	   const char* name, const char* signature) {
-  if (*id == NULL) {
-    *id = getFieldID(env, object, name, signature);
-    if (*id == NULL) {
-      return JNI_FALSE;
-    }
-  }
-  return JNI_TRUE;
-}
-
-
-jboolean
-getFieldID(jfieldID* id, JNIEnv* env, jclass klass,
-	   const char* name, const char* signature) {
-  if (*id == NULL) {
-    *id = getFieldID(env, klass, name, signature);
-    if (*id == NULL) {
-      return JNI_FALSE;
-    }
-  }
-  return JNI_TRUE;
-}
-
-jboolean
-getStaticMethodID(jmethodID* id, JNIEnv* env, jobject object,
-		  const char* name, const char* signature) {
-  if (*id == NULL) {
-    *id = getStaticMethodID(env, object, name, signature);
-    if (*id == NULL) {
-      return JNI_FALSE;
-    }
-  }
-  return JNI_TRUE;
-}
-
-jboolean
-getStaticMethodID(jmethodID* id, JNIEnv* env, jclass klass,
-		  const char* name, const char* signature) {
-  if (*id == NULL) {
-    *id = getStaticMethodID(env, klass, name, signature);
-    if (*id == NULL) {
-      return JNI_FALSE;
-    }
-  }
-  return JNI_TRUE;
-}
-
-
-jboolean
-getStaticFieldID(jfieldID* id, JNIEnv* env, jobject object,
-		 const char* name, const char* signature) {
-  if (*id == NULL) {
-    *id = getStaticFieldID(env, object, name, signature);
-    if (*id == NULL) {
-      return JNI_FALSE;
-    }
-  }
-  return JNI_TRUE;
-}
-
-
-jboolean
-getStaticFieldID(jfieldID* id, JNIEnv* env, jclass klass,
-		 const char* name, const char* signature) {
-  if (*id == NULL) {
-    *id = getStaticFieldID(env, klass, name, signature);
-    if (*id == NULL) {
-      return JNI_FALSE;
-    }
-  }
-  return JNI_TRUE;
-}
diff --git a/frysk-sys/frysk/jni/members.hxx b/frysk-sys/frysk/jni/members.hxx
deleted file mode 100644
index 3f28942..0000000
--- a/frysk-sys/frysk/jni/members.hxx
+++ /dev/null
@@ -1,96 +0,0 @@
-// This file is part of the program FRYSK.
-//
-// Copyright 2008, Red Hat Inc.
-//
-// FRYSK is free software; you can redistribute it and/or modify it
-// under the terms of the GNU General Public License as published by
-// the Free Software Foundation; version 2 of the License.
-//
-// FRYSK is distributed in the hope that it will be useful, but
-// WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// General Public License for more details.
-// 
-// You should have received a copy of the GNU General Public License
-// along with FRYSK; if not, write to the Free Software Foundation,
-// Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
-// 
-// In addition, as a special exception, Red Hat, Inc. gives You the
-// additional right to link the code of FRYSK with code not covered
-// under the GNU General Public License ("Non-GPL Code") and to
-// distribute linked combinations including the two, subject to the
-// limitations in this paragraph. Non-GPL Code permitted under this
-// exception must only link to the code of FRYSK through those well
-// defined interfaces identified in the file named EXCEPTION found in
-// the source code files (the "Approved Interfaces"). The files of
-// Non-GPL Code may instantiate templates or use macros or inline
-// functions from the Approved Interfaces without causing the
-// resulting work to be covered by the GNU General Public
-// License. Only Red Hat, Inc. may make changes or additions to the
-// list of Approved Interfaces. You must obey the GNU General Public
-// License in all respects for all of the FRYSK code and other code
-// used in conjunction with FRYSK except the Non-GPL Code covered by
-// this exception. If you modify this file, you may extend this
-// exception to your version of the file, but you are not obligated to
-// do so. If you do not wish to provide this exception without
-// modification, you must delete this exception statement from your
-// version and license this file solely under the GPL without
-// exception.
-
-/**
- * These methods either return the requested ID; or print a message to
- * stderr, and then return NULL.
- */
-
-extern jmethodID getMethodID(JNIEnv* env, jobject object,
-			     const char* name, const char* signature);
-
-extern jmethodID getMethodID(JNIEnv* env, jclass klass,
-			     const char* name, const char* signature);
-
-extern jfieldID getFieldID(JNIEnv* env, jobject object,
-			   const char* name, const char* signature);
-
-extern jfieldID getFieldID(JNIEnv* env, jclass klass,
-			   const char* name, const char* signature);
-
-extern jmethodID getStaticMethodID(JNIEnv* env, jobject object,
-				   const char* name, const char* signature);
-
-extern jmethodID getStaticMethodID(JNIEnv* env, jclass klass,
-				   const char* name, const char* signature);
-
-extern jfieldID getStaticFieldID(JNIEnv* env, jobject object,
-				 const char* name, const char* signature);
-
-extern jfieldID getStaticFieldID(JNIEnv* env, jclass klass,
-				 const char* name, const char* signature);
-
-/**
- * These methods are similar, but instead of returning the ID they
- * update the ID parameter, and return false if the update fails.
- */
-
-extern jboolean getMethodID(jmethodID* id, JNIEnv* env, jobject object,
-			    const char* name, const char* signature);
-
-extern jboolean getMethodID(jmethodID* id, JNIEnv* env, jclass klass,
-			    const char* name, const char* signature);
-
-extern jboolean getFieldID(jfieldID* id, JNIEnv* env, jobject object,
-			   const char* name, const char* signature);
-
-extern jboolean getFieldID(jfieldID* id, JNIEnv* env, jclass klass,
-			   const char* name, const char* signature);
-
-extern jboolean getStaticMethodID(jmethodID* id, JNIEnv* env, jobject object,
-				  const char* name, const char* signature);
-
-extern jboolean getStaticMethodID(jmethodID* id, JNIEnv* env, jclass klass,
-				  const char* name, const char* signature);
-
-extern jboolean getStaticFieldID(jfieldID* id, JNIEnv* env, jobject object,
-				 const char* name, const char* signature);
-
-extern jboolean getStaticFieldID(jfieldID* id, JNIEnv* env, jclass klass,
-				 const char* name, const char* signature);
diff --git a/frysk-sys/frysk/rsl/ChangeLog b/frysk-sys/frysk/rsl/ChangeLog
index 1977571..3dd5bb3 100644
--- a/frysk-sys/frysk/rsl/ChangeLog
+++ b/frysk-sys/frysk/rsl/ChangeLog
@@ -1,3 +1,8 @@
+2008-05-01  Andrew Cagney  <cagney@redhat.com>
+
+	* jni/Log.cxx: Re-implement using jnixx generated stubs.
+	* jni/Log.hxx: Ditto.
+
 2008-04-16  Andrew Cagney  <cagney@redhat.com>
 
 	* jni/Log.cxx: Use members.hxx, and print.hxx.
diff --git a/frysk-sys/frysk/rsl/jni/Log.cxx b/frysk-sys/frysk/rsl/jni/Log.cxx
index ee2e70d..635c7ac 100644
--- a/frysk-sys/frysk/rsl/jni/Log.cxx
+++ b/frysk-sys/frysk/rsl/jni/Log.cxx
@@ -40,73 +40,47 @@
 #include <stdarg.h>
 #include <stdlib.h>
 
-#include <jni.h>
+#include "frysk/jni/xx.hxx"
+#include "frysk/rsl/Log-jni.hxx"
 
 #include "frysk/jni/print.hxx"
-#include "frysk/jni/members.hxx"
 #include "frysk/rsl/jni/Log.hxx"
 
-static bool
-logging(JNIEnv* env, jobject logger) {
-  static jmethodID loggingID = NULL;
-  if (!getMethodID(&loggingID, env, logger, "logging", "()B"))
-    return false;
-  jboolean result = env->CallBooleanMethod(logger, loggingID);
-  if (env->ExceptionCheck())
-    return false;
-  return result;
-}
-
-static void
-log(JNIEnv* env, jobject logger, jstring msg) {
-  static jmethodID logID = NULL;
-  if (!getMethodID(&logID, env, logger, "log", "(Ljava/lang/String;)V"))
-    return;
-  env->CallVoidMethod(logger, logID, msg);
-}
-
 void
-logf(JNIEnv *env, jobject logger, const char* format, ...) {
-  if (!logging(env, logger))
+logf(JNIEnv *env, frysk::rsl::Log* logger, const char* format, ...) {
+  if (!frysk::rsl::Log::logging(env, logger))
     return;
   va_list ap;
   va_start(ap, format);
   jstring message = vajprintf(env, format, ap);
-  if (message != NULL)
-    log(env, logger, message);
+  frysk::rsl::Log::log(env, logger, message);
   va_end(ap);
 }
 
 void
-logf(JNIEnv *env, jobject logger, jobject object, const char* format, ...) {
-  if (!logging(env, logger))
+logf(JNIEnv *env, frysk::rsl::Log* logger, jobject object,
+     const char* format, ...) {
+  if (!frysk::rsl::Log::logging(env, logger))
     return;
   va_list ap;
   va_start(ap, format);
   jstring message = vajprintf(env, format, ap);
   if (message != NULL)
-    log(env, logger, message);
+    frysk::rsl::Log::log(env, logger, message);
   va_end(ap);
 }
 
 void
-log(JNIEnv *env, jobject logger, const char* p1, jobject p2) {
-  if (!logging(env, logger))
+log(JNIEnv *env, frysk::rsl::Log* logger, const char* p1, jobject p2) {
+  if (!frysk::rsl::Log::logging(env, logger))
     return;
-  static jmethodID logID = NULL;
-  if (!getMethodID(&logID, env, logger, "log",
-		   "(Ljava/lang/String;Ljava/lang/Object;)V"))
-    return;
-  env->CallVoidMethod(logger, logID, env->NewStringUTF(p1), p2);


hooks/post-receive
--
frysk system monitor/debugger


                 reply	other threads:[~2008-05-01 15:58 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20080501155840.27396.qmail@sourceware.org \
    --to=cagney@sourceware.org \
    --cc=frysk-cvs@sourceware.org \
    --cc=frysk@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).