diff -rNu smalltalk-2.0.11/blox/gtk/BloxGTK.c smalltalk-2.0.11-gtk/blox/gtk/BloxGTK.c --- smalltalk-2.0.11/blox/gtk/BloxGTK.c Sun Jul 14 13:45:57 2002 +++ smalltalk-2.0.11-gtk/blox/gtk/BloxGTK.c Thu Jan 1 01:00:00 1970 @@ -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.11/blox/gtk/GtkDecl.st.in smalltalk-2.0.11-gtk/blox/gtk/GtkDecl.st.in --- smalltalk-2.0.11/blox/gtk/GtkDecl.st.in Sun Jul 14 13:45:57 2002 +++ smalltalk-2.0.11-gtk/blox/gtk/GtkDecl.st.in Wed Jan 15 13:39:17 2003 @@ -35,6 +35,7 @@ DLD addLibrary: 'libgdk'! DLD addLibrary: 'libgtk'! +DLD addModule: 'blox-gtk'! Blox addSubspace: #Gtk! Namespace current: Blox Gtk! @@ -80,6 +81,12 @@ poolDictionaries: '' category: 'Gtk'! -$ +$$ + +GtkWidget + defineCFunc: 'bloxGtkConnectSignal' + withSelectorArgs: 'connectSignal: name withHandler: eventHandler withEventData: eventData' + returning: #void + args: #( #selfSmalltalk #string #smalltalk #smalltalk )! Namespace current: Smalltalk! diff -rNu smalltalk-2.0.11/blox/gtk/Makefile.am smalltalk-2.0.11-gtk/blox/gtk/Makefile.am --- smalltalk-2.0.11/blox/gtk/Makefile.am Sun Jul 14 13:45:57 2002 +++ smalltalk-2.0.11-gtk/blox/gtk/Makefile.am Wed Jan 15 15:11:05 2003 @@ -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 order bloxgtk_DATA = GtkDecl.st -CLEANFILES = $(noinst_SCRIPTS) $(bloxgtk_DATA) +CLEANFILES = $(noinst_SCRIPTS) $(bloxgtk_DATA) $(BUILT_SOURCES) .order timestamp 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,30 +71,53 @@ 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 + +callback_hash.c: make_callback_hash .order + (builddir=`pwd`; \ + cd $(GTK_HEADERS) && \ + $$builddir/make_callback_hash `cat $$builddir/.order`) > $@ + +signal_funcs.c: make_signal_funcs .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 + +blox-gtk.h: blox-gtk.h.in make_signal_funcs .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`) > /dev/null + sed '1,/^\$$\$$/d' blox-gtk.h.in >> blox-gtk.h .order: timestamp timestamp: order Makefile.am diff -rNu smalltalk-2.0.11/blox/gtk/blox-gtk.c smalltalk-2.0.11-gtk/blox/gtk/blox-gtk.c --- smalltalk-2.0.11/blox/gtk/blox-gtk.c Thu Jan 1 01:00:00 1970 +++ smalltalk-2.0.11-gtk/blox/gtk/blox-gtk.c Wed Jan 15 15:08:54 2003 @@ -0,0 +1,157 @@ +/*********************************************************************** + * + * Gtk+ wrappers for GNU Smalltalk + * + ***********************************************************************/ + +/*********************************************************************** + * + * Copyright 2001, 2003 Free Software Foundation, Inc. + * Written by Paolo Bonzini and Norman Jordan. + * + * 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. + * + ***********************************************************************/ + +#include "config.h" +#include "gstpub.h" + +#include +#include +#include +#include +#include +#include + +#ifdef STDC_HEADERS +#include +#include +#endif + +#include "blox-gtk.h" + +static GHashTable *h_event_data = NULL; +static GHashTable *h_callback = NULL; + +gint cleanup_callback_data (GtkWidget * widget, gpointer data); + + +void +_blox_connect_signal (OOP widget, char *event_name, OOP event_handler, + OOP user_data) +{ + eventData *data; + eventData *newEventData; + char *widgetClassName; + GtkWidget *cWidget = _blox_vm_proxy->OOPToCObject (widget); + void *signalFunc = NULL; + GtkType currentType; + + newEventData = (eventData *) malloc (sizeof (eventData)); + newEventData->eventHandler = event_handler; + _blox_vm_proxy->registerOOP (event_handler); + newEventData->data = user_data; + _blox_vm_proxy->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 (h_callback, 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 + (h_callback, widgetClassName), event_name); + } + + if (signalFunc == NULL) + return; + + gtk_signal_connect (GTK_OBJECT (cWidget), event_name, + GTK_SIGNAL_FUNC (signalFunc), newEventData); + + if (h_event_data == NULL) + h_event_data = g_hash_table_new (g_direct_hash, g_direct_equal); + + data = g_hash_table_lookup (h_event_data, cWidget); + if (data == NULL) + { + g_hash_table_insert (h_event_data, cWidget, newEventData); + + gtk_signal_connect_after (GTK_OBJECT (cWidget), "destroy", + GTK_SIGNAL_FUNC (cleanup_callback_data), + NULL); + } + else + { + while (data->next) + data = data->next; + + data->next = newEventData; + } +} + + +void +_blox_gtk_init () +{ + int argc = 1; + gchar *argvArray[] = { "gst", NULL }; + gchar **argv = argvArray; + gtk_init (&argc, &argv); + + h_callback = _blox_create_callback_hash (); +} + + +gint +cleanup_callback_data (GtkWidget * widget, gpointer data) +{ + eventData *eD, *nextEventData; + + eD = g_hash_table_lookup (h_event_data, widget); + if (eD != NULL) + g_hash_table_remove (h_event_data, widget); + + while (eD != NULL) + { + nextEventData = eD->next; + _blox_vm_proxy->unregisterOOP (eD->eventHandler); + _blox_vm_proxy->unregisterOOP (eD->data); + free (eD); + eD = nextEventData; + } + + return (FALSE); +} + + +void +gst_initModule (proxy) + VMProxy *proxy; +{ + _blox_vm_proxy = proxy; + _blox_vm_proxy->defineCFunc ("bloxGtkInit", _blox_gtk_init); + _blox_vm_proxy->defineCFunc ("bloxGtkConnectSignal", _blox_connect_signal); + + h_event_data = NULL; +} diff -rNu smalltalk-2.0.11/blox/gtk/blox-gtk.h.in smalltalk-2.0.11-gtk/blox/gtk/blox-gtk.h.in --- smalltalk-2.0.11/blox/gtk/blox-gtk.h.in Thu Jan 1 01:00:00 1970 +++ smalltalk-2.0.11-gtk/blox/gtk/blox-gtk.h.in Wed Jan 15 15:07:33 2003 @@ -0,0 +1,51 @@ +/*********************************************************************** + * + * Gtk+ bindings for GNU Smalltalk + * + ***********************************************************************/ + +/*********************************************************************** + * + * Copyright 2003 Free Software Foundation, Inc. + * Written by Norman Jordan. + * + * 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. + * + ***********************************************************************/ + +#ifndef _HAVE_BLOXGTK_H +#define _HAVE_BLOXGTK_H + +#include +#include + +#include "gstpub.h" + +static VMProxy *_blox_vm_proxy; + +typedef struct _eventData eventData; +struct _eventData +{ + OOP eventHandler; + OOP data; + eventData *next; +}; + +GHashTable *_blox_create_callback_hash(); + +$$ +#endif diff -rNu smalltalk-2.0.11/blox/gtk/funcs.awk smalltalk-2.0.11-gtk/blox/gtk/funcs.awk --- smalltalk-2.0.11/blox/gtk/funcs.awk Sun Jul 14 13:45:57 2002 +++ smalltalk-2.0.11-gtk/blox/gtk/funcs.awk Wed Jan 15 15:17:29 2003 @@ -36,7 +36,7 @@ ######################################################################## BEGIN { - FS = "[ \(\t]+" + FS = "[ (\t]+" type["void"] = "#void" type["int"] = "#int" @@ -78,7 +78,11 @@ name = substr($2, 2) correct_case[tolower(name)] = name prefix = method_prefix(name) "_" - method_regexp = method_regexp "|^" prefix + if (length (method_regexp)) + method_regexp = method_regexp "|^" prefix + else + method_regexp = method_regexp "^" prefix + class[prefix] = name } @@ -191,10 +195,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 ) @@ -227,7 +231,7 @@ function returned( var ) { - if (var ~ /*$/) + if (var ~ /\*$/) return var ~ /g?char/ ? "#string" : strip(var) " type" # everything else is `xxx type' diff -rNu smalltalk-2.0.11/blox/gtk/make_callback_hash.awk smalltalk-2.0.11-gtk/blox/gtk/make_callback_hash.awk --- smalltalk-2.0.11/blox/gtk/make_callback_hash.awk Thu Jan 1 01:00:00 1970 +++ smalltalk-2.0.11-gtk/blox/gtk/make_callback_hash.awk Wed Jan 15 13:42:42 2003 @@ -0,0 +1,82 @@ +#! @AWK@ -f + +####################################################################### +# +# Gtk wrapper creation scripts (creating hash table for callbacks) +# +# $Revision: 1.95.1$ +# $Date: 2000/12/27 10:45:49$ +# $Author: pb$ +# +######################################################################## + + +####################################################################### +# +# Copyright 1988-92, 1994-95, 1999, 2000 Free Software Foundation, Inc. +# Written by Norman Jordan +# +# This file is part of the GNU Smalltalk class library. +# +# The GNU Smalltalk class library is free software; you can redistribute it +# and/or modify it under the terms of the GNU Lesser General Public License +# as published by the Free Software Foundation; either version 2.1, or (at +# your option) any later version. +# +# The GNU Smalltalk class library 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 Lesser +# General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public License +# along with the GNU Smalltalk class library; see the file COPYING.LESSER. +# If not, write to the Free Software Foundation, 59 Temple Place - Suite +# 330, Boston, MA 02111-1307, USA. +# +######################################################################## + +BEGIN { + print "/* Automatically generated, do not edit! */" + print "#include \n" + print "#include \"blox-gtk.h\"\n" + + print "GHashTable*" + print "_blox_create_callback_hash()" + print "{" + print " GHashTable *callBackHash, *currentHash;\n" + print " callBackHash = 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 " currentHash = g_hash_table_new(g_str_hash, g_str_equal);" + printf " g_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 " g_hash_table_insert(currentHash, \"%s\", %s_%s);\n", signalName, className, signalName + } + } + print "" +} + +END { + print " return(callBackHash);" + print "}" +} diff -rNu smalltalk-2.0.11/blox/gtk/make_enums.awk smalltalk-2.0.11-gtk/blox/gtk/make_enums.awk --- smalltalk-2.0.11/blox/gtk/make_enums.awk Sun Jul 14 13:45:57 2002 +++ smalltalk-2.0.11-gtk/blox/gtk/make_enums.awk Wed Jan 15 15:15:28 2003 @@ -35,6 +35,11 @@ # ######################################################################## +BEGIN { + print "#include " + print "#include " +} + FNR == 1 { enum_class = substr(smalltalkize(toupper(FILENAME)), 1, 3) print "#include <" FILENAME ">" @@ -55,11 +60,8 @@ if ($1 == "/*") { do getline - while ($1 != "*/") - getline - } - - if (/[A-Z]/) { + while ($0 !~ /\*\/$/) + } else if (/[A-Z]/) { sub(/,/, "", $1) declaration[$1] = "" } diff -rNu smalltalk-2.0.11/blox/gtk/make_signal_funcs.awk smalltalk-2.0.11-gtk/blox/gtk/make_signal_funcs.awk --- smalltalk-2.0.11/blox/gtk/make_signal_funcs.awk Thu Jan 1 01:00:00 1970 +++ smalltalk-2.0.11-gtk/blox/gtk/make_signal_funcs.awk Wed Jan 15 15:08:19 2003 @@ -0,0 +1,296 @@ +#! @AWK@ -f + +####################################################################### +# +# Gtk wrapper creation scripts (C->Smalltalk interface for signals) +# +# $Revision: 1.95.1$ +# $Date: 2000/12/27 10:45:49$ +# $Author: pb$ +# +######################################################################## + + +####################################################################### +# +# Copyright 1988-92, 1994-95, 1999, 2000 Free Software Foundation, Inc. +# Written by Norman Jordan +# +# This file is part of the GNU Smalltalk class library. +# +# The GNU Smalltalk class library is free software; you can redistribute it +# and/or modify it under the terms of the GNU Lesser General Public License +# as published by the Free Software Foundation; either version 2.1, or (at +# your option) any later version. +# +# The GNU Smalltalk class library 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 Lesser +# General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public License +# along with the GNU Smalltalk class library; see the file COPYING.LESSER. +# If not, write to the Free Software Foundation, 59 Temple Place - Suite +# 330, Boston, MA 02111-1307, USA. +# +######################################################################## + +BEGIN { + print "/* Automatically generated, do not edit! */" + 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 " static char selectorName[] = \"" getSelector(signalName, argNames) "\";" + print " eventData *eD = bloxGtkUserData;" + print " OOP 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 " %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 " handler = eD->eventHandler;" + print " userData = eD->data;\n" + + printf " result = _blox_vm_proxy->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 "_blox_vm_proxy->%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 " free(%s);\n", volatileName + } + } + } +} + +function commonEnd(returnType) { + if(returnType == "gint" || returnType == "GtkType") { + print "\n return(_blox_vm_proxy->OOPToInt(result));" + } else if(returnType == "gboolean") { + print "\n return(_blox_vm_proxy->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.11/blox/gtk/proof.st smalltalk-2.0.11-gtk/blox/gtk/proof.st --- smalltalk-2.0.11/blox/gtk/proof.st Sun Jul 14 13:45:58 2002 +++ smalltalk-2.0.11-gtk/blox/gtk/proof.st Wed Jan 15 13:31:01 2003 @@ -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.11/blox/gtk/structs.awk smalltalk-2.0.11-gtk/blox/gtk/structs.awk --- smalltalk-2.0.11/blox/gtk/structs.awk Sun Jul 14 13:45:58 2002 +++ smalltalk-2.0.11-gtk/blox/gtk/structs.awk Wed Jan 15 15:15:51 2003 @@ -88,7 +88,7 @@ read_next_line() - parent = ($1 ~ /^Gtk/) && ($2 !~ /^*/) && ($1 in processed) ? $1 : "CObject" + parent = ($1 ~ /^Gtk/) && ($2 !~ /^\*/) && ($1 in processed) ? $1 : "CObject" parse_struct(parent, name) } diff -rNu smalltalk-2.0.11/configure.ac smalltalk-2.0.11-gtk/configure.ac --- smalltalk-2.0.11/configure.ac Wed Jan 1 21:03:34 2003 +++ smalltalk-2.0.11-gtk/configure.ac Wed Jan 15 13:31:54 2003 @@ -157,13 +157,13 @@ AC_ARG_ENABLE(gtk, [ --enable-gtk (would) enable GTK implementation of Blox], [ AM_PATH_GLIB(1.2.0, [ - AM_PATH_GTK(1.2.0, - BLOX_IMPLEMENTATION=BloxGTK, + AM_PATH_GTK(1.2.0, [ + 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 )],