// Generated by hareconv #ifndef {}_H_ #define {}_H_ #include #include #include static_assert(__STDC_VERSION__ >= 202311L, "hareconv-generated header depends on C23 or later"); #ifndef HAS_HARE_HELPERS #define HAS_HARE_HELPERS static_assert(sizeof(float) == 4, "hareconv-generated header depends on float being f32-equivalent"); static_assert(sizeof(double) == 8, "hareconv-generated header depends on double being f64-equivalent"); static_assert(sizeof(int) >= 4, "hareconv-generated header depends on int being at least four bytes"); static_assert(CHAR_BIT == 8, "hareconv-generated header depends on one byte being eight bits"); #define HARE_SLICE(...) struct {{ typeof(__VA_ARGS__) *data; size_t len, cap; }} #define HARE_CONST_STR(...) (hare_str){{ ((void)sizeof(struct {{ \ static_assert(_Generic((__VA_ARGS__), uint8_t *: 1, default: 0), \ "HARE_CONST_STR argument should be a u8\"string literal\""); \ int x; }}), __VA_ARGS__), \ sizeof(__VA_ARGS__) - 1, sizeof(__VA_ARGS__) - 1 }} #define HARE_NULSTR(...) ((void)sizeof(struct {{ \ static_assert(_Generic((__VA_ARGS__), hare_str: 1, default: 0), \ "HARE_NULSTR argument should be a hare_str"); \ int x; }}), (char *)(__VA_ARGS__).data) #define HARE_TAG(...) (*(uint32_t *)&(__VA_ARGS__)) typedef HARE_SLICE(uint8_t) hare_str; #define HARE_MATCH(...) for (auto _ = &(__VA_ARGS__); _; _ = nullptr) \ switch (((void)sizeof(struct {{ static_assert(sizeof(*_) >= 4, \ "HARE_MATCH argument should be a tagged union"); \ int _; }}), *(uint32_t *)_)) if (true) #define HARE_CASE(LET, TAG) _internal_HARE_CASE(LET, TAG) #define _internal_HARE_CASE(LET, TAG) }} else if (true) {{ \ static_assert(_Generic(TAG, unsigned long: 1, default: 0), \ "HARE_CASE's TAG argument should be a HARE_TAG_* constant"); \ case TAG: auto _hare_##LET = &_->_##TAG; auto LET = *_hare_##LET; \ _hare_##TAG #define HARE_CASE_DEFAULT }} else if (true) {{ default: #define HARE_TAG_bool {}UL #define HARE_TAG_f32 {}UL #define HARE_TAG_f64 {}UL #define HARE_TAG_i16 {}UL #define HARE_TAG_i32 {}UL #define HARE_TAG_i64 {}UL #define HARE_TAG_i8 {}UL #define HARE_TAG_int {}UL #define HARE_TAG_never {}UL #define HARE_TAG_null {}UL #define HARE_TAG_opaque {}UL #define HARE_TAG_rune {}UL #define HARE_TAG_size {}UL #define HARE_TAG_str {}UL #define HARE_TAG_u16 {}UL #define HARE_TAG_u32 {}UL #define HARE_TAG_u64 {}UL #define HARE_TAG_u8 {}UL #define HARE_TAG_uint {}UL #define HARE_TAG_uintptr {}UL #define HARE_TAG_valist {}UL #define HARE_TAG_void {}UL #endif #endif