changeset 189:20bf7487c370

Update bool to follow datatype representation change
author Adam Chlipala <adamc@hcoop.net>
date Sun, 03 Aug 2008 19:52:37 -0400
parents 8e9f97508f0d
children 3eb53c957d10
files include/types.h src/c/lacweb.c
diffstat 2 files changed, 5 insertions(+), 12 deletions(-) [+]
line wrap: on
line diff
--- a/include/types.h	Sun Aug 03 19:49:21 2008 -0400
+++ b/include/types.h	Sun Aug 03 19:52:37 2008 -0400
@@ -8,11 +8,7 @@
 typedef struct __lws_0 lw_unit;
 typedef lw_unit lw_Basis_unit;
 
-enum lw_Basis_bool_enum { lw_Basis_False, lw_Basis_True };
-
-typedef struct lw_Basis_bool {
-  enum lw_Basis_bool_enum tag;
-} *lw_Basis_bool;
+typedef enum lw_Basis_bool { lw_Basis_False, lw_Basis_True } lw_Basis_bool;
 
 typedef struct lw_context *lw_context;
 
--- a/src/c/lacweb.c	Sun Aug 03 19:49:21 2008 -0400
+++ b/src/c/lacweb.c	Sun Aug 03 19:52:37 2008 -0400
@@ -339,7 +339,7 @@
 }
 
 char *lw_Basis_urlifyBool(lw_context ctx, lw_Basis_bool b) {
-  if (b->tag == lw_Basis_False)
+  if (b == lw_Basis_False)
     return "0";
   else
     return "1";
@@ -383,7 +383,7 @@
 }
 
 void lw_Basis_urlifyBool_w(lw_context ctx, lw_Basis_bool b) {
-  if (b->tag == lw_Basis_False)
+  if (b == lw_Basis_False)
     lw_writec(ctx, '0');
   else
     lw_writec(ctx, '1');
@@ -448,17 +448,14 @@
   return s1;
 }
 
-static struct lw_Basis_bool lw_False = { lw_Basis_False },
-  lw_True = { lw_Basis_True };
-
 lw_Basis_bool lw_Basis_unurlifyBool(lw_context ctx, char **s) {
   char *new_s = lw_unurlify_advance(*s);
   lw_Basis_bool r;
   
   if (*s[0] == 0 || !strcmp(*s, "0") || !strcmp(*s, "off"))
-    r = &lw_False;
+    r = lw_Basis_False;
   else
-    r = &lw_True;
+    r = lw_Basis_True;
 
   *s = new_s;
   return r;