aboutsummaryrefslogtreecommitdiff
path: root/bindgen
diff options
context:
space:
mode:
authorkcbanner <kcbanner@gmail.com>2022-08-28 02:17:51 -0400
committerkcbanner <kcbanner@gmail.com>2022-08-28 02:17:51 -0400
commit47da9c03feec3d9a2d09f3d68d879a99ab9590c9 (patch)
treeaf9b691f91d2fc97b0cd63619622351bb3e223ee /bindgen
parentf8abb1ca8079ce48b10ce50d005355df39f86d25 (diff)
gen_zig.py: use meta.FnPtr instead of a switch
Diffstat (limited to 'bindgen')
-rw-r--r--bindgen/gen_zig.py4
1 files changed, 2 insertions, 2 deletions
diff --git a/bindgen/gen_zig.py b/bindgen/gen_zig.py
index f58ace15..5c118c11 100644
--- a/bindgen/gen_zig.py
+++ b/bindgen/gen_zig.py
@@ -377,8 +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):
- sig = f"fn({funcptr_args_c(field_type, prefix)}) callconv(.C) {funcptr_result_c(field_type)}"
- l(f" {field_name}: (switch (builtin.zig_backend) {{ .stage1 => ?{sig}, else => ?*const {sig} }}) = 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)
@@ -483,6 +482,7 @@ def pre_parse(inp):
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");')