changeset 745:ee2feab275db

blobSize
author Adam Chlipala <adamc@hcoop.net>
date Sun, 26 Apr 2009 11:07:25 -0400
parents 1ef3c1ef617d
children 2c7244c066f1
files include/urweb.h lib/ur/basis.urs src/c/urweb.c tests/blob.ur
diffstat 4 files changed, 8 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/include/urweb.h	Sun Apr 26 10:54:45 2009 -0400
+++ b/include/urweb.h	Sun Apr 26 11:07:25 2009 -0400
@@ -169,5 +169,6 @@
 uw_Basis_string uw_Basis_fileName(uw_context, uw_Basis_file);
 uw_Basis_string uw_Basis_fileMimeType(uw_context, uw_Basis_file);
 uw_Basis_blob uw_Basis_fileData(uw_context, uw_Basis_file);
+uw_Basis_int uw_Basis_blobSize(uw_context, uw_Basis_blob);
 
 __attribute__((noreturn)) void uw_return_blob(uw_context, uw_Basis_blob, uw_Basis_string mimeType);
--- a/lib/ur/basis.urs	Sun Apr 26 10:54:45 2009 -0400
+++ b/lib/ur/basis.urs	Sun Apr 26 11:07:25 2009 -0400
@@ -524,6 +524,7 @@
 type mimeType
 val blessMime : string -> mimeType
 val returnBlob : t ::: Type -> blob -> mimeType -> transaction t
+val blobSize : blob -> int
 
 con radio = [Body, Radio]
 val radio : formTag string radio []
--- a/src/c/urweb.c	Sun Apr 26 10:54:45 2009 -0400
+++ b/src/c/urweb.c	Sun Apr 26 11:07:25 2009 -0400
@@ -2183,6 +2183,10 @@
   return f.type;
 }
 
+uw_Basis_int uw_Basis_blobSize(uw_context ctx, uw_Basis_blob b) {
+  return b.size;
+}
+
 uw_Basis_blob uw_Basis_fileData(uw_context ctx, uw_Basis_file f) {
   return f.data;
 }
--- a/tests/blob.ur	Sun Apr 26 10:54:45 2009 -0400
+++ b/tests/blob.ur	Sun Apr 26 11:07:25 2009 -0400
@@ -12,8 +12,8 @@
     main ()
 
 and main () =
-    ls <- queryX (SELECT t.Id, t.Desc FROM t ORDER BY t.Desc)
-          (fn r => <xml><li><a link={view r.T.Id}>{[r.T.Desc]}</a></li></xml>);
+    ls <- queryX (SELECT t.Id, t.Desc, t.Data FROM t ORDER BY t.Desc)
+          (fn r => <xml><li><a link={view r.T.Id}>{[r.T.Desc]} ({[blobSize r.T.Data]})</a></li></xml>);
     return <xml><body>
       {ls}