Skip to content

Add support for elaborated types. #3

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

Closed
wants to merge 1 commit into from
Closed
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
9 changes: 9 additions & 0 deletions src/clang.rs
Original file line number Diff line number Diff line change
Expand Up @@ -446,6 +446,12 @@ impl Type {
clang_getFunctionTypeCallingConv(self.x)
}
}

pub fn named(&self) -> Type {
unsafe {
Type { x: clang_Type_getNamedType(self.x) }
}
}
}

// SourceLocation
Expand Down Expand Up @@ -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",
_ => "?"
}
}
Expand Down
3 changes: 3 additions & 0 deletions src/clangll.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions src/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
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);