Rename {uint,int} methods to {usize,isize}.
This commit is contained in:
parent
012f45eaf7
commit
905644de5d
@ -726,7 +726,7 @@ pub mod reader {
|
||||
fn read_u8(&mut self) -> DecodeResult<u8> {
|
||||
Ok(doc_as_u8(self.next_doc(EsU8)?))
|
||||
}
|
||||
fn read_uint(&mut self) -> DecodeResult<usize> {
|
||||
fn read_usize(&mut self) -> DecodeResult<usize> {
|
||||
let v = self._next_int(EsU8, EsU64)?;
|
||||
if v > (::std::usize::MAX as u64) {
|
||||
Err(IntTooBig(v as usize))
|
||||
@ -747,7 +747,7 @@ pub mod reader {
|
||||
fn read_i8(&mut self) -> DecodeResult<i8> {
|
||||
Ok(doc_as_u8(self.next_doc(EsI8)?) as i8)
|
||||
}
|
||||
fn read_int(&mut self) -> DecodeResult<isize> {
|
||||
fn read_isize(&mut self) -> DecodeResult<isize> {
|
||||
let v = self._next_int(EsI8, EsI64)? as i64;
|
||||
if v > (isize::MAX as i64) || v < (isize::MIN as i64) {
|
||||
debug!("FIXME \\#6122: Removing this makes this function miscompile");
|
||||
@ -1219,7 +1219,7 @@ pub mod writer {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn emit_uint(&mut self, v: usize) -> EncodeResult {
|
||||
fn emit_usize(&mut self, v: usize) -> EncodeResult {
|
||||
self.emit_u64(v as u64)
|
||||
}
|
||||
fn emit_u64(&mut self, v: u64) -> EncodeResult {
|
||||
@ -1247,7 +1247,7 @@ pub mod writer {
|
||||
self.wr_tagged_raw_u8(EsU8 as usize, v)
|
||||
}
|
||||
|
||||
fn emit_int(&mut self, v: isize) -> EncodeResult {
|
||||
fn emit_isize(&mut self, v: isize) -> EncodeResult {
|
||||
self.emit_i64(v as i64)
|
||||
}
|
||||
fn emit_i64(&mut self, v: i64) -> EncodeResult {
|
||||
|
@ -54,7 +54,7 @@ impl<'a> serialize::Encoder for Encoder<'a> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn emit_uint(&mut self, v: usize) -> EncodeResult {
|
||||
fn emit_usize(&mut self, v: usize) -> EncodeResult {
|
||||
write_uleb128!(self, v)
|
||||
}
|
||||
|
||||
@ -75,7 +75,7 @@ impl<'a> serialize::Encoder for Encoder<'a> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn emit_int(&mut self, v: isize) -> EncodeResult {
|
||||
fn emit_isize(&mut self, v: isize) -> EncodeResult {
|
||||
write_sleb128!(self, v)
|
||||
}
|
||||
|
||||
@ -120,7 +120,7 @@ impl<'a> serialize::Encoder for Encoder<'a> {
|
||||
}
|
||||
|
||||
fn emit_str(&mut self, v: &str) -> EncodeResult {
|
||||
self.emit_uint(v.len())?;
|
||||
self.emit_usize(v.len())?;
|
||||
let _ = self.cursor.write_all(v.as_bytes());
|
||||
Ok(())
|
||||
}
|
||||
@ -139,7 +139,7 @@ impl<'a> serialize::Encoder for Encoder<'a> {
|
||||
-> EncodeResult
|
||||
where F: FnOnce(&mut Self) -> EncodeResult
|
||||
{
|
||||
self.emit_uint(v_id)?;
|
||||
self.emit_usize(v_id)?;
|
||||
f(self)
|
||||
}
|
||||
|
||||
@ -221,7 +221,7 @@ impl<'a> serialize::Encoder for Encoder<'a> {
|
||||
fn emit_seq<F>(&mut self, len: usize, f: F) -> EncodeResult
|
||||
where F: FnOnce(&mut Encoder<'a>) -> EncodeResult
|
||||
{
|
||||
self.emit_uint(len)?;
|
||||
self.emit_usize(len)?;
|
||||
f(self)
|
||||
}
|
||||
|
||||
@ -234,7 +234,7 @@ impl<'a> serialize::Encoder for Encoder<'a> {
|
||||
fn emit_map<F>(&mut self, len: usize, f: F) -> EncodeResult
|
||||
where F: FnOnce(&mut Encoder<'a>) -> EncodeResult
|
||||
{
|
||||
self.emit_uint(len)?;
|
||||
self.emit_usize(len)?;
|
||||
f(self)
|
||||
}
|
||||
|
||||
@ -329,7 +329,7 @@ impl<'a> serialize::Decoder for Decoder<'a> {
|
||||
Ok(value)
|
||||
}
|
||||
|
||||
fn read_uint(&mut self) -> Result<usize, Self::Error> {
|
||||
fn read_usize(&mut self) -> Result<usize, Self::Error> {
|
||||
read_uleb128!(self, usize)
|
||||
}
|
||||
|
||||
@ -351,7 +351,7 @@ impl<'a> serialize::Decoder for Decoder<'a> {
|
||||
unsafe { Ok(::std::mem::transmute(as_u8)) }
|
||||
}
|
||||
|
||||
fn read_int(&mut self) -> Result<isize, Self::Error> {
|
||||
fn read_isize(&mut self) -> Result<isize, Self::Error> {
|
||||
read_sleb128!(self, isize)
|
||||
}
|
||||
|
||||
@ -376,7 +376,7 @@ impl<'a> serialize::Decoder for Decoder<'a> {
|
||||
}
|
||||
|
||||
fn read_str(&mut self) -> Result<String, Self::Error> {
|
||||
let len = self.read_uint()?;
|
||||
let len = self.read_usize()?;
|
||||
let s = ::std::str::from_utf8(&self.data[self.position..self.position + len]).unwrap();
|
||||
self.position += len;
|
||||
Ok(s.to_string())
|
||||
@ -391,7 +391,7 @@ impl<'a> serialize::Decoder for Decoder<'a> {
|
||||
fn read_enum_variant<T, F>(&mut self, _: &[&str], mut f: F) -> Result<T, Self::Error>
|
||||
where F: FnMut(&mut Decoder<'a>, usize) -> Result<T, Self::Error>
|
||||
{
|
||||
let disr = self.read_uint()?;
|
||||
let disr = self.read_usize()?;
|
||||
f(self, disr)
|
||||
}
|
||||
|
||||
@ -404,7 +404,7 @@ impl<'a> serialize::Decoder for Decoder<'a> {
|
||||
fn read_enum_struct_variant<T, F>(&mut self, _: &[&str], mut f: F) -> Result<T, Self::Error>
|
||||
where F: FnMut(&mut Decoder<'a>, usize) -> Result<T, Self::Error>
|
||||
{
|
||||
let disr = self.read_uint()?;
|
||||
let disr = self.read_usize()?;
|
||||
f(self, disr)
|
||||
}
|
||||
|
||||
@ -483,7 +483,7 @@ impl<'a> serialize::Decoder for Decoder<'a> {
|
||||
fn read_seq<T, F>(&mut self, f: F) -> Result<T, Self::Error>
|
||||
where F: FnOnce(&mut Decoder<'a>, usize) -> Result<T, Self::Error>
|
||||
{
|
||||
let len = self.read_uint()?;
|
||||
let len = self.read_usize()?;
|
||||
f(self, len)
|
||||
}
|
||||
|
||||
@ -496,7 +496,7 @@ impl<'a> serialize::Decoder for Decoder<'a> {
|
||||
fn read_map<T, F>(&mut self, f: F) -> Result<T, Self::Error>
|
||||
where F: FnOnce(&mut Decoder<'a>, usize) -> Result<T, Self::Error>
|
||||
{
|
||||
let len = self.read_uint()?;
|
||||
let len = self.read_usize()?;
|
||||
f(self, len)
|
||||
}
|
||||
|
||||
|
@ -136,7 +136,7 @@ impl<
|
||||
for item in self {
|
||||
bits |= item.to_usize();
|
||||
}
|
||||
s.emit_uint(bits)
|
||||
s.emit_usize(bits)
|
||||
}
|
||||
}
|
||||
|
||||
@ -144,7 +144,7 @@ impl<
|
||||
T: Decodable + CLike
|
||||
> Decodable for EnumSet<T> {
|
||||
fn decode<D: Decoder>(d: &mut D) -> Result<EnumSet<T>, D::Error> {
|
||||
let bits = d.read_uint()?;
|
||||
let bits = d.read_usize()?;
|
||||
let mut set = EnumSet::new();
|
||||
for bit in 0..(mem::size_of::<usize>()*8) {
|
||||
if bits & (1 << bit) != 0 {
|
||||
|
@ -495,13 +495,13 @@ impl<'a> ::Encoder for Encoder<'a> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn emit_uint(&mut self, v: usize) -> EncodeResult { emit_enquoted_if_mapkey!(self, v) }
|
||||
fn emit_usize(&mut self, v: usize) -> EncodeResult { emit_enquoted_if_mapkey!(self, v) }
|
||||
fn emit_u64(&mut self, v: u64) -> EncodeResult { emit_enquoted_if_mapkey!(self, v) }
|
||||
fn emit_u32(&mut self, v: u32) -> EncodeResult { emit_enquoted_if_mapkey!(self, v) }
|
||||
fn emit_u16(&mut self, v: u16) -> EncodeResult { emit_enquoted_if_mapkey!(self, v) }
|
||||
fn emit_u8(&mut self, v: u8) -> EncodeResult { emit_enquoted_if_mapkey!(self, v) }
|
||||
|
||||
fn emit_int(&mut self, v: isize) -> EncodeResult { emit_enquoted_if_mapkey!(self, v) }
|
||||
fn emit_isize(&mut self, v: isize) -> EncodeResult { emit_enquoted_if_mapkey!(self, v) }
|
||||
fn emit_i64(&mut self, v: i64) -> EncodeResult { emit_enquoted_if_mapkey!(self, v) }
|
||||
fn emit_i32(&mut self, v: i32) -> EncodeResult { emit_enquoted_if_mapkey!(self, v) }
|
||||
fn emit_i16(&mut self, v: i16) -> EncodeResult { emit_enquoted_if_mapkey!(self, v) }
|
||||
@ -743,13 +743,13 @@ impl<'a> ::Encoder for PrettyEncoder<'a> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn emit_uint(&mut self, v: usize) -> EncodeResult { emit_enquoted_if_mapkey!(self, v) }
|
||||
fn emit_usize(&mut self, v: usize) -> EncodeResult { emit_enquoted_if_mapkey!(self, v) }
|
||||
fn emit_u64(&mut self, v: u64) -> EncodeResult { emit_enquoted_if_mapkey!(self, v) }
|
||||
fn emit_u32(&mut self, v: u32) -> EncodeResult { emit_enquoted_if_mapkey!(self, v) }
|
||||
fn emit_u16(&mut self, v: u16) -> EncodeResult { emit_enquoted_if_mapkey!(self, v) }
|
||||
fn emit_u8(&mut self, v: u8) -> EncodeResult { emit_enquoted_if_mapkey!(self, v) }
|
||||
|
||||
fn emit_int(&mut self, v: isize) -> EncodeResult { emit_enquoted_if_mapkey!(self, v) }
|
||||
fn emit_isize(&mut self, v: isize) -> EncodeResult { emit_enquoted_if_mapkey!(self, v) }
|
||||
fn emit_i64(&mut self, v: i64) -> EncodeResult { emit_enquoted_if_mapkey!(self, v) }
|
||||
fn emit_i32(&mut self, v: i32) -> EncodeResult { emit_enquoted_if_mapkey!(self, v) }
|
||||
fn emit_i16(&mut self, v: i16) -> EncodeResult { emit_enquoted_if_mapkey!(self, v) }
|
||||
@ -2137,12 +2137,12 @@ impl ::Decoder for Decoder {
|
||||
expect!(self.pop(), Null)
|
||||
}
|
||||
|
||||
read_primitive! { read_uint, usize }
|
||||
read_primitive! { read_usize, usize }
|
||||
read_primitive! { read_u8, u8 }
|
||||
read_primitive! { read_u16, u16 }
|
||||
read_primitive! { read_u32, u32 }
|
||||
read_primitive! { read_u64, u64 }
|
||||
read_primitive! { read_int, isize }
|
||||
read_primitive! { read_isize, isize }
|
||||
read_primitive! { read_i8, i8 }
|
||||
read_primitive! { read_i16, i16 }
|
||||
read_primitive! { read_i32, i32 }
|
||||
|
@ -24,12 +24,12 @@ pub trait Encoder {
|
||||
|
||||
// Primitive types:
|
||||
fn emit_nil(&mut self) -> Result<(), Self::Error>;
|
||||
fn emit_uint(&mut self, v: usize) -> Result<(), Self::Error>;
|
||||
fn emit_usize(&mut self, v: usize) -> Result<(), Self::Error>;
|
||||
fn emit_u64(&mut self, v: u64) -> Result<(), Self::Error>;
|
||||
fn emit_u32(&mut self, v: u32) -> Result<(), Self::Error>;
|
||||
fn emit_u16(&mut self, v: u16) -> Result<(), Self::Error>;
|
||||
fn emit_u8(&mut self, v: u8) -> Result<(), Self::Error>;
|
||||
fn emit_int(&mut self, v: isize) -> Result<(), Self::Error>;
|
||||
fn emit_isize(&mut self, v: isize) -> Result<(), Self::Error>;
|
||||
fn emit_i64(&mut self, v: i64) -> Result<(), Self::Error>;
|
||||
fn emit_i32(&mut self, v: i32) -> Result<(), Self::Error>;
|
||||
fn emit_i16(&mut self, v: i16) -> Result<(), Self::Error>;
|
||||
@ -108,12 +108,12 @@ pub trait Decoder {
|
||||
|
||||
// Primitive types:
|
||||
fn read_nil(&mut self) -> Result<(), Self::Error>;
|
||||
fn read_uint(&mut self) -> Result<usize, Self::Error>;
|
||||
fn read_usize(&mut self) -> Result<usize, Self::Error>;
|
||||
fn read_u64(&mut self) -> Result<u64, Self::Error>;
|
||||
fn read_u32(&mut self) -> Result<u32, Self::Error>;
|
||||
fn read_u16(&mut self) -> Result<u16, Self::Error>;
|
||||
fn read_u8(&mut self) -> Result<u8, Self::Error>;
|
||||
fn read_int(&mut self) -> Result<isize, Self::Error>;
|
||||
fn read_isize(&mut self) -> Result<isize, Self::Error>;
|
||||
fn read_i64(&mut self) -> Result<i64, Self::Error>;
|
||||
fn read_i32(&mut self) -> Result<i32, Self::Error>;
|
||||
fn read_i16(&mut self) -> Result<i16, Self::Error>;
|
||||
@ -200,13 +200,13 @@ pub trait Decodable: Sized {
|
||||
|
||||
impl Encodable for usize {
|
||||
fn encode<S: Encoder>(&self, s: &mut S) -> Result<(), S::Error> {
|
||||
s.emit_uint(*self)
|
||||
s.emit_usize(*self)
|
||||
}
|
||||
}
|
||||
|
||||
impl Decodable for usize {
|
||||
fn decode<D: Decoder>(d: &mut D) -> Result<usize, D::Error> {
|
||||
d.read_uint()
|
||||
d.read_usize()
|
||||
}
|
||||
}
|
||||
|
||||
@ -260,13 +260,13 @@ impl Decodable for u64 {
|
||||
|
||||
impl Encodable for isize {
|
||||
fn encode<S: Encoder>(&self, s: &mut S) -> Result<(), S::Error> {
|
||||
s.emit_int(*self)
|
||||
s.emit_isize(*self)
|
||||
}
|
||||
}
|
||||
|
||||
impl Decodable for isize {
|
||||
fn decode<D: Decoder>(d: &mut D) -> Result<isize, D::Error> {
|
||||
d.read_int()
|
||||
d.read_isize()
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user