Convert more core types to camel case

This commit is contained in:
Brian Anderson
2012-08-14 16:54:13 -07:00
parent 8be0f665bc
commit 74c69e1053
67 changed files with 457 additions and 427 deletions

View File

@@ -86,21 +86,21 @@ export as_const_buf;
export unsafe;
export u8;
export extensions;
export const_vector;
export copyable_vector;
export immutable_vector;
export immutable_copyable_vector;
export iter_trait_extensions;
export ConstVector;
export CopyableVector;
export ImmutableVector;
export ImmutableCopyableVector;
export IterTraitExtensions;
export vec_concat;
#[abi = "cdecl"]
extern mod rustrt {
fn vec_reserve_shared(++t: *sys::TypeDesc,
++v: **unsafe::vec_repr,
++v: **unsafe::VecRepr,
++n: libc::size_t);
fn vec_from_buf_shared(++t: *sys::TypeDesc,
++ptr: *(),
++count: libc::size_t) -> *unsafe::vec_repr;
++count: libc::size_t) -> *unsafe::VecRepr;
}
#[abi = "rust-intrinsic"]
@@ -109,7 +109,7 @@ extern mod rusti {
}
/// A function used to initialize the elements of a vector
type init_op/&<T> = fn(uint) -> T;
type InitOp/&<T> = fn(uint) -> T;
/// Returns true if a vector contains no elements
pure fn is_empty<T>(v: &[const T]) -> bool {
@@ -140,7 +140,7 @@ pure fn same_length<T, U>(xs: &[const T], ys: &[const U]) -> bool {
fn reserve<T>(&v: ~[const T], n: uint) {
// Only make the (slow) call into the runtime if we have to
if capacity(v) < n {
let ptr = ptr::addr_of(v) as **unsafe::vec_repr;
let ptr = ptr::addr_of(v) as **unsafe::VecRepr;
rustrt::vec_reserve_shared(sys::get_type_desc::<T>(),
ptr, n as size_t);
}
@@ -169,7 +169,7 @@ fn reserve_at_least<T>(&v: ~[const T], n: uint) {
#[inline(always)]
pure fn capacity<T>(&&v: ~[const T]) -> uint {
unsafe {
let repr: **unsafe::vec_repr = ::unsafe::reinterpret_cast(addr_of(v));
let repr: **unsafe::VecRepr = ::unsafe::reinterpret_cast(addr_of(v));
(**repr).alloc / sys::size_of::<T>()
}
}
@@ -186,7 +186,7 @@ pure fn len<T>(&&v: &[const T]) -> uint {
* Creates an immutable vector of size `n_elts` and initializes the elements
* to the value returned by the function `op`.
*/
pure fn from_fn<T>(n_elts: uint, op: init_op<T>) -> ~[T] {
pure fn from_fn<T>(n_elts: uint, op: InitOp<T>) -> ~[T] {
let mut v = ~[];
unchecked{reserve(v, n_elts);}
let mut i: uint = 0u;
@@ -523,7 +523,7 @@ fn pop<T>(&v: ~[const T]) -> T {
#[inline(always)]
fn push<T>(&v: ~[const T], +initval: T) {
unsafe {
let repr: **unsafe::vec_repr = ::unsafe::reinterpret_cast(addr_of(v));
let repr: **unsafe::VecRepr = ::unsafe::reinterpret_cast(addr_of(v));
let fill = (**repr).fill;
if (**repr).alloc > fill {
push_fast(v, initval);
@@ -537,7 +537,7 @@ fn push<T>(&v: ~[const T], +initval: T) {
// This doesn't bother to make sure we have space.
#[inline(always)] // really pretty please
unsafe fn push_fast<T>(&v: ~[const T], +initval: T) {
let repr: **unsafe::vec_repr = ::unsafe::reinterpret_cast(addr_of(v));
let repr: **unsafe::VecRepr = ::unsafe::reinterpret_cast(addr_of(v));
let fill = (**repr).fill;
(**repr).fill += sys::size_of::<T>();
let p = ptr::addr_of((**repr).data);
@@ -640,7 +640,7 @@ fn grow<T: copy>(&v: ~[const T], n: uint, initval: T) {
* * init_op - A function to call to retreive each appended element's
* value
*/
fn grow_fn<T>(&v: ~[const T], n: uint, op: init_op<T>) {
fn grow_fn<T>(&v: ~[const T], n: uint, op: InitOp<T>) {
reserve_at_least(v, len(v) + n);
let mut i: uint = 0u;
while i < n { push(v, op(i)); i += 1u; }
@@ -1304,14 +1304,14 @@ impl<T: copy> ~[mut T]: add<&[const T],~[mut T]> {
}
}
trait const_vector {
trait ConstVector {
pure fn is_empty() -> bool;
pure fn is_not_empty() -> bool;
pure fn len() -> uint;
}
/// Extension methods for vectors
impl<T> &[const T]: const_vector {
impl<T> &[const T]: ConstVector {
/// Returns true if a vector contains no elements
#[inline]
pure fn is_empty() -> bool { is_empty(self) }
@@ -1323,7 +1323,7 @@ impl<T> &[const T]: const_vector {
pure fn len() -> uint { len(self) }
}
trait copyable_vector<T> {
trait CopyableVector<T> {
pure fn head() -> T;
pure fn init() -> ~[T];
pure fn last() -> T;
@@ -1332,7 +1332,7 @@ trait copyable_vector<T> {
}
/// Extension methods for vectors
impl<T: copy> &[const T]: copyable_vector<T> {
impl<T: copy> &[const T]: CopyableVector<T> {
/// Returns the first element of a vector
#[inline]
pure fn head() -> T { head(self) }
@@ -1350,7 +1350,7 @@ impl<T: copy> &[const T]: copyable_vector<T> {
pure fn tail() -> ~[T] { tail(self) }
}
trait immutable_vector<T> {
trait ImmutableVector<T> {
pure fn foldr<U: copy>(z: U, p: fn(T, U) -> U) -> U;
pure fn iter(f: fn(T));
pure fn iteri(f: fn(uint, T));
@@ -1369,7 +1369,7 @@ trait immutable_vector<T> {
}
/// Extension methods for vectors
impl<T> &[T]: immutable_vector<T> {
impl<T> &[T]: ImmutableVector<T> {
/// Reduce a vector from right to left
#[inline]
pure fn foldr<U: copy>(z: U, p: fn(T, U) -> U) -> U { foldr(self, z, p) }
@@ -1477,14 +1477,14 @@ impl<T> &[T]: immutable_vector<T> {
}
}
trait immutable_copyable_vector<T> {
trait ImmutableCopyableVector<T> {
pure fn filter(f: fn(T) -> bool) -> ~[T];
pure fn find(f: fn(T) -> bool) -> option<T>;
pure fn rfind(f: fn(T) -> bool) -> option<T>;
}
/// Extension methods for vectors
impl<T: copy> &[T]: immutable_copyable_vector<T> {
impl<T: copy> &[T]: ImmutableCopyableVector<T> {
/**
* Construct a new vector from the elements of a vector for which some
* predicate holds.
@@ -1518,14 +1518,14 @@ impl<T: copy> &[T]: immutable_copyable_vector<T> {
mod unsafe {
// FIXME: This should have crate visibility (#1893 blocks that)
/// The internal representation of a vector
type vec_repr = {
type VecRepr = {
box_header: (uint, uint, uint, uint),
mut fill: uint,
mut alloc: uint,
data: u8
};
type slice_repr = {
type SliceRepr = {
mut data: *u8,
mut len: uint
};
@@ -1555,7 +1555,7 @@ mod unsafe {
*/
#[inline(always)]
unsafe fn set_len<T>(&&v: ~[const T], new_len: uint) {
let repr: **vec_repr = ::unsafe::reinterpret_cast(addr_of(v));
let repr: **VecRepr = ::unsafe::reinterpret_cast(addr_of(v));
(**repr).fill = new_len * sys::size_of::<T>();
}
@@ -1570,14 +1570,14 @@ mod unsafe {
*/
#[inline(always)]
unsafe fn to_ptr<T>(v: ~[const T]) -> *T {
let repr: **vec_repr = ::unsafe::reinterpret_cast(addr_of(v));
let repr: **VecRepr = ::unsafe::reinterpret_cast(addr_of(v));
return ::unsafe::reinterpret_cast(addr_of((**repr).data));
}
#[inline(always)]
unsafe fn to_ptr_slice<T>(v: &[const T]) -> *T {
let repr: **slice_repr = ::unsafe::reinterpret_cast(addr_of(v));
let repr: **SliceRepr = ::unsafe::reinterpret_cast(addr_of(v));
return ::unsafe::reinterpret_cast(addr_of((**repr).data));
}
@@ -1729,12 +1729,12 @@ mod u8 {
// This cannot be used with iter-trait.rs because of the region pointer
// required in the slice.
impl<A> &[A]: iter::base_iter<A> {
impl<A> &[A]: iter::BaseIter<A> {
fn each(blk: fn(A) -> bool) { each(self, blk) }
fn size_hint() -> option<uint> { some(len(self)) }
}
impl<A> &[A]: iter::extended_iter<A> {
impl<A> &[A]: iter::ExtendedIter<A> {
fn eachi(blk: fn(uint, A) -> bool) { iter::eachi(self, blk) }
fn all(blk: fn(A) -> bool) -> bool { iter::all(self, blk) }
fn any(blk: fn(A) -> bool) -> bool { iter::any(self, blk) }
@@ -1746,7 +1746,7 @@ impl<A> &[A]: iter::extended_iter<A> {
fn position(f: fn(A) -> bool) -> option<uint> { iter::position(self, f) }
}
trait iter_trait_extensions<A> {
trait IterTraitExtensions<A> {
fn filter_to_vec(pred: fn(A) -> bool) -> ~[A];
fn map_to_vec<B>(op: fn(A) -> B) -> ~[B];
fn to_vec() -> ~[A];
@@ -1754,7 +1754,7 @@ trait iter_trait_extensions<A> {
fn max() -> A;
}
impl<A: copy> &[A]: iter_trait_extensions<A> {
impl<A: copy> &[A]: IterTraitExtensions<A> {
fn filter_to_vec(pred: fn(A) -> bool) -> ~[A] {
iter::filter_to_vec(self, pred)
}