Skip to content

Little logging things #266

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Nov 15, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions libbindgen/src/clang.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1235,21 +1235,23 @@ pub fn type_to_str(x: Enum_CXTypeKind) -> String {
/// Dump the Clang AST to stdout for debugging purposes.
pub fn ast_dump(c: &Cursor, depth: isize) -> Enum_CXVisitorResult {
fn print_indent(depth: isize, s: &str) {
let mut i = 0;
while i < depth {
for _ in 0..depth {
print!("\t");
i += 1;
}
println!("{}", s);
}
let ct = c.cur_type().kind();

print_indent(depth,
&format!("({} {} {}",
&format!("(kind: {}, spelling: {}, type: {}",
kind_to_str(c.kind()),
c.spelling(),
type_to_str(ct)));
type_to_str(c.cur_type().kind())));

// Recurse.
c.visit(|s| ast_dump(&s, depth + 1));

print_indent(depth, ")");

CXChildVisit_Continue
}

Expand Down
16 changes: 16 additions & 0 deletions libbindgen/src/codegen/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -228,9 +228,12 @@ impl CodeGenerator for Item {
result: &mut CodegenResult,
_extra: &()) {
if self.is_hidden(ctx) || result.seen(self.id()) {
debug!("<Item as CodeGenerator>::codegen: Ignoring hidden or seen: self = {:?}", self);
return;
}

debug!("<Item as CodeGenerator>::codegen: self = {:?}", self);

result.set_seen(self.id());

match *self.kind() {
Expand Down Expand Up @@ -264,6 +267,8 @@ impl CodeGenerator for Module {
ctx: &BindgenContext,
result: &mut CodegenResult,
item: &Item) {
debug!("<Module as CodeGenerator>::codegen: item = {:?}", item);

if !ctx.options().enable_cxx_namespaces {
for child in self.children() {
ctx.resolve_item(*child).codegen(ctx, result, &());
Expand Down Expand Up @@ -299,6 +304,8 @@ impl CodeGenerator for Var {
ctx: &BindgenContext,
result: &mut CodegenResult,
item: &Item) {
debug!("<Var as CodeGenerator>::codegen: item = {:?}", item);

let canonical_name = item.canonical_name(ctx);

if result.seen_var(&canonical_name) {
Expand Down Expand Up @@ -349,6 +356,8 @@ impl CodeGenerator for Type {
ctx: &BindgenContext,
result: &mut CodegenResult,
item: &Item) {
debug!("<Type as CodeGenerator>::codegen: item = {:?}", item);

match *self.kind() {
TypeKind::Void |
TypeKind::NullPtr |
Expand Down Expand Up @@ -600,6 +609,9 @@ impl CodeGenerator for CompInfo {
result: &mut CodegenResult,
item: &Item) {
use aster::struct_field::StructFieldBuilder;

debug!("<CompInfo as CodeGenerator>::codegen: item = {:?}", item);

// Don't output classes with template parameters that aren't types, and
// also don't output template specializations, neither total or partial.
//
Expand Down Expand Up @@ -1361,6 +1373,8 @@ impl CodeGenerator for Enum {
ctx: &BindgenContext,
result: &mut CodegenResult,
item: &Item) {
debug!("<Enum as CodeGenerator>::codegen: item = {:?}", item);

let name = item.canonical_name(ctx);
let enum_ty = item.expect_type();
let layout = enum_ty.layout(ctx);
Expand Down Expand Up @@ -1800,6 +1814,8 @@ impl CodeGenerator for Function {
ctx: &BindgenContext,
result: &mut CodegenResult,
item: &Item) {
debug!("<Function as CodeGenerator>::codegen: item = {:?}", item);

let name = self.name();
let mut canonical_name = item.canonical_name(ctx);
let mangled_name = self.mangled_name();
Expand Down