projects
/
rust-lightning
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
29b209c
)
[bindings] Expose a _clone fn for every enum
author
Matt Corallo
<git@bluematt.me>
Tue, 20 Oct 2020 18:02:12 +0000
(14:02 -0400)
committer
Matt Corallo
<git@bluematt.me>
Mon, 23 Nov 2020 16:08:34 +0000
(11:08 -0500)
This somewhat assumes that every public enum implements clone in
some way, but that is currently the case.
c-bindings-gen/src/main.rs
patch
|
blob
|
history
diff --git
a/c-bindings-gen/src/main.rs
b/c-bindings-gen/src/main.rs
index b4a148fbafcb967e34ffd426cf74cdbb9ddc6086..be3d36724853425184f0dc9fa78b5b91cde60850 100644
(file)
--- a/
c-bindings-gen/src/main.rs
+++ b/
c-bindings-gen/src/main.rs
@@
-995,6
+995,10
@@
fn writeln_enum<'a, 'b, W: std::io::Write>(w: &mut W, e: &'a syn::ItemEnum, type
if needs_free {
writeln!(w, "#[no_mangle]\npub extern \"C\" fn {}_free(this_ptr: {}) {{ }}", e.ident, e.ident).unwrap();
}
+ writeln!(w, "#[no_mangle]").unwrap();
+ writeln!(w, "pub extern \"C\" fn {}_clone(orig: &{}) -> {} {{", e.ident, e.ident, e.ident).unwrap();
+ writeln!(w, "\torig.clone()").unwrap();
+ writeln!(w, "}}").unwrap();
write_cpp_wrapper(cpp_headers, &format!("{}", e.ident), needs_free);
}