Skip to content

Commit 87ab4ee

Browse files
committed
uint -> u32
1 parent 0c43246 commit 87ab4ee

File tree

9 files changed

+226
-233
lines changed

9 files changed

+226
-233
lines changed

compiler_tests/test.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -205,10 +205,10 @@ mod tests {
205205

206206
let enum_list = test_complex_list.init_enum_list(100);
207207

208-
for i in range::<uint>(0, 10) {
208+
for i in range::<u32>(0, 10) {
209209
enum_list.set(i, an_enum::Qux);
210210
}
211-
for i in range::<uint>(10, 20) {
211+
for i in range::<u32>(10, 20) {
212212
enum_list.set(i, an_enum::Bar);
213213
}
214214

@@ -261,10 +261,10 @@ mod tests {
261261

262262
let complex_list_reader = test_complex_list.as_reader();
263263
let enum_list_reader = complex_list_reader.get_enum_list();
264-
for i in range::<uint>(0,10) {
264+
for i in range::<u32>(0,10) {
265265
assert!(enum_list_reader.get(i) == Some(an_enum::Qux));
266266
}
267-
for i in range::<uint>(10,20) {
267+
for i in range::<u32>(10,20) {
268268
assert!(enum_list_reader.get(i) == Some(an_enum::Bar));
269269
}
270270

src/capnp/arena.rs

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ pub type SegmentId = u32;
1515
pub struct SegmentReader {
1616
pub arena : ArenaPtr,
1717
pub ptr : *const Word,
18-
pub size : WordCount
18+
pub size : WordCount32
1919
}
2020

2121
impl SegmentReader {
@@ -45,7 +45,7 @@ impl SegmentBuilder {
4545
pub fn new(arena : *mut BuilderArena,
4646
id : SegmentId,
4747
ptr : *mut Word,
48-
size : WordCount) -> SegmentBuilder {
48+
size : WordCount32) -> SegmentBuilder {
4949
SegmentBuilder {
5050
reader : SegmentReader {
5151
arena : BuilderArenaPtr(arena),
@@ -57,21 +57,21 @@ impl SegmentBuilder {
5757
}
5858
}
5959

60-
pub fn get_word_offset_to(&mut self, ptr : *mut Word) -> WordCount {
60+
pub fn get_word_offset_to(&mut self, ptr : *mut Word) -> WordCount32 {
6161
let this_addr : uint = self.reader.ptr.to_uint();
6262
let ptr_addr : uint = ptr.to_uint();
6363
assert!(ptr_addr >= this_addr);
6464
let result = (ptr_addr - this_addr) / BYTES_PER_WORD;
65-
return result;
65+
return result as u32;
6666
}
6767

6868
#[inline]
69-
pub fn current_size(&self) -> WordCount {
70-
ptr_sub(self.pos, self.reader.ptr)
69+
pub fn current_size(&self) -> WordCount32 {
70+
ptr_sub(self.pos, self.reader.ptr) as u32
7171
}
7272

7373
#[inline]
74-
pub fn allocate(&mut self, amount : WordCount) -> Option<*mut Word> {
74+
pub fn allocate(&mut self, amount : WordCount32) -> Option<*mut Word> {
7575
if amount > self.reader.size - self.current_size() {
7676
return None;
7777
} else {
@@ -82,7 +82,7 @@ impl SegmentBuilder {
8282
}
8383

8484
#[inline]
85-
pub fn get_ptr_unchecked(&self, offset : WordCount) -> *mut Word {
85+
pub fn get_ptr_unchecked(&self, offset : WordCount32) -> *mut Word {
8686
unsafe {
8787
::std::mem::transmute(self.reader.ptr.offset(offset as int))
8888
}
@@ -119,7 +119,7 @@ impl ReaderArena {
119119
segment0 : SegmentReader {
120120
arena : Null,
121121
ptr : unsafe { segments[0].unsafe_get(0) },
122-
size : segments[0].len()
122+
size : segments[0].len() as u32
123123
},
124124
more_segments : Vec::new(),
125125
cap_table : Vec::new(),
@@ -137,7 +137,7 @@ impl ReaderArena {
137137
let segment_reader = SegmentReader {
138138
arena : arena_ptr,
139139
ptr : unsafe { segment.unsafe_get(0) },
140-
size : segment.len()
140+
size : segment.len() as u32
141141
};
142142
more_segment_readers.push(segment_reader);
143143
}
@@ -167,7 +167,7 @@ pub struct BuilderArena {
167167
pub more_segments : Vec<Box<SegmentBuilder>>,
168168
pub allocation_strategy : message::AllocationStrategy,
169169
pub owned_memory : Vec<*mut Word>,
170-
pub next_size : uint,
170+
pub next_size : u32,
171171
pub cap_table : Vec<Option<Box<ClientHook+Send>>>,
172172
pub fail_fast : bool,
173173
}
@@ -181,7 +181,7 @@ impl Drop for BuilderArena {
181181
}
182182

183183
pub enum FirstSegment<'a> {
184-
NumWords(uint),
184+
NumWords(u32),
185185
ZeroedWords(&'a mut [Word])
186186
}
187187

@@ -191,15 +191,15 @@ impl BuilderArena {
191191
first_segment : FirstSegment,
192192
fail_fast : bool) -> Box<BuilderArena> {
193193

194-
let (first_segment, num_words, owned_memory) : (*mut Word, uint, Vec<*mut Word>) = unsafe {
194+
let (first_segment, num_words, owned_memory) : (*mut Word, u32, Vec<*mut Word>) = unsafe {
195195
match first_segment {
196196
NumWords(n) => {
197197
let ptr = ::std::mem::transmute(
198198
libc::calloc(n as libc::size_t,
199199
BYTES_PER_WORD as libc::size_t));
200200
(ptr, n, vec!(ptr))
201201
}
202-
ZeroedWords(w) => (w.as_mut_ptr(), w.len(), Vec::new())
202+
ZeroedWords(w) => (w.as_mut_ptr(), w.len() as u32, Vec::new())
203203
}};
204204

205205
let mut result = box BuilderArena {
@@ -225,7 +225,7 @@ impl BuilderArena {
225225
result
226226
}
227227

228-
pub fn allocate_owned_memory(&mut self, minimum_size : WordCount) -> (*mut Word, WordCount) {
228+
pub fn allocate_owned_memory(&mut self, minimum_size : WordCount32) -> (*mut Word, WordCount32) {
229229
let size = ::std::cmp::max(minimum_size, self.next_size);
230230
let new_words : *mut Word = unsafe {
231231
::std::mem::transmute(libc::calloc(size as libc::size_t,
@@ -242,7 +242,7 @@ impl BuilderArena {
242242

243243

244244
#[inline]
245-
pub fn allocate(&mut self, amount : WordCount) -> (*mut SegmentBuilder, *mut Word) {
245+
pub fn allocate(&mut self, amount : WordCount32) -> (*mut SegmentBuilder, *mut Word) {
246246
unsafe {
247247
match self.segment0.allocate(amount) {
248248
Some(result) => { return ((&mut self.segment0) as *mut SegmentBuilder, result) }
@@ -285,18 +285,18 @@ impl BuilderArena {
285285
if self.more_segments.len() == 0 {
286286
::std::slice::raw::buf_as_slice::<Word, T>(
287287
self.segment0.reader.ptr,
288-
self.segment0.current_size(),
288+
self.segment0.current_size() as uint,
289289
|v| cont([v]) )
290290
} else {
291291
let mut result = Vec::new();
292292
result.push(::std::mem::transmute(
293293
::std::raw::Slice { data : self.segment0.reader.ptr,
294-
len : self.segment0.current_size()}));
294+
len : self.segment0.current_size() as uint}));
295295

296296
for seg in self.more_segments.iter() {
297297
result.push(::std::mem::transmute(
298298
::std::raw::Slice { data : seg.reader.ptr,
299-
len : seg.current_size()}));
299+
len : seg.current_size() as uint}));
300300
}
301301
cont(result.as_slice())
302302
}

src/capnp/blob.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,11 @@ pub mod text {
1212
static EMPTY : &'static str = "";
1313

1414
// len does not include the required null terminator at the end
15-
pub fn new_reader<'a>(p : *const u8, len : uint) -> Option<Reader<'a>> {
15+
pub fn new_reader<'a>(p : *const u8, len : u32) -> Option<Reader<'a>> {
1616
// XXX The empty case is special and I don't know why.
1717
if len == 0 { return Some(EMPTY); }
1818
let v : &'a [u8] =
19-
unsafe { std::mem::transmute(std::raw::Slice { data: p, len: len }) };
19+
unsafe { std::mem::transmute(std::raw::Slice { data: p, len: len as uint}) };
2020
std::str::from_utf8(v)
2121
}
2222

@@ -27,8 +27,8 @@ pub mod text {
2727

2828
impl <'a> Builder <'a> {
2929

30-
pub fn new<'b>(p : *mut u8, len : uint) -> Builder<'b> {
31-
Builder { ptr : p, len : len}
30+
pub fn new<'b>(p : *mut u8, len : u32) -> Builder<'b> {
31+
Builder { ptr : p, len : len as uint}
3232
}
3333

3434
pub fn as_mut_bytes(&self) -> &'a mut [u8] {
@@ -47,18 +47,18 @@ pub mod data {
4747

4848
pub type Reader<'a> = &'a [u8];
4949

50-
pub fn new_reader<'a>(p : *const u8, len : uint) -> Reader<'a> {
50+
pub fn new_reader<'a>(p : *const u8, len : u32) -> Reader<'a> {
5151
unsafe {
52-
let v = std::raw::Slice { data: p, len: len };
52+
let v = std::raw::Slice { data: p, len: len as uint};
5353
std::mem::transmute(v)
5454
}
5555
}
5656

5757
pub type Builder<'a> = &'a mut [u8];
5858

59-
pub fn new_builder<'a>(p : *mut u8, len : uint) -> Builder<'a> {
59+
pub fn new_builder<'a>(p : *mut u8, len : u32) -> Builder<'a> {
6060
unsafe {
61-
let v = std::raw::Slice { data: p as *const u8, len: len };
61+
let v = std::raw::Slice { data: p as *const u8, len: len as uint};
6262
std::mem::transmute(v)
6363
}
6464
}

src/capnp/common.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ pub fn allocate_zeroed_words(size : WordCount) -> ::std::vec::Vec<Word> {
7272
pub struct MessageSize {
7373
//# Size of a message. Every struct type has a method `.total_size()` that returns this.
7474
pub word_count : u64,
75-
pub cap_count : uint
75+
pub cap_count : u32
7676
}
7777

7878
impl MessageSize {

0 commit comments

Comments
 (0)