diff options
| author | Andre Weissflog <floooh@gmail.com> | 2022-05-30 15:35:21 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-05-30 15:35:21 +0200 |
| commit | 2bd14a389008b87d24706801fb5e40141d928087 (patch) | |
| tree | 5fddaf955ca90f163e5c1aeb33101f236258c9b2 /bindgen/gen_zig.py | |
| parent | e79c1e55ace947a41fa55fcc1aa79570c05b069e (diff) | |
Language bindings: fix new allocator callbacks (#671)
* remove typedef indirection for allocator callback functions
* language bindings: fix allocator bindings
* language bindings: replace FIXMEs and ??? with actual errors
Diffstat (limited to 'bindgen/gen_zig.py')
| -rw-r--r-- | bindgen/gen_zig.py | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/bindgen/gen_zig.py b/bindgen/gen_zig.py index 5a0fceb7..e18dacc0 100644 --- a/bindgen/gen_zig.py +++ b/bindgen/gen_zig.py @@ -7,7 +7,7 @@ # - otherwise snake_case #------------------------------------------------------------------------------- import gen_ir -import json, re, os, shutil +import json, re, os, shutil, sys module_names = { 'sg_': 'gfx', @@ -263,7 +263,7 @@ def as_extern_c_arg_type(arg_type, prefix): elif is_const_prim_ptr(arg_type): return f"[*c]const {as_zig_prim_type(extract_ptr_type(arg_type))}" else: - return '??? (as_extern_c_arg_type)' + sys.exit(f"Error as_extern_c_arg_type(): {arg_type}") def as_zig_arg_type(arg_prefix, arg_type, prefix): # NOTE: if arg_prefix is None, the result is used as return value @@ -293,7 +293,7 @@ def as_zig_arg_type(arg_prefix, arg_type, prefix): elif is_const_prim_ptr(arg_type): return pre + f"*const {as_zig_prim_type(extract_ptr_type(arg_type))}" else: - return arg_prefix + "??? (as_zig_arg_type)" + sys.exit(f"ERROR as_zig_arg_type(): {arg_type}") # get C-style arguments of a function pointer as string def funcptr_args_c(field_type, prefix): @@ -317,8 +317,10 @@ def funcptr_res_c(field_type): return 'void' elif is_const_void_ptr(res_type): return '?*const anyopaque' + elif is_void_ptr(res_type): + return '?*anyopaque' else: - return '???' + sys.exit(f"ERROR funcptr_res_c(): {field_type}") def funcdecl_args_c(decl, prefix): s = "" @@ -398,8 +400,7 @@ def gen_struct(decl, prefix, callconvc_funcptrs = True, use_raw_name=False, use_ zig_type = as_zig_enum_type(array_type, prefix) def_val = '.{}' else: - zig_type = '??? (array type)' - def_val = '???' + sys.exit(f"ERROR gen_struct is_1d_array_type: {array_type}") t0 = f"[{array_nums[0]}]{zig_type}" t0_slice = f"[]const {zig_type}" t1 = f"[_]{zig_type}" @@ -407,7 +408,7 @@ def gen_struct(decl, prefix, callconvc_funcptrs = True, use_raw_name=False, use_ elif is_const_void_ptr(array_type): l(f" {field_name}: [{array_nums[0]}]?*const anyopaque = [_]?*const anyopaque {{ null }} ** {array_nums[0]},") else: - l(f"// FIXME: ??? array {field_name}: {field_type} => {array_type} [{array_nums[0]}]") + sys.exit(f"ERROR gen_struct: array {field_name}: {field_type} => {array_type} [{array_nums[0]}]") elif is_2d_array_type(field_type): array_type = extract_array_type(field_type) array_nums = extract_array_nums(field_type) @@ -418,12 +419,11 @@ def gen_struct(decl, prefix, callconvc_funcptrs = True, use_raw_name=False, use_ zig_type = as_zig_struct_type(array_type, prefix) def_val = ".{ }" else: - zig_type = "???" - def_val = "???" + sys.exit(f"ERROR gen_struct is_2d_array_type: {array_type}") t0 = f"[{array_nums[0]}][{array_nums[1]}]{zig_type}" l(f" {field_name}: {t0} = [_][{array_nums[1]}]{zig_type}{{[_]{zig_type}{{ {def_val} }}**{array_nums[1]}}}**{array_nums[0]},") else: - l(f"// FIXME: {field_name}: {field_type};") + sys.exit(f"ERROR gen_struct: {field_name}: {field_type};") l("};") def gen_consts(decl, prefix): |