Same as a C unsigned char
json :: serialization_write $ Byte :: accept_json_serializer
Refinable service to customize the serialization of this class to JSONmsgpack :: serialization_write $ Byte :: accept_msgpack_serializer
Hook to customize the serialization of this class to MessagePackserialization :: Serializable :: accept_json_serializer
Refinable service to customize the serialization of this class to JSONserialization :: Serializable :: accept_msgpack_attribute_counter
Hook to customize the behavior of theAttributeCounter
serialization :: Serializable :: accept_msgpack_serializer
Hook to customize the serialization of this class to MessagePackserialization :: Serializable :: add_to_bundle
Called by[]=
to dynamically choose the appropriate method according
core :: Object :: class_factory
Implementation used byget_class
to create the specific class.
serialization :: Serializable :: core_serialize_to
Actual serialization ofself
to serializer
core :: Numeric :: defaultinit
core :: Object :: defaultinit
core :: Discrete :: defaultinit
core :: Comparable :: defaultinit
serialization :: Serializable :: from_deserializer
Create an instance of this class from thedeserializer
core :: Object :: is_same_instance
Return true ifself
and other
are the same instance (i.e. same identity).
core :: Object :: is_same_serialized
Isself
the same as other
in a serialization context?
core :: Object :: is_same_type
Return true ifself
and other
have the same dynamic type.
serialization :: Serializable :: msgpack_extra_array_items
Hook to request a larger than usual metadata arraycore :: Object :: output_class_name
Display class name on stdout (debug only).serialization :: Serializable :: serialize_msgpack
Serializeself
to MessagePack bytes
serialization :: Serializable :: serialize_to
Serializeself
to serializer
serialization :: Serializable :: serialize_to_json
Serializeself
to JSON
serialization :: Serializable :: to_pretty_json
Serializeself
to plain pretty JSON
Serializer::serialize
serialization :: DirectSerializable
Instances of this class are not delayed and instead serialized immediately
# Native bytes.
# Same as a C `unsigned char`
universal Byte
super Discrete
super Numeric
redef type OTHER: Byte
redef fun successor(i) do return self + i.to_b
redef fun predecessor(i) do return self - i.to_b
redef fun object_id is intern
redef fun hash do return self.to_i
redef fun ==(i) is intern
redef fun !=(i) is intern
redef fun output is intern
redef fun <=(i) is intern
redef fun <(i) is intern
redef fun >=(i) is intern
redef fun >(i) is intern
redef fun +(i) is intern
# On an Byte, unary minus will return `(256 - self) % 256`
#
# assert -1u8 == 0xFFu8
# assert -0u8 == 0x00u8
redef fun - is intern
redef fun -(i) is intern
redef fun *(i) is intern
redef fun /(i) is intern
# Modulo of `self` with `i`.
#
# Finds the remainder of division of `self` by `i`.
#
# assert 5u8 % 2u8 == 1u8
# assert 10u8 % 2u8 == 0u8
fun %(i: Byte): Byte is intern
redef fun zero do return 0.to_b
redef fun value_of(val) do return val.to_b
# `i` bits shift fo the left
#
# assert 5u8 << 1 == 10u8
fun <<(i: Int): Byte is intern `{ return self << i; `}
# `i` bits shift fo the right
#
# assert 5u8 >> 1 == 2u8
fun >>(i: Int): Byte is intern `{ return self >> i; `}
redef fun to_i is intern
redef fun to_f is intern
redef fun to_b do return self
redef fun distance(i) do return (self - i).to_i
redef fun <=>(other)
do
if self < other then
return -1
else if other < self then
return 1
else
return 0
end
end
redef fun is_between(c, d)
do
if self < c or d < self then
return false
else
return true
end
end
redef fun max(other)
do
if self < other then
return other
else
return self
end
end
redef fun min(c)
do
if c < self then
return c
else
return self
end
end
# Is `self` an ASCII whitespace ?
fun is_whitespace: Bool do return self == 0x7Fu8 or self <= 0x20u8
end
lib/core/kernel.nit:601,1--700,3
redef class Byte
# Returns the result of a binary AND operation on `self` and `i`
#
# assert 0x10u8 & 0x01u8 == 0u8
fun &(i: Byte): Byte is intern `{ return self & i; `}
# Returns the result of a binary OR operation on `self` and `i`
#
# assert 0x10u8 | 0x01u8 == 0x11u8
fun |(i: Byte): Byte `{ return self | i; `}
# Returns the result of a binary XOR operation on `self` and `i`
#
# assert 0x101u8 ^ 0x110u8 == 0x11u8
fun ^(i: Byte): Byte `{ return self ^ i; `}
# Returns the 1's complement of `self`
#
# assert ~0x2Fu8 == 0xD0u8
fun ~: Byte `{ return ~self; `}
end
lib/core/math.nit:184,1--204,3
redef class Byte
# C function to calculate the length of the `CString` to receive `self`
private fun byte_to_s_len: Int `{
return snprintf(NULL, 0, "0x%02x", self);
`}
# C function to convert an nit Int to a CString (char*)
private fun native_byte_to_s(nstr: CString, strlen: Int) `{
snprintf(nstr, strlen, "0x%02x", self);
`}
# Displayable byte in its hexadecimal form (0x..)
#
# ~~~
# assert 1.to_b.to_s == "0x01"
# assert (-123).to_b.to_s == "0x85"
# ~~~
redef fun to_s do
var nslen = byte_to_s_len
var ns = new CString(nslen + 1)
ns[nslen] = 0
native_byte_to_s(ns, nslen + 1)
return ns.to_s_unsafe(nslen, copy=false, clean=false)
end
end
lib/core/text/abstract_text.nit:1930,1--1954,3
redef class Byte super DirectSerializable end
lib/serialization/serialization_core.nit:260,1--45
redef class Byte
redef fun accept_json_serializer(v)
do
if v.plain_json then
to_i.accept_json_serializer v
else
v.stream.write "\{\"__kind\": \"byte\", \"__val\": "
to_i.accept_json_serializer v
v.stream.write "\}"
end
end
end
lib/json/serialization_write.nit:289,1--300,3
redef class Byte
redef fun accept_msgpack_serializer(v)
do
if v.plain_msgpack then
# Write as a string
v.stream.write_msgpack_int to_i
else
# Write as ext
var bytes = new Bytes.with_capacity(1)
bytes.add self.to_i
v.stream.write_msgpack_ext(v.ext_typ_byte, bytes)
end
end
end
lib/msgpack/serialization_write.nit:260,1--273,3