00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #ifndef CU_EXCEPT_H
00019 #define CU_EXCEPT_H
00020
00021 #include <cuflow/fwd.h>
00022 #include <cuflow/wind.h>
00023 #include <cu/clos.h>
00024 #include <cu/conf.h>
00025 #ifdef CUCONF_HAVE_GC_GC_H
00026 # include <gc/gc.h>
00027 #else
00028 # include <gc.h>
00029 #endif
00030
00031 CU_BEGIN_DECLARATIONS
00032
00033 #define cuflow_xc_extern(name, proto, sct) cuflowP_xc_extern(name, proto, sct)
00034 #define cuflow_xc_define(name, proto) cuflowP_xc_define(name, proto)
00035 #define cuflowP_xc_extern(name, ign_t, alops, argl, sct) \
00036 typedef struct name##_s *name##_t; \
00037 void name##_cct alops##prepend(argl, name##_t); \
00038 struct name##_s { \
00039 struct cuflowP_windargs windargs; \
00040 cuPP_splice sct \
00041 }
00042 #define cuflowP_xc_define(name, ign_t, alops, argl) \
00043 void name##_cct alops##prepend(argl, name##_t self)
00044
00045
00046 #define cuflow_xc_cct_m(xc, fn, ...) \
00047 ((fn)(xc, __VA_ARGS__), (xc)->windargs.xc_key = (cu_fnptr_t)(fn))
00048 #define cuflow_xc_cct0_m(xc, fn) \
00049 ((fn)(xc), (xc)->windargs.xc_key = (cu_fnptr_t)(fn))
00050
00051 #define cuflow_throw(name, ...) \
00052 do { \
00053 name##_t xc = GC_malloc(sizeof(struct name##_s)); \
00054 cuflow_xc_cct_m(xc, name##_cct, __VA_ARGS__); \
00055 cuflowP_throw(&xc->windargs); \
00056 } while (0)
00057 #define cuflow_throw0(name) \
00058 do { \
00059 name##_t xc = GC_malloc(sizeof(struct name##_s)); \
00060 cuflow_xc_cct0_m(xc, name##_cct); \
00061 cuflowP_throw(&xc->windargs); \
00062 } while (0)
00063 #define cuflow_throw_static(xc) cuflowP_throw(&(xc)->windargs)
00064
00065 #define cuflow_xc_is(name) (cuflowP_windstate.windargs->xc_key == name##_cct)
00066 #define cuflow_xc_dcln(name) \
00067 name##_t xc = (name##_t)((char *)cuflowP_windstate.windargs \
00068 - offsetof(struct name##_s, windargs))
00069
00070 CU_END_DECLARATIONS
00071
00072 #endif