about summary refs log tree commit diff
path: root/src/libcore
diff options
context:
space:
mode:
authorNiko Matsakis <niko@alum.mit.edu>2012-03-14 11:49:28 -0400
committerNiko Matsakis <niko@alum.mit.edu>2012-03-14 11:49:28 -0400
commitffa187db252a7ee8765025f95d2cae18859258be (patch)
tree7be54115a961c0681b80f2c36ee3fff791a2fd28 /src/libcore
parentc6f2594319266c73f9b5a6c69dd482d6fda8dd12 (diff)
downloadrust-ffa187db252a7ee8765025f95d2cae18859258be.tar.gz
rust-ffa187db252a7ee8765025f95d2cae18859258be.zip
adjust auto_serialize to generate fns named serialize_T()
We used to generate a module T with a serialize() and deserialize() fn,
but this was suboptimal for a number of reasons:

- it required moving serialization into core so that uint etc worked
- it was harder to override the serialization behavior locally
  (this is now trivial)
Diffstat (limited to 'src/libcore')
-rw-r--r--src/libcore/core.rc3
-rw-r--r--src/libcore/serialization.rs116
-rw-r--r--src/libcore/uint.rs8
3 files changed, 1 insertions, 126 deletions
diff --git a/src/libcore/core.rc b/src/libcore/core.rc
index 72f5b528c9a..c28ad0a0282 100644
--- a/src/libcore/core.rc
+++ b/src/libcore/core.rc
@@ -31,7 +31,7 @@ export uint, u8, u16, u32, u64;
 export float, f32, f64;
 export box, char, str, ptr, vec, bool;
 export either, option, result, iter;
-export libc, os, io, run, rand, sys, unsafe, logging, serialization;
+export libc, os, io, run, rand, sys, unsafe, logging;
 export comm, task, future;
 export extfmt;
 export tuple;
@@ -88,7 +88,6 @@ mod cmath;
 mod sys;
 mod unsafe;
 mod logging;
-mod serialization;
 
 // Concurrency
 mod comm;
diff --git a/src/libcore/serialization.rs b/src/libcore/serialization.rs
deleted file mode 100644
index 187be90c4f5..00000000000
--- a/src/libcore/serialization.rs
+++ /dev/null
@@ -1,116 +0,0 @@
-export serializer;
-export serializer_helpers;
-export deserializer;
-export deserializer_helpers;
-
-/*
-Core serialization interfaces.
-*/
-
-iface serializer {
-    // Primitive types:
-    fn emit_nil();
-    fn emit_uint(v: uint);
-    fn emit_u64(v: u64);
-    fn emit_u32(v: u32);
-    fn emit_u16(v: u16);
-    fn emit_u8(v: u8);
-    fn emit_int(v: int);
-    fn emit_i64(v: i64);
-    fn emit_i32(v: i32);
-    fn emit_i16(v: i16);
-    fn emit_i8(v: i8);
-    fn emit_bool(v: bool);
-    fn emit_float(v: float);
-    fn emit_f64(v: f64);
-    fn emit_f32(v: f32);
-    fn emit_str(v: str);
-
-    // Compound types:
-    fn emit_enum(name: str, f: fn());
-    fn emit_enum_variant(v_name: str, v_id: uint, sz: uint, f: fn());
-    fn emit_enum_variant_arg(idx: uint, f: fn());
-    fn emit_vec(len: uint, f: fn());
-    fn emit_vec_elt(idx: uint, f: fn());
-    fn emit_box(f: fn());
-    fn emit_uniq(f: fn());
-    fn emit_rec(f: fn());
-    fn emit_rec_field(f_name: str, f_idx: uint, f: fn());
-    fn emit_tup(sz: uint, f: fn());
-    fn emit_tup_elt(idx: uint, f: fn());
-}
-
-iface deserializer {
-    // Primitive types:
-    fn read_nil() -> ();
-
-    fn read_uint() -> uint;
-    fn read_u64() -> u64;
-    fn read_u32() -> u32;
-    fn read_u16() -> u16;
-    fn read_u8() -> u8;
-
-    fn read_int() -> int;
-    fn read_i64() -> i64;
-    fn read_i32() -> i32;
-    fn read_i16() -> i16;
-    fn read_i8() -> i8;
-
-
-    fn read_bool() -> bool;
-
-    fn read_str() -> str;
-
-    fn read_f64() -> f64;
-    fn read_f32() -> f32;
-    fn read_float() -> float;
-
-    // Compound types:
-    fn read_enum<T:copy>(name: str, f: fn() -> T) -> T;
-    fn read_enum_variant<T:copy>(f: fn(uint) -> T) -> T;
-    fn read_enum_variant_arg<T:copy>(idx: uint, f: fn() -> T) -> T;
-    fn read_vec<T:copy>(f: fn(uint) -> T) -> T;
-    fn read_vec_elt<T:copy>(idx: uint, f: fn() -> T) -> T;
-    fn read_box<T:copy>(f: fn() -> T) -> T;
-    fn read_uniq<T:copy>(f: fn() -> T) -> T;
-    fn read_rec<T:copy>(f: fn() -> T) -> T;
-    fn read_rec_field<T:copy>(f_name: str, f_idx: uint, f: fn() -> T) -> T;
-    fn read_tup<T:copy>(sz: uint, f: fn() -> T) -> T;
-    fn read_tup_elt<T:copy>(idx: uint, f: fn() -> T) -> T;
-}
-
-// ___________________________________________________________________________
-// Helper routines
-//
-// These should eventually be coded as traits.
-
-fn emit_from_vec<S: serializer, T>(s: S, v: [T], f: fn(T)) {
-    s.emit_vec(vec::len(v)) {||
-        vec::iteri(v) {|i,e|
-            s.emit_vec_elt(i) {||
-                f(e)
-            }
-        }
-    }
-}
-
-fn read_to_vec<D: deserializer, T>(d: D, f: fn() -> T) -> [T] {
-    d.read_vec {|len|
-        vec::from_fn(len) {|i|
-            d.read_vec_elt(i) {|| f() }
-        }
-    }
-}
-
-impl serializer_helpers<S: serializer> for S {
-    fn emit_from_vec<T>(v: [T], f: fn(T)) {
-        emit_from_vec(self, v, f)
-    }
-}
-
-impl deserializer_helpers<D: deserializer> for D {
-    fn read_to_vec<T>(f: fn() -> T) -> [T] {
-        read_to_vec(self, f)
-    }
-}
-
diff --git a/src/libcore/uint.rs b/src/libcore/uint.rs
index e466717657d..88230bea094 100644
--- a/src/libcore/uint.rs
+++ b/src/libcore/uint.rs
@@ -192,14 +192,6 @@ fn compl(i: uint) -> uint {
     max_value ^ i
 }
 
-fn serialize<S: serialization::serializer>(s: S, v: uint) {
-    s.emit_uint(v);
-}
-
-fn deserialize<D: serialization::deserializer>(d: D) -> uint {
-    d.read_uint()
-}
-
 #[cfg(test)]
 mod tests {