diff --git a/src/clang.rs b/src/clang.rs index 9c46a94ef2..8426deebba 100644 --- a/src/clang.rs +++ b/src/clang.rs @@ -446,6 +446,12 @@ impl Type { clang_getFunctionTypeCallingConv(self.x) } } + + pub fn named(&self) -> Type { + unsafe { + Type { x: clang_Type_getNamedType(self.x) } + } + } } // SourceLocation @@ -946,6 +952,9 @@ pub fn type_to_str(x: Enum_CXTypeKind) -> &'static str { CXType_IncompleteArray => "IncompleteArray", CXType_VariableArray => "VariableArray", CXType_DependentSizedArray => "DependentSizedArray", + CXType_MemberPointer => "MemberPointer", + CXType_Auto => "Auto", + CXType_Elaborated => "Elaborated", _ => "?" } } diff --git a/src/clangll.rs b/src/clangll.rs index 4877ea70e0..901fff2b2c 100644 --- a/src/clangll.rs +++ b/src/clangll.rs @@ -408,6 +408,8 @@ 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; +pub const CXType_Auto: c_uint = 118; +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; @@ -1108,6 +1110,7 @@ extern "C" { pub fn clang_Type_getNumTemplateArguments(T: CXType) -> c_int; pub fn clang_Type_getTemplateArgumentAsType(T: CXType, i: c_int) -> CXType; + pub fn clang_Type_getNamedType(CT: CXType) -> CXType; pub fn clang_Cursor_isBitField(C: CXCursor) -> c_uint; pub fn clang_Cursor_isFunctionInlined(C: CXCursor) -> c_uint; pub fn clang_isVirtualBase(arg1: CXCursor) -> c_uint; diff --git a/src/parser.rs b/src/parser.rs index 6b942b2a94..8673318656 100644 --- a/src/parser.rs +++ b/src/parser.rs @@ -489,6 +489,7 @@ 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), + CXType_Elaborated => conv_ty_resolving_typedefs(ctx, &ty.named(), cursor, resolve_typedefs), _ => { let fail = ctx.options.fail_on_unknown_type; log_err_warn(ctx, diff --git a/tests/expectations/elaborated.rs b/tests/expectations/elaborated.rs new file mode 100644 index 0000000000..366c6882ce --- /dev/null +++ b/tests/expectations/elaborated.rs @@ -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); +} diff --git a/tests/headers/elaborated.hpp b/tests/headers/elaborated.hpp new file mode 100644 index 0000000000..4bfbff23dd --- /dev/null +++ b/tests/headers/elaborated.hpp @@ -0,0 +1,5 @@ +namespace whatever { + typedef int whatever_t; +} + +void something(const whatever::whatever_t *wat);