diff options
| author | Andre Weissflog <floooh@gmail.com> | 2025-03-21 19:18:53 +0100 |
|---|---|---|
| committer | Andre Weissflog <floooh@gmail.com> | 2025-03-21 19:18:53 +0100 |
| commit | d6c1b9e12cc2c56e49f1425cdfdd4641d54f564c (patch) | |
| tree | d8853877aed631c9e799a94cd3cc21465b464aea /bindgen | |
| parent | 5c97c9ad38210b87581ac333ba060ab51d17c35e (diff) | |
gen_zig.py: remove zig 0.13.0 vs 0.14.0 hack in code-generated asRange helper
Diffstat (limited to 'bindgen')
| -rw-r--r-- | bindgen/gen_zig.py | 47 |
1 files changed, 14 insertions, 33 deletions
diff --git a/bindgen/gen_zig.py b/bindgen/gen_zig.py index 52f617e5..0281e9b8 100644 --- a/bindgen/gen_zig.py +++ b/bindgen/gen_zig.py @@ -489,39 +489,20 @@ 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(' // 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(' 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('') |