diff options
author | Adam Chlipala <adam@chlipala.net> | 2011-08-21 10:55:31 -0400 |
---|---|---|
committer | Adam Chlipala <adam@chlipala.net> | 2011-08-21 10:55:31 -0400 |
commit | 1e022eb78e7ca3fd15634e3845756b9c14209cf3 (patch) | |
tree | 0838befdc51675455f8e33e979e23dcfaf06eeb5 | |
parent | f1096b0e7bd380e9ccfb1438548596fe9e9ab5e9 (diff) |
Add prototypes for [un]urlification functions
-rw-r--r-- | src/cjr_print.sml | 76 | ||||
-rw-r--r-- | tests/rpcNested.ur | 16 |
2 files changed, 88 insertions, 4 deletions
diff --git a/src/cjr_print.sml b/src/cjr_print.sml index fb36e36e..0b900218 100644 --- a/src/cjr_print.sml +++ b/src/cjr_print.sml @@ -524,7 +524,7 @@ fun capitalize s = str (Char.toUpper (String.sub (s, 0))) ^ String.extract (s, 1, NONE) local - val urlHandlers = ref ([] : pp_desc list) + val urlHandlers = ref ([] : (pp_desc * pp_desc) list) in fun addUrlHandler v = urlHandlers := v :: !urlHandlers @@ -648,6 +648,14 @@ fun unurlify fromClient env (t, loc) = space, string "*unurlify_", string (Int.toString i), + string "(uw_context, char **);", + newline], + box [string "static", + space, + p_typ env t, + space, + string "*unurlify_", + string (Int.toString i), string "(uw_context ctx, char **request) {", newline, box [string "return ((*request)[0] == '/' ? ++*request : *request,", @@ -799,6 +807,14 @@ fun unurlify fromClient env (t, loc) = space, string "unurlify_", string (Int.toString i), + string "(uw_context, char **);", + newline], + box [string "static", + space, + p_typ env (t, ErrorMsg.dummySpan), + space, + string "unurlify_", + string (Int.toString i), string "(uw_context ctx, char **request) {", newline, box [string "return", @@ -828,6 +844,14 @@ fun unurlify fromClient env (t, loc) = space, string "unurlify_list_", string (Int.toString i), + string "(uw_context, char **);", + newline], + box [string "static", + space, + p_typ env (t, loc), + space, + string "unurlify_list_", + string (Int.toString i), string "(uw_context ctx, char **request) {", newline, box [string "return ((*request)[0] == '/' ? ++*request : *request,", @@ -1037,6 +1061,22 @@ fun urlify env t = space, string "urlify_", string (Int.toString i), + string "(uw_context,", + space, + p_typ env t, + space, + if isUnboxable t then + box [] + else + string "*", + string ");", + newline], + box [string "static", + space, + string "void", + space, + string "urlify_", + string (Int.toString i), string "(uw_context ctx,", space, p_typ env t, @@ -1153,6 +1193,17 @@ fun urlify env t = space, string "urlify_", string (Int.toString i), + string "(uw_context,", + space, + p_typ env t, + string ");", + newline], + box [string "static", + space, + string "void", + space, + string "urlify_", + string (Int.toString i), string "(uw_context ctx,", space, p_typ env t, @@ -1226,6 +1277,19 @@ fun urlify env t = space, string "urlifyl_", string (Int.toString i), + string "(uw_context,", + space, + string "struct __uws_", + string (Int.toString i), + space, + string "*);", + newline], + box [string "static", + space, + string "void", + space, + string "urlifyl_", + string (Int.toString i), string "(uw_context ctx,", space, string "struct __uws_", @@ -2323,8 +2387,10 @@ fun p_file env (ds, ps) = val (pds, env) = ListUtil.foldlMap (fn (d, env) => let val d' = p_decl env d + val hs = latestUrlHandlers () + val (protos, defs) = ListPair.unzip hs in - (box (List.revAppend (latestUrlHandlers (), [d'])), + (box (List.revAppend (protos, (List.revAppend (defs, [d'])))), E.declBinds env d) end) env ds @@ -2848,7 +2914,8 @@ fun p_file env (ds, ps) = in (p', latestUrlHandlers () @ handlers) end) [] ps - + val (protos, defs) = ListPair.unzip handlers + val hasDb = ref false val tables = ref [] val views = ref [] @@ -3120,7 +3187,8 @@ fun p_file env (ds, ps) = newline, newline, - box (rev handlers), + box (rev protos), + box (rev defs), string "static void uw_handle(uw_context ctx, char *request) {", newline, diff --git a/tests/rpcNested.ur b/tests/rpcNested.ur new file mode 100644 index 00000000..4d8923bb --- /dev/null +++ b/tests/rpcNested.ur @@ -0,0 +1,16 @@ +datatype node + = Node of + { Label : string + , SubForest : list node + } + +fun getNode () : transaction node = + return (Node { Label = "foo", SubForest = [] }) + +fun main () : transaction page = return <xml><body> + <button onclick={ + n <- rpc (getNode ()); + case n of + Node {Label = l, ...} => alert ("l = " ^ l) + }/> + </body></xml> |