From 567db06ae5a1beaac06124c0a4b6bb9435ec441e Mon Sep 17 00:00:00 2001 From: Matt Corallo Date: Fri, 30 Apr 2021 21:50:03 +0000 Subject: [PATCH] Handle empty variant structs and enums in variants --- genbindings.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/genbindings.py b/genbindings.py index 11e65927..4b5ef5dc 100755 --- a/genbindings.py +++ b/genbindings.py @@ -512,7 +512,7 @@ with open(sys.argv[1]) as in_h, open(sys.argv[2], "w") as out_java: if "LDK" + variant_name in union_enum_items: enum_var_lines = union_enum_items["LDK" + variant_name] for idx, field in enumerate(enum_var_lines): - if idx != 0 and idx < len(enum_var_lines) - 2: + if idx != 0 and idx < len(enum_var_lines) - 2 and field.strip() != "": fields.append(type_mapping_generator.map_type(field.strip(' ;'), False, None, False, True)) enum_variants.append(ComplexEnumVariantInfo(variant_name, fields, False)) elif camel_to_snake(variant_name) in inline_enum_variants: @@ -888,6 +888,8 @@ with open(sys.argv[1]) as in_h, open(sys.argv[2], "w") as out_java: line = line.strip() if line.startswith("struct "): line = line[7:] + elif line.startswith("enum "): + line = line[5:] split = line.split(" ") assert len(split) == 2 tuple_variants[split[1].strip(";")] = split[0] -- 2.39.5