aboutsummaryrefslogtreecommitdiff
path: root/bindgen
diff options
context:
space:
mode:
authorAndre Weissflog <floooh@gmail.com>2022-11-03 18:52:02 +0100
committerAndre Weissflog <floooh@gmail.com>2022-11-03 18:52:02 +0100
commit1eb5468afb333e59e842481a714dfdfcb306c991 (patch)
tree43c79930d74fd5204272e1ef39aab7563c44394e /bindgen
parent471f125e0aaa0b5c1201c754812c14cbb8b98ff1 (diff)
parent6f5c4163703dc617fedd63e969ccf324a711852d (diff)
Merge branch 'zig-0.10.0'
Diffstat (limited to 'bindgen')
-rw-r--r--bindgen/README.md1
-rw-r--r--bindgen/gen_zig.py9
2 files changed, 8 insertions, 2 deletions
diff --git a/bindgen/README.md b/bindgen/README.md
index a2b6ba4c..f90e499c 100644
--- a/bindgen/README.md
+++ b/bindgen/README.md
@@ -22,6 +22,7 @@ To update the Zig bindings:
> cd sokol/bindgen
> git clone https://github.com/floooh/sokol-zig
> git clone https://github.com/floooh/sokol-nim
+> git clone https://github.com/floooh/sokol-odin
> python3 gen_all.py
```
diff --git a/bindgen/gen_zig.py b/bindgen/gen_zig.py
index aff1a65a..17b33d07 100644
--- a/bindgen/gen_zig.py
+++ b/bindgen/gen_zig.py
@@ -328,7 +328,7 @@ def gen_struct(decl, prefix):
elif is_const_prim_ptr(field_type):
l(f" {field_name}: ?[*]const {as_zig_prim_type(util.extract_ptr_type(field_type))} = null,")
elif util.is_func_ptr(field_type):
- l(f" {field_name}: ?fn({funcptr_args_c(field_type, prefix)}) callconv(.C) {funcptr_result_c(field_type)} = null,")
+ l(f" {field_name}: ?meta.FnPtr(fn({funcptr_args_c(field_type, prefix)}) callconv(.C) {funcptr_result_c(field_type)}) = null,")
elif util.is_1d_array_type(field_type):
array_type = util.extract_array_type(field_type)
array_sizes = util.extract_array_sizes(field_type)
@@ -432,6 +432,8 @@ def pre_parse(inp):
enum_items[enum_name].append(as_enum_item_name(item['name']))
def gen_imports(inp, dep_prefixes):
+ l('const builtin = @import("builtin");')
+ l('const meta = @import("std").meta;')
for dep_prefix in dep_prefixes:
dep_module_name = module_names[dep_prefix]
l(f'const {dep_prefix[:-1]} = @import("{dep_module_name}.zig");')
@@ -455,7 +457,10 @@ def gen_helpers(inp):
l(' }')
l(' },')
l(' .Struct, .Array => {')
- l(' return .{ .ptr = &val, .size = @sizeOf(@TypeOf(val)) };')
+ l(' switch (builtin.zig_backend) {')
+ l(' .stage1 => return .{ .ptr = &val, .size = @sizeOf(@TypeOf(val)) },')
+ l(' else => @compileError("Structs and arrays must be passed as pointers to asRange"),')
+ l(' }')
l(' },')
l(' else => {')
l(' @compileError("Cannot convert to range!");')