]> git.bitcoin.ninja Git - ldk-java/commitdiff
Handle empty variant structs and enums in variants
authorMatt Corallo <git@bluematt.me>
Fri, 30 Apr 2021 21:50:03 +0000 (21:50 +0000)
committerMatt Corallo <git@bluematt.me>
Sat, 1 May 2021 00:11:31 +0000 (00:11 +0000)
genbindings.py

index 11e659277cf1586272e3edd8cabce64040b720b2..4b5ef5dc8bdc96e1de0ff0b85cada71bbb4fe413 100755 (executable)
@@ -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]