diff options
author | Adam Chlipala <adam@chlipala.net> | 2011-09-03 12:51:05 -0400 |
---|---|---|
committer | Adam Chlipala <adam@chlipala.net> | 2011-09-03 12:51:05 -0400 |
commit | cd28ea2ee01ac023b7b1dfac39ae5ddf4ded5c4e (patch) | |
tree | d792d445b5fbc6b0a16eadef95d70510f9037dd6 /src | |
parent | 3c860c3c95d4d085499fd01e3140f32aafbc1bd7 (diff) |
An abstract type of IDs
Diffstat (limited to 'src')
-rw-r--r-- | src/c/urweb.c | 9 | ||||
-rw-r--r-- | src/monoize.sml | 1 | ||||
-rw-r--r-- | src/settings.sml | 7 |
3 files changed, 15 insertions, 2 deletions
diff --git a/src/c/urweb.c b/src/c/urweb.c index 2a593767..0f1634e9 100644 --- a/src/c/urweb.c +++ b/src/c/urweb.c @@ -463,6 +463,8 @@ struct uw_context { uw_Basis_postBody postBody; uw_Basis_string queryString; + unsigned nextId; + char error_message[ERROR_BUF_LEN]; }; @@ -532,6 +534,8 @@ uw_context uw_init(int id, void *logger_data, uw_logger log_debug) { ctx->queryString = NULL; + ctx->nextId = 0; + return ctx; } @@ -608,6 +612,7 @@ void uw_reset_keep_error_message(uw_context ctx) { ctx->used_transactionals = 0; ctx->script_header = ""; ctx->queryString = NULL; + ctx->nextId = 0; } void uw_reset_keep_request(uw_context ctx) { @@ -3947,3 +3952,7 @@ void uw_cutErrorLocation(char *s) { memmove(s, s2+2, strlen(s2+2)+1); } + +uw_Basis_string uw_Basis_fresh(uw_context ctx) { + return uw_Basis_htmlifyInt(ctx, ctx->nextId++); +} diff --git a/src/monoize.sml b/src/monoize.sml index 7849e1cd..9f100a3f 100644 --- a/src/monoize.sml +++ b/src/monoize.sml @@ -219,6 +219,7 @@ fun monoType env = | L.CApp ((L.CApp ((L.CFfi ("Basis", "xhtml"), _), _), _), _) => (L'.TFfi ("Basis", "string"), loc) | L.CFfi ("Basis", "css_class") => (L'.TFfi ("Basis", "string"), loc) + | L.CFfi ("Basis", "id") => (L'.TFfi ("Basis", "string"), loc) | L.CApp ((L.CFfi ("Basis", "serialized"), _), _) => (L'.TFfi ("Basis", "string"), loc) diff --git a/src/settings.sml b/src/settings.sml index 8b376a00..9301e93e 100644 --- a/src/settings.sml +++ b/src/settings.sml @@ -155,7 +155,8 @@ val benignBase = basis ["get_cookie", "onKeypress", "onKeyup", "onMousedown", - "onMouseup"] + "onMouseup", + "fresh"] val benign = ref benignBase fun setBenignEffectful ls = benign := S.addList (benignBase, ls) @@ -278,7 +279,9 @@ val jsFuncsBase = basisM [("alert", "alert"), ("onKeypress", "uw_onKeypress"), ("onKeyup", "uw_onKeyup"), ("onMousedown", "uw_onMousedown"), - ("onMouseup", "uw_onMouseup")] + ("onMouseup", "uw_onMouseup"), + + ("fresh", "fresh")] val jsFuncs = ref jsFuncsBase fun setJsFuncs ls = jsFuncs := foldl (fn ((k, v), m) => M.insert (m, k, v)) jsFuncsBase ls fun jsFunc x = M.find (!jsFuncs, x) |