[C#] Update auto-generated C# bindings
[ldk-java] / c_sharp / src / org / ldk / structs / Type.cs
index 20799363b7ff28b691bdea7ebda6066d7de58a5c..c4769c098b7f7ecbc40c31bf14d674d51d4621b0 100644 (file)
@@ -1,3 +1,4 @@
+
 using org.ldk.impl;
 using org.ldk.enums;
 using org.ldk.util;
@@ -5,36 +6,35 @@ using System;
 
 namespace org { namespace ldk { namespace structs {
 
+
+
+/** An implementation of Type */
+public interface TypeInterface {
+       /**Returns the type identifying the message payload.
+        */
+       short type_id();
+       /**Return a human-readable "debug" string describing this object
+        */
+       string debug_str();
+       /**Serialize the object into a byte array
+        */
+       byte[] write();
+}
+
 /**
  * Defines a type identifier for sending messages over the wire.
  * 
  * Messages implementing this trait specify a type and must be [`Writeable`].
  */
 public class Type : CommonBase {
-       internal readonly bindings.LDKType bindings_instance;
+       internal bindings.LDKType bindings_instance;
+       internal long instance_idx;
+
        internal Type(object _dummy, long ptr) : base(ptr) { bindings_instance = null; }
-       private Type(bindings.LDKType arg) : base(bindings.LDKType_new(arg)) {
-               this.ptrs_to.AddLast(arg);
-               this.bindings_instance = arg;
-       }
        ~Type() {
                if (ptr != 0) { bindings.Type_free(ptr); }
        }
 
-       public interface TypeInterface {
-               /**
-                * Returns the type identifying the message payload.
-                */
-               short type_id();
-               /**
-                * Return a human-readable "debug" string describing this object
-                */
-               string debug_str();
-               /**
-                * Serialize the object into a byte array
-                */
-               byte[] write();
-       }
        private class LDKTypeHolder { internal Type held; }
        private class LDKTypeImpl : bindings.LDKType {
                internal LDKTypeImpl(TypeInterface arg, LDKTypeHolder impl_holder) { this.arg = arg; this.impl_holder = impl_holder; }
@@ -45,22 +45,32 @@ public class Type : CommonBase {
                                GC.KeepAlive(arg);
                        return ret;
                }
-               public string debug_str() {
+               public long debug_str() {
                        string ret = arg.debug_str();
                                GC.KeepAlive(arg);
-                       return ret;
+                       long result = InternalUtils.encodeString(ret);
+                       return result;
                }
-               public byte[] write() {
+               public long write() {
                        byte[] ret = arg.write();
                                GC.KeepAlive(arg);
-                       return ret;
+                       long result = InternalUtils.encodeUint8Array(ret);
+                       return result;
                }
        }
+
+       /** Creates a new instance of Type from a given implementation */
        public static Type new_impl(TypeInterface arg) {
                LDKTypeHolder impl_holder = new LDKTypeHolder();
-               impl_holder.held = new Type(new LDKTypeImpl(arg, impl_holder));
+               LDKTypeImpl impl = new LDKTypeImpl(arg, impl_holder);
+               long[] ptr_idx = bindings.LDKType_new(impl);
+
+               impl_holder.held = new Type(null, ptr_idx[0]);
+               impl_holder.held.instance_idx = ptr_idx[1];
+               impl_holder.held.bindings_instance = impl;
                return impl_holder.held;
        }
+
        /**
         * Returns the type identifying the message payload.
         */
@@ -74,18 +84,22 @@ public class Type : CommonBase {
         * Return a human-readable "debug" string describing this object
         */
        public string debug_str() {
-               string ret = bindings.Type_debug_str(this.ptr);
+               long ret = bindings.Type_debug_str(this.ptr);
                GC.KeepAlive(this);
-               return ret;
+               if (ret >= 0 && ret <= 4096) { return null; }
+               string ret_conv = InternalUtils.decodeString(ret);
+               return ret_conv;
        }
 
        /**
         * Serialize the object into a byte array
         */
        public byte[] write() {
-               byte[] ret = bindings.Type_write(this.ptr);
+               long ret = bindings.Type_write(this.ptr);
                GC.KeepAlive(this);
-               return ret;
+               if (ret >= 0 && ret <= 4096) { return null; }
+               byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
+               return ret_conv;
        }
 
        internal long clone_ptr() {