Support raw pointers in cxx::bridge.
This allows raw pointers to types to be passed into and out of
cxx::bridge extern "C++" APIs. As normal with raw pointers in Rust,
there are no safety or lifetime guarantees.
Passing a raw pointer into such an API requires that the
function be marked "unsafe".
diff --git a/gen/src/write.rs b/gen/src/write.rs
index a2ce630..b3911c1 100644
--- a/gen/src/write.rs
+++ b/gen/src/write.rs
@@ -222,7 +222,7 @@
Type::Fn(_) => out.builtin.rust_fn = true,
Type::SliceRef(_) => out.builtin.rust_slice = true,
Type::Array(_) => out.include.array = true,
- Type::Ref(_) | Type::Void(_) => {}
+ Type::Ref(_) | Type::Void(_) | Type::Ptr(_) => {}
}
}
}
@@ -1179,6 +1179,13 @@
write_type(out, &r.inner);
write!(out, " &");
}
+ Type::Ptr(p) => {
+ if !p.mutable {
+ write!(out, "const ");
+ }
+ write_type(out, &p.inner);
+ write!(out, " *");
+ }
Type::Str(_) => {
write!(out, "::rust::Str");
}
@@ -1253,7 +1260,7 @@
| Type::SliceRef(_)
| Type::Fn(_)
| Type::Array(_) => write!(out, " "),
- Type::Ref(_) => {}
+ Type::Ref(_) | Type::Ptr(_) => {}
Type::Void(_) => unreachable!(),
}
}