Skip to content

Commit

Permalink
Rename {uint,int} methods to {usize,isize}.
Browse files Browse the repository at this point in the history
  • Loading branch information
frewsxcv committed Aug 25, 2016
1 parent 012f45e commit 905644d
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 33 deletions.
8 changes: 4 additions & 4 deletions src/librbml/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand All @@ -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");
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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 {
Expand Down
26 changes: 13 additions & 13 deletions src/librbml/opaque.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

Expand All @@ -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)
}

Expand Down Expand Up @@ -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(())
}
Expand All @@ -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)
}

Expand Down Expand Up @@ -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)
}

Expand All @@ -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)
}

Expand Down Expand Up @@ -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)
}

Expand All @@ -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)
}

Expand All @@ -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())
Expand All @@ -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)
}

Expand All @@ -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)
}

Expand Down Expand Up @@ -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)
}

Expand All @@ -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)
}

Expand Down
4 changes: 2 additions & 2 deletions src/libserialize/collection_impls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -136,15 +136,15 @@ impl<
for item in self {
bits |= item.to_usize();
}
s.emit_uint(bits)
s.emit_usize(bits)
}
}

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 {
Expand Down
12 changes: 6 additions & 6 deletions src/libserialize/json.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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) }
Expand Down Expand Up @@ -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) }
Expand Down Expand Up @@ -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 }
Expand Down
16 changes: 8 additions & 8 deletions src/libserialize/serialize.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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>;
Expand Down Expand Up @@ -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>;
Expand Down Expand Up @@ -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()
}
}

Expand Down Expand Up @@ -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()
}
}

Expand Down

0 comments on commit 905644d

Please sign in to comment.