private fun kind_char: Byte do return 0x06u8
private fun kind_float: Byte do return 0x07u8
private fun kind_string: Byte do return 0x08u8
-private fun kind_native_string: Byte do return 0x09u8
+private fun kind_c_string: Byte do return 0x09u8
private fun kind_flat_array: Byte do return 0x0Au8
private fun new_object_end: Byte do return 0x00u8
# Target writing stream
var stream: Writer is writable
+ redef var current_object = null
+
redef fun serialize(object)
do
if object == null then
stream.write_int64 id
else
# serialize here
+ var last_object = current_object
+ current_object = object
object.serialize_to_binary self
+ current_object = last_object
end
end
if b == null then return '�'
bf[i] = b
end
- return bf.to_s_with_length(ln)[0]
+ return bf.to_s_unsafe(ln, copy=false)[0]
end
if kind == kind_string then return stream.read_block
- if kind == kind_native_string then return stream.read_block.to_cstring
+ if kind == kind_c_string then return stream.read_block.to_cstring
if kind == kind_flat_array then
# An array
private fun serialize_to_binary(v: BinarySerializer)
do
serialize_header_to_binary v
- core_serialize_to v
+ v.serialize_core self
v.stream.write_byte new_object_end
end
end
redef class CString
redef fun serialize_to_binary(v)
do
- v.stream.write_byte kind_native_string
+ v.stream.write_byte kind_c_string
v.stream.write_block to_s
end
end
do
serialize_header_to_binary v
- core_serialize_to v
+ v.serialize_core self
v.stream.write_string "keys"
v.serialize_flat_array keys