X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;f=c-bindings-gen%2Fsrc%2Fmain.rs;h=1d37bb2b6335c4a538511b13345d5f01be36a5bc;hb=e8c40b6f04f3b55cd305c7ad88b07dec23a84c4e;hp=9665fdc3008cc015e1c487065e03e16a93118a37;hpb=b33df3ebba7af25aa0e53654953d8493406109ed;p=ldk-c-bindings diff --git a/c-bindings-gen/src/main.rs b/c-bindings-gen/src/main.rs index 9665fdc..1d37bb2 100644 --- a/c-bindings-gen/src/main.rs +++ b/c-bindings-gen/src/main.rs @@ -1,3 +1,11 @@ +// This file is Copyright its original authors, visible in version control +// history. +// +// This file is licensed under the Apache License, Version 2.0 +// or the MIT license , at your option. +// You may not use this file except in accordance with one or both of these +// licenses. + //! Converts a rust crate into a rust crate containing a number of C-exported wrapper functions and //! classes (which is exportable using cbindgen). //! In general, supports convering: @@ -382,8 +390,8 @@ fn writeln_trait<'a, 'b, W: std::io::Write>(w: &mut W, t: &'a syn::ItemTrait, ty }); } ) ); - writeln!(w, "/// Frees any resources associated with this object given its this_arg pointer.").unwrap(); - writeln!(w, "/// Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed.").unwrap(); + writeln!(w, "\t/// Frees any resources associated with this object given its this_arg pointer.").unwrap(); + writeln!(w, "\t/// Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed.").unwrap(); writeln!(w, "\tpub free: Option,").unwrap(); generated_fields.push("free".to_owned()); writeln!(w, "}}").unwrap(); @@ -1342,6 +1350,15 @@ fn convert_file<'a, 'b>(libast: &'a FullLibraryAST, crate_types: &mut CrateTypes let mut out = std::fs::OpenOptions::new().write(true).create(true).truncate(true) .open(new_file_path).expect("Unable to open new src file"); + writeln!(out, "// This file is Copyright its original authors, visible in version control").unwrap(); + writeln!(out, "// history and in the source files from which this was generated.").unwrap(); + writeln!(out, "//").unwrap(); + writeln!(out, "// This file is licensed under the license available in the LICENSE or LICENSE.md").unwrap(); + writeln!(out, "// file in the root of this repository or, if no such file exists, the same").unwrap(); + writeln!(out, "// license as that which applies to the original source files from which this").unwrap(); + writeln!(out, "// source was automatically generated.").unwrap(); + writeln!(out, "").unwrap(); + writeln_docs(&mut out, &attrs, ""); if module == "" { @@ -1357,8 +1374,8 @@ fn convert_file<'a, 'b>(libast: &'a FullLibraryAST, crate_types: &mut CrateTypes writeln!(out, "#![allow(unused_unsafe)]").unwrap(); writeln!(out, "#![allow(unused_braces)]").unwrap(); writeln!(out, "#![deny(missing_docs)]").unwrap(); - writeln!(out, "mod c_types;").unwrap(); - writeln!(out, "mod bitcoin;").unwrap(); + writeln!(out, "pub mod c_types;").unwrap(); + writeln!(out, "pub mod bitcoin;").unwrap(); } else { writeln!(out, "\nuse std::ffi::c_void;\nuse bitcoin::hashes::Hash;\nuse crate::c_types::*;\n").unwrap(); }