From fbb9e65c0f25de412ce4f3978422f59b747e463b Mon Sep 17 00:00:00 2001 From: Alexander Medvednikov Date: Fri, 15 Apr 2022 18:25:45 +0300 Subject: [PATCH] all: ~500 more byte=>u8 --- cmd/tools/vast/cjson.v | 6 +- examples/sokol/01_cubes/cube.v | 2 +- .../sokol/06_obj_viewer/modules/obj/rend.v | 2 +- .../sokol/particles/modules/particle/color.v | 8 +- examples/sokol/sounds/melody.v | 2 +- examples/sokol/sounds/wav_player.v | 18 +- examples/viewer/view.v | 2 +- vlib/arrays/arrays_test.v | 4 +- vlib/builtin/array.v | 4 +- vlib/builtin/int.v | 2 +- vlib/builtin/int_test.v | 14 +- vlib/builtin/js/map_test.js.v | 4 +- vlib/builtin/js/string_test.js.v | 4 +- .../old/.checks/linuxsys/linuxsys.v | 170 ++++++++++++------ .../linux_bare/old/.checks/string/string.v | 70 ++++---- vlib/builtin/map_test.v | 6 +- vlib/builtin/string.v | 4 +- vlib/builtin/string_test.v | 4 +- vlib/clipboard/clipboard_darwin.c.v | 2 +- vlib/clipboard/x11/clipboard.c.v | 8 +- vlib/context/context.v | 14 +- vlib/darwin/darwin.v | 6 +- vlib/dl/dl_windows.c.v | 2 +- vlib/encoding/base58/alphabet.v | 2 +- vlib/encoding/base64/base64.c.v | 6 +- vlib/encoding/base64/base64.v | 4 +- vlib/encoding/csv/reader.v | 10 +- vlib/encoding/csv/writer.v | 2 +- vlib/encoding/hex/hex.v | 2 +- vlib/encoding/utf8/utf8.v | 4 +- vlib/flag/flag.v | 30 ++-- vlib/fontstash/fontstash.c.v | 2 +- vlib/fontstash/fontstash_funcs.c.v | 2 +- vlib/fontstash/fontstash_structs.c.v | 8 +- vlib/gg/gg.c.v | 2 +- vlib/gg/gg.js.v | 2 +- vlib/gg/image.c.v | 6 +- vlib/gx/color.v | 12 +- vlib/hash/fnv1a/fnv1a.v | 4 +- vlib/hash/wyhash.c.v | 4 +- vlib/hash/wyhash.v | 6 +- vlib/math/bits/bits.v | 11 +- vlib/mysql/_cdefs.c.v | 44 ++--- vlib/mysql/orm.v | 2 +- vlib/mysql/result.v | 2 +- vlib/mysql/stmt.c.v | 2 +- vlib/mysql/utils.v | 4 +- vlib/net/address_android.c.v | 2 +- vlib/net/address_darwin.c.v | 18 +- vlib/net/address_default.c.v | 6 +- vlib/net/address_dragonfly.c.v | 18 +- vlib/net/address_freebsd.c.v | 18 +- vlib/net/address_linux.c.v | 2 +- vlib/net/address_netbsd.c.v | 18 +- vlib/net/address_openbsd.c.v | 18 +- vlib/net/address_windows.c.v | 2 +- vlib/net/http/chunked/dechunk.v | 2 +- vlib/net/http/header.v | 4 +- vlib/net/net_windows.c.v | 6 +- vlib/net/openssl/ssl_connection.v | 2 +- vlib/net/tcp.v | 4 +- vlib/net/udp.v | 4 +- vlib/net/unix/stream_nix.v | 4 +- vlib/net/urllib/urllib.v | 8 +- vlib/net/websocket/io.v | 2 +- vlib/net/websocket/websocket_client.v | 4 +- vlib/os/fd.c.v | 2 +- vlib/os/file.c.v | 2 +- vlib/os/file_test.v | 8 +- vlib/os/process_windows.c.v | 2 +- vlib/pg/pg.v | 16 +- vlib/picoev/picoev.v | 8 +- vlib/picohttpparser/misc.v | 2 +- vlib/picohttpparser/response.v | 6 +- vlib/rand/mt19937/mt19937.v | 2 +- vlib/rand/musl/musl_rng.v | 2 +- vlib/rand/pcg32/pcg32.v | 2 +- vlib/rand/rand.v | 4 +- vlib/rand/splitmix64/splitmix64.v | 2 +- vlib/rand/sys/system_rng.c.v | 2 +- vlib/rand/wyrand/wyrand.v | 2 +- vlib/readline/readline_linux.c.v | 6 +- vlib/regex/regex.v | 26 +-- vlib/sokol/gfx/gfx_structs.c.v | 8 +- vlib/sokol/sapp/sapp_structs.c.v | 2 +- vlib/sokol/sapp/sapp_v.c.v | 2 +- vlib/sokol/sapp/screenshot.c.v | 2 +- vlib/sokol/sfons/sfons.c.v | 2 +- vlib/sokol/sfons/sfons_funcs.c.v | 2 +- vlib/sokol/sgl/sgl.c.v | 20 +-- vlib/sokol/sgl/sgl_funcs.c.v | 20 +-- vlib/sqlite/sqlite.v | 2 +- vlib/stbi/stbi.c.v | 26 +-- vlib/strconv/atof.c.v | 6 +- vlib/strconv/atoi.v | 2 +- vlib/strconv/format.v | 2 +- vlib/strconv/format_mem.js.v | 2 +- vlib/strings/builder.c.v | 8 +- vlib/strings/strings.c.v | 2 +- vlib/strings/strings.js.v | 2 +- vlib/strings/strings.v | 2 +- vlib/sync/channel_select_2_test.v | 4 +- vlib/sync/channel_select_test.v | 2 +- vlib/sync/select_close_test.v | 2 +- vlib/szip/szip.v | 6 +- vlib/term/term_windows.c.v | 2 +- vlib/term/ui/consoleapi_windows.c.v | 2 +- vlib/term/ui/input.v | 2 +- vlib/term/ui/ui.v | 6 +- vlib/toml/ast/types.v | 2 +- vlib/toml/decoder/decoder.v | 5 +- vlib/toml/scanner/scanner.v | 5 +- vlib/toml/util/util.v | 6 +- vlib/v/ast/types.v | 7 + vlib/v/checker/str.v | 2 +- vlib/v/embed_file/embed_file.v | 8 +- vlib/v/eval/object.v | 2 +- vlib/v/fmt/comments.v | 2 +- vlib/v/gen/c/cgen.v | 2 +- vlib/v/gen/js/sourcemap/vlq/vlq.v | 4 +- vlib/v/gen/native/amd64.v | 2 +- vlib/v/scanner/scanner.v | 10 +- vlib/v/tests/assembly/asm_test.amd64.v | 2 +- vlib/v/tests/assembly/asm_test.i386.v | 2 +- vlib/v/tests/c_function_mut_param/code_test.v | 2 +- vlib/v/tests/cast_to_byte_test.v | 2 +- vlib/v/tests/comptime_for_test.v | 2 +- vlib/v/tests/comptime_if_is_test.v | 2 +- .../const_comptime_eval_before_vinit_test.v | 4 +- ..._simple_int_expressions_at_comptime_test.v | 6 +- vlib/v/tests/fixed_array_const_size_test.v | 2 +- vlib/v/tests/fixed_array_init_test.v | 2 +- vlib/v/tests/fn_high_test.v | 2 +- vlib/v/tests/fn_test.v | 2 +- .../for_t_fields_with_comptime_if_test.v | 10 +- vlib/v/tests/interface_fields_test.v | 2 +- vlib/v/tests/interface_test.v | 2 +- vlib/v/tests/multiret_with_ptrtype_test.v | 2 +- vlib/v/tests/sizeof_test.v | 2 +- vlib/v/tests/struct_embed_test.v | 4 +- ..._with_voidptr_fields_can_be_printed_test.v | 2 +- vlib/v/tests/testdata/test_array_bound.v | 4 +- vlib/v/tests/typeof_test.v | 2 +- vlib/v/tests/unsafe_test.v | 2 +- vlib/v/util/scanning.v | 4 +- vlib/v/vmod/parser.v | 6 +- vlib/x/ttf/render_bmp.v | 4 +- vlib/x/ttf/ttf.v | 2 +- 148 files changed, 545 insertions(+), 495 deletions(-) diff --git a/cmd/tools/vast/cjson.v b/cmd/tools/vast/cjson.v index 63e9f5d54..976eaaaa2 100644 --- a/cmd/tools/vast/cjson.v +++ b/cmd/tools/vast/cjson.v @@ -24,7 +24,7 @@ fn C.cJSON_CreateNull() &C.cJSON // fn C.cJSON_CreateNumber() &C.cJSON // fn C.cJSON_CreateString() &C.cJSON -fn C.cJSON_CreateRaw(&byte) &C.cJSON +fn C.cJSON_CreateRaw(&u8) &C.cJSON fn C.cJSON_IsInvalid(voidptr) bool @@ -45,13 +45,13 @@ fn C.cJSON_IsObject(voidptr) bool fn C.cJSON_IsRaw(voidptr) bool -fn C.cJSON_AddItemToObject(voidptr, &byte, voidptr) +fn C.cJSON_AddItemToObject(voidptr, &u8, voidptr) fn C.cJSON_AddItemToArray(voidptr, voidptr) fn C.cJSON_Delete(voidptr) -fn C.cJSON_Print(voidptr) &byte +fn C.cJSON_Print(voidptr) &u8 [inline] fn create_object() &C.cJSON { diff --git a/examples/sokol/01_cubes/cube.v b/examples/sokol/01_cubes/cube.v index 3ac68bbcf..2ccfef9a3 100644 --- a/examples/sokol/01_cubes/cube.v +++ b/examples/sokol/01_cubes/cube.v @@ -68,7 +68,7 @@ fn destroy_texture(sg_img gfx.Image) { } // Use only if usage: .dynamic is enabled -fn update_text_texture(sg_img gfx.Image, w int, h int, buf &byte) { +fn update_text_texture(sg_img gfx.Image, w int, h int, buf &u8) { sz := w * h * 4 mut tmp_sbc := gfx.ImageData{} tmp_sbc.subimage[0][0] = gfx.Range{ diff --git a/examples/sokol/06_obj_viewer/modules/obj/rend.v b/examples/sokol/06_obj_viewer/modules/obj/rend.v index 38d760774..d6dc8902b 100644 --- a/examples/sokol/06_obj_viewer/modules/obj/rend.v +++ b/examples/sokol/06_obj_viewer/modules/obj/rend.v @@ -18,7 +18,7 @@ import stbi /****************************************************************************** * Texture functions ******************************************************************************/ -pub fn create_texture(w int, h int, buf &byte) gfx.Image { +pub fn create_texture(w int, h int, buf &u8) gfx.Image { sz := w * h * 4 mut img_desc := gfx.ImageDesc{ width: w diff --git a/examples/sokol/particles/modules/particle/color.v b/examples/sokol/particles/modules/particle/color.v index 535e48ad7..81ac5a30f 100644 --- a/examples/sokol/particles/modules/particle/color.v +++ b/examples/sokol/particles/modules/particle/color.v @@ -5,8 +5,8 @@ module particle // * Color pub struct Color { mut: - r byte - g byte - b byte - a byte + r u8 + g u8 + b u8 + a u8 } diff --git a/examples/sokol/sounds/melody.v b/examples/sokol/sounds/melody.v index 664971d65..9eb6c4a52 100644 --- a/examples/sokol/sounds/melody.v +++ b/examples/sokol/sounds/melody.v @@ -61,7 +61,7 @@ fn graphics_frame(mut state AppState) { } [inline] -fn (mut state AppState) bsample(idx int) byte { +fn (mut state AppState) bsample(idx int) u8 { return u8(127 + state.frames[(state.gframe + idx) & 2047] * 128) } diff --git a/examples/sokol/sounds/wav_player.v b/examples/sokol/sounds/wav_player.v index 143769faf..ce06366df 100644 --- a/examples/sokol/sounds/wav_player.v +++ b/examples/sokol/sounds/wav_player.v @@ -104,15 +104,15 @@ struct RIFFChunkHeader { } struct RIFFFormat { - format_tag u16 // PCM = 1; Values other than 1 indicate some form of compression. - nchannels u16 // Nc ; 1 = mono ; 2 = stereo - sample_rate u32 // F - avg_bytes_per_second u32 // F * M*Nc - nblock_align u16 // M*Nc - bits_per_sample u16 // 8 * M - cbsize u16 // Size of the extension: 22 - valid_bits_per_sample u16 // at most 8*M - channel_mask u32 // Speaker position mask + format_tag u16 // PCM = 1; Values other than 1 indicate some form of compression. + nchannels u16 // Nc ; 1 = mono ; 2 = stereo + sample_rate u32 // F + avg_bytes_per_second u32 // F * M*Nc + nblock_align u16 // M*Nc + bits_per_sample u16 // 8 * M + cbsize u16 // Size of the extension: 22 + valid_bits_per_sample u16 // at most 8*M + channel_mask u32 // Speaker position mask sub_format [16]u8 // GUID } diff --git a/examples/viewer/view.v b/examples/viewer/view.v index c7bfce1d6..d031b4230 100644 --- a/examples/viewer/view.v +++ b/examples/viewer/view.v @@ -144,7 +144,7 @@ fn destroy_texture(sg_img gfx.Image) { } // Use only if: .dynamic is enabled -fn update_text_texture(sg_img gfx.Image, w int, h int, buf &byte) { +fn update_text_texture(sg_img gfx.Image, w int, h int, buf &u8) { sz := w * h * 4 mut tmp_sbc := gfx.ImageData{} tmp_sbc.subimage[0][0] = gfx.Range{ diff --git a/vlib/arrays/arrays_test.v b/vlib/arrays/arrays_test.v index c979dbd84..06832e930 100644 --- a/vlib/arrays/arrays_test.v +++ b/vlib/arrays/arrays_test.v @@ -283,10 +283,10 @@ fn test_copy() { } fn test_can_copy_bits() { - assert can_copy_bits() + assert can_copy_bits() assert can_copy_bits() assert can_copy_bits() - assert can_copy_bits<&byte>() + assert can_copy_bits<&u8>() // autofree needs to intercept assign assert !can_copy_bits() assert !can_copy_bits<[]int>() diff --git a/vlib/builtin/array.v b/vlib/builtin/array.v index e78254468..ff5e9594a 100644 --- a/vlib/builtin/array.v +++ b/vlib/builtin/array.v @@ -642,8 +642,8 @@ pub fn (mut a array) reverse_in_place() { mut tmp_value := malloc(a.element_size) for i in 0 .. a.len / 2 { vmemcpy(tmp_value, &u8(a.data) + i * a.element_size, a.element_size) - vmemcpy(&u8(a.data) + i * a.element_size, &u8(a.data) + - (a.len - 1 - i) * a.element_size, a.element_size) + vmemcpy(&u8(a.data) + i * a.element_size, &u8(a.data) + (a.len - 1 - i) * a.element_size, + a.element_size) vmemcpy(&u8(a.data) + (a.len - 1 - i) * a.element_size, tmp_value, a.element_size) } free(tmp_value) diff --git a/vlib/builtin/int.v b/vlib/builtin/int.v index ac0987f9c..9ad1b86d0 100644 --- a/vlib/builtin/int.v +++ b/vlib/builtin/int.v @@ -7,7 +7,7 @@ module builtin // ----- value to string functions ----- // -//type u8 = byte +// type u8 = byte type byte = u8 type i32 = int diff --git a/vlib/builtin/int_test.v b/vlib/builtin/int_test.v index 5602d07a8..cac4dc51f 100644 --- a/vlib/builtin/int_test.v +++ b/vlib/builtin/int_test.v @@ -148,21 +148,21 @@ fn test_bin() { fn test_oct() { x1 := 0o12 assert x1 == 10 - x2 := 00000o350 + x2 := 0o350 assert x2 == 232 - x3 := 000o00073 + x3 := 0o00073 assert x3 == 59 - x4 := 00000000 + x4 := 0 assert x4 == 0 - x5 := 00000195 + x5 := 195 assert x5 == 195 x6 := -0o744 assert x6 == -484 - x7 := -000o000042 + x7 := -0o000042 assert x7 == -34 - x8 := -0000112 + x8 := -112 assert x8 == -112 - x9 := -000 + x9 := -0 assert x9 == 0 } diff --git a/vlib/builtin/js/map_test.js.v b/vlib/builtin/js/map_test.js.v index 5d5c6db25..e06611527 100644 --- a/vlib/builtin/js/map_test.js.v +++ b/vlib/builtin/js/map_test.js.v @@ -181,7 +181,7 @@ fn test_various_map_value() { mut m9 := map[string]bool{} m9['test'] = true assert m9['test'] == true - mut m10 := map[string]byte{} + mut m10 := map[string]u8{} m10['test'] = u8(0) assert m10['test'] == u8(0) mut m11 := map[string]f32{} @@ -762,7 +762,7 @@ fn test_in_map_literal() { } fn test_byte_keys() { - mut m := map[byte]byte{} + mut m := map[u8]u8{} byte_max := u8(255) for i in u8(0) .. byte_max { m[i] = i diff --git a/vlib/builtin/js/string_test.js.v b/vlib/builtin/js/string_test.js.v index 3433278ee..5b0d04822 100644 --- a/vlib/builtin/js/string_test.js.v +++ b/vlib/builtin/js/string_test.js.v @@ -783,11 +783,11 @@ fn test_double_quote_inter() { assert '$a $b' == '1 2' } -fn foo(b byte) byte { +fn foo(b u8) u8 { return b - 10 } -fn filter(b byte) bool { +fn filter(b u8) bool { return b != `a` } diff --git a/vlib/builtin/linux_bare/old/.checks/linuxsys/linuxsys.v b/vlib/builtin/linux_bare/old/.checks/linuxsys/linuxsys.v index cca5cb62f..ca9951f33 100644 --- a/vlib/builtin/linux_bare/old/.checks/linuxsys/linuxsys.v +++ b/vlib/builtin/linux_bare/old/.checks/linuxsys/linuxsys.v @@ -1,31 +1,89 @@ module main -import forkedtest + +import builtin.linux_bare.old..checks.forkedtest const ( - sample_text_file1 = "" + sample_text_file1 = '' ) -fn check_fork_minimal () { +fn check_fork_minimal() { child := sys_fork() ec := 100 if child == 0 { - println("child") + println('child') sys_exit(ec) } siginfo := [ - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0] + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + ] - e := sys_waitid(.p_pid, child, intptr(siginfo.data) , .wexited, 0) + e := sys_waitid(.p_pid, child, intptr(siginfo.data), .wexited, 0) assert e == .enoerror - //println(i64_tos(buffer0,80,siginfo[Sig_index.si_code],16)) + // println(i64_tos(buffer0,80,siginfo[Sig_index.si_code],16)) assert siginfo[Sig_index.si_code] == int(Wi_si_code.cld_exited) assert siginfo[Sig_index.si_pid] == child assert siginfo[Sig_index.si_status] == ec @@ -40,7 +98,7 @@ fn check_read_write_pipe() { // sys_read // sys_close // - buffer0 := []byte{len:(128)} + buffer0 := []u8{len: (128)} buffer := byteptr(buffer0.data) fd := [-1, -1] @@ -55,9 +113,9 @@ fn check_read_write_pipe() { assert fd[0] != -1 assert fd[1] != -1 - test_data := "test_data" + test_data := 'test_data' b := test_data.len + 1 - c1, e1 := sys_write (fd[1], test_data.str, u64(b)) + c1, e1 := sys_write(fd[1], test_data.str, u64(b)) assert e1 == .enoerror assert c1 == b @@ -67,9 +125,9 @@ fn check_read_write_pipe() { assert e2 == .enoerror assert c2 == b - assert buffer[b-1] == 0 + assert buffer[b - 1] == 0 - for i in 0..b { + for i in 0 .. b { assert test_data[i] == buffer[i] } @@ -81,32 +139,32 @@ fn check_read_write_pipe() { fn check_read_file() { /* - Checks the following system calls: + Checks the following system calls: sys_read sys_write sys_close sys_open */ - buffer0 := []byte{len:(128)} + buffer0 := []u8{len: (128)} buffer := byteptr(buffer0.data) - test_file := "sample_text1.txt" - sample_text := "Do not change this text.\n" + test_file := 'sample_text1.txt' + sample_text := 'Do not change this text.\n' fd, ec := sys_open(test_file.str, .o_rdonly, 0) assert fd > 0 assert ec == .enoerror n := sample_text.len - c, e := sys_read(fd, buffer, u64(n*2)) + c, e := sys_read(fd, buffer, u64(n * 2)) assert e == .enoerror assert c == n - for i in 0..n { + for i in 0 .. n { assert sample_text[i] == buffer[i] } assert sys_close(fd) == .enoerror } fn check_open_file_fail() { - fd1, ec1 := sys_open("./nofilehere".str, .o_rdonly, 0) + fd1, ec1 := sys_open('./nofilehere'.str, .o_rdonly, 0) assert fd1 == -1 assert ec1 == .enoent } @@ -126,19 +184,20 @@ fn check_print() { */ fn check_munmap_fail() { - ec := sys_munmap(-16384,8192) + ec := sys_munmap(-16384, 8192) assert ec == .einval } fn check_mmap_one_page() { mp := int(Mm_prot.prot_read) | int(Mm_prot.prot_write) mf := int(Map_flags.map_private) | int(Map_flags.map_anonymous) - mut a, e := sys_mmap(0, u64(Linux_mem.page_size), Mm_prot(mp), Map_flags(mf), -1, 0) + mut a, e := sys_mmap(0, u64(Linux_mem.page_size), Mm_prot(mp), Map_flags(mf), -1, + 0) assert e == .enoerror assert a != byteptr(-1) - for i in 0..int(Linux_mem.page_size) { + for i in 0 .. int(Linux_mem.page_size) { b := i & 0xFF a[i] = b assert a[i] == b @@ -149,32 +208,32 @@ fn check_mmap_one_page() { } fn check_mm_pages() { - for i in 0 .. int(Linux_mem.page_size)-4 { + for i in 0 .. int(Linux_mem.page_size) - 4 { assert u32(1) == mm_pages(u64(i)) } - for i in int(Linux_mem.page_size)-3 .. (int(Linux_mem.page_size)*2)-4 { + for i in int(Linux_mem.page_size) - 3 .. (int(Linux_mem.page_size) * 2) - 4 { assert u32(2) == mm_pages(u64(i)) } - for i in (int(Linux_mem.page_size)*2)-3 .. (int(Linux_mem.page_size)*3)-4 { + for i in (int(Linux_mem.page_size) * 2) - 3 .. (int(Linux_mem.page_size) * 3) - 4 { assert u32(3) == mm_pages(u64(i)) } } -//pub fn mm_alloc(size u64) (voidptr, Errno) +// pub fn mm_alloc(size u64) (voidptr, Errno) fn check_mm_alloc() { for i in 1 .. 2000 { - size := u64(i*1000) + size := u64(i * 1000) pages := mm_pages(size) mut a, e := mm_alloc(size) assert e == .enoerror - ap := intptr(a-4) + ap := intptr(a - 4) assert *ap == int(pages) assert e == .enoerror assert !isnil(a) - if (i%111) == 0 { + if (i % 111) == 0 { for j in 0 .. int(size) { b := j & 0xFF a[j] = b @@ -189,7 +248,7 @@ fn check_mm_alloc() { } fn check_int_array_ro() { - a := [100,110,120,130] + a := [100, 110, 120, 130] assert a.len == 4 assert a[0] == 100 assert a[1] == 110 @@ -198,13 +257,13 @@ fn check_int_array_ro() { } fn check_int_array_rw() { - mut a := [-10,-11,-12,-13] + mut a := [-10, -11, -12, -13] assert a.len == 4 assert a[0] == -10 assert a[1] == -11 assert a[2] == -12 assert a[3] == -13 - for i in 0..a.len { + for i in 0 .. a.len { b := -a[i] * 10 a[i] = b assert a[i] == b @@ -213,7 +272,7 @@ fn check_int_array_rw() { } fn check_int64_array_ro() { - a := [i64(1000),1100,1200,1300,1400] + a := [i64(1000), 1100, 1200, 1300, 1400] assert a.len == 5 assert a[0] == 1000 assert a[1] == 1100 @@ -229,7 +288,7 @@ fn check_voidptr_array_ro() { voidptr(12000), voidptr(13000), voidptr(14000), - voidptr(15000) + voidptr(15000), ] assert a.len == 6 assert a[0] == voidptr(10000) @@ -247,7 +306,7 @@ fn check_voidptr_array_rw() { voidptr(-1), voidptr(-1), voidptr(-1), - voidptr(-1) + voidptr(-1), ] assert a.len == 6 @@ -277,23 +336,22 @@ fn check_voidptr_array_rw() { assert a[5] == voidptr(150000) } - fn main() { mut fails := 0 - fails += forkedtest.normal_run(check_fork_minimal, "check_fork_minimal") - fails += forkedtest.normal_run(check_munmap_fail, "check_munmap_fail") - fails += forkedtest.normal_run(check_mmap_one_page, "check_mmap_one_page") - fails += forkedtest.normal_run(check_mm_pages, "check_mm_pages") - fails += forkedtest.normal_run(check_mm_alloc, "check_mm_alloc") - fails += forkedtest.normal_run(check_read_write_pipe, "check_read_write_pipe") - fails += forkedtest.normal_run(check_read_file, "check_read_file") + fails += forkedtest.normal_run(check_fork_minimal, 'check_fork_minimal') + fails += forkedtest.normal_run(check_munmap_fail, 'check_munmap_fail') + fails += forkedtest.normal_run(check_mmap_one_page, 'check_mmap_one_page') + fails += forkedtest.normal_run(check_mm_pages, 'check_mm_pages') + fails += forkedtest.normal_run(check_mm_alloc, 'check_mm_alloc') + fails += forkedtest.normal_run(check_read_write_pipe, 'check_read_write_pipe') + fails += forkedtest.normal_run(check_read_file, 'check_read_file') // check_print() - fails += forkedtest.normal_run(check_open_file_fail, "check_open_file_fail") - fails += forkedtest.normal_run(check_int_array_ro, "check_int_array_ro") - fails += forkedtest.normal_run(check_int_array_rw, "check_int_array_rw") - fails += forkedtest.normal_run(check_int64_array_ro, "check_int64_array_ro") - fails += forkedtest.normal_run(check_voidptr_array_ro, "check_voidptr_array_ro") - fails += forkedtest.normal_run(check_voidptr_array_rw, "check_voidptr_array_rw") + fails += forkedtest.normal_run(check_open_file_fail, 'check_open_file_fail') + fails += forkedtest.normal_run(check_int_array_ro, 'check_int_array_ro') + fails += forkedtest.normal_run(check_int_array_rw, 'check_int_array_rw') + fails += forkedtest.normal_run(check_int64_array_ro, 'check_int64_array_ro') + fails += forkedtest.normal_run(check_voidptr_array_ro, 'check_voidptr_array_ro') + fails += forkedtest.normal_run(check_voidptr_array_rw, 'check_voidptr_array_rw') assert fails == 0 sys_exit(0) diff --git a/vlib/builtin/linux_bare/old/.checks/string/string.v b/vlib/builtin/linux_bare/old/.checks/string/string.v index 54c06e7ef..1b7d3e57d 100644 --- a/vlib/builtin/linux_bare/old/.checks/string/string.v +++ b/vlib/builtin/linux_bare/old/.checks/string/string.v @@ -1,63 +1,63 @@ module main -import forkedtest -fn check_string_eq () { - assert "monkey" != "rat" - some_animal := "a bird" - assert some_animal == "a bird" +import builtin.linux_bare.old..checks.forkedtest + +fn check_string_eq() { + assert 'monkey' != 'rat' + some_animal := 'a bird' + assert some_animal == 'a bird' } fn check_i64_tos() { - buffer0 := []byte{len:(128)} + buffer0 := []u8{len: (128)} buffer := byteptr(buffer0.data) s0 := i64_tos(buffer, 70, 140, 10) - assert s0 == "140" + assert s0 == '140' s1 := i64_tos(buffer, 70, -160, 10) - assert s1 == "-160" + assert s1 == '-160' s2 := i64_tos(buffer, 70, 65537, 16) - assert s2 == "10001" + assert s2 == '10001' s3 := i64_tos(buffer, 70, -160000, 10) - assert s3 == "-160000" + assert s3 == '-160000' } fn check_i64_str() { - assert "141" == i64_str(141, 10) - assert "-161" == i64_str(-161, 10) - assert "10002" == i64_str(65538, 16) - assert "-160001" == i64_str(-160001, 10) + assert '141' == i64_str(141, 10) + assert '-161' == i64_str(-161, 10) + assert '10002' == i64_str(65538, 16) + assert '-160001' == i64_str(-160001, 10) } fn check_str_clone() { - a := i64_str(1234,10) + a := i64_str(1234, 10) b := a.clone() assert a == b - c := i64_str(-6789,10).clone() - assert c == "-6789" + c := i64_str(-6789, 10).clone() + assert c == '-6789' +} + +fn check_string_add_works() { + abc := 'abc' + combined := 'a' + 'b' + 'c' + assert abc.len == combined.len + assert abc[0] == combined[0] + assert abc[1] == combined[1] + assert abc[2] == combined[2] + assert abc[0] == `a` + assert abc == combined } -fn check_string_add_works(){ - abc := 'abc' - combined := 'a' + 'b' + 'c' - assert abc.len == combined.len - assert abc[0] == combined[0] - assert abc[1] == combined[1] - assert abc[2] == combined[2] - assert abc[0] == `a` - assert abc == combined -} - -fn main () { +fn main() { mut fails := 0 - fails += forkedtest.normal_run(check_string_eq, "check_string_eq") - fails += forkedtest.normal_run(check_i64_tos, "check_i64_tos") - fails += forkedtest.normal_run(check_i64_str, "check_i64_str") - fails += forkedtest.normal_run(check_str_clone, "check_str_clone") - fails += forkedtest.normal_run(check_string_add_works, "check_string_add_works") + fails += forkedtest.normal_run(check_string_eq, 'check_string_eq') + fails += forkedtest.normal_run(check_i64_tos, 'check_i64_tos') + fails += forkedtest.normal_run(check_i64_str, 'check_i64_str') + fails += forkedtest.normal_run(check_str_clone, 'check_str_clone') + fails += forkedtest.normal_run(check_string_add_works, 'check_string_add_works') assert fails == 0 sys_exit(0) } - diff --git a/vlib/builtin/map_test.v b/vlib/builtin/map_test.v index 65a323412..223a4f899 100644 --- a/vlib/builtin/map_test.v +++ b/vlib/builtin/map_test.v @@ -179,7 +179,7 @@ fn test_various_map_value() { mut m9 := map[string]bool{} m9['test'] = true assert m9['test'] == true - mut m10 := map[string]byte{} + mut m10 := map[string]u8{} m10['test'] = u8(0) assert m10['test'] == u8(0) mut m11 := map[string]f32{} @@ -194,7 +194,7 @@ fn test_various_map_value() { mut m14 := map[string]voidptr{} m14['test'] = voidptr(0) assert m14['test'] == voidptr(0) - mut m15 := map[string]&byte{} + mut m15 := map[string]&u8{} m15['test'] = &u8(0) assert m15['test'] == &u8(0) mut m16 := map[string]i64{} @@ -750,7 +750,7 @@ fn test_in_map_literal() { } fn test_byte_keys() { - mut m := map[byte]byte{} + mut m := map[u8]u8{} byte_max := u8(255) for i in u8(0) .. byte_max { m[i] = i diff --git a/vlib/builtin/string.v b/vlib/builtin/string.v index 7078ad750..f471aa505 100644 --- a/vlib/builtin/string.v +++ b/vlib/builtin/string.v @@ -44,7 +44,7 @@ Note: A V string should be/is immutable from the point of view of pub struct string { pub: str &u8 = 0 // points to a C style 0 terminated string of bytes. - len int // the length of the .str field, excluding the ending 0 byte. It is always equal to strlen(.str). + len int // the length of the .str field, excluding the ending 0 byte. It is always equal to strlen(.str). // NB string.is_lit is an enumeration of the following: // .is_lit == 0 => a fresh string, should be freed by autofree // .is_lit == 1 => a literal string from .rodata, should NOT be freed @@ -1215,7 +1215,7 @@ pub fn (s string) to_upper() string { pub fn (s string) is_upper() bool { for i in 0 .. s.len { if s[i] >= `a` && s[i] <= `z` { - return false + return false } } return true diff --git a/vlib/builtin/string_test.v b/vlib/builtin/string_test.v index 6f200375d..38c0f1720 100644 --- a/vlib/builtin/string_test.v +++ b/vlib/builtin/string_test.v @@ -837,11 +837,11 @@ fn test_double_quote_inter() { assert '$a $b' == '1 2' } -fn foo(b byte) byte { +fn foo(b u8) u8 { return b - 10 } -fn filter(b byte) bool { +fn filter(b u8) bool { return b != `a` } diff --git a/vlib/clipboard/clipboard_darwin.c.v b/vlib/clipboard/clipboard_darwin.c.v index d2d0756d6..f22e7320d 100644 --- a/vlib/clipboard/clipboard_darwin.c.v +++ b/vlib/clipboard/clipboard_darwin.c.v @@ -17,7 +17,7 @@ mut: fn C.darwin_new_pasteboard() voidptr -fn C.darwin_get_pasteboard_text(voidptr) &byte +fn C.darwin_get_pasteboard_text(voidptr) &u8 fn C.darwin_set_pasteboard_text(voidptr, string) bool diff --git a/vlib/clipboard/x11/clipboard.c.v b/vlib/clipboard/x11/clipboard.c.v index d4b60be80..8aacdbf12 100644 --- a/vlib/clipboard/x11/clipboard.c.v +++ b/vlib/clipboard/x11/clipboard.c.v @@ -42,17 +42,17 @@ fn C.XChangeProperty(d &C.Display, requestor Window, property Atom, typ Atom, fo fn C.XSendEvent(d &C.Display, requestor Window, propogate int, mask i64, event &C.XEvent) -fn C.XInternAtom(d &C.Display, typ &byte, only_if_exists int) Atom +fn C.XInternAtom(d &C.Display, typ &u8, only_if_exists int) Atom fn C.XCreateSimpleWindow(d &C.Display, root Window, x int, y int, width u32, height u32, border_width u32, border u64, background u64) Window -fn C.XOpenDisplay(name &byte) &C.Display +fn C.XOpenDisplay(name &u8) &C.Display fn C.XConvertSelection(d &C.Display, selection Atom, target Atom, property Atom, requestor Window, time int) int fn C.XSync(d &C.Display, discard int) int -fn C.XGetWindowProperty(d &C.Display, w Window, property Atom, offset i64, length i64, delete int, req_type Atom, actual_type_return &Atom, actual_format_return &int, nitems &u64, bytes_after_return &u64, prop_return &&byte) int +fn C.XGetWindowProperty(d &C.Display, w Window, property Atom, offset i64, length i64, delete int, req_type Atom, actual_type_return &Atom, actual_format_return &int, nitems &u64, bytes_after_return &u64, prop_return &&u8) int fn C.XDeleteProperty(d &C.Display, w Window, property Atom) int @@ -154,7 +154,7 @@ struct Property { actual_type Atom actual_format int nitems u64 - data &byte + data &u8 } // new_clipboard returns a new `Clipboard` instance allocated on the heap. diff --git a/vlib/context/context.v b/vlib/context/context.v index 7eff04915..ed32b7e1c 100644 --- a/vlib/context/context.v +++ b/vlib/context/context.v @@ -21,19 +21,7 @@ const ( ) // Key represents the type for the ValueContext key -pub type Key = bool - | byte - | f32 - | f64 - | i16 - | i64 - | i8 - | int - | string - | u16 - | u32 - | u64 - | voidptr +pub type Key = bool | f32 | f64 | i16 | i64 | i8 | int | string | u16 | u32 | u64 | u8 | voidptr // Any represents a generic type for the ValueContext pub interface Any {} diff --git a/vlib/darwin/darwin.v b/vlib/darwin/darwin.v index b86636e10..b85d8d71e 100644 --- a/vlib/darwin/darwin.v +++ b/vlib/darwin/darwin.v @@ -30,10 +30,10 @@ pub fn nsstring(s string) voidptr { // for .app packages: .../my.app/Contents/Resources // for cli: .../parent_folder/Resources -fn C.CFBundleCopyResourcesDirectoryURL(bundle voidptr) &byte +fn C.CFBundleCopyResourcesDirectoryURL(bundle voidptr) &u8 fn C.CFBundleGetMainBundle() voidptr -fn C.CFURLGetFileSystemRepresentation(url &byte, resolve_against_base bool, buffer &byte, buffer_size int) int -fn C.CFRelease(url &byte) +fn C.CFURLGetFileSystemRepresentation(url &u8, resolve_against_base bool, buffer &u8, buffer_size int) int +fn C.CFRelease(url &u8) pub fn resource_path() string { main_bundle := C.CFBundleGetMainBundle() diff --git a/vlib/dl/dl_windows.c.v b/vlib/dl/dl_windows.c.v index 85de31eac..8f3156fbc 100644 --- a/vlib/dl/dl_windows.c.v +++ b/vlib/dl/dl_windows.c.v @@ -6,7 +6,7 @@ pub const rtld_lazy = 0 fn C.LoadLibrary(libfilename &u16) voidptr -fn C.GetProcAddress(handle voidptr, procname &byte) voidptr +fn C.GetProcAddress(handle voidptr, procname &u8) voidptr fn C.FreeLibrary(handle voidptr) bool diff --git a/vlib/encoding/base58/alphabet.v b/vlib/encoding/base58/alphabet.v index 1cc00f8a0..42cb5c6e9 100644 --- a/vlib/encoding/base58/alphabet.v +++ b/vlib/encoding/base58/alphabet.v @@ -24,7 +24,7 @@ fn init_alphabets() map[string]Alphabet { // will be encoded to and a decode table. struct Alphabet { mut: - decode []i8 = []i8{len: 128, init: -1} + decode []i8 = []i8{len: 128, init: -1} encode []u8 = []u8{len: 58} } diff --git a/vlib/encoding/base64/base64.c.v b/vlib/encoding/base64/base64.c.v index 08bd68f73..1e912e933 100644 --- a/vlib/encoding/base64/base64.c.v +++ b/vlib/encoding/base64/base64.c.v @@ -4,7 +4,7 @@ module base64 // encode_in_buffer returns the size of the encoded data in the buffer. // Please note: The buffer should be large enough (i.e. 4/3 of the data.len, or larger) to hold the encoded data. // Please note: The function does NOT allocate new memory, and is suitable for handling very large strings. -pub fn encode_in_buffer(data []u8, buffer &byte) int { +pub fn encode_in_buffer(data []u8, buffer &u8) int { return encode_from_buffer(buffer, data.data, data.len) } @@ -126,8 +126,8 @@ fn decode_from_buffer(dest &u8, src &u8, src_len int) int { for src_len - si >= 8 { // Converting 8 bytes of input into 6 bytes of output. Storing these in the upper bytes of an u64. datablock_64.data = assemble64(u8(index[d[si + 0]]), u8(index[d[si + 1]]), - u8(index[d[si + 2]]), u8(index[d[si + 3]]), u8(index[d[si + 4]]), - u8(index[d[si + 5]]), u8(index[d[si + 6]]), u8(index[d[si + 7]])) + u8(index[d[si + 2]]), u8(index[d[si + 3]]), u8(index[d[si + 4]]), u8(index[d[si + 5]]), + u8(index[d[si + 6]]), u8(index[d[si + 7]])) // Reading out the individual bytes from the u64. Watch out with endianess. $if little_endian { diff --git a/vlib/encoding/base64/base64.v b/vlib/encoding/base64/base64.v index 0f45ed2a0..ce26510b0 100644 --- a/vlib/encoding/base64/base64.v +++ b/vlib/encoding/base64/base64.v @@ -54,13 +54,13 @@ pub fn url_encode_str(data string) string { // assemble64 assembles 8 base64 digits into 6 bytes. // Each digit comes from the decode map. // Please note: Invalid base64 digits are not expected and not handled. -fn assemble64(n1 byte, n2 byte, n3 byte, n4 byte, n5 byte, n6 byte, n7 byte, n8 byte) u64 { +fn assemble64(n1 u8, n2 u8, n3 u8, n4 u8, n5 u8, n6 u8, n7 u8, n8 u8) u64 { return u64(n1) << 58 | u64(n2) << 52 | u64(n3) << 46 | u64(n4) << 40 | u64(n5) << 34 | u64(n6) << 28 | u64(n7) << 22 | u64(n8) << 16 } // assemble32 assembles 4 base64 digits into 3 bytes. // Each digit comes from the decode map. // Please note: Invalid base64 digits are not expected and not handled. -fn assemble32(n1 byte, n2 byte, n3 byte, n4 byte) u32 { +fn assemble32(n1 u8, n2 u8, n3 u8, n4 u8) u32 { return u32(n1) << 26 | u32(n2) << 20 | u32(n3) << 14 | u32(n4) << 8 } diff --git a/vlib/encoding/csv/reader.v b/vlib/encoding/csv/reader.v index 9907c8524..b3901b74e 100644 --- a/vlib/encoding/csv/reader.v +++ b/vlib/encoding/csv/reader.v @@ -44,16 +44,16 @@ struct Reader { // headings []string data string pub mut: - delimiter byte - comment byte + delimiter u8 + comment u8 is_mac_pre_osx_le bool row_pos int } [params] pub struct ReaderConfig { - delimiter byte = `,` - comment byte = `#` + delimiter u8 = `,` + comment u8 = `#` } // new_reader initializes a Reader with string data to parse and, @@ -210,6 +210,6 @@ fn (mut r Reader) read_record() ?[]string { return fields } -fn valid_delim(b byte) bool { +fn valid_delim(b u8) bool { return b != 0 && b != `"` && b != `\r` && b != `\n` } diff --git a/vlib/encoding/csv/writer.v b/vlib/encoding/csv/writer.v index 07bd26c59..b46c9d68e 100644 --- a/vlib/encoding/csv/writer.v +++ b/vlib/encoding/csv/writer.v @@ -10,7 +10,7 @@ mut: sb strings.Builder pub mut: use_crlf bool - delimiter byte + delimiter u8 } pub fn new_writer() &Writer { diff --git a/vlib/encoding/hex/hex.v b/vlib/encoding/hex/hex.v index d709f01e8..d847d5d3d 100644 --- a/vlib/encoding/hex/hex.v +++ b/vlib/encoding/hex/hex.v @@ -52,7 +52,7 @@ pub fn encode(bytes []u8) string { } // char2nibble converts an ASCII hex character to it's hex value -fn char2nibble(b byte) ?byte { +fn char2nibble(b u8) ?u8 { match b { `0`...`9` { return b - u8(`0`) } `A`...`F` { return b - u8(`A`) + 10 } diff --git a/vlib/encoding/utf8/utf8.v b/vlib/encoding/utf8/utf8.v index 88c598fe5..d4e885e41 100644 --- a/vlib/encoding/utf8/utf8.v +++ b/vlib/encoding/utf8/utf8.v @@ -11,7 +11,7 @@ pub fn validate_str(str string) bool { return validate(str.str, str.len) } -pub fn validate(data &byte, len int) bool { +pub fn validate(data &u8, len int) bool { mut state := Utf8State{} for i := 0; i < len; i++ { s := unsafe { data[i] } @@ -46,7 +46,7 @@ fn (mut s Utf8State) seq(r0 bool, r1 bool, is_tail bool) bool { return false } -fn (mut s Utf8State) next_state(c byte) { +fn (mut s Utf8State) next_state(c u8) { // sequence 1 if s.index == 0 { if (c >= 0x00 + 1 && c <= 0x7F) || c == 0x00 { diff --git a/vlib/flag/flag.v b/vlib/flag/flag.v index 116c12689..49e8de30b 100644 --- a/vlib/flag/flag.v +++ b/vlib/flag/flag.v @@ -4,7 +4,7 @@ module flag pub struct Flag { pub: name string // name as it appears on command line - abbr byte // shortcut + abbr u8 // shortcut usage string // help message val_desc string // something like '' that appears in usage, // and also the default value, when the flag is not given @@ -200,7 +200,7 @@ pub fn (mut fs FlagParser) allow_unknown_args() { // private helper to register a flag // This version supports abbreviations. -fn (mut fs FlagParser) add_flag(name string, abbr byte, usage string, desc string) { +fn (mut fs FlagParser) add_flag(name string, abbr u8, usage string, desc string) { fs.flags << Flag{ name: name abbr: abbr @@ -219,7 +219,7 @@ fn (mut fs FlagParser) add_flag(name string, abbr byte, usage string, desc strin // - the name, usage are registered // - found arguments and corresponding values are removed from args list [manualfree] -fn (mut fs FlagParser) parse_value(longhand string, shorthand byte) []string { +fn (mut fs FlagParser) parse_value(longhand string, shorthand u8) []string { full := '--$longhand' defer { unsafe { full.free() } @@ -278,7 +278,7 @@ fn (mut fs FlagParser) parse_value(longhand string, shorthand byte) []string { // special: it is allowed to define bool flags without value // -> '--flag' is parsed as true // -> '--flag' is equal to '--flag=true' -fn (mut fs FlagParser) parse_bool_value(longhand string, shorthand byte) ?string { +fn (mut fs FlagParser) parse_bool_value(longhand string, shorthand u8) ?string { { full := '--$longhand' for i, arg in fs.args { @@ -317,7 +317,7 @@ fn (mut fs FlagParser) parse_bool_value(longhand string, shorthand byte) ?string // bool_opt returns an option with the bool value of the given command line flag, named `name`. // It returns an error, when the flag is not given by the user. // This version supports abbreviations. -pub fn (mut fs FlagParser) bool_opt(name string, abbr byte, usage string) ?bool { +pub fn (mut fs FlagParser) bool_opt(name string, abbr u8, usage string) ?bool { mut res := false { fs.add_flag(name, abbr, usage, '') @@ -333,7 +333,7 @@ pub fn (mut fs FlagParser) bool_opt(name string, abbr byte, usage string) ?bool // If that flag is given by the user, then it returns its parsed bool value. // When it is not, it returns the default value in `bdefault`. // This version supports abbreviations. -pub fn (mut fs FlagParser) bool(name string, abbr byte, bdefault bool, usage string) bool { +pub fn (mut fs FlagParser) bool(name string, abbr u8, bdefault bool, usage string) bool { value := fs.bool_opt(name, abbr, usage) or { return bdefault } return value } @@ -341,7 +341,7 @@ pub fn (mut fs FlagParser) bool(name string, abbr byte, bdefault bool, usage str // int_multi returns all values associated with the provided flag in `name`. // When that flag has no values, it returns an empty array. // This version supports abbreviations. -pub fn (mut fs FlagParser) int_multi(name string, abbr byte, usage string) []int { +pub fn (mut fs FlagParser) int_multi(name string, abbr u8, usage string) []int { fs.add_flag(name, abbr, usage, '') parsed := fs.parse_value(name, abbr) mut value := []int{} @@ -354,7 +354,7 @@ pub fn (mut fs FlagParser) int_multi(name string, abbr byte, usage string) []int // int_opt returns an option with the integer value, associated with the flag in `name`. // When the flag is not given by the user, it returns an error. // This version supports abbreviations. -pub fn (mut fs FlagParser) int_opt(name string, abbr byte, usage string) ?int { +pub fn (mut fs FlagParser) int_opt(name string, abbr u8, usage string) ?int { mut res := 0 { fs.add_flag(name, abbr, usage, '') @@ -372,7 +372,7 @@ pub fn (mut fs FlagParser) int_opt(name string, abbr byte, usage string) ?int { // When the flag is given by the user, it returns its parsed integer value. // When it is not, it returns the integer value in `idefault`. // This version supports abbreviations. -pub fn (mut fs FlagParser) int(name string, abbr byte, idefault int, usage string) int { +pub fn (mut fs FlagParser) int(name string, abbr u8, idefault int, usage string) int { value := fs.int_opt(name, abbr, usage) or { return idefault } return value } @@ -380,7 +380,7 @@ pub fn (mut fs FlagParser) int(name string, abbr byte, idefault int, usage strin // float_multi returns all floating point values, associated with the flag named `name`. // When no values for that flag are found, it returns an empty array. // This version supports abbreviations. -pub fn (mut fs FlagParser) float_multi(name string, abbr byte, usage string) []f64 { +pub fn (mut fs FlagParser) float_multi(name string, abbr u8, usage string) []f64 { fs.add_flag(name, abbr, usage, '') parsed := fs.parse_value(name, abbr) mut value := []f64{} @@ -393,7 +393,7 @@ pub fn (mut fs FlagParser) float_multi(name string, abbr byte, usage string) []f // float_opt returns an option with the floating point value, associated with the flag in `name`. // When the flag is not given by the user, it returns an error. // This version supports abbreviations. -pub fn (mut fs FlagParser) float_opt(name string, abbr byte, usage string) ?f64 { +pub fn (mut fs FlagParser) float_opt(name string, abbr u8, usage string) ?f64 { mut res := 0.0 { fs.add_flag(name, abbr, usage, '') @@ -410,7 +410,7 @@ pub fn (mut fs FlagParser) float_opt(name string, abbr byte, usage string) ?f64 // When the flag is given by the user, it returns its parsed floating point value. // When it is not, it returns the value in `fdefault`. // This version supports abbreviations. -pub fn (mut fs FlagParser) float(name string, abbr byte, fdefault f64, usage string) f64 { +pub fn (mut fs FlagParser) float(name string, abbr u8, fdefault f64, usage string) f64 { value := fs.float_opt(name, abbr, usage) or { return fdefault } return value } @@ -418,7 +418,7 @@ pub fn (mut fs FlagParser) float(name string, abbr byte, fdefault f64, usage str // string_multi returns all string values, associated with the flag named `name`. // When no values for that flag are found, it returns an empty array. // This version supports abbreviations. -pub fn (mut fs FlagParser) string_multi(name string, abbr byte, usage string) []string { +pub fn (mut fs FlagParser) string_multi(name string, abbr u8, usage string) []string { fs.add_flag(name, abbr, usage, '') return fs.parse_value(name, abbr) } @@ -426,7 +426,7 @@ pub fn (mut fs FlagParser) string_multi(name string, abbr byte, usage string) [] // string_opt returns an option with the string value, associated with the flag in `name`. // When the flag is not given by the user, it returns an error. // This version supports abbreviations. -pub fn (mut fs FlagParser) string_opt(name string, abbr byte, usage string) ?string { +pub fn (mut fs FlagParser) string_opt(name string, abbr u8, usage string) ?string { mut res := '' { fs.add_flag(name, abbr, usage, '') @@ -443,7 +443,7 @@ pub fn (mut fs FlagParser) string_opt(name string, abbr byte, usage string) ?str // If that flag is given as an option, then its parsed value is returned as a string. // When it is not, it returns the default string value in `sdefault`. // This version supports abbreviations. -pub fn (mut fs FlagParser) string(name string, abbr byte, sdefault string, usage string) string { +pub fn (mut fs FlagParser) string(name string, abbr u8, sdefault string, usage string) string { value := fs.string_opt(name, abbr, usage) or { return sdefault } return value } diff --git a/vlib/fontstash/fontstash.c.v b/vlib/fontstash/fontstash.c.v index 1253d9da8..4c9eb5b10 100644 --- a/vlib/fontstash/fontstash.c.v +++ b/vlib/fontstash/fontstash.c.v @@ -251,7 +251,7 @@ pub fn (s &Context) text_iter_next(iter &C.FONStextIter, quad &C.FONSquad) int { // get_texture_data returns the current Context's raw texture data. // `width` and `height` is assigned the size of the texture dimensions. [inline] -pub fn (s &Context) get_texture_data(width &int, height &int) &byte { +pub fn (s &Context) get_texture_data(width &int, height &int) &u8 { return &u8(C.fonsGetTextureData(s, width, height)) } diff --git a/vlib/fontstash/fontstash_funcs.c.v b/vlib/fontstash/fontstash_funcs.c.v index 8e260e777..cd67bcd8e 100644 --- a/vlib/fontstash/fontstash_funcs.c.v +++ b/vlib/fontstash/fontstash_funcs.c.v @@ -18,7 +18,7 @@ fn C.fonsResetAtlas(s &C.FONScontext, width int, height int) int // Add fonts fn C.fonsGetFontByName(s &C.FONScontext, name &char) int fn C.fonsAddFallbackFont(s &C.FONScontext, base int, fallback int) int -fn C.fonsAddFontMem(s &C.FONScontext, name &char, data &byte, dataSize int, freeData int) int +fn C.fonsAddFontMem(s &C.FONScontext, name &char, data &u8, dataSize int, freeData int) int // State handling fn C.fonsPushState(s &C.FONScontext) diff --git a/vlib/fontstash/fontstash_structs.c.v b/vlib/fontstash/fontstash_structs.c.v index e34ef26ed..605404581 100644 --- a/vlib/fontstash/fontstash_structs.c.v +++ b/vlib/fontstash/fontstash_structs.c.v @@ -10,7 +10,7 @@ pub struct C.FONSparams { // int (*renderResize)(void* uptr, int width, int height) renderResize fn (uptr voidptr, width int, height int) int // void (*renderUpdate)(void* uptr, int* rect, const unsigned char* data) - renderUpdate fn (uptr voidptr, rect &int, data &byte) + renderUpdate fn (uptr voidptr, rect &int, data &u8) // void (*renderDraw)(void* uptr, const float* verts, const float* tcoords, const unsigned int* colors, int nverts) renderDraw fn (uptr voidptr, verts &f32, tcoords &f32, colors &u32, nverts int) // void (*renderDelete)(void* uptr) @@ -40,9 +40,9 @@ pub struct C.FONStextIter { iblur i16 font &C.FONSfont prevGlyphIndex int - str &byte - next &byte - end &byte + str &u8 + next &u8 + end &u8 utf8state u32 } diff --git a/vlib/gg/gg.c.v b/vlib/gg/gg.c.v index cc38d50a3..5c72856a5 100644 --- a/vlib/gg/gg.c.v +++ b/vlib/gg/gg.c.v @@ -128,7 +128,7 @@ pub mut: ui_mode bool // do not redraw everything 60 times/second, but only when the user requests frame u64 // the current frame counted from the start of the application; always increasing // - mbtn_mask byte + mbtn_mask u8 mouse_buttons MouseButtons // typed version of mbtn_mask; easier to use for user programs mouse_pos_x int mouse_pos_y int diff --git a/vlib/gg/gg.js.v b/vlib/gg/gg.js.v index b5eccbb3d..21e959326 100644 --- a/vlib/gg/gg.js.v +++ b/vlib/gg/gg.js.v @@ -276,7 +276,7 @@ pub mut: user_data voidptr ui_mode bool frame u64 - mbtn_mask byte + mbtn_mask u8 mouse_buttons MouseButtons mouse_pos_x int mouse_pos_y int diff --git a/vlib/gg/image.c.v b/vlib/gg/image.c.v index 7da0a7404..ec57680c5 100644 --- a/vlib/gg/image.c.v +++ b/vlib/gg/image.c.v @@ -150,14 +150,14 @@ pub fn (mut ctx Context) new_streaming_image(w int, h int, channels int, sicfg S // update_pixel_data is a helper for working with image streams (i.e. images, // that are updated dynamically by the CPU on each frame) -pub fn (mut ctx Context) update_pixel_data(cached_image_idx int, buf &byte) { +pub fn (mut ctx Context) update_pixel_data(cached_image_idx int, buf &u8) { mut image := ctx.get_cached_image_by_idx(cached_image_idx) image.update_pixel_data(buf) } // update_pixel_data updates the sokol specific pixel data associated // with this `Image`. -pub fn (mut img Image) update_pixel_data(buf &byte) { +pub fn (mut img Image) update_pixel_data(buf &u8) { mut data := gfx.ImageData{} data.subimage[0][0].ptr = buf data.subimage[0][0].size = usize(img.width * img.height * img.nr_channels) @@ -218,7 +218,7 @@ fn create_image(file string) Image { // memory buffer `buf` of size `bufsize`. // // See also: create_image_from_byte_array -pub fn (mut ctx Context) create_image_from_memory(buf &byte, bufsize int) Image { +pub fn (mut ctx Context) create_image_from_memory(buf &u8, bufsize int) Image { stb_img := stbi.load_from_memory(buf, bufsize) or { return Image{} } mut img := Image{ width: stb_img.width diff --git a/vlib/gx/color.v b/vlib/gx/color.v index c1d38fd4d..0d563efc0 100644 --- a/vlib/gx/color.v +++ b/vlib/gx/color.v @@ -116,10 +116,10 @@ pub const ( // Color represents a 32 bit color value in sRGB format pub struct Color { pub mut: - r byte - g byte - b byte - a byte = 255 + r u8 + g u8 + b u8 + a u8 = 255 } // hex takes in a 32 bit integer and splits it into 4 byte values @@ -132,7 +132,7 @@ pub fn hex(color int) Color { } } -pub fn rgb(r byte, g byte, b byte) Color { +pub fn rgb(r u8, g u8, b u8) Color { return Color{ r: r g: g @@ -140,7 +140,7 @@ pub fn rgb(r byte, g byte, b byte) Color { } } -pub fn rgba(r byte, g byte, b byte, a byte) Color { +pub fn rgba(r u8, g u8, b u8, a u8) Color { return Color{ r: r g: g diff --git a/vlib/hash/fnv1a/fnv1a.v b/vlib/hash/fnv1a/fnv1a.v index 8d32c5d06..e60b19930 100644 --- a/vlib/hash/fnv1a/fnv1a.v +++ b/vlib/hash/fnv1a/fnv1a.v @@ -46,7 +46,7 @@ pub fn sum32_struct(s &T) u32 { // sum32_bytes returns a fnv1a hash of `data_len` bytes starting at // the address in the given &byte pointer `data`. [direct_array_access; inline; unsafe] -pub fn sum32_bytes(data &byte, data_len int) u32 { +pub fn sum32_bytes(data &u8, data_len int) u32 { mut hash := fnv1a.fnv32_offset_basis for i in 0 .. data_len { hash = unsafe { (hash ^ u32(data[i])) * fnv1a.fnv32_prime } @@ -78,7 +78,7 @@ pub fn sum64(data []u8) u64 { // sum64_bytes returns a fnv1a hash of `data_len` bytes starting at // the address in the given &byte pointer `data`. [direct_array_access; inline; unsafe] -pub fn sum64_bytes(data &byte, data_len int) u64 { +pub fn sum64_bytes(data &u8, data_len int) u64 { mut hash := fnv1a.fnv64_offset_basis for i in 0 .. data_len { hash = unsafe { (hash ^ u64(data[i])) * fnv1a.fnv64_prime } diff --git a/vlib/hash/wyhash.c.v b/vlib/hash/wyhash.c.v index 71dd11d36..b8c3cb560 100644 --- a/vlib/hash/wyhash.c.v +++ b/vlib/hash/wyhash.c.v @@ -2,12 +2,12 @@ module hash //#flag -I @VEXEROOT/thirdparty/wyhash //#include "wyhash.h" -fn C.wyhash(&byte, u64, u64, &u64) u64 +fn C.wyhash(&u8, u64, u64, &u64) u64 fn C.wyhash64(u64, u64) u64 [inline] -pub fn wyhash_c(key &byte, len u64, seed u64) u64 { +pub fn wyhash_c(key &u8, len u64, seed u64) u64 { return C.wyhash(key, len, seed, &u64(C._wyp)) } diff --git a/vlib/hash/wyhash.v b/vlib/hash/wyhash.v index 7bbc00613..61e5c610a 100644 --- a/vlib/hash/wyhash.v +++ b/vlib/hash/wyhash.v @@ -51,21 +51,21 @@ pub fn wymum(a u64, b u64) u64 { } [inline] -fn wyr3(p &byte, k u64) u64 { +fn wyr3(p &u8, k u64) u64 { unsafe { return (u64(p[0]) << 16) | (u64(p[k >> 1]) << 8) | u64(p[k - 1]) } } [inline] -fn wyr4(p &byte) u64 { +fn wyr4(p &u8) u64 { unsafe { return u32(p[0]) | (u32(p[1]) << u32(8)) | (u32(p[2]) << u32(16)) | (u32(p[3]) << u32(24)) } } [inline] -fn wyr8(p &byte) u64 { +fn wyr8(p &u8) u64 { unsafe { return u64(p[0]) | (u64(p[1]) << 8) | (u64(p[2]) << 16) | (u64(p[3]) << 24) | (u64(p[4]) << 32) | (u64(p[5]) << 40) | (u64(p[6]) << 48) | (u64(p[7]) << 56) } diff --git a/vlib/math/bits/bits.v b/vlib/math/bits/bits.v index 29614a265..b75e2e549 100644 --- a/vlib/math/bits/bits.v +++ b/vlib/math/bits/bits.v @@ -9,10 +9,9 @@ const ( de_bruijn32tab = [u8(0), 1, 28, 2, 29, 14, 24, 3, 30, 22, 20, 15, 25, 17, 4, 8, 31, 27, 13, 23, 21, 19, 16, 7, 26, 12, 18, 6, 11, 5, 10, 9] de_bruijn64 = u64(0x03f79d71b4ca8b09) - de_bruijn64tab = [u8(0), 1, 56, 2, 57, 49, 28, 3, 61, 58, 42, 50, 38, 29, 17, 4, 62, 47, - 59, 36, 45, 43, 51, 22, 53, 39, 33, 30, 24, 18, 12, 5, 63, 55, 48, 27, 60, 41, 37, 16, - 46, 35, 44, 21, 52, 32, 23, 11, 54, 26, 40, 15, 34, 20, 31, 10, 25, 14, 19, 9, 13, 8, 7, - 6] + de_bruijn64tab = [u8(0), 1, 56, 2, 57, 49, 28, 3, 61, 58, 42, 50, 38, 29, 17, 4, 62, 47, 59, + 36, 45, 43, 51, 22, 53, 39, 33, 30, 24, 18, 12, 5, 63, 55, 48, 27, 60, 41, 37, 16, 46, + 35, 44, 21, 52, 32, 23, 11, 54, 26, 40, 15, 34, 20, 31, 10, 25, 14, 19, 9, 13, 8, 7, 6] ) const ( @@ -31,7 +30,7 @@ const ( // --- LeadingZeros --- // leading_zeros_8 returns the number of leading zero bits in x; the result is 8 for x == 0. -pub fn leading_zeros_8(x byte) int { +pub fn leading_zeros_8(x u8) int { return 8 - len_8(x) } @@ -146,7 +145,7 @@ pub fn ones_count_64(x u64) int { // // This function's execution time does not depend on the inputs. [inline] -pub fn rotate_left_8(x byte, k int) byte { +pub fn rotate_left_8(x u8, k int) u8 { n := u8(8) s := u8(k) & (n - u8(1)) return (x << s) | (x >> (n - s)) diff --git a/vlib/mysql/_cdefs.c.v b/vlib/mysql/_cdefs.c.v index 23aebed9b..bc76e923c 100644 --- a/vlib/mysql/_cdefs.c.v +++ b/vlib/mysql/_cdefs.c.v @@ -10,15 +10,15 @@ struct C.MYSQL_RES { [typedef] struct C.MYSQL_FIELD { - name &byte // Name of column - org_name &byte // Original column name, if an alias - table &byte // Table of column if column was a field - org_table &byte // Org table name, if table was an alias - db &byte // Database for table - catalog &byte // Catalog for table - def &byte // Default value (set by mysql_list_fields) - length int // Width of column (create length) - max_length int // Max width for selected set + name &u8 // Name of column + org_name &u8 // Original column name, if an alias + table &u8 // Table of column if column was a field + org_table &u8 // Org table name, if table was an alias + db &u8 // Database for table + catalog &u8 // Catalog for table + def &u8 // Default value (set by mysql_list_fields) + length int // Width of column (create length) + max_length int // Max width for selected set name_length u32 org_name_length u32 table_length u32 @@ -36,13 +36,13 @@ fn C.mysql_init(mysql &C.MYSQL) &C.MYSQL fn C.mysql_real_connect(mysql &C.MYSQL, host &char, user &char, passwd &char, db &char, port u32, unix_socket &char, client_flag ConnectionFlag) &C.MYSQL -fn C.mysql_query(mysql &C.MYSQL, q &byte) int +fn C.mysql_query(mysql &C.MYSQL, q &u8) int -fn C.mysql_real_query(mysql &C.MYSQL, q &byte, len u32) int +fn C.mysql_real_query(mysql &C.MYSQL, q &u8, len u32) int -fn C.mysql_select_db(mysql &C.MYSQL, db &byte) int +fn C.mysql_select_db(mysql &C.MYSQL, db &u8) int -fn C.mysql_change_user(mysql &C.MYSQL, user &byte, password &byte, db &byte) bool +fn C.mysql_change_user(mysql &C.MYSQL, user &u8, password &u8, db &u8) bool fn C.mysql_affected_rows(mysql &C.MYSQL) u64 @@ -50,7 +50,7 @@ fn C.mysql_options(mysql &C.MYSQL, option int, arg voidptr) int fn C.mysql_get_option(mysql &C.MYSQL, option int, arg voidptr) int -fn C.mysql_list_tables(mysql &C.MYSQL, wild &byte) &C.MYSQL_RES +fn C.mysql_list_tables(mysql &C.MYSQL, wild &u8) &C.MYSQL_RES fn C.mysql_num_fields(res &C.MYSQL_RES) int @@ -66,36 +66,36 @@ fn C.mysql_ping(mysql &C.MYSQL) int fn C.mysql_store_result(mysql &C.MYSQL) &C.MYSQL_RES -fn C.mysql_fetch_row(res &C.MYSQL_RES) &&byte +fn C.mysql_fetch_row(res &C.MYSQL_RES) &&u8 fn C.mysql_fetch_fields(res &C.MYSQL_RES) &C.MYSQL_FIELD fn C.mysql_free_result(res &C.MYSQL_RES) -fn C.mysql_real_escape_string(mysql &C.MYSQL, to &byte, from &byte, len u64) u64 +fn C.mysql_real_escape_string(mysql &C.MYSQL, to &u8, from &u8, len u64) u64 // fn C.mysql_real_escape_string_quote(mysql &C.MYSQL, to &byte, from &byte, len u64, quote byte) u64 (Don't exist in mariadb) fn C.mysql_close(sock &C.MYSQL) // INFO & VERSION -fn C.mysql_info(mysql &C.MYSQL) &byte +fn C.mysql_info(mysql &C.MYSQL) &u8 -fn C.mysql_get_host_info(mysql &C.MYSQL) &byte +fn C.mysql_get_host_info(mysql &C.MYSQL) &u8 -fn C.mysql_get_server_info(mysql &C.MYSQL) &byte +fn C.mysql_get_server_info(mysql &C.MYSQL) &u8 fn C.mysql_get_server_version(mysql &C.MYSQL) u64 fn C.mysql_get_client_version() u64 -fn C.mysql_get_client_info() &byte +fn C.mysql_get_client_info() &u8 // DEBUG & ERROR INFO -fn C.mysql_error(mysql &C.MYSQL) &byte +fn C.mysql_error(mysql &C.MYSQL) &u8 fn C.mysql_errno(mysql &C.MYSQL) int fn C.mysql_dump_debug_info(mysql &C.MYSQL) int -fn C.mysql_debug(debug &byte) +fn C.mysql_debug(debug &u8) diff --git a/vlib/mysql/orm.v b/vlib/mysql/orm.v index 6fc08b2ae..7bda4741a 100644 --- a/vlib/mysql/orm.v +++ b/vlib/mysql/orm.v @@ -3,7 +3,7 @@ module mysql import orm import time -type Prims = byte | f32 | f64 | i16 | i64 | i8 | int | string | u16 | u32 | u64 +type Prims = f32 | f64 | i16 | i64 | i8 | int | string | u16 | u32 | u64 | u8 // sql expr diff --git a/vlib/mysql/result.v b/vlib/mysql/result.v index a3652592e..1070ed241 100644 --- a/vlib/mysql/result.v +++ b/vlib/mysql/result.v @@ -33,7 +33,7 @@ pub struct Field { } // fetch_row - fetches the next row from a result. -pub fn (r Result) fetch_row() &&byte { +pub fn (r Result) fetch_row() &&u8 { return C.mysql_fetch_row(r.result) } diff --git a/vlib/mysql/stmt.c.v b/vlib/mysql/stmt.c.v index d37440801..cef2ec151 100644 --- a/vlib/mysql/stmt.c.v +++ b/vlib/mysql/stmt.c.v @@ -153,7 +153,7 @@ pub fn (mut stmt Stmt) bind_bool(b &bool) { stmt.bind(mysql.mysql_type_tiny, b, 0) } -pub fn (mut stmt Stmt) bind_u8(b &byte) { +pub fn (mut stmt Stmt) bind_u8(b &u8) { stmt.bind(mysql.mysql_type_tiny, b, 0) } diff --git a/vlib/mysql/utils.v b/vlib/mysql/utils.v index 2d6332781..d35554c80 100644 --- a/vlib/mysql/utils.v +++ b/vlib/mysql/utils.v @@ -11,7 +11,7 @@ fn get_errno(conn &C.MYSQL) int { } // resolve_nil_str - returns an empty string if passed value is a nil pointer. -fn resolve_nil_str(ptr &byte) string { +fn resolve_nil_str(ptr &u8) string { if isnil(ptr) { return '' } @@ -19,7 +19,7 @@ fn resolve_nil_str(ptr &byte) string { } [inline] -fn mystring(b &byte) string { +fn mystring(b &u8) string { unsafe { return b.vstring() } diff --git a/vlib/net/address_android.c.v b/vlib/net/address_android.c.v index 38825cb2f..f1bfc51ca 100644 --- a/vlib/net/address_android.c.v +++ b/vlib/net/address_android.c.v @@ -55,7 +55,7 @@ struct Ip { } struct Unix { - path [max_unix_path]byte + path [max_unix_path]u8 } [_pack: '1'] diff --git a/vlib/net/address_darwin.c.v b/vlib/net/address_darwin.c.v index 1bae1deb5..93632b08b 100644 --- a/vlib/net/address_darwin.c.v +++ b/vlib/net/address_darwin.c.v @@ -17,18 +17,18 @@ mut: struct C.sockaddr_in6 { mut: // 1 + 1 + 2 + 4 + 16 + 4 = 28; - sin6_len byte // 1 - sin6_family byte // 1 - sin6_port u16 // 2 - sin6_flowinfo u32 // 4 + sin6_len u8 // 1 + sin6_family u8 // 1 + sin6_port u16 // 2 + sin6_flowinfo u32 // 4 sin6_addr [16]u8 // 16 - sin6_scope_id u32 // 4 + sin6_scope_id u32 // 4 } struct C.sockaddr_in { mut: - sin_len byte - sin_family byte + sin_len u8 + sin_family u8 sin_port u16 sin_addr u32 sin_zero [8]char @@ -36,8 +36,8 @@ mut: struct C.sockaddr_un { mut: - sun_len byte - sun_family byte + sun_len u8 + sun_family u8 sun_path [max_unix_path]char } diff --git a/vlib/net/address_default.c.v b/vlib/net/address_default.c.v index 43c33e115..529d0439a 100644 --- a/vlib/net/address_default.c.v +++ b/vlib/net/address_default.c.v @@ -16,20 +16,20 @@ mut: struct C.sockaddr_in { mut: - sin_family byte + sin_family u8 sin_port u16 sin_addr u32 } struct C.sockaddr_in6 { mut: - sin6_family byte + sin6_family u8 sin6_port u16 sin6_addr [4]u32 } struct C.sockaddr_un { mut: - sun_family byte + sun_family u8 sun_path [max_unix_path]char } diff --git a/vlib/net/address_dragonfly.c.v b/vlib/net/address_dragonfly.c.v index 3bb200ed3..d080f0a1b 100644 --- a/vlib/net/address_dragonfly.c.v +++ b/vlib/net/address_dragonfly.c.v @@ -22,18 +22,18 @@ mut: struct C.sockaddr_in6 { mut: // 1 + 1 + 2 + 4 + 16 + 4 = 28; - sin6_len byte // 1 - sin6_family byte // 1 - sin6_port u16 // 2 - sin6_flowinfo u32 // 4 + sin6_len u8 // 1 + sin6_family u8 // 1 + sin6_port u16 // 2 + sin6_flowinfo u32 // 4 sin6_addr [16]u8 // 16 - sin6_scope_id u32 // 4 + sin6_scope_id u32 // 4 } struct C.sockaddr_in { mut: - sin_len byte - sin_family byte + sin_len u8 + sin_family u8 sin_port u16 sin_addr u32 sin_zero [8]char @@ -41,8 +41,8 @@ mut: struct C.sockaddr_un { mut: - sun_len byte - sun_family byte + sun_len u8 + sun_family u8 sun_path [max_unix_path]char } diff --git a/vlib/net/address_freebsd.c.v b/vlib/net/address_freebsd.c.v index 72ad8b712..853001725 100644 --- a/vlib/net/address_freebsd.c.v +++ b/vlib/net/address_freebsd.c.v @@ -20,18 +20,18 @@ mut: struct C.sockaddr_in6 { mut: // 1 + 1 + 2 + 4 + 16 + 4 = 28; - sin6_len byte // 1 - sin6_family byte // 1 - sin6_port u16 // 2 - sin6_flowinfo u32 // 4 + sin6_len u8 // 1 + sin6_family u8 // 1 + sin6_port u16 // 2 + sin6_flowinfo u32 // 4 sin6_addr [16]u8 // 16 - sin6_scope_id u32 // 4 + sin6_scope_id u32 // 4 } struct C.sockaddr_in { mut: - sin_len byte - sin_family byte + sin_len u8 + sin_family u8 sin_port u16 sin_addr u32 sin_zero [8]char @@ -39,8 +39,8 @@ mut: struct C.sockaddr_un { mut: - sun_len byte - sun_family byte + sun_len u8 + sun_family u8 sun_path [max_unix_path]char } diff --git a/vlib/net/address_linux.c.v b/vlib/net/address_linux.c.v index 38825cb2f..f1bfc51ca 100644 --- a/vlib/net/address_linux.c.v +++ b/vlib/net/address_linux.c.v @@ -55,7 +55,7 @@ struct Ip { } struct Unix { - path [max_unix_path]byte + path [max_unix_path]u8 } [_pack: '1'] diff --git a/vlib/net/address_netbsd.c.v b/vlib/net/address_netbsd.c.v index 6b85d8224..27bd63d7f 100644 --- a/vlib/net/address_netbsd.c.v +++ b/vlib/net/address_netbsd.c.v @@ -22,18 +22,18 @@ mut: struct C.sockaddr_in6 { mut: // 1 + 1 + 2 + 4 + 16 + 4 = 28; - sin6_len byte // 1 - sin6_family byte // 1 - sin6_port u16 // 2 - sin6_flowinfo u32 // 4 + sin6_len u8 // 1 + sin6_family u8 // 1 + sin6_port u16 // 2 + sin6_flowinfo u32 // 4 sin6_addr [16]u8 // 16 - sin6_scope_id u32 // 4 + sin6_scope_id u32 // 4 } struct C.sockaddr_in { mut: - sin_len byte - sin_family byte + sin_len u8 + sin_family u8 sin_port u16 sin_addr u32 sin_zero [8]char @@ -41,8 +41,8 @@ mut: struct C.sockaddr_un { mut: - sun_len byte - sun_family byte + sun_len u8 + sun_family u8 sun_path [max_unix_path]char } diff --git a/vlib/net/address_openbsd.c.v b/vlib/net/address_openbsd.c.v index 72ad8b712..853001725 100644 --- a/vlib/net/address_openbsd.c.v +++ b/vlib/net/address_openbsd.c.v @@ -20,18 +20,18 @@ mut: struct C.sockaddr_in6 { mut: // 1 + 1 + 2 + 4 + 16 + 4 = 28; - sin6_len byte // 1 - sin6_family byte // 1 - sin6_port u16 // 2 - sin6_flowinfo u32 // 4 + sin6_len u8 // 1 + sin6_family u8 // 1 + sin6_port u16 // 2 + sin6_flowinfo u32 // 4 sin6_addr [16]u8 // 16 - sin6_scope_id u32 // 4 + sin6_scope_id u32 // 4 } struct C.sockaddr_in { mut: - sin_len byte - sin_family byte + sin_len u8 + sin_family u8 sin_port u16 sin_addr u32 sin_zero [8]char @@ -39,8 +39,8 @@ mut: struct C.sockaddr_un { mut: - sun_len byte - sun_family byte + sun_len u8 + sun_family u8 sun_path [max_unix_path]char } diff --git a/vlib/net/address_windows.c.v b/vlib/net/address_windows.c.v index 0b060ae20..e649cc4e6 100644 --- a/vlib/net/address_windows.c.v +++ b/vlib/net/address_windows.c.v @@ -50,7 +50,7 @@ struct Ip { } struct Unix { - path [max_unix_path]byte + path [max_unix_path]u8 } [_pack: '1'] diff --git a/vlib/net/http/chunked/dechunk.v b/vlib/net/http/chunked/dechunk.v index d4507ebb7..44f251231 100644 --- a/vlib/net/http/chunked/dechunk.v +++ b/vlib/net/http/chunked/dechunk.v @@ -31,7 +31,7 @@ fn (mut s ChunkScanner) read_chunk_size() u32 { return n } -fn unhex(c byte) byte { +fn unhex(c u8) u8 { if `0` <= c && c <= `9` { return c - `0` } else if `a` <= c && c <= `f` { diff --git a/vlib/net/http/header.v b/vlib/net/http/header.v index 7f4a19eac..49b987d98 100644 --- a/vlib/net/http/header.v +++ b/vlib/net/http/header.v @@ -630,7 +630,7 @@ struct HeaderKeyError { Error code int header string - invalid_char byte + invalid_char u8 } pub fn (err HeaderKeyError) msg() string { @@ -662,7 +662,7 @@ fn is_valid(header string) ? { } // is_token checks if the byte is valid for a header token -fn is_token(b byte) bool { +fn is_token(b u8) bool { return match b { 33, 35...39, 42, 43, 45, 46, 48...57, 65...90, 94...122, 124, 126 { true } else { false } diff --git a/vlib/net/net_windows.c.v b/vlib/net/net_windows.c.v index 337176f36..b003a3043 100644 --- a/vlib/net/net_windows.c.v +++ b/vlib/net/net_windows.c.v @@ -762,11 +762,11 @@ struct C.WSAData { mut: wVersion u16 wHighVersion u16 - szDescription [257]byte - szSystemStatus [129]byte + szDescription [257]u8 + szSystemStatus [129]u8 iMaxSockets u16 iMaxUdpDg u16 - lpVendorInfo &byte + lpVendorInfo &u8 } fn init() { diff --git a/vlib/net/openssl/ssl_connection.v b/vlib/net/openssl/ssl_connection.v index 558274739..ca84e2b4d 100644 --- a/vlib/net/openssl/ssl_connection.v +++ b/vlib/net/openssl/ssl_connection.v @@ -147,7 +147,7 @@ pub fn (mut s SSLConn) connect(mut tcp_conn net.TcpConn, hostname string) ? { } } -pub fn (mut s SSLConn) socket_read_into_ptr(buf_ptr &byte, len int) ?int { +pub fn (mut s SSLConn) socket_read_into_ptr(buf_ptr &u8, len int) ?int { mut res := 0 for { res = C.SSL_read(voidptr(s.ssl), buf_ptr, len) diff --git a/vlib/net/tcp.v b/vlib/net/tcp.v index bb21b650f..2350296b1 100644 --- a/vlib/net/tcp.v +++ b/vlib/net/tcp.v @@ -52,7 +52,7 @@ pub fn (mut c TcpConn) close() ? { c.sock.close() ? } -pub fn (c TcpConn) read_ptr(buf_ptr &byte, len int) ?int { +pub fn (c TcpConn) read_ptr(buf_ptr &u8, len int) ?int { mut res := wrap_read_result(C.recv(c.sock.handle, voidptr(buf_ptr), len, 0)) ? $if trace_tcp ? { eprintln('<<< TcpConn.read_ptr | c.sock.handle: $c.sock.handle | buf_ptr: ${ptr_str(buf_ptr)} len: $len | res: $res') @@ -96,7 +96,7 @@ pub fn (mut c TcpConn) read_deadline() ?time.Time { } // write_ptr blocks and attempts to write all data -pub fn (mut c TcpConn) write_ptr(b &byte, len int) ?int { +pub fn (mut c TcpConn) write_ptr(b &u8, len int) ?int { $if trace_tcp ? { eprintln( '>>> TcpConn.write_ptr | c.sock.handle: $c.sock.handle | b: ${ptr_str(b)} len: $len |\n' + diff --git a/vlib/net/udp.v b/vlib/net/udp.v index d5435ca98..2821f23bd 100644 --- a/vlib/net/udp.v +++ b/vlib/net/udp.v @@ -58,7 +58,7 @@ pub fn dial_udp(raddr string) ?&UdpConn { // } // } -pub fn (mut c UdpConn) write_ptr(b &byte, len int) ?int { +pub fn (mut c UdpConn) write_ptr(b &u8, len int) ?int { remote := c.sock.remote() or { return err_no_udp_remote } return c.write_to_ptr(remote, b, len) } @@ -71,7 +71,7 @@ pub fn (mut c UdpConn) write_string(s string) ?int { return c.write_ptr(s.str, s.len) } -pub fn (mut c UdpConn) write_to_ptr(addr Addr, b &byte, len int) ?int { +pub fn (mut c UdpConn) write_to_ptr(addr Addr, b &u8, len int) ?int { res := C.sendto(c.sock.handle, b, len, 0, voidptr(&addr), addr.len()) if res >= 0 { return res diff --git a/vlib/net/unix/stream_nix.v b/vlib/net/unix/stream_nix.v index 6448843b6..790471604 100644 --- a/vlib/net/unix/stream_nix.v +++ b/vlib/net/unix/stream_nix.v @@ -170,7 +170,7 @@ pub fn (mut c StreamConn) close() ? { } // write_ptr blocks and attempts to write all data -pub fn (mut c StreamConn) write_ptr(b &byte, len int) ?int { +pub fn (mut c StreamConn) write_ptr(b &u8, len int) ?int { $if trace_unix ? { eprintln( '>>> StreamConn.write_ptr | c.sock.handle: $c.sock.handle | b: ${ptr_str(b)} len: $len |\n' + @@ -208,7 +208,7 @@ pub fn (mut c StreamConn) write_string(s string) ?int { return c.write_ptr(s.str, s.len) } -pub fn (mut c StreamConn) read_ptr(buf_ptr &byte, len int) ?int { +pub fn (mut c StreamConn) read_ptr(buf_ptr &u8, len int) ?int { mut res := wrap_read_result(C.recv(c.sock.handle, voidptr(buf_ptr), len, 0)) ? $if trace_unix ? { eprintln('<<< StreamConn.read_ptr | c.sock.handle: $c.sock.handle | buf_ptr: ${ptr_str(buf_ptr)} len: $len | res: $res') diff --git a/vlib/net/urllib/urllib.v b/vlib/net/urllib/urllib.v index bd91e4f3d..0fdc31555 100644 --- a/vlib/net/urllib/urllib.v +++ b/vlib/net/urllib/urllib.v @@ -38,7 +38,7 @@ fn error_msg(message string, val string) string { // // Please be informed that for now should_escape does not check all // reserved characters correctly. See golang.org/issue/5684. -fn should_escape(c byte, mode EncodingMode) bool { +fn should_escape(c u8, mode EncodingMode) bool { // §2.3 Unreserved characters (alphanum) if (`a` <= c && c <= `z`) || (`A` <= c && c <= `Z`) || (`0` <= c && c <= `9`) { return false @@ -417,7 +417,7 @@ fn get_scheme(rawurl string) ?string { // split slices s into two substrings separated by the first occurence of // sep. If cutc is true then sep is included with the second substring. // If sep does not occur in s then s and the empty string is returned. -fn split(s string, sep byte, cutc bool) (string, string) { +fn split(s string, sep u8, cutc bool) (string, string) { i := s.index_u8(sep) if i < 0 { return s, '' @@ -1062,7 +1062,7 @@ fn string_contains_ctl_u8(s string) bool { return false } -pub fn ishex(c byte) bool { +pub fn ishex(c u8) bool { if `0` <= c && c <= `9` { return true } else if `a` <= c && c <= `f` { @@ -1073,7 +1073,7 @@ pub fn ishex(c byte) bool { return false } -fn unhex(c byte) byte { +fn unhex(c u8) u8 { if `0` <= c && c <= `9` { return c - `0` } else if `a` <= c && c <= `f` { diff --git a/vlib/net/websocket/io.v b/vlib/net/websocket/io.v index cd9b8dcff..35d6e08a6 100644 --- a/vlib/net/websocket/io.v +++ b/vlib/net/websocket/io.v @@ -28,7 +28,7 @@ fn (mut ws Client) socket_read(mut buffer []u8) ?int { } // socket_read reads from socket into the provided byte pointer and length -fn (mut ws Client) socket_read_ptr(buf_ptr &byte, len int) ?int { +fn (mut ws Client) socket_read_ptr(buf_ptr &u8, len int) ?int { lock { if ws.state in [.closed, .closing] || ws.conn.sock.handle <= 1 { return error('socket_read_ptr: trying to read a closed socket') diff --git a/vlib/net/websocket/websocket_client.v b/vlib/net/websocket/websocket_client.v index 747020a4f..be216b0f1 100644 --- a/vlib/net/websocket/websocket_client.v +++ b/vlib/net/websocket/websocket_client.v @@ -60,7 +60,7 @@ pub enum State { pub struct Message { pub: opcode OPCode // websocket frame type of this message - payload []u8 // payload of the message + payload []u8 // payload of the message } // OPCode represents the supported websocket frame types @@ -229,7 +229,7 @@ pub fn (mut ws Client) pong() ? { } // write_ptr writes len bytes provided a byteptr with a websocket messagetype -pub fn (mut ws Client) write_ptr(bytes &byte, payload_len int, code OPCode) ?int { +pub fn (mut ws Client) write_ptr(bytes &u8, payload_len int, code OPCode) ?int { // ws.debug_log('write_ptr code: $code') if ws.state != .open || ws.conn.sock.handle < 1 { // todo: send error here later diff --git a/vlib/os/fd.c.v b/vlib/os/fd.c.v index 2dcc5f3a1..d558ea359 100644 --- a/vlib/os/fd.c.v +++ b/vlib/os/fd.c.v @@ -22,7 +22,7 @@ pub fn fd_write(fd int, s string) { return } remaining = remaining - written - sp = unsafe { voidptr(sp + written)} + sp = unsafe { voidptr(sp + written) } } } diff --git a/vlib/os/file.c.v b/vlib/os/file.c.v index 45eedc7d4..b27a4bd0c 100644 --- a/vlib/os/file.c.v +++ b/vlib/os/file.c.v @@ -465,7 +465,7 @@ pub fn (f &File) read_from(pos u64, mut buf []u8) ?int { // read_into_ptr reads at most max_size bytes from the file and writes it into ptr. // Returns the amount of bytes read or an error. -pub fn (f &File) read_into_ptr(ptr &byte, max_size int) ?int { +pub fn (f &File) read_into_ptr(ptr &u8, max_size int) ?int { return fread(ptr, 1, max_size, f.cfile) } diff --git a/vlib/os/file_test.v b/vlib/os/file_test.v index ccd529fe4..b9ddac395 100644 --- a/vlib/os/file_test.v +++ b/vlib/os/file_test.v @@ -286,7 +286,7 @@ fn test_read_raw() ? { f.close() f = os.open_file(tfile, 'r') ? p := f.read_raw() ? - b := f.read_raw() ? + b := f.read_raw() ? c := f.read_raw() ? x := f.read_raw() ? f.close() @@ -309,8 +309,8 @@ fn test_read_raw_at() ? { mut at := u64(3) p := f.read_raw_at(at) ? at += sizeof(Point) - b := f.read_raw_at(at) ? - at += sizeof(byte) + b := f.read_raw_at(at) ? + at += sizeof(u8) c := f.read_raw_at(at) ? at += sizeof(Color) x := f.read_raw_at(at) ? @@ -345,7 +345,7 @@ fn test_seek() ? { // f.seek(i64(sizeof(Point)), .start) ? assert f.tell() ? == sizeof(Point) - b := f.read_raw() ? + b := f.read_raw() ? assert b == another_byte f.seek(i64(sizeof(Color)), .current) ? diff --git a/vlib/os/process_windows.c.v b/vlib/os/process_windows.c.v index 40cd59fdb..1d513ea2b 100644 --- a/vlib/os/process_windows.c.v +++ b/vlib/os/process_windows.c.v @@ -10,7 +10,7 @@ fn C.PeekNamedPipe(hNamedPipe voidptr, lpBuffer voidptr, nBufferSize int, lpByte type FN_NTSuspendResume = fn (voidptr) -fn ntdll_fn(name &byte) FN_NTSuspendResume { +fn ntdll_fn(name &u8) FN_NTSuspendResume { ntdll := C.GetModuleHandleA(c'NTDLL') if ntdll == 0 { return FN_NTSuspendResume(0) diff --git a/vlib/pg/pg.v b/vlib/pg/pg.v index 0f09b644c..6b210d43d 100644 --- a/vlib/pg/pg.v +++ b/vlib/pg/pg.v @@ -38,11 +38,11 @@ pub: dbname string } -fn C.PQconnectdb(a &byte) &C.PGconn +fn C.PQconnectdb(a &u8) &C.PGconn -fn C.PQerrorMessage(voidptr) &byte +fn C.PQerrorMessage(voidptr) &u8 -fn C.PQgetvalue(&C.PGResult, int, int) &byte +fn C.PQgetvalue(&C.PGResult, int, int) &u8 fn C.PQstatus(voidptr) int @@ -52,20 +52,20 @@ fn C.PQntuples(&C.PGResult) int fn C.PQnfields(&C.PGResult) int -fn C.PQexec(voidptr, &byte) &C.PGResult +fn C.PQexec(voidptr, &u8) &C.PGResult // Params: // const Oid *paramTypes // const char *const *paramValues // const int *paramLengths // const int *paramFormats -fn C.PQexecParams(conn voidptr, command &byte, nParams int, paramTypes int, paramValues &byte, paramLengths int, paramFormats int, resultFormat int) &C.PGResult +fn C.PQexecParams(conn voidptr, command &u8, nParams int, paramTypes int, paramValues &u8, paramLengths int, paramFormats int, resultFormat int) &C.PGResult -fn C.PQputCopyData(conn voidptr, buffer &byte, nbytes int) int +fn C.PQputCopyData(conn voidptr, buffer &u8, nbytes int) int -fn C.PQputCopyEnd(voidptr, &byte) int +fn C.PQputCopyEnd(voidptr, &u8) int -fn C.PQgetCopyData(conn voidptr, buffer &&byte, async int) int +fn C.PQgetCopyData(conn voidptr, buffer &&u8, async int) int fn C.PQclear(&C.PGResult) voidptr diff --git a/vlib/picoev/picoev.v b/vlib/picoev/picoev.v index ad4a27b8c..afadc6f1d 100644 --- a/vlib/picoev/picoev.v +++ b/vlib/picoev/picoev.v @@ -70,10 +70,10 @@ struct Picoev { timeout_secs int max_headers int mut: - date &byte - buf &byte + date &u8 + buf &u8 idx [1024]int - out &byte + out &u8 } [inline] @@ -94,7 +94,7 @@ fn close_conn(loop &C.picoev_loop, fd int) { } [inline] -fn req_read(fd int, b &byte, max_len int, idx int) int { +fn req_read(fd int, b &u8, max_len int, idx int) int { unsafe { return C.read(fd, b + idx, max_len - idx) } diff --git a/vlib/picohttpparser/misc.v b/vlib/picohttpparser/misc.v index 6c8e1e7b7..7bce4e3ec 100644 --- a/vlib/picohttpparser/misc.v +++ b/vlib/picohttpparser/misc.v @@ -1,7 +1,7 @@ module picohttpparser [inline; unsafe] -fn cpy(dst &byte, src &byte, len int) int { +fn cpy(dst &u8, src &u8, len int) int { unsafe { C.memcpy(dst, src, len) } return len } diff --git a/vlib/picohttpparser/response.v b/vlib/picohttpparser/response.v index d181a5f16..c7943520c 100644 --- a/vlib/picohttpparser/response.v +++ b/vlib/picohttpparser/response.v @@ -3,10 +3,10 @@ module picohttpparser pub struct Response { fd int pub: - date &byte = 0 - buf_start &byte = 0 + date &u8 = 0 + buf_start &u8 = 0 pub mut: - buf &byte = 0 + buf &u8 = 0 } [inline] diff --git a/vlib/rand/mt19937/mt19937.v b/vlib/rand/mt19937/mt19937.v index 5577328dc..e493b4201 100644 --- a/vlib/rand/mt19937/mt19937.v +++ b/vlib/rand/mt19937/mt19937.v @@ -99,7 +99,7 @@ pub fn (mut rng MT19937RNG) seed(seed_data []u32) { // byte returns a uniformly distributed pseudorandom 8-bit unsigned positive `byte`. [inline] -pub fn (mut rng MT19937RNG) u8() byte { +pub fn (mut rng MT19937RNG) u8() u8 { if rng.bytes_left >= 1 { rng.bytes_left -= 1 value := u8(rng.buffer) diff --git a/vlib/rand/musl/musl_rng.v b/vlib/rand/musl/musl_rng.v index 96d437ddf..22ef39b95 100644 --- a/vlib/rand/musl/musl_rng.v +++ b/vlib/rand/musl/musl_rng.v @@ -29,7 +29,7 @@ pub fn (mut rng MuslRNG) seed(seed_data []u32) { // byte returns a uniformly distributed pseudorandom 8-bit unsigned positive `byte`. [inline] -pub fn (mut rng MuslRNG) u8() byte { +pub fn (mut rng MuslRNG) u8() u8 { if rng.bytes_left >= 1 { rng.bytes_left -= 1 value := u8(rng.buffer) diff --git a/vlib/rand/pcg32/pcg32.v b/vlib/rand/pcg32/pcg32.v index e0b54d99a..dfe1b2c03 100644 --- a/vlib/rand/pcg32/pcg32.v +++ b/vlib/rand/pcg32/pcg32.v @@ -39,7 +39,7 @@ pub fn (mut rng PCG32RNG) seed(seed_data []u32) { // byte returns a uniformly distributed pseudorandom 8-bit unsigned positive `byte`. [inline] -pub fn (mut rng PCG32RNG) u8() byte { +pub fn (mut rng PCG32RNG) u8() u8 { if rng.bytes_left >= 1 { rng.bytes_left -= 1 value := u8(rng.buffer) diff --git a/vlib/rand/rand.v b/vlib/rand/rand.v index 0441815a2..88eddc009 100644 --- a/vlib/rand/rand.v +++ b/vlib/rand/rand.v @@ -16,7 +16,7 @@ import time pub interface PRNG { mut: seed(seed_data []u32) - u8() byte + u8() u8 u16() u16 u32() u32 u64() u64 @@ -424,7 +424,7 @@ pub fn intn(max int) ?int { } // byte returns a uniformly distributed pseudorandom 8-bit unsigned positive `byte`. -pub fn u8() byte { +pub fn u8() u8 { return default_rng.u8() } diff --git a/vlib/rand/splitmix64/splitmix64.v b/vlib/rand/splitmix64/splitmix64.v index 44efeac19..116781427 100644 --- a/vlib/rand/splitmix64/splitmix64.v +++ b/vlib/rand/splitmix64/splitmix64.v @@ -29,7 +29,7 @@ pub fn (mut rng SplitMix64RNG) seed(seed_data []u32) { // byte returns a uniformly distributed pseudorandom 8-bit unsigned positive `byte`. [inline] -pub fn (mut rng SplitMix64RNG) u8() byte { +pub fn (mut rng SplitMix64RNG) u8() u8 { if rng.bytes_left >= 1 { rng.bytes_left -= 1 value := u8(rng.buffer) diff --git a/vlib/rand/sys/system_rng.c.v b/vlib/rand/sys/system_rng.c.v index 4c84bf8e4..3b4774891 100644 --- a/vlib/rand/sys/system_rng.c.v +++ b/vlib/rand/sys/system_rng.c.v @@ -64,7 +64,7 @@ pub fn (r SysRNG) default_rand() int { // byte returns a uniformly distributed pseudorandom 8-bit unsigned positive `byte`. [inline] -pub fn (mut r SysRNG) u8() byte { +pub fn (mut r SysRNG) u8() u8 { if r.bytes_left >= 1 { r.bytes_left -= 1 value := u8(r.buffer) diff --git a/vlib/rand/wyrand/wyrand.v b/vlib/rand/wyrand/wyrand.v index 23989df8d..6a0e41abb 100644 --- a/vlib/rand/wyrand/wyrand.v +++ b/vlib/rand/wyrand/wyrand.v @@ -35,7 +35,7 @@ pub fn (mut rng WyRandRNG) seed(seed_data []u32) { // byte returns a uniformly distributed pseudorandom 8-bit unsigned positive `byte`. [inline] -pub fn (mut rng WyRandRNG) u8() byte { +pub fn (mut rng WyRandRNG) u8() u8 { // Can we extract a value from the buffer? if rng.bytes_left >= 1 { rng.bytes_left -= 1 diff --git a/vlib/readline/readline_linux.c.v b/vlib/readline/readline_linux.c.v index d5d4d4f71..a5c22c9e1 100644 --- a/vlib/readline/readline_linux.c.v +++ b/vlib/readline/readline_linux.c.v @@ -22,7 +22,7 @@ mut: c_oflag int c_cflag int c_lflag int - c_line byte + c_line u8 c_cc [cclen]int } @@ -32,7 +32,7 @@ mut: c_oflag u32 c_cflag u32 c_lflag u32 - c_line byte + c_line u8 c_cc [cclen]int } @@ -300,7 +300,7 @@ fn (r Readline) analyse_extended_control() Action { // analyse_extended_control_no_eat returns an `Action` based on the type of input byte given in `c`. // analyse_extended_control_no_eat specialises in detection of delete and insert keys. -fn (r Readline) analyse_extended_control_no_eat(last_c byte) Action { +fn (r Readline) analyse_extended_control_no_eat(last_c u8) Action { c := r.read_char() match u8(c) { `~` { diff --git a/vlib/regex/regex.v b/vlib/regex/regex.v index ae5ff2fc1..53683165a 100644 --- a/vlib/regex/regex.v +++ b/vlib/regex/regex.v @@ -75,7 +75,7 @@ General Utilities */ // utf8util_char_len calculate the length in bytes of a utf8 char [inline] -fn utf8util_char_len(b byte) int { +fn utf8util_char_len(b u8) int { return ((0xe5000000 >> ((b >> 3) & 0x1e)) & 3) + 1 } @@ -100,7 +100,7 @@ fn (re RE) get_char(in_txt string, i int) (u32, int) { // get_charb get a char from position i and return an u32 with the unicode code [direct_array_access; inline] -fn (re RE) get_charb(in_txt &byte, i int) (u32, int) { +fn (re RE) get_charb(in_txt &u8, i int) (u32, int) { // ascii 8 bit if (re.flag & regex.f_bin) != 0 || unsafe { in_txt[i] } & 0x80 == 0 { return u32(unsafe { in_txt[i] }), 1 @@ -117,7 +117,7 @@ fn (re RE) get_charb(in_txt &byte, i int) (u32, int) { } [inline] -fn is_alnum(in_char byte) bool { +fn is_alnum(in_char u8) bool { mut tmp := in_char - `A` if tmp <= 25 { return true @@ -137,28 +137,28 @@ fn is_alnum(in_char byte) bool { } [inline] -fn is_not_alnum(in_char byte) bool { +fn is_not_alnum(in_char u8) bool { return !is_alnum(in_char) } [inline] -fn is_space(in_char byte) bool { +fn is_space(in_char u8) bool { return in_char in regex.spaces } [inline] -fn is_not_space(in_char byte) bool { +fn is_not_space(in_char u8) bool { return !is_space(in_char) } [inline] -fn is_digit(in_char byte) bool { +fn is_digit(in_char u8) bool { tmp := in_char - `0` return tmp <= 0x09 } [inline] -fn is_not_digit(in_char byte) bool { +fn is_not_digit(in_char u8) bool { return !is_digit(in_char) } @@ -175,13 +175,13 @@ fn is_not_wordchar(in_char byte) bool { */ [inline] -fn is_lower(in_char byte) bool { +fn is_lower(in_char u8) bool { tmp := in_char - `a` return tmp <= 25 } [inline] -fn is_upper(in_char byte) bool { +fn is_upper(in_char u8) bool { tmp := in_char - `A` return tmp <= 25 } @@ -231,14 +231,14 @@ fn simple_log(txt string) { * Token Structs * ******************************************************************************/ -pub type FnValidator = fn (byte) bool +pub type FnValidator = fn (u8) bool struct Token { mut: ist rune // char ch rune // char of the token if any - ch_len byte // char len + ch_len u8 // char len // Quantifiers / branch rep_min int // used also for jump next in the OR branch [no match] pc jump rep_max int // used also for jump next in the OR branch [ match] pc jump @@ -1666,7 +1666,7 @@ pub mut: } [direct_array_access] -pub fn (mut re RE) match_base(in_txt &byte, in_txt_len int) (int, int) { +pub fn (mut re RE) match_base(in_txt &u8, in_txt_len int) (int, int) { // result status mut result := regex.no_match_found // function return diff --git a/vlib/sokol/gfx/gfx_structs.c.v b/vlib/sokol/gfx/gfx_structs.c.v index b3ac95ce0..9acadae8a 100644 --- a/vlib/sokol/gfx/gfx_structs.c.v +++ b/vlib/sokol/gfx/gfx_structs.c.v @@ -527,9 +527,9 @@ struct C.sg_stencil_state { enabled bool front StencilFaceState back StencilFaceState - read_mask byte - write_mask byte - ref byte + read_mask u8 + write_mask u8 + ref u8 } pub type StencilState = C.sg_stencil_state @@ -594,7 +594,7 @@ pub type DepthAttachmentAction = C.sg_depth_attachment_action struct C.sg_stencil_attachment_action { pub mut: action Action - value byte + value u8 } pub type StencilAttachmentAction = C.sg_stencil_attachment_action diff --git a/vlib/sokol/sapp/sapp_structs.c.v b/vlib/sokol/sapp/sapp_structs.c.v index 04bdda02b..460b4ab16 100644 --- a/vlib/sokol/sapp/sapp_structs.c.v +++ b/vlib/sokol/sapp/sapp_structs.c.v @@ -37,7 +37,7 @@ pub: frame_cb fn () cleanup_cb fn () event_cb fn (&Event) //&sapp_event) - fail_cb fn (&byte) + fail_cb fn (&u8) user_data voidptr // these are the user-provided callbacks with user data init_userdata_cb fn (voidptr) diff --git a/vlib/sokol/sapp/sapp_v.c.v b/vlib/sokol/sapp/sapp_v.c.v index 283a88f82..bca061a2f 100644 --- a/vlib/sokol/sapp/sapp_v.c.v +++ b/vlib/sokol/sapp/sapp_v.c.v @@ -45,7 +45,7 @@ pub fn screenshot_png(path string) ? { } // write_rgba_to_ppm writes `pixels` data in RGBA format to PPM3 format. -fn write_rgba_to_ppm(path string, w int, h int, components int, pixels &byte) ? { +fn write_rgba_to_ppm(path string, w int, h int, components int, pixels &u8) ? { mut f_out := os.create(path) ? defer { f_out.close() diff --git a/vlib/sokol/sapp/screenshot.c.v b/vlib/sokol/sapp/screenshot.c.v index 8aaba15f0..23e1fe3d4 100644 --- a/vlib/sokol/sapp/screenshot.c.v +++ b/vlib/sokol/sapp/screenshot.c.v @@ -6,7 +6,7 @@ pub struct Screenshot { height int size int mut: - pixels &byte + pixels &u8 } [manualfree] diff --git a/vlib/sokol/sfons/sfons.c.v b/vlib/sokol/sfons/sfons.c.v index 8a8f31278..4d5720f62 100644 --- a/vlib/sokol/sfons/sfons.c.v +++ b/vlib/sokol/sfons/sfons.c.v @@ -17,7 +17,7 @@ pub fn destroy(ctx &fontstash.Context) { } [inline] -pub fn rgba(r byte, g byte, b byte, a byte) u32 { +pub fn rgba(r u8, g u8, b u8, a u8) u32 { return C.sfons_rgba(r, g, b, a) } diff --git a/vlib/sokol/sfons/sfons_funcs.c.v b/vlib/sokol/sfons/sfons_funcs.c.v index 377fc3645..3bf0e4ecd 100644 --- a/vlib/sokol/sfons/sfons_funcs.c.v +++ b/vlib/sokol/sfons/sfons_funcs.c.v @@ -4,5 +4,5 @@ import fontstash fn C.sfons_create(width int, height int, flags int) &fontstash.Context fn C.sfons_destroy(ctx &fontstash.Context) -fn C.sfons_rgba(r byte, g byte, b byte, a byte) u32 +fn C.sfons_rgba(r u8, g u8, b u8, a u8) u32 fn C.sfons_flush(ctx &fontstash.Context) diff --git a/vlib/sokol/sgl/sgl.c.v b/vlib/sokol/sgl/sgl.c.v index 502fbda10..692790471 100644 --- a/vlib/sokol/sgl/sgl.c.v +++ b/vlib/sokol/sgl/sgl.c.v @@ -240,12 +240,12 @@ pub fn c4f(r f32, g f32, b f32, a f32) { } [inline] -pub fn c3b(r byte, g byte, b byte) { +pub fn c3b(r u8, g u8, b u8) { C.sgl_c3b(r, g, b) } [inline] -pub fn c4b(r byte, g byte, b byte, a byte) { +pub fn c4b(r u8, g u8, b u8, a u8) { C.sgl_c4b(r, g, b, a) } @@ -316,7 +316,7 @@ pub fn v2f_c3f(x f32, y f32, r f32, g f32, b f32) { } [inline] -pub fn v2f_c3b(x f32, y f32, r byte, g byte, b byte) { +pub fn v2f_c3b(x f32, y f32, r u8, g u8, b u8) { C.sgl_v2f_c3b(x, y, r, g, b) } @@ -326,7 +326,7 @@ pub fn v2f_c4f(x f32, y f32, r f32, g f32, b f32, a f32) { } [inline] -pub fn v2f_c4b(x f32, y f32, r byte, g byte, b byte, a byte) { +pub fn v2f_c4b(x f32, y f32, r u8, g u8, b u8, a u8) { C.sgl_v2f_c4b(x, y, r, g, b, a) } @@ -341,7 +341,7 @@ pub fn v3f_c3f(x f32, y f32, z f32, r f32, g f32, b f32) { } [inline] -pub fn v3f_c3b(x f32, y f32, z f32, r byte, g byte, b byte) { +pub fn v3f_c3b(x f32, y f32, z f32, r u8, g u8, b u8) { C.sgl_v3f_c3b(x, y, z, r, g, b) } @@ -351,7 +351,7 @@ pub fn v3f_c4f(x f32, y f32, z f32, r f32, g f32, b f32, a f32) { } [inline] -pub fn v3f_c4b(x f32, y f32, z f32, r byte, g byte, b byte, a byte) { +pub fn v3f_c4b(x f32, y f32, z f32, r u8, g u8, b u8, a u8) { C.sgl_v3f_c4b(x, y, z, r, g, b, a) } @@ -366,7 +366,7 @@ pub fn v2f_t2f_c3f(x f32, y f32, u f32, v f32, r f32, g f32, b f32) { } [inline] -pub fn v2f_t2f_c3b(x f32, y f32, u f32, v f32, r byte, g byte, b byte) { +pub fn v2f_t2f_c3b(x f32, y f32, u f32, v f32, r u8, g u8, b u8) { C.sgl_v2f_t2f_c3b(x, y, u, v, r, g, b) } @@ -376,7 +376,7 @@ pub fn v2f_t2f_c4f(x f32, y f32, u f32, v f32, r f32, g f32, b f32, a f32) { } [inline] -pub fn v2f_t2f_c4b(x f32, y f32, u f32, v f32, r byte, g byte, b byte, a byte) { +pub fn v2f_t2f_c4b(x f32, y f32, u f32, v f32, r u8, g u8, b u8, a u8) { C.sgl_v2f_t2f_c4b(x, y, u, v, r, g, b, a) } @@ -391,7 +391,7 @@ pub fn v3f_t2f_c3f(x f32, y f32, z f32, u f32, v f32, r f32, g f32, b f32) { } [inline] -pub fn v3f_t2f_c3b(x f32, y f32, z f32, u f32, v f32, r byte, g byte, b byte) { +pub fn v3f_t2f_c3b(x f32, y f32, z f32, u f32, v f32, r u8, g u8, b u8) { C.sgl_v3f_t2f_c3b(x, y, z, u, v, r, g, b) } @@ -401,7 +401,7 @@ pub fn v3f_t2f_c4f(x f32, y f32, z f32, u f32, v f32, r f32, g f32, b f32, a f32 } [inline] -pub fn v3f_t2f_c4b(x f32, y f32, z f32, u f32, v f32, r byte, g byte, b byte, a byte) { +pub fn v3f_t2f_c4b(x f32, y f32, z f32, u f32, v f32, r u8, g u8, b u8, a u8) { C.sgl_v3f_t2f_c4b(x, y, z, u, v, r, g, b, a) } diff --git a/vlib/sokol/sgl/sgl_funcs.c.v b/vlib/sokol/sgl/sgl_funcs.c.v index 0a477d394..a1b444adc 100644 --- a/vlib/sokol/sgl/sgl_funcs.c.v +++ b/vlib/sokol/sgl/sgl_funcs.c.v @@ -59,8 +59,8 @@ fn C.sgl_pop_matrix() fn C.sgl_t2f(u f32, v f32) fn C.sgl_c3f(r f32, g f32, b f32) fn C.sgl_c4f(r f32, g f32, b f32, a f32) -fn C.sgl_c3b(r byte, g byte, b byte) -fn C.sgl_c4b(r byte, g byte, b byte, a byte) +fn C.sgl_c3b(r u8, g u8, b u8) +fn C.sgl_c4b(r u8, g u8, b u8, a u8) fn C.sgl_c1i(rgba u32) fn C.sgl_point_size(s f32) @@ -76,24 +76,24 @@ fn C.sgl_v3f(x f32, y f32, z f32) fn C.sgl_v2f_t2f(x f32, y f32, u f32, v f32) fn C.sgl_v3f_t2f(x f32, y f32, z f32, u f32, v f32) fn C.sgl_v2f_c3f(x f32, y f32, r f32, g f32, b f32) -fn C.sgl_v2f_c3b(x f32, y f32, r byte, g byte, b byte) +fn C.sgl_v2f_c3b(x f32, y f32, r u8, g u8, b u8) fn C.sgl_v2f_c4f(x f32, y f32, r f32, g f32, b f32, a f32) -fn C.sgl_v2f_c4b(x f32, y f32, r byte, g byte, b byte, a byte) +fn C.sgl_v2f_c4b(x f32, y f32, r u8, g u8, b u8, a u8) fn C.sgl_v2f_c1i(x f32, y f32, rgba u32) fn C.sgl_v3f_c3f(x f32, y f32, z f32, r f32, g f32, b f32) -fn C.sgl_v3f_c3b(x f32, y f32, z f32, r byte, g byte, b byte) +fn C.sgl_v3f_c3b(x f32, y f32, z f32, r u8, g u8, b u8) fn C.sgl_v3f_c4f(x f32, y f32, z f32, r f32, g f32, b f32, a f32) -fn C.sgl_v3f_c4b(x f32, y f32, z f32, r byte, g byte, b byte, a byte) +fn C.sgl_v3f_c4b(x f32, y f32, z f32, r u8, g u8, b u8, a u8) fn C.sgl_v3f_c1i(x f32, y f32, z f32, rgba u32) fn C.sgl_v2f_t2f_c3f(x f32, y f32, u f32, v f32, r f32, g f32, b f32) -fn C.sgl_v2f_t2f_c3b(x f32, y f32, u f32, v f32, r byte, g byte, b byte) +fn C.sgl_v2f_t2f_c3b(x f32, y f32, u f32, v f32, r u8, g u8, b u8) fn C.sgl_v2f_t2f_c4f(x f32, y f32, u f32, v f32, r f32, g f32, b f32, a f32) -fn C.sgl_v2f_t2f_c4b(x f32, y f32, u f32, v f32, r byte, g byte, b byte, a byte) +fn C.sgl_v2f_t2f_c4b(x f32, y f32, u f32, v f32, r u8, g u8, b u8, a u8) fn C.sgl_v2f_t2f_c1i(x f32, y f32, u f32, v f32, rgba u32) fn C.sgl_v3f_t2f_c3f(x f32, y f32, z f32, u f32, v f32, r f32, g f32, b f32) -fn C.sgl_v3f_t2f_c3b(x f32, y f32, z f32, u f32, v f32, r byte, g byte, b byte) +fn C.sgl_v3f_t2f_c3b(x f32, y f32, z f32, u f32, v f32, r u8, g u8, b u8) fn C.sgl_v3f_t2f_c4f(x f32, y f32, z f32, u f32, v f32, r f32, g f32, b f32, a f32) -fn C.sgl_v3f_t2f_c4b(x f32, y f32, z f32, u f32, v f32, r byte, g byte, b byte, a byte) +fn C.sgl_v3f_t2f_c4b(x f32, y f32, z f32, u f32, v f32, r u8, g u8, b u8, a u8) fn C.sgl_v3f_t2f_c1i(x f32, y f32, z f32, u f32, v f32, rgba u32) fn C.sgl_end() diff --git a/vlib/sqlite/sqlite.v b/vlib/sqlite/sqlite.v index 5a188cafc..5689296ed 100644 --- a/vlib/sqlite/sqlite.v +++ b/vlib/sqlite/sqlite.v @@ -72,7 +72,7 @@ fn C.sqlite3_finalize(&C.sqlite3_stmt) int // fn C.sqlite3_column_name(&C.sqlite3_stmt, int) &char -fn C.sqlite3_column_text(&C.sqlite3_stmt, int) &byte +fn C.sqlite3_column_text(&C.sqlite3_stmt, int) &u8 fn C.sqlite3_column_int(&C.sqlite3_stmt, int) int diff --git a/vlib/stbi/stbi.c.v b/vlib/stbi/stbi.c.v index 474a3c04c..f970bb3a1 100644 --- a/vlib/stbi/stbi.c.v +++ b/vlib/stbi/stbi.c.v @@ -69,7 +69,7 @@ pub fn write_tga_with_rle(flag bool) { // Utility functions // //----------------------------------------------------------------------------- -fn C.stbi_image_free(retval_from_stbi_load &byte) +fn C.stbi_image_free(retval_from_stbi_load &u8) pub fn (img &Image) free() { C.stbi_image_free(img.data) @@ -80,9 +80,9 @@ pub fn (img &Image) free() { // Load functions // //----------------------------------------------------------------------------- -fn C.stbi_load(filename &char, x &int, y &int, channels_in_file &int, desired_channels int) &byte -fn C.stbi_load_from_file(f voidptr, x &int, y &int, channels_in_file &int, desired_channels int) &byte -fn C.stbi_load_from_memory(buffer &byte, len int, x &int, y &int, channels_in_file &int, desired_channels int) &byte +fn C.stbi_load(filename &char, x &int, y &int, channels_in_file &int, desired_channels int) &u8 +fn C.stbi_load_from_file(f voidptr, x &int, y &int, channels_in_file &int, desired_channels int) &u8 +fn C.stbi_load_from_memory(buffer &u8, len int, x &int, y &int, channels_in_file &int, desired_channels int) &u8 // load load an image from a path pub fn load(path string) ?Image { @@ -107,7 +107,7 @@ pub fn load(path string) ?Image { } // load_from_memory load an image from a memory buffer -pub fn load_from_memory(buf &byte, bufsize int) ?Image { +pub fn load_from_memory(buf &u8, bufsize int) ?Image { mut res := Image{ ok: true data: 0 @@ -126,30 +126,30 @@ pub fn load_from_memory(buf &byte, bufsize int) ?Image { // Write functions // //----------------------------------------------------------------------------- -fn C.stbi_write_png(filename &char, w int, h int, comp int, buffer &byte, stride_in_bytes int) int -fn C.stbi_write_bmp(filename &char, w int, h int, comp int, buffer &byte) int -fn C.stbi_write_tga(filename &char, w int, h int, comp int, buffer &byte) int -fn C.stbi_write_jpg(filename &char, w int, h int, comp int, buffer &byte, quality int) int +fn C.stbi_write_png(filename &char, w int, h int, comp int, buffer &u8, stride_in_bytes int) int +fn C.stbi_write_bmp(filename &char, w int, h int, comp int, buffer &u8) int +fn C.stbi_write_tga(filename &char, w int, h int, comp int, buffer &u8) int +fn C.stbi_write_jpg(filename &char, w int, h int, comp int, buffer &u8, quality int) int // fn C.stbi_write_hdr(filename &char, w int, h int, comp int, buffer &byte) int // buffer &byte => buffer &f32 // stbi_write_png write on path a PNG file // row_stride_in_bytes is usually equal to: w * comp -pub fn stbi_write_png(path string, w int, h int, comp int, buf &byte, row_stride_in_bytes int) ? { +pub fn stbi_write_png(path string, w int, h int, comp int, buf &u8, row_stride_in_bytes int) ? { if 0 == C.stbi_write_png(&char(path.str), w, h, comp, buf, row_stride_in_bytes) { return error('stbi_image failed to write png file to "$path"') } } // stbi_write_png write on path a BMP file -pub fn stbi_write_bmp(path string, w int, h int, comp int, buf &byte) ? { +pub fn stbi_write_bmp(path string, w int, h int, comp int, buf &u8) ? { if 0 == C.stbi_write_bmp(&char(path.str), w, h, comp, buf) { return error('stbi_image failed to write bmp file to "$path"') } } // stbi_write_png write on path a TGA file -pub fn stbi_write_tga(path string, w int, h int, comp int, buf &byte) ? { +pub fn stbi_write_tga(path string, w int, h int, comp int, buf &u8) ? { if 0 == C.stbi_write_tga(&char(path.str), w, h, comp, buf) { return error('stbi_image failed to write tga file to "$path"') } @@ -158,7 +158,7 @@ pub fn stbi_write_tga(path string, w int, h int, comp int, buf &byte) ? { // stbi_write_png write on path a JPG file // quality select teh compression quality of the JPG // quality is between 1 and 100. Higher quality looks better but results in a bigger image. -pub fn stbi_write_jpg(path string, w int, h int, comp int, buf &byte, quality int) ? { +pub fn stbi_write_jpg(path string, w int, h int, comp int, buf &u8, quality int) ? { if 0 == C.stbi_write_jpg(&char(path.str), w, h, comp, buf, quality) { return error('stbi_image failed to write jpg file to "$path"') } diff --git a/vlib/strconv/atof.c.v b/vlib/strconv/atof.c.v index 11663976e..c51bd3f29 100644 --- a/vlib/strconv/atof.c.v +++ b/vlib/strconv/atof.c.v @@ -100,15 +100,15 @@ fn sub96(s2 u32, s1 u32, s0 u32, d2 u32, d1 u32, d0 u32) (u32, u32, u32) { } // Utility functions -fn is_digit(x byte) bool { +fn is_digit(x u8) bool { return (x >= strconv.c_zero && x <= strconv.c_nine) == true } -fn is_space(x byte) bool { +fn is_space(x u8) bool { return x == `\t` || x == `\n` || x == `\v` || x == `\f` || x == `\r` || x == ` ` } -fn is_exp(x byte) bool { +fn is_exp(x u8) bool { return (x == `E` || x == `e`) == true } diff --git a/vlib/strconv/atoi.v b/vlib/strconv/atoi.v index fcc0191c8..8dd4c0002 100644 --- a/vlib/strconv/atoi.v +++ b/vlib/strconv/atoi.v @@ -12,7 +12,7 @@ const ( max_u64 = u64(18446744073709551615) // as u64 // use this until we add support ) -pub fn byte_to_lower(c byte) byte { +pub fn byte_to_lower(c u8) u8 { return c | (`x` - `X`) } diff --git a/vlib/strconv/format.v b/vlib/strconv/format.v index 47b10db40..39eae1266 100644 --- a/vlib/strconv/format.v +++ b/vlib/strconv/format.v @@ -80,7 +80,7 @@ Single format functions */ pub struct BF_param { pub mut: - pad_ch byte = u8(` `) // padding char + pad_ch u8 = u8(` `) // padding char len0 int = -1 // default len for whole the number or string len1 int = 6 // number of decimal digits, if needed positive bool = true // mandatory: the sign of the number passed diff --git a/vlib/strconv/format_mem.js.v b/vlib/strconv/format_mem.js.v index 36a673286..312992685 100644 --- a/vlib/strconv/format_mem.js.v +++ b/vlib/strconv/format_mem.js.v @@ -76,7 +76,7 @@ pub fn format_dec_sb(d u64, p BF_param, mut res strings.Builder) { // Legacy version // max u64 18446744073709551615 => 20 byte - mut buf := [32]byte{} + mut buf := [32]u8{} mut i := 20 mut d1 := d for i >= (21 - n_char) { diff --git a/vlib/strings/builder.c.v b/vlib/strings/builder.c.v index aa5f3146c..29a0609d6 100644 --- a/vlib/strings/builder.c.v +++ b/vlib/strings/builder.c.v @@ -18,7 +18,7 @@ pub fn new_builder(initial_size int) Builder { // write_ptr writes `len` bytes provided byteptr to the accumulated buffer [unsafe] -pub fn (mut b Builder) write_ptr(ptr &byte, len int) { +pub fn (mut b Builder) write_ptr(ptr &u8, len int) { if len == 0 { return } @@ -51,12 +51,12 @@ pub fn (mut b Builder) write_runes(runes []rune) { // write_b appends a single `data` byte to the accumulated buffer [deprecated: 'Use write_u8() instead'] [deprecated_after: '2022-02-11'] -pub fn (mut b Builder) write_b(data byte) { +pub fn (mut b Builder) write_b(data u8) { b << data } // write_byte appends a single `data` byte to the accumulated buffer -pub fn (mut b Builder) write_u8(data byte) { +pub fn (mut b Builder) write_u8(data u8) { b << data } @@ -81,7 +81,7 @@ pub fn (mut b Builder) drain_builder(mut other Builder, other_new_cap int) { // byte_at returns a byte, located at a given index `i`. // Note: it can panic, if there are not enough bytes in the strings builder yet. [inline] -pub fn (b &Builder) byte_at(n int) byte { +pub fn (b &Builder) byte_at(n int) u8 { return unsafe { (&[]u8(b))[n] } } diff --git a/vlib/strings/strings.c.v b/vlib/strings/strings.c.v index a07f34502..b475786ba 100644 --- a/vlib/strings/strings.c.v +++ b/vlib/strings/strings.c.v @@ -1,7 +1,7 @@ module strings // strings.repeat - fill a string with `n` repetitions of the character `c` -pub fn repeat(c byte, n int) string { +pub fn repeat(c u8, n int) string { if n <= 0 { return '' } diff --git a/vlib/strings/strings.js.v b/vlib/strings/strings.js.v index 2c3fe9657..866b80fb3 100644 --- a/vlib/strings/strings.js.v +++ b/vlib/strings/strings.js.v @@ -1,6 +1,6 @@ module strings -pub fn repeat(c byte, n int) string { +pub fn repeat(c u8, n int) string { if n <= 0 { return '' } diff --git a/vlib/strings/strings.v b/vlib/strings/strings.v index 2e43095f4..ce0c82ebc 100644 --- a/vlib/strings/strings.v +++ b/vlib/strings/strings.v @@ -24,7 +24,7 @@ pub fn random(n int) string { // find_between_pair_byte is the fastest in the find_between_pair_* family of functions. // Example: assert strings.find_between_pair_u8('(V) (NOT V)',`(`,`)`) == 'V' // Example: assert strings.find_between_pair_u8('s {X{Y}} s',`{`,`}`) == 'X{Y}' -pub fn find_between_pair_u8(input string, start byte, end byte) string { +pub fn find_between_pair_u8(input string, start u8, end u8) string { mut marks := 0 mut start_index := -1 for i, b in input { diff --git a/vlib/sync/channel_select_2_test.v b/vlib/sync/channel_select_2_test.v index f1e571adb..0c1b830d8 100644 --- a/vlib/sync/channel_select_2_test.v +++ b/vlib/sync/channel_select_2_test.v @@ -14,7 +14,7 @@ fn do_send_int(ch chan int) { } } -fn do_send_u8(ch chan byte) { +fn do_send_u8(ch chan u8) { for i in 0 .. 300 { ch <- u8(i) } @@ -29,7 +29,7 @@ fn do_send_i64(ch chan i64) { fn test_select() { chi := chan int{} chl := chan i64{cap: 1} - chb := chan byte{cap: 10} + chb := chan u8{cap: 10} recch := chan i64{cap: 0} go do_rec_i64(recch) go do_send_int(chi) diff --git a/vlib/sync/channel_select_test.v b/vlib/sync/channel_select_test.v index 9ef64d403..a8865a294 100644 --- a/vlib/sync/channel_select_test.v +++ b/vlib/sync/channel_select_test.v @@ -43,7 +43,7 @@ fn do_send_i64(mut ch Channel) { fn test_select() { mut chi := new_channel(0) mut chl := new_channel(1) - mut chb := new_channel(10) + mut chb := new_channel(10) mut recch := new_channel(0) go do_rec_i64(mut recch) go do_send_int(mut chi) diff --git a/vlib/sync/select_close_test.v b/vlib/sync/select_close_test.v index b733b8d7b..7a15bf9f5 100644 --- a/vlib/sync/select_close_test.v +++ b/vlib/sync/select_close_test.v @@ -42,7 +42,7 @@ fn do_send_i64(mut ch Channel) { fn test_select() { mut chi := new_channel(0) mut chl := new_channel(1) - mut chb := new_channel(10) + mut chb := new_channel(10) mut recch := new_channel(0) go do_rec_i64(mut recch) go do_send_int(mut chi) diff --git a/vlib/szip/szip.v b/vlib/szip/szip.v index 9e52fbe14..db3db33cf 100644 --- a/vlib/szip/szip.v +++ b/vlib/szip/szip.v @@ -15,13 +15,13 @@ fn C.zip_open(&char, int, char) &Zip fn C.zip_close(&Zip) -fn C.zip_entry_open(&Zip, &byte) int +fn C.zip_entry_open(&Zip, &u8) int fn C.zip_entry_openbyindex(&Zip, int) int fn C.zip_entry_close(&Zip) int -fn C.zip_entry_name(&Zip) &byte +fn C.zip_entry_name(&Zip) &u8 fn C.zip_entry_index(&Zip) int @@ -66,7 +66,7 @@ pub enum OpenMode { } [inline] -fn (om OpenMode) to_u8() byte { +fn (om OpenMode) to_u8() u8 { return match om { .write { `w` diff --git a/vlib/term/term_windows.c.v b/vlib/term/term_windows.c.v index db55b62f0..bf12e94a4 100644 --- a/vlib/term/term_windows.c.v +++ b/vlib/term/term_windows.c.v @@ -33,7 +33,7 @@ mut: union C.uChar { mut: UnicodeChar rune - AsciiChar byte + AsciiChar u8 } [typedef] diff --git a/vlib/term/ui/consoleapi_windows.c.v b/vlib/term/ui/consoleapi_windows.c.v index 7dc0aee04..3ebd0dae3 100644 --- a/vlib/term/ui/consoleapi_windows.c.v +++ b/vlib/term/ui/consoleapi_windows.c.v @@ -17,7 +17,7 @@ struct C.INPUT_RECORD { union C.uChar { mut: UnicodeChar rune - AsciiChar byte + AsciiChar u8 } [typedef] diff --git a/vlib/term/ui/input.v b/vlib/term/ui/input.v index c5e7b7d63..81b887f83 100644 --- a/vlib/term/ui/input.v +++ b/vlib/term/ui/input.v @@ -160,7 +160,7 @@ pub: // Keyboard event info code KeyCode modifiers Modifiers - ascii byte + ascii u8 utf8 string // Resized event info width int diff --git a/vlib/term/ui/ui.v b/vlib/term/ui/ui.v index 78e43eb52..512bc2c23 100644 --- a/vlib/term/ui/ui.v +++ b/vlib/term/ui/ui.v @@ -7,9 +7,9 @@ import strings pub struct Color { pub: - r byte - g byte - b byte + r u8 + g u8 + b u8 } pub fn (c Color) hex() string { diff --git a/vlib/toml/ast/types.v b/vlib/toml/ast/types.v index b3dd55358..f87386ec6 100644 --- a/vlib/toml/ast/types.v +++ b/vlib/toml/ast/types.v @@ -102,7 +102,7 @@ pub mut: pub: pos token.Pos is_multiline bool - quote byte + quote u8 } // str returns the `string` representation of the `Quoted` type. diff --git a/vlib/toml/decoder/decoder.v b/vlib/toml/decoder/decoder.v index fef1fa0a9..7006aa01a 100644 --- a/vlib/toml/decoder/decoder.v +++ b/vlib/toml/decoder/decoder.v @@ -159,9 +159,8 @@ pub fn decode_quoted_escapes(mut q ast.Quoted) ? { && u8(s.peek(3)).is_hex_digit() && u8(s.peek(4)).is_hex_digit() if is_valid_short { - is_valid_long := u8(s.peek(5)).is_hex_digit() - && u8(s.peek(6)).is_hex_digit() && u8(s.peek(7)).is_hex_digit() - && u8(s.peek(8)).is_hex_digit() + is_valid_long := u8(s.peek(5)).is_hex_digit() && u8(s.peek(6)).is_hex_digit() + && u8(s.peek(7)).is_hex_digit() && u8(s.peek(8)).is_hex_digit() // If it's a long type Unicode (\UXXXXXXXX) with a maximum of 10 chars: '\' + 'U' + 8 hex characters // we pass in 10 characters from the `u`/`U` which is the longest possible sequence // of 9 chars plus one extra. diff --git a/vlib/toml/scanner/scanner.v b/vlib/toml/scanner/scanner.v index e11782526..394a64058 100644 --- a/vlib/toml/scanner/scanner.v +++ b/vlib/toml/scanner/scanner.v @@ -536,7 +536,7 @@ fn (mut s Scanner) extract_multiline_string() ?string { // handle_escapes returns any escape character sequence. // For escape sequence validation see `Checker.check_quoted_escapes`. -fn (mut s Scanner) handle_escapes(quote byte, is_multiline bool) (string, int) { +fn (mut s Scanner) handle_escapes(quote u8, is_multiline bool) (string, int) { c := u8(s.at()) mut lit := c.ascii_str() is_literal_string := quote == `'` @@ -597,8 +597,7 @@ fn (mut s Scanner) extract_number() ?string { s.col += 2 } c = s.at() - if !(u8(c).is_hex_digit() || c in scanner.digit_extras) - || (c == `.` && s.is_left_of_assign) { + if !(u8(c).is_hex_digit() || c in scanner.digit_extras) || (c == `.` && s.is_left_of_assign) { break } s.pos++ diff --git a/vlib/toml/util/util.v b/vlib/toml/util/util.v index 60f42c8b0..41b994d9c 100644 --- a/vlib/toml/util/util.v +++ b/vlib/toml/util/util.v @@ -4,20 +4,20 @@ module util [inline] -pub fn is_key_char(c byte) bool { +pub fn is_key_char(c u8) bool { return (c >= `a` && c <= `z`) || (c >= `A` && c <= `Z`) // || c == `_` || c == `-` <- these are identified when tokenizing } // is_ascii_control_character returns true if `byte_char` is an ASCII control character. [inline] -pub fn is_ascii_control_character(byte_char byte) bool { +pub fn is_ascii_control_character(byte_char u8) bool { return (byte_char >= 0 && byte_char <= 0x1f) || byte_char == 0x7f } // is_illegal_ascii_control_character returns true if a `byte_char` ASCII control character // is considered "illegal" in TOML . [inline] -pub fn is_illegal_ascii_control_character(byte_char byte) bool { +pub fn is_illegal_ascii_control_character(byte_char u8) bool { return byte_char != 0x09 && is_ascii_control_character(byte_char) } diff --git a/vlib/v/ast/types.v b/vlib/v/ast/types.v index 8a65fb544..1862b5cae 100644 --- a/vlib/v/ast/types.v +++ b/vlib/v/ast/types.v @@ -1148,6 +1148,13 @@ pub fn (t &Table) type_to_str_using_aliases(typ Type, import_aliases map[string] } .alias, .any, .placeholder, .enum_ { res = t.shorten_user_defined_typenames(res, import_aliases) + /* + if res.ends_with('.byte') { + res = 'u8' + } else { + res = t.shorten_user_defined_typenames(res, import_aliases) + } + */ } .aggregate {} } diff --git a/vlib/v/checker/str.v b/vlib/v/checker/str.v index 3b4414b46..8f3ed9c22 100644 --- a/vlib/v/checker/str.v +++ b/vlib/v/checker/str.v @@ -6,7 +6,7 @@ module checker import v.ast import v.token -pub fn (mut c Checker) get_default_fmt(ftyp ast.Type, typ ast.Type) byte { +pub fn (mut c Checker) get_default_fmt(ftyp ast.Type, typ ast.Type) u8 { if ftyp.has_flag(.optional) { return `s` } else if typ.is_float() { diff --git a/vlib/v/embed_file/embed_file.v b/vlib/v/embed_file/embed_file.v index 2c8110d82..7c8d63f09 100644 --- a/vlib/v/embed_file/embed_file.v +++ b/vlib/v/embed_file/embed_file.v @@ -12,8 +12,8 @@ pub struct EmbedFileData { apath string compression_type string mut: - compressed &byte - uncompressed &byte + compressed &u8 + uncompressed &u8 free_compressed bool free_uncompressed bool pub: @@ -58,7 +58,7 @@ pub fn (original &EmbedFileData) to_bytes() []u8 { } } -pub fn (mut ed EmbedFileData) data() &byte { +pub fn (mut ed EmbedFileData) data() &u8 { if !isnil(ed.uncompressed) { return ed.uncompressed } @@ -100,7 +100,7 @@ pub struct EmbedFileIndexEntry { id int path string algo string - data &byte + data &u8 } // find_index_entry_by_path is used internally by the V compiler: diff --git a/vlib/v/eval/object.v b/vlib/v/eval/object.v index 1ee7059da..f71d84b27 100644 --- a/vlib/v/eval/object.v +++ b/vlib/v/eval/object.v @@ -11,12 +11,12 @@ type Object = Array | Void | []Object | bool - | byte | char | f64 | i64 | rune | string + | u8 | voidptr // string is the same as the autogenerated str() methods diff --git a/vlib/v/fmt/comments.v b/vlib/v/fmt/comments.v index 98d52bd72..088cfa8b8 100644 --- a/vlib/v/fmt/comments.v +++ b/vlib/v/fmt/comments.v @@ -137,6 +137,6 @@ pub fn (mut f Fmt) import_comments(comments []ast.Comment, options CommentsOptio } } -fn is_char_alphanumeric(c byte) bool { +fn is_char_alphanumeric(c u8) bool { return c.is_letter() || c.is_digit() } diff --git a/vlib/v/gen/c/cgen.v b/vlib/v/gen/c/cgen.v index e2976328d..84e16e4cb 100644 --- a/vlib/v/gen/c/cgen.v +++ b/vlib/v/gen/c/cgen.v @@ -2212,7 +2212,7 @@ fn (mut g Gen) expr_with_cast(expr ast.Expr, got_type_raw ast.Type, expected_typ g.expr(expr) } -fn write_octal_escape(mut b strings.Builder, c byte) { +fn write_octal_escape(mut b strings.Builder, c u8) { b << 92 // \ b << 48 + (c >> 6) // oct digit 2 b << 48 + (c >> 3) & 7 // oct digit 1 diff --git a/vlib/v/gen/js/sourcemap/vlq/vlq.v b/vlib/v/gen/js/sourcemap/vlq/vlq.v index 179f29339..4e9289cc3 100644 --- a/vlib/v/gen/js/sourcemap/vlq/vlq.v +++ b/vlib/v/gen/js/sourcemap/vlq/vlq.v @@ -33,7 +33,7 @@ fn abs64(x i64) u64 { // Decode a single base64 digit. [inline] -fn decode64(input byte) byte { +fn decode64(input u8) u8 { $if debug { assert input >= vlq.enc_char_special_plus assert input <= vlq.enc_char_end_zl @@ -82,7 +82,7 @@ pub fn decode(mut input io.Reader) ?i64 { } [inline] -fn encode64(input byte) byte { +fn encode64(input u8) u8 { $if debug { assert input < 64 } diff --git a/vlib/v/gen/native/amd64.v b/vlib/v/gen/native/amd64.v index 44d025e41..a059a46e3 100644 --- a/vlib/v/gen/native/amd64.v +++ b/vlib/v/gen/native/amd64.v @@ -54,7 +54,7 @@ fn (mut g Gen) dec(reg Register) { } [inline] -fn byt(n int, s int) byte { +fn byt(n int, s int) u8 { return u8((n >> (s * 8)) & 0xff) } diff --git a/vlib/v/scanner/scanner.v b/vlib/v/scanner/scanner.v index 5c88ecac1..2f764b184 100644 --- a/vlib/v/scanner/scanner.v +++ b/vlib/v/scanner/scanner.v @@ -43,9 +43,9 @@ pub mut: is_print_line_on_error bool is_print_colored_error bool is_print_rel_paths_on_error bool - quote byte // which quote is used to denote current string: ' or " - inter_quote byte - nr_lines int // total number of lines in the source file that were scanned + quote u8 // which quote is used to denote current string: ' or " + inter_quote u8 + nr_lines int // total number of lines in the source file that were scanned is_vh bool // Keep newlines is_fmt bool // Used for v fmt. comments_mode CommentsMode @@ -623,7 +623,7 @@ pub fn (s &Scanner) peek_token(n int) token.Token { } [direct_array_access; inline] -fn (s &Scanner) look_ahead(n int) byte { +fn (s &Scanner) look_ahead(n int) u8 { if s.pos + n < s.text.len { return s.text[s.pos + n] } else { @@ -1127,7 +1127,7 @@ fn (s &Scanner) current_column() int { return s.pos - s.last_nl_pos } -fn (s &Scanner) count_symbol_before(p int, sym byte) int { +fn (s &Scanner) count_symbol_before(p int, sym u8) int { mut count := 0 for i := p; i >= 0; i-- { if s.text[i] != sym { diff --git a/vlib/v/tests/assembly/asm_test.amd64.v b/vlib/v/tests/assembly/asm_test.amd64.v index 93017b4d9..dab7decce 100644 --- a/vlib/v/tests/assembly/asm_test.amd64.v +++ b/vlib/v/tests/assembly/asm_test.amd64.v @@ -116,7 +116,7 @@ mut: ebx u32 edx u32 ecx u32 - zero byte // for string + zero u8 // for string } fn (m Manu) str() string { diff --git a/vlib/v/tests/assembly/asm_test.i386.v b/vlib/v/tests/assembly/asm_test.i386.v index d4e395b52..dedf6698e 100644 --- a/vlib/v/tests/assembly/asm_test.i386.v +++ b/vlib/v/tests/assembly/asm_test.i386.v @@ -112,7 +112,7 @@ mut: ebx u32 edx u32 ecx u32 - zero byte // for string + zero u8 // for string } fn (m Manu) str() string { diff --git a/vlib/v/tests/c_function_mut_param/code_test.v b/vlib/v/tests/c_function_mut_param/code_test.v index 91189df85..bbbe4444f 100644 --- a/vlib/v/tests/c_function_mut_param/code_test.v +++ b/vlib/v/tests/c_function_mut_param/code_test.v @@ -2,7 +2,7 @@ module main #include "@VMODROOT/code.c" -fn C.mut_arg(key &byte, mut val usize) +fn C.mut_arg(key &u8, mut val usize) fn test_c_function_mut_param() { key := &u8(1) diff --git a/vlib/v/tests/cast_to_byte_test.v b/vlib/v/tests/cast_to_byte_test.v index 3aa623139..4b3b65edd 100644 --- a/vlib/v/tests/cast_to_byte_test.v +++ b/vlib/v/tests/cast_to_byte_test.v @@ -6,7 +6,7 @@ enum WireType { _32bit = 5 } -fn pack_wire_type(w WireType) byte { +fn pack_wire_type(w WireType) u8 { return u8(w) } diff --git a/vlib/v/tests/comptime_for_test.v b/vlib/v/tests/comptime_for_test.v index 6675211ba..b7991e7ba 100644 --- a/vlib/v/tests/comptime_for_test.v +++ b/vlib/v/tests/comptime_for_test.v @@ -9,7 +9,7 @@ pub: f u64 pub mut: g string - h byte + h u8 } ['foo/bar/three'] diff --git a/vlib/v/tests/comptime_if_is_test.v b/vlib/v/tests/comptime_if_is_test.v index c8fbabc91..0f2f28f35 100644 --- a/vlib/v/tests/comptime_if_is_test.v +++ b/vlib/v/tests/comptime_if_is_test.v @@ -15,7 +15,7 @@ fn test_generic_is() { } fn g(t T) int { - $if T is byte || T is i8 { + $if T is u8 || T is i8 { return 1 } return 2 diff --git a/vlib/v/tests/const_comptime_eval_before_vinit_test.v b/vlib/v/tests/const_comptime_eval_before_vinit_test.v index c9bff8efc..4a7470015 100644 --- a/vlib/v/tests/const_comptime_eval_before_vinit_test.v +++ b/vlib/v/tests/const_comptime_eval_before_vinit_test.v @@ -58,8 +58,8 @@ const zzz_an_f64_const_1 = zzz_an_f64_const + f64(1.0) // values will be the same. [unsafe] -fn static_storage(idx int, value int) byte { - mut static storage := [256]byte{} +fn static_storage(idx int, value int) u8 { + mut static storage := [256]u8{} if value == -1 { return storage[idx] } diff --git a/vlib/v/tests/const_eval_simple_int_expressions_at_comptime_test.v b/vlib/v/tests/const_eval_simple_int_expressions_at_comptime_test.v index 70a1b4620..b183908f3 100644 --- a/vlib/v/tests/const_eval_simple_int_expressions_at_comptime_test.v +++ b/vlib/v/tests/const_eval_simple_int_expressions_at_comptime_test.v @@ -10,17 +10,17 @@ fn test_consts() { } fn test_fixed_size_array_can_use_a_known_comptime_const_as_its_size() { - buf := [buf_siz]byte{} + buf := [buf_siz]u8{} println(buf.len) assert buf.len == 2048 } fn test_fixed_size_array_using_a_known_int_expression_directly_as_its_size() { - zbuf := [5 + 20 * 10]byte{} + zbuf := [5 + 20 * 10]u8{} assert zbuf.len == 205 } fn test_fixed_size_array_using_a_known_int_expression_with_const_as_its_size() { - zbuf := [2 * kb]byte{} + zbuf := [2 * kb]u8{} assert zbuf.len == 2048 } diff --git a/vlib/v/tests/fixed_array_const_size_test.v b/vlib/v/tests/fixed_array_const_size_test.v index b2c37a414..8048eb38d 100644 --- a/vlib/v/tests/fixed_array_const_size_test.v +++ b/vlib/v/tests/fixed_array_const_size_test.v @@ -4,7 +4,7 @@ const ( ) struct Foo { - bar [size]byte + bar [size]u8 } fn test_fixed_array_const_size() { diff --git a/vlib/v/tests/fixed_array_init_test.v b/vlib/v/tests/fixed_array_init_test.v index 2f28fec47..1d7ab9989 100644 --- a/vlib/v/tests/fixed_array_init_test.v +++ b/vlib/v/tests/fixed_array_init_test.v @@ -38,7 +38,7 @@ fn test_fixed_type_init() { } fn test_fixed_custom_init() { - a := [2]byte{init: 7} + a := [2]u8{init: 7} assert a == [u8(7), 7]! mut b := [3]int{} assert b == [0, 0, 0]! diff --git a/vlib/v/tests/fn_high_test.v b/vlib/v/tests/fn_high_test.v index e172c7a21..9e565d7a9 100644 --- a/vlib/v/tests/fn_high_test.v +++ b/vlib/v/tests/fn_high_test.v @@ -28,7 +28,7 @@ fn high_fn_return_single_anon() fn (int) f32 { fn high_fn_return_multi_anons() (fn (int) f32, fn (int) string) { // parsing trap - _ = fn (n int) byte { + _ = fn (n int) u8 { return 0x00 } correct_second := fn (n int) string { diff --git a/vlib/v/tests/fn_test.v b/vlib/v/tests/fn_test.v index 6555127c4..5762cc3cb 100644 --- a/vlib/v/tests/fn_test.v +++ b/vlib/v/tests/fn_test.v @@ -51,7 +51,7 @@ interface MyInterface {} type F9 = fn (MyInterface) -fn C.atoi(&byte) int +fn C.atoi(&u8) int fn C.freec(ptr voidptr) [trusted] diff --git a/vlib/v/tests/for_t_fields_with_comptime_if_test.v b/vlib/v/tests/for_t_fields_with_comptime_if_test.v index 79c7bd6d8..19c9aae36 100644 --- a/vlib/v/tests/for_t_fields_with_comptime_if_test.v +++ b/vlib/v/tests/for_t_fields_with_comptime_if_test.v @@ -1,13 +1,13 @@ struct Abc { - a byte - b byte + a u8 + b u8 c int } fn decode() T { mut x := T{} $for field in T.fields { - $if field.typ is byte { + $if field.typ is u8 { x.$(field.name) = 1 } $else { x.$(field.name) = 3 @@ -28,14 +28,14 @@ fn test_decode() { struct Abc2 { an_int int - a_byte byte + a_byte u8 a_string string } fn decode2() T { mut x := T{} $for field in T.fields { - $if field.typ is byte { + $if field.typ is u8 { x.$(field.name) = u8(-1) } $else $if field.typ is int { x.$(field.name) = int(-1) diff --git a/vlib/v/tests/interface_fields_test.v b/vlib/v/tests/interface_fields_test.v index a62d226c9..c863ed55b 100644 --- a/vlib/v/tests/interface_fields_test.v +++ b/vlib/v/tests/interface_fields_test.v @@ -10,7 +10,7 @@ mut: } struct Dog { - padding [256]byte + padding [256]u8 padding2 int mut: breed string diff --git a/vlib/v/tests/interface_test.v b/vlib/v/tests/interface_test.v index f095567d5..a93e9cfe8 100644 --- a/vlib/v/tests/interface_test.v +++ b/vlib/v/tests/interface_test.v @@ -400,7 +400,7 @@ struct AA { } struct BB { - pad [10]byte + pad [10]u8 mut: my_field int } diff --git a/vlib/v/tests/multiret_with_ptrtype_test.v b/vlib/v/tests/multiret_with_ptrtype_test.v index 06129cd6f..db13a53f1 100644 --- a/vlib/v/tests/multiret_with_ptrtype_test.v +++ b/vlib/v/tests/multiret_with_ptrtype_test.v @@ -2,7 +2,7 @@ fn multi_voidptr_ret() (voidptr, bool) { return voidptr(0), true } -fn multi_byteptr_ret() (&byte, bool) { +fn multi_byteptr_ret() (&u8, bool) { return &u8(0), true } diff --git a/vlib/v/tests/sizeof_test.v b/vlib/v/tests/sizeof_test.v index 26292ee5e..224268020 100644 --- a/vlib/v/tests/sizeof_test.v +++ b/vlib/v/tests/sizeof_test.v @@ -16,7 +16,7 @@ fn test_math_sizeof() { fn test_sizeof() { assert sizeof(rune) == 4 - assert sizeof([44]byte) == 44 + assert sizeof([44]u8) == 44 assert sizeof(`€`) == 4 // depends on -m32/64 assert sizeof(S1) in [u32(4), 8] diff --git a/vlib/v/tests/struct_embed_test.v b/vlib/v/tests/struct_embed_test.v index f371bbb05..188607243 100644 --- a/vlib/v/tests/struct_embed_test.v +++ b/vlib/v/tests/struct_embed_test.v @@ -161,8 +161,8 @@ fn test_embed_method_generic() { type Piece = King | Queen struct Pos { - x byte - y byte + x u8 + y u8 } enum TeamEnum { diff --git a/vlib/v/tests/structs_with_voidptr_fields_can_be_printed_test.v b/vlib/v/tests/structs_with_voidptr_fields_can_be_printed_test.v index 6c44ae65b..1e2f32333 100644 --- a/vlib/v/tests/structs_with_voidptr_fields_can_be_printed_test.v +++ b/vlib/v/tests/structs_with_voidptr_fields_can_be_printed_test.v @@ -2,7 +2,7 @@ struct Abc { mut: vptr voidptr vptrptr &voidptr = 0 - bptr &byte = 0 + bptr &u8 = 0 cptr &char = c'abcdef' } diff --git a/vlib/v/tests/testdata/test_array_bound.v b/vlib/v/tests/testdata/test_array_bound.v index f9286ea3a..5035c4722 100644 --- a/vlib/v/tests/testdata/test_array_bound.v +++ b/vlib/v/tests/testdata/test_array_bound.v @@ -3,11 +3,11 @@ enum Index { two } -fn direct(b byte) bool { +fn direct(b u8) bool { return true } -fn access(b byte) bool { +fn access(b u8) bool { return false } diff --git a/vlib/v/tests/typeof_test.v b/vlib/v/tests/typeof_test.v index e717110ef..c0d101292 100644 --- a/vlib/v/tests/typeof_test.v +++ b/vlib/v/tests/typeof_test.v @@ -127,7 +127,7 @@ fn myfn(i int) int { fn myfn2() { } -fn myfn3(i int, s string) byte { +fn myfn3(i int, s string) u8 { return u8(0) } diff --git a/vlib/v/tests/unsafe_test.v b/vlib/v/tests/unsafe_test.v index dc2a8a943..80a790142 100644 --- a/vlib/v/tests/unsafe_test.v +++ b/vlib/v/tests/unsafe_test.v @@ -74,7 +74,7 @@ fn test_unsafe_if_stmt() { assert x == 4 } -const fixedbytes = [100]byte{} +const fixedbytes = [100]u8{} fn test_unsafe_pointers() { fsize := fixedbytes.len diff --git a/vlib/v/util/scanning.v b/vlib/v/util/scanning.v index eee3c5129..cfb5316f4 100644 --- a/vlib/v/util/scanning.v +++ b/vlib/v/util/scanning.v @@ -1,12 +1,12 @@ module util [inline] -pub fn is_name_char(c byte) bool { +pub fn is_name_char(c u8) bool { return (c >= `a` && c <= `z`) || (c >= `A` && c <= `Z`) || c == `_` } [inline] -pub fn is_func_char(c byte) bool { +pub fn is_func_char(c u8) bool { return (c >= `a` && c <= `z`) || (c >= `A` && c <= `Z`) || c == `_` || (c >= `0` && c <= `9`) } diff --git a/vlib/v/vmod/parser.v b/vlib/v/vmod/parser.v index b0bd2e9a9..f516c441e 100644 --- a/vlib/v/vmod/parser.v +++ b/vlib/v/vmod/parser.v @@ -80,11 +80,11 @@ fn (mut s Scanner) skip_whitespace() { } } -fn is_name_alpha(chr byte) bool { +fn is_name_alpha(chr u8) bool { return chr.is_letter() || chr == `_` } -fn (mut s Scanner) create_string(q byte) string { +fn (mut s Scanner) create_string(q u8) string { mut str := '' for s.pos < s.text.len && s.text[s.pos] != q { if s.text[s.pos] == `\\` && s.text[s.pos + 1] == q { @@ -107,7 +107,7 @@ fn (mut s Scanner) create_ident() string { return text } -fn (s Scanner) peek_char(c byte) bool { +fn (s Scanner) peek_char(c u8) bool { return s.pos - 1 < s.text.len && s.text[s.pos - 1] == c } diff --git a/vlib/x/ttf/render_bmp.v b/vlib/x/ttf/render_bmp.v index 7c2fabf70..16c7a4ee0 100644 --- a/vlib/x/ttf/render_bmp.v +++ b/vlib/x/ttf/render_bmp.v @@ -19,8 +19,8 @@ import math pub struct BitMap { pub mut: tf &TTF_File - buf &byte = 0 // pointer to the memory buffer - buf_size int // allocated buf size in bytes + buf &u8 = 0 // pointer to the memory buffer + buf_size int // allocated buf size in bytes width int = 1 // width of the buffer height int = 1 // height of the buffer bp int = 4 // byte per pixel of the buffer diff --git a/vlib/x/ttf/ttf.v b/vlib/x/ttf/ttf.v index 5acee3151..2c90f8878 100644 --- a/vlib/x/ttf/ttf.v +++ b/vlib/x/ttf/ttf.v @@ -490,7 +490,7 @@ fn (mut tf TTF_File) read_compound_glyph(mut in_glyph Glyph) { * TTF_File get functions * ******************************************************************************/ -fn (mut tf TTF_File) get_u8() byte { +fn (mut tf TTF_File) get_u8() u8 { x := tf.buf[tf.pos] tf.pos++ return u8(x) -- 2.30.2