annotate demo/noisy.ur @ 1739:c414850f206f

Add support for -boot flag, which allows in-tree execution of Ur/Web The boot flag rewrites most hardcoded paths to point to the build directory, and also forces static compilation. This is convenient for developing Ur/Web, or if you cannot 'sudo make install' Ur/Web. The following changes were made: * Header files were moved to include/urweb instead of include; this lets FFI users point their C_INCLUDE_PATH at this directory at write <urweb/urweb.h>. For internal Ur/Web executables, we simply pass -I$PATH/include/urweb as normal. * Differentiate between LIB and SRCLIB; SRCLIB is Ur and JavaScript source files, while LIB is compiled products from libtool. For in-tree compilation these live in different places. * No longer reference Config for paths; instead use Settings; these settings can be changed dynamically by Compiler.enableBoot () (TODO: add a disableBoot function.) * config.h is now generated directly in include/urweb/config.h, for consistency's sake (especially since it gets installed along with the rest of the headers!) * All of the autotools build products got updated. * The linkStatic field in protocols now only contains the name of the build product, and not the absolute path. Future users have to be careful not to reference the Settings files to early, lest they get an old version (this was the source of two bugs during development of this patch.)
author Edward Z. Yang <ezyang@mit.edu>
date Wed, 02 May 2012 17:17:57 -0400
parents ed06e25c70ef
children e6bc6bbd7a32
rev   line source
adamc@651 1 datatype list t = Nil | Cons of t * list t
adamc@651 2
adamc@651 3 table t : { Id : int, A : string }
adamc@708 4 PRIMARY KEY Id
adamc@651 5
adamc@651 6 fun add id s =
adamc@651 7 dml (INSERT INTO t (Id, A) VALUES ({[id]}, {[s]}))
adamc@651 8
adamc@651 9 fun del id =
adamc@651 10 dml (DELETE FROM t WHERE t.Id = {[id]})
adamc@651 11
adamc@651 12 fun lookup id =
adamc@651 13 ro <- oneOrNoRows (SELECT t.A FROM t WHERE t.Id = {[id]});
adamc@651 14 case ro of
adamc@651 15 None => return None
adamc@651 16 | Some r => return (Some r.T.A)
adamc@651 17
adamc@651 18 fun check ls =
adamc@651 19 case ls of
adamc@651 20 Nil => return ()
adamc@651 21 | Cons (id, ls') =>
adamc@908 22 ao <- rpc (lookup id);
adamc@651 23 alert (case ao of
adamc@651 24 None => "Nada"
adamc@651 25 | Some a => a);
adamc@651 26 check ls'
adamc@651 27
adamc@782 28 fun main () =
adamc@651 29 idAdd <- source "";
adamc@651 30 aAdd <- source "";
adamc@651 31
adamc@651 32 idDel <- source "";
adamc@651 33
adamc@651 34 return <xml><body>
adamc@651 35 <button value="Check values of 1, 2, and 3" onclick={check (Cons (1, Cons (2, Cons (3, Nil))))}/><br/>
adamc@651 36 <br/>
adamc@908 37 <button value="Add" onclick={id <- get idAdd; a <- get aAdd; rpc (add (readError id) a)}/>
adamc@651 38 <ctextbox source={idAdd}/>
adamc@651 39 <ctextbox source={aAdd}/><br/>
adamc@651 40 <br/>
adamc@908 41 <button value="Delete" onclick={id <- get idDel; rpc (del (readError id))}/>
adamc@651 42 <ctextbox source={idDel}/>
adamc@651 43 </body></xml>