diff options
| author | Andre Weissflog <floooh@gmail.com> | 2024-08-31 13:19:04 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-08-31 13:19:04 +0200 |
| commit | 9b2bf20a21057187f15a4e745e59830d3c0dc153 (patch) | |
| tree | 79944c7d0e3934475855cccf892991441509726d | |
| parent | e85b58aaf2e1c7603a0bd0eea7e99a250948299b (diff) | |
| parent | eba2681843c1aa7af66680067ee28c333cc3dd51 (diff) | |
Merge pull request #1100 from floooh/fix/sokol-zig/issue78
sokol-zig: work around a breaking Zig stdlib naming change
| -rw-r--r-- | CHANGELOG.md | 14 | ||||
| -rw-r--r-- | bindgen/gen_zig.py | 47 |
2 files changed, 47 insertions, 14 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index 0de74557..8b243805 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,19 @@ ## Updates +### 31-Aug-2024 + +A fix in the sokol-zig bindings generator for a breaking naming convention +change in the Zig stdlib. The fix supports both the old and new naming +convention so that sokol-zig continues to be compatible with zig 0.13.0. + +To update the sokol-zig depenency in your project, just run: + +``` +zig fetch --save=sokol git+https://github.com/floooh/sokol-zig.git +``` + +Details in PR https://github.com/floooh/sokol/pull/1100 + ### 26-Aug-2024 A small behaviour update for sokol_gl.h (may be breaking if you call `sgl_error()`): diff --git a/bindgen/gen_zig.py b/bindgen/gen_zig.py index 4b63eebe..7b537586 100644 --- a/bindgen/gen_zig.py +++ b/bindgen/gen_zig.py @@ -466,20 +466,39 @@ def gen_helpers(inp): l('// helper function to convert "anything" to a Range struct') l('pub fn asRange(val: anytype) Range {') l(' const type_info = @typeInfo(@TypeOf(val));') - l(' switch (type_info) {') - l(' .Pointer => {') - l(' switch (type_info.Pointer.size) {') - l(' .One => return .{ .ptr = val, .size = @sizeOf(type_info.Pointer.child) },') - l(' .Slice => return .{ .ptr = val.ptr, .size = @sizeOf(type_info.Pointer.child) * val.len },') - l(' else => @compileError("FIXME: Pointer type!"),') - l(' }') - l(' },') - l(' .Struct, .Array => {') - l(' @compileError("Structs and arrays must be passed as pointers to asRange");') - l(' },') - l(' else => {') - l(' @compileError("Cannot convert to range!");') - l(' },') + l(' // FIXME: naming convention change between 0.13 and 0.14-dev') + l(' if (@hasField(@TypeOf(type_info), "Pointer")) {') + l(' switch (type_info) {') + l(' .Pointer => {') + l(' switch (type_info.Pointer.size) {') + l(' .One => return .{ .ptr = val, .size = @sizeOf(type_info.Pointer.child) },') + l(' .Slice => return .{ .ptr = val.ptr, .size = @sizeOf(type_info.Pointer.child) * val.len },') + l(' else => @compileError("FIXME: Pointer type!"),') + l(' }') + l(' },') + l(' .Struct, .Array => {') + l(' @compileError("Structs and arrays must be passed as pointers to asRange");') + l(' },') + l(' else => {') + l(' @compileError("Cannot convert to range!");') + l(' },') + l(' }') + l(' } else {') + l(' switch (type_info) {') + l(' .pointer => {') + l(' switch (type_info.pointer.size) {') + l(' .One => return .{ .ptr = val, .size = @sizeOf(type_info.pointer.child) },') + l(' .Slice => return .{ .ptr = val.ptr, .size = @sizeOf(type_info.pointer.child) * val.len },') + l(' else => @compileError("FIXME: Pointer type!"),') + l(' }') + l(' },') + l(' .@"struct", .array => {') + l(' @compileError("Structs and arrays must be passed as pointers to asRange");') + l(' },') + l(' else => {') + l(' @compileError("Cannot convert to range!");') + l(' },') + l(' }') l(' }') l('}') l('') |