feature #6 - preliminary implementation, cannot nest yet
[svn/Cll1h/.git] / cll1.h
diff --git a/cll1.h b/cll1.h
index 6f49f720c607bcef29b040520888f2fb56a54ad6..48aa0a1d98c8b5e26f18764570592030785fc346 100644 (file)
--- a/cll1.h
+++ b/cll1.h
@@ -197,7 +197,17 @@ extern  unsigned RANDOM_SEED;
 #define Get_obj_as(ID,COMMUNITY,MEM,...) MEM ID=get_obj_as(COMMUNITY,MEM,INTERFACE,__VA_ARGS__)
 #define I_am(SELF,MEM) MEM SELF=(MEM)community
 /* .----------------------------------------------------------------------.
-  /  9. implementation of C<<1 library functions, updated 2008-01-26 xCh.
+  /  9. C<<1 setjmp()/longjmp() based exceptions, updated 2008-09-30
+ '----------------------------------------------------------------------- */
+#include <setjmp.h>
+#define try if(!(_exception_type=setjmp(_exception_env)))
+#define fail(E) longjmp(_exception_env, (E))
+#define else_switch_exceptions else switch(_exception_type)
+#define else_catch_exception(E) else if (_exception_type==(E))
+static jmp_buf _exception_env;
+static int _exception_type;
+/* .----------------------------------------------------------------------.
+  /  10. implementation of C<<1 library functions, updated 2008-01-26 xCh.
  '----------------------------------------------------------------------- */
 /* later... #define _MALLOC void *_cll1_malloc(size_t size) {  return malloc(size); } */
 #define _CLL1_FPRINT(IOSTREAM) { int ofs=0; va_list ap; /* <-' */ for(va_start(ap,s);s!=NIL;s=va_arg(ap,char *)) { if(ofs)fputs(OFS,IOSTREAM);else ofs=1;/**/fputs(coalesce(s,NIL),IOSTREAM); } va_end(ap); fputs(EOL,IOSTREAM); }
This page took 0.092272 seconds and 4 git commands to generate.