std: remove Encoder::emit_{owned,managed} and Decoder::read_{owned,managed}

This commit is contained in:
Erick Tryzelaar 2013-03-28 20:51:40 -07:00
parent 8b43c620b9
commit 63fc88757f
4 changed files with 5 additions and 33 deletions

View file

@ -315,16 +315,6 @@ pub mod reader {
fn read_str(&self) -> ~str { doc_as_str(self.next_doc(EsStr)) }
// Compound types:
fn read_owned<T>(&self, f: &fn() -> T) -> T {
debug!("read_owned()");
f()
}
fn read_managed<T>(&self, f: &fn() -> T) -> T {
debug!("read_managed()");
f()
}
fn read_enum<T>(&self, name: &str, f: &fn() -> T) -> T {
debug!("read_enum(%s)", name);
self._check_label(name);
@ -651,10 +641,6 @@ pub mod writer {
self.wr_tagged_str(EsStr as uint, v)
}
fn emit_borrowed(&self, f: &fn()) { f() }
fn emit_owned(&self, f: &fn()) { f() }
fn emit_managed(&self, f: &fn()) { f() }
fn emit_enum(&self, name: &str, f: &fn()) {
self._emit_label(name);
self.wr_tag(EsEnum as uint, f)

View file

@ -108,10 +108,6 @@ impl serialize::Encoder for Encoder {
fn emit_char(&self, v: char) { self.emit_str(str::from_char(v)) }
fn emit_str(&self, v: &str) { self.wr.write_str(escape_str(v)) }
fn emit_borrowed(&self, f: &fn()) { f() }
fn emit_owned(&self, f: &fn()) { f() }
fn emit_managed(&self, f: &fn()) { f() }
fn emit_enum(&self, _name: &str, f: &fn()) { f() }
fn emit_enum_variant(&self, name: &str, _id: uint, cnt: uint, f: &fn()) {
// enums are encoded as strings or vectors:

View file

@ -41,9 +41,6 @@ pub trait Encoder {
fn emit_str(&self, v: &str);
// Compound types:
fn emit_borrowed(&self, f: &fn());
fn emit_owned(&self, f: &fn());
fn emit_managed(&self, f: &fn());
fn emit_enum(&self, name: &str, f: &fn());
fn emit_enum_variant(&self, v_name: &str, v_id: uint, sz: uint, f: &fn());
@ -97,9 +94,6 @@ pub trait Decoder {
fn read_enum_variant<T>(&self, names: &[&str], f: &fn(uint) -> T) -> T;
fn read_enum_variant_arg<T>(&self, idx: uint, f: &fn() -> T) -> T;
fn read_owned<T>(&self, f: &fn() -> T) -> T;
fn read_managed<T>(&self, f: &fn() -> T) -> T;
fn read_owned_vec<T>(&self, f: &fn(uint) -> T) -> T;
fn read_managed_vec<T>(&self, f: &fn(uint) -> T) -> T;
fn read_vec_elt<T>(&self, idx: uint, f: &fn() -> T) -> T;
@ -296,31 +290,31 @@ impl<D:Decoder> Decodable<D> for () {
impl<'self, S:Encoder,T:Encodable<S>> Encodable<S> for &'self T {
fn encode(&self, s: &S) {
s.emit_borrowed(|| (**self).encode(s))
(**self).encode(s)
}
}
impl<S:Encoder,T:Encodable<S>> Encodable<S> for ~T {
fn encode(&self, s: &S) {
s.emit_owned(|| (**self).encode(s))
(**self).encode(s)
}
}
impl<D:Decoder,T:Decodable<D>> Decodable<D> for ~T {
fn decode(d: &D) -> ~T {
d.read_owned(|| ~Decodable::decode(d))
~Decodable::decode(d)
}
}
impl<S:Encoder,T:Encodable<S>> Encodable<S> for @T {
fn encode(&self, s: &S) {
s.emit_managed(|| (**self).encode(s))
(**self).encode(s)
}
}
impl<D:Decoder,T:Decodable<D>> Decodable<D> for @T {
fn decode(d: &D) -> @T {
d.read_managed(|| @Decodable::decode(d))
@Decodable::decode(d)
}
}

View file

@ -1242,10 +1242,6 @@ mod test {
fn emit_char(&self, +_v: char) { self.add_unknown_to_log(); }
fn emit_str(&self, +_v: &str) { self.add_unknown_to_log(); }
fn emit_borrowed(&self, f: &fn()) { self.add_unknown_to_log(); f() }
fn emit_owned(&self, f: &fn()) { self.add_unknown_to_log(); f() }
fn emit_managed(&self, f: &fn()) { self.add_unknown_to_log(); f() }
fn emit_enum(&self, name: &str, f: &fn()) {
self.add_to_log(CallToEmitEnum(name.to_str())); f(); }