Skip to content

Wrap Type into Option #347

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 1 commit into from
Dec 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
12 changes: 6 additions & 6 deletions libbindgen/src/clang.rs
Original file line number Diff line number Diff line change
Expand Up @@ -402,12 +402,12 @@ impl Cursor {

/// Given that this cursor's referent is a `typedef`, get the `Type` that is
/// being aliased.
pub fn typedef_type(&self) -> Type {
unsafe {
Type {
x: clang_getTypedefDeclUnderlyingType(self.x),
}
}
pub fn typedef_type(&self) -> Option<Type> {
let inner = Type {
x: unsafe { clang_getTypedefDeclUnderlyingType(self.x) }
};

if inner.is_valid() { Some(inner) } else { None }
}

/// Get the linkage kind for this cursor's referent.
Expand Down
4 changes: 2 additions & 2 deletions libbindgen/src/ir/ty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -660,7 +660,7 @@ impl Type {

name = current.spelling();

let inner_ty = cur.typedef_type();
let inner_ty = cur.typedef_type().expect("Not valid Type?");
inner = Item::from_ty(
&inner_ty,
Some(cur),
Expand Down Expand Up @@ -825,7 +825,7 @@ impl Type {
TypeKind::Function(signature)
}
CXType_Typedef => {
let inner = cursor.typedef_type();
let inner = cursor.typedef_type().expect("Not valid Type?");
let inner =
Item::from_ty_or_ref(inner, location, parent_id, ctx);
TypeKind::Alias(ty.spelling(), inner)
Expand Down