From 6fe59bf8776f8913aacfb00a2281c94a117b95d1 Mon Sep 17 00:00:00 2001 From: Niko Matsakis Date: Sun, 11 Aug 2013 13:29:14 -0400 Subject: Add a field `borrow_offset` to the type descriptor indicating what amount a T* pointer must be adjusted to reach the contents of the box. For `~T` types, this requires knowing the type `T`, which is not known in the case of objects. --- src/libstd/unstable/intrinsics.rs | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) (limited to 'src/libstd') diff --git a/src/libstd/unstable/intrinsics.rs b/src/libstd/unstable/intrinsics.rs index c60edad3dbd..d2807303fb2 100644 --- a/src/libstd/unstable/intrinsics.rs +++ b/src/libstd/unstable/intrinsics.rs @@ -38,16 +38,34 @@ pub use realstd::unstable::intrinsics::{TyDesc, Opaque, TyVisitor}; pub type GlueFn = extern "Rust" fn(*i8); -// NB: this has to be kept in sync with the Rust ABI. +// NB: this has to be kept in sync with `type_desc` in `rt` #[lang="ty_desc"] #[cfg(not(test))] pub struct TyDesc { + // sizeof(T) size: uint, + + // alignof(T) align: uint, + + // Called on a copy of a value of type `T` *after* memcpy take_glue: GlueFn, + + // Called when a value of type `T` is no longer needed drop_glue: GlueFn, + + // Called by drop glue when a value of type `T` can be freed free_glue: GlueFn, + + // Called by reflection visitor to visit a value of type `T` visit_glue: GlueFn, + + // If T represents a box pointer (`@U` or `~U`), then + // `borrow_offset` is the amount that the pointer must be adjusted + // to find the payload. This is always derivable from the type + // `U`, but in the case of `@Trait` or `~Trait` objects, the type + // `U` is unknown. + borrow_offset: uint, } #[lang="opaque"] -- cgit 1.4.1-3-g733a5