X-Git-Url: http://nitlanguage.org diff --git a/lib/binary/serialization.nit b/lib/binary/serialization.nit index e069304..34de766 100644 --- a/lib/binary/serialization.nit +++ b/lib/binary/serialization.nit @@ -25,7 +25,7 @@ # | 0x06 utf8 byte sequence # Char # | 0x07 double(64 bits) # Float # | 0x08 block # String -# | 0x09 block # NativeString +# | 0x09 block # CString # | 0x0A flat_array; # Array[nullable Object] # # block = int64 int8*; @@ -129,7 +129,7 @@ class BinaryDeserializer private var unclaimed_attributes = new UnrolledList[HashMap[String, nullable Object]] # Buffer for one char - private var char_buf: NativeString is lazy do return new NativeString(4) + private var char_buf: CString is lazy do return new CString(4) # Read and deserialize the next attribute name and value # @@ -153,7 +153,7 @@ class BinaryDeserializer return new Couple[String, nullable Object](next_attribute_name, next_object) end - redef fun deserialize_attribute(name) + redef fun deserialize_attribute(name, static_type) do if unclaimed_attributes.last.keys.has(name) then # Pick in already deserialized attributes @@ -178,7 +178,7 @@ class BinaryDeserializer # An invalid attribute name is an heuristic for invalid data. # Hitting an object end marker will result in an empty string. - assert next_attribute_name.is_valid_id else + if not next_attribute_name.is_valid_id then var error if next_attribute_name.is_empty then @@ -304,7 +304,7 @@ class BinaryDeserializer return null end - redef fun deserialize + redef fun deserialize(static_type) do errors.clear @@ -336,6 +336,12 @@ redef class Text return true end + + redef fun serialize_to_binary(v) + do + v.stream.write_byte kind_string + v.stream.write_block to_s + end end # --- @@ -397,15 +403,7 @@ redef class Char end end -redef class String - redef fun serialize_to_binary(v) - do - v.stream.write_byte kind_string - v.stream.write_block self - end -end - -redef class NativeString +redef class CString redef fun serialize_to_binary(v) do v.stream.write_byte kind_native_string