C import: unions (SDL_Event) and their fields; #defines that are expressions, casts or text; typedef'd structs no function mentions; FLAG_A | FLAG_B fits a u64

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Nexoniarz 2026-10-29 09:23:29 +01:00
commit d0666cf788
7 changed files with 314 additions and 13 deletions

View file

@ -0,0 +1,25 @@
// C unions (SDL_Event-style) and #defines that are expressions, strings or casts
import "cunion.h"
link "cunion.c"
fn main() {
print(EV_MOTION, EV_KEY, FLAG_BIG, FLAGS_BOTH, HALF, GREETING, LONG_NAME)
u64 flags = FLAG_BIG | FLAG_GL
u32 small = EV_KEY
print(flags, small)
Event e
if poll_event(addr(e)) != 0 && e.type == EV_MOTION {
print("motion", e.motion.x, e.motion.y)
}
k := Event(key: Key(type: EV_KEY, key: 32))
print(k.type == EV_KEY, k.key.key)
[]Event queue
queue.push(e)
queue.push(k)
print(queue[1].key.key, queue.len)
Tagged t
t.as.f = 0.5
print(t.as.f)
}