From fbe8a11be350e6f926c91c960fd009aa3dcbcbcf Mon Sep 17 00:00:00 2001 From: Andre Weissflog Date: Thu, 14 Jul 2022 20:11:37 +0200 Subject: bindings generation minor code cleanup --- bindgen/gen_ir.py | 2 +- bindgen/gen_nim.py | 10 +++++----- bindgen/gen_zig.py | 10 +++++----- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/bindgen/gen_ir.py b/bindgen/gen_ir.py index 6fcfdb06..1441c435 100644 --- a/bindgen/gen_ir.py +++ b/bindgen/gen_ir.py @@ -79,7 +79,7 @@ def parse_func(decl): if 'inner' in decl: for param in decl['inner']: if param['kind'] != 'ParmVarDecl': - print(f"warning: ignoring func {decl['name']} (unsupported parameter type)") + print(f" >> warning: ignoring func {decl['name']} (unsupported parameter type)") return None outp_param = {} outp_param['name'] = param['name'] diff --git a/bindgen/gen_nim.py b/bindgen/gen_nim.py index a01c057d..6d5ad851 100644 --- a/bindgen/gen_nim.py +++ b/bindgen/gen_nim.py @@ -148,6 +148,9 @@ xor yield """.split() + common_prim_types +re_1d_array = re.compile("^(?:const )?\w*\s\*?\[\d*\]$") +re_2d_array = re.compile("^(?:const )?\w*\s\*?\[\d*\]\[\d*\]$") + struct_types = [] enum_types = [] out_lines = '' @@ -160,9 +163,6 @@ def reset_globals(): enum_types = [] out_lines = '' -re_1d_array = re.compile("^(?:const )?\w*\s\*?\[\d*\]$") -re_2d_array = re.compile("^(?:const )?\w*\s\*?\[\d*\]\[\d*\]$") - def l(s): global out_lines out_lines += s + '\n' @@ -609,7 +609,7 @@ def gen_module(inp, dep_prefixes): gen_extra(inp) def prepare(): - print('Generating nim bindings:') + print('=== Generating Nim bindings:') if not os.path.isdir('sokol-nim/src/sokol'): os.makedirs('sokol-nim/src/sokol') if not os.path.isdir('sokol-nim/src/sokol/c'): @@ -617,7 +617,7 @@ def prepare(): def gen(c_header_path, c_prefix, dep_c_prefixes): if not c_prefix in module_names: - print(f'warning: skipping generation for {c_prefix} prefix...') + print(f' >> warning: skipping generation for {c_prefix} prefix...') return global out_lines module_name = module_names[c_prefix] diff --git a/bindgen/gen_zig.py b/bindgen/gen_zig.py index 59e7825b..149df3de 100644 --- a/bindgen/gen_zig.py +++ b/bindgen/gen_zig.py @@ -89,6 +89,9 @@ prim_defaults = { 'size_t': '0' } +re_1d_array = re.compile("^(?:const )?\w*\s\*?\[\d*\]$") +re_2d_array = re.compile("^(?:const )?\w*\s\*?\[\d*\]\[\d*\]$") + struct_types = [] enum_types = [] enum_items = {} @@ -104,9 +107,6 @@ def reset_globals(): enum_items = {} out_lines = '' -re_1d_array = re.compile("^(?:const )?\w*\s\*?\[\d*\]$") -re_2d_array = re.compile("^(?:const )?\w*\s\*?\[\d*\]\[\d*\]$") - def l(s): global out_lines out_lines += s + '\n' @@ -558,7 +558,7 @@ def gen_module(inp, dep_prefixes): gen_func_zig(decl, prefix) def prepare(): - print('Generating zig bindings:') + print('=== Generating Zig bindings:') if not os.path.isdir('sokol-zig/src/sokol'): os.makedirs('sokol-zig/src/sokol') if not os.path.isdir('sokol-zig/src/sokol/c'): @@ -566,7 +566,7 @@ def prepare(): def gen(c_header_path, c_prefix, dep_c_prefixes): if not c_prefix in module_names: - print(f'warning: skipping generation for {c_prefix} prefix...') + print(f' >> warning: skipping generation for {c_prefix} prefix...') return module_name = module_names[c_prefix] c_source_path = c_source_paths[c_prefix] -- cgit v1.2.3