Explorar o código

fix prim_types array

Matheus Catarino hai 3 meses
pai
achega
cf03048c5a
Modificáronse 1 ficheiros con 3 adicións e 2 borrados
  1. 3 2
      bindgen/gen_d.py

+ 3 - 2
bindgen/gen_d.py

@@ -311,9 +311,10 @@ def gen_struct(decl, type_converter):
         elif util.is_array_type(field_type):
         elif util.is_array_type(field_type):
             array_type = util.extract_array_type(field_type)
             array_type = util.extract_array_type(field_type)
             array_sizes = util.extract_array_sizes(field_type)
             array_sizes = util.extract_array_sizes(field_type)
-            if array_type in prim_types and array_sizes and len(array_sizes) == 1:
+            if array_type in prim_types and array_sizes:
+                # Handle all primitive arrays with proper defaults
                 default_value = f" = [{', '.join([prim_defaults[array_type]] * int(array_sizes[0]))}]"
                 default_value = f" = [{', '.join([prim_defaults[array_type]] * int(array_sizes[0]))}]"
-            elif array_type in type_converter.struct_types or array_type in type_converter.enum_types or len(array_sizes) > 1:
+            elif array_type in type_converter.struct_types or array_type in type_converter.enum_types:
                 default_value = " = []"
                 default_value = " = []"
             else:
             else:
                 default_value = " = null"
                 default_value = " = null"