changeset 2039:3d10ae22abd6

Default 'jsFunc' for less-safe FFI
author Adam Chlipala <adam@chlipala.net>
date Wed, 16 Jul 2014 04:06:11 -0400
parents ec2c7a22df0d
children 8ea382a57ce2
files doc/manual.tex src/corify.sml tests/lessSafeFfi.ur
diffstat 3 files changed, 10 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/doc/manual.tex	Sun Jul 13 06:14:23 2014 -0400
+++ b/doc/manual.tex	Wed Jul 16 04:06:11 2014 -0400
@@ -2552,6 +2552,8 @@
 \item \texttt{jsFunc "putJsFuncNameHere"}
 \end{itemize}
 
+When no \texttt{jsFunc} directive is present, the function is assumed to map to a JavaScript function of the same name, if used in a client-side context.
+
 
 \section{Compiler Phases}
 
--- a/src/corify.sml	Sun Jul 13 06:14:23 2014 -0400
+++ b/src/corify.sml	Wed Jul 16 04:06:11 2014 -0400
@@ -1221,6 +1221,11 @@
                   | Source.ServerOnly => Settings.addServerOnly name
                   | Source.JsFunc s => Settings.addJsFunc (name, s)) modes;
 
+            if List.exists (fn Source.JsFunc _ => true | _ => false) modes then
+                ()
+            else
+                Settings.addJsFunc (name, #2 name);
+
             if isTrans andalso not (Settings.isBenignEffectful name) then
                 Settings.addEffectful name
             else
--- a/tests/lessSafeFfi.ur	Sun Jul 13 06:14:23 2014 -0400
+++ b/tests/lessSafeFfi.ur	Wed Jul 16 04:06:11 2014 -0400
@@ -4,13 +4,15 @@
 ffi adder : int -> int -> int
 
 ffi bup jsFunc "alert" : string -> transaction unit
+ffi alert : string -> transaction unit
 
 fun other () : transaction page =
     (*bar 17;
     q <- baz;*)
     return <xml><body>
       (*{[foo 42]}, {[q]}*)
-      <button onclick={fn _ => bup "asdf"}/>
+      <button value="bup" onclick={fn _ => bup "asdf"}/>
+      <button value="alert" onclick={fn _ => alert "qqqz"}/>
     </body></xml>
 
 fun main () = return <xml><body>