Let a Rex file wrap a C header with the same name

Structs from C headers get their own table names, so raylib.rex can
wrap "raylib.h" and still have its own Color. Ignore Opcode's
.opcode file.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Your NameandClaude Opus 5.5 committed 2026-11-08 14:08:46 +01:00
1 parent fc911ec809
commit a68c720755
5 files changed
+36 -8

No files matched your search

+13
View File
@@ -298,3 +298,16 @@ fn a_missing_library_says_how_to_link() {
let _ = std::fs::remove_dir_all(&dir);
assert!(e.contains("linking with the C library failed") && e.contains("link \"name\""), "{e}");
}
#[test]
fn a_wrapper_file_can_have_the_headers_name() {
// shapes.rex wraps shapes.h and has its own `Size`
let wrapper = "import \"shapes.h\"\n\npub struct Size {\n pub w, h: int\n}\n\npub func area(s: Size): float {\n return shapes.area(shapes.Size{float(s.w), float(s.h)})\n}\n";
let out = run(&[
("shapes.h", SHAPES_H),
("shapes.c", SHAPES_C),
("shapes.rex", wrapper),
("main.rex", "import shapes\n\nfunc main() {\n var s = shapes.Size{2, 3}\n print(s, shapes.area(s))\n}\n"),
]);
assert_eq!(out, "shapes.Size{w: 2, h: 3} 6.0\n");
}