This is the mail archive of the java-patches@gcc.gnu.org mailing list for the Java project.
| Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
|---|---|---|
| Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |
| Other format: | [Raw text] | |
Hi,
Here is a patch to resync the ansi, pedantic setup of GNU Classpath with
the JNI gtk-peer c files in libgcj. Some of this has already been
reported to this list. Since I didn't have a current libgcj checkout at
that time never made it into the tree.
2004-04-17 Mark Wielaard <mark@klomp.org>
* Makefile.am (PEDANTIC_CFLAGS): New -ansi -pedantic -Wall
-Wno-long-long flags variable.
(gtk_c_files): Use PEDANTIC_CFLAGS.
* Makefile.in: Regenerated.
* jni/classpath/jcl.c: Changed C++ comments into C comments. Removed
commented out code.
* jni/gtk-peer/gnu_java_awt_peer_gtk_GtkCheckboxPeer.c: Likewise.
* jni/gtk-peer/gnu_java_awt_peer_gtk_GtkComponentPeer.c: Likewise.
* jni/gtk-peer/gnu_java_awt_peer_gtk_GtkEvents.c: Likewise.
* jni/gtk-peer/gnu_java_awt_peer_gtk_GtkFileDialogPeer.c: Likewise.
* jni/gtk-peer/gnu_java_awt_peer_gtk_GtkListPeer.c: Likewise.
* jni/gtk-peer/gnu_java_awt_peer_gtk_GtkMenuPeer.c: Likewise.
* jni/gtk-peer/gnu_java_awt_peer_gtk_GtkTextComponentPeer.c: Likewise.
* jni/gtk-peer/gthread-jni.c: Likewise.
(maybe_rethrow): Explicitly malloc and free buf.
The special PEDANTIC_CFLAGS setup as used in GNU Classpath is only
enforced on the jni gtk-peers C source files in libgcj. This should make
merging and syncing sources with GNU Classpath easier. Something similar
should probably also go onto the gui-branch (which I don't have checked
out, so someone else should do that).
OK, to commit?
Cheers,
Mark
Index: Makefile.am
===================================================================
RCS file: /cvs/gcc/gcc/libjava/Makefile.am,v
retrieving revision 1.369
diff -u -r1.369 Makefile.am
--- Makefile.am 16 Apr 2004 18:44:40 -0000 1.369
+++ Makefile.am 17 Apr 2004 18:21:08 -0000
@@ -120,6 +120,9 @@
AM_CFLAGS = @LIBGCJ_CFLAGS@
endif
+## Extra CFLAGS used for JNI C sources shared with GNU Classpath.
+PEDANTIC_CFLAGS = -ansi -pedantic -Wall -Wno-long-long
+
JCFLAGS = -g
JC1FLAGS = @LIBGCJ_JAVAFLAGS@ $(GCJFLAGS)
@@ -471,9 +474,11 @@
$(c_files): java/lang/fdlibm.h java/lang/ieeefp.h java/lang/mprec.h
## FIXME: see above
+## These JNI C files are shared with GNU Classpath which needs PEDANTIC_CFLAGS.
$(gtk_c_files): %.lo: %.c
$(LTCOMPILE) -c -Ijniinclude -I$(srcdir)/jni/classpath -I$(srcdir)/jni/gtk-peer \
- $(GTK_CFLAGS) $(LIBART_CFLAGS) $(CAIRO_LIBS) $(PANGOFT2_LIBS) -o $@ $<
+ $(PEDANTIC_CFLAGS) $(GTK_CFLAGS) $(LIBART_CFLAGS) \
+ $(CAIRO_LIBS) $(PANGOFT2_LIBS) -o $@ $<
$(gtk_c_files): $(gtk_c_headers)
Index: jni/classpath/jcl.c
===================================================================
RCS file: /cvs/gcc/gcc/libjava/jni/classpath/jcl.c,v
retrieving revision 1.3
diff -u -r1.3 jcl.c
--- jni/classpath/jcl.c 16 Apr 2004 18:44:45 -0000 1.3
+++ jni/classpath/jcl.c 17 Apr 2004 18:21:08 -0000
@@ -43,7 +43,11 @@
#define __attribute__(x) /* nothing */
#endif
-static char errstr[4098]; // this way the memory is pre-allocated, so that we do not have to worry if we are out of memory.
+/*
+ * This way the memory is pre-allocated, so that we do not have to worry
+ * if we are out of memory.
+ */
+static char errstr[4098];
JNIEXPORT void JNICALL JCL_ThrowException(JNIEnv * env, char * className, char * errMsg) {
jclass excClass;
Index: jni/gtk-peer/gnu_java_awt_peer_gtk_GtkCheckboxPeer.c
===================================================================
RCS file: /cvs/gcc/gcc/libjava/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkCheckboxPeer.c,v
retrieving revision 1.5
diff -u -r1.5 gnu_java_awt_peer_gtk_GtkCheckboxPeer.c
--- jni/gtk-peer/gnu_java_awt_peer_gtk_GtkCheckboxPeer.c 17 Mar 2004 21:29:01 -0000 1.5
+++ jni/gtk-peer/gnu_java_awt_peer_gtk_GtkCheckboxPeer.c 17 Apr 2004 18:21:08 -0000
@@ -1,5 +1,5 @@
/* gtkcheckboxpeer.c -- Native implementation of GtkCheckboxPeer
- Copyright (C) 1998, 1999, 2002, 2003 Free Software Foundation, Inc.
+ Copyright (C) 1998, 1999, 2002, 2003, 2004 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -230,7 +230,6 @@
static void
item_toggled (GtkToggleButton *item, jobject peer)
{
- //g_print ("toggled\n");
(*gdk_env)->CallVoidMethod (gdk_env, peer,
postItemEventID,
peer,
Index: jni/gtk-peer/gnu_java_awt_peer_gtk_GtkComponentPeer.c
===================================================================
RCS file: /cvs/gcc/gcc/libjava/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkComponentPeer.c,v
retrieving revision 1.17
diff -u -r1.17 gnu_java_awt_peer_gtk_GtkComponentPeer.c
--- jni/gtk-peer/gnu_java_awt_peer_gtk_GtkComponentPeer.c 16 Apr 2004 18:44:45 -0000 1.17
+++ jni/gtk-peer/gnu_java_awt_peer_gtk_GtkComponentPeer.c 17 Apr 2004 18:21:08 -0000
@@ -1,5 +1,5 @@
/* gtkcomponentpeer.c -- Native implementation of GtkComponentPeer
- Copyright (C) 1998, 1999, 2002 Free Software Foundation, Inc.
+ Copyright (C) 1998, 1999, 2002, 2004 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -136,7 +136,7 @@
ptr = NSA_GET_PTR (env, obj);
gdk_threads_enter ();
- // gtk_widget_grab_focus (GTK_WIDGET (ptr));
+ /* XXX gtk_widget_grab_focus (GTK_WIDGET (ptr)); */
gdk_threads_leave ();
}
@@ -610,10 +610,12 @@
gboolean
filter_expose_event_handler (GtkWidget *widget, GdkEvent *event, jobject peer)
{
- // Prevent the default event handler from getting this signal if applicable
- // FIXME: I came up with these filters by looking for patterns in the unwanted
- // expose events that are fed back to us from gtk/X. Perhaps there is
- // a way to prevent them from occuring in the first place.
+ /*
+ * Prevent the default event handler from getting this signal if applicable
+ * FIXME: I came up with these filters by looking for patterns in the unwanted
+ * expose events that are fed back to us from gtk/X. Perhaps there is
+ * a way to prevent them from occuring in the first place.
+ */
if (event->type == GDK_EXPOSE && (!GTK_IS_LAYOUT(widget)
|| event->any.window != widget->window))
{
@@ -622,8 +624,8 @@
}
else
{
- // There may be non-expose events that are triggered while we're
- // painting a heavyweight peer.
+ /* There may be non-expose events that are triggered while we're
+ painting a heavyweight peer. */
return pre_event_handler(widget, event, peer);
}
}
@@ -641,8 +643,8 @@
gdk_threads_enter ();
- // GtkFramePeer is built as a GtkLayout inside a GtkVBox inside a GtkWindow.
- // Events go to the GtkLayout layer, so we filter them there.
+ /* GtkFramePeer is built as a GtkLayout inside a GtkVBox inside a GtkWindow.
+ Events go to the GtkLayout layer, so we filter them there. */
if (GTK_IS_WINDOW(ptr))
{
children = gtk_container_get_children(GTK_CONTAINER(ptr));
@@ -685,8 +687,8 @@
gdk_threads_enter ();
- // GtkFramePeer is built as a GtkLayout inside a GtkVBox inside a GtkWindow.
- // Events go to the GtkLayout layer, so we filter them there.
+ /* GtkFramePeer is built as a GtkLayout inside a GtkVBox inside a GtkWindow.
+ Events go to the GtkLayout layer, so we filter them there. */
if (GTK_IS_WINDOW(ptr))
{
children = gtk_container_get_children(GTK_CONTAINER(ptr));
Index: jni/gtk-peer/gnu_java_awt_peer_gtk_GtkEvents.c
===================================================================
RCS file: /cvs/gcc/gcc/libjava/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkEvents.c,v
retrieving revision 1.20
diff -u -r1.20 gnu_java_awt_peer_gtk_GtkEvents.c
--- jni/gtk-peer/gnu_java_awt_peer_gtk_GtkEvents.c 17 Mar 2004 21:29:01 -0000 1.20
+++ jni/gtk-peer/gnu_java_awt_peer_gtk_GtkEvents.c 17 Apr 2004 18:21:08 -0000
@@ -1,5 +1,5 @@
/* gtkevents.c -- GDK/GTK event handlers
- Copyright (C) 1998, 1999, 2002 Free Software Foundation, Inc.
+ Copyright (C) 1998, 1999, 2002, 2004 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -934,9 +934,9 @@
click_count,
JNI_FALSE);
- // Generate an AWT click event only if the release occured in the
- // window it was pressed in, and the mouse has not been dragged since
- // the last time it was pressed.
+ /* Generate an AWT click event only if the release occured in the
+ window it was pressed in, and the mouse has not been dragged since
+ the last time it was pressed. */
gdk_window_get_size (event->any.window, &width, &height);
if (! hasBeenDragged
&& event->button.x >= 0
@@ -1038,11 +1038,11 @@
break;
case GDK_EXPOSE:
{
- // This filters out unwanted feedback expose events from gtk/X
- // when we explictly invalidate and update heavyweight components,
- // thus avoiding an infinite loop.
- // FIXME: I'm not quite sure why we're getting these expose events.
- // Maybe there is a way to avoid them?
+ /* This filters out unwanted feedback expose events from gtk/X
+ when we explictly invalidate and update heavyweight components,
+ thus avoiding an infinite loop.
+ FIXME: I'm not quite sure why we're getting these expose events.
+ Maybe there is a way to avoid them? */
if((event->any.window == widget->window && event->any.send_event)
|| GTK_IS_LAYOUT(widget))
{
@@ -1181,7 +1181,6 @@
| GDK_KEY_PRESS_MASK
| GDK_FOCUS_CHANGE_MASK);
- // g_print("storing obj %p property on window %p\n", obj, window);
gdk_property_change (window,
addr_atom,
type_atom,
@@ -1196,10 +1195,8 @@
{
va_list ap;
jobject *obj;
- //void *ptr = NSA_GET_PTR (env, peer_obj);
obj = NSA_GET_GLOBAL_REF (env, peer_obj);
- //g_print("Connection obj %s\n", gtk_widget_get_name (GTK_WIDGET (ptr)));
g_assert (obj);
va_start (ap, nwindows);
Index: jni/gtk-peer/gnu_java_awt_peer_gtk_GtkFileDialogPeer.c
===================================================================
RCS file: /cvs/gcc/gcc/libjava/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkFileDialogPeer.c,v
retrieving revision 1.5
diff -u -r1.5 gnu_java_awt_peer_gtk_GtkFileDialogPeer.c
--- jni/gtk-peer/gnu_java_awt_peer_gtk_GtkFileDialogPeer.c 16 Apr 2004 18:44:45 -0000 1.5
+++ jni/gtk-peer/gnu_java_awt_peer_gtk_GtkFileDialogPeer.c 17 Apr 2004 18:21:08 -0000
@@ -1,5 +1,5 @@
/* gtkfiledialogpeer.c -- Native implementation of GtkFileDialogPeer
- Copyright (C) 1998, 1999, 2002 Free Software Foundation, Inc.
+ Copyright (C) 1998, 1999, 2002, 2004 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -156,7 +156,7 @@
static jmethodID disposeID;
void *ptr;
- // We only need this for the case when the user closed the window
+ /* We only need this for the case when the user closed the window. */
if (responseId != GTK_RESPONSE_DELETE_EVENT)
return;
Index: jni/gtk-peer/gnu_java_awt_peer_gtk_GtkListPeer.c
===================================================================
RCS file: /cvs/gcc/gcc/libjava/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkListPeer.c,v
retrieving revision 1.7
diff -u -r1.7 gnu_java_awt_peer_gtk_GtkListPeer.c
--- jni/gtk-peer/gnu_java_awt_peer_gtk_GtkListPeer.c 13 Dec 2003 01:15:47 -0000 1.7
+++ jni/gtk-peer/gnu_java_awt_peer_gtk_GtkListPeer.c 17 Apr 2004 18:21:08 -0000
@@ -1,5 +1,5 @@
/* gtklistpeer.c -- Native implementation of GtkListPeer
- Copyright (C) 1998, 1999 Free Software Foundation, Inc.
+ Copyright (C) 1998, 1999, 2004 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -324,7 +324,6 @@
GdkEventButton *event __attribute__((unused)),
jobject peer_obj)
{
- //g_print ("select_row\n");
(*gdk_env)->CallVoidMethod (gdk_env, peer_obj,
postListItemEventID,
row,
@@ -338,7 +337,6 @@
GdkEventButton *event __attribute__((unused)),
jobject peer_obj)
{
- //g_print ("unselect_row\n");
(*gdk_env)->CallVoidMethod (gdk_env, peer_obj,
postListItemEventID,
row,
Index: jni/gtk-peer/gnu_java_awt_peer_gtk_GtkMenuPeer.c
===================================================================
RCS file: /cvs/gcc/gcc/libjava/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkMenuPeer.c,v
retrieving revision 1.5
diff -u -r1.5 gnu_java_awt_peer_gtk_GtkMenuPeer.c
--- jni/gtk-peer/gnu_java_awt_peer_gtk_GtkMenuPeer.c 16 Apr 2004 18:44:45 -0000 1.5
+++ jni/gtk-peer/gnu_java_awt_peer_gtk_GtkMenuPeer.c 17 Apr 2004 18:21:08 -0000
@@ -1,5 +1,5 @@
/* gtkmenupeer.c -- Native implementation of GtkMenuPeer
- Copyright (C) 1999 Free Software Foundation, Inc.
+ Copyright (C) 1999, 2004 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -108,7 +108,7 @@
gtk_menu_item_set_submenu (GTK_MENU_ITEM (menu_title), menu);
- // Allow this menu to grab the pointer.
+ /* Allow this menu to grab the pointer. */
GtkWidget *toplevel = gtk_widget_get_toplevel (menu);
if (GTK_IS_WINDOW (toplevel))
{
Index: jni/gtk-peer/gnu_java_awt_peer_gtk_GtkTextComponentPeer.c
===================================================================
RCS file: /cvs/gcc/gcc/libjava/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkTextComponentPeer.c,v
retrieving revision 1.11
diff -u -r1.11 gnu_java_awt_peer_gtk_GtkTextComponentPeer.c
--- jni/gtk-peer/gnu_java_awt_peer_gtk_GtkTextComponentPeer.c 13 Dec 2003 01:15:47 -0000 1.11
+++ jni/gtk-peer/gnu_java_awt_peer_gtk_GtkTextComponentPeer.c 17 Apr 2004 18:21:08 -0000
@@ -1,5 +1,5 @@
/* gtktextcomponentpeer.c -- Native implementation of GtkTextComponentPeer
- Copyright (C) 1998, 1999 Free Software Foundation, Inc.
+ Copyright (C) 1998, 1999, 2004 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -112,8 +112,8 @@
{
void *ptr;
int pos = 0;
- GtkEditable *editable; // type of GtkEntry (TextField)
- GtkWidget *text = NULL; // type of GtkTextView (TextArea)
+ GtkEditable *editable; /* type of GtkEntry (TextField) */
+ GtkWidget *text = NULL; /* type of GtkTextView (TextArea) */
GtkTextBuffer *buf;
GtkTextMark *mark;
GtkTextIter iter;
@@ -157,8 +157,8 @@
(JNIEnv *env, jobject obj, jint pos)
{
void *ptr;
- GtkEditable *editable; // type of GtkEntry (TextField)
- GtkWidget *text = NULL; // type of GtkTextView (TextArea)
+ GtkEditable *editable; /* type of GtkEntry (TextField) */
+ GtkWidget *text = NULL; /* type of GtkTextView (TextArea) */
GtkTextBuffer *buf;
GtkTextIter iter;
@@ -198,8 +198,8 @@
{
void *ptr;
int pos = 0;
- GtkEditable *editable; // type of GtkEntry (TextField)
- GtkWidget *text = NULL; // type of GtkTextView (TextArea)
+ GtkEditable *editable; /* type of GtkEntry (TextField) */
+ GtkWidget *text = NULL; /* type of GtkTextView (TextArea) */
GtkTextBuffer *buf;
GtkTextIter start;
GtkTextIter end;
@@ -255,8 +255,8 @@
{
void *ptr;
int pos = 0;
- GtkEditable *editable; // type of GtkEntry (TextField)
- GtkWidget *text = NULL; // type of GtkTextView (TextArea)
+ GtkEditable *editable; /* type of GtkEntry (TextField) */
+ GtkWidget *text = NULL; /* type of GtkTextView (TextArea) */
GtkTextBuffer *buf;
GtkTextIter start;
GtkTextIter end;
@@ -311,8 +311,8 @@
(JNIEnv *env, jobject obj, jint start, jint end)
{
void *ptr;
- GtkEditable *editable; // type of GtkEntry (TextField)
- GtkWidget *text = NULL; // type of GtkTextView (TextArea)
+ GtkEditable *editable; /* type of GtkEntry (TextField) */
+ GtkWidget *text = NULL; /* type of GtkTextView (TextArea) */
GtkTextBuffer *buf;
GtkTextIter iter;
@@ -357,8 +357,8 @@
(JNIEnv *env, jobject obj, jboolean state)
{
void *ptr;
- GtkEditable *editable; // type of GtkEntry (TextField)
- GtkWidget *text = NULL; // type of GtkTextView (TextArea)
+ GtkEditable *editable; /* type of GtkEntry (TextField) */
+ GtkWidget *text = NULL; /* type of GtkTextView (TextArea) */
ptr = NSA_GET_PTR (env, obj);
@@ -396,8 +396,8 @@
void *ptr;
char *contents = NULL;
jstring jcontents;
- GtkEditable *editable; // type of GtkEntry (TextField)
- GtkWidget *text = NULL; // type of GtkTextView (TextArea)
+ GtkEditable *editable; /* type of GtkEntry (TextField) */
+ GtkWidget *text = NULL; /* type of GtkTextView (TextArea) */
GtkTextBuffer *buf;
GtkTextIter start, end;
@@ -444,7 +444,7 @@
{
void *ptr;
const char *str;
- GtkWidget *text = NULL; // type of GtkTextView (TextArea)
+ GtkWidget *text = NULL; /* type of GtkTextView (TextArea) */
GtkTextBuffer *buf;
ptr = NSA_GET_PTR (env, obj);
Index: jni/gtk-peer/gthread-jni.c
===================================================================
RCS file: /cvs/gcc/gcc/libjava/jni/gtk-peer/gthread-jni.c,v
retrieving revision 1.3
diff -u -r1.3 gthread-jni.c
--- jni/gtk-peer/gthread-jni.c 8 Oct 2003 15:49:33 -0000 1.3
+++ jni/gtk-peer/gthread-jni.c 17 Apr 2004 18:21:08 -0000
@@ -1,5 +1,5 @@
/* gthread-jni.c -- JNI threading routines for GLIB
- Copyright (C) 1998 Free Software Foundation, Inc.
+ Copyright (C) 1998, 2004 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -91,28 +91,40 @@
static void maybe_rethrow(JNIEnv *gdk_env, char *message, char *file, int line) {
jthrowable cause;
- /* rethrow if an exception happened */
- if ((cause = (*gdk_env)->ExceptionOccurred(gdk_env)) != NULL) {
jstring jmessage;
- jclass obj_class;
+ jclass obj_class;
jobject obj;
jmethodID ctor;
+ int len;
+ char *buf;
- /* allocate local message in Java */
- int len = strlen(message) + strlen(file) + 25;
- char buf[ len ];
- bzero(buf, len);
- sprintf(buf, "%s (at %s:%d)", message, file, line);
- jmessage = (*gdk_env)->NewStringUTF(gdk_env, buf);
+ /* rethrow if an exception happened */
+ if ((cause = (*gdk_env)->ExceptionOccurred(gdk_env)) != NULL)
+ {
+
+ /* allocate local message in Java */
+ len = strlen(message) + strlen(file) + 25;
+ buf = (char *) malloc(len);
+ if (buf != NULL)
+ {
+ bzero(buf, len);
+ sprintf(buf, "%s (at %s:%d)", message, file, line);
+ jmessage = (*gdk_env)->NewStringUTF(gdk_env, buf);
+ free(buf);
+ }
+ else
+ jmessage = NULL;
- /* create RuntimeException wrapper object */
- obj_class = (*gdk_env)->FindClass (gdk_env, "java/lang/RuntimeException");
- ctor = (*gdk_env)->GetMethodID(gdk_env, obj_class, "<init>", "(Ljava/langString;Ljava/lang/Throwable)V");
- obj = (*gdk_env)->NewObject (gdk_env, obj_class, ctor, jmessage, cause);
-
- /* throw it */
- (*gdk_env)->Throw(gdk_env, (jthrowable)obj);
- }
+ /* create RuntimeException wrapper object */
+ obj_class = (*gdk_env)->FindClass (gdk_env,
+ "java/lang/RuntimeException");
+ ctor = (*gdk_env)->GetMethodID(gdk_env, obj_class, "<init>",
+ "(Ljava/langString;Ljava/lang/Throwable)V");
+ obj = (*gdk_env)->NewObject (gdk_env, obj_class, ctor, jmessage, cause);
+
+ /* throw it */
+ (*gdk_env)->Throw(gdk_env, (jthrowable)obj);
+ }
}
/* This macro is used to include a source location in the exception message */
@@ -204,7 +216,7 @@
static gboolean g_mutex_trylock_jni_impl
(GMutex *mutex __attribute__((unused)))
{
- // Shall we implement this in a JikesRVM-specific way under a flag?
+ /* XXX Shall we implement this in a VM-specific way under a flag? */
return FALSE;
}
Attachment:
signature.asc
Description: This is a digitally signed message part
| Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
|---|---|---|
| Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |