comparison src/cjr_print.sml @ 569:162d5308e34f

Successfully generated a page element from a signal
author Adam Chlipala <adamc@hcoop.net>
date Sat, 20 Dec 2008 16:19:26 -0500
parents ae03d09043c1
children 889dc9fceb3a
comparison
equal deleted inserted replaced
568:55fc747a67dc 569:162d5308e34f
1798 newline]) 1798 newline])
1799 ss, 1799 ss,
1800 1800
1801 string "}"] 1801 string "}"]
1802 1802
1803 | DJavaScript s => box [string "static char jslib[] = \"",
1804 string (String.toString s),
1805 string "\";"]
1806
1803 datatype 'a search = 1807 datatype 'a search =
1804 Found of 'a 1808 Found of 'a
1805 | NotFound 1809 | NotFound
1806 | Error 1810 | Error
1807 1811
2046 string (Int.toString (size s)), 2050 string (Int.toString (size s)),
2047 string ";", 2051 string ";",
2048 newline, 2052 newline,
2049 string "if (*request == '/') ++request;", 2053 string "if (*request == '/') ++request;",
2050 newline, 2054 newline,
2055 string "uw_write_header(ctx, \"Content-type: text/html\\r\\n\");",
2056 newline,
2057 string "uw_write(ctx, \"<html>\");",
2058 newline,
2051 box [string "{", 2059 box [string "{",
2052 newline, 2060 newline,
2053 box (ListUtil.mapi (fn (i, t) => box [p_typ env t, 2061 box (ListUtil.mapi (fn (i, t) => box [p_typ env t,
2054 space, 2062 space,
2055 string "arg", 2063 string "arg",
2068 (string "ctx" 2076 (string "ctx"
2069 :: ListUtil.mapi (fn (i, _) => string ("arg" ^ Int.toString i)) ts), 2077 :: ListUtil.mapi (fn (i, _) => string ("arg" ^ Int.toString i)) ts),
2070 inputsVar, 2078 inputsVar,
2071 string ", uw_unit_v);", 2079 string ", uw_unit_v);",
2072 newline, 2080 newline,
2081 string "uw_write(ctx, \"</html>\");",
2082 newline,
2073 string "return;", 2083 string "return;",
2074 newline, 2084 newline,
2075 string "}", 2085 string "}",
2076 newline, 2086 newline,
2077 string "}"] 2087 string "}"]
2371 makeSwitch (fnums, 0), 2381 makeSwitch (fnums, 0),
2372 string "}", 2382 string "}",
2373 newline, 2383 newline,
2374 newline, 2384 newline,
2375 string "void uw_handle(uw_context ctx, char *request) {", 2385 string "void uw_handle(uw_context ctx, char *request) {",
2386 newline,
2387 string "if (!strcmp(request, \"/app.js\")) {",
2388 newline,
2389 box [string "uw_write_header(ctx, \"Content-type: text/javascript\\r\\n\");",
2390 newline,
2391 string "uw_write(ctx, jslib);",
2392 newline,
2393 string "return;",
2394 newline],
2395 string "}",
2376 newline, 2396 newline,
2377 p_list_sep newline (fn x => x) pds', 2397 p_list_sep newline (fn x => x) pds',
2378 newline, 2398 newline,
2379 string "uw_error(ctx, FATAL, \"Unknown page\");", 2399 string "uw_error(ctx, FATAL, \"Unknown page\");",
2380 newline, 2400 newline,