Skip to content

Commit fb192d9

Browse files
committed
all: replace []byte with []u8
1 parent 0527ac6 commit fb192d9

File tree

164 files changed

+533
-533
lines changed

Some content is hidden

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

164 files changed

+533
-533
lines changed

cmd/tools/bench/wyhash.v

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ fn main() {
1414
mut checksum := u64(0)
1515
mut start_pos := 0
1616
mut bgenerating := benchmark.start()
17-
mut bytepile := []byte{}
17+
mut bytepile := []u8{}
1818
for _ in 0 .. sample_size * max_str_len {
1919
bytepile << u8(rand.int_in_range(40, 125) or { 40 })
2020
}

cmd/tools/vast/vast.v

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2209,7 +2209,7 @@ fn (t Tree) array_node_int(nodes []int) &Node {
22092209
return arr
22102210
}
22112211

2212-
fn (t Tree) array_node_u8(nodes []byte) &Node {
2212+
fn (t Tree) array_node_u8(nodes []u8) &Node {
22132213
mut arr := new_array()
22142214
for node in nodes {
22152215
arr.add_item(t.number_node(node))

cmd/tools/vbin2v.v

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ fn (context Context) footer() string {
4646
return ')\n'
4747
}
4848

49-
fn (context Context) file2v(bname string, fbytes []byte, bn_max int) string {
49+
fn (context Context) file2v(bname string, fbytes []u8, bn_max int) string {
5050
mut sb := strings.new_builder(1000)
5151
bn_diff_len := bn_max - bname.len
5252
sb.write_string('\t${bname}_len' + ' '.repeat(bn_diff_len - 4) + ' = $fbytes.len\n')
@@ -73,7 +73,7 @@ fn (context Context) file2v(bname string, fbytes []byte, bn_max int) string {
7373
return sb.str()
7474
}
7575

76-
fn (context Context) bname_and_bytes(file string) ?(string, []byte) {
76+
fn (context Context) bname_and_bytes(file string) ?(string, []u8) {
7777
fname := os.file_name(file)
7878
fname_escaped := fname.replace_each(['.', '_', '-', '_'])
7979
byte_name := '$context.prefix$fname_escaped'.to_lower()
@@ -120,7 +120,7 @@ fn main() {
120120
if context.write_file != '' && os.file_ext(context.write_file) !in ['.vv', '.v'] {
121121
context.write_file += '.v'
122122
}
123-
mut file_byte_map := map[string][]byte{}
123+
mut file_byte_map := map[string][]u8{}
124124
for file in real_files {
125125
bname, fbytes := context.bname_and_bytes(file) or {
126126
eprintln(err.msg())

examples/net_udp_server_and_client.v

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ fn main() {
99
println('------------------------------------------')
1010
is_server := '-l' in os.args
1111
port := cmdline.option(os.args, '-p', '40001').int()
12-
mut buf := []byte{len: 100}
12+
mut buf := []u8{len: 100}
1313
if is_server {
1414
println('UDP echo server, listening for udp packets on port: $port')
1515
mut c := net.listen_udp(':$port') ?

examples/pendulum-simulation/modules/sim/img/ppm.v

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,14 +35,14 @@ pub fn (s ImageSettings) to_grid_settings() sim.GridSettings {
3535
pub struct PPMWriter {
3636
mut:
3737
file os.File
38-
cache []byte
38+
cache []u8
3939
cache_size int
4040
}
4141

4242
pub fn ppm_writer_for_fname(fname string, settings ImageSettings) ?&PPMWriter {
4343
mut writer := &PPMWriter{
4444
cache_size: settings.cache_size
45-
cache: []byte{cap: settings.cache_size}
45+
cache: []u8{cap: settings.cache_size}
4646
}
4747
writer.start_for_file(fname, settings) ?
4848
return writer

examples/sokol/06_obj_viewer/modules/obj/util.v

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,10 @@ pub fn read_lines_from_file(file_path string) []string {
2323
return rows
2424
}
2525

26-
// read a file as []byte
27-
pub fn read_bytes_from_file(file_path string) []byte {
26+
// read a file as []u8
27+
pub fn read_bytes_from_file(file_path string) []u8 {
2828
mut path := ''
29-
mut buffer := []byte{}
29+
mut buffer := []u8{}
3030
$if android {
3131
path = 'models/' + file_path
3232
buffer = os.read_apk_asset(path) or {

examples/viewer/view.v

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -215,9 +215,9 @@ fn (mut app App) read_bytes(path string) bool {
215215
return true
216216
}
217217

218-
// read a file as []byte
219-
pub fn read_bytes_from_file(file_path string) []byte {
220-
mut buffer := []byte{}
218+
// read a file as []u8
219+
pub fn read_bytes_from_file(file_path string) []u8 {
220+
mut buffer := []u8{}
221221
buffer = os.read_bytes(file_path) or {
222222
eprintln('ERROR: Texure file: [$file_path] NOT FOUND.')
223223
exit(0)

vlib/bitfield/bitfield.v

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ const (
2626

2727
// from_bytes converts a byte array into a bitfield.
2828
// [0x0F, 0x01] => 0000 1111 0000 0001
29-
pub fn from_bytes(input []byte) BitField {
29+
pub fn from_bytes(input []u8) BitField {
3030
mut output := new(input.len * 8)
3131
for i, b in input {
3232
mut ob := u8(0)
@@ -61,7 +61,7 @@ pub fn from_bytes(input []byte) BitField {
6161

6262
// from_bytes_lowest_bits_first converts a byte array into a bitfield
6363
// [0x0F, 0x01] => 1111 0000 1000 0000
64-
pub fn from_bytes_lowest_bits_first(input []byte) BitField {
64+
pub fn from_bytes_lowest_bits_first(input []u8) BitField {
6565
mut output := new(input.len * 8)
6666
for i, b in input {
6767
output.field[i / 4] |= u32(b) << ((i % 4) * 8)

vlib/builtin/array.v

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -839,7 +839,7 @@ pub fn (a []string) str() string {
839839

840840
// hex returns a string with the hexadecimal representation
841841
// of the byte elements of the array.
842-
pub fn (b []byte) hex() string {
842+
pub fn (b []u8) hex() string {
843843
mut hex := unsafe { malloc_noscan(b.len * 2 + 1) }
844844
mut dst_i := 0
845845
for i in b {
@@ -865,7 +865,7 @@ pub fn (b []byte) hex() string {
865865
// Returns the number of elements copied.
866866
// NOTE: This is not an `array` method. It is a function that takes two arrays of bytes.
867867
// See also: `arrays.copy`.
868-
pub fn copy(mut dst []byte, src []byte) int {
868+
pub fn copy(mut dst []u8, src []u8) int {
869869
min := if dst.len < src.len { dst.len } else { src.len }
870870
if min > 0 {
871871
unsafe { vmemmove(&u8(dst.data), src.data, min) }
@@ -913,10 +913,10 @@ pub fn (a array) pointers() []voidptr {
913913
return res
914914
}
915915

916-
// vbytes on`voidptr` makes a V []byte structure from a C style memory buffer.
916+
// vbytes on`voidptr` makes a V []u8 structure from a C style memory buffer.
917917
// NOTE: the data is reused, NOT copied!
918918
[unsafe]
919-
pub fn (data voidptr) vbytes(len int) []byte {
919+
pub fn (data voidptr) vbytes(len int) []u8 {
920920
res := array{
921921
element_size: 1
922922
data: data
@@ -926,9 +926,9 @@ pub fn (data voidptr) vbytes(len int) []byte {
926926
return res
927927
}
928928

929-
// vbytes on `&byte` makes a V []byte structure from a C style memory buffer.
929+
// vbytes on `&byte` makes a V []u8 structure from a C style memory buffer.
930930
// NOTE: the data is reused, NOT copied!
931931
[unsafe]
932-
pub fn (data &byte) vbytes(len int) []byte {
932+
pub fn (data &byte) vbytes(len int) []u8 {
933933
return unsafe { voidptr(data).vbytes(len) }
934934
}

vlib/builtin/int.v

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -525,9 +525,9 @@ pub fn (c u8) is_capital() bool {
525525
}
526526

527527
// clone clones the byte array, and returns the newly created copy.
528-
pub fn (b []u8) clone() []byte {
529-
mut res := []byte{len: b.len}
530-
// mut res := make([]byte, {repeat:b.len})
528+
pub fn (b []u8) clone() []u8 {
529+
mut res := []u8{len: b.len}
530+
// mut res := make([]u8, {repeat:b.len})
531531
for i in 0 .. b.len {
532532
res[i] = b[i]
533533
}

0 commit comments

Comments
 (0)