about summary refs log tree commit diff
diff options
context:
space:
mode:
authorKang Seonghoon <public+git@mearie.org>2015-03-02 00:37:14 +0900
committerKang Seonghoon <public+git@mearie.org>2015-03-03 11:55:36 +0900
commit2f3aa0dd2e9a599a80e22d79c33a5d7e2554f90b (patch)
tree20764d298aa28879d50ff15e82743ae9cfb5a23f
parentc9840b644c7e69551c6f9d737125375e4aec602d (diff)
downloadrust-2f3aa0dd2e9a599a80e22d79c33a5d7e2554f90b.tar.gz
rust-2f3aa0dd2e9a599a80e22d79c33a5d7e2554f90b.zip
metadata: Eliminate the `EsEnumBody` tag.
It doesn't serve any useful purpose. It *might* be useful when
there are some tags that are generated by `Encodable` and
not delimited by any tags, but IIUC it's not the case.

Previous:

                  <-------------------- len1 ------------------->
    EsEnum <len1> EsEnumVid <vid> EsEnumBody <len2> <arg1> <arg2>
                                                    <--- len2 -->

Now:

                  <----------- len1 ---------->
    EsEnum <len1> EsEnumVid <vid> <arg1> <arg2>
-rw-r--r--src/librbml/lib.rs47
1 files changed, 12 insertions, 35 deletions
diff --git a/src/librbml/lib.rs b/src/librbml/lib.rs
index a2fe71f0b4b..58cf5daf941 100644
--- a/src/librbml/lib.rs
+++ b/src/librbml/lib.rs
@@ -103,17 +103,16 @@ pub enum EbmlEncoderTag {
 
     EsStr      = 0x11,
     EsEnum     = 0x12,
-    EsEnumBody = 0x13,
-    EsVec      = 0x14,
-    EsVecElt   = 0x15,
-    EsMap      = 0x16,
-    EsMapKey   = 0x17,
-    EsMapVal   = 0x18,
+    EsVec      = 0x13,
+    EsVecElt   = 0x14,
+    EsMap      = 0x15,
+    EsMapKey   = 0x16,
+    EsMapVal   = 0x17,
 
-    EsOpaque   = 0x19,
+    EsOpaque   = 0x18,
 
     // Used only when debugging
-    EsLabel    = 0x1a,
+    EsLabel    = 0x19,
 }
 
 const NUM_TAGS: uint = 0x1000;
@@ -160,7 +159,7 @@ pub mod reader {
     use super::{ ApplicationError, EsVec, EsMap, EsEnum, EsVecLen, EsVecElt,
         EsMapLen, EsMapKey, EsEnumVid, EsU64, EsU32, EsU16, EsU8, EsInt, EsI64,
         EsI32, EsI16, EsI8, EsBool, EsF64, EsF32, EsChar, EsStr, EsMapVal,
-        EsEnumBody, EsUint, EsOpaque, EsLabel, EbmlEncoderTag, Doc, TaggedDoc,
+        EsUint, EsOpaque, EsLabel, EbmlEncoderTag, Doc, TaggedDoc,
         Error, IntTooBig, InvalidTag, Expected, NUM_IMPLICIT_TAGS, TAG_IMPLICIT_LEN };
 
     pub type DecodeResult<T> = Result<T, Error>;
@@ -564,17 +563,7 @@ pub mod reader {
             let idx = try!(self._next_uint(EsEnumVid));
             debug!("  idx={}", idx);
 
-            let doc = try!(self.next_doc(EsEnumBody));
-
-            let (old_parent, old_pos) = (self.parent, self.pos);
-            self.parent = doc;
-            self.pos = self.parent.start;
-
-            let result = try!(f(self, idx));
-
-            self.parent = old_parent;
-            self.pos = old_pos;
-            Ok(result)
+            f(self, idx)
         }
 
         fn read_enum_variant_arg<T, F>(&mut self, idx: uint, f: F) -> DecodeResult<T> where
@@ -592,17 +581,7 @@ pub mod reader {
             let idx = try!(self._next_uint(EsEnumVid));
             debug!("  idx={}", idx);
 
-            let doc = try!(self.next_doc(EsEnumBody));
-
-            let (old_parent, old_pos) = (self.parent, self.pos);
-            self.parent = doc;
-            self.pos = self.parent.start;
-
-            let result = try!(f(self, idx));
-
-            self.parent = old_parent;
-            self.pos = old_pos;
-            Ok(result)
+            f(self, idx)
         }
 
         fn read_enum_struct_variant_field<T, F>(&mut self,
@@ -743,7 +722,7 @@ pub mod writer {
 
     use super::{ EsVec, EsMap, EsEnum, EsVecLen, EsVecElt, EsMapLen, EsMapKey,
         EsEnumVid, EsU64, EsU32, EsU16, EsU8, EsInt, EsI64, EsI32, EsI16, EsI8,
-        EsBool, EsF64, EsF32, EsChar, EsStr, EsMapVal, EsEnumBody, EsUint,
+        EsBool, EsF64, EsF32, EsChar, EsStr, EsMapVal, EsUint,
         EsOpaque, EsLabel, EbmlEncoderTag, NUM_IMPLICIT_TAGS, NUM_TAGS };
 
     use serialize;
@@ -1059,9 +1038,7 @@ pub mod writer {
             F: FnOnce(&mut Encoder<'a, W>) -> EncodeResult,
         {
             try!(self._emit_tagged_uint(EsEnumVid, v_id));
-            try!(self.start_tag(EsEnumBody as uint));
-            try!(f(self));
-            self.end_tag()
+            f(self)
         }
 
         fn emit_enum_variant_arg<F>(&mut self, _: uint, f: F) -> EncodeResult where