summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGravatar Adam Chlipala <adam@chlipala.net>2011-12-03 10:00:10 -0500
committerGravatar Adam Chlipala <adam@chlipala.net>2011-12-03 10:00:10 -0500
commit8e7573e9187d583bcc478676ad92dd94a9ba8387 (patch)
tree999270929063a6966b6a45583e091ce015e612b3 /src
parent0f14aa67e5446391904c6a4d2ee7b4f00b803158 (diff)
Allow sources to be returned by RPCs
Diffstat (limited to 'src')
-rw-r--r--src/c/urweb.c20
-rw-r--r--src/jscomp.sml2
2 files changed, 22 insertions, 0 deletions
diff --git a/src/c/urweb.c b/src/c/urweb.c
index 491fb73d..8ebd9a2f 100644
--- a/src/c/urweb.c
+++ b/src/c/urweb.c
@@ -1762,6 +1762,16 @@ char *uw_Basis_urlifyBool(uw_context ctx, uw_Basis_bool b) {
return "1";
}
+char *uw_Basis_urlifySource(uw_context ctx, uw_Basis_source src) {
+ char *r;
+ int len;
+ uw_check_heap(ctx, 2 * INTS_MAX + 2);
+ r = ctx->heap.front;
+ sprintf(r, "%d/%llu%n", src.context, src.source, &len);
+ ctx->heap.front += len+1;
+ return r;
+}
+
static void uw_Basis_urlifyInt_w_unsafe(uw_context ctx, uw_Basis_int n) {
int len;
@@ -1843,6 +1853,16 @@ uw_unit uw_Basis_urlifyBool_w(uw_context ctx, uw_Basis_bool b) {
return uw_unit_v;
}
+uw_unit uw_Basis_urlifySource_w(uw_context ctx, uw_Basis_source src) {
+ int len;
+
+ uw_check(ctx, 2 * INTS_MAX + 2);
+ sprintf(ctx->page.front, "%d/%llu%n", src.context, src.source, &len);
+ ctx->page.front += len;
+
+ return uw_unit_v;
+}
+
static char *uw_unurlify_advance(char *s) {
char *new_s = strchr(s, '/');
diff --git a/src/jscomp.sml b/src/jscomp.sml
index 3e475899..16043ba5 100644
--- a/src/jscomp.sml
+++ b/src/jscomp.sml
@@ -310,6 +310,8 @@ fun process file =
| TFfi ("Basis", "bool") => ("t[i++] == \"1\"", st)
+ | TSource => ("parseSource(t[i++], t[i++])", st)
+
| TOption t =>
let
val (e, st) = unurlifyExp loc (t, st)