Custom Search
|
Date: January 31, 2003
From: "Bonzini" <bonzini@xxxxxxx>
References:
<E18dy8J-00022J-00@xxxxxxxxxxxxxxxxxxxx>
Can you please send the floatmath.st.log file? > my configuration has been: ./configure --with-tk=/usr/local/lib/tk8.3 > --with-tcl=/usr/local/lib/tcl8.3 --enable-modules=Blox,TCP I don't think that --enable-modules in general is a good idea. I prefer specifying manually what goes in an image. Paolo
Date: January 29, 2003
From: console_operator_nul <everglade@xxxxxxxxx>
Hello,
I am installing smalltalk-2.0.11 on my OpenBSD 3.0 box.
The failing results are:
make check floatmath.st
FloatANSITest
FractionANSITest
ScaledDecimalANSITest;
make install /usr/libexec/ld.so: Undefined symbol "_Tcl_Free"
in gst:/usr/local/lib/libtk83.so.1.3 .
my configuration has been: ./configure --with-tk=/usr/local/lib/tk8.3
--with-tcl=/usr/local/lib/tcl8.3 --enable-modules=Blox,TCP
I have been urged to report. I am looking for solutions but if you
can hint, you are welcome to contact me. I would be most obliged.
My email address: everglade@xxxxxxxxx
My name Robert Vencent Racamy.
Date: January 27, 2003
From: Paolo Bonzini <paolo.bonzini@xxxxxxxxx>
In-reply-to:
<20030127150754.N17359@xxxxxxxxxxxxxxx>
References:
<20030127114618.F17359@xxxxxxxxxxxxxxx> <200301271437.55826.paolo.bonzini@xxxxxxxxx> <20030127150754.N17359@xxxxxxxxxxxxxxx>
On Monday 27 January 2003 15:07, Sven Verdoolaege wrote: > But a slight variation of it still persists: Sorry, I meant in my development tree. Paolo
Date: January 27, 2003
From: Paolo Bonzini <paolo.bonzini@xxxxxxxxx>
In-reply-to:
<20030127150754.N17359@xxxxxxxxxxxxxxx>
References:
<20030127114618.F17359@xxxxxxxxxxxxxxx> <200301271437.55826.paolo.bonzini@xxxxxxxxx> <20030127150754.N17359@xxxxxxxxxxxxxxx>
> I didn't realize there were prereleases. I post announces to freshmeat and sometimes here too. Paolo
Date: January 27, 2003
From: Sven Verdoolaege <skimo@xxxxxxxxxx>
In-reply-to:
<200301271437.55826.paolo.bonzini@xxxxxxxxx>
References:
<20030127114618.F17359@xxxxxxxxxxxxxxx> <200301271437.55826.paolo.bonzini@xxxxxxxxx>
On Mon, Jan 27, 2003 at 02:37:55PM +0100, Paolo Bonzini wrote: > I think that it is solved in 2.1 prereleases (the mechanisms behind > event-handling and switching between C and Smalltalk code changed very much > in between), and version 2.1 is sufficiently near to release, that probably > the best solution is to upgrade. I didn't realize there were prereleases. > However I'll check it out just in case the bug is also in 2.1, or maybe it > went back latent. On first inspection, it seems to work now. > Re. the other bug, it is indeed fixed in 2.1. But a slight variation of it still persists: Perform some change. Select "Save Image" then "Exit" and I get: Object: nil error: did not understand #rootView UndefinedObject(Object)>>#doesNotUnderstand: BLOX.BLOXBrowser.ModalDialog>>#message:in: BLOX.BLOXBrowser.BrowserMain>>#quit DirectedMessage(Message)>>#sendTo: DirectedMessage>>#send BLOX.BMenuItem(BLOX.BMenuObject)>>#invokeCallback Moreover, the "Save Image" does not do its job. Neither is the image really saved if you just do "Exit" and press "Yes". skimo
Date: January 27, 2003
From: Paolo Bonzini <paolo.bonzini@xxxxxxxxx>
In-reply-to:
<20030127114618.F17359@xxxxxxxxxxxxxxx>
References:
<20030127114618.F17359@xxxxxxxxxxxxxxx>
> I get a somewhat reproducible segmentation fault when > use Blox and FileStream. I think that it is solved in 2.1 prereleases (the mechanisms behind event-handling and switching between C and Smalltalk code changed very much in between), and version 2.1 is sufficiently near to release, that probably the best solution is to upgrade. However I'll check it out just in case the bug is also in 2.1, or maybe it went back latent. Re. the other bug, it is indeed fixed in 2.1. Paolo
Date: January 27, 2003
From: Sven Verdoolaege <skimo@xxxxxxxxxx>
Merely exiting from a blox run doesn't seem to work either. gst -q -g /usr/local/share/smalltalk/blox/Run.st Then select Exit from the menu and push the "yes" button. I get this error message: Object: nil error: did not understand #blox UndefinedObject(Object)>>#originalPrimError: UndefinedObject(Object)>>#primError: MessageNotUnderstood(Exception)>>#defaultAction [] in Exception class>>#coreException MessageNotUnderstood(Signal)>>#activateHandler: MessageNotUnderstood(Exception)>>#signal UndefinedObject(Object)>>#doesNotUnderstand: BLOX BLOXBrowser BrowserMain>>#initialize UndefinedObject>>#executeStatements The image does not seem to have been saved. config.log is the same as the one attached to <20030127114618.F17359@xxxxxxxxxxxxxxx> skimo
Date: January 27, 2003
From: Sven Verdoolaege <skimo@xxxxxxxxxx>
I get a somewhat reproducible segmentation fault when
use Blox and FileStream.
To reproduce:
gst -q -g /usr/local/share/smalltalk/blox/Run.st
Paste "FileStream fileIn: 'GENDER.st' !"
into the Transcript area; select it and choose "Do it" from the
menu. Most of the times I get:
Starting window environment...
Program received signal SIGSEGV, Segmentation fault.
0x0807faf7 in unwind_context () at interp.c:1032
1032 SET_THIS_METHOD (newContext->method, GET_CONTEXT_IP (newContext));
(gdb) bt
#0 0x0807faf7 in unwind_context () at interp.c:1032
#1 0x0807d288 in _gst_interpret () at interp-bc.inl:1604
#2 0x08053074 in _gst_execute_statements (temporaries=0x0, statements=0x0,
quiet=true) at comp.c:681
#3 0x08081af3 in _gst_yyparse () at gst.y:140
#4 0x08083bdf in _gst_parse_stream () at lex.c:1063
#5 0x080526ff in process_file (fileName=0xa <Address 0xa out of bounds>,
quiet=false) at lib.c:788
#6 0x08052166 in gst_top_level_loop () at lib.c:594
#7 0x08051ba5 in main (argc=0, argv=0x0) at main.c:51
#8 0x400d79ed in __libc_start_main () from /lib/libc.so.6
(gdb)
It seems to depend on whether I select the command up to the '!'
or the whole line. Selecting the whole line usually does it.
GENDER.st is a small file generated by gst itself and is attached.
config.log attached as well.
BTW, I noticed a variation of my name in the "THANKS" file,
but it's not quite correct.
skimo
GENDER.st
Description: Text document
config.log.gz
Description: application/gunzip
_______________________________________________ help-smalltalk mailing list help-smalltalk@xxxxxxx http://mail.gnu.org/mailman/listinfo/help-smalltalk
Date: January 16, 2003
From: "Bonzini" <bonzini@xxxxxxx>
I'm uploading 2.0i which synchronizes the bugfixes with 2.0.11, has some fixes for the browser, and includes Norman Jordan's updated GTK+ bindings (with some modifications to simplify the makefiles, to shorten some selectors, and to have the proof-of-concept example actually draw a button and react to clicks). ftp://alpha.gnu.org/gnu/smalltalk/smalltalk-2.0i.tar.gz ftp://alpha.gnu.org/gnu/smalltalk/smalltalk-2.0h-2.0i.diff.gz |_ _ _ __ |_)(_)| ),' ------- '---
Date: January 15, 2003
From: Paolo Bonzini <paolo.bonzini@xxxxxxxxx>
In-reply-to:
<20030115073342.GA21418@xxxxxxxxxxxxxxx>
References:
<20030114081516.GA826@xxxxxxxxxxxxxxx> <200301141156.16254.paolo.bonzini@xxxxxxxxx> <20030115073342.GA21418@xxxxxxxxxxxxxxx>
Here is the patch that I applied on top of 2.0.11 (includes a few fixes to work with mawk and to leave the build directory a bit more clean, as well as re-indentation of some files). Please work from this. Paolo
smalltalk-gtk+-2.patch
Description: Text Data
_______________________________________________ help-smalltalk mailing list help-smalltalk@xxxxxxx http://mail.gnu.org/mailman/listinfo/help-smalltalk
Date: January 15, 2003
From: Norman Jordan <njordan@xxxxxxx>
In-reply-to:
<200301141156.16254.paolo.bonzini@xxxxxxxxx>
References:
<20030114081516.GA826@xxxxxxxxxxxxxxx> <200301141156.16254.paolo.bonzini@xxxxxxxxx>
For some strange reason, it doesn't recognize the C function
"bloxGtkConnectSignal" if I put it at the end of GtkDecl.st.
I have made some of the changes that were suggested. I have merged the
modules and renamed the C files.
On Tue, Jan 14, 2003 at 11:56:16AM +0100, Paolo Bonzini wrote:
> Forgot about this:
>
> > +
> > + 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 )!"
> > + }
>
> Move it to GtkDecl.st.in; no need to clutter the awk scripts which should be
> as generic as possible.
>
> --
> |_ _ _ __
> |_)(_)| ) ;'_.
>
--
Norman Jordan <njordan@xxxxxxx>
smalltalk-gtk+.patch
Description: Text document
_______________________________________________ help-smalltalk mailing list help-smalltalk@xxxxxxx http://mail.gnu.org/mailman/listinfo/help-smalltalk
Date: January 14, 2003
From: Paolo Bonzini <paolo.bonzini@xxxxxxxxx>
In-reply-to:
<20030114081516.GA826@xxxxxxxxxxxxxxx>
References:
<20030114081516.GA826@xxxxxxxxxxxxxxx>
Forgot about this:
> +
> + 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 )!"
> + }
Move it to GtkDecl.st.in; no need to clutter the awk scripts which should be
as generic as possible.
--
|_ _ _ __
|_)(_)| ) ;'_.
Date: January 14, 2003
From: Paolo Bonzini <bonzini@xxxxxxx>
In-reply-to:
<20030114081516.GA826@xxxxxxxxxxxxxxx>
References:
<20030114081516.GA826@xxxxxxxxxxxxxxx>
> Here is a patch I have been working on for the blox/gtk
> directory. It leaves control in Gtk+'s main loop, and control only
> returns to Smalltalk when an event happens that the program is
> listening for.
This will eventually need to be changed, but it is a good start.
In general I appreciate your work a lot even though it has some
problems, so here is a review of your patches.
It's good to see things moving on blox-gtk, I hope to make it the
definitive back-end one day.
> + lt_dlinit();
> + supportHandle = lt_dlopen(".libs/blox-gtk-support.so");
I don't see the need for this support module (besides, the correct
way is not to pass .libs, but to add the proper path to LD_LIBRARY_PATH
until gst is installed). Just link the files together.
> +bloxgtk_header_in = BloxGTK.h.in
> +bloxgtk_header_file = BloxGTK.h
> +bloxgtk_generated_c_files = BloxGTKSignalFuncs.c BloxGTKInitCallbackHash.c
BUILT_SOURCES = BloxGTK.h signal_funcs.c callback_hash.c
(It might be good to switch to blox-gtk.[hc] as well, I don't like mixed
case names even though it was me who wrote BloxGTK.c; feel free to do
that yourself).
> +CLEANFILES = $(noinst_SCRIPTS) $(bloxgtk_DATA) $(bloxgtk_header_file)
> $(bloxgtk_generated_c_files)
CLEANFILES = ... $(BUILT_SOURCES)
> +blox_gtk_la_SOURCES = BloxGTK.c
blox_gtk_la_SOURCES = BloxGTK.c 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/$<) > $@
Ok. Probably better to switch to something more sensible like $data than
a lone dollar (again, my mistake).
> +BloxGTK.h:
> +BloxGTKSignalFuncs.c: make_signal_funcs make_callback_hash .order
> + sed -ne '/^\$$/q' -e p $(bloxgtk_header_in) > $(bloxgtk_header_file)
> + (builddir=`pwd`; \
> + cd $(GTK_HEADERS) && \
> + $$builddir/make_signal_funcs -v
> header_file=$$builddir/$(bloxgtk_header_file) \
> + `cat $$builddir/.order`) > $@
> + sed '1,/^\$$/d' $(bloxgtk_header_in) >> $(bloxgtk_header_file)
> +
> +BloxGTKInitCallbackHash.c: make_callback_hash .order
> + (builddir=`pwd`; \
> + cd $(GTK_HEADERS) && \
> + $$builddir/make_callback_hash `cat $$builddir/.order`) > $@
> +
Good, again apart from the file names.
> - decl = decl " self"
> + decl = decl " #self"
>
> else if (substr(tst, 1, 3) == "...")
> - decl = decl " variadic"
> + decl = decl " #variadic"
Obviously.
> Only in smalltalk-2.0.9/blox/gtk: make_signal_funcs.awk
Please use diff -rNu (also for make_callback_hash.awk) so that the
files are included.
Paolo
Date: January 14, 2003
From: Norman Jordan <njordan@xxxxxxx>
Here is a patch I have been working on for the blox/gtk directory. It leaves control in Gtk+'s main loop, and control only returns to Smalltalk when an event happens that the program is listening for. -- Norman Jordan <njordan@xxxxxxx>
smalltalk-gtk+.patch
Description: Text document
_______________________________________________ help-smalltalk mailing list help-smalltalk@xxxxxxx http://mail.gnu.org/mailman/listinfo/help-smalltalk
Date: January 13, 2003
From: "Tomas Vanak" <tomas@xxxxxxxx>
References:
<019d01c2b625$e8a5a450$f5fe0bd9@PORTATIL> <20030107093435.GG28090@biancaneve
>
Hi Paolo, I wanted to try the same code in both smalltalks, that is why I used the given code. >From the output of ./configure I can see I'm not using the GMP library: checking how to link with GMP... not found even when I'm using ./configure --with-gmp=/usr/lib I have a libgmp.so.3.1.1 library there. Do I need another version? Am I putting the -with-gmp parameter wrong? Thanks Best regards Tomas ----- Original Message ----- From: "Paolo Bonzini" <bonzini@xxxxxxx> To: "Tomas Vanak" <tomas@xxxxxxxx> Cc: <help-smalltalk@xxxxxxx> Sent: Tuesday, January 07, 2003 10:34 AM Subject: Re: GNU ST Speed > > I tried the version 2.0h and I saw a lot of improvements! > > Amazing work! > > Thanks! > > > I was trying to compare the speed of St/X and GNU St. > > I tried just a simple example of a factorial: > > Integer>>factorial > > |p i| > > p := 2. > > i := 3. > > [i <= self] whileTrue: [ > > p := p * i. > > i := i + 1. > > ]. > > ^p > > Why don't you use the bundled factorial method? It is optimized to the > extreme... also check that you are using GMP. ST/X's LargeIntegers are > coded in C, without GMP GNU Smalltalk's are coded in Smalltalk. > > > Then I did-it: 1000 timesRepeat: [1000 factorial], on GNU St it took many > > minutes to complete and it was scavenging all the time. > > A scavenging takes a few milliseconds. Even using -g might improve the > performance by avoiding printing the messages. It might also be worthwhile > to increase the size of new-space (see methods in ObjectMemory) -- in > general, not only for this example -- for example having 1 MB of new-space > and 200 Kb for each survivor space (total 1,5 MB; currently I have 300 Kb > and 40 Kb). More info on the new GC/memory manager is found in the info > documentation > > Paolo >
Date: January 13, 2003
From: Paolo Bonzini <bonzini@xxxxxxx>
In-reply-to:
<019d01c2b625$e8a5a450$f5fe0bd9@PORTATIL>
References:
<019d01c2b625$e8a5a450$f5fe0bd9@PORTATIL>
> I tried the version 2.0h and I saw a lot of improvements! > Amazing work! Thanks! > I was trying to compare the speed of St/X and GNU St. > I tried just a simple example of a factorial: > Integer>>factorial > |p i| > p := 2. > i := 3. > [i <= self] whileTrue: [ > p := p * i. > i := i + 1. > ]. > ^p Why don't you use the bundled factorial method? It is optimized to the extreme... also check that you are using GMP. ST/X's LargeIntegers are coded in C, without GMP GNU Smalltalk's are coded in Smalltalk. > Then I did-it: 1000 timesRepeat: [1000 factorial], on GNU St it took many > minutes to complete and it was scavenging all the time. A scavenging takes a few milliseconds. Even using -g might improve the performance by avoiding printing the messages. It might also be worthwhile to increase the size of new-space (see methods in ObjectMemory) -- in general, not only for this example -- for example having 1 MB of new-space and 200 Kb for each survivor space (total 1,5 MB; currently I have 300 Kb and 40 Kb). More info on the new GC/memory manager is found in the info documentation Paolo
Date: January 12, 2003
From: "Bonzini" <bonzini@xxxxxxx>
References:
<lz3cnzfz3t.fsf@xxxxxxxxxxxxxxxxxxxxx>
Download ftp://alpha.gnu.org/gnu/smalltalk-2.0.11.tar.gz (it is a known packaging problem). This tarball will be moved to the main FTP site shortly. |_ _ _ __ |_)(_)| ),' ------- '---
Date: January 11, 2003
From: Alexey Promokhov <ayp@xxxxxxxxxx>
Hello! I'm trying to build Smalltalk 2.0.9 on Linux (Slackware 8.1). ./configure without any switches (only --prefix specified). Here is the error message. === Cut === Making all in libgst make[2]: Entering directory `/var/tmp/smalltalk-2.0.9/libgst' make all-am make[3]: Entering directory `/var/tmp/smalltalk-2.0.9/libgst' make[3]: *** No rule to make target `../snprintfv/snprintfv/libsnprintfvc.la', needed by `libgst.la'. Stop. make[3]: Leaving directory `/var/tmp/smalltalk-2.0.9/libgst' make[2]: *** [all] Error 2 make[2]: Leaving directory `/var/tmp/smalltalk-2.0.9/libgst' make[1]: *** [all-recursive] Error 1 make[1]: Leaving directory `/var/tmp/smalltalk-2.0.9' make: *** [all] Error 2 === Cut === Can anybody suggest something? Please cc me, I'm not in mailing list. -- Alexey Promokhov <ayp#ayp.msk.ru>
Date: January 09, 2003
From: "Bonzini" <bonzini@xxxxxxx>
References:
<20030108223643.38175.qmail@xxxxxxxxxxxxxxxxxxxxxxx>
> (1) Changing namespaces in the namespace browser > changes the class list, but the protocol list, > selector list and text stay the same. > Suggest setting curClass := nil in NamespaceBrowser > #namespaceSelection Fixed. > value: (itemPosition > 0 > ifTrue: [(data perform: listMsg) > at: itemPosition > ifAbsent: [nil]] > ifFalse: [nil])) ]. At this point it is easier to drop the if and just do "at: itemPosition ifAbsent: [ nil ]". This method also needs to be modified so that canceling a method update does not change the selected method (strange you did not get that :-). > It seems that this is ultimately because #idle returns > Blox itself (the Class) as its methodCategory, which, > I would guess is because it is an ansynchronous > call-out, because the other call-outs return 'C > functions', nicely. ClassDescription is lacking the definition of #defineAsyncCFunc:withSelectorArgs:args: while it has #defineCFunc:withSelectorArgs:returning:args: (which sets the category). This, plus a typo in _gst_execute_statements: oldClass = _gst_this_class; oldCategory = _gst_this_class; // should be _gst_this_category ... _gst_set_compilation_class (oldClass); _gst_set_compilation_category (oldCategory); The sequence is: 1) #compileString:ifError: primitive sets compilation category to nil 2) _gst_execute_statements is called to get value of compile-time constant 3) _gst_execute_statements sets category to _gst_this_class, i.e. Blox 4) async call-out's method category ends up being Blox > I also find that if you add an instance variable in > the browser (or make any other change), and Accept, it > frequently does not work. I'll also take a look at this. BTW, 2.0.11 is delayed because I did found a couple of bugs in it (and in the development versions) -- one in the compiler, one in detection of Tcl/Tk on FreeBSD. I'll release it tomorrow. Thanks. Paolo
Date: January 09, 2003
From: "Bonzini" <bonzini@xxxxxxx>
References:
<20030108220651.69980.qmail@xxxxxxxxxxxxxxxxxxxxxxx>
> > Check if you can handle Gtk events manually, before > > trying all this. > > I think you can, but there is quite a lot of > initialization and cleanup code in gtk_main, and modal > dialogs (for example) are implemented by making a > nested gtk_main call, it seems, which might cause > grief. No need to use them -- we can fake them in Smalltalk just like Blox/Tk does (it puts the process that started the modal loop waiting on a Semaphore, and signals the semaphore when the modal dialog goes away). I like very much the heavy usage of processes in the 2.1 Blox/Tk (that's also where VisualWorks is moving to and what ST/X has been doing for ages*), it simplifies a lot of tasks. Paolo *actually they use a dispatching process per window; gst has a single dispatching process and a single process per event
Date: January 09, 2003
From: MSA or SJF <msasjf@xxxxxxxxxxx>
Some bugs, and some suggested fixes, if they are of
any use.
I've just realised that I haven't got round to moving
to 2.0h, so apologies if I'm reporting something that
you've already fixed.
(1) Changing namespaces in the namespace browser
changes the class list, but the protocol list,
selector list and text stay the same.
Suggest setting curClass := nil in NamespaceBrowser
#namespaceSelection
(2) Clicking on an empty list (eg the selector list
just after adding a new protocol) gives an error.
It seems that two messages come through: the first
with index 1 (which is surely incorrect, though I
didn't trace where it comes from), the second with
index 0. The first message causes the error. You can
suppress it by amending PList #selection:at: to read
at the bottom:
...
value: (itemPosition > 0
ifTrue: [(data perform: listMsg)
at: itemPosition
ifAbsent: [nil]]
ifFalse: [nil])) ].
...
(3) If you click on the class radio button (ie meta)
to browse the class methods for BLOX Blox, you get a
stack that ends up:
Object: Blox class error: did not understand #<=
It seems that this is ultimately because #idle returns
Blox itself (the Class) as its methodCategory, which,
I would guess is because it is an ansynchronous
call-out, because the other call-outs return 'C
functions', nicely.
Things get a little involved at this stage, so I
haven't taken it any further than that.
I also find that if you add an instance variable in
the browser (or make any other change), and Accept, it
frequently does not work, but, confusingly, it seems
erratic - not necessarily throwing the same error each
time, and sometimes it works! I'll keep poking around
on this one.
Regards,
Mike
__________________________________________________
Do you Yahoo!?
Yahoo! Mail Plus - Powerful. Affordable. Sign up now.
http://mailplus.yahoo.com
Date: January 09, 2003
From: "Daniel A. Koepke" <dkoepke@xxxxxxxxxxxxx>
In-reply-to:
<200301081726.42757.paolo.bonzini@xxxxxxxxx>
References:
<200301081726.42757.paolo.bonzini@xxxxxxxxx>
On Wed, 8 Jan 2003, Paolo Bonzini wrote:
> Check if you can handle Gtk events manually, before trying all this.
>From the GTK+ 2.0 documentation:
gboolean gtk_main_iteration_do (gboolean blocking);
Runs a single iteration of the mainloop. If no events are available
either return or block dependent on the value of _blocking_.
blocking : TRUE if you want GTK+ to block if no events are pending.
Returns : TRUE if gtk_main_quit() has been called for the innermost
mainloop.
-dak
Date: January 08, 2003
From: Paolo Bonzini <paolo.bonzini@xxxxxxxxx>
In-reply-to:
<20030108160823.23514.qmail@xxxxxxxxxxxxxxxxxxxxxxx>
References:
<20030108160823.23514.qmail@xxxxxxxxxxxxxxxxxxxxxxx>
> In proof.st you make the comment that there is no way > to fork a Process for Gtk gtkMain. > > Were you referring to a Smalltalk Process or an OS > one? Ehm, I don't remember. But it seems easier to do now that I have asynchronous call-outs and CallinProcesses -- Blox-Tk's event loop is indeed less buggy and simpler. Maybe you can tell gtk_main not to start the event loop, and then process Gtk events one at a time like it is done in Blox-Tk. > You'd also have to put Gtk in thread-aware mode and > synchronize all calls. That seems like hard work, but > not /impossible/. Check if you can handle Gtk events manually, before trying all this. -- |_ _ _ __ |_)(_)| ) ;'_.
Date: January 08, 2003
From: MSA or SJF <msasjf@xxxxxxxxxxx>
Paolo, In proof.st you make the comment that there is no way to fork a Process for Gtk gtkMain. Were you referring to a Smalltalk Process or an OS one? I can see that it isn't going to be totally straightforward, but I see no reason why one shouldn't fork the actual gtk_main call (issues with portability to W*, I suppose). You'd also have to put Gtk in thread-aware mode and synchronize all calls. That seems like hard work, but not /impossible/. Is there something that I've missed? If not, I think I'll give it a go and see what I get. Regards, Mike __________________________________________________ Do you Yahoo!? Yahoo! Mail Plus - Powerful. Affordable. Sign up now. http://mailplus.yahoo.com
Date: January 05, 2003
From: "Bonzini" <bonzini@xxxxxxx>
References:
<3E17F6B6.8020403@xxxxxxx> <3E17F8EF.4000106@xxxxxxx><004d01c2b49d$6473efe0$82011897@bonz
> <3E181B11.3070901@xxxxxxx><003e01c2b4d0$06d3b450$911c1897@bonz
> <3E186345.6000606@xxxxxxx>
I put integration of this little library into the httpd on the TODO list for 2.2; I'll also integrate it with Servlets so that you can serve servlets with a CGI interface as well. It will be slow, however (0.1s on my machine to bring up the image). |_ _ _ __ |_)(_)| ),' ------- '---
Date: January 05, 2003
From: Markus Fritsche <Fritsche.Markus@xxxxxxx>
In-reply-to:
<003e01c2b4d0$06d3b450$911c1897@bonz
>
References:
<3E17F6B6.8020403@xxxxxxx> <3E17F8EF.4000106@xxxxxxx> <004d01c2b49d$6473efe0$82011897@bonz
> <3E181B11.3070901@xxxxxxx> <003e01c2b4d0$06d3b450$911c1897@bonz
>
Bonzini wrote:
printOn: tstream
tstream nextPut: $<; nextPutAll: tag.
....
tstream nextPutAll: ' />' ].
! !
You're right. I have adjusted the methods. Regards, Markus -- http://reauktion.de/archer/Object subclass: #HTML instanceVariableNames: 'tag params data stream' classVariableNames: '' poolDictionaries: '' category: 'MFCGI-Utilities'! HTML comment: ' I am a simple evaluate and transform class. My usage is not as simple as it should be! Example: HTML a: {''href''->''http://reauktion.de/archer'' . ''Markus Fritsche ''} evaluates to: Markus Fritsche HTML br: '' '! HTML methodsFor: 'proxiing'! process: aMessage | arg inst | tag := aMessage selector allButLast. aMessage arguments first isString ifTrue: [ arg := aMessage arguments ] ifFalse: [ arg := aMessage arguments first ifNil: [ {nil} ]]. arg do: [ :i | (i isKindOf: Association) ifTrue: [ self params add: i ] ifFalse: [ self data add: i ] ]. self printOn: stream ! doesNotUnderstand: aMessage ^ self process: aMessage ! ! HTML class methodsFor: 'proxiing'! doesNotUnderstand: aMessage | tstream inst | tstream := WriteStream on: String new. inst := self new. inst stream: tstream. inst process: aMessage. ^ tstream contents ! ! HTML methodsFor: 'conversion'! asString ^self printString ! ! HTML methodsFor: 'printing'! printOn: aStream aStream nextPut: $<; nextPutAll: tag. (self params size > 0) ifTrue: [ self params keysAndValuesDo: [ :k :v | aStream nextPut: $ ; nextPutAll: k; nextPutAll: '="'; nextPutAll: v; nextPut: $" ] ]. (data first isNil) ifFalse: [ aStream nextPut: $>. data do: [ :e | aStream nextPutAll: e asString ]. aStream nextPutAll: ''; nextPutAll: tag; nextPut: $>. ] ifTrue: [ aStream nextPutAll: ' />' ] ! ! HTML class methodsFor: 'instance-creation'! new ^super new initialize ! ! HTML methodsFor: 'initialize-release'! initialize params := Dictionary new. data := OrderedCollection new ! ! HTML methodsFor: 'accessing'! stream: aStream stream := aStream ! stream ^stream ! tag: aString tag := aString ! tag ^tag ! data: anObject data := anObject ! data ^ data ! params ^params ! params: anObject params := anObject ! !
_______________________________________________ help-smalltalk mailing list help-smalltalk@xxxxxxx http://mail.gnu.org/mailman/listinfo/help-smalltalk
Date: January 05, 2003
From: "Bonzini" <bonzini@xxxxxxx>
References:
<3E17F6B6.8020403@xxxxxxx> <3E17F8EF.4000106@xxxxxxx> <004d01c2b49d$6473efe0$82011897@bonz
> <3E181B11.3070901@xxxxxxx>
It is of no use to have #asString do the work on a separate stream; change
it to #printOn: tstream, then you have
process: aMessage
....
self printOn: stream
!
asString
^self printString
!
printOn: tstream
tstream nextPut: $<; nextPutAll: tag.
....
tstream nextPutAll: ' />' ].
! !
Looks nicer :-)
|_ _ _ __
|_)(_)| ),'
------- '---
Date: January 05, 2003
From: "Bonzini" <bonzini@xxxxxxx>
References:
<3E17F6B6.8020403@xxxxxxx> <002e01c2b499$d8eb4b10$82011897@bonz
> <3E182489.9010605@xxxxxxx>
> I should also change the way POST request are processed a bit - making > an XMLRPC (server) implementation in GNU Smalltalk possible. I'm very > busy at the moment, so that would last a bit (although I hope to > implement one until march). But before I have to dive a bit into > WebServer, to make the XMLRPC implementation usable from CGI/Apache and > as a WebServer-Servlet. Simply great. Paolo
Date: January 05, 2003
From: "Bonzini" <bonzini@xxxxxxx>
References:
<3E18232C.90709@xxxxxxx>
> When I do 'configure --enable-modules=tcp; make install', the > installation procedure stops, saying that there is no package named > 'tcp' - since packages.xml only defines the package 'TCP'. So configure with --enable-modules=TCP :-) which AFAIK is what you had to do in 2.0.x as well... However I usually prefer having a vanilla gst.im in the system path (no --enable-modules) and loading modules on-demand in my image. Paolo
Date: January 05, 2003
From: Markus Fritsche <Fritsche.Markus@xxxxxxx>
In-reply-to:
<002e01c2b499$d8eb4b10$82011897@bonz
>
References:
<3E17F6B6.8020403@xxxxxxx> <002e01c2b499$d8eb4b10$82011897@bonz
>
Bonzini wrote:
I've attached some code for GNU Smalltalk that enables a bit of "CGI processing" in GNU Smalltalk (feedback appreciated). How it's used?
Cool, though I still have to look at it. Some of it might be moved to net/httpd under a separate package than WebServer (e.g. cookies).
I should also change the way POST request are processed a bit - making an XMLRPC (server) implementation in GNU Smalltalk possible. I'm very busy at the moment, so that would last a bit (although I hope to implement one until march). But before I have to dive a bit into WebServer, to make the XMLRPC implementation usable from CGI/Apache and as a WebServer-Servlet.
Regards, Markus -- http://reauktion.de/archer/
Date: January 05, 2003
From: Markus Fritsche <Fritsche.Markus@xxxxxxx>
Hi!
When I do 'configure --enable-modules=tcp; make install', the
installation procedure stops, saying that there is no package named
'tcp' - since packages.xml only defines the package 'TCP'.
Regards, Markus -- http://reauktion.de/archer/
Date: January 05, 2003
From: Markus Fritsche <Fritsche.Markus@xxxxxxx>
In-reply-to:
<004d01c2b49d$6473efe0$82011897@bonz
>
References:
<3E17F6B6.8020403@xxxxxxx> <3E17F8EF.4000106@xxxxxxx> <004d01c2b49d$6473efe0$82011897@bonz
>
Bonzini wrote:
Interesting. I would move the actual code to generate HTML to the instance side, so that you can specify a custom stream. Then, the class-side #doesNotUnderstand: would redirect to a particular instance that writes to stdout.
I've changed it so that HTML something: nil! returns '<something />' and (HTML new) stream: stdout; something: nil! writes "<something />" on stdout. Regards, Markus -- http://reauktion.de/archer/Object subclass: #HTML instanceVariableNames: 'tag params data stream' classVariableNames: '' poolDictionaries: '' category: 'MFCGI-Utilities'! HTML comment: ' I am a simple evaluate and transform class. My usage is not as simple as it should be! Example: HTML a: {''href''->''http://reauktion.de/archer'' . ''Markus Fritsche ''} evaluates to: Markus Fritsche HTML br: '' '! HTML methodsFor: 'proxiing'! process: aMessage | arg inst | tag := aMessage selector allButLast. aMessage arguments first isString ifTrue: [ arg := aMessage arguments ] ifFalse: [ arg := aMessage arguments first ifNil: [ {nil} ]]. arg do: [ :i | (i isKindOf: Association) ifTrue: [ self params add: i ] ifFalse: [ self data add: i ] ]. stream nextPutAll: self asString ! doesNotUnderstand: aMessage ^ self process: aMessage ! ! HTML class methodsFor: 'proxiing'! doesNotUnderstand: aMessage | tstream inst | tstream := WriteStream on: String new. inst := self new. inst stream: tstream. inst process: aMessage. ^ tstream contents ! ! HTML methodsFor: 'conversion'! asString | tstream | tstream := WriteStream on: String new. tstream nextPut: $<; nextPutAll: tag. (self params size > 0) ifTrue: [ self params keysAndValuesDo: [ :k :v | tstream nextPut: $ ; nextPutAll: k; nextPutAll: '="'; nextPutAll: v; nextPut: $" ] ]. (data first isNil) ifFalse: [ tstream nextPut: $>. data do: [ :e | tstream nextPutAll: e asString ]. tstream nextPutAll: ''; nextPutAll: tag; nextPut: $>. ] ifTrue: [ tstream nextPutAll: ' />' ]. ^tstream contents ! ! HTML class methodsFor: 'instance-creation'! new ^super new initialize ! ! HTML methodsFor: 'initialize-release'! initialize params := Dictionary new. data := OrderedCollection new ! ! HTML methodsFor: 'accessing'! stream: aStream stream := aStream ! stream ^stream ! tag: aString tag := aString ! tag ^tag ! data: anObject data := anObject ! data ^ data ! params ^params ! params: anObject params := anObject ! !
_______________________________________________ help-smalltalk mailing list help-smalltalk@xxxxxxx http://mail.gnu.org/mailman/listinfo/help-smalltalk
Date: January 05, 2003
From: "Bonzini" <bonzini@xxxxxxx>
References:
<3E17F6B6.8020403@xxxxxxx> <3E17F8EF.4000106@xxxxxxx>
> I forgot: HTMLSupport brings some "HTML templating", this is a test for > a Smalltalk-expression style HTML. Since it is more to write than html, > it is not so useful, but could be enhanced in future. Interesting. I would move the actual code to generate HTML to the instance side, so that you can specify a custom stream. Then, the class-side #doesNotUnderstand: would redirect to a particular instance that writes to stdout. Paolo
Date: January 05, 2003
From: Markus Fritsche <Fritsche.Markus@xxxxxxx>
In-reply-to:
<3E17F6B6.8020403@xxxxxxx>
References:
<3E17F6B6.8020403@xxxxxxx>
Markus Fritsche wrote:I forgot: HTMLSupport brings some "HTML templating", this is a test for a Smalltalk-expression style HTML. Since it is more to write than html, it is not so useful, but could be enhanced in future.
Example:
HTML a: {'href'->'http://www.heise.de/'.'Compu' . HTML br: nil . 'erkram'}!
Use:
HTML [tag]: 'content'!
HTML [tag]: {'parm1'->'val1' . 'parmn'->'valn' . [content] . [content] .
... }!
Regards, Markus -- http://reauktion.de/archer/
Date: January 05, 2003
From: "Bonzini" <bonzini@xxxxxxx>
References:
<3E17F6B6.8020403@xxxxxxx>
> I've attached some code for GNU Smalltalk that enables a bit of "CGI > processing" in GNU Smalltalk (feedback appreciated). How it's used? Cool, though I still have to look at it. Some of it might be moved to net/httpd under a separate package than WebServer (e.g. cookies). > Also, I'd like to have some proposals for some higher level CGI > processing in GNU Smalltalk. What about processing > "multipart/form-data"? Is this needed? Some very basic code for it can be found under the FileServer (net/httpd/FileServer.st). Paolo
Date: January 05, 2003
From: Markus Fritsche <Fritsche.Markus@xxxxxxx>
Hi!I've attached some code for GNU Smalltalk that enables a bit of "CGI processing" in GNU Smalltalk (feedback appreciated). How it's used? FileIn loadCGI.st (no package definition yet, since it is more a draft version):
This loads: SystemAdd.st STTRef.st (this is STT from /net/httpd/ without the STTServlet stuff) Cookie.st CGI.st HTMLSupport.st And adds the namespace MFCGI. configure your httpd (for example, like this): ScriptAlias /scripts/ /home/user/path_to_image/and chmod the image to be executable. Put test.stt somewhere within your webserver. Point your browser to:
http://webserver/scripts/gst.im/path_to_test.stt/test.stt?test=It+works!If I forgot something (that means, you do not see "Hello World it works", let me know.
Also, I'd like to have some proposals for some higher level CGI processing in GNU Smalltalk. What about processing "multipart/form-data"? Is this needed?
Regards, Markus -- http://reauktion.de/archer/
Object subclass: #CGI
instanceVariableNames: 'cgidata mystream htmlentities mimeType cookie
redirect'
classVariableNames: 'Instance'
poolDictionaries: ''
category: 'MFCGI-Utilities'!
CGI comment: '
Copyright (c) 2003 Markus Fritsche
'!
CGI class methodsFor: 'get-Singleton'!
instance
"Store an instance"
^ Instance
! !
CGI class methodsFor: 'auto-startup'!
beNotifiedOnStartUp
"add to ObjectMemory dependants"
ObjectMemory addDependent: self.
ObjectMemory snapshot
! !
CGI class methodsFor: 'notify'!
update: aspect
"be notified on startup"
((aspect == #returnFromSnapshot) and:
[ (Smalltalk getenv: 'GATEWAY_INTERFACE') isNil not ]) ifTrue:
[ self processCGI ]
! !
CGI class methodsFor: 'instance-creation'!
processCGI
"make an instance an process the query"
Instance := self new.
Instance processCGI.
^ Instance
! !
CGI methodsFor: 'processing'!
processCGI
"look which data we got"
| qrystring contenttype f stt |
qrystring := Smalltalk getenv: 'QUERY_STRING'.
qrystring isNil ifFalse:
[ self decodeQuery: qrystring ] ifTrue:
[ contenttype := Smalltalk getenv: 'CONTENT_TYPE'.
contenttype = 'x-www-form-urlencoded' ifTrue:
[ qrystring := stdin next: (Smalltalk getenv: 'CONTENT_LENGTH')
asInteger ] ifFalse:
[ 'multipart/form-data' = contenttype ifTrue:
[ self handleUpload: (stdin next: (Smalltalk getenv:
'CONTENT_LENGTH') asInteger). ] ifFalse:
[ self error: 'Couldn''t decode request' ].
]
].
(File exists: self sttName) ifTrue:
[ f := File name: self sttName.
stt := f readStream contents.
self output: ((STTTemplate on: stt) evaluateOn: self)
] ifFalse: [ CGI output: 'schade' ].
ObjectMemory quit.
!
decodeQuery: aString
"decode of an URL encoded string"
| pairs unescaped pair |
cgidata := Dictionary new.
unescaped := NetClients.URL decode: aString.
pairs := unescaped substrings: $&.
pairs do: [ :pairStr |
pair := pairStr substrings: $=.
cgidata at: (pair at: 1) put: (pair at: 2)]
! !
CGI methodsFor: 'accessing'!
cgidata
^ cgidata
!
varget: name
^ cgidata at: name ifAbsent: []
!
instance
^ self class instance
!
redirect: aString
redirect := aString
!
mimeType
^ mimeType
!
mimeType: aString
mimeType := aString
!
stream: aStream
mystream := aStream
!
stream
^ mystream ifNil: [ mystream := stdout ]
! !
CGI methodsFor: 'output'!
output: aString
self stream nextPutAll: aString.
!
outHtmlEscaped: aString
self stream nextPutAll: aString asHtmlString
!
outputStream: aStream
"output the contents of a stream"
self stream nextPutAll: aStream contents.
!
crlf
self stream nextPut: Character cr; nextPut: Character lf
! !
CGI methodsFor: 'information'!
sttName
^Smalltalk getenv: 'PATH_TRANSLATED'
!
scriptpath
| scriptadr c |
scriptadr := Smalltalk getenv: 'PATH_INFO'.
c := (scriptadr substrings: $/) removeLast.
c do: [ :s | scriptadr := scriptadr, '/', s ].
^ scriptadr
!
pathinfo
^Smalltalk getenv: 'PATH_INFO'
!
scriptadr
^((Smalltalk getenv: 'SCRIPT_NAME'), (self pathinfo))
! !
CGI methodsFor: 'http-out'!
httpHeader
self output: 'Content-Type: '.
mimeType isNil ifFalse:
[ self output: mimeType ] ifTrue:
[ self output: 'text/html'; crlf ].
cookie ifNotNil:
[ self output: 'Set-Cookie: ';
output: cookie asString; crlf ].
redirect ifNotNil:
[ self output: 'Location ';
output: redirect; crlf ].
self crlf; yourself
! !
NameSpace current: MFCGI!
Object subclass: #Cookie
instanceVariableNames: 'name value expires path secure domain'
classVariableNames: ''
poolDictionaries: ''
category: 'MFCGI-Utilities'!
Cookie comment: '
Copyright (c) 2003 Markus Fritsche
'!
Cookie class methodsFor: 'decoding'!
get: aString
"get the value of a cookie identified by aString"
| cookieStr cookies |
cookieStr := (Smalltalk getenv: 'HTTP_COOKIE'), ';'.
cookies := cookieStr substrings: $;.
cookies do: [ :cookie | (cookie startsWith: aString) ifTrue: [
^ NetClients.URL decode: ((cookie substrings: $=) at: 2)]].
^ ''!
!
Cookie methodsFor: 'accessing'!
name: aString
name := aString
!
value: aString
value := aString
!
expires: aDateTime
"set the expiry date for a cookie"
expires := aDateTime asUTC
!
path: aString
path := aString
!
domain: aString
domain := aString
!
secure: aString
secure := aString
!
asString
"output the cookie as a string"
| str dateStr |
str := WriteStream on: String new.
((value isNil) or: [ name isNil ]) ifTrue: [ ^ '' ].
str nextPutAll: name; nextPut: $=; nextPutAll: (NetClients.URL encode:
value).
expires ifNotNil: [ :asd |
dateStr := WriteStream on: String new.
dateStr nextPutAll: expires dayName; nextPutAll: ', ';
nextPutAll: expires day printString; nextPut: $-;
nextPutAll: expires month printString; nextPut: $-;
nextPutAll: expires year printString; nextPut: $ ;
nextPutAll: expires hour24 printString; nextPut: $:;
nextPutAll: expires minute printString; nextPut: $:;
nextPutAll: expires second printString; nextPutAll: ' GMT'.
str nextPutAll: (self pvtoptional: dateStr contents what: 'expires')].
str nextPutAll: (self pvtoptional: path what: 'path').
str nextPutAll: (self pvtoptional: domain what: 'domain').
str nextPutAll: (self pvtoptional: secure what: 'secure').
^ str contents
!
asHttpEquiv
"to set a cookie within the html page after the HTTPHeader is written"
| str |
str := WriteStream on: String new.
str nextPutAll: '<meta http-equiv="Set-Cookie" content="';
nextPutAll: self asString; nextPut: $";
nextPut: $>; cr; nextPut: Character lf.
^ str contents
!
!
Cookie methodsFor: 'private'!
pvtoptional: aString what: secString
"private"
aString ifNotNil: [ :asd |
^ ('; ', secString, '=', aString)].
^ ''
! !
Object subclass: #HTML
instanceVariableNames: 'tag params data'
classVariableNames: ''
poolDictionaries: ''
category: 'MFCGI-Utilities'!
HTML comment: '
I am a simple evaluate and transform class. My usage is not as simple as
it should be!
Example:
HTML a: {''href''->''http://reauktion.de/archer'' . ''Markus Fritsche ''}
evaluates to:
Markus Fritsche
HTML br: ''
'!
HTML class methodsFor: 'proxiing'!
doesNotUnderstand: aMessage
| inst arg |
inst := self new.
inst tag: aMessage selector allButLast.
aMessage arguments first isString ifTrue:
[ arg := aMessage arguments ] ifFalse:
[ arg := aMessage arguments first ifNil: [ {nil} ]].
arg do: [ :i |
(i isKindOf: Association) ifTrue: [
inst params add: i
] ifFalse: [
inst data add: i
]
].
^ inst asString
! !
HTML methodsFor: 'conversion'!
asString
| stream |
stream := WriteStream on: String new.
stream nextPut: $<; nextPutAll: tag.
(self params size > 0) ifTrue:
[ self params keysAndValuesDo: [ :k :v |
stream nextPut: $ ; nextPutAll: k;
nextPutAll: '="'; nextPutAll: v;
nextPut: $"
]
].
(data first isNil) ifFalse: [
stream nextPut: $>.
data do: [ :e | stream nextPutAll: e asString ].
stream nextPutAll: ''; nextPutAll: tag; nextPut: $>. ] ifTrue: [
stream nextPutAll: ' />' ].
^stream contents
! !
HTML class methodsFor: 'instance-creation'!
new
^super new initialize
! !
HTML methodsFor: 'initialize-release'!
initialize
params := Dictionary new.
data := OrderedCollection new
! !
HTML methodsFor: 'accessing'!
tag: aString
tag := aString
!
tag
^tag
!
data: anObject
data := anObject
!
data
^ data
!
params
^params
!
params: anObject
params := anObject
! !
"=====================================================================
|
| Smalltalk templates
|
|
======================================================================"
"======================================================================
|
| Copyright 2002 Federico G. Stilman
| Porting by Markus Fritsche and Paolo Bonzini
| Integration with the web server framework by Paolo Bonzini.
|
| This file is part of GNU Smalltalk.
|
| 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.LIB.
| If not, write to the Free Software Foundation, 59 Temple Place - Suite
| 330, Boston, MA 02111-1307, USA.
|
======================================================================"
Object subclass: #STTTemplate
instanceVariableNames: 'sttCode cache asStringSelector'
classVariableNames: ''
poolDictionaries: ''
category: 'Web-STT'!
STTTemplate comment:
'This class implements template à la JSP, PHP, ASP (ugh!), and so on.
Smalltalk code is included between {% and %} tags. The only caution
is not to include comments between a period or an open parentheses
of any kind, and the closing %}.
For example
%{ "Comment" 1 to: 5 do: [ %} yes<br> %{ ] %} is valid
%{ 1 to: 5 do: [ "Comment" %} yes<br> %{ ] %} is not valid
This restriction might be removed in the future.
The template is evaluated by sending #evaluateOn: or #evaluateOn:stream:
and returns the output stream (available to the code as the variable `out'').
The first (or only) argument of these two methods is available to the
code as `self'').'!
!STTTemplate methodsFor: 'caching'!
cache
"Returns the receiver's cached object"
^cache!
cache: anObject
"Save anObject in the receiver's cache"
cache := anObject!
initializeCache
"Initialize the receiver's cache"
cache := nil.!
isCached
"Tell if the receiver is cached or not. In the future
this will consider the fact that a cached object may
become old after some time, and that means that the
object is NOT cached anymore."
^self cache notNil! !
!STTTemplate methodsFor: 'private'!
asSmalltalkCodeOn: anObject
"Returns the equivalent version of the receiver as a Smalltalk
CompiledMethod"
| method stream |
self isCached ifTrue: [ ^self cache ].
stream := String new writeStream.
self writeSmalltalkCodeOn: stream.
method := anObject class compileString: stream contents.
self cache: method.
anObject class removeSelector: method selector.
^method
!
writeSmalltalkCodeOn: stream
"Write the equivalent version of the receiver as Smalltalk code
on the given stream"
| sttOpenIndex sttCloseIndex lastIndex sttCodeIndex smalltalkExpression |
stream
nextPutAll: 'STT_Cache';
print: self asOop;
nextPutAll: ': out';
nl.
lastIndex := 1.
[ (sttOpenIndex := self sttCode
indexOfSubCollection: '{%' startingAt: lastIndex) > 0] whileTrue: [
self
writeOutputCodeFor: (self sttCode copyFrom: lastIndex to:
sttOpenIndex - 1)
on: stream.
sttCloseIndex := self sttCode
indexOfSubCollection: '%}'
startingAt: sttOpenIndex
ifAbsent: [ ^ self error: 'Missing closing tag' ].
sttCodeIndex := sttOpenIndex + 2.
(sttCode at: sttOpenIndex + 2) = $=
ifTrue: [
stream nextPutAll: 'out nextPutAll: ('.
sttCodeIndex := sttCodeIndex + 1 ].
smalltalkExpression := sttCode copyFrom: sttCodeIndex to: sttCloseIndex
- 1.
smalltalkExpression := smalltalkExpression trimSeparators.
stream nextPutAll: smalltalkExpression.
(sttCode at: sttOpenIndex + 2) = $=
ifTrue: [
stream nextPutAll: ') ', self asStringSelector asString.
sttCodeIndex := sttCodeIndex + 1.
].
('|[({.' includes: smalltalkExpression last)
ifFalse: [ stream nextPut: $. ].
stream nl.
lastIndex := sttCloseIndex + 2.
].
self
writeOutputCodeFor: (self sttCode copyFrom: lastIndex to: sttCode size)
on: stream.
stream
nextPutAll: '^out'.
!
writeOutputCodeFor: aString on: aStream
"Writes on aStream the required Smalltalk code for outputing aString on
'out'"
aStream
nextPutAll: 'out nextPutAll: ''';
nextPutAll: aString;
nextPutAll: '''.';
nl! !
!STTTemplate methodsFor: 'evaluating'!
evaluateOn: anObject
"Evaluates the receiver to anObject"
^(self evaluateOn: anObject stream: String new writeStream) contents
!
evaluateOn: anObject stream: out
"Evaluates the receiver to anObject"
^anObject perform: (self asSmalltalkCodeOn: anObject) with: out
! !
!STTTemplate methodsFor: 'accessing'!
sttCode
"Returns the receiver's Smalltalk Template code"
^sttCode!
asStringSelector
"Returns the selector used to show objects as Strings on the receiver"
^asStringSelector!
asStringSelector: aSymbol
"Sets the selector used to show objects as Strings on the receiver"
asStringSelector := aSymbol! !
!STTTemplate methodsFor: 'initializing'!
initializeOn: aString asStringSelector: aSymbol
sttCode := aString.
asStringSelector := aSymbol.
self initializeCache.! !
!STTTemplate class methodsFor: 'unit testing'!
test
| sttTest |
sttTest := '
<html>
<head><title>{%= self class %}</title></head>
<body>
<table>
{% self to: 10 do: [ :each | %}
<tr>
<td>{%= each printString %}</td>
<td>{%= (each * 2) printString %}</td>
</tr>
{% ] %}
</table>
</body>
</html>'.
^(STTTemplate on: sttTest) evaluateOn: 1!
test2
| sttTest |
sttTest := '
<html>
<head><title>{%= self class %}</title></head>
{%
out nextPutAll: ''This is another test''; nl.
1 to: 15 do: [:x |
out nextPutAll: ''<p>This paragraph was manually sent out
'',
(self * x) printString, ''</p>''; nl ].
out nextPutAll: ''After all this ST code goes the final HTML
closing tag''.
%}
</html>'.
^(STTTemplate on: sttTest) evaluateOn: 3! !
!STTTemplate class methodsFor: 'instance creation'!
on: aString
"Creates an instance of the receiver on aString"
^self on: aString asStringSelector: self defaultAsStringSelector!
on: aString asStringSelector: aSymbol
"Creates an instance of the receiver on aString"
^self new initializeOn: aString asStringSelector: aSymbol! !
!STTTemplate class methodsFor: 'defaults'!
defaultAsStringSelector
^#displayString! !
!STTResponse class methodsFor: 'responding'!
respondTo: aRequest with: aSTTTemplate
self new
stt: aSTTTemplate;
respondTo: aRequest! !
String methodsFor: 'conversion'!
asHtmlString
"convert the String to an HTML escaped string"
| d stream |
stream := WriteStream on: String new.
d := Dictionary new.
d at: Character cr put: ' ';
at: Character lf put: ' ';
at: Character tab put: '	';
at: $& put: '&';
at: $ put: ' ';
at: $< put: '<';
at: $> put: '>';
at: $" put: '"'.
self do: [ :c |
stream nextPutAll: (d at: c ifAbsent: [String with: c])].
^stream contents
! !
String methodsFor: 'copying'!
allButLast
^ self copyFrom: 1 to: self size - 1
! !
Smalltalk addSubspace: #MFCGI.
#(
'CGI.st'
'Cookie.st'
'STTRef.st'
) do: [ :file | FileStream fileIn: file ].
ObjectMemory addDependent: CGI!
Namespace current: Smalltalk!
{% self httpHeader %}
_______________________________________________ help-smalltalk mailing list help-smalltalk@xxxxxxx http://mail.gnu.org/mailman/listinfo/help-smalltalk
Date: January 04, 2003
From: "Bonzini" <bonzini@xxxxxxx>
I'm about to release 2.0.11; I've backported a number of fixes there from the development branch, as well as the bugs that David Forster and Peter Schueller reported and in operation without GMP. The JIT is a bit more stable. Since this is going to be at least in my intention the last 2.0.x release, I'm only putting a pre-release of it on alpha.gnu.org I also released another post-feature-freeze release from the will-be-2.1 branch. It has all the bugfixes in 2.0.11, a few Blox+browser fixes, and it includes the ability to syntax highlight class definitions as well and a (working) Ctrl+S binding for Accept in the class browser. The same bugfix for the JIT has been applied here too, though there are still a few problems that I'm going to address soon. ftp://alpha.gnu.org/gnu/smalltalk/smalltalk-2.0.11.tar.gz ftp://alpha.gnu.org/gnu/smalltalk/smalltalk-2.0.10-2.0.11.diff.gz ftp://alpha.gnu.org/gnu/smalltalk/smalltalk-2.0h.tar.gz ftp://alpha.gnu.org/gnu/smalltalk/smalltalk-2.0g-2.0h.diff.gz |_ _ _ __ |_)(_)| ),' ------- '---
Date: January 02, 2003
From: "Bonzini" <bonzini@xxxxxxx>
References:
<20030101230735.46771.qmail@xxxxxxxxxxxxxxxxxxxxxxx>
> make[4]: *** No rule to make target `handler.c', > needed by `handler.lo'. Sorry, I could not reproduce this. I did find a bug in sigsegv/configure.in that could cause this error, but only if you ran config.status manually; not by ./configure && make. Please send me your sigsegv/config.log file and the output of ls -lR sigsegv (to detect dangling symlinks and the like). Paolo
Date: January 01, 2003
From: David Forster <dforster89@xxxxxxxxxxxxx>
Per Paolo Bonzini's request, I'm CC:'ing this post to
help-smalltalk@xxxxxxx for archival purposes...
Date: Mon, 30 Dec 2002 15:15:30 -0700
Subject: Fix (?) for strange CObject at:type: behavior
Hi Paolo,
I've discovered what appears to be a bug in VMpr_CObject_at
(prims.inl:4533). When the passed type is a real CType instead of an
integer type, the stack gets messed up:
SET_STACKTOP (_gst_c_object_new_typed (addr, oop3));
As far as I could figure out, _gst_c_object_new_typed does not place
it's return OOP on the stack, thus messing the stack up (?). Or at
the very least, there's something else below it on the stack. At any
rate, changing SET_STACKTOP to PUSH_OOP solved the problem for me and
seems to work...
Here's the code that triggered it for me:
listDepthsOfScreen: aScreen
"Return a list of all depths supported by the given screen."
| nCReturn cList result block v idx |
nCReturn := CInt new: (CInt sizeof).
cList := self cXListDepths: self a2: aScreen a3: nCReturn.
result := Set new.
(nCReturn value) printNl.
block := [ :x |
x display.
' ' display.
idx := ((CIntType sizeof) * x).
x display.
' ' display.
idx display.
' ' display.
v := (cList at: idx type: CIntType).
x display.
' ' display.
v := v value.
x display.
' - ' display.
v displayNl.
result add: v.].
0 to: ((nCReturn value) - 1) do: block.
nCReturn free.
cList free. "FIXME: Use XFree"
^result.
!
This returns the correct result, but it prints out:
st> x listDepthsOfScreen: 0!
7
0 0 0 CInt(16r83D2010) 24 - 24
1 1 4 CInt(16r83D2014) 1 - 1
2 2 8 CInt(16r83D2018) 4 - 4
3 3 12 CInt(16r83D201C) 8 - 8
4 4 16 CInt(16r83D2020) 15 - 15
5 5 20 CInt(16r83D2024) 16 - 16
6 6 24 CInt(16r83D2028) 32 - 32
Somehow `x' is getting corrupted with the value of `v'. And if I
eliminate `block' and just pass the block directly to to:do: it works
OK, but will only call the block ONCE (thus only returning a set with
`24' in it.). If I make `v' a temporary inside the block, it enters
an infinite loop.
If I pass `10' as the type everything works OK.
The above method can be pasted right into my previous Xlib bindings
code in Xlib_Display.st:269. Then to repeat run under X:
FileStream fileIn: 'Xlib.st'!
Smalltalk at: #x put: (Xlib Display new)!
x listDepthsOfScreen: 0!
This is with Debian GNU/Linux 3.0 and GNU Smalltalk 2.0.10.
Thanks,
-Dave
Date: January 01, 2003
From: "Bonzini" <bonzini@xxxxxxx>
This patch fixes the bugs in the Smalltalk code that runs instead of GMP, and that caused the two test failures you reported. (The patch applies cleanly to both 2.0.10 and 2.0g) |_ _ _ __ |_)(_)| ),' ------- '---
largeinteger-fixes.patch
Description: Binary data
_______________________________________________ help-smalltalk mailing list help-smalltalk@xxxxxxx http://mail.gnu.org/mailman/listinfo/help-smalltalk
Date: January 01, 2003
From: "Paolo Bonzini" <bonzini@xxxxxxx>
References:
<20030101152709.94098.qmail@xxxxxxxxxxxxxxxxxxxxxxx>
> This is with gcc 2.96 (Mandrake 8.2), which doesn't > seem to recognize the -MF option (at least, it's not > documented). I'm going to try again with > 3.0.<notsure>, since that's conveniently available as > an RPM. No, the Makefile's wrong. You can fix it by installing libtool. Use gcc 3.2.1 if you're going to install a new gcc. -MF is checked by configure, so it's fine. If it were misdetected it would fail all over the build process. Paolo
Date: January 01, 2003
From: MSA or SJF <msasjf@xxxxxxxxxxx>
Same problem in both - make fails with: ... gcc -DHAVE_CONFIG_H -I. -I. -I.. -I.. -g -O2 -MT dl-no.lo -MD -MP -MF .deps/dl-n o.Tpo -c dl-no.c -fPIC -DPIC -o .libs/dl-no.lo dl-no.c:40:18: ltdl.h: No such file or directory make[5]: *** [dl-no.lo] Error 1 make[5]: Leaving directory `/home/mike/install/smalltalk-2.0g/snprintfv/snprintf v' ... This is with gcc 2.96 (Mandrake 8.2), which doesn't seem to recognize the -MF option (at least, it's not documented). I'm going to try again with 3.0.<notsure>, since that's conveniently available as an RPM. Mike __________________________________________________ Do you Yahoo!? Yahoo! Mail Plus - Powerful. Affordable. Sign up now. http://mailplus.yahoo.com