aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CHANGELOG.md14
-rw-r--r--bindgen/gen_zig.py47
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('')