Skip to content

Commit

Permalink
Auto merge of #6 - servo:add-elab, r=emilio
Browse files Browse the repository at this point in the history
Add support for elaborated types.

Fixes #1.
  • Loading branch information
bors-servo authored Jul 1, 2016
2 parents 7726d5a + 63067c9 commit e1a59ff
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/clang.rs
Original file line number Diff line number Diff line change
Expand Up @@ -455,6 +455,13 @@ impl Type {
clang_getFunctionTypeCallingConv(self.x)
}
}

#[cfg(not(feature="llvm_stable"))]
pub fn named(&self) -> Type {
unsafe {
Type { x: clang_Type_getNamedType(self.x) }
}
}
}

// SourceLocation
Expand Down Expand Up @@ -955,6 +962,11 @@ pub fn type_to_str(x: Enum_CXTypeKind) -> &'static str {
CXType_IncompleteArray => "IncompleteArray",
CXType_VariableArray => "VariableArray",
CXType_DependentSizedArray => "DependentSizedArray",
CXType_MemberPointer => "MemberPointer",
#[cfg(not(feature="llvm_stable"))]
CXType_Auto => "Auto",
#[cfg(not(feature="llvm_stable"))]
CXType_Elaborated => "Elaborated",
_ => "?"
}
}
Expand Down
6 changes: 6 additions & 0 deletions src/clangll.rs
Original file line number Diff line number Diff line change
Expand Up @@ -408,6 +408,10 @@ pub const CXType_IncompleteArray: c_uint = 114;
pub const CXType_VariableArray: c_uint = 115;
pub const CXType_DependentSizedArray: c_uint = 116;
pub const CXType_MemberPointer: c_uint = 117;
#[cfg(not(feature="llvm_stable"))]
pub const CXType_Auto: c_uint = 118;
#[cfg(not(feature="llvm_stable"))]
pub const CXType_Elaborated: c_uint = 119;
pub type Enum_CXCallingConv = c_uint;
pub const CXCallingConv_Default: c_uint = 0;
pub const CXCallingConv_C: c_uint = 1;
Expand Down Expand Up @@ -1108,6 +1112,8 @@ extern "C" {
pub fn clang_Type_getNumTemplateArguments(T: CXType) -> c_int;
pub fn clang_Type_getTemplateArgumentAsType(T: CXType, i: c_int) ->
CXType;
#[cfg(not(feature="llvm_stable"))]
pub fn clang_Type_getNamedType(CT: CXType) -> CXType;
pub fn clang_Cursor_isBitField(C: CXCursor) -> c_uint;
#[cfg(not(feature="llvm_stable"))]
pub fn clang_Cursor_isFunctionInlined(C: CXCursor) -> c_uint;
Expand Down
2 changes: 2 additions & 0 deletions src/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -490,6 +490,8 @@ fn conv_ty_resolving_typedefs(ctx: &mut ClangParserCtx,
CXType_Unexposed |
CXType_Enum => conv_decl_ty_resolving_typedefs(ctx, ty, cursor, resolve_typedefs),
CXType_ConstantArray => TArray(Box::new(conv_ty_resolving_typedefs(ctx, &ty.elem_type(), cursor, resolve_typedefs)), ty.array_size(), layout),
#[cfg(not(feature="llvm_stable"))]
CXType_Elaborated => conv_ty_resolving_typedefs(ctx, &ty.named(), cursor, resolve_typedefs),
_ => {
let fail = ctx.options.fail_on_unknown_type;
log_err_warn(ctx,
Expand Down
7 changes: 7 additions & 0 deletions tests/expectations/elaborated.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
/* automatically generated by rust-bindgen */

pub type whatever_t = ::std::os::raw::c_int;
extern "C" {
#[link_name = "_Z9somethingPKi"]
pub fn something(wat: *const whatever_t);
}
5 changes: 5 additions & 0 deletions tests/headers/elaborated.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
namespace whatever {
typedef int whatever_t;
}

void something(const whatever::whatever_t *wat);

0 comments on commit e1a59ff

Please sign in to comment.