diff src/cjr_print.sml @ 1546:133c71008bef

Add prototypes for [un]urlification functions
author Adam Chlipala <adam@chlipala.net>
date Sun, 21 Aug 2011 10:55:31 -0400
parents 5f530f8e3511
children 553a5cc3a4b5
line wrap: on
line diff
--- 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,