# HG changeset patch # User Adam Chlipala # Date 1313938531 14400 # Node ID 133c71008bef406c33126e04fcdbe9ea8105ff7b # Parent 5f530f8e35110152997da62ef75dcfd940dd2ae1 Add prototypes for [un]urlification functions diff -r 5f530f8e3511 -r 133c71008bef src/cjr_print.sml --- a/src/cjr_print.sml Sun Aug 21 10:39:19 2011 -0400 +++ b/src/cjr_print.sml Sun Aug 21 10:55:31 2011 -0400 @@ -524,7 +524,7 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ newline, newline, - box (rev handlers), + box (rev protos), + box (rev defs), string "static void uw_handle(uw_context ctx, char *request) {", newline, diff -r 5f530f8e3511 -r 133c71008bef tests/rpcNested.ur --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/rpcNested.ur Sun Aug 21 10:55:31 2011 -0400 @@ -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 +