2
0
Эх сурвалжийг харах

bindings generation minor code cleanup

Andre Weissflog 3 жил өмнө
parent
commit
fbe8a11be3

+ 1 - 1
bindgen/gen_ir.py

@@ -79,7 +79,7 @@ def parse_func(decl):
     if 'inner' in decl:
     if 'inner' in decl:
         for param in decl['inner']:
         for param in decl['inner']:
             if param['kind'] != 'ParmVarDecl':
             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
                 return None
             outp_param = {}
             outp_param = {}
             outp_param['name'] = param['name']
             outp_param['name'] = param['name']

+ 5 - 5
bindgen/gen_nim.py

@@ -148,6 +148,9 @@ xor
 yield
 yield
 """.split() + common_prim_types
 """.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 = []
 struct_types = []
 enum_types = []
 enum_types = []
 out_lines = ''
 out_lines = ''
@@ -160,9 +163,6 @@ def reset_globals():
     enum_types = []
     enum_types = []
     out_lines = ''
     out_lines = ''
 
 
-re_1d_array = re.compile("^(?:const )?\w*\s\*?\[\d*\]$")
-re_2d_array = re.compile("^(?:const )?\w*\s\*?\[\d*\]\[\d*\]$")
-
 def l(s):
 def l(s):
     global out_lines
     global out_lines
     out_lines += s + '\n'
     out_lines += s + '\n'
@@ -609,7 +609,7 @@ def gen_module(inp, dep_prefixes):
     gen_extra(inp)
     gen_extra(inp)
 
 
 def prepare():
 def prepare():
-    print('Generating nim bindings:')
+    print('=== Generating Nim bindings:')
     if not os.path.isdir('sokol-nim/src/sokol'):
     if not os.path.isdir('sokol-nim/src/sokol'):
         os.makedirs('sokol-nim/src/sokol')
         os.makedirs('sokol-nim/src/sokol')
     if not os.path.isdir('sokol-nim/src/sokol/c'):
     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):
 def gen(c_header_path, c_prefix, dep_c_prefixes):
     if not c_prefix in module_names:
     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
         return
     global out_lines
     global out_lines
     module_name = module_names[c_prefix]
     module_name = module_names[c_prefix]

+ 5 - 5
bindgen/gen_zig.py

@@ -89,6 +89,9 @@ prim_defaults = {
     'size_t':       '0'
     'size_t':       '0'
 }
 }
 
 
+re_1d_array = re.compile("^(?:const )?\w*\s\*?\[\d*\]$")
+re_2d_array = re.compile("^(?:const )?\w*\s\*?\[\d*\]\[\d*\]$")
+
 struct_types = []
 struct_types = []
 enum_types = []
 enum_types = []
 enum_items = {}
 enum_items = {}
@@ -104,9 +107,6 @@ def reset_globals():
     enum_items = {}
     enum_items = {}
     out_lines = ''
     out_lines = ''
 
 
-re_1d_array = re.compile("^(?:const )?\w*\s\*?\[\d*\]$")
-re_2d_array = re.compile("^(?:const )?\w*\s\*?\[\d*\]\[\d*\]$")
-
 def l(s):
 def l(s):
     global out_lines
     global out_lines
     out_lines += s + '\n'
     out_lines += s + '\n'
@@ -558,7 +558,7 @@ def gen_module(inp, dep_prefixes):
                     gen_func_zig(decl, prefix)
                     gen_func_zig(decl, prefix)
 
 
 def prepare():
 def prepare():
-    print('Generating zig bindings:')
+    print('=== Generating Zig bindings:')
     if not os.path.isdir('sokol-zig/src/sokol'):
     if not os.path.isdir('sokol-zig/src/sokol'):
         os.makedirs('sokol-zig/src/sokol')
         os.makedirs('sokol-zig/src/sokol')
     if not os.path.isdir('sokol-zig/src/sokol/c'):
     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):
 def gen(c_header_path, c_prefix, dep_c_prefixes):
     if not c_prefix in module_names:
     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
         return
     module_name = module_names[c_prefix]
     module_name = module_names[c_prefix]
     c_source_path = c_source_paths[c_prefix]
     c_source_path = c_source_paths[c_prefix]