diff options
| author | Bruce Hill <bruce@bruce-hill.com> | 2024-02-20 13:06:03 -0500 |
|---|---|---|
| committer | Bruce Hill <bruce@bruce-hill.com> | 2024-02-20 13:06:03 -0500 |
| commit | f9cc44f145dd0c165010765791054666f973eff3 (patch) | |
| tree | 5a5664797f9bee63a1c3287b3d05d4c20880df97 /nextlang.h | |
| parent | d2aeee16e6ad84bfb2d77221e424d1441a2ceea2 (diff) | |
Fixing up enums
Diffstat (limited to 'nextlang.h')
| -rw-r--r-- | nextlang.h | 3 |
1 files changed, 3 insertions, 0 deletions
@@ -40,6 +40,9 @@ CORD as_cord(void *x, bool use_color, const char *fmt, ...); default: "???") #define $heap(x) (__typeof(x)*)memcpy(GC_MALLOC(sizeof(x)), (__typeof(x)[1]){x}, sizeof(x)) #define $stack(x) (__typeof(x)*)((__typeof(x)[1]){x}) +#define $tagged(obj_expr, type_name, tag_name) ({ __typeof(obj_expr) $obj = obj_expr; \ + $obj.$tag == $tag$##type_name##$##tag_name ? &$obj.tag_name : NULL; }) + #define not(x) _Generic(x, bool: (bool)!(x), default: ~(x)) #define and(x, y) _Generic(x, bool: (bool)((x) && (y)), default: ((x) & (y))) |
