Skip to content

Commit

Permalink
Add support for double-arrays in struct fields
Browse files Browse the repository at this point in the history
  • Loading branch information
alexcrichton committed Jul 5, 2017
1 parent 2bcacb0 commit 466d365
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
15 changes: 13 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1221,8 +1221,19 @@ impl<'a> Generator<'a> {
format!("{}({}**{})({})", ret, abi, sig, args.connect(", "))
}
ast::TyKind::FixedLengthVec(ref t, ref e) => {
format!("{}(*{})[{}]", self.ty2name(t, false), sig,
self.expr2str(e))
match t.node {
ast::TyKind::FixedLengthVec(ref t2, ref e2) => {
format!("{}(*{})[{}][{}]",
self.ty2name(t2, false),
sig,
self.expr2str(e),
self.expr2str(e2))
}
_ => {
format!("{}(*{})[{}]", self.ty2name(t, false), sig,
self.expr2str(e))
}
}
}
_ => format!("{}* {}", self.ty2name(ty, false), sig)
}
Expand Down
1 change: 1 addition & 0 deletions testcrate/src/t1.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ struct T1Bar {
T1Foo c;
uint8_t d;
int64_t e[T1N];
int64_t f[T1N][2];
};

struct T1Baz {
Expand Down
1 change: 1 addition & 0 deletions testcrate/src/t1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ pub struct T1Bar {
pub c: T1Foo,
pub d: u8,
pub e: [i64; T1N as usize],
pub f: [[i64; 2]; T1N as usize],
}

#[repr(C)]
Expand Down

0 comments on commit 466d365

Please sign in to comment.