Unverified Commit 95821b3b authored by Jeremy Soller's avatar Jeremy Soller Committed by GitHub

Merge pull request #3 from dlrobertson/mod_path_attr

Improve module path parsing
parents d14295f3 653a328c
......@@ -313,12 +313,35 @@ impl Parser {
} else if next_mod_path2.exists() {
self.parse_mod(pkg, next_mod_path2.as_path())?;
} else {
// Last chance to find a module path
let mut path_attr_found = false;
for attr in &item.attrs {
if attr.is_sugared_doc {
continue;
}
match attr.interpret_meta() {
Some(syn::Meta::NameValue(syn::MetaNameValue { ident, lit, ..})) => {
match (ident.as_ref(), lit) {
("path", syn::Lit::Str(ref path)) => {
path_attr_found = true;
self.parse_mod(pkg, &mod_dir.join(path.value()))?;
}
_ => (),
}
}
_ => (),
}
}
// This should be an error, but it's common enough to
// just elicit a warning
warn!(
"Parsing crate `{}`: can't find mod {}`.",
pkg.name, next_mod_name
);
if !path_attr_found {
warn!(
"Parsing crate `{}`: can't find mod {}`.",
pkg.name, next_mod_name
);
}
}
}
......
#include <stdint.h>
#include <stdlib.h>
#include <stdbool.h>
#define EXPORT_ME_TOO 42
typedef struct {
uint64_t val;
} ExportMe;
void export_me(ExportMe *val);
#include <cstdint>
#include <cstdlib>
static const uint8_t EXPORT_ME_TOO = 42;
struct ExportMe {
uint64_t val;
};
extern "C" {
void export_me(ExportMe *val);
} // extern "C"
[[package]]
name = "mod_path"
version = "0.1.0"
[package]
name = "mod_path"
version = "0.1.0"
authors = ["cbindgen"]
[lib]
name = "mod_path"
crate-type = ["lib", "dylib"]
[parse]
parse_deps = false
#[path = "other.rs"]
mod inner;
pub use inner::*;
#[repr(C)]
pub struct ExportMe {
val: u64
}
#[repr(C)]
pub struct DoNotExportMe {
val: u64
}
pub const EXPORT_ME_TOO: u8 = 0x2a;
#[no_mangle]
pub unsafe extern "C" fn export_me(val: *mut ExportMe) { }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment