[Java-gnome-developer] Julian's contributions
Brought to you by:
afcowie
|
From: Jeffrey M. <ku...@ne...> - 2001-03-30 02:27:32
|
First of all let me say thank you Julian for all of the patches.
I appreciate all of the help I can get. All of those who are
listening I am looking for volunteers. If you have the time and
interest I need you!
Sorry it has taken me so long to respond to all of your emails.
I will address all of them here.
1) Subject: Freezing on runtime exception within signal handler
Great addition. This code has been added and is now in cvs.
2) Subject: GtkContainer::Children()
In this email you stated that you don't know where to update the
generator to fix this problem. This has been fixed and is now
in cvs. Let me explain how I fixed this problem and at the same
time explain a nice feature of the code generator.
In the src/tools directory you will find a file named JNIProps.txt.
This file allows you to define how code is generated for specific
scheme types that are used in the defs file. The file is very well
commented and is easy to follow. The entry for "GList" was as follows:
GList.javaType: gnu.gdk.GListString
GList.nativeType: jobject
GList.nativeUnwrap: GList *$TO = peerOfGListString (env, $FROM);
GList.nativeWrap: \
$CLEANUP \
return makeGListString (env, ($CALL));
GList.rawType: GList *
As you can see it assumed that GLists only contained strings. I changed
this scheme type to GListString and made the cooresponding changes
in the defs file. I then added a new set of entries for GList. The
new entries for GList are as follows:
GList.javaType: gnu.gtk.GtkWidget[]
GList.nativeType: jobjectArray
GList.nativeUnwrap: \
GList *$TO = NULL; \
jsize len = (*env)->GetArrayLength(env, $FROM); \
int i; \
\n-\n \
for (i = 0; i < len; i++) { \
GtkWidget *widget = (*env)->GetObjectArrayElement(env, $FROM, i);\
$TO = g_list_append($TO, widget); \
}
GList.nativeWrap: \
GList *list = $CALL; \
int childrenLength = g_list_length(list); \
jclass widgetCls = (*env)->FindClass(env, "gnu/gtk/GtkWidget"); \
jobjectArray array = NULL; \
jobject widget; \
GtkWidget *nativeWidget; \
if (childrenLength > 0) { \
int i; \
for (i = 0; i < childrenLength; i++) { \
nativeWidget = (GtkWidget*)g_list_nth_data(list, i); \
widget = makeBaseObjectClass(env, nativeWidget); \
if (array == NULL) \
array = (*env)->NewObjectArray(env, childrenLength, \
widgetCls, widget); \
else \
(*env)->SetObjectArrayElement(env, array, i, widget); \
} \
} \
$CLEANUP \
return array;
GList.rawType: GList *
This mechanism makes it very simple to extend the capabilities
of the generator by defining new scheme types and adding the
appropriate code in this text file.
3) Subject: parent missing from GtkWidget
This has been fixed and is also in cvs. I will explain how I
fixed this problem and also introduce you to another feature of
the generator. The generator is far from perfect at this time.
There are many instances when the generator is unable to generate
the appropriate code. To get around this I added the ability to
insert manual code into the generated code. In the src/code
directory you will find two additional directories; java and glue. T
These directories are where you should place manual code. The
code found in these files will be inserted into the end for the
code generated by the code generator. I added the file GtkWidget.java
to the java directory and GtkWidget.h and GtkWidget.c to the glue
directory. These files contain the fix to you reported problem.
4) Subject: parent missing from GtkWidget -
> But what I can't quite figure out is why the java objects are
> created as GtkWidgets instead of being just returned as GtkWidgets.
This is a very good point. I have been meaning to make this change
but it hasn't been my highest priority. I have just added a method
to BaseObject called makeBaseObjectClass. This method detects the
correct Gtk type and builds a peer for it much the same way as
the makeBaseObjectSubclass. I will be updating the code generator
to use this method where appropriate over the next few days.
I hope I have answered you questions and addressed all of you
issues. If not please let me know.
-Jeff
|