Fix short, push trait struct refcnt increment down to lang
authorMatt Corallo <git@bluematt.me>
Wed, 13 Jan 2021 04:48:24 +0000 (23:48 -0500)
committerMatt Corallo <git@bluematt.me>
Mon, 25 Jan 2021 21:09:09 +0000 (16:09 -0500)
gen_type_mapping.py
genbindings.py
java_strings.py
typescript_strings.py

index 7eda9b7ca01c04f34ecb9792a4224e6d6ce82fc3..fe2aed21397c45a2e26b39b2333fd90fdfb83fb7 100644 (file)
@@ -275,9 +275,7 @@ class TypeMappingGenerator:
                         if needs_full_clone and (ty_info.rust_obj.replace("LDK", "") + "_clone") in self.clone_fns:
                             base_conv = base_conv + "\n" + ty_info.var_name + "_conv = " + ty_info.rust_obj.replace("LDK", "") + "_clone(" + ty_info.var_name + ");"
                         else:
-                            base_conv = base_conv + "\nif (" + ty_info.var_name + "_conv.free == " + ty_info.rust_obj + "_JCalls_free) {\n"
-                            base_conv = base_conv + "\t// If this_arg is a JCalls struct, then we need to increment the refcnt in it.\n"
-                            base_conv = base_conv + "\t" + ty_info.rust_obj + "_JCalls_clone(" + ty_info.var_name + "_conv.this_arg);\n}"
+                            base_conv = base_conv + self.consts.trait_struct_inc_refcnt(ty_info)
                             if needs_full_clone:
                                 base_conv = base_conv + "// Warning: we may need a move here but can't do a full clone!\n"
 
index fa75b0fb44e5e8d646fd2630281c78ec6915a01f..221b1bd823132dffe4930774324a166bab0ae8fc 100755 (executable)
@@ -201,7 +201,7 @@ def java_c_types(fn_arg, ret_arr_len):
     elif fn_arg.startswith("uint16_t"):
         mapped_type = consts.c_type_map['uint16_t']
         java_ty = mapped_type[0]
-        c_ty = "jshort"
+        c_ty = "int16_t"
         fn_ty_arg = "S"
         fn_arg = fn_arg[8:].strip()
         is_primitive = True
index 2e9ae67052d7d06fe6873065da9004d0a72fc4a2..d73a15de87328d4114350a387f28a88e978a38b3 100644 (file)
@@ -702,6 +702,12 @@ import java.util.Arrays;
 
         return (out_java, out_java_trait, out_c)
 
+    def trait_struct_inc_refcnt(self, ty_info):
+        base_conv = "\nif (" + ty_info.var_name + "_conv.free == " + ty_info.rust_obj + "_JCalls_free) {\n"
+        base_conv = base_conv + "\t// If this_arg is a JCalls struct, then we need to increment the refcnt in it.\n"
+        base_conv = base_conv + "\t" + ty_info.rust_obj + "_JCalls_clone(" + ty_info.var_name + "_conv.this_arg);\n}"
+        return base_conv
+
     def map_complex_enum(self, struct_name, variant_list, camel_to_snake):
         java_hu_type = struct_name.replace("LDK", "")
         out_java_enum = ""
index 6e2ce6fa3bea22e77394852fffcaf91e4b4808dd..7c6e6ab5644b5abb99d926b5d527bb803957f531 100644 (file)
@@ -650,6 +650,9 @@ const wasm = wasmInstance.exports;
 
         return (out_typescript_bindings, out_typescript_human, out_c)
 
+    def trait_struct_inc_refcnt(self, ty_info):
+        return ""
+
     def map_complex_enum(self, struct_name, variant_list, camel_to_snake):
         java_hu_type = struct_name.replace("LDK", "")