X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;f=java_strings.py;h=c0eddca110ad91fdae9271ca41fd825e3e21a848;hb=bf08029c1ad5244b59902eada723b634dcade62d;hp=cb23b56a6d01332e8e25a8c8de0dc56fab45ae95;hpb=4b75327c6b57b9819938eb0008667c86c39d6ca7;p=ldk-java diff --git a/java_strings.py b/java_strings.py index cb23b56a..c0eddca1 100644 --- a/java_strings.py +++ b/java_strings.py @@ -121,6 +121,30 @@ class CommonBase { } """ + self.txout_defn = """public class TxOut extends CommonBase { + /** The script_pubkey in this output */ + public final byte[] script_pubkey; + /** The value, in satoshis, of this output */ + public final long value; + + TxOut(java.lang.Object _dummy, long ptr) { + super(ptr); + this.script_pubkey = bindings.TxOut_get_script_pubkey(ptr); + this.value = bindings.TxOut_get_value(ptr); + } + public TxOut(long value, byte[] script_pubkey) { + super(bindings.TxOut_new(script_pubkey, value)); + this.script_pubkey = bindings.TxOut_get_script_pubkey(ptr); + this.value = bindings.TxOut_get_value(ptr); + } + + @Override @SuppressWarnings(\"deprecation\") + protected void finalize() throws Throwable { + super.finalize(); + if (ptr != 0) { bindings.TxOut_free(ptr); } + } +}""" + self.c_file_pfx = """#include // On OSX jlong (ie long long) is not equivalent to int64_t, so we override here #define int64_t jlong @@ -628,6 +652,19 @@ import javax.annotation.Nullable; def var_decl_statement(self, ty_string, var_name, statement): return ty_string + " " + var_name + " = " + statement + def constr_hu_array(self, ty_info, arr_len): + base_ty = ty_info.subty.java_hu_ty.split("[")[0].split("<")[0] + conv = "new " + base_ty + "[" + arr_len + "]" + if "[" in ty_info.subty.java_hu_ty.split("<")[0]: + # Do a bit of a dance to move any excess [] to the end + conv += "[" + ty_info.subty.java_hu_ty.split("<")[0].split("[")[1] + return conv + + def for_n_in_range(self, n, minimum, maximum): + return "for (int " + n + " = " + minimum + "; " + n + " < " + maximum + "; " + n + "++) {" + def for_n_in_arr(self, n, arr_name, arr_elem_ty): + return ("for (" + arr_elem_ty.java_hu_ty + " " + n + ": " + arr_name + ") { ", " }") + def get_ptr(self, var): return var + ".ptr" def set_null_skip_free(self, var):