diff options
| author | Andre Weissflog <floooh@gmail.com> | 2022-10-16 19:43:18 +0200 |
|---|---|---|
| committer | Andre Weissflog <floooh@gmail.com> | 2022-10-16 19:43:18 +0200 |
| commit | 6f5c4163703dc617fedd63e969ccf324a711852d (patch) | |
| tree | f6426afd7075182220900d462d6e39bd70c09f7a /bindgen | |
| parent | 89fd487bea0854dfba1e6f42b58687f49ba68c55 (diff) | |
| parent | 47da9c03feec3d9a2d09f3d68d879a99ab9590c9 (diff) | |
Merge branch 'master' of github.com:kcbanner/sokol into zig-0.10.0
Diffstat (limited to 'bindgen')
| -rw-r--r-- | bindgen/README.md | 1 | ||||
| -rw-r--r-- | bindgen/gen_zig.py | 9 |
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 84a95147..5c118c11 100644 --- a/bindgen/gen_zig.py +++ b/bindgen/gen_zig.py @@ -377,7 +377,7 @@ def gen_struct(decl, prefix): elif is_const_prim_ptr(field_type): l(f" {field_name}: ?[*]const {as_zig_prim_type(extract_ptr_type(field_type))} = null,") elif 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 is_1d_array_type(field_type): array_type = extract_array_type(field_type) array_sizes = extract_array_sizes(field_type) @@ -481,6 +481,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");') @@ -504,7 +506,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!");') |