summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/codegen/mod.rs5
-rw-r--r--src/ir/ty.rs14
-rw-r--r--tests/expectations/blocks.rs2
3 files changed, 17 insertions, 4 deletions
diff --git a/src/codegen/mod.rs b/src/codegen/mod.rs
index 7de416a8..36f20689 100644
--- a/src/codegen/mod.rs
+++ b/src/codegen/mod.rs
@@ -311,6 +311,7 @@ impl CodeGenerator for Type {
TypeKind::Float(..) |
TypeKind::Array(..) |
TypeKind::Pointer(..) |
+ TypeKind::BlockPointer |
TypeKind::Reference(..) |
TypeKind::TemplateRef(..) |
TypeKind::Function(..) |
@@ -1382,6 +1383,10 @@ impl ToRustTy for Type {
utils::build_templated_path(item, ctx, false)
}
+ TypeKind::BlockPointer => {
+ let void = raw!(c_void);
+ void.to_ptr(/* is_const = */ false, ctx.span())
+ }
TypeKind::Pointer(inner) |
TypeKind::Reference(inner) => {
let inner = ctx.resolve_item(inner);
diff --git a/src/ir/ty.rs b/src/ir/ty.rs
index b0bf9bf6..97cdf925 100644
--- a/src/ir/ty.rs
+++ b/src/ir/ty.rs
@@ -90,6 +90,7 @@ impl Type {
TypeKind::Array(..) |
TypeKind::Reference(..) |
TypeKind::Pointer(..) |
+ TypeKind::BlockPointer |
TypeKind::Int(..) |
TypeKind::Float(..) |
TypeKind::Named(..) => true,
@@ -124,8 +125,9 @@ impl Type {
TypeKind::Comp(ref ci)
=> ci.layout(type_resolver),
// FIXME(emilio): This is a hack for anonymous union templates.
- // Use the actual pointer size!
- TypeKind::Pointer(..)
+ // Use the actual pointer size!
+ TypeKind::Pointer(..) |
+ TypeKind::BlockPointer
=> Some(Layout::new(mem::size_of::<*mut ()>(), mem::align_of::<*mut ()>())),
TypeKind::ResolvedTypeRef(inner)
=> type_resolver.resolve_type(inner).layout(type_resolver),
@@ -286,6 +288,7 @@ impl Type {
TypeKind::Reference(..) |
TypeKind::Void |
TypeKind::NullPtr |
+ TypeKind::BlockPointer |
TypeKind::Pointer(..) => self,
TypeKind::ResolvedTypeRef(inner) |
@@ -334,6 +337,8 @@ pub enum TypeKind {
/// A pointer to a type. The bool field represents whether it's const or
/// not.
Pointer(ItemId),
+ /// A pointer to an Apple block.
+ BlockPointer,
/// A reference to a type, as in: int& foo().
Reference(ItemId),
/// A reference to a template, with different template parameter names. To
@@ -376,6 +381,7 @@ impl Type {
TypeKind::Enum(..) |
TypeKind::Reference(..) |
TypeKind::NullPtr |
+ TypeKind::BlockPointer |
TypeKind::Pointer(..) => false,
TypeKind::UnresolvedTypeRef(..)
@@ -485,13 +491,15 @@ impl Type {
// We might need to, though, if the context is already in the
// process of resolving them.
CXType_MemberPointer |
- CXType_BlockPointer |
CXType_Pointer => {
let inner =
Item::from_ty_or_ref(ty.pointee_type(), location,
parent_id, ctx);
TypeKind::Pointer(inner)
}
+ CXType_BlockPointer => {
+ TypeKind::BlockPointer
+ }
// XXX: RValueReference is most likely wrong, but I don't think we
// can even add bindings for that, so huh.
CXType_RValueReference |
diff --git a/tests/expectations/blocks.rs b/tests/expectations/blocks.rs
index 88a797e2..528ea518 100644
--- a/tests/expectations/blocks.rs
+++ b/tests/expectations/blocks.rs
@@ -5,5 +5,5 @@
extern "C" {
- pub fn atexit_b(arg1: ::std::option::Option<unsafe extern "C" fn()>);
+ pub fn atexit_b(arg1: *mut ::std::os::raw::c_void);
}