diff -rNu smalltalk-2.0.9.old/blox/gtk/BloxGTK.c smalltalk-2.0.9/blox/gtk/BloxGTK.c --- smalltalk-2.0.9.old/blox/gtk/BloxGTK.c 2002-07-14 04:45:57.000000000 -0700 +++ smalltalk-2.0.9/blox/gtk/BloxGTK.c 1969-12-31 16:00:00.000000000 -0800 @@ -1,94 +0,0 @@ -/*********************************************************************** - * - * Blox - * - * Standardized, Tk-based GUI widgets available for various window - * systems - Interface to Tcl - * - ***********************************************************************/ - -/*********************************************************************** - * - * Copyright 1988-92, 1994-95, 1999-2001 Free Software Foundation, Inc. - * XPM code is Copyright (C) 1989-94 GROUPE BULL - * Written by Paolo Bonzini. - * - * This file is part of GNU Smalltalk. - * - * GNU Smalltalk 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; either version 2, or (at your option) any later - * version. - * - * GNU Smalltalk 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 - * GNU Smalltalk; see the file COPYING. If not, write to the Free Software - * Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - * - * Here is the copyright notice for the XPM code: - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * GROUPE BULL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - * Except as contained in this notice, the name of GROUPE BULL shall not be - * used in advertising or otherwise to promote the sale, use or other dealings - * in this Software without prior written authorization from GROUPE BULL. - - ***********************************************************************/ - -#include "config.h" -#include "gstpub.h" -#include "alloc.h" - -#ifndef HAVE_TCLTK -#error Tcl/Tk 8.0 needed to install the GNU Smalltalk GUI -#endif - -#include -#include -#include -#include -#include - -#ifdef STDC_HEADERS -#include -#include -#endif - -static VMProxy *vmProxy; - -void -bloxGtkInit() -{ - int argc = 1; - gchar *argvArray[] = { "gst", NULL }; - gchar **argv = argvArray; - gtk_init (&argc, &argv); -} - - -void -gst_initModule(proxy) - VMProxy *proxy; -{ - vmProxy = proxy; - vmProxy->defineCFunc("bloxGtkInit", bloxGtkInit); -} diff -rNu smalltalk-2.0.9.old/blox/gtk/GtkDecl.st.in smalltalk-2.0.9/blox/gtk/GtkDecl.st.in --- smalltalk-2.0.9.old/blox/gtk/GtkDecl.st.in 2002-07-14 04:45:57.000000000 -0700 +++ smalltalk-2.0.9/blox/gtk/GtkDecl.st.in 2003-01-14 21:55:53.000000000 -0800 @@ -35,6 +35,7 @@ DLD addLibrary: 'libgdk'! DLD addLibrary: 'libgtk'! +DLD addModule: 'blox-gtk'! Blox addSubspace: #Gtk! Namespace current: Blox Gtk! @@ -80,6 +81,6 @@ poolDictionaries: '' category: 'Gtk'! -$ +$$ Namespace current: Smalltalk! diff -rNu smalltalk-2.0.9.old/blox/gtk/Makefile.am smalltalk-2.0.9/blox/gtk/Makefile.am --- smalltalk-2.0.9.old/blox/gtk/Makefile.am 2002-07-14 04:45:57.000000000 -0700 +++ smalltalk-2.0.9/blox/gtk/Makefile.am 2003-01-14 22:59:10.000000000 -0800 @@ -1,21 +1,23 @@ bloxgtkdir = $(pkgdatadir)/blox/gtk if HAVE_GTK -noinst_SCRIPTS = structs funcs make_enums +noinst_SCRIPTS = structs funcs make_enums make_signal_funcs make_callback_hash bloxgtk_DATA = GtkDecl.st -CLEANFILES = $(noinst_SCRIPTS) $(bloxgtk_DATA) +CLEANFILES = $(noinst_SCRIPTS) $(bloxgtk_DATA) $(BUILT_SOURCES) endif EXTRA_DIST = GtkDecl.st.in proof.st \ structs.awk funcs.awk make_enums.awk order.awk -EXTRA_LTLIBRARIES = libblox-gtk.la +EXTRA_LTLIBRARIES = blox-gtk.la pkglib_LTLIBRARIES = @MODULES_GTK@ -libblox_gtk_la_LDFLAGS = -module -rpath $(pkglibdir) -no-undefined \ - -release $(VERSION) -libblox_gtk_la_SOURCES = BloxGTK.c +blox_gtk_la_LDFLAGS = -module -rpath $(pkglibdir) -no-undefined \ + -release $(VERSION) --export-dynamic +blox_gtk_la_SOURCES = signal_funcs.c callback_hash.c blox-gtk.c +blox_gtk_la_LIBADD = $(GLIB_LIBS) -INCLUDES = -I$(top_srcdir)/libgst -I$(top_srcdir)/lib-src $(TCL_INCLUDES) + +INCLUDES = -I$(top_srcdir)/libgst -I$(top_srcdir)/lib-src -I$(top_srcdir)/libltdl $(TCL_INCLUDES) AM_CFLAGS = $(GLIB_CFLAGS) $(GTK_CFLAGS) @@ -69,31 +71,47 @@ structs: $(srcdir)/structs.awk funcs: $(srcdir)/funcs.awk make_enums: $(srcdir)/make_enums.awk +make_signal_funcs: $(srcdir)/make_signal_funcs.awk +make_callback_hash: $(srcdir)/make_callback_hash.awk order: $(srcdir)/order.awk # ------------------------------------- noinst_PROGRAMS = enums enums_SOURCES = enums.c -BUILT_SOURCES = enums.c +BUILT_SOURCES = enums.c blox-gtk.h signal_funcs.c callback_hash.c # ------------------------------------- GtkDecl.st: $(srcdir)/GtkDecl.st.in $(noinst_PROGRAMS) .order structs funcs (echo \"Don\'t modify this file, edit GtkDecl.st.in instead\!\"; \ - sed -ne '/\$/q' -e p $<; \ + sed -ne '/^\$$\$$/q' -e p $< && \ builddir=`pwd`; \ cd $(GTK_HEADERS) && \ $$builddir/structs `cat $$builddir/.order` && \ $$builddir/enums && \ - $$builddir/funcs `cat $$builddir/.order`; - sed '1,/\$/d' $<) > $@ + $$builddir/funcs `cat $$builddir/.order` && \ + sed '1,/^\$$\$$/d' $$builddir/$<) > $@ enums.c: .order make_enums builddir=`pwd`; \ cd $(GTK_HEADERS) && \ $$builddir/make_enums `cat $$builddir/.order` > $$builddir/enums.c +blox-gtk.h: +signal_funcs.c: make_signal_funcs make_callback_hash .order + sed -ne '/^\$$\$$/q' -e p blox-gtk.h.in > blox-gtk.h + (builddir=`pwd`; \ + cd $(GTK_HEADERS) && \ + $$builddir/make_signal_funcs -v header_file=$$builddir/blox-gtk.h \ + `cat $$builddir/.order`) > $@ + sed '1,/^\$$\$$/d' blox-gtk.h.in >> blox-gtk.h + +callback_hash.c: make_callback_hash .order + (builddir=`pwd`; \ + cd $(GTK_HEADERS) && \ + $$builddir/make_callback_hash `cat $$builddir/.order`) > $@ + .order: timestamp timestamp: order Makefile.am builddir=`pwd`; \ diff -rNu smalltalk-2.0.9.old/blox/gtk/blox-gtk.c smalltalk-2.0.9/blox/gtk/blox-gtk.c --- smalltalk-2.0.9.old/blox/gtk/blox-gtk.c 1969-12-31 16:00:00.000000000 -0800 +++ smalltalk-2.0.9/blox/gtk/blox-gtk.c 2003-01-14 22:57:26.000000000 -0800 @@ -0,0 +1,183 @@ +/*********************************************************************** + * + * Blox + * + * Standardized, Tk-based GUI widgets available for various window + * systems - Interface to Tcl + * + ***********************************************************************/ + +/*********************************************************************** + * + * Copyright 1988-92, 1994-95, 1999-2001 Free Software Foundation, Inc. + * XPM code is Copyright (C) 1989-94 GROUPE BULL + * Written by Paolo Bonzini. + * + * This file is part of GNU Smalltalk. + * + * GNU Smalltalk 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; either version 2, or (at your option) any later + * version. + * + * GNU Smalltalk 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 + * GNU Smalltalk; see the file COPYING. If not, write to the Free Software + * Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + * Here is the copyright notice for the XPM code: + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * GROUPE BULL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * Except as contained in this notice, the name of GROUPE BULL shall not be + * used in advertising or otherwise to promote the sale, use or other dealings + * in this Software without prior written authorization from GROUPE BULL. + + ***********************************************************************/ + +#include "config.h" +#include "gstpub.h" +#include "alloc.h" + +#ifndef HAVE_TCLTK +#error Tcl/Tk 8.0 needed to install the GNU Smalltalk GUI +#endif + +#include +#include +#include +#include +#include +#include + +#ifdef STDC_HEADERS +#include +#include +#endif + +#include "blox-gtk.h" + +static GHashTable *eventDataHash = NULL; +static GHashTable *callBackHash = NULL; + +gint bloxGtkDestroyFinalSignalHandler(GtkWidget *widget, gpointer data); + + +void +bloxGtkConnectSignal(OOP widget, char *event_name, OOP event_handler, OOP user_data) { + eventData *data; + eventData *newEventData; + char *widgetClassName; + GtkWidget *cWidget = vmProxy->OOPToCObject(widget); + void *signalFunc = NULL; + GtkType currentType; + + newEventData = (eventData *)malloc(sizeof(eventData)); + newEventData->eventHandler = event_handler; + vmProxy->registerOOP(event_handler); + newEventData->data = user_data; + vmProxy->registerOOP(user_data); + newEventData->next = NULL; + + currentType = GTK_OBJECT_TYPE(cWidget); + widgetClassName = gtk_type_name(currentType); + signalFunc = g_hash_table_lookup(g_hash_table_lookup(callBackHash, widgetClassName), event_name); + + while(signalFunc == NULL && strcmp(widgetClassName, "GtkObject") != 0) { + currentType = gtk_type_parent(currentType); + widgetClassName = gtk_type_name(currentType); + signalFunc = g_hash_table_lookup(g_hash_table_lookup(callBackHash, widgetClassName), event_name); + } + + if(signalFunc == NULL) { + return; + } + + gtk_signal_connect(GTK_OBJECT(cWidget), event_name, GTK_SIGNAL_FUNC(signalFunc), newEventData); + + if(eventDataHash == NULL) { + eventDataHash = g_hash_table_new(g_direct_hash, g_direct_equal); + } + + data = g_hash_table_lookup(eventDataHash, cWidget); + if(data == NULL) { + g_hash_table_insert(eventDataHash, cWidget, newEventData); + + gtk_signal_connect_after(GTK_OBJECT(cWidget), "destroy", + GTK_SIGNAL_FUNC(bloxGtkDestroyFinalSignalHandler), NULL); + } else { + while(data->next != NULL) { + data = data->next; + } + data->next = newEventData; + } +} + + +void +bloxGtkInit() +{ + int argc = 1; + gchar *argvArray[] = { "gst", NULL }; + gchar **argv = argvArray; + gtk_init (&argc, &argv); + + callBackHash = bloxGtkCreateCallBackHash(); +} + + +gint +bloxGtkDestroyFinalSignalHandler(GtkWidget *widget, gpointer data) +{ + eventData *eD, *nextEventData; + + eD = g_hash_table_lookup(eventDataHash, widget); + if(eD != NULL) g_hash_table_remove(eventDataHash, widget); + + while(eD != NULL) { + nextEventData = eD->next; + vmProxy->unregisterOOP(eD->eventHandler); + vmProxy->unregisterOOP(eD->data); + free(eD); + eD = nextEventData; + } + + return(FALSE); +} + + +void +gst_initModule(proxy) + VMProxy *proxy; +{ + vmProxy = proxy; + vmProxy->defineCFunc("bloxGtkInit", bloxGtkInit); + vmProxy->defineCFunc("bloxGtkConnectSignal", bloxGtkConnectSignal); + + eventDataHash = NULL; +} + +VMProxy* +bloxGtkGetVmProxy() +{ + return vmProxy; +} diff -rNu smalltalk-2.0.9.old/blox/gtk/blox-gtk.h.in smalltalk-2.0.9/blox/gtk/blox-gtk.h.in --- smalltalk-2.0.9.old/blox/gtk/blox-gtk.h.in 1969-12-31 16:00:00.000000000 -0800 +++ smalltalk-2.0.9/blox/gtk/blox-gtk.h.in 2003-01-14 21:46:21.000000000 -0800 @@ -0,0 +1,80 @@ +/*********************************************************************** + * + * Blox + * + * Standardized, Tk-based GUI widgets available for various window + * systems - Interface to Tcl + * + ***********************************************************************/ + +/*********************************************************************** + * + * Copyright 1988-92, 1994-95, 1999-2001 Free Software Foundation, Inc. + * XPM code is Copyright (C) 1989-94 GROUPE BULL + * Written by Paolo Bonzini. + * + * This file is part of GNU Smalltalk. + * + * GNU Smalltalk 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; either version 2, or (at your option) any later + * version. + * + * GNU Smalltalk 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 + * GNU Smalltalk; see the file COPYING. If not, write to the Free Software + * Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + * Here is the copyright notice for the XPM code: + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * GROUPE BULL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * Except as contained in this notice, the name of GROUPE BULL shall not be + * used in advertising or otherwise to promote the sale, use or other dealings + * in this Software without prior written authorization from GROUPE BULL. + + ***********************************************************************/ + +#ifndef _HAVE_BLOXGTK_H +#define _HAVE_BLOXGTK_H + +#include +#include + +#include "gstpub.h" + +static VMProxy *vmProxy; + +typedef struct _eventData eventData; +struct _eventData +{ + OOP eventHandler; + OOP data; + eventData *next; +}; + +GHashTable *bloxGtkCreateCallBackHash(); + +VMProxy *bloxGtkGetVmProxy(); + +$$ +#endif diff -rNu smalltalk-2.0.9.old/blox/gtk/funcs.awk smalltalk-2.0.9/blox/gtk/funcs.awk --- smalltalk-2.0.9.old/blox/gtk/funcs.awk 2002-07-14 04:45:57.000000000 -0700 +++ smalltalk-2.0.9/blox/gtk/funcs.awk 2003-01-14 21:46:21.000000000 -0800 @@ -36,7 +36,7 @@ ######################################################################## BEGIN { - FS = "[ \(\t]+" + FS = "[ (\t]+" type["void"] = "#void" type["int"] = "#int" @@ -191,10 +191,10 @@ continue if (i < 5 && self) - decl = decl " self" + decl = decl " #self" else if (substr(tst, 1, 3) == "...") - decl = decl " variadic" + decl = decl " #variadic" else if ( index( tst, "," ) > 0 || index( tst, ")" ) > 0 ) decl = decl " " ctype( strip( last ), tst ) diff -rNu smalltalk-2.0.9.old/blox/gtk/make_callback_hash.awk smalltalk-2.0.9/blox/gtk/make_callback_hash.awk --- smalltalk-2.0.9.old/blox/gtk/make_callback_hash.awk 1969-12-31 16:00:00.000000000 -0800 +++ smalltalk-2.0.9/blox/gtk/make_callback_hash.awk 2003-01-14 21:46:21.000000000 -0800 @@ -0,0 +1,46 @@ +#! @AWK@ -f + +BEGIN { + print "#include \n" + print "#include \"blox-gtk.h\"\n" + + print "GHashTable*" + print "bloxGtkCreateCallBackHash()" + print "{" + print "\tGHashTable *callBackHash, *currentHash;\n" + print "\tcallBackHash = g_hash_table_new(g_str_hash, g_str_equal);\n" +} + +$1 == "struct" && $2 ~ /_Gtk[A-Z][a-zA-Z]+Class/ { + className = $2 + gsub(/_/, "", className) + gsub(/Class$/, "", className) + print "\tcurrentHash = g_hash_table_new(g_str_hash, g_str_equal);" + printf "\tg_hash_table_insert(callBackHash, \"%s\", currentHash);\n", className + + while($1 != "};") { + getline + if ($0 ~ /[a-zA-Z0-9]+ \(\* [a-zA-Z_]+\)/) { + signalName = $3 + if(signalName ~ /\)\(/) { + gsub(/\(.*$/, "", signalName) + } + gsub(/\)$/, "", signalName) + } else if($0 ~ /[a-zA-Z0-9]+ \(\*[a-zA-Z_]+\)/) { + signalName = $2 + sub(/^\(\*/, "", signalName) + gsub(/\).*$/, "", signalName) + } else { + continue + } + if(className != "GtkContainer" || signalName != "forall") { + printf "\tg_hash_table_insert(currentHash, \"%s\", %s_%s);\n", signalName, className, signalName + } + } + print "" +} + +END { + print "\treturn(callBackHash);" + print "}" +} diff -rNu smalltalk-2.0.9.old/blox/gtk/make_enums.awk smalltalk-2.0.9/blox/gtk/make_enums.awk --- smalltalk-2.0.9.old/blox/gtk/make_enums.awk 2002-07-14 04:45:57.000000000 -0700 +++ smalltalk-2.0.9/blox/gtk/make_enums.awk 2003-01-14 21:46:21.000000000 -0800 @@ -35,6 +35,11 @@ # ######################################################################## +BEGIN { + print "#include " + print "#include " +} + FNR == 1 { enum_class = substr(smalltalkize(toupper(FILENAME)), 1, 3) print "#include <" FILENAME ">" @@ -55,13 +60,15 @@ if ($1 == "/*") { do getline - while ($1 != "*/") - getline + while ($0 !~ /\*\/$/) { + getline + } } if (/[A-Z]/) { sub(/,/, "", $1) declaration[$1] = "" +# print ">>> " $1 ": " NR } getline } diff -rNu smalltalk-2.0.9.old/blox/gtk/make_signal_funcs.awk smalltalk-2.0.9/blox/gtk/make_signal_funcs.awk --- smalltalk-2.0.9.old/blox/gtk/make_signal_funcs.awk 1969-12-31 16:00:00.000000000 -0800 +++ smalltalk-2.0.9/blox/gtk/make_signal_funcs.awk 2003-01-14 21:46:21.000000000 -0800 @@ -0,0 +1,261 @@ +#! @AWK@ -f + +BEGIN { + print "#include " + print "#include " + print "#include \n" + print "#include \"gstpub.h\"\n" + print "#include \"blox-gtk.h\"\n" +} + +$0 ~ /^struct _[a-zA-Z]+Class/ { + className = $2 + sub(/^_/, "", className) + sub(/Class$/, "", className) + + getline + while($0 !~ /^};/) { + delete argModifiers + delete argTypes + delete argNames + + if($0 ~ /[a-zA-Z0-9]+[ \t]+\(\*[a-zA-Z0-9_]+\)\([a-zA-Z_]+[ \t]+\**[a-zA-Z_]+[,\)]/) { + returnType = $1 + signalName = $2 + gsub(/\).*$/, "", signalName) + sub(/^\(\*/, "", signalName) + argModifiers[0] = "" + argTypes[0] = $2 + gsub(/^\(.*\(/, "", argTypes[0]) + argNames[0] = $3 + sub(/,$/, "", argNames[0]) + sub(/\);/, "", argNames[0]) + } else if($0 ~ /[a-zA-Z0-9]+[ \t]+\(\*[ \t]+[a-zA-Z0-9_]+\)\([a-zA-Z_]+[ \t]+\**[a-zA-Z)]+[,\)]/) { + returnType = $1 + signalName = $3 + sub(/\).*$/, "", signalName) + argModifiers[0] = "" + argTypes[0] = $3 + gsub(/^.*\(/, "", argTypes[0]) + argNames[0] = $4 + sub(/,$/, "", argNames[0]) + sub(/\);/, "", argNames[0]) + } else if($0 ~ /[a-zA-Z0-9]+[ \t]+\(\*[a-zA-Z0-9_]+\)[ \t]+\([a-zA-Z_]+[ \t]+\**[a-zA-Z_]+[,\)]/) { + returnType = $1 + signalName = $2 + sub(/^\(\*/, "", signalName) + sub(/\)$/, "", signalName) + argModifiers[0] = "" + argTypes[0] = $3 + gsub(/^\(/, "", argTypes[0]) + argNames[0] = $4 + sub(/,$/, "", argNames[0]) + sub(/\);/, "", argNames[0]) + } else if($0 ~ /[a-zA-Z0-9]+[ \t]+\(\*[ \t]+[a-zA-Z0-9_]+\)[ \t]+\([a-zA-Z_]+[ \t]+\**[a-zA-Z_]+[,\)]/) { + returnType = $1 + signalName = $3 + sub(/\)$/, "", signalName) + argModifiers[0] = "" + argTypes[0] = $4 + gsub(/^\(/, "", argTypes[0]) + argNames[0] = $5 + sub(/,$/, "", argNames[0]) + sub(/\);/, "", argNames[0]) + } else { + getline + continue + } + + if(className == "GtkContainer" && signalName == "forall") { + getline + continue + } + + i = 1 + while($0 !~ /\);[ \t]*$/) { + getline + + if(NF == 2) { + argModifiers[i] = "" + argTypes[i] = $1 + argNames[i] = $2 + sub(/,$/, "", argNames[i]) + sub(/\);$/, "", argNames[i]) + } else { + argModifiers[i] = $1 + argTypes[i] = $2 + argNames[i] = $3 + sub(/,$/, "", argNames[i]) + sub(/\);$/, "", argNames[i]) + } + i++ + } + commonStart(returnType, className, signalName, argModifiers, argTypes, argNames); + createVolatileVars(argModifiers, argTypes, argNames) + commonMiddle(argModifiers, argTypes, argNames) + freeVolatileVars(argModifiers, argNames) + commonEnd(returnType) + + getline + } +} + +function getSelector(signalName, argNames) { + string = smalltalkize(signalName) ":" + for(i in argNames) { + argName = argNames[i] + gsub(/^\**/, "", argName) + gsub(/\[\]/, "", argName) + string = string smalltalkize("with_" argName) ":" + } + return string +} + +function commonStart(returnType, className, signalName, argModifiers, argTypes, argNames) { + printf "%s %s_%s(", returnType, className, signalName + printf "%s %s_%s(", returnType, className, signalName >> header_file + + for(i in argModifiers) { + if(argModifiers[i] != "") { + argString = argModifiers[i] " " + } else { + argString = "" + } + printf "%s%s %s, ", argString, argTypes[i], argNames[i] + printf "%s%s %s, ", argString, argTypes[i], argNames[i] >> header_file + } + + print "gpointer bloxGtkUserData)" + print "gpointer bloxGtkUserData);\n" >> header_file + print "{" + + print "\tstatic char selectorName[] = \"" getSelector(signalName, argNames) "\";" + print "\teventData *eD = bloxGtkUserData;" + print "\tOOP handler, userData, result;" +} + +function createVolatileVars(argModifiers, argTypes, argNames) { + for(i in argModifiers) { + if(argModifiers[i] == "const") { + if(argNames[i] ~ /^\*/) { + volatileName = "*" smalltalkize("volatile_" substr(argNames[i], 2)) + pointer = 1 + } else { + volatileName = smalltalkize("volatile_", argNames[i]); + pointer = 0 + } + printf "\t%s %s = ", argTypes[i], volatileName + + if(pointer == 1) { + if(argTypes[i] == "char" || argTypes[i] == "gchar") { + printf "strdup(%s);", substr(argNames[i], 2) + } else { + printf "memcpy(malloc(sizeof(%s)), %s, sizeof(%s));", argTypes[i], substr(argNames[i], 2), argTypes[i] + } + } + } + } + print "" +} + +function commonMiddle(argModifiers, argTypes, argNames) { + print "\tvmProxy = bloxGtkGetVmProxy();" + print "\thandler = eD->eventHandler;" + print "\tuserData = eD->data;\n" + + printf "\tresult = vmProxy->strMsgSend(handler, selectorName, userData, " + for(i in argModifiers) { + if(argModifiers[i] == "const") { + if(argNames[i] ~ /^\*/) { + varName = smalltalkize("volatile_" substr(argNames[i], 2)) + pointer = 1 + } else { + varName = smalltalkize("volatile_" argNames[i]) + pointer = 0 + } + } else { + if(argNames[i] ~ /^\*/) { + varName = substr(argNames[i], 2) + pointer = 1 + } else { + varName = argNames[i] + pointer = 0 + } + } + gsub(/\[\]/, "", varName) + + if(pointer) { + if((argTypes[i] == "char" || argTypes[i] == "gchar") && argNames[i] !~ /\[\]$/) { + converter = "stringToOOP" + } else { + converter = "cObjectToOOP" + } + } else { + if(argTypes[i] == "char" || argTypes[i] == "gchar") { + converter = "charToOOP" + } else if(argTypes[i] == "int" || argTypes[i] == "gint" || argTypes[i] == "guint" || + argTypes[i] == "GtkStateType" || argTypes[i] == "GtkAccelFlags" || + argTypes[i] == "GdkModifierType" || argTypes[i] == "GtkDirectionType" || + argTypes[i] == "guint32" || argTypes[i] == "GtkOrientation" || + argTypes[i] == "GtkToolbarStyle" || argTypes[i] == "GtkCTreeExpansionType" || + argTypes[i] == "GtkShadowType" || argTypes[i] == "GtkArrowType" || + argTypes[i] == "GtkPositionType" || argTypes[i] == "GtkScrollType" || + argTypes[i] == "GtkCListDragPos" || argTypes[i] == "guint8" || + argTypes[i] == "GtkCellType" || "GtkMenuDirectionType") { + converter = "intToOOP" + } else if(argTypes[i] == "float" || argTypes[i] == "gfloat" || argTypes[i] == "double" || + argTypes[i] == "gdouble") { + converter = "floatToOOP" + } else if(argTypes[i] == "gboolean") { + converter = "boolToOOP" + } else if(argTypes[i] == "gpointer") { + converter = "cObjectToOOP" + } else { + print " *** ERROR: " argTypes[i] " *** " + continue + } + } + + printf "vmProxy->%s(%s), ", converter, varName + } + + print "NULL);" +} + +function freeVolatileVars(argModifiers, argNames) { + isFirst = 1 + for(i in argModifiers) { + if(argModifiers[i] == "const") { + if(argNames[i] ~ /^\*/) { + volatileName = smalltalkize("volatile_" substr(argNames[i], 2)) + if(isFirst == 1) { + print "" + isFirst = 0 + } + printf "\tfree(%s);\n", volatileName + } + } + } +} + +function commonEnd(returnType) { + if(returnType == "gint" || returnType == "GtkType") { + print "\n\treturn(vmProxy->OOPToInt(result));" + } else if(returnType == "gboolean") { + print "\n\treturn(vmProxy->OOPToBool(result));" + } + print "}\n" +} + +function smalltalkize( res ) +{ + first = substr (res, 1, 1) + res = tolower( substr (res, 2) ) + + while (is = index (res, "_")) { + first = first substr(res, 1, is - 1) toupper( substr (res, is + 1, 1)) + res = substr (res, is + 2) + } + + return first res +} diff -rNu smalltalk-2.0.9.old/blox/gtk/proof.st smalltalk-2.0.9/blox/gtk/proof.st --- smalltalk-2.0.9.old/blox/gtk/proof.st 2002-07-14 04:45:58.000000000 -0700 +++ smalltalk-2.0.9/blox/gtk/proof.st 2003-01-14 21:53:26.000000000 -0800 @@ -1,8 +1,30 @@ Gtk bloxGtkInit! -| w | +Object subclass: #EventHandler + instanceVariableNames: '' + classVariableNames: '' + poolDictionaries: '' + category: nil! + +!EventHandler class methodsFor: 'instance creation'! +new + ^super new +! ! + +!EventHandler methodsFor: 'event handling'! +deleteEvent: data withWidget: widget withEvent: evt + ^0 +! + +destroy: data withObject: object + Gtk gtkMainQuit +! ! + +| w eh | w := GtkWindow new: Gtk gtkWindowToplevel. +eh := EventHandler new. +w connectSignal: 'delete_event' withHandler: eh withEventData: nil. +w connectSignal: 'destroy' withHandler: eh withEventData: nil. w show. -"No way to exit this by forking a separate Process!! The VM halts!!" Gtk gtkMain! diff -rNu smalltalk-2.0.9.old/blox/gtk/structs.awk smalltalk-2.0.9/blox/gtk/structs.awk --- smalltalk-2.0.9.old/blox/gtk/structs.awk 2002-07-14 04:45:58.000000000 -0700 +++ smalltalk-2.0.9/blox/gtk/structs.awk 2003-01-14 23:08:31.000000000 -0800 @@ -171,6 +171,14 @@ print "\tclassVariableNames: ''" print "\tpoolDictionaries: ''" print "\tcategory: 'Gtk'!\n" + + if(name == "GtkWidget") { + print "GtkWidget" + print "\tdefineCFunc: 'bloxGtkConnectSignal'" + print "\twithSelectorArgs: 'connectSignal: name withHandler: eventHandler withEventData: eventData'" + print "\treturning: #void" + print "\targs: #( #selfSmalltalk #string #smalltalk #smalltalk )!\n" + } } function parse_struct (parent, name) diff -rNu smalltalk-2.0.9.old/configure.ac smalltalk-2.0.9/configure.ac --- smalltalk-2.0.9.old/configure.ac 2002-12-05 03:48:43.000000000 -0800 +++ smalltalk-2.0.9/configure.ac 2003-01-14 21:45:30.000000000 -0800 @@ -158,12 +158,12 @@ [ --enable-gtk (would) enable GTK implementation of Blox], [ AM_PATH_GLIB(1.2.0, [ AM_PATH_GTK(1.2.0, - BLOX_IMPLEMENTATION=BloxGTK, + BLOX_IMPLEMENTATION=BloxGTK enable_gtk=yes for i in `$GTK_CONFIG --cflags | sed s/-I//g`; do test -f $i/gtk/gtk.h && GTK_HEADERS="$i" done - AC_SUBST(GTK_HEADERS) + AC_SUBST(GTK_HEADERS), )], enable_gtk=no )],