core: rename box to managed. Close #4079.

This commit is contained in:
Graydon Hoare 2012-12-03 17:45:19 -08:00
parent 2a5713ed5c
commit 94be145169
8 changed files with 27 additions and 25 deletions

View File

@ -19,12 +19,12 @@ used features.
`core` includes modules corresponding to each of the integer types, each of
the floating point types, the `bool` type, tuples, characters, strings,
vectors (`vec`), shared boxes (`box`), and unsafe and borrowed pointers
(`ptr`). Additionally, `core` provides task management and creation (`task`),
communication primitives (`comm` and `pipes`), an efficient vector builder
(`dvec`), platform abstractions (`os` and `path`), basic I/O abstractions
(`io`), common traits (`cmp`, `num`, `to_str`), and complete bindings
to the C standard library (`libc`).
vectors (`vec`), managed boxes (`managed`), owned boxes (`owned`), and unsafe
and borrowed pointers (`ptr`). Additionally, `core` provides task management
and creation (`task`), communication primitives (`comm` and `pipes`), an
efficient vector builder (`dvec`), platform abstractions (`os` and `path`),
basic I/O abstractions (`io`), common traits (`cmp`, `num`, `to_str`), and
complete bindings to the C standard library (`libc`).
`core` is linked to all crates by default and its contents imported.
Implicitly, all crates behave as if they included the following prologue:
@ -92,7 +92,7 @@ pub mod at_vec;
pub mod str;
pub mod ptr;
pub mod box; // FIXME #4079 Rename to 'managed' to match 'owned'
pub mod managed;
pub mod owned;

View File

@ -43,7 +43,7 @@ priv impl<T> DListNode<T> {
pure fn assert_links() {
match self.next {
Some(neighbour) => match neighbour.prev {
Some(me) => if !box::ptr_eq(*self, *me) {
Some(me) => if !managed::ptr_eq(*self, *me) {
fail ~"Asymmetric next-link in dlist node."
},
None => fail ~"One-way next-link in dlist node."
@ -52,7 +52,7 @@ priv impl<T> DListNode<T> {
}
match self.prev {
Some(neighbour) => match neighbour.next {
Some(me) => if !box::ptr_eq(*me, *self) {
Some(me) => if !managed::ptr_eq(*me, *self) {
fail ~"Asymmetric prev-link in dlist node."
},
None => fail ~"One-way prev-link in dlist node."
@ -137,9 +137,11 @@ priv impl<T> DList<T> {
}
if !nobe.linked { fail ~"That node isn't linked to any dlist." }
if !((nobe.prev.is_some()
|| box::ptr_eq(*self.hd.expect(~"headless dlist?"), *nobe)) &&
|| managed::ptr_eq(*self.hd.expect(~"headless dlist?"),
*nobe)) &&
(nobe.next.is_some()
|| box::ptr_eq(*self.tl.expect(~"tailless dlist?"), *nobe))) {
|| managed::ptr_eq(*self.tl.expect(~"tailless dlist?"),
*nobe))) {
fail ~"That node isn't on this dlist."
}
}
@ -322,7 +324,7 @@ impl<T> DList<T> {
* to the other list's head. O(1).
*/
fn append(them: DList<T>) {
if box::ptr_eq(*self, *them) {
if managed::ptr_eq(*self, *them) {
fail ~"Cannot append a dlist to itself!"
}
if them.len() > 0 {
@ -339,7 +341,7 @@ impl<T> DList<T> {
* list's tail to this list's head. O(1).
*/
fn prepend(them: DList<T>) {
if box::ptr_eq(*self, *them) {
if managed::ptr_eq(*self, *them) {
fail ~"Cannot prepend a dlist to itself!"
}
if them.len() > 0 {
@ -405,7 +407,7 @@ impl<T> DList<T> {
rabbit = option::get(rabbit).next;
}
if option::is_some(&rabbit) {
assert !box::ptr_eq(*option::get(rabbit), *nobe);
assert !managed::ptr_eq(*option::get(rabbit), *nobe);
}
// advance
link = nobe.next_link();
@ -426,7 +428,7 @@ impl<T> DList<T> {
rabbit = option::get(rabbit).prev;
}
if option::is_some(&rabbit) {
assert !box::ptr_eq(*option::get(rabbit), *nobe);
assert !managed::ptr_eq(*option::get(rabbit), *nobe);
}
// advance
link = nobe.prev_link();

View File

@ -31,10 +31,10 @@ mod inst {
}
if !nobe.linked ||
(!((nobe.prev.is_some()
|| box::ptr_eq(*self.hd.expect(~"headless dlist?"),
|| managed::ptr_eq(*self.hd.expect(~"headless dlist?"),
*nobe))
&& (nobe.next.is_some()
|| box::ptr_eq(*self.tl.expect(~"tailless dlist?"),
|| managed::ptr_eq(*self.tl.expect(~"tailless dlist?"),
*nobe)))) {
fail ~"Removing a dlist node during iteration is forbidden!"
}

View File

@ -27,8 +27,8 @@ use intrinsic::{TyDesc, TyVisitor, visit_tydesc};
use reflect::{MovePtr, MovePtrAdaptor};
use vec::UnboxedVecRepr;
use vec::raw::{VecRepr, SliceRepr};
pub use box::raw::BoxRepr;
use box::raw::BoxHeaderRepr;
pub use managed::raw::BoxRepr;
use managed::raw::BoxHeaderRepr;
/// Helpers
@ -279,7 +279,7 @@ impl ReprVisitor : TyVisitor {
fn visit_box(mtbl: uint, inner: *TyDesc) -> bool {
self.writer.write_char('@');
self.write_mut_qualifier(mtbl);
do self.get::<&box::raw::BoxRepr> |b| {
do self.get::<&managed::raw::BoxRepr> |b| {
let p = ptr::to_unsafe_ptr(&b.data) as *c_void;
self.visit_ptr_inner(p, inner);
}
@ -288,7 +288,7 @@ impl ReprVisitor : TyVisitor {
fn visit_uniq(mtbl: uint, inner: *TyDesc) -> bool {
self.writer.write_char('~');
self.write_mut_qualifier(mtbl);
do self.get::<&box::raw::BoxRepr> |b| {
do self.get::<&managed::raw::BoxRepr> |b| {
let p = ptr::to_unsafe_ptr(&b.data) as *c_void;
self.visit_ptr_inner(p, inner);
}
@ -446,7 +446,7 @@ impl ReprVisitor : TyVisitor {
fn visit_opaque_box() -> bool {
self.writer.write_char('@');
do self.get::<&box::raw::BoxRepr> |b| {
do self.get::<&managed::raw::BoxRepr> |b| {
let p = ptr::to_unsafe_ptr(&b.data) as *c_void;
self.visit_ptr_inner(p, b.header.type_desc);
}

View File

@ -1763,7 +1763,7 @@ mod raw {
/// The internal representation of a (boxed) vector
pub struct VecRepr {
box_header: box::raw::BoxHeaderRepr,
box_header: managed::raw::BoxHeaderRepr,
unboxed: UnboxedVecRepr
}

View File

@ -63,7 +63,7 @@ use syntax::visit::{visit_crate, visit_expr, visit_expr_opt, visit_fn};
use syntax::visit::{visit_foreign_item, visit_item, visit_method_helper};
use syntax::visit::{visit_mod, visit_ty, vt};
use box::ptr_eq;
use managed::ptr_eq;
use dvec::DVec;
use option::{Some, get, is_some, is_none};
use str::{connect, split_str};

View File

@ -476,7 +476,7 @@ fn p_t_s_rec(cx: ext_ctxt, m: matchable, s: selector, b: binders) {
match_result {
return match m {
match_expr(e) => {
if box::ptr_eq(e, pat) {
if managed::ptr_eq(e, pat) {
// XXX: Is this right?
Some(leaf(match_exact))
} else {