X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;f=c-bindings-gen%2Fsrc%2Fblocks.rs;fp=c-bindings-gen%2Fsrc%2Fblocks.rs;h=107c72b3db4b97a852cd0c1a84c8b17ed8d92d7d;hb=e57c225e0f1822809879da01e79e6157cc0996f7;hp=6ba829537ad3bbe2f7d3b6919a18f9a5ed1eabff;hpb=1e06274765ce2c5614175baa355f6b67edefc14f;p=rust-lightning diff --git a/c-bindings-gen/src/blocks.rs b/c-bindings-gen/src/blocks.rs index 6ba82953..107c72b3 100644 --- a/c-bindings-gen/src/blocks.rs +++ b/c-bindings-gen/src/blocks.rs @@ -16,12 +16,15 @@ pub fn write_cpp_wrapper(cpp_header_file: &mut File, ty: &str, has_destructor: b writeln!(cpp_header_file, "\tLDK{} self;", ty).unwrap(); writeln!(cpp_header_file, "public:").unwrap(); writeln!(cpp_header_file, "\t{}(const {}&) = delete;", ty, ty).unwrap(); + writeln!(cpp_header_file, "\t{}({}&& o) : self(o.self) {{ memset(&o, 0, sizeof({})); }}", ty, ty, ty).unwrap(); + writeln!(cpp_header_file, "\t{}(LDK{}&& m_self) : self(m_self) {{ memset(&m_self, 0, sizeof(LDK{})); }}", ty, ty, ty).unwrap(); + writeln!(cpp_header_file, "\toperator LDK{}() && {{ LDK{} res = self; memset(&self, 0, sizeof(LDK{})); return res; }}", ty, ty, ty).unwrap(); if has_destructor { writeln!(cpp_header_file, "\t~{}() {{ {}_free(self); }}", ty, ty).unwrap(); + writeln!(cpp_header_file, "\t{}& operator=({}&& o) {{ {}_free(self); self = o.self; memset(&o, 0, sizeof({})); return *this; }}", ty, ty, ty, ty).unwrap(); + } else { + writeln!(cpp_header_file, "\t{}& operator=({}&& o) {{ self = o.self; memset(&o, 0, sizeof({})); return *this; }}", ty, ty, ty).unwrap(); } - writeln!(cpp_header_file, "\t{}({}&& o) : self(o.self) {{ memset(&o, 0, sizeof({})); }}", ty, ty, ty).unwrap(); - writeln!(cpp_header_file, "\t{}(LDK{}&& m_self) : self(m_self) {{ memset(&m_self, 0, sizeof(LDK{})); }}", ty, ty, ty).unwrap(); - writeln!(cpp_header_file, "\toperator LDK{}() {{ LDK{} res = self; memset(&self, 0, sizeof(LDK{})); return res; }}", ty, ty, ty).unwrap(); writeln!(cpp_header_file, "\tLDK{}* operator &() {{ return &self; }}", ty).unwrap(); writeln!(cpp_header_file, "\tLDK{}* operator ->() {{ return &self; }}", ty).unwrap(); writeln!(cpp_header_file, "\tconst LDK{}* operator &() const {{ return &self; }}", ty).unwrap();