all: ~500 more byte=>u8

master
Alexander Medvednikov 2022-04-15 18:25:45 +03:00
parent ae6a25f44e
commit fbb9e65c0f
148 changed files with 544 additions and 494 deletions

View File

@ -24,7 +24,7 @@ fn C.cJSON_CreateNull() &C.cJSON
// fn C.cJSON_CreateNumber() &C.cJSON // fn C.cJSON_CreateNumber() &C.cJSON
// fn C.cJSON_CreateString() &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 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_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_AddItemToArray(voidptr, voidptr)
fn C.cJSON_Delete(voidptr) fn C.cJSON_Delete(voidptr)
fn C.cJSON_Print(voidptr) &byte fn C.cJSON_Print(voidptr) &u8
[inline] [inline]
fn create_object() &C.cJSON { fn create_object() &C.cJSON {

View File

@ -68,7 +68,7 @@ fn destroy_texture(sg_img gfx.Image) {
} }
// Use only if usage: .dynamic is enabled // 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 sz := w * h * 4
mut tmp_sbc := gfx.ImageData{} mut tmp_sbc := gfx.ImageData{}
tmp_sbc.subimage[0][0] = gfx.Range{ tmp_sbc.subimage[0][0] = gfx.Range{

View File

@ -18,7 +18,7 @@ import stbi
/****************************************************************************** /******************************************************************************
* Texture functions * 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 sz := w * h * 4
mut img_desc := gfx.ImageDesc{ mut img_desc := gfx.ImageDesc{
width: w width: w

View File

@ -5,8 +5,8 @@ module particle
// * Color // * Color
pub struct Color { pub struct Color {
mut: mut:
r byte r u8
g byte g u8
b byte b u8
a byte a u8
} }

View File

@ -61,7 +61,7 @@ fn graphics_frame(mut state AppState) {
} }
[inline] [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) return u8(127 + state.frames[(state.gframe + idx) & 2047] * 128)
} }

View File

@ -144,7 +144,7 @@ fn destroy_texture(sg_img gfx.Image) {
} }
// Use only if: .dynamic is enabled // 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 sz := w * h * 4
mut tmp_sbc := gfx.ImageData{} mut tmp_sbc := gfx.ImageData{}
tmp_sbc.subimage[0][0] = gfx.Range{ tmp_sbc.subimage[0][0] = gfx.Range{

View File

@ -283,10 +283,10 @@ fn test_copy() {
} }
fn test_can_copy_bits() { fn test_can_copy_bits() {
assert can_copy_bits<byte>() assert can_copy_bits<u8>()
assert can_copy_bits<int>() assert can_copy_bits<int>()
assert can_copy_bits<voidptr>() assert can_copy_bits<voidptr>()
assert can_copy_bits<&byte>() assert can_copy_bits<&u8>()
// autofree needs to intercept assign // autofree needs to intercept assign
assert !can_copy_bits<string>() assert !can_copy_bits<string>()
assert !can_copy_bits<[]int>() assert !can_copy_bits<[]int>()

View File

@ -642,8 +642,8 @@ pub fn (mut a array) reverse_in_place() {
mut tmp_value := malloc(a.element_size) mut tmp_value := malloc(a.element_size)
for i in 0 .. a.len / 2 { for i in 0 .. a.len / 2 {
vmemcpy(tmp_value, &u8(a.data) + i * a.element_size, a.element_size) vmemcpy(tmp_value, &u8(a.data) + i * a.element_size, a.element_size)
vmemcpy(&u8(a.data) + i * a.element_size, &u8(a.data) + vmemcpy(&u8(a.data) + i * a.element_size, &u8(a.data) + (a.len - 1 - i) * a.element_size,
(a.len - 1 - i) * a.element_size, a.element_size) a.element_size)
vmemcpy(&u8(a.data) + (a.len - 1 - i) * a.element_size, tmp_value, a.element_size) vmemcpy(&u8(a.data) + (a.len - 1 - i) * a.element_size, tmp_value, a.element_size)
} }
free(tmp_value) free(tmp_value)

View File

@ -148,21 +148,21 @@ fn test_bin() {
fn test_oct() { fn test_oct() {
x1 := 0o12 x1 := 0o12
assert x1 == 10 assert x1 == 10
x2 := 00000o350 x2 := 0o350
assert x2 == 232 assert x2 == 232
x3 := 000o00073 x3 := 0o00073
assert x3 == 59 assert x3 == 59
x4 := 00000000 x4 := 0
assert x4 == 0 assert x4 == 0
x5 := 00000195 x5 := 195
assert x5 == 195 assert x5 == 195
x6 := -0o744 x6 := -0o744
assert x6 == -484 assert x6 == -484
x7 := -000o000042 x7 := -0o000042
assert x7 == -34 assert x7 == -34
x8 := -0000112 x8 := -112
assert x8 == -112 assert x8 == -112
x9 := -000 x9 := -0
assert x9 == 0 assert x9 == 0
} }

View File

@ -181,7 +181,7 @@ fn test_various_map_value() {
mut m9 := map[string]bool{} mut m9 := map[string]bool{}
m9['test'] = true m9['test'] = true
assert m9['test'] == true assert m9['test'] == true
mut m10 := map[string]byte{} mut m10 := map[string]u8{}
m10['test'] = u8(0) m10['test'] = u8(0)
assert m10['test'] == u8(0) assert m10['test'] == u8(0)
mut m11 := map[string]f32{} mut m11 := map[string]f32{}
@ -762,7 +762,7 @@ fn test_in_map_literal() {
} }
fn test_byte_keys() { fn test_byte_keys() {
mut m := map[byte]byte{} mut m := map[u8]u8{}
byte_max := u8(255) byte_max := u8(255)
for i in u8(0) .. byte_max { for i in u8(0) .. byte_max {
m[i] = i m[i] = i

View File

@ -783,11 +783,11 @@ fn test_double_quote_inter() {
assert '$a $b' == '1 2' assert '$a $b' == '1 2'
} }
fn foo(b byte) byte { fn foo(b u8) u8 {
return b - 10 return b - 10
} }
fn filter(b byte) bool { fn filter(b u8) bool {
return b != `a` return b != `a`
} }

View File

@ -1,26 +1,84 @@
module main module main
import forkedtest
import builtin.linux_bare.old..checks.forkedtest
const ( const (
sample_text_file1 = "" sample_text_file1 = ''
) )
fn check_fork_minimal() { fn check_fork_minimal() {
child := sys_fork() child := sys_fork()
ec := 100 ec := 100
if child == 0 { if child == 0 {
println("child") println('child')
sys_exit(ec) sys_exit(ec)
} }
siginfo := [ 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)
@ -40,7 +98,7 @@ fn check_read_write_pipe() {
// sys_read // sys_read
// sys_close // sys_close
// //
buffer0 := []byte{len:(128)} buffer0 := []u8{len: (128)}
buffer := byteptr(buffer0.data) buffer := byteptr(buffer0.data)
fd := [-1, -1] fd := [-1, -1]
@ -55,7 +113,7 @@ fn check_read_write_pipe() {
assert fd[0] != -1 assert fd[0] != -1
assert fd[1] != -1 assert fd[1] != -1
test_data := "test_data" test_data := 'test_data'
b := test_data.len + 1 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))
@ -87,11 +145,11 @@ fn check_read_file() {
sys_close sys_close
sys_open sys_open
*/ */
buffer0 := []byte{len:(128)} buffer0 := []u8{len: (128)}
buffer := byteptr(buffer0.data) buffer := byteptr(buffer0.data)
test_file := "sample_text1.txt" test_file := 'sample_text1.txt'
sample_text := "Do not change this text.\n" sample_text := 'Do not change this text.\n'
fd, ec := sys_open(test_file.str, .o_rdonly, 0) fd, ec := sys_open(test_file.str, .o_rdonly, 0)
assert fd > 0 assert fd > 0
assert ec == .enoerror assert ec == .enoerror
@ -106,7 +164,7 @@ fn check_read_file() {
} }
fn check_open_file_fail() { 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 fd1 == -1
assert ec1 == .enoent assert ec1 == .enoent
} }
@ -133,7 +191,8 @@ fn check_munmap_fail() {
fn check_mmap_one_page() { fn check_mmap_one_page() {
mp := int(Mm_prot.prot_read) | int(Mm_prot.prot_write) mp := int(Mm_prot.prot_read) | int(Mm_prot.prot_write)
mf := int(Map_flags.map_private) | int(Map_flags.map_anonymous) 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 e == .enoerror
assert a != byteptr(-1) assert a != byteptr(-1)
@ -229,7 +288,7 @@ fn check_voidptr_array_ro() {
voidptr(12000), voidptr(12000),
voidptr(13000), voidptr(13000),
voidptr(14000), voidptr(14000),
voidptr(15000) voidptr(15000),
] ]
assert a.len == 6 assert a.len == 6
assert a[0] == voidptr(10000) assert a[0] == voidptr(10000)
@ -247,7 +306,7 @@ fn check_voidptr_array_rw() {
voidptr(-1), voidptr(-1),
voidptr(-1), voidptr(-1),
voidptr(-1), voidptr(-1),
voidptr(-1) voidptr(-1),
] ]
assert a.len == 6 assert a.len == 6
@ -277,23 +336,22 @@ fn check_voidptr_array_rw() {
assert a[5] == voidptr(150000) assert a[5] == voidptr(150000)
} }
fn main() { fn main() {
mut fails := 0 mut fails := 0
fails += forkedtest.normal_run(check_fork_minimal, "check_fork_minimal") 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_munmap_fail, 'check_munmap_fail')
fails += forkedtest.normal_run(check_mmap_one_page, "check_mmap_one_page") 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_pages, 'check_mm_pages')
fails += forkedtest.normal_run(check_mm_alloc, "check_mm_alloc") 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_write_pipe, 'check_read_write_pipe')
fails += forkedtest.normal_run(check_read_file, "check_read_file") fails += forkedtest.normal_run(check_read_file, 'check_read_file')
// check_print() // check_print()
fails += forkedtest.normal_run(check_open_file_fail, "check_open_file_fail") 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_ro, 'check_int_array_ro')
fails += forkedtest.normal_run(check_int_array_rw, "check_int_array_rw") 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_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_ro, 'check_voidptr_array_ro')
fails += forkedtest.normal_run(check_voidptr_array_rw, "check_voidptr_array_rw") fails += forkedtest.normal_run(check_voidptr_array_rw, 'check_voidptr_array_rw')
assert fails == 0 assert fails == 0
sys_exit(0) sys_exit(0)

View File

@ -1,34 +1,35 @@
module main module main
import forkedtest
import builtin.linux_bare.old..checks.forkedtest
fn check_string_eq() { fn check_string_eq() {
assert "monkey" != "rat" assert 'monkey' != 'rat'
some_animal := "a bird" some_animal := 'a bird'
assert some_animal == "a bird" assert some_animal == 'a bird'
} }
fn check_i64_tos() { fn check_i64_tos() {
buffer0 := []byte{len:(128)} buffer0 := []u8{len: (128)}
buffer := byteptr(buffer0.data) buffer := byteptr(buffer0.data)
s0 := i64_tos(buffer, 70, 140, 10) s0 := i64_tos(buffer, 70, 140, 10)
assert s0 == "140" assert s0 == '140'
s1 := i64_tos(buffer, 70, -160, 10) s1 := i64_tos(buffer, 70, -160, 10)
assert s1 == "-160" assert s1 == '-160'
s2 := i64_tos(buffer, 70, 65537, 16) s2 := i64_tos(buffer, 70, 65537, 16)
assert s2 == "10001" assert s2 == '10001'
s3 := i64_tos(buffer, 70, -160000, 10) s3 := i64_tos(buffer, 70, -160000, 10)
assert s3 == "-160000" assert s3 == '-160000'
} }
fn check_i64_str() { fn check_i64_str() {
assert "141" == i64_str(141, 10) assert '141' == i64_str(141, 10)
assert "-161" == i64_str(-161, 10) assert '-161' == i64_str(-161, 10)
assert "10002" == i64_str(65538, 16) assert '10002' == i64_str(65538, 16)
assert "-160001" == i64_str(-160001, 10) assert '-160001' == i64_str(-160001, 10)
} }
fn check_str_clone() { fn check_str_clone() {
@ -36,7 +37,7 @@ fn check_str_clone() {
b := a.clone() b := a.clone()
assert a == b assert a == b
c := i64_str(-6789, 10).clone() c := i64_str(-6789, 10).clone()
assert c == "-6789" assert c == '-6789'
} }
fn check_string_add_works() { fn check_string_add_works() {
@ -52,12 +53,11 @@ fn check_string_add_works(){
fn main() { fn main() {
mut fails := 0 mut fails := 0
fails += forkedtest.normal_run(check_string_eq, "check_string_eq") 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_tos, 'check_i64_tos')
fails += forkedtest.normal_run(check_i64_str, "check_i64_str") 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_str_clone, 'check_str_clone')
fails += forkedtest.normal_run(check_string_add_works, "check_string_add_works") fails += forkedtest.normal_run(check_string_add_works, 'check_string_add_works')
assert fails == 0 assert fails == 0
sys_exit(0) sys_exit(0)
} }

View File

@ -179,7 +179,7 @@ fn test_various_map_value() {
mut m9 := map[string]bool{} mut m9 := map[string]bool{}
m9['test'] = true m9['test'] = true
assert m9['test'] == true assert m9['test'] == true
mut m10 := map[string]byte{} mut m10 := map[string]u8{}
m10['test'] = u8(0) m10['test'] = u8(0)
assert m10['test'] == u8(0) assert m10['test'] == u8(0)
mut m11 := map[string]f32{} mut m11 := map[string]f32{}
@ -194,7 +194,7 @@ fn test_various_map_value() {
mut m14 := map[string]voidptr{} mut m14 := map[string]voidptr{}
m14['test'] = voidptr(0) m14['test'] = voidptr(0)
assert m14['test'] == voidptr(0) assert m14['test'] == voidptr(0)
mut m15 := map[string]&byte{} mut m15 := map[string]&u8{}
m15['test'] = &u8(0) m15['test'] = &u8(0)
assert m15['test'] == &u8(0) assert m15['test'] == &u8(0)
mut m16 := map[string]i64{} mut m16 := map[string]i64{}
@ -750,7 +750,7 @@ fn test_in_map_literal() {
} }
fn test_byte_keys() { fn test_byte_keys() {
mut m := map[byte]byte{} mut m := map[u8]u8{}
byte_max := u8(255) byte_max := u8(255)
for i in u8(0) .. byte_max { for i in u8(0) .. byte_max {
m[i] = i m[i] = i

View File

@ -837,11 +837,11 @@ fn test_double_quote_inter() {
assert '$a $b' == '1 2' assert '$a $b' == '1 2'
} }
fn foo(b byte) byte { fn foo(b u8) u8 {
return b - 10 return b - 10
} }
fn filter(b byte) bool { fn filter(b u8) bool {
return b != `a` return b != `a`
} }

View File

@ -17,7 +17,7 @@ mut:
fn C.darwin_new_pasteboard() voidptr 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 fn C.darwin_set_pasteboard_text(voidptr, string) bool

View File

@ -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.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.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.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.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 fn C.XDeleteProperty(d &C.Display, w Window, property Atom) int
@ -154,7 +154,7 @@ struct Property {
actual_type Atom actual_type Atom
actual_format int actual_format int
nitems u64 nitems u64
data &byte data &u8
} }
// new_clipboard returns a new `Clipboard` instance allocated on the heap. // new_clipboard returns a new `Clipboard` instance allocated on the heap.

View File

@ -21,19 +21,7 @@ const (
) )
// Key represents the type for the ValueContext key // Key represents the type for the ValueContext key
pub type Key = bool pub type Key = bool | f32 | f64 | i16 | i64 | i8 | int | string | u16 | u32 | u64 | u8 | voidptr
| byte
| f32
| f64
| i16
| i64
| i8
| int
| string
| u16
| u32
| u64
| voidptr
// Any represents a generic type for the ValueContext // Any represents a generic type for the ValueContext
pub interface Any {} pub interface Any {}

View File

@ -30,10 +30,10 @@ pub fn nsstring(s string) voidptr {
// for .app packages: .../my.app/Contents/Resources // for .app packages: .../my.app/Contents/Resources
// for cli: .../parent_folder/Resources // for cli: .../parent_folder/Resources
fn C.CFBundleCopyResourcesDirectoryURL(bundle voidptr) &byte fn C.CFBundleCopyResourcesDirectoryURL(bundle voidptr) &u8
fn C.CFBundleGetMainBundle() voidptr fn C.CFBundleGetMainBundle() voidptr
fn C.CFURLGetFileSystemRepresentation(url &byte, resolve_against_base bool, buffer &byte, buffer_size int) int fn C.CFURLGetFileSystemRepresentation(url &u8, resolve_against_base bool, buffer &u8, buffer_size int) int
fn C.CFRelease(url &byte) fn C.CFRelease(url &u8)
pub fn resource_path() string { pub fn resource_path() string {
main_bundle := C.CFBundleGetMainBundle() main_bundle := C.CFBundleGetMainBundle()

View File

@ -6,7 +6,7 @@ pub const rtld_lazy = 0
fn C.LoadLibrary(libfilename &u16) voidptr 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 fn C.FreeLibrary(handle voidptr) bool

View File

@ -4,7 +4,7 @@ module base64
// encode_in_buffer returns the size of the encoded data in the buffer. // 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 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. // 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) 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 { for src_len - si >= 8 {
// Converting 8 bytes of input into 6 bytes of output. Storing these in the upper bytes of an u64. // 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]]), 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 + 2]]), u8(index[d[si + 3]]), u8(index[d[si + 4]]), u8(index[d[si + 5]]),
u8(index[d[si + 5]]), u8(index[d[si + 6]]), u8(index[d[si + 7]])) u8(index[d[si + 6]]), u8(index[d[si + 7]]))
// Reading out the individual bytes from the u64. Watch out with endianess. // Reading out the individual bytes from the u64. Watch out with endianess.
$if little_endian { $if little_endian {

View File

@ -54,13 +54,13 @@ pub fn url_encode_str(data string) string {
// assemble64 assembles 8 base64 digits into 6 bytes. // assemble64 assembles 8 base64 digits into 6 bytes.
// Each digit comes from the decode map. // Each digit comes from the decode map.
// Please note: Invalid base64 digits are not expected and not handled. // 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 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. // assemble32 assembles 4 base64 digits into 3 bytes.
// Each digit comes from the decode map. // Each digit comes from the decode map.
// Please note: Invalid base64 digits are not expected and not handled. // 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 return u32(n1) << 26 | u32(n2) << 20 | u32(n3) << 14 | u32(n4) << 8
} }

View File

@ -44,16 +44,16 @@ struct Reader {
// headings []string // headings []string
data string data string
pub mut: pub mut:
delimiter byte delimiter u8
comment byte comment u8
is_mac_pre_osx_le bool is_mac_pre_osx_le bool
row_pos int row_pos int
} }
[params] [params]
pub struct ReaderConfig { pub struct ReaderConfig {
delimiter byte = `,` delimiter u8 = `,`
comment byte = `#` comment u8 = `#`
} }
// new_reader initializes a Reader with string data to parse and, // new_reader initializes a Reader with string data to parse and,
@ -210,6 +210,6 @@ fn (mut r Reader) read_record() ?[]string {
return fields return fields
} }
fn valid_delim(b byte) bool { fn valid_delim(b u8) bool {
return b != 0 && b != `"` && b != `\r` && b != `\n` return b != 0 && b != `"` && b != `\r` && b != `\n`
} }

View File

@ -10,7 +10,7 @@ mut:
sb strings.Builder sb strings.Builder
pub mut: pub mut:
use_crlf bool use_crlf bool
delimiter byte delimiter u8
} }
pub fn new_writer() &Writer { pub fn new_writer() &Writer {

View File

@ -52,7 +52,7 @@ pub fn encode(bytes []u8) string {
} }
// char2nibble converts an ASCII hex character to it's hex value // char2nibble converts an ASCII hex character to it's hex value
fn char2nibble(b byte) ?byte { fn char2nibble(b u8) ?u8 {
match b { match b {
`0`...`9` { return b - u8(`0`) } `0`...`9` { return b - u8(`0`) }
`A`...`F` { return b - u8(`A`) + 10 } `A`...`F` { return b - u8(`A`) + 10 }

View File

@ -11,7 +11,7 @@ pub fn validate_str(str string) bool {
return validate(str.str, str.len) 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{} mut state := Utf8State{}
for i := 0; i < len; i++ { for i := 0; i < len; i++ {
s := unsafe { data[i] } s := unsafe { data[i] }
@ -46,7 +46,7 @@ fn (mut s Utf8State) seq(r0 bool, r1 bool, is_tail bool) bool {
return false return false
} }
fn (mut s Utf8State) next_state(c byte) { fn (mut s Utf8State) next_state(c u8) {
// sequence 1 // sequence 1
if s.index == 0 { if s.index == 0 {
if (c >= 0x00 + 1 && c <= 0x7F) || c == 0x00 { if (c >= 0x00 + 1 && c <= 0x7F) || c == 0x00 {

View File

@ -4,7 +4,7 @@ module flag
pub struct Flag { pub struct Flag {
pub: pub:
name string // name as it appears on command line name string // name as it appears on command line
abbr byte // shortcut abbr u8 // shortcut
usage string // help message usage string // help message
val_desc string // something like '<arg>' that appears in usage, val_desc string // something like '<arg>' that appears in usage,
// and also the default value, when the flag is not given // 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 // private helper to register a flag
// This version supports abbreviations. // 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{ fs.flags << Flag{
name: name name: name
abbr: abbr 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 // - the name, usage are registered
// - found arguments and corresponding values are removed from args list // - found arguments and corresponding values are removed from args list
[manualfree] [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' full := '--$longhand'
defer { defer {
unsafe { full.free() } 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 // special: it is allowed to define bool flags without value
// -> '--flag' is parsed as true // -> '--flag' is parsed as true
// -> '--flag' is equal to '--flag=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' full := '--$longhand'
for i, arg in fs.args { 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`. // 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. // It returns an error, when the flag is not given by the user.
// This version supports abbreviations. // 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 mut res := false
{ {
fs.add_flag(name, abbr, usage, '<bool>') fs.add_flag(name, abbr, usage, '<bool>')
@ -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. // 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`. // When it is not, it returns the default value in `bdefault`.
// This version supports abbreviations. // 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 } value := fs.bool_opt(name, abbr, usage) or { return bdefault }
return value 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`. // int_multi returns all values associated with the provided flag in `name`.
// When that flag has no values, it returns an empty array. // When that flag has no values, it returns an empty array.
// This version supports abbreviations. // 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, '<multiple ints>') fs.add_flag(name, abbr, usage, '<multiple ints>')
parsed := fs.parse_value(name, abbr) parsed := fs.parse_value(name, abbr)
mut value := []int{} 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`. // 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. // When the flag is not given by the user, it returns an error.
// This version supports abbreviations. // 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 mut res := 0
{ {
fs.add_flag(name, abbr, usage, '<int>') fs.add_flag(name, abbr, usage, '<int>')
@ -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 the flag is given by the user, it returns its parsed integer value.
// When it is not, it returns the integer value in `idefault`. // When it is not, it returns the integer value in `idefault`.
// This version supports abbreviations. // 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 } value := fs.int_opt(name, abbr, usage) or { return idefault }
return value 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`. // 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. // When no values for that flag are found, it returns an empty array.
// This version supports abbreviations. // 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, '<multiple floats>') fs.add_flag(name, abbr, usage, '<multiple floats>')
parsed := fs.parse_value(name, abbr) parsed := fs.parse_value(name, abbr)
mut value := []f64{} 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`. // 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. // When the flag is not given by the user, it returns an error.
// This version supports abbreviations. // 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 mut res := 0.0
{ {
fs.add_flag(name, abbr, usage, '<float>') fs.add_flag(name, abbr, usage, '<float>')
@ -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 the flag is given by the user, it returns its parsed floating point value.
// When it is not, it returns the value in `fdefault`. // When it is not, it returns the value in `fdefault`.
// This version supports abbreviations. // 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 } value := fs.float_opt(name, abbr, usage) or { return fdefault }
return value 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`. // 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. // When no values for that flag are found, it returns an empty array.
// This version supports abbreviations. // 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, '<multiple strings>') fs.add_flag(name, abbr, usage, '<multiple strings>')
return fs.parse_value(name, abbr) 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`. // 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. // When the flag is not given by the user, it returns an error.
// This version supports abbreviations. // 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 := '' mut res := ''
{ {
fs.add_flag(name, abbr, usage, '<string>') fs.add_flag(name, abbr, usage, '<string>')
@ -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. // 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`. // When it is not, it returns the default string value in `sdefault`.
// This version supports abbreviations. // 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 } value := fs.string_opt(name, abbr, usage) or { return sdefault }
return value return value
} }

View File

@ -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. // get_texture_data returns the current Context's raw texture data.
// `width` and `height` is assigned the size of the texture dimensions. // `width` and `height` is assigned the size of the texture dimensions.
[inline] [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)) return &u8(C.fonsGetTextureData(s, width, height))
} }

View File

@ -18,7 +18,7 @@ fn C.fonsResetAtlas(s &C.FONScontext, width int, height int) int
// Add fonts // Add fonts
fn C.fonsGetFontByName(s &C.FONScontext, name &char) int fn C.fonsGetFontByName(s &C.FONScontext, name &char) int
fn C.fonsAddFallbackFont(s &C.FONScontext, base int, fallback int) 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 // State handling
fn C.fonsPushState(s &C.FONScontext) fn C.fonsPushState(s &C.FONScontext)

View File

@ -10,7 +10,7 @@ pub struct C.FONSparams {
// int (*renderResize)(void* uptr, int width, int height) // int (*renderResize)(void* uptr, int width, int height)
renderResize fn (uptr voidptr, width int, height int) int renderResize fn (uptr voidptr, width int, height int) int
// void (*renderUpdate)(void* uptr, int* rect, const unsigned char* data) // 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) // 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) renderDraw fn (uptr voidptr, verts &f32, tcoords &f32, colors &u32, nverts int)
// void (*renderDelete)(void* uptr) // void (*renderDelete)(void* uptr)
@ -40,9 +40,9 @@ pub struct C.FONStextIter {
iblur i16 iblur i16
font &C.FONSfont font &C.FONSfont
prevGlyphIndex int prevGlyphIndex int
str &byte str &u8
next &byte next &u8
end &byte end &u8
utf8state u32 utf8state u32
} }

View File

@ -128,7 +128,7 @@ pub mut:
ui_mode bool // do not redraw everything 60 times/second, but only when the user requests 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 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_buttons MouseButtons // typed version of mbtn_mask; easier to use for user programs
mouse_pos_x int mouse_pos_x int
mouse_pos_y int mouse_pos_y int

View File

@ -276,7 +276,7 @@ pub mut:
user_data voidptr user_data voidptr
ui_mode bool ui_mode bool
frame u64 frame u64
mbtn_mask byte mbtn_mask u8
mouse_buttons MouseButtons mouse_buttons MouseButtons
mouse_pos_x int mouse_pos_x int
mouse_pos_y int mouse_pos_y int

View File

@ -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, // update_pixel_data is a helper for working with image streams (i.e. images,
// that are updated dynamically by the CPU on each frame) // 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) mut image := ctx.get_cached_image_by_idx(cached_image_idx)
image.update_pixel_data(buf) image.update_pixel_data(buf)
} }
// update_pixel_data updates the sokol specific pixel data associated // update_pixel_data updates the sokol specific pixel data associated
// with this `Image`. // 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{} mut data := gfx.ImageData{}
data.subimage[0][0].ptr = buf data.subimage[0][0].ptr = buf
data.subimage[0][0].size = usize(img.width * img.height * img.nr_channels) 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`. // memory buffer `buf` of size `bufsize`.
// //
// See also: create_image_from_byte_array // 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{} } stb_img := stbi.load_from_memory(buf, bufsize) or { return Image{} }
mut img := Image{ mut img := Image{
width: stb_img.width width: stb_img.width

View File

@ -116,10 +116,10 @@ pub const (
// Color represents a 32 bit color value in sRGB format // Color represents a 32 bit color value in sRGB format
pub struct Color { pub struct Color {
pub mut: pub mut:
r byte r u8
g byte g u8
b byte b u8
a byte = 255 a u8 = 255
} }
// hex takes in a 32 bit integer and splits it into 4 byte values // 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{ return Color{
r: r r: r
g: g 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{ return Color{
r: r r: r
g: g g: g

View File

@ -46,7 +46,7 @@ pub fn sum32_struct<T>(s &T) u32 {
// sum32_bytes returns a fnv1a hash of `data_len` bytes starting at // sum32_bytes returns a fnv1a hash of `data_len` bytes starting at
// the address in the given &byte pointer `data`. // the address in the given &byte pointer `data`.
[direct_array_access; inline; unsafe] [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 mut hash := fnv1a.fnv32_offset_basis
for i in 0 .. data_len { for i in 0 .. data_len {
hash = unsafe { (hash ^ u32(data[i])) * fnv1a.fnv32_prime } 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 // sum64_bytes returns a fnv1a hash of `data_len` bytes starting at
// the address in the given &byte pointer `data`. // the address in the given &byte pointer `data`.
[direct_array_access; inline; unsafe] [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 mut hash := fnv1a.fnv64_offset_basis
for i in 0 .. data_len { for i in 0 .. data_len {
hash = unsafe { (hash ^ u64(data[i])) * fnv1a.fnv64_prime } hash = unsafe { (hash ^ u64(data[i])) * fnv1a.fnv64_prime }

View File

@ -2,12 +2,12 @@ module hash
//#flag -I @VEXEROOT/thirdparty/wyhash //#flag -I @VEXEROOT/thirdparty/wyhash
//#include "wyhash.h" //#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 fn C.wyhash64(u64, u64) u64
[inline] [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)) return C.wyhash(key, len, seed, &u64(C._wyp))
} }

View File

@ -51,21 +51,21 @@ pub fn wymum(a u64, b u64) u64 {
} }
[inline] [inline]
fn wyr3(p &byte, k u64) u64 { fn wyr3(p &u8, k u64) u64 {
unsafe { unsafe {
return (u64(p[0]) << 16) | (u64(p[k >> 1]) << 8) | u64(p[k - 1]) return (u64(p[0]) << 16) | (u64(p[k >> 1]) << 8) | u64(p[k - 1])
} }
} }
[inline] [inline]
fn wyr4(p &byte) u64 { fn wyr4(p &u8) u64 {
unsafe { unsafe {
return u32(p[0]) | (u32(p[1]) << u32(8)) | (u32(p[2]) << u32(16)) | (u32(p[3]) << u32(24)) return u32(p[0]) | (u32(p[1]) << u32(8)) | (u32(p[2]) << u32(16)) | (u32(p[3]) << u32(24))
} }
} }
[inline] [inline]
fn wyr8(p &byte) u64 { fn wyr8(p &u8) u64 {
unsafe { 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) 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)
} }

View File

@ -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, 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] 23, 21, 19, 16, 7, 26, 12, 18, 6, 11, 5, 10, 9]
de_bruijn64 = u64(0x03f79d71b4ca8b09) 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, de_bruijn64tab = [u8(0), 1, 56, 2, 57, 49, 28, 3, 61, 58, 42, 50, 38, 29, 17, 4, 62, 47, 59,
59, 36, 45, 43, 51, 22, 53, 39, 33, 30, 24, 18, 12, 5, 63, 55, 48, 27, 60, 41, 37, 16, 36, 45, 43, 51, 22, 53, 39, 33, 30, 24, 18, 12, 5, 63, 55, 48, 27, 60, 41, 37, 16, 46,
46, 35, 44, 21, 52, 32, 23, 11, 54, 26, 40, 15, 34, 20, 31, 10, 25, 14, 19, 9, 13, 8, 7, 35, 44, 21, 52, 32, 23, 11, 54, 26, 40, 15, 34, 20, 31, 10, 25, 14, 19, 9, 13, 8, 7, 6]
6]
) )
const ( const (
@ -31,7 +30,7 @@ const (
// --- LeadingZeros --- // --- LeadingZeros ---
// leading_zeros_8 returns the number of leading zero bits in x; the result is 8 for x == 0. // 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) 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. // This function's execution time does not depend on the inputs.
[inline] [inline]
pub fn rotate_left_8(x byte, k int) byte { pub fn rotate_left_8(x u8, k int) u8 {
n := u8(8) n := u8(8)
s := u8(k) & (n - u8(1)) s := u8(k) & (n - u8(1))
return (x << s) | (x >> (n - s)) return (x << s) | (x >> (n - s))

View File

@ -10,13 +10,13 @@ struct C.MYSQL_RES {
[typedef] [typedef]
struct C.MYSQL_FIELD { struct C.MYSQL_FIELD {
name &byte // Name of column name &u8 // Name of column
org_name &byte // Original column name, if an alias org_name &u8 // Original column name, if an alias
table &byte // Table of column if column was a field table &u8 // Table of column if column was a field
org_table &byte // Org table name, if table was an alias org_table &u8 // Org table name, if table was an alias
db &byte // Database for table db &u8 // Database for table
catalog &byte // Catalog for table catalog &u8 // Catalog for table
def &byte // Default value (set by mysql_list_fields) def &u8 // Default value (set by mysql_list_fields)
length int // Width of column (create length) length int // Width of column (create length)
max_length int // Max width for selected set max_length int // Max width for selected set
name_length u32 name_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_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 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_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 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_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_fetch_fields(res &C.MYSQL_RES) &C.MYSQL_FIELD
fn C.mysql_free_result(res &C.MYSQL_RES) 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_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) fn C.mysql_close(sock &C.MYSQL)
// INFO & VERSION // 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_server_version(mysql &C.MYSQL) u64
fn C.mysql_get_client_version() 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 // 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_errno(mysql &C.MYSQL) int
fn C.mysql_dump_debug_info(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)

View File

@ -3,7 +3,7 @@ module mysql
import orm import orm
import time 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 // sql expr

View File

@ -33,7 +33,7 @@ pub struct Field {
} }
// fetch_row - fetches the next row from a result. // 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) return C.mysql_fetch_row(r.result)
} }

View File

@ -153,7 +153,7 @@ pub fn (mut stmt Stmt) bind_bool(b &bool) {
stmt.bind(mysql.mysql_type_tiny, b, 0) 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) stmt.bind(mysql.mysql_type_tiny, b, 0)
} }

View File

@ -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. // 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) { if isnil(ptr) {
return '' return ''
} }
@ -19,7 +19,7 @@ fn resolve_nil_str(ptr &byte) string {
} }
[inline] [inline]
fn mystring(b &byte) string { fn mystring(b &u8) string {
unsafe { unsafe {
return b.vstring() return b.vstring()
} }

View File

@ -55,7 +55,7 @@ struct Ip {
} }
struct Unix { struct Unix {
path [max_unix_path]byte path [max_unix_path]u8
} }
[_pack: '1'] [_pack: '1']

View File

@ -17,8 +17,8 @@ mut:
struct C.sockaddr_in6 { struct C.sockaddr_in6 {
mut: mut:
// 1 + 1 + 2 + 4 + 16 + 4 = 28; // 1 + 1 + 2 + 4 + 16 + 4 = 28;
sin6_len byte // 1 sin6_len u8 // 1
sin6_family byte // 1 sin6_family u8 // 1
sin6_port u16 // 2 sin6_port u16 // 2
sin6_flowinfo u32 // 4 sin6_flowinfo u32 // 4
sin6_addr [16]u8 // 16 sin6_addr [16]u8 // 16
@ -27,8 +27,8 @@ mut:
struct C.sockaddr_in { struct C.sockaddr_in {
mut: mut:
sin_len byte sin_len u8
sin_family byte sin_family u8
sin_port u16 sin_port u16
sin_addr u32 sin_addr u32
sin_zero [8]char sin_zero [8]char
@ -36,8 +36,8 @@ mut:
struct C.sockaddr_un { struct C.sockaddr_un {
mut: mut:
sun_len byte sun_len u8
sun_family byte sun_family u8
sun_path [max_unix_path]char sun_path [max_unix_path]char
} }

View File

@ -16,20 +16,20 @@ mut:
struct C.sockaddr_in { struct C.sockaddr_in {
mut: mut:
sin_family byte sin_family u8
sin_port u16 sin_port u16
sin_addr u32 sin_addr u32
} }
struct C.sockaddr_in6 { struct C.sockaddr_in6 {
mut: mut:
sin6_family byte sin6_family u8
sin6_port u16 sin6_port u16
sin6_addr [4]u32 sin6_addr [4]u32
} }
struct C.sockaddr_un { struct C.sockaddr_un {
mut: mut:
sun_family byte sun_family u8
sun_path [max_unix_path]char sun_path [max_unix_path]char
} }

View File

@ -22,8 +22,8 @@ mut:
struct C.sockaddr_in6 { struct C.sockaddr_in6 {
mut: mut:
// 1 + 1 + 2 + 4 + 16 + 4 = 28; // 1 + 1 + 2 + 4 + 16 + 4 = 28;
sin6_len byte // 1 sin6_len u8 // 1
sin6_family byte // 1 sin6_family u8 // 1
sin6_port u16 // 2 sin6_port u16 // 2
sin6_flowinfo u32 // 4 sin6_flowinfo u32 // 4
sin6_addr [16]u8 // 16 sin6_addr [16]u8 // 16
@ -32,8 +32,8 @@ mut:
struct C.sockaddr_in { struct C.sockaddr_in {
mut: mut:
sin_len byte sin_len u8
sin_family byte sin_family u8
sin_port u16 sin_port u16
sin_addr u32 sin_addr u32
sin_zero [8]char sin_zero [8]char
@ -41,8 +41,8 @@ mut:
struct C.sockaddr_un { struct C.sockaddr_un {
mut: mut:
sun_len byte sun_len u8
sun_family byte sun_family u8
sun_path [max_unix_path]char sun_path [max_unix_path]char
} }

View File

@ -20,8 +20,8 @@ mut:
struct C.sockaddr_in6 { struct C.sockaddr_in6 {
mut: mut:
// 1 + 1 + 2 + 4 + 16 + 4 = 28; // 1 + 1 + 2 + 4 + 16 + 4 = 28;
sin6_len byte // 1 sin6_len u8 // 1
sin6_family byte // 1 sin6_family u8 // 1
sin6_port u16 // 2 sin6_port u16 // 2
sin6_flowinfo u32 // 4 sin6_flowinfo u32 // 4
sin6_addr [16]u8 // 16 sin6_addr [16]u8 // 16
@ -30,8 +30,8 @@ mut:
struct C.sockaddr_in { struct C.sockaddr_in {
mut: mut:
sin_len byte sin_len u8
sin_family byte sin_family u8
sin_port u16 sin_port u16
sin_addr u32 sin_addr u32
sin_zero [8]char sin_zero [8]char
@ -39,8 +39,8 @@ mut:
struct C.sockaddr_un { struct C.sockaddr_un {
mut: mut:
sun_len byte sun_len u8
sun_family byte sun_family u8
sun_path [max_unix_path]char sun_path [max_unix_path]char
} }

View File

@ -55,7 +55,7 @@ struct Ip {
} }
struct Unix { struct Unix {
path [max_unix_path]byte path [max_unix_path]u8
} }
[_pack: '1'] [_pack: '1']

View File

@ -22,8 +22,8 @@ mut:
struct C.sockaddr_in6 { struct C.sockaddr_in6 {
mut: mut:
// 1 + 1 + 2 + 4 + 16 + 4 = 28; // 1 + 1 + 2 + 4 + 16 + 4 = 28;
sin6_len byte // 1 sin6_len u8 // 1
sin6_family byte // 1 sin6_family u8 // 1
sin6_port u16 // 2 sin6_port u16 // 2
sin6_flowinfo u32 // 4 sin6_flowinfo u32 // 4
sin6_addr [16]u8 // 16 sin6_addr [16]u8 // 16
@ -32,8 +32,8 @@ mut:
struct C.sockaddr_in { struct C.sockaddr_in {
mut: mut:
sin_len byte sin_len u8
sin_family byte sin_family u8
sin_port u16 sin_port u16
sin_addr u32 sin_addr u32
sin_zero [8]char sin_zero [8]char
@ -41,8 +41,8 @@ mut:
struct C.sockaddr_un { struct C.sockaddr_un {
mut: mut:
sun_len byte sun_len u8
sun_family byte sun_family u8
sun_path [max_unix_path]char sun_path [max_unix_path]char
} }

View File

@ -20,8 +20,8 @@ mut:
struct C.sockaddr_in6 { struct C.sockaddr_in6 {
mut: mut:
// 1 + 1 + 2 + 4 + 16 + 4 = 28; // 1 + 1 + 2 + 4 + 16 + 4 = 28;
sin6_len byte // 1 sin6_len u8 // 1
sin6_family byte // 1 sin6_family u8 // 1
sin6_port u16 // 2 sin6_port u16 // 2
sin6_flowinfo u32 // 4 sin6_flowinfo u32 // 4
sin6_addr [16]u8 // 16 sin6_addr [16]u8 // 16
@ -30,8 +30,8 @@ mut:
struct C.sockaddr_in { struct C.sockaddr_in {
mut: mut:
sin_len byte sin_len u8
sin_family byte sin_family u8
sin_port u16 sin_port u16
sin_addr u32 sin_addr u32
sin_zero [8]char sin_zero [8]char
@ -39,8 +39,8 @@ mut:
struct C.sockaddr_un { struct C.sockaddr_un {
mut: mut:
sun_len byte sun_len u8
sun_family byte sun_family u8
sun_path [max_unix_path]char sun_path [max_unix_path]char
} }

View File

@ -50,7 +50,7 @@ struct Ip {
} }
struct Unix { struct Unix {
path [max_unix_path]byte path [max_unix_path]u8
} }
[_pack: '1'] [_pack: '1']

View File

@ -31,7 +31,7 @@ fn (mut s ChunkScanner) read_chunk_size() u32 {
return n return n
} }
fn unhex(c byte) byte { fn unhex(c u8) u8 {
if `0` <= c && c <= `9` { if `0` <= c && c <= `9` {
return c - `0` return c - `0`
} else if `a` <= c && c <= `f` { } else if `a` <= c && c <= `f` {

View File

@ -630,7 +630,7 @@ struct HeaderKeyError {
Error Error
code int code int
header string header string
invalid_char byte invalid_char u8
} }
pub fn (err HeaderKeyError) msg() string { 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 // 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 { return match b {
33, 35...39, 42, 43, 45, 46, 48...57, 65...90, 94...122, 124, 126 { true } 33, 35...39, 42, 43, 45, 46, 48...57, 65...90, 94...122, 124, 126 { true }
else { false } else { false }

View File

@ -762,11 +762,11 @@ struct C.WSAData {
mut: mut:
wVersion u16 wVersion u16
wHighVersion u16 wHighVersion u16
szDescription [257]byte szDescription [257]u8
szSystemStatus [129]byte szSystemStatus [129]u8
iMaxSockets u16 iMaxSockets u16
iMaxUdpDg u16 iMaxUdpDg u16
lpVendorInfo &byte lpVendorInfo &u8
} }
fn init() { fn init() {

View File

@ -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 mut res := 0
for { for {
res = C.SSL_read(voidptr(s.ssl), buf_ptr, len) res = C.SSL_read(voidptr(s.ssl), buf_ptr, len)

View File

@ -52,7 +52,7 @@ pub fn (mut c TcpConn) close() ? {
c.sock.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)) ? mut res := wrap_read_result(C.recv(c.sock.handle, voidptr(buf_ptr), len, 0)) ?
$if trace_tcp ? { $if trace_tcp ? {
eprintln('<<< TcpConn.read_ptr | c.sock.handle: $c.sock.handle | buf_ptr: ${ptr_str(buf_ptr)} len: $len | res: $res') 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 // 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 ? { $if trace_tcp ? {
eprintln( eprintln(
'>>> TcpConn.write_ptr | c.sock.handle: $c.sock.handle | b: ${ptr_str(b)} len: $len |\n' + '>>> TcpConn.write_ptr | c.sock.handle: $c.sock.handle | b: ${ptr_str(b)} len: $len |\n' +

View File

@ -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 } remote := c.sock.remote() or { return err_no_udp_remote }
return c.write_to_ptr(remote, b, len) 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) 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()) res := C.sendto(c.sock.handle, b, len, 0, voidptr(&addr), addr.len())
if res >= 0 { if res >= 0 {
return res return res

View File

@ -170,7 +170,7 @@ pub fn (mut c StreamConn) close() ? {
} }
// write_ptr blocks and attempts to write all data // 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 ? { $if trace_unix ? {
eprintln( eprintln(
'>>> StreamConn.write_ptr | c.sock.handle: $c.sock.handle | b: ${ptr_str(b)} len: $len |\n' + '>>> 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) 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)) ? mut res := wrap_read_result(C.recv(c.sock.handle, voidptr(buf_ptr), len, 0)) ?
$if trace_unix ? { $if trace_unix ? {
eprintln('<<< StreamConn.read_ptr | c.sock.handle: $c.sock.handle | buf_ptr: ${ptr_str(buf_ptr)} len: $len | res: $res') eprintln('<<< StreamConn.read_ptr | c.sock.handle: $c.sock.handle | buf_ptr: ${ptr_str(buf_ptr)} len: $len | res: $res')

View File

@ -38,7 +38,7 @@ fn error_msg(message string, val string) string {
// //
// Please be informed that for now should_escape does not check all // Please be informed that for now should_escape does not check all
// reserved characters correctly. See golang.org/issue/5684. // 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) // §2.3 Unreserved characters (alphanum)
if (`a` <= c && c <= `z`) || (`A` <= c && c <= `Z`) || (`0` <= c && c <= `9`) { if (`a` <= c && c <= `z`) || (`A` <= c && c <= `Z`) || (`0` <= c && c <= `9`) {
return false return false
@ -417,7 +417,7 @@ fn get_scheme(rawurl string) ?string {
// split slices s into two substrings separated by the first occurence of // 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. // 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. // 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) i := s.index_u8(sep)
if i < 0 { if i < 0 {
return s, '' return s, ''
@ -1062,7 +1062,7 @@ fn string_contains_ctl_u8(s string) bool {
return false return false
} }
pub fn ishex(c byte) bool { pub fn ishex(c u8) bool {
if `0` <= c && c <= `9` { if `0` <= c && c <= `9` {
return true return true
} else if `a` <= c && c <= `f` { } else if `a` <= c && c <= `f` {
@ -1073,7 +1073,7 @@ pub fn ishex(c byte) bool {
return false return false
} }
fn unhex(c byte) byte { fn unhex(c u8) u8 {
if `0` <= c && c <= `9` { if `0` <= c && c <= `9` {
return c - `0` return c - `0`
} else if `a` <= c && c <= `f` { } else if `a` <= c && c <= `f` {

View File

@ -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 // 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 { lock {
if ws.state in [.closed, .closing] || ws.conn.sock.handle <= 1 { if ws.state in [.closed, .closing] || ws.conn.sock.handle <= 1 {
return error('socket_read_ptr: trying to read a closed socket') return error('socket_read_ptr: trying to read a closed socket')

View File

@ -229,7 +229,7 @@ pub fn (mut ws Client) pong() ? {
} }
// write_ptr writes len bytes provided a byteptr with a websocket messagetype // 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') // ws.debug_log('write_ptr code: $code')
if ws.state != .open || ws.conn.sock.handle < 1 { if ws.state != .open || ws.conn.sock.handle < 1 {
// todo: send error here later // todo: send error here later

View File

@ -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. // 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. // 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) return fread(ptr, 1, max_size, f.cfile)
} }

View File

@ -286,7 +286,7 @@ fn test_read_raw() ? {
f.close() f.close()
f = os.open_file(tfile, 'r') ? f = os.open_file(tfile, 'r') ?
p := f.read_raw<Point>() ? p := f.read_raw<Point>() ?
b := f.read_raw<byte>() ? b := f.read_raw<u8>() ?
c := f.read_raw<Color>() ? c := f.read_raw<Color>() ?
x := f.read_raw<Permissions>() ? x := f.read_raw<Permissions>() ?
f.close() f.close()
@ -309,8 +309,8 @@ fn test_read_raw_at() ? {
mut at := u64(3) mut at := u64(3)
p := f.read_raw_at<Point>(at) ? p := f.read_raw_at<Point>(at) ?
at += sizeof(Point) at += sizeof(Point)
b := f.read_raw_at<byte>(at) ? b := f.read_raw_at<u8>(at) ?
at += sizeof(byte) at += sizeof(u8)
c := f.read_raw_at<Color>(at) ? c := f.read_raw_at<Color>(at) ?
at += sizeof(Color) at += sizeof(Color)
x := f.read_raw_at<Permissions>(at) ? x := f.read_raw_at<Permissions>(at) ?
@ -345,7 +345,7 @@ fn test_seek() ? {
// //
f.seek(i64(sizeof(Point)), .start) ? f.seek(i64(sizeof(Point)), .start) ?
assert f.tell() ? == sizeof(Point) assert f.tell() ? == sizeof(Point)
b := f.read_raw<byte>() ? b := f.read_raw<u8>() ?
assert b == another_byte assert b == another_byte
f.seek(i64(sizeof(Color)), .current) ? f.seek(i64(sizeof(Color)), .current) ?

View File

@ -10,7 +10,7 @@ fn C.PeekNamedPipe(hNamedPipe voidptr, lpBuffer voidptr, nBufferSize int, lpByte
type FN_NTSuspendResume = fn (voidptr) type FN_NTSuspendResume = fn (voidptr)
fn ntdll_fn(name &byte) FN_NTSuspendResume { fn ntdll_fn(name &u8) FN_NTSuspendResume {
ntdll := C.GetModuleHandleA(c'NTDLL') ntdll := C.GetModuleHandleA(c'NTDLL')
if ntdll == 0 { if ntdll == 0 {
return FN_NTSuspendResume(0) return FN_NTSuspendResume(0)

View File

@ -38,11 +38,11 @@ pub:
dbname string 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 fn C.PQstatus(voidptr) int
@ -52,20 +52,20 @@ fn C.PQntuples(&C.PGResult) int
fn C.PQnfields(&C.PGResult) int fn C.PQnfields(&C.PGResult) int
fn C.PQexec(voidptr, &byte) &C.PGResult fn C.PQexec(voidptr, &u8) &C.PGResult
// Params: // Params:
// const Oid *paramTypes // const Oid *paramTypes
// const char *const *paramValues // const char *const *paramValues
// const int *paramLengths // const int *paramLengths
// const int *paramFormats // 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 fn C.PQclear(&C.PGResult) voidptr

View File

@ -70,10 +70,10 @@ struct Picoev {
timeout_secs int timeout_secs int
max_headers int max_headers int
mut: mut:
date &byte date &u8
buf &byte buf &u8
idx [1024]int idx [1024]int
out &byte out &u8
} }
[inline] [inline]
@ -94,7 +94,7 @@ fn close_conn(loop &C.picoev_loop, fd int) {
} }
[inline] [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 { unsafe {
return C.read(fd, b + idx, max_len - idx) return C.read(fd, b + idx, max_len - idx)
} }

View File

@ -1,7 +1,7 @@
module picohttpparser module picohttpparser
[inline; unsafe] [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) } unsafe { C.memcpy(dst, src, len) }
return len return len
} }

View File

@ -3,10 +3,10 @@ module picohttpparser
pub struct Response { pub struct Response {
fd int fd int
pub: pub:
date &byte = 0 date &u8 = 0
buf_start &byte = 0 buf_start &u8 = 0
pub mut: pub mut:
buf &byte = 0 buf &u8 = 0
} }
[inline] [inline]

View File

@ -99,7 +99,7 @@ pub fn (mut rng MT19937RNG) seed(seed_data []u32) {
// byte returns a uniformly distributed pseudorandom 8-bit unsigned positive `byte`. // byte returns a uniformly distributed pseudorandom 8-bit unsigned positive `byte`.
[inline] [inline]
pub fn (mut rng MT19937RNG) u8() byte { pub fn (mut rng MT19937RNG) u8() u8 {
if rng.bytes_left >= 1 { if rng.bytes_left >= 1 {
rng.bytes_left -= 1 rng.bytes_left -= 1
value := u8(rng.buffer) value := u8(rng.buffer)

View File

@ -29,7 +29,7 @@ pub fn (mut rng MuslRNG) seed(seed_data []u32) {
// byte returns a uniformly distributed pseudorandom 8-bit unsigned positive `byte`. // byte returns a uniformly distributed pseudorandom 8-bit unsigned positive `byte`.
[inline] [inline]
pub fn (mut rng MuslRNG) u8() byte { pub fn (mut rng MuslRNG) u8() u8 {
if rng.bytes_left >= 1 { if rng.bytes_left >= 1 {
rng.bytes_left -= 1 rng.bytes_left -= 1
value := u8(rng.buffer) value := u8(rng.buffer)

View File

@ -39,7 +39,7 @@ pub fn (mut rng PCG32RNG) seed(seed_data []u32) {
// byte returns a uniformly distributed pseudorandom 8-bit unsigned positive `byte`. // byte returns a uniformly distributed pseudorandom 8-bit unsigned positive `byte`.
[inline] [inline]
pub fn (mut rng PCG32RNG) u8() byte { pub fn (mut rng PCG32RNG) u8() u8 {
if rng.bytes_left >= 1 { if rng.bytes_left >= 1 {
rng.bytes_left -= 1 rng.bytes_left -= 1
value := u8(rng.buffer) value := u8(rng.buffer)

View File

@ -16,7 +16,7 @@ import time
pub interface PRNG { pub interface PRNG {
mut: mut:
seed(seed_data []u32) seed(seed_data []u32)
u8() byte u8() u8
u16() u16 u16() u16
u32() u32 u32() u32
u64() u64 u64() u64
@ -424,7 +424,7 @@ pub fn intn(max int) ?int {
} }
// byte returns a uniformly distributed pseudorandom 8-bit unsigned positive `byte`. // byte returns a uniformly distributed pseudorandom 8-bit unsigned positive `byte`.
pub fn u8() byte { pub fn u8() u8 {
return default_rng.u8() return default_rng.u8()
} }

View File

@ -29,7 +29,7 @@ pub fn (mut rng SplitMix64RNG) seed(seed_data []u32) {
// byte returns a uniformly distributed pseudorandom 8-bit unsigned positive `byte`. // byte returns a uniformly distributed pseudorandom 8-bit unsigned positive `byte`.
[inline] [inline]
pub fn (mut rng SplitMix64RNG) u8() byte { pub fn (mut rng SplitMix64RNG) u8() u8 {
if rng.bytes_left >= 1 { if rng.bytes_left >= 1 {
rng.bytes_left -= 1 rng.bytes_left -= 1
value := u8(rng.buffer) value := u8(rng.buffer)

View File

@ -64,7 +64,7 @@ pub fn (r SysRNG) default_rand() int {
// byte returns a uniformly distributed pseudorandom 8-bit unsigned positive `byte`. // byte returns a uniformly distributed pseudorandom 8-bit unsigned positive `byte`.
[inline] [inline]
pub fn (mut r SysRNG) u8() byte { pub fn (mut r SysRNG) u8() u8 {
if r.bytes_left >= 1 { if r.bytes_left >= 1 {
r.bytes_left -= 1 r.bytes_left -= 1
value := u8(r.buffer) value := u8(r.buffer)

View File

@ -35,7 +35,7 @@ pub fn (mut rng WyRandRNG) seed(seed_data []u32) {
// byte returns a uniformly distributed pseudorandom 8-bit unsigned positive `byte`. // byte returns a uniformly distributed pseudorandom 8-bit unsigned positive `byte`.
[inline] [inline]
pub fn (mut rng WyRandRNG) u8() byte { pub fn (mut rng WyRandRNG) u8() u8 {
// Can we extract a value from the buffer? // Can we extract a value from the buffer?
if rng.bytes_left >= 1 { if rng.bytes_left >= 1 {
rng.bytes_left -= 1 rng.bytes_left -= 1

View File

@ -22,7 +22,7 @@ mut:
c_oflag int c_oflag int
c_cflag int c_cflag int
c_lflag int c_lflag int
c_line byte c_line u8
c_cc [cclen]int c_cc [cclen]int
} }
@ -32,7 +32,7 @@ mut:
c_oflag u32 c_oflag u32
c_cflag u32 c_cflag u32
c_lflag u32 c_lflag u32
c_line byte c_line u8
c_cc [cclen]int 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 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. // 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() c := r.read_char()
match u8(c) { match u8(c) {
`~` { `~` {

View File

@ -75,7 +75,7 @@ General Utilities
*/ */
// utf8util_char_len calculate the length in bytes of a utf8 char // utf8util_char_len calculate the length in bytes of a utf8 char
[inline] [inline]
fn utf8util_char_len(b byte) int { fn utf8util_char_len(b u8) int {
return ((0xe5000000 >> ((b >> 3) & 0x1e)) & 3) + 1 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 // get_charb get a char from position i and return an u32 with the unicode code
[direct_array_access; inline] [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 // ascii 8 bit
if (re.flag & regex.f_bin) != 0 || unsafe { in_txt[i] } & 0x80 == 0 { if (re.flag & regex.f_bin) != 0 || unsafe { in_txt[i] } & 0x80 == 0 {
return u32(unsafe { in_txt[i] }), 1 return u32(unsafe { in_txt[i] }), 1
@ -117,7 +117,7 @@ fn (re RE) get_charb(in_txt &byte, i int) (u32, int) {
} }
[inline] [inline]
fn is_alnum(in_char byte) bool { fn is_alnum(in_char u8) bool {
mut tmp := in_char - `A` mut tmp := in_char - `A`
if tmp <= 25 { if tmp <= 25 {
return true return true
@ -137,28 +137,28 @@ fn is_alnum(in_char byte) bool {
} }
[inline] [inline]
fn is_not_alnum(in_char byte) bool { fn is_not_alnum(in_char u8) bool {
return !is_alnum(in_char) return !is_alnum(in_char)
} }
[inline] [inline]
fn is_space(in_char byte) bool { fn is_space(in_char u8) bool {
return in_char in regex.spaces return in_char in regex.spaces
} }
[inline] [inline]
fn is_not_space(in_char byte) bool { fn is_not_space(in_char u8) bool {
return !is_space(in_char) return !is_space(in_char)
} }
[inline] [inline]
fn is_digit(in_char byte) bool { fn is_digit(in_char u8) bool {
tmp := in_char - `0` tmp := in_char - `0`
return tmp <= 0x09 return tmp <= 0x09
} }
[inline] [inline]
fn is_not_digit(in_char byte) bool { fn is_not_digit(in_char u8) bool {
return !is_digit(in_char) return !is_digit(in_char)
} }
@ -175,13 +175,13 @@ fn is_not_wordchar(in_char byte) bool {
*/ */
[inline] [inline]
fn is_lower(in_char byte) bool { fn is_lower(in_char u8) bool {
tmp := in_char - `a` tmp := in_char - `a`
return tmp <= 25 return tmp <= 25
} }
[inline] [inline]
fn is_upper(in_char byte) bool { fn is_upper(in_char u8) bool {
tmp := in_char - `A` tmp := in_char - `A`
return tmp <= 25 return tmp <= 25
} }
@ -231,14 +231,14 @@ fn simple_log(txt string) {
* Token Structs * Token Structs
* *
******************************************************************************/ ******************************************************************************/
pub type FnValidator = fn (byte) bool pub type FnValidator = fn (u8) bool
struct Token { struct Token {
mut: mut:
ist rune ist rune
// char // char
ch rune // char of the token if any ch rune // char of the token if any
ch_len byte // char len ch_len u8 // char len
// Quantifiers / branch // Quantifiers / branch
rep_min int // used also for jump next in the OR branch [no match] pc jump 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 rep_max int // used also for jump next in the OR branch [ match] pc jump
@ -1666,7 +1666,7 @@ pub mut:
} }
[direct_array_access] [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 // result status
mut result := regex.no_match_found // function return mut result := regex.no_match_found // function return

View File

@ -527,9 +527,9 @@ struct C.sg_stencil_state {
enabled bool enabled bool
front StencilFaceState front StencilFaceState
back StencilFaceState back StencilFaceState
read_mask byte read_mask u8
write_mask byte write_mask u8
ref byte ref u8
} }
pub type StencilState = C.sg_stencil_state 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 { struct C.sg_stencil_attachment_action {
pub mut: pub mut:
action Action action Action
value byte value u8
} }
pub type StencilAttachmentAction = C.sg_stencil_attachment_action pub type StencilAttachmentAction = C.sg_stencil_attachment_action

View File

@ -37,7 +37,7 @@ pub:
frame_cb fn () frame_cb fn ()
cleanup_cb fn () cleanup_cb fn ()
event_cb fn (&Event) //&sapp_event) 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 user_data voidptr // these are the user-provided callbacks with user data
init_userdata_cb fn (voidptr) init_userdata_cb fn (voidptr)

View File

@ -45,7 +45,7 @@ pub fn screenshot_png(path string) ? {
} }
// write_rgba_to_ppm writes `pixels` data in RGBA format to PPM3 format. // 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) ? mut f_out := os.create(path) ?
defer { defer {
f_out.close() f_out.close()

View File

@ -6,7 +6,7 @@ pub struct Screenshot {
height int height int
size int size int
mut: mut:
pixels &byte pixels &u8
} }
[manualfree] [manualfree]

View File

@ -17,7 +17,7 @@ pub fn destroy(ctx &fontstash.Context) {
} }
[inline] [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) return C.sfons_rgba(r, g, b, a)
} }

View File

@ -4,5 +4,5 @@ import fontstash
fn C.sfons_create(width int, height int, flags int) &fontstash.Context fn C.sfons_create(width int, height int, flags int) &fontstash.Context
fn C.sfons_destroy(ctx &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) fn C.sfons_flush(ctx &fontstash.Context)

View File

@ -240,12 +240,12 @@ pub fn c4f(r f32, g f32, b f32, a f32) {
} }
[inline] [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) C.sgl_c3b(r, g, b)
} }
[inline] [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) 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] [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) 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] [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) 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] [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) 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] [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) 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] [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) 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] [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) 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] [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) 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] [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) C.sgl_v3f_t2f_c4b(x, y, z, u, v, r, g, b, a)
} }

View File

@ -59,8 +59,8 @@ fn C.sgl_pop_matrix()
fn C.sgl_t2f(u f32, v f32) fn C.sgl_t2f(u f32, v f32)
fn C.sgl_c3f(r f32, g f32, b 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_c4f(r f32, g f32, b f32, a f32)
fn C.sgl_c3b(r byte, g byte, b byte) fn C.sgl_c3b(r u8, g u8, b u8)
fn C.sgl_c4b(r byte, g byte, b byte, a byte) fn C.sgl_c4b(r u8, g u8, b u8, a u8)
fn C.sgl_c1i(rgba u32) fn C.sgl_c1i(rgba u32)
fn C.sgl_point_size(s f32) 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_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_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_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_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_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_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_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_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_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_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_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_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_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_v3f_t2f_c1i(x f32, y f32, z f32, u f32, v f32, rgba u32)
fn C.sgl_end() fn C.sgl_end()

View File

@ -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_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 fn C.sqlite3_column_int(&C.sqlite3_stmt, int) int

View File

@ -69,7 +69,7 @@ pub fn write_tga_with_rle(flag bool) {
// Utility functions // 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() { pub fn (img &Image) free() {
C.stbi_image_free(img.data) C.stbi_image_free(img.data)
@ -80,9 +80,9 @@ pub fn (img &Image) free() {
// Load functions // Load functions
// //
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
fn C.stbi_load(filename &char, 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) &byte 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 &byte, len int, x &int, y &int, channels_in_file &int, desired_channels int) &byte 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 // load load an image from a path
pub fn load(path string) ?Image { 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 // 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{ mut res := Image{
ok: true ok: true
data: 0 data: 0
@ -126,30 +126,30 @@ pub fn load_from_memory(buf &byte, bufsize int) ?Image {
// Write functions // 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_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 &byte) 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 &byte) 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 &byte, quality int) 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 // 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 // stbi_write_png write on path a PNG file
// row_stride_in_bytes is usually equal to: w * comp // 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) { 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"') return error('stbi_image failed to write png file to "$path"')
} }
} }
// stbi_write_png write on path a BMP file // 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) { if 0 == C.stbi_write_bmp(&char(path.str), w, h, comp, buf) {
return error('stbi_image failed to write bmp file to "$path"') return error('stbi_image failed to write bmp file to "$path"')
} }
} }
// stbi_write_png write on path a TGA file // 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) { if 0 == C.stbi_write_tga(&char(path.str), w, h, comp, buf) {
return error('stbi_image failed to write tga file to "$path"') 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 // stbi_write_png write on path a JPG file
// quality select teh compression quality of the JPG // quality select teh compression quality of the JPG
// quality is between 1 and 100. Higher quality looks better but results in a bigger image. // 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) { 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"') return error('stbi_image failed to write jpg file to "$path"')
} }

View File

@ -100,15 +100,15 @@ fn sub96(s2 u32, s1 u32, s0 u32, d2 u32, d1 u32, d0 u32) (u32, u32, u32) {
} }
// Utility functions // Utility functions
fn is_digit(x byte) bool { fn is_digit(x u8) bool {
return (x >= strconv.c_zero && x <= strconv.c_nine) == true 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 == ` ` 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 return (x == `E` || x == `e`) == true
} }

View File

@ -12,7 +12,7 @@ const (
max_u64 = u64(18446744073709551615) // as u64 // use this until we add support 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`) return c | (`x` - `X`)
} }

View File

@ -80,7 +80,7 @@ Single format functions
*/ */
pub struct BF_param { pub struct BF_param {
pub mut: 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 len0 int = -1 // default len for whole the number or string
len1 int = 6 // number of decimal digits, if needed len1 int = 6 // number of decimal digits, if needed
positive bool = true // mandatory: the sign of the number passed positive bool = true // mandatory: the sign of the number passed

View File

@ -76,7 +76,7 @@ pub fn format_dec_sb(d u64, p BF_param, mut res strings.Builder) {
// Legacy version // Legacy version
// max u64 18446744073709551615 => 20 byte // max u64 18446744073709551615 => 20 byte
mut buf := [32]byte{} mut buf := [32]u8{}
mut i := 20 mut i := 20
mut d1 := d mut d1 := d
for i >= (21 - n_char) { for i >= (21 - n_char) {

View File

@ -18,7 +18,7 @@ pub fn new_builder(initial_size int) Builder {
// write_ptr writes `len` bytes provided byteptr to the accumulated buffer // write_ptr writes `len` bytes provided byteptr to the accumulated buffer
[unsafe] [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 { if len == 0 {
return 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 // write_b appends a single `data` byte to the accumulated buffer
[deprecated: 'Use write_u8() instead'] [deprecated: 'Use write_u8() instead']
[deprecated_after: '2022-02-11'] [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 b << data
} }
// write_byte appends a single `data` byte to the accumulated buffer // 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 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`. // 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. // Note: it can panic, if there are not enough bytes in the strings builder yet.
[inline] [inline]
pub fn (b &Builder) byte_at(n int) byte { pub fn (b &Builder) byte_at(n int) u8 {
return unsafe { (&[]u8(b))[n] } return unsafe { (&[]u8(b))[n] }
} }

View File

@ -1,7 +1,7 @@
module strings module strings
// strings.repeat - fill a string with `n` repetitions of the character `c` // 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 { if n <= 0 {
return '' return ''
} }

View File

@ -1,6 +1,6 @@
module strings module strings
pub fn repeat(c byte, n int) string { pub fn repeat(c u8, n int) string {
if n <= 0 { if n <= 0 {
return '' return ''
} }

View File

@ -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. // 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('(V) (NOT V)',`(`,`)`) == 'V'
// Example: assert strings.find_between_pair_u8('s {X{Y}} s',`{`,`}`) == 'X{Y}' // 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 marks := 0
mut start_index := -1 mut start_index := -1
for i, b in input { for i, b in input {

View File

@ -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 { for i in 0 .. 300 {
ch <- u8(i) ch <- u8(i)
} }
@ -29,7 +29,7 @@ fn do_send_i64(ch chan i64) {
fn test_select() { fn test_select() {
chi := chan int{} chi := chan int{}
chl := chan i64{cap: 1} chl := chan i64{cap: 1}
chb := chan byte{cap: 10} chb := chan u8{cap: 10}
recch := chan i64{cap: 0} recch := chan i64{cap: 0}
go do_rec_i64(recch) go do_rec_i64(recch)
go do_send_int(chi) go do_send_int(chi)

View File

@ -43,7 +43,7 @@ fn do_send_i64(mut ch Channel) {
fn test_select() { fn test_select() {
mut chi := new_channel<int>(0) mut chi := new_channel<int>(0)
mut chl := new_channel<i64>(1) mut chl := new_channel<i64>(1)
mut chb := new_channel<byte>(10) mut chb := new_channel<u8>(10)
mut recch := new_channel<i64>(0) mut recch := new_channel<i64>(0)
go do_rec_i64(mut recch) go do_rec_i64(mut recch)
go do_send_int(mut chi) go do_send_int(mut chi)

View File

@ -42,7 +42,7 @@ fn do_send_i64(mut ch Channel) {
fn test_select() { fn test_select() {
mut chi := new_channel<int>(0) mut chi := new_channel<int>(0)
mut chl := new_channel<i64>(1) mut chl := new_channel<i64>(1)
mut chb := new_channel<byte>(10) mut chb := new_channel<u8>(10)
mut recch := new_channel<i64>(0) mut recch := new_channel<i64>(0)
go do_rec_i64(mut recch) go do_rec_i64(mut recch)
go do_send_int(mut chi) go do_send_int(mut chi)

View File

@ -15,13 +15,13 @@ fn C.zip_open(&char, int, char) &Zip
fn C.zip_close(&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_openbyindex(&Zip, int) int
fn C.zip_entry_close(&Zip) 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 fn C.zip_entry_index(&Zip) int
@ -66,7 +66,7 @@ pub enum OpenMode {
} }
[inline] [inline]
fn (om OpenMode) to_u8() byte { fn (om OpenMode) to_u8() u8 {
return match om { return match om {
.write { .write {
`w` `w`

Some files were not shown because too many files have changed in this diff Show More