diff options
author | 2009-03-08 13:41:55 -0400 | |
---|---|---|
committer | 2009-03-08 13:41:55 -0400 | |
commit | 5f77fc276c90321dec9e17ec483a1d8b11db3c96 (patch) | |
tree | 340a1e5251d1a16874ce49b5edf487714f45ff7b /src/cjr_print.sml | |
parent | b691dfb678a18667a623b45111683c480476051b (diff) |
RPC returning an option
Diffstat (limited to 'src/cjr_print.sml')
-rw-r--r-- | src/cjr_print.sml | 50 |
1 files changed, 22 insertions, 28 deletions
diff --git a/src/cjr_print.sml b/src/cjr_print.sml index 73024aa5..aff5efd3 100644 --- a/src/cjr_print.sml +++ b/src/cjr_print.sml @@ -1087,42 +1087,36 @@ fun urlify env t = newline] end - | TOption t => box [] - (*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 "({", + | TOption t => + box [string "if (it", + string (Int.toString level), + string ") {", + if isUnboxable t then + box [string "uw_write(ctx, \"Some/\");", newline, - p_typ env t, - space, - string "*tmp", - space, - string "=", + urlify' rf level t] + else + box [p_typ env t, space, - string "uw_malloc(ctx, sizeof(", - p_typ env t, - string "));", - newline, - string "*tmp", + string "it", + string (Int.toString (level + 1)), space, string "=", space, - unurlify' rf (#1 t), + string "*it", + string (Int.toString level), string ";", newline, - string "tmp;", + string "uw_write(ctx, \"Some/\");", newline, - string "})"], - string ") :", - space, - string "(uw_error(ctx, FATAL, \"Error unurlifying option type\"), NULL))))"]*) + urlify' rf (level + 1) t, + string ";", + newline], + string "} else {", + box [string "uw_write(ctx, \"None\");", + newline], + string "}", + newline] | _ => (ErrorMsg.errorAt loc "Unable to choose a URL encoding function"; space) |