[Java-gnome-developer] CVS: Fixes, fixes, fixes
Brought to you by:
afcowie
From: Santeri P. <sa...@ik...> - 2001-04-06 15:17:12
|
Attached is a patch against current CVS head, as well as well as four new files (src/code/glue/GdkWindow.[ch], src/code/java/GdkWindow.java, tools/StructConstructorSpec.java). These things have been changed (not all documented, though): - Added (object) argument to argspec, look for example the gdk_color_parse routine which takes the GdkColor* as _second_ argument, not the first one.. now it is converted satisfyingly into a object method parse(). See also gdk_draw_* which now are associated with GdkWindow as methods, not static routines! (BTW: Shouldn't they be associated with GdkDrawable, and not GdkWindow?) This required changes in ArgumentSpec and ArgumentList handling. The first argument is no longer special in the argument list (withoutFirst() is removed), and the getIsObject() and getExplicitObject() [maybe these should be renamed?] determine the actual object argument of the functions. - Added (struct-constructor) as optional fourth field into (define-object). This has the effect of creating a g_malloc0() constructor for the type. This is usable for object types which do not sport a "natural" constructor (_new), and are used in Glib as normal structs. This allows allocation and manipulation of such types. See (define-object GdkColor) as an example. The StructConstructorSpec.java is part of this change. There's probably cleaner way my using existing classes, but I couldn't and didn't want to check how that could've been done. - Fixed type conversion problems in getters.. these might not be the most beautiful way of doing them, but at least I got rid of tons of type problems in C. Mostly the problem was associated with the getter layout of: JNIEXPORT jobject JNICALL Java_gnu_gdk_GdkEventExpose_getWindow ( JNIEnv *env, jobject obj) { GdkEventExpose *cptr = peerOfBaseObject (env, obj); { jclass result_jc = (*env)->FindClass (env, "gnu/gdk/GdkWindow"); jobject result = makeBaseObjectSubclass (env, result_jc, ( GdkEventExpose_get_window (cptr))); return result; } } GdkWindow * GdkEventExpose_get_window (GdkEventExpose * cptr) { return cptr->window; } Previously the return type of GdkEventExpose_get_window was jobject, not GdkWindow *. I think it's better to keep the C routines with their "natural" types, and let the JNI wrapper perform the casting (as it currently does anyway). - Added dependencies for the generated files also on the converter classes, so if you change the generator code the generated code will be generated automatically. - Changed some object fields to (read-write), since they're that. This was done only on the object types that I happened to need to have settable fields, so the results are not complete. - Added some misc. static GDK routines. - LibGlade.java and LibGladeGnome.java tried to use type named "Map" to store Hashtables. Changed to use "Hashtable" instead. - Changed FileEmitter to modify the target java/c/header file only if the "new" version differs from the old one (sans the "Generation date:" part). Very useful, since only those files that are really modified are touched, and thus files not really modified are not recompiled at all. Saves a lot of time. Indentation of the changes is totally out of style wrt/ to the style used in the current sources, since I could not figure out which c-style (in emacs) it would be equivalent to. With these changes I can now successfully make something like the following: GdkColor c = new GdkColor(); c.parse("red"); getColormap().allocColor(c); gc.setForeground(c); getWindow().drawRectangle(...); Okay. I hope I remembered to include all necessary files etc.. -- sa...@ik... I have become death, destroyer of the worlds. |