From: Matt Corallo Date: Fri, 19 Nov 2021 20:11:56 +0000 (+0000) Subject: Add helper method on results to return `result_ok` X-Git-Tag: v0.0.103.1^2~11 X-Git-Url: http://git.bitcoin.ninja/?a=commitdiff_plain;h=81c8df191bcdcccc1e2f1d2141331ea80c93cb5e;p=ldk-c-bindings Add helper method on results to return `result_ok` This fixes https://github.com/lightningdevkit/ldk-garbagecollected/issues/59 --- diff --git a/c-bindings-gen/src/blocks.rs b/c-bindings-gen/src/blocks.rs index 5713578..6e6b897 100644 --- a/c-bindings-gen/src/blocks.rs +++ b/c-bindings-gen/src/blocks.rs @@ -124,6 +124,12 @@ pub fn write_result_block(w: &mut W, mangled_container: &str, writeln!(w, "\t}}").unwrap(); writeln!(w, "}}").unwrap(); + writeln!(w, "/// Checks if the given object is currently in the success state").unwrap(); + writeln!(w, "#[no_mangle]").unwrap(); + writeln!(w, "pub extern \"C\" fn {}_is_ok(o: &{}) -> bool {{", mangled_container, mangled_container).unwrap(); + writeln!(w, "\to.result_ok").unwrap(); + writeln!(w, "}}").unwrap(); + writeln!(w, "#[no_mangle]").unwrap(); writeln!(w, "/// Frees any resources used by the {}.", mangled_container).unwrap(); writeln!(w, "pub extern \"C\" fn {}_free(_res: {}) {{ }}", mangled_container, mangled_container).unwrap();