aboutsummaryrefslogtreecommitdiff
path: root/bindgen/gen_zig.py
diff options
context:
space:
mode:
authorAndre Weissflog <floooh@gmail.com>2020-12-23 19:06:45 +0100
committerAndre Weissflog <floooh@gmail.com>2020-12-23 19:06:45 +0100
commita780b2f3bbce420e17d913da5b171c3bd95ac166 (patch)
treeb7361977550360819dee2ad7a6572b8f62274d12 /bindgen/gen_zig.py
parent9571c8e9901c05a556d9e71d3735fc64c080349a (diff)
bindgen: add sokol_time.h
Diffstat (limited to 'bindgen/gen_zig.py')
-rw-r--r--bindgen/gen_zig.py14
1 files changed, 12 insertions, 2 deletions
diff --git a/bindgen/gen_zig.py b/bindgen/gen_zig.py
index b605785a..2750dd99 100644
--- a/bindgen/gen_zig.py
+++ b/bindgen/gen_zig.py
@@ -134,12 +134,18 @@ def is_const_void_ptr(s):
def is_void_ptr(s):
return s == "void *"
-def is_prim_ptr(s):
+def is_const_prim_ptr(s):
for prim_type in prim_types:
if s == f"const {prim_type} *":
return True
return False
+def is_prim_ptr(s):
+ for prim_type in prim_types:
+ if s == f"{prim_type} *":
+ return True
+ return False
+
def is_const_struct_ptr(s):
for struct_type in struct_types:
if s == f"const {struct_type} *":
@@ -188,6 +194,8 @@ def as_extern_c_arg_type(arg_type):
return "[*c]const u8"
elif is_const_struct_ptr(arg_type):
return f"[*c]const {as_title_case(extract_ptr_type(arg_type))}"
+ elif is_prim_ptr(arg_type):
+ return f"[*c] {as_zig_prim_type(extract_ptr_type(arg_type))}"
else:
return '???'
@@ -214,6 +222,8 @@ def as_zig_arg_type(arg_prefix, arg_type):
elif is_const_struct_ptr(arg_type):
# not a bug, pass const structs by value
return pre + f"{as_title_case(extract_ptr_type(arg_type))}"
+ elif is_prim_ptr(arg_type):
+ return pre + f"* {as_zig_prim_type(extract_ptr_type(arg_type))}"
else:
return arg_prefix + "???"
@@ -295,7 +305,7 @@ def gen_struct(decl, prefix, callconvc_funcptrs = True, use_raw_name=False, use_
l(f" {field_name}: ?*const c_void = null,")
elif is_void_ptr(field_type):
l(f" {field_name}: ?*c_void = null,")
- elif is_prim_ptr(field_type):
+ 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):
if callconvc_funcptrs: