auto merge of #5277 : bstrie/rust/deimpselfstd, r=brson

This commit is contained in:
bors 2013-03-07 19:51:36 -08:00
commit 88f0a10578
14 changed files with 128 additions and 127 deletions

View File

@ -335,7 +335,7 @@ pub impl<T:Const + Owned> RWARC<T> {
* Failing will unlock the ARC while unwinding. However, unlike all other
* access modes, this will not poison the ARC.
*/
fn read<U>(blk: fn(x: &T) -> U) -> U {
fn read<U>(&self, blk: fn(x: &T) -> U) -> U {
let state = unsafe { get_shared_immutable_state(&self.x) };
do (&state.lock).read {
check_poison(false, state.failed);
@ -360,7 +360,7 @@ pub impl<T:Const + Owned> RWARC<T> {
* }
* ~~~
*/
fn write_downgrade<U>(blk: fn(v: RWWriteMode<T>) -> U) -> U {
fn write_downgrade<U>(&self, blk: fn(v: RWWriteMode<T>) -> U) -> U {
unsafe {
let state = get_shared_mutable_state(&self.x);
do (*borrow_rwlock(state)).write_downgrade |write_mode| {
@ -373,7 +373,7 @@ pub impl<T:Const + Owned> RWARC<T> {
}
/// To be called inside of the write_downgrade block.
fn downgrade(token: RWWriteMode/&a<T>) -> RWReadMode/&a<T> {
fn downgrade(&self, token: RWWriteMode/&a<T>) -> RWReadMode/&a<T> {
// The rwlock should assert that the token belongs to us for us.
let state = unsafe { get_shared_immutable_state(&self.x) };
let RWWriteMode((data, t, _poison)) = token;

View File

@ -13,11 +13,11 @@ use core::str;
use core::vec;
pub trait ToBase64 {
pure fn to_base64() -> ~str;
pure fn to_base64(&self) -> ~str;
}
impl ToBase64 for &self/[u8] {
pure fn to_base64() -> ~str {
pure fn to_base64(&self) -> ~str {
let chars = str::chars(
~"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"
);
@ -70,17 +70,17 @@ impl ToBase64 for &self/[u8] {
}
impl ToBase64 for &self/str {
pure fn to_base64() -> ~str {
str::to_bytes(self).to_base64()
pure fn to_base64(&self) -> ~str {
str::to_bytes(*self).to_base64()
}
}
pub trait FromBase64 {
pure fn from_base64() -> ~[u8];
pure fn from_base64(&self) -> ~[u8];
}
impl FromBase64 for ~[u8] {
pure fn from_base64() -> ~[u8] {
pure fn from_base64(&self) -> ~[u8] {
if self.len() % 4u != 0u { fail!(~"invalid base64 length"); }
let len = self.len();
@ -142,8 +142,8 @@ impl FromBase64 for ~[u8] {
}
impl FromBase64 for ~str {
pure fn from_base64() -> ~[u8] {
str::to_bytes(self).from_base64()
pure fn from_base64(&self) -> ~[u8] {
str::to_bytes(*self).from_base64()
}
}

View File

@ -29,19 +29,19 @@ pub struct DuplexStream<T, U> {
#[cfg(stage1)]
#[cfg(stage2)]
pub impl<T:Owned,U:Owned> DuplexStream<T, U> {
fn send(x: T) {
fn send(&self, x: T) {
self.chan.send(x)
}
fn try_send(x: T) -> bool {
fn try_send(&self, x: T) -> bool {
self.chan.try_send(x)
}
fn recv() -> U {
fn recv(&self, ) -> U {
self.port.recv()
}
fn try_recv() -> Option<U> {
fn try_recv(&self) -> Option<U> {
self.port.try_recv()
}
pure fn peek() -> bool {
pure fn peek(&self) -> bool {
self.port.peek()
}
}

View File

@ -217,7 +217,7 @@ pub mod reader {
}
priv impl Decoder {
fn _check_label(lbl: &str) {
fn _check_label(&self, lbl: &str) {
if self.pos < self.parent.end {
let TaggedDoc { tag: r_tag, doc: r_doc } =
doc_at(self.parent.data, self.pos);
@ -233,7 +233,7 @@ pub mod reader {
}
}
fn next_doc(exp_tag: EbmlEncoderTag) -> Doc {
fn next_doc(&self, exp_tag: EbmlEncoderTag) -> Doc {
debug!(". next_doc(exp_tag=%?)", exp_tag);
if self.pos >= self.parent.end {
fail!(~"no more documents in current node!");
@ -255,7 +255,7 @@ pub mod reader {
r_doc
}
fn push_doc<T>(d: Doc, f: fn() -> T) -> T {
fn push_doc<T>(&self, d: Doc, f: fn() -> T) -> T {
let old_parent = self.parent;
let old_pos = self.pos;
self.parent = d;
@ -266,7 +266,7 @@ pub mod reader {
r
}
fn _next_uint(exp_tag: EbmlEncoderTag) -> uint {
fn _next_uint(&self, exp_tag: EbmlEncoderTag) -> uint {
let r = doc_as_u32(self.next_doc(exp_tag));
debug!("_next_uint exp_tag=%? result=%?", exp_tag, r);
r as uint
@ -446,7 +446,7 @@ pub mod writer {
// FIXME (#2741): Provide a function to write the standard ebml header.
pub impl Encoder {
fn start_tag(tag_id: uint) {
fn start_tag(&self, tag_id: uint) {
debug!("Start tag %u", tag_id);
// Write the enum ID:
@ -458,7 +458,7 @@ pub mod writer {
self.writer.write(zeroes);
}
fn end_tag() {
fn end_tag(&self) {
let last_size_pos = self.size_positions.pop();
let cur_pos = self.writer.tell();
self.writer.seek(last_size_pos as int, io::SeekSet);
@ -469,72 +469,72 @@ pub mod writer {
debug!("End tag (size = %u)", size);
}
fn wr_tag(tag_id: uint, blk: fn()) {
fn wr_tag(&self, tag_id: uint, blk: fn()) {
self.start_tag(tag_id);
blk();
self.end_tag();
}
fn wr_tagged_bytes(tag_id: uint, b: &[u8]) {
fn wr_tagged_bytes(&self, tag_id: uint, b: &[u8]) {
write_vuint(self.writer, tag_id);
write_vuint(self.writer, vec::len(b));
self.writer.write(b);
}
fn wr_tagged_u64(tag_id: uint, v: u64) {
fn wr_tagged_u64(&self, tag_id: uint, v: u64) {
do io::u64_to_be_bytes(v, 8u) |v| {
self.wr_tagged_bytes(tag_id, v);
}
}
fn wr_tagged_u32(tag_id: uint, v: u32) {
fn wr_tagged_u32(&self, tag_id: uint, v: u32) {
do io::u64_to_be_bytes(v as u64, 4u) |v| {
self.wr_tagged_bytes(tag_id, v);
}
}
fn wr_tagged_u16(tag_id: uint, v: u16) {
fn wr_tagged_u16(&self, tag_id: uint, v: u16) {
do io::u64_to_be_bytes(v as u64, 2u) |v| {
self.wr_tagged_bytes(tag_id, v);
}
}
fn wr_tagged_u8(tag_id: uint, v: u8) {
fn wr_tagged_u8(&self, tag_id: uint, v: u8) {
self.wr_tagged_bytes(tag_id, &[v]);
}
fn wr_tagged_i64(tag_id: uint, v: i64) {
fn wr_tagged_i64(&self, tag_id: uint, v: i64) {
do io::u64_to_be_bytes(v as u64, 8u) |v| {
self.wr_tagged_bytes(tag_id, v);
}
}
fn wr_tagged_i32(tag_id: uint, v: i32) {
fn wr_tagged_i32(&self, tag_id: uint, v: i32) {
do io::u64_to_be_bytes(v as u64, 4u) |v| {
self.wr_tagged_bytes(tag_id, v);
}
}
fn wr_tagged_i16(tag_id: uint, v: i16) {
fn wr_tagged_i16(&self, tag_id: uint, v: i16) {
do io::u64_to_be_bytes(v as u64, 2u) |v| {
self.wr_tagged_bytes(tag_id, v);
}
}
fn wr_tagged_i8(tag_id: uint, v: i8) {
fn wr_tagged_i8(&self, tag_id: uint, v: i8) {
self.wr_tagged_bytes(tag_id, &[v as u8]);
}
fn wr_tagged_str(tag_id: uint, v: &str) {
fn wr_tagged_str(&self, tag_id: uint, v: &str) {
str::byte_slice(v, |b| self.wr_tagged_bytes(tag_id, b));
}
fn wr_bytes(b: &[u8]) {
fn wr_bytes(&self, b: &[u8]) {
debug!("Write %u bytes", vec::len(b));
self.writer.write(b);
}
fn wr_str(s: &str) {
fn wr_str(&self, s: &str) {
debug!("Write str: %?", s);
self.writer.write(str::to_bytes(s));
}
@ -549,12 +549,12 @@ pub mod writer {
priv impl Encoder {
// used internally to emit things like the vector length and so on
fn _emit_tagged_uint(t: EbmlEncoderTag, v: uint) {
fn _emit_tagged_uint(&self, t: EbmlEncoderTag, v: uint) {
assert v <= 0xFFFF_FFFF_u;
self.wr_tagged_u32(t as uint, v as u32);
}
fn _emit_label(label: &str) {
fn _emit_label(&self, label: &str) {
// There are various strings that we have access to, such as
// the name of a record field, which do not actually appear in
// the encoded EBML (normally). This is just for

View File

@ -47,7 +47,7 @@ priv enum FutureState<A> {
/// Methods on the `future` type
pub impl<A:Copy> Future<A> {
fn get() -> A {
fn get(&self) -> A {
//! Get the value of the future
*(self.get_ref())
}

View File

@ -24,7 +24,7 @@ pub impl BufReader {
}
}
priv fn as_bytes_reader<A>(f: &fn(&BytesReader) -> A) -> A {
priv fn as_bytes_reader<A>(&self, f: &fn(&BytesReader) -> A) -> A {
// Recreating the BytesReader state every call since
// I can't get the borrowing to work correctly
let bytes_reader = BytesReader {

View File

@ -387,7 +387,7 @@ pub fn Parser(rdr: io::Reader) -> Parser {
}
pub impl Parser {
fn parse() -> Result<Json, Error> {
fn parse(&self) -> Result<Json, Error> {
match self.parse_value() {
Ok(value) => {
// Skip trailing whitespaces.
@ -405,9 +405,9 @@ pub impl Parser {
}
priv impl Parser {
fn eof() -> bool { self.ch == -1 as char }
fn eof(&self) -> bool { self.ch == -1 as char }
fn bump() {
fn bump(&self) {
self.ch = self.rdr.read_char();
if self.ch == '\n' {
@ -418,16 +418,16 @@ priv impl Parser {
}
}
fn next_char() -> char {
fn next_char(&self) -> char {
self.bump();
self.ch
}
fn error<T>(msg: ~str) -> Result<T, Error> {
fn error<T>(&self, msg: ~str) -> Result<T, Error> {
Err(Error { line: self.line, col: self.col, msg: @msg })
}
fn parse_value() -> Result<Json, Error> {
fn parse_value(&self) -> Result<Json, Error> {
self.parse_whitespace();
if self.eof() { return self.error(~"EOF while parsing value"); }
@ -448,11 +448,11 @@ priv impl Parser {
}
}
fn parse_whitespace() {
fn parse_whitespace(&self) {
while char::is_whitespace(self.ch) { self.bump(); }
}
fn parse_ident(ident: &str, value: Json) -> Result<Json, Error> {
fn parse_ident(&self, ident: &str, value: Json) -> Result<Json, Error> {
if str::all(ident, |c| c == self.next_char()) {
self.bump();
Ok(value)
@ -461,7 +461,7 @@ priv impl Parser {
}
}
fn parse_number() -> Result<Json, Error> {
fn parse_number(&self) -> Result<Json, Error> {
let mut neg = 1f;
if self.ch == '-' {
@ -491,7 +491,7 @@ priv impl Parser {
Ok(Number(neg * res))
}
fn parse_integer() -> Result<float, Error> {
fn parse_integer(&self) -> Result<float, Error> {
let mut res = 0f;
match self.ch {
@ -523,7 +523,7 @@ priv impl Parser {
Ok(res)
}
fn parse_decimal(res: float) -> Result<float, Error> {
fn parse_decimal(&self, res: float) -> Result<float, Error> {
self.bump();
// Make sure a digit follows the decimal place.
@ -549,7 +549,7 @@ priv impl Parser {
Ok(res)
}
fn parse_exponent(res: float) -> Result<float, Error> {
fn parse_exponent(&self, res: float) -> Result<float, Error> {
self.bump();
let mut res = res;
@ -590,7 +590,7 @@ priv impl Parser {
Ok(res)
}
fn parse_str() -> Result<~str, Error> {
fn parse_str(&self) -> Result<~str, Error> {
let mut escape = false;
let mut res = ~"";
@ -654,7 +654,7 @@ priv impl Parser {
self.error(~"EOF while parsing string")
}
fn parse_list() -> Result<Json, Error> {
fn parse_list(&self) -> Result<Json, Error> {
self.bump();
self.parse_whitespace();
@ -684,7 +684,7 @@ priv impl Parser {
};
}
fn parse_object() -> Result<Json, Error> {
fn parse_object(&self) -> Result<Json, Error> {
self.bump();
self.parse_whitespace();
@ -1072,87 +1072,87 @@ impl Eq for Error {
pure fn ne(&self, other: &Error) -> bool { !(*self).eq(other) }
}
trait ToJson { fn to_json() -> Json; }
trait ToJson { fn to_json(&self) -> Json; }
impl ToJson for Json {
fn to_json() -> Json { copy self }
fn to_json(&self) -> Json { copy *self }
}
impl ToJson for @Json {
fn to_json() -> Json { (*self).to_json() }
fn to_json(&self) -> Json { (**self).to_json() }
}
impl ToJson for int {
fn to_json() -> Json { Number(self as float) }
fn to_json(&self) -> Json { Number(*self as float) }
}
impl ToJson for i8 {
fn to_json() -> Json { Number(self as float) }
fn to_json(&self) -> Json { Number(*self as float) }
}
impl ToJson for i16 {
fn to_json() -> Json { Number(self as float) }
fn to_json(&self) -> Json { Number(*self as float) }
}
impl ToJson for i32 {
fn to_json() -> Json { Number(self as float) }
fn to_json(&self) -> Json { Number(*self as float) }
}
impl ToJson for i64 {
fn to_json() -> Json { Number(self as float) }
fn to_json(&self) -> Json { Number(*self as float) }
}
impl ToJson for uint {
fn to_json() -> Json { Number(self as float) }
fn to_json(&self) -> Json { Number(*self as float) }
}
impl ToJson for u8 {
fn to_json() -> Json { Number(self as float) }
fn to_json(&self) -> Json { Number(*self as float) }
}
impl ToJson for u16 {
fn to_json() -> Json { Number(self as float) }
fn to_json(&self) -> Json { Number(*self as float) }
}
impl ToJson for u32 {
fn to_json() -> Json { Number(self as float) }
fn to_json(&self) -> Json { Number(*self as float) }
}
impl ToJson for u64 {
fn to_json() -> Json { Number(self as float) }
fn to_json(&self) -> Json { Number(*self as float) }
}
impl ToJson for float {
fn to_json() -> Json { Number(self) }
fn to_json(&self) -> Json { Number(*self) }
}
impl ToJson for f32 {
fn to_json() -> Json { Number(self as float) }
fn to_json(&self) -> Json { Number(*self as float) }
}
impl ToJson for f64 {
fn to_json() -> Json { Number(self as float) }
fn to_json(&self) -> Json { Number(*self as float) }
}
impl ToJson for () {
fn to_json() -> Json { Null }
fn to_json(&self) -> Json { Null }
}
impl ToJson for bool {
fn to_json() -> Json { Boolean(self) }
fn to_json(&self) -> Json { Boolean(*self) }
}
impl ToJson for ~str {
fn to_json() -> Json { String(copy self) }
fn to_json(&self) -> Json { String(copy *self) }
}
impl ToJson for @~str {
fn to_json() -> Json { String(copy *self) }
fn to_json(&self) -> Json { String(copy **self) }
}
impl<A:ToJson,B:ToJson> ToJson for (A, B) {
fn to_json() -> Json {
match self {
fn to_json(&self) -> Json {
match *self {
(ref a, ref b) => {
List(~[a.to_json(), b.to_json()])
}
@ -1161,8 +1161,8 @@ impl<A:ToJson,B:ToJson> ToJson for (A, B) {
}
impl<A:ToJson,B:ToJson,C:ToJson> ToJson for (A, B, C) {
fn to_json() -> Json {
match self {
fn to_json(&self) -> Json {
match *self {
(ref a, ref b, ref c) => {
List(~[a.to_json(), b.to_json(), c.to_json()])
}
@ -1171,11 +1171,11 @@ impl<A:ToJson,B:ToJson,C:ToJson> ToJson for (A, B, C) {
}
impl<A:ToJson> ToJson for ~[A] {
fn to_json() -> Json { List(self.map(|elt| elt.to_json())) }
fn to_json(&self) -> Json { List(self.map(|elt| elt.to_json())) }
}
impl<A:ToJson + Copy> ToJson for LinearMap<~str, A> {
fn to_json() -> Json {
fn to_json(&self) -> Json {
let mut d = LinearMap::new();
for self.each |&(key, value)| {
d.insert(copy *key, value.to_json());
@ -1185,8 +1185,8 @@ impl<A:ToJson + Copy> ToJson for LinearMap<~str, A> {
}
impl<A:ToJson> ToJson for Option<A> {
fn to_json() -> Json {
match self {
fn to_json(&self) -> Json {
match *self {
None => Null,
Some(ref value) => value.to_json()
}

View File

@ -187,13 +187,13 @@ pub mod v4 {
pub struct Ipv4Rep { a: u8, b: u8, c: u8, d: u8 }
pub trait AsUnsafeU32 {
unsafe fn as_u32() -> u32;
unsafe fn as_u32(&self) -> u32;
}
impl AsUnsafeU32 for Ipv4Rep {
// this is pretty dastardly, i know
unsafe fn as_u32() -> u32 {
*((ptr::addr_of(&self)) as *u32)
unsafe fn as_u32(&self) -> u32 {
*((ptr::addr_of(self)) as *u32)
}
}
pub fn parse_to_ipv4_rep(ip: &str) -> result::Result<Ipv4Rep, ~str> {

View File

@ -823,31 +823,31 @@ pub fn socket_buf(sock: TcpSocket) -> TcpSocketBuf {
/// Convenience methods extending `net::tcp::TcpSocket`
pub impl TcpSocket {
pub fn read_start() -> result::Result<@Port<
pub fn read_start(&self) -> result::Result<@Port<
result::Result<~[u8], TcpErrData>>, TcpErrData> {
read_start(&self)
read_start(self)
}
pub fn read_stop() ->
pub fn read_stop(&self) ->
result::Result<(), TcpErrData> {
read_stop(&self)
read_stop(self)
}
fn read(timeout_msecs: uint) ->
fn read(&self, timeout_msecs: uint) ->
result::Result<~[u8], TcpErrData> {
read(&self, timeout_msecs)
read(self, timeout_msecs)
}
fn read_future(timeout_msecs: uint) ->
fn read_future(&self, timeout_msecs: uint) ->
future::Future<result::Result<~[u8], TcpErrData>> {
read_future(&self, timeout_msecs)
read_future(self, timeout_msecs)
}
pub fn write(raw_write_data: ~[u8])
pub fn write(&self, raw_write_data: ~[u8])
-> result::Result<(), TcpErrData> {
write(&self, raw_write_data)
write(self, raw_write_data)
}
pub fn write_future(raw_write_data: ~[u8])
pub fn write_future(&self, raw_write_data: ~[u8])
-> future::Future<result::Result<(), TcpErrData>> {
write_future(&self, raw_write_data)
write_future(self, raw_write_data)
}
pub fn get_peer_addr() -> ip::IpAddr {
pub fn get_peer_addr(&self) -> ip::IpAddr {
unsafe {
if self.socket_data.ipv6 {
let addr = uv::ll::ip6_addr("", 0);
@ -1264,11 +1264,11 @@ enum TcpReadResult {
}
trait ToTcpErr {
fn to_tcp_err() -> TcpErrData;
fn to_tcp_err(&self) -> TcpErrData;
}
impl ToTcpErr for uv::ll::uv_err_data {
fn to_tcp_err() -> TcpErrData {
fn to_tcp_err(&self) -> TcpErrData {
TcpErrData { err_name: self.err_name, err_msg: self.err_msg }
}
}

View File

@ -74,7 +74,7 @@ pub mod chained {
}
priv impl<K:Eq + IterBytes + Hash,V> T<K, V> {
pure fn search_rem(k: &K, h: uint, idx: uint,
pure fn search_rem(&self, k: &K, h: uint, idx: uint,
e_root: @Entry<K,V>) -> SearchResult<K,V> {
let mut e0 = e_root;
let mut comp = 1u; // for logging
@ -100,7 +100,7 @@ pub mod chained {
};
}
pure fn search_tbl(k: &K, h: uint) -> SearchResult<K,V> {
pure fn search_tbl(&self, k: &K, h: uint) -> SearchResult<K,V> {
let idx = h % vec::len(self.chains);
match copy self.chains[idx] {
None => {
@ -120,7 +120,7 @@ pub mod chained {
}
}
fn rehash() {
fn rehash(&self) {
let n_old_chains = self.chains.len();
let n_new_chains: uint = uint::next_power_of_two(n_old_chains+1u);
let mut new_chains = chains(n_new_chains);
@ -134,7 +134,7 @@ pub mod chained {
}
pub impl<K:Eq + IterBytes + Hash,V> T<K, V> {
pure fn each_entry(blk: fn(@Entry<K,V>) -> bool) {
pure fn each_entry(&self, blk: fn(@Entry<K,V>) -> bool) {
// n.b. we can't use vec::iter() here because self.chains
// is stored in a mutable location.
let mut i = 0u, n = self.chains.len();
@ -176,7 +176,7 @@ pub mod chained {
}
}
fn insert(k: K, v: V) -> bool {
fn insert(&self, k: K, v: V) -> bool {
let hash = k.hash_keyed(0,0) as uint;
match self.search_tbl(&k, hash) {
NotFound => {
@ -220,7 +220,7 @@ pub mod chained {
}
}
fn remove(k: &K) -> bool {
fn remove(&self, k: &K) -> bool {
match self.search_tbl(k, k.hash_keyed(0,0) as uint) {
NotFound => false,
FoundFirst(idx, entry) => {
@ -260,7 +260,8 @@ pub mod chained {
}
}
fn update_with_key(key: K, newval: V, ff: fn(K, V, V) -> V) -> bool {
fn update_with_key(&self, key: K, newval: V, ff: fn(K, V, V) -> V)
-> bool {
/*
match self.find(key) {
None => return self.insert(key, val),
@ -311,7 +312,7 @@ pub mod chained {
}
}
fn update(key: K, newval: V, ff: fn(V, V) -> V) -> bool {
fn update(&self, key: K, newval: V, ff: fn(V, V) -> V) -> bool {
return self.update_with_key(key, newval, |_k, v, v1| ff(v,v1));
}
@ -325,7 +326,7 @@ pub mod chained {
}
pub impl<K:Eq + IterBytes + Hash + Copy + ToStr,V:ToStr + Copy> T<K, V> {
fn to_writer(wr: io::Writer) {
fn to_writer(&self, wr: io::Writer) {
if self.count == 0u {
wr.write_str(~"{}");
return;

View File

@ -28,7 +28,7 @@ not required in or otherwise suitable for the core library.
#[allow(vecs_implicitly_copyable)];
#[deny(non_camel_case_types)];
#[allow(deprecated_self)];
#[deny(deprecated_self)];
#[allow(deprecated_mutable_fields)];
#[no_core];

View File

@ -99,7 +99,7 @@ fn new_sem_and_signal(count: int, num_condvars: uint)
#[doc(hidden)]
pub impl<Q:Owned> &self/Sem<Q> {
fn acquire() {
fn acquire(&self) {
let mut waiter_nobe = None;
unsafe {
do (**self).with |state| {
@ -121,7 +121,7 @@ pub impl<Q:Owned> &self/Sem<Q> {
let _ = comm::recv_one(option::unwrap(waiter_nobe));
}
}
fn release() {
fn release(&self) {
unsafe {
do (**self).with |state| {
state.count += 1;
@ -135,12 +135,12 @@ pub impl<Q:Owned> &self/Sem<Q> {
// FIXME(#3154) move both copies of this into Sem<Q>, and unify the 2 structs
#[doc(hidden)]
pub impl &self/Sem<()> {
fn access<U>(blk: fn() -> U) -> U {
fn access<U>(&self, blk: fn() -> U) -> U {
let mut release = None;
unsafe {
do task::unkillable {
self.acquire();
release = Some(SemRelease(self));
release = Some(SemRelease(*self));
}
}
blk()
@ -148,12 +148,12 @@ pub impl &self/Sem<()> {
}
#[doc(hidden)]
pub impl &self/Sem<~[Waitqueue]> {
fn access<U>(blk: fn() -> U) -> U {
fn access<U>(&self, blk: fn() -> U) -> U {
let mut release = None;
unsafe {
do task::unkillable {
self.acquire();
release = Some(SemAndSignalRelease(self));
release = Some(SemAndSignalRelease(*self));
}
}
blk()
@ -385,7 +385,7 @@ pub impl Semaphore {
fn release(&self) { (&self.sem).release() }
/// Run a function with ownership of one of the semaphore's resources.
fn access<U>(blk: fn() -> U) -> U { (&self.sem).access(blk) }
fn access<U>(&self, blk: fn() -> U) -> U { (&self.sem).access(blk) }
}
/****************************************************************************

View File

@ -209,25 +209,25 @@ pub pure fn strftime(format: &str, tm: &Tm) -> ~str {
pub impl Tm {
/// Convert time to the seconds from January 1, 1970
fn to_timespec() -> Timespec {
fn to_timespec(&self) -> Timespec {
unsafe {
let mut sec = 0i64;
if self.tm_gmtoff == 0_i32 {
rustrt::rust_timegm(self, &mut sec);
rustrt::rust_timegm(*self, &mut sec);
} else {
rustrt::rust_mktime(self, &mut sec);
rustrt::rust_mktime(*self, &mut sec);
}
Timespec::new(sec, self.tm_nsec)
}
}
/// Convert time to the local timezone
fn to_local() -> Tm {
fn to_local(&self) -> Tm {
at(self.to_timespec())
}
/// Convert time to the UTC
fn to_utc() -> Tm {
fn to_utc(&self) -> Tm {
at_utc(self.to_timespec())
}
@ -235,7 +235,7 @@ pub impl Tm {
* Return a string of the current time in the form
* "Thu Jan 1 00:00:00 1970".
*/
pure fn ctime() -> ~str { self.strftime(~"%c") }
pure fn ctime(&self) -> ~str { self.strftime(~"%c") }
/// Formats the time according to the format string.
pure fn strftime(&self, format: &str) -> ~str {
@ -248,7 +248,7 @@ pub impl Tm {
* local: "Thu, 22 Mar 2012 07:53:18 PST"
* utc: "Thu, 22 Mar 2012 14:53:18 UTC"
*/
pure fn rfc822() -> ~str {
pure fn rfc822(&self) -> ~str {
if self.tm_gmtoff == 0_i32 {
self.strftime(~"%a, %d %b %Y %T GMT")
} else {
@ -262,7 +262,7 @@ pub impl Tm {
* local: "Thu, 22 Mar 2012 07:53:18 -0700"
* utc: "Thu, 22 Mar 2012 14:53:18 -0000"
*/
pure fn rfc822z() -> ~str {
pure fn rfc822z(&self) -> ~str {
self.strftime(~"%a, %d %b %Y %T %z")
}
@ -272,7 +272,7 @@ pub impl Tm {
* local: "2012-02-22T07:53:18-07:00"
* utc: "2012-02-22T14:53:18Z"
*/
pure fn rfc3339() -> ~str {
pure fn rfc3339(&self) -> ~str {
if self.tm_gmtoff == 0_i32 {
self.strftime(~"%Y-%m-%dT%H:%M:%SZ")
} else {

View File

@ -200,7 +200,7 @@ struct Logger {
}
pub impl Logger {
fn info(i: &str) {
fn info(&self, i: &str) {
io::println(~"workcache: " + i.to_owned());
}
}