Skip to content

Commit ceec097

Browse files
committed
rename usize to uint
1 parent d5f5626 commit ceec097

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

83 files changed

+398
-398
lines changed

lib/c/src/ctypes/mod.ri

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,10 @@ public alias wchar_t := uint32;
2525
public alias intmax_t := int64;
2626
public alias uintmax_t := uint64;
2727

28-
public alias size_t := usize;
28+
public alias size_t := uint;
2929
public alias ptrdiff_t := int;
3030
public alias intptr_t := int;
31-
public alias uintptr_t := usize;
31+
public alias uintptr_t := uint;
3232
public alias ssize_t := int;
3333

3434
public alias pid_t := int32;
@@ -37,4 +37,4 @@ public alias ino_t := uint64;
3737
public alias dev_t := uint64;
3838
public alias uid_t := uint32;
3939
public alias gid_t := uint32;
40-
public alias mode_t := usize;
40+
public alias mode_t := uint;

lib/c/src/libc/dirent.ri

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
// be found in the LICENSE file.
44

55
public struct dirent {
6-
public d_ino: usize;
7-
public d_off: usize;
6+
public d_ino: uint;
7+
public d_off: uint;
88
public d_reclen: uint16;
99
public d_type: uint8;
1010
public d_name: [256]uint8;

lib/c/src/libc/stat.ri

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import { * } from c/ctypes;
99
public struct Stat {
1010
public dev: dev_t;
1111
public ino: ino_t;
12-
public nlink: usize;
12+
public nlink: uint;
1313

1414
public mode: uint32;
1515
public uid: uid_t;
@@ -31,5 +31,5 @@ extern (C) {
3131
public func stat(__file: [&]uint8, __buf: &mut Stat) -> int32;
3232
public func lstat(file: [&]uint8, buf: &mut Stat) -> int32;
3333

34-
public func mkdir(path: [&]uint8, mode: usize) -> int32;
34+
public func mkdir(path: [&]uint8, mode: uint) -> int32;
3535
}

lib/c/src/libc/stdio.ri

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44

55
import { * } from c/ctypes;
66

7-
public const MAX_PATH_LEN: usize := 4096;
8-
public const MAX_NAME_LEN: usize := 255;
7+
public const MAX_PATH_LEN: uint := 4096;
8+
public const MAX_NAME_LEN: uint := 255;
99

1010
public const STDIN_FILENO := 0;
1111
public const STDOUT_FILENO := 1;
@@ -97,13 +97,13 @@ extern (C) {
9797
public func ferror(stream: &FILE) -> int32;
9898
public func fseek(stream: &mut FILE, offset: uint64, whence: int32) -> int32;
9999
public func ftell(stream: &mut FILE) -> int64;
100-
public func fread(ptr: rawptr, size: usize, nitems: usize, stream: &mut FILE) -> usize;
100+
public func fread(ptr: rawptr, size: uint, nitems: uint, stream: &mut FILE) -> uint;
101101
public func fputc(c: int32, stream: &mut FILE) -> int32;
102102
public func fputs(s: [&]uint8, stream: &mut FILE) -> int32;
103103
public func fprintf(stream: &mut FILE, fmt: [&]uint8, ...) -> int32;
104-
public func fwrite(ptr: rawptr, size: usize, nobj: usize, stream: &mut FILE) -> usize;
104+
public func fwrite(ptr: rawptr, size: uint, nobj: uint, stream: &mut FILE) -> uint;
105105
public func fflush(stream: &mut FILE) -> int32;
106-
public func fgets(s: [&]mut uint8, n: usize, stream: &mut FILE) -> int32;
106+
public func fgets(s: [&]mut uint8, n: uint, stream: &mut FILE) -> int32;
107107
public func fclose(stream: &mut FILE) -> int32;
108108
public func fileno(stream: &FILE) -> int32;
109109
public func rewind(stream: &mut FILE);
@@ -115,5 +115,5 @@ extern (C) {
115115
public func popen(cmd: [&]uint8, modes: [&]uint8) -> ?&mut FILE;
116116
public func pclose(stream: &mut FILE) -> int32;
117117

118-
public func getline(lineptr: &?[&]uint8, n: &usize, stream: &mut FILE) -> int;
118+
public func getline(lineptr: &?[&]uint8, n: &uint, stream: &mut FILE) -> int;
119119
}

lib/c/src/libc/stdlib.ri

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,9 @@ extern (C) {
2626
public func strtoul(nptr: [&]uint8, endptr: ?[&]uint8, base: int32) -> uint64;
2727
public func strtoull(nptr: [&]uint8, endptr: ?[&]uint8, base: int32) -> uint64;
2828

29-
public func malloc(size: usize) -> ?rawptr;
30-
public func calloc(nobj: usize, size: usize) -> ?rawptr;
31-
public func realloc(p: ?rawptr, size: usize) -> ?rawptr;
29+
public func malloc(size: uint) -> ?rawptr;
30+
public func calloc(nobj: uint, size: uint) -> ?rawptr;
31+
public func realloc(p: ?rawptr, size: uint) -> ?rawptr;
3232
public func free(p: rawptr);
3333

3434
public func getenv(name: [&]uint8) -> ?[&]mut uint8;

lib/c/src/libc/string.ri

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@
33
// be found in the LICENSE file.
44

55
extern (C) {
6-
public func memchr(cx: rawptr, c: int32, n: usize) -> ?rawptr;
7-
public func memcmp(cx: rawptr, ct: rawptr, n: usize) -> int32;
8-
public func memcpy(dest: rawptr, src: rawptr, n: usize) -> ?rawptr;
9-
public func memmove(dest: rawptr, src: rawptr, n: usize) -> ?rawptr;
10-
public func memset(dest: rawptr, c: int32, n: usize) -> ?rawptr;
6+
public func memchr(cx: rawptr, c: int32, n: uint) -> ?rawptr;
7+
public func memcmp(cx: rawptr, ct: rawptr, n: uint) -> int32;
8+
public func memcpy(dest: rawptr, src: rawptr, n: uint) -> ?rawptr;
9+
public func memmove(dest: rawptr, src: rawptr, n: uint) -> ?rawptr;
10+
public func memset(dest: rawptr, c: int32, n: uint) -> ?rawptr;
1111

1212
public func strerror(code: int32) -> ?[&]mut uint8;
13-
public func strlen(cs: ?[&]uint8) -> usize;
13+
public func strlen(cs: ?[&]uint8) -> uint;
1414
public func strstr(needle: ?[&]uint8, haystack: ?[&]uint8) -> ?[&]uint8;
1515
}

lib/c/src/libc/unistd.ri

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,14 @@ extern (C) {
1212

1313
public func isatty(fd: int32) -> int32;
1414

15-
public func write(fd: int32, buf: rawptr, count: usize) -> int;
16-
public func read(fildes: int32, buf: rawptr, nbyte: usize) -> int;
15+
public func write(fd: int32, buf: rawptr, count: uint) -> int;
16+
public func read(fildes: int32, buf: rawptr, nbyte: uint) -> int;
1717

1818
public func rmdir(path: [&]uint8) -> int32;
1919
public func chdir(path: [&]uint8) -> int32;
20-
public func getcwd(buf: [&]uint8, size: usize) -> ?[&]uint8;
20+
public func getcwd(buf: [&]uint8, size: uint) -> ?[&]uint8;
2121

22-
public func readlink(path: [&]uint8, buf: [&]uint8, size: usize) -> int;
22+
public func readlink(path: [&]uint8, buf: [&]uint8, size: uint) -> int;
2323

2424
#if _LINUX_
2525
public func get_nprocs() -> int32;

lib/c/src/wyhash.ri

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ extern (C) {
1313
func _wymix(a: uint64, b: uint64) -> uint64;
1414
func _wyr8(p: &uint8) -> uint64;
1515
func _wyr4(p: &uint8) -> uint64;
16-
func _wyr3(p: &uint8, k: usize) -> uint64;
17-
public func wyhash(key: rawptr, len: usize, seed: uint64, secret: &uint64) -> uint64;
16+
func _wyr3(p: &uint8, k: uint) -> uint64;
17+
public func wyhash(key: rawptr, len: uint, seed: uint64, secret: &uint64) -> uint64;
1818
public func wyhash64(a: uint64, b: uint64) -> uint64;
1919
func wyrand(seed: &uint64) -> uint64;
2020
func wy2u01(r: uint64) -> float64;

lib/core/src/StaticBuffer.c.ri

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import c/libc;
66

77
struct StaticBuffer {
88
buf: [25]mut uint8;
9-
mut len: usize;
9+
mut len: uint;
1010

1111
public func push(mut self, byte: uint8) {
1212
if self.len > self.buf.len {

lib/core/src/StringBuilder.c.ri

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ public struct StringBuilder < Stringable {
1010

1111
/// Returns a string builder with capacity `cap`.
1212
#[inline]
13-
public func new(cap: usize := 0) -> Self {
13+
public func new(cap: uint := 0) -> Self {
1414
return Self(unsafe { Vector.new(@size_of(uint8), cap) });
1515
}
1616

@@ -40,7 +40,7 @@ public struct StringBuilder < Stringable {
4040
}
4141

4242
#[unsafe]
43-
public func write_raw_with_len(mut self, s: [&]uint8, len: usize) {
43+
public func write_raw_with_len(mut self, s: [&]uint8, len: uint) {
4444
self.inner.reserve(self.inner.len + len);
4545
mem_copy(
4646
unsafe { @ptr_add(self.inner.ptr, self.inner.elem_size * self.inner.len) },
@@ -90,7 +90,7 @@ public struct StringBuilder < Stringable {
9090

9191
/// Returns the number of runes contained in `self`.
9292
#[inline]
93-
public func runes_count(self) -> usize {
93+
public func runes_count(self) -> uint {
9494
return cstr_runes_count(unsafe { @as([&]uint8, self.inner.ptr) }, self.inner.len);
9595
}
9696

@@ -100,12 +100,12 @@ public struct StringBuilder < Stringable {
100100
}
101101

102102
#[inline]
103-
public func len(self) -> usize {
103+
public func len(self) -> uint {
104104
return self.inner.len;
105105
}
106106

107107
#[inline]
108-
public func cap(self) -> usize {
108+
public func cap(self) -> uint {
109109
return self.inner.cap;
110110
}
111111

lib/core/src/StringFormatter.ri

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@
44

55
public struct StringFormatter {
66
buf: string;
7-
mut i: usize;
7+
mut i: uint;
88
mut res: StringBuilder;
99

1010
func fmt(mut self, args: ...Stringable) -> string {
1111
self.res = StringBuilder.new(self.buf.len);
12-
mut args_idx: usize := 0;
12+
mut args_idx: uint := 0;
1313
while self.i < self.buf.len : self.i += 1 {
1414
b := unsafe { self.buf.ptr[self.i] };
1515
b2 := if self.i + 1 < self.buf.len unsafe { self.buf.ptr[self.i + 1] } else { 0 };
@@ -35,15 +35,15 @@ public struct StringFormatter {
3535
if has_fwidth and fwidth > 0 {
3636
value_len := @as(int, value.len);
3737
if value_len <= fwidth {
38-
self.res.write_string(" ".repeat(@as(usize, fwidth - value_len)));
38+
self.res.write_string(" ".repeat(@as(uint, fwidth - value_len)));
3939
}
4040
}
4141
self.res.write_string(value);
4242
if has_fwidth and fwidth < 0 {
4343
fwidth = -fwidth;
4444
value_len := @as(int, value.len);
4545
if value_len <= fwidth {
46-
self.res.write_string(" ".repeat(@as(usize, fwidth - value_len)));
46+
self.res.write_string(" ".repeat(@as(uint, fwidth - value_len)));
4747
}
4848
}
4949
if !has_fwidth {
@@ -77,15 +77,15 @@ public struct StringFormatter {
7777
if has_fwidth and fwidth > 0 {
7878
value_len := @as(int, value.len);
7979
if value_len <= fwidth {
80-
self.res.write_string(" ".repeat(@as(usize, fwidth - value_len)));
80+
self.res.write_string(" ".repeat(@as(uint, fwidth - value_len)));
8181
}
8282
}
8383
self.res.write_string(value);
8484
if has_fwidth and fwidth < 0 {
8585
fwidth = -fwidth;
8686
value_len := @as(int, value.len);
8787
if value_len <= fwidth {
88-
self.res.write_string(" ".repeat(@as(usize, fwidth - value_len)));
88+
self.res.write_string(" ".repeat(@as(uint, fwidth - value_len)));
8989
}
9090
}
9191
} else {

lib/core/src/TokenIterator.ri

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
public struct TokenIterator {
66
buffer: string;
77
delimiter_bytes: []uint8;
8-
mut index: usize;
8+
mut index: uint;
99

1010
/// Returns a slice of the current token, or none if tokenization is
1111
/// complete, and advances to the next token.
@@ -35,7 +35,7 @@ public struct TokenIterator {
3535
/// Returns a slice of the remaining bytes. Does not affect iterator state.
3636
public func rest(&self) -> string {
3737
// move to beginning of token
38-
mut index: usize := self.index;
38+
mut index: uint := self.index;
3939
while index < self.buffer.len and self.is_split_byte(self.buffer[index])
4040
: index += 1 {}
4141
return self.buffer[index..];

lib/core/src/Vector.c.ri

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -5,46 +5,46 @@
55
#[boxed]
66
struct Vector {
77
mut ptr: rawptr;
8-
elem_size: usize;
9-
mut len: usize;
10-
mut cap: usize;
8+
elem_size: uint;
9+
mut len: uint;
10+
mut cap: uint;
1111
is_ref: bool;
1212

1313
#[unsafe; inline]
14-
func new(elem_size: usize, cap: usize) -> Self {
14+
func new(elem_size: uint, cap: uint) -> Self {
1515
return Self(internal_zeroed(cap * elem_size), elem_size, 0, cap);
1616
}
1717

1818
#[unsafe; inline]
19-
func new_with_len(elem_size: usize, len: usize, cap: usize) -> Self {
19+
func new_with_len(elem_size: uint, len: uint, cap: uint) -> Self {
2020
return Self(internal_zeroed(cap * elem_size), elem_size, len, cap);
2121
}
2222

2323
#[unsafe]
24-
func from_array(arr: rawptr, elem_size: usize, len: usize) -> Self {
24+
func from_array(arr: rawptr, elem_size: uint, len: uint) -> Self {
2525
vec := Self(internal_zeroed(len * elem_size), elem_size, len, len);
2626
mem_copy(vec.ptr, arr, len * elem_size);
2727
return vec;
2828
}
2929

3030
#[unsafe; inline]
31-
func from_array_no_alloc(arr: rawptr, elem_size: usize, len: usize) -> Self {
31+
func from_array_no_alloc(arr: rawptr, elem_size: uint, len: uint) -> Self {
3232
return Self(arr, elem_size, len, len, is_ref: true);
3333
}
3434

3535
#[unsafe; inline]
36-
func raw_get(self, idx: usize) -> rawptr {
36+
func raw_get(self, idx: uint) -> rawptr {
3737
return unsafe { @ptr_add(@as([&]mut uint8, self.ptr), idx * self.elem_size) };
3838
}
3939

40-
func get(self, idx: usize) -> rawptr {
40+
func get(self, idx: uint) -> rawptr {
4141
if idx >= self.len {
4242
process_panic("vector index out of range (index: {}, len: {})", idx, self.len);
4343
}
4444
return unsafe { @ptr_add(@as([&]mut uint8, self.ptr), idx * self.elem_size) };
4545
}
4646

47-
func set(self, idx: usize, val: rawptr) {
47+
func set(self, idx: uint, val: rawptr) {
4848
if idx >= self.len {
4949
process_panic("vector index out of range (index: {}, len: {})", idx, self.len);
5050
}
@@ -81,7 +81,7 @@ struct Vector {
8181
/// NOTE: This function does NOT operate in-place. Internally, it creates a copy
8282
/// of the vector, skipping over `size` elements starting at `i`, and then points
8383
/// the original variable to the new memory location.
84-
public func delete(mut self, i: usize, size: usize := 1, no_slices: bool := false) {
84+
public func delete(mut self, i: uint, size: uint := 1, no_slices: bool := false) {
8585
if i + size > self.len {
8686
end_idx := if size == 1 { "..{}".fmt(i + size) } else { "" };
8787
process_panic(
@@ -93,7 +93,7 @@ struct Vector {
9393
// `self.delete(0)` should move (2-0-1) elements = 1 element (the 34) forward
9494
old_ptr := self.ptr;
9595
new_size := self.len - size;
96-
new_cap: usize := if new_size == 0 { 1 } else { new_size };
96+
new_cap: uint := if new_size == 0 { 1 } else { new_size };
9797
self.ptr = mem_zeroed(new_cap * self.elem_size) catch @unreachable();
9898
mem_copy(self.ptr, old_ptr, i * self.elem_size);
9999
unsafe {
@@ -112,7 +112,7 @@ struct Vector {
112112

113113
/// Trims the array length to `index` without modifying the allocated data.
114114
/// If `index` is greater than `len` nothing will be changed.
115-
public func trim(mut self, index: usize) {
115+
public func trim(mut self, index: uint) {
116116
if index < self.len {
117117
self.len = index;
118118
}
@@ -139,7 +139,7 @@ struct Vector {
139139
return !(self == rhs);
140140
}
141141

142-
func reserve(mut self, required: usize) {
142+
func reserve(mut self, required: uint) {
143143
if required <= self.cap {
144144
return;
145145
}
@@ -154,7 +154,7 @@ struct Vector {
154154
self.cap = cap;
155155
}
156156

157-
func slice(self, start: usize, end: usize) -> Self {
157+
func slice(self, start: uint, end: uint) -> Self {
158158
if start > end or end > self.len {
159159
process_panic(
160160
"slice index out of range (range: {}..{}, len: {})", start, end, self.len
@@ -171,7 +171,7 @@ struct Vector {
171171
}
172172

173173
#[inline]
174-
func slice_from(self, start: usize) -> Self {
174+
func slice_from(self, start: uint) -> Self {
175175
return self.slice(start, self.len);
176176
}
177177

0 commit comments

Comments
 (0)