diff src/cjr_print.sml @ 471:20fab0e96217

Tree demo working (and other assorted regressions fixed)
author Adam Chlipala <adamc@hcoop.net>
date Thu, 06 Nov 2008 19:43:48 -0500
parents 7cb418e9714f
children c9566d49ecfe
line wrap: on
line diff
--- a/src/cjr_print.sml	Thu Nov 06 18:49:38 2008 -0500
+++ b/src/cjr_print.sml	Thu Nov 06 19:43:48 2008 -0500
@@ -799,6 +799,43 @@
                              string "})"]
                     end
 
+              | TOption t =>
+                box [string "(request[0] == '/' ? ++request : request, ",
+                     string "((!strncmp(request, \"None\", 4) ",
+                     string "&& (request[4] == 0 || request[4] == '/')) ",
+                     string "? (request += 4, NULL) ",
+                     string ": ((!strncmp(request, \"Some\", 4) ",
+                     string "&& request[4] == '/') ",
+                     string "? (request += 5, ",
+                     if isUnboxable  t then
+                         unurlify' rf (#1 t)
+                     else
+                         box [string "({",
+                              newline,
+                              p_typ env t,
+                              space,
+                              string "*tmp",
+                              space,
+                              string "=",
+                              space,
+                              string "uw_malloc(ctx, sizeof(",
+                              p_typ env t,
+                              string "));",
+                              newline,
+                              string "*tmp",
+                              space,
+                              string "=",
+                              space,
+                              unurlify' rf (#1 t),
+                              string ";",
+                              newline,
+                              string "tmp;",
+                              newline,
+                              string "})"],
+                     string ") :",
+                     space,
+                     string "(uw_error(ctx, FATAL, \"Error unurlifying option type\"), NULL))))"]
+
               | _ => (ErrorMsg.errorAt loc "Unable to choose a URL decoding function";
                       space)
     in