From 1e022eb78e7ca3fd15634e3845756b9c14209cf3 Mon Sep 17 00:00:00 2001 From: Adam Chlipala Date: Sun, 21 Aug 2011 10:55:31 -0400 Subject: Add prototypes for [un]urlification functions --- src/cjr_print.sml | 76 ++++++++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 72 insertions(+), 4 deletions(-) (limited to 'src/cjr_print.sml') 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 @@ -643,6 +643,14 @@ fun unurlify fromClient env (t, loc) = in unurlifies := IS.add (!unurlifies, i); addUrlHandler (box [string "static", + space, + p_typ env t, + space, + string "*unurlify_", + string (Int.toString i), + string "(uw_context, char **);", + newline], + box [string "static", space, p_typ env t, space, @@ -794,6 +802,14 @@ fun unurlify fromClient env (t, loc) = string ")"] in addUrlHandler (box [string "static", + space, + p_typ env (t, ErrorMsg.dummySpan), + space, + string "unurlify_", + string (Int.toString i), + string "(uw_context, char **);", + newline], + box [string "static", space, p_typ env (t, ErrorMsg.dummySpan), space, @@ -823,6 +839,14 @@ fun unurlify fromClient env (t, loc) = else (unurlifies := IS.add (!unurlifies, i); addUrlHandler (box [string "static", + space, + p_typ 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, @@ -1032,6 +1056,22 @@ fun urlify env t = in urlifies := IS.add (!urlifies, i); addUrlHandler (box [string "static", + space, + string "void", + 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, @@ -1148,6 +1188,17 @@ fun urlify env t = newline] in addUrlHandler (box [string "static", + space, + string "void", + space, + string "urlify_", + string (Int.toString i), + string "(uw_context,", + space, + p_typ env t, + string ");", + newline], + box [string "static", space, string "void", space, @@ -1221,6 +1272,19 @@ fun urlify env t = else (urlifiesL := IS.add (!urlifiesL, i); addUrlHandler (box [string "static", + space, + string "void", + 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, @@ -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, -- cgit v1.2.3