# HG changeset patch # User Adam Chlipala # Date 1241280643 14400 # Node ID df09c95085f8fab7e6534e409a4d70038ec2cc57 # Parent a28982de56455c8c385e29af5d60937973a75360 More FFI compiler options diff -r a28982de5645 -r df09c95085f8 src/cjr_print.sml --- a/src/cjr_print.sml Sat May 02 11:27:26 2009 -0400 +++ b/src/cjr_print.sml Sat May 02 12:10:43 2009 -0400 @@ -2839,6 +2839,8 @@ ^ OS.Path.joinDirFile {dir = Settings.getUrlPrefix (), file = "app.js"} ^ "\\\">\\n"), + p_list (fn x => string ("")) + (Settings.getScripts ()), string "\");", newline, string "uw_set_needs_push(ctx, ", diff -r a28982de5645 -r df09c95085f8 src/compiler.sig --- a/src/compiler.sig Sat May 02 11:27:26 2009 -0400 +++ b/src/compiler.sig Sat May 02 12:10:43 2009 -0400 @@ -41,6 +41,7 @@ ffi : string list, link : string list, headers : string list, + scripts : string list, clientToServer : Settings.ffi list, effectful : Settings.ffi list, clientOnly : Settings.ffi list, diff -r a28982de5645 -r df09c95085f8 src/compiler.sml --- a/src/compiler.sml Sat May 02 11:27:26 2009 -0400 +++ b/src/compiler.sml Sat May 02 12:10:43 2009 -0400 @@ -45,6 +45,7 @@ ffi : string list, link : string list, headers : string list, + scripts : string list, clientToServer : Settings.ffi list, effectful : Settings.ffi list, clientOnly : Settings.ffi list, @@ -208,7 +209,7 @@ print = SourcePrint.p_file} fun p_job {prefix, database, exe, sql, sources, debug, profile, - timeout, ffi, link, headers, + timeout, ffi, link, headers, scripts, clientToServer, effectful, clientOnly, serverOnly, jsFuncs} = let open Print.PD @@ -241,6 +242,7 @@ newline, p_list_sep (box []) (fn s => box [string "Ffi", space, string s, newline]) ffi, p_list_sep (box []) (fn s => box [string "Header", space, string s, newline]) headers, + p_list_sep (box []) (fn s => box [string "Script", space, string s, newline]) scripts, p_list_sep (box []) (fn s => box [string "Link", space, string s, newline]) link, p_ffi "ClientToServer" clientToServer, p_ffi "Effectful" effectful, @@ -305,6 +307,7 @@ val ffi = ref [] val link = ref [] val headers = ref [] + val scripts = ref [] val clientToServer = ref [] val effectful = ref [] val clientOnly = ref [] @@ -323,6 +326,7 @@ ffi = rev (!ffi), link = rev (!link), headers = rev (!headers), + scripts = rev (!scripts), clientToServer = rev (!clientToServer), effectful = rev (!effectful), clientOnly = rev (!clientOnly), @@ -387,6 +391,7 @@ | "ffi" => ffi := relify arg :: !ffi | "link" => link := relifyA arg :: !link | "include" => headers := relifyA arg :: !headers + | "script" => scripts := arg :: !scripts | "clientToServer" => clientToServer := ffiS () :: !clientToServer | "effectful" => effectful := ffiS () :: !effectful | "clientOnly" => clientOnly := ffiS () :: !clientOnly @@ -402,6 +407,7 @@ Settings.setUrlPrefix (#prefix job); Settings.setTimeout (#timeout job); Settings.setHeaders (#headers job); + Settings.setScripts (#scripts job); Settings.setClientToServer (#clientToServer job); Settings.setEffectful (#effectful job); Settings.setClientOnly (#clientOnly job); diff -r a28982de5645 -r df09c95085f8 src/demo.sml --- a/src/demo.sml Sat May 02 11:27:26 2009 -0400 +++ b/src/demo.sml Sat May 02 12:10:43 2009 -0400 @@ -98,6 +98,7 @@ ffi = [], link = [], headers = [], + scripts = [], clientToServer = [], effectful = [], clientOnly = [], diff -r a28982de5645 -r df09c95085f8 src/settings.sig --- a/src/settings.sig Sat May 02 11:27:26 2009 -0400 +++ b/src/settings.sig Sat May 02 12:10:43 2009 -0400 @@ -39,6 +39,10 @@ val setHeaders : string list -> unit val getHeaders : unit -> string list + (* Which extra JavaScript URLs should be included? *) + val setScripts : string list -> unit + val getScripts : unit -> string list + type ffi = string * string (* Which FFI types may be sent from clients to servers? *) diff -r a28982de5645 -r df09c95085f8 src/settings.sml --- a/src/settings.sml Sat May 02 11:27:26 2009 -0400 +++ b/src/settings.sml Sat May 02 12:10:43 2009 -0400 @@ -30,6 +30,7 @@ val urlPrefix = ref "/" val timeout = ref 0 val headers = ref ([] : string list) +val scripts = ref ([] : string list) fun getUrlPrefix () = !urlPrefix fun setUrlPrefix p = @@ -46,6 +47,9 @@ fun getHeaders () = !headers fun setHeaders ls = headers := ls +fun getScripts () = !scripts +fun setScripts ls = scripts := ls + type ffi = string * string structure K = struct diff -r a28982de5645 -r df09c95085f8 tests/cffi.ur --- a/tests/cffi.ur Sat May 02 11:27:26 2009 -0400 +++ b/tests/cffi.ur Sat May 02 12:10:43 2009 -0400 @@ -1,6 +1,12 @@ +fun printer () = Test.foo + fun effect () = Test.print; - return + return +