Skip to content

Commit 3618668

Browse files
committed
Remove some cruft
1 parent 47eca1f commit 3618668

File tree

3 files changed

+6
-22
lines changed

3 files changed

+6
-22
lines changed

c-bindings-gen/src/main.rs

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,6 @@ fn println_trait<'a, W: std::io::Write>(w: &mut W, t: &'a syn::ItemTrait, module
249249
match export_status(&t.attrs) {
250250
ExportStatus::Export => {},
251251
ExportStatus::NoExport|ExportStatus::TestOnly => return,
252-
ExportStatus::Rename(_) => unimplemented!(),
253252
}
254253
println_docs(w, &t.attrs, "");
255254

@@ -300,7 +299,6 @@ fn println_trait<'a, W: std::io::Write>(w: &mut W, t: &'a syn::ItemTrait, module
300299
},
301300
ExportStatus::Export => {},
302301
ExportStatus::TestOnly => continue,
303-
ExportStatus::Rename(_) => unimplemented!(),
304302
}
305303
if m.default.is_some() { unimplemented!(); }
306304
println_docs(w, &m.attrs, "\t");
@@ -461,12 +459,11 @@ fn println_opaque<W: std::io::Write>(w: &mut W, ident: &syn::Ident, struct_name:
461459
}
462460

463461
fn println_struct<W: std::io::Write>(w: &mut W, s: &syn::ItemStruct, module_path: &str, types: &mut TypeResolver, extra_headers: &mut File) {
464-
let mut struct_name = &format!("{}", s.ident);
462+
let struct_name = &format!("{}", s.ident);
465463
let export = export_status(&s.attrs);
466464
match export {
467465
ExportStatus::Export => {},
468466
ExportStatus::NoExport|ExportStatus::TestOnly => return,
469-
ExportStatus::Rename(ref name) => { struct_name = &name; },
470467
}
471468

472469
//XXX: Stupid hack:
@@ -492,7 +489,6 @@ fn println_struct<W: std::io::Write>(w: &mut W, s: &syn::ItemStruct, module_path
492489
all_fields_settable = false;
493490
continue
494491
},
495-
ExportStatus::Rename(_) => { unimplemented!(); },
496492
}
497493

498494
if let Some(ident) = &field.ident {
@@ -553,7 +549,6 @@ fn println_struct<W: std::io::Write>(w: &mut W, s: &syn::ItemStruct, module_path
553549
}
554550
}
555551

556-
557552
types.struct_imported(&s.ident, struct_name.clone());
558553
}
559554

@@ -583,7 +578,6 @@ eprintln!("WIP: IMPL {:?} FOR {}", trait_path.1, ident);
583578
match export_status(&m.attrs) {
584579
ExportStatus::Export => {},
585580
ExportStatus::NoExport|ExportStatus::TestOnly => continue,
586-
ExportStatus::Rename(_) => unimplemented!(),
587581
}
588582
if m.defaultness.is_some() { unimplemented!(); }
589583
println_docs(w, &m.attrs, "");
@@ -626,7 +620,6 @@ fn println_enum<W: std::io::Write>(w: &mut W, e: &syn::ItemEnum, module_path: &s
626620
match export_status(&e.attrs) {
627621
ExportStatus::Export => {},
628622
ExportStatus::NoExport|ExportStatus::TestOnly => return,
629-
ExportStatus::Rename(_) => { unimplemented!(); },
630623
}
631624

632625
for var in e.variants.iter() {
@@ -743,14 +736,12 @@ fn convert_file(path: &str, out_path: &str, orig_crate: &str, module: &str, head
743736
match export_status(&m.attrs) {
744737
ExportStatus::Export => {},
745738
ExportStatus::NoExport|ExportStatus::TestOnly => continue,
746-
ExportStatus::Rename(_) => unimplemented!(),
747739
}
748740

749741
if m.content.is_some() { unimplemented!(); } // Probably mod tests {}
750742
let f_path = format!("{}/{}.rs", (path.as_ref() as &Path).parent().unwrap().display(), m.ident);
751743
let new_mod = if module.is_empty() { format!("{}", m.ident) } else { format!("{}::{}", module, m.ident) };
752744
if let Ok(_) = File::open(&f_path) {
753-
754745
if should_export(&f_path) {
755746
println_docs(&mut out, &m.attrs, "");
756747
write!(out, "pub mod {};\n", m.ident).unwrap();
@@ -776,7 +767,6 @@ fn convert_file(path: &str, out_path: &str, orig_crate: &str, module: &str, head
776767
match export_status(&t.attrs) {
777768
ExportStatus::Export => {},
778769
ExportStatus::NoExport|ExportStatus::TestOnly => continue,
779-
ExportStatus::Rename(_) => unimplemented!(),
780770
}
781771
if t.generics.lt_token.is_none() {
782772
println_opaque(&mut out, &t.ident, &format!("{}", t.ident), &t.generics, &t.attrs, &orig_module, &type_resolver, header_file);
@@ -797,15 +787,15 @@ fn convert_file(path: &str, out_path: &str, orig_crate: &str, module: &str, head
797787

798788
fn main() {
799789
let args: Vec<String> = env::args().collect();
800-
if args.len() != 6 {
801-
eprintln!("Usage: source/dir our/dir orig_crate module::path extra/includes.h");
790+
if args.len() != 5 {
791+
eprintln!("Usage: source/dir our/dir orig_crate extra/includes.h");
802792
process::exit(1);
803793
}
804794

805795
let mut header_file = std::fs::OpenOptions::new().write(true).append(true)
806-
.open(&args[5]).expect("Unable to open new header file");
796+
.open(&args[4]).expect("Unable to open new header file");
807797

808-
convert_file(&(args[1].clone() + "/lib.rs"), &(args[2].clone() + "lib.rs"), &args[3], &args[4], &mut header_file);
798+
convert_file(&(args[1].clone() + "/lib.rs"), &(args[2].clone() + "lib.rs"), &args[3], "", &mut header_file);
809799

810800
header_file.flush().unwrap();
811801
}

c-bindings-gen/src/types.rs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@ pub enum ExportStatus {
5353
Export,
5454
NoExport,
5555
TestOnly,
56-
Rename(String),
5756
}
5857
pub fn export_status(attrs: &[syn::Attribute]) -> ExportStatus {
5958
for attr in attrs.iter() {
@@ -84,11 +83,6 @@ pub fn export_status(attrs: &[syn::Attribute]) -> ExportStatus {
8483
let line = format!("{}", lit);
8584
if line.contains("(C-not exported)") {
8685
return ExportStatus::NoExport;
87-
} else {
88-
let split: Vec<_> = line.split("(C-exported as ").collect();
89-
if split.len() == 2 {
90-
return ExportStatus::Rename(split[1].split(")").next().unwrap().to_string());
91-
}
9286
}
9387
},
9488
_ => unimplemented!(),

genbindings.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ OUT="$(pwd)/lightning-c-bindings/src"
99
OUT_F="$(pwd)/lightning-c-bindings/include/rust_types.h"
1010
echo > $OUT_F
1111

12-
RUST_BACKTRACE=1 $GEN $SRC/ $OUT/ lightning "" $OUT_F
12+
RUST_BACKTRACE=1 $GEN $SRC/ $OUT/ lightning $OUT_F
1313

1414
cd lightning-c-bindings
1515
cargo build

0 commit comments

Comments
 (0)