1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

all: ~500 more byte=>u8

This commit is contained in:
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_CreateString() &C.cJSON
fn C.cJSON_CreateRaw(&byte) &C.cJSON
fn C.cJSON_CreateRaw(&u8) &C.cJSON
fn C.cJSON_IsInvalid(voidptr) bool
@ -45,13 +45,13 @@ fn C.cJSON_IsObject(voidptr) bool
fn C.cJSON_IsRaw(voidptr) bool
fn C.cJSON_AddItemToObject(voidptr, &byte, voidptr)
fn C.cJSON_AddItemToObject(voidptr, &u8, voidptr)
fn C.cJSON_AddItemToArray(voidptr, voidptr)
fn C.cJSON_Delete(voidptr)
fn C.cJSON_Print(voidptr) &byte
fn C.cJSON_Print(voidptr) &u8
[inline]
fn create_object() &C.cJSON {

View File

@ -68,7 +68,7 @@ fn destroy_texture(sg_img gfx.Image) {
}
// Use only if usage: .dynamic is enabled
fn update_text_texture(sg_img gfx.Image, w int, h int, buf &byte) {
fn update_text_texture(sg_img gfx.Image, w int, h int, buf &u8) {
sz := w * h * 4
mut tmp_sbc := gfx.ImageData{}
tmp_sbc.subimage[0][0] = gfx.Range{

View File

@ -18,7 +18,7 @@ import stbi
/******************************************************************************
* Texture functions
******************************************************************************/
pub fn create_texture(w int, h int, buf &byte) gfx.Image {
pub fn create_texture(w int, h int, buf &u8) gfx.Image {
sz := w * h * 4
mut img_desc := gfx.ImageDesc{
width: w

View File

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

View File

@ -61,7 +61,7 @@ fn graphics_frame(mut state AppState) {
}
[inline]
fn (mut state AppState) bsample(idx int) byte {
fn (mut state AppState) bsample(idx int) u8 {
return u8(127 + state.frames[(state.gframe + idx) & 2047] * 128)
}

View File

@ -104,15 +104,15 @@ struct RIFFChunkHeader {
}
struct RIFFFormat {
format_tag u16 // PCM = 1; Values other than 1 indicate some form of compression.
nchannels u16 // Nc ; 1 = mono ; 2 = stereo
sample_rate u32 // F
avg_bytes_per_second u32 // F * M*Nc
nblock_align u16 // M*Nc
bits_per_sample u16 // 8 * M
cbsize u16 // Size of the extension: 22
valid_bits_per_sample u16 // at most 8*M
channel_mask u32 // Speaker position mask
format_tag u16 // PCM = 1; Values other than 1 indicate some form of compression.
nchannels u16 // Nc ; 1 = mono ; 2 = stereo
sample_rate u32 // F
avg_bytes_per_second u32 // F * M*Nc
nblock_align u16 // M*Nc
bits_per_sample u16 // 8 * M
cbsize u16 // Size of the extension: 22
valid_bits_per_sample u16 // at most 8*M
channel_mask u32 // Speaker position mask
sub_format [16]u8 // GUID
}

View File

@ -144,7 +144,7 @@ fn destroy_texture(sg_img gfx.Image) {
}
// Use only if: .dynamic is enabled
fn update_text_texture(sg_img gfx.Image, w int, h int, buf &byte) {
fn update_text_texture(sg_img gfx.Image, w int, h int, buf &u8) {
sz := w * h * 4
mut tmp_sbc := gfx.ImageData{}
tmp_sbc.subimage[0][0] = gfx.Range{

View File

@ -283,10 +283,10 @@ fn test_copy() {
}
fn test_can_copy_bits() {
assert can_copy_bits<byte>()
assert can_copy_bits<u8>()
assert can_copy_bits<int>()
assert can_copy_bits<voidptr>()
assert can_copy_bits<&byte>()
assert can_copy_bits<&u8>()
// autofree needs to intercept assign
assert !can_copy_bits<string>()
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)
for i in 0 .. a.len / 2 {
vmemcpy(tmp_value, &u8(a.data) + i * a.element_size, a.element_size)
vmemcpy(&u8(a.data) + i * a.element_size, &u8(a.data) +
(a.len - 1 - i) * a.element_size, a.element_size)
vmemcpy(&u8(a.data) + i * a.element_size, &u8(a.data) + (a.len - 1 - i) * a.element_size,
a.element_size)
vmemcpy(&u8(a.data) + (a.len - 1 - i) * a.element_size, tmp_value, a.element_size)
}
free(tmp_value)

View File

@ -7,7 +7,7 @@ module builtin
// ----- value to string functions -----
//
//type u8 = byte
// type u8 = byte
type byte = u8
type i32 = int

View File

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

View File

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

View File

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

View File

@ -1,31 +1,89 @@
module main
import forkedtest
import builtin.linux_bare.old..checks.forkedtest
const (
sample_text_file1 = ""
sample_text_file1 = ''
)
fn check_fork_minimal () {
fn check_fork_minimal() {
child := sys_fork()
ec := 100
if child == 0 {
println("child")
println('child')
sys_exit(ec)
}
siginfo := [
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0]
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
]
e := sys_waitid(.p_pid, child, intptr(siginfo.data) , .wexited, 0)
e := sys_waitid(.p_pid, child, intptr(siginfo.data), .wexited, 0)
assert e == .enoerror
//println(i64_tos(buffer0,80,siginfo[Sig_index.si_code],16))
// println(i64_tos(buffer0,80,siginfo[Sig_index.si_code],16))
assert siginfo[Sig_index.si_code] == int(Wi_si_code.cld_exited)
assert siginfo[Sig_index.si_pid] == child
assert siginfo[Sig_index.si_status] == ec
@ -40,7 +98,7 @@ fn check_read_write_pipe() {
// sys_read
// sys_close
//
buffer0 := []byte{len:(128)}
buffer0 := []u8{len: (128)}
buffer := byteptr(buffer0.data)
fd := [-1, -1]
@ -55,9 +113,9 @@ fn check_read_write_pipe() {
assert fd[0] != -1
assert fd[1] != -1
test_data := "test_data"
test_data := 'test_data'
b := test_data.len + 1
c1, e1 := sys_write (fd[1], test_data.str, u64(b))
c1, e1 := sys_write(fd[1], test_data.str, u64(b))
assert e1 == .enoerror
assert c1 == b
@ -67,9 +125,9 @@ fn check_read_write_pipe() {
assert e2 == .enoerror
assert c2 == b
assert buffer[b-1] == 0
assert buffer[b - 1] == 0
for i in 0..b {
for i in 0 .. b {
assert test_data[i] == buffer[i]
}
@ -81,32 +139,32 @@ fn check_read_write_pipe() {
fn check_read_file() {
/*
Checks the following system calls:
Checks the following system calls:
sys_read
sys_write
sys_close
sys_open
*/
buffer0 := []byte{len:(128)}
buffer0 := []u8{len: (128)}
buffer := byteptr(buffer0.data)
test_file := "sample_text1.txt"
sample_text := "Do not change this text.\n"
test_file := 'sample_text1.txt'
sample_text := 'Do not change this text.\n'
fd, ec := sys_open(test_file.str, .o_rdonly, 0)
assert fd > 0
assert ec == .enoerror
n := sample_text.len
c, e := sys_read(fd, buffer, u64(n*2))
c, e := sys_read(fd, buffer, u64(n * 2))
assert e == .enoerror
assert c == n
for i in 0..n {
for i in 0 .. n {
assert sample_text[i] == buffer[i]
}
assert sys_close(fd) == .enoerror
}
fn check_open_file_fail() {
fd1, ec1 := sys_open("./nofilehere".str, .o_rdonly, 0)
fd1, ec1 := sys_open('./nofilehere'.str, .o_rdonly, 0)
assert fd1 == -1
assert ec1 == .enoent
}
@ -126,19 +184,20 @@ fn check_print() {
*/
fn check_munmap_fail() {
ec := sys_munmap(-16384,8192)
ec := sys_munmap(-16384, 8192)
assert ec == .einval
}
fn check_mmap_one_page() {
mp := int(Mm_prot.prot_read) | int(Mm_prot.prot_write)
mf := int(Map_flags.map_private) | int(Map_flags.map_anonymous)
mut a, e := sys_mmap(0, u64(Linux_mem.page_size), Mm_prot(mp), Map_flags(mf), -1, 0)
mut a, e := sys_mmap(0, u64(Linux_mem.page_size), Mm_prot(mp), Map_flags(mf), -1,
0)
assert e == .enoerror
assert a != byteptr(-1)
for i in 0..int(Linux_mem.page_size) {
for i in 0 .. int(Linux_mem.page_size) {
b := i & 0xFF
a[i] = b
assert a[i] == b
@ -149,32 +208,32 @@ fn check_mmap_one_page() {
}
fn check_mm_pages() {
for i in 0 .. int(Linux_mem.page_size)-4 {
for i in 0 .. int(Linux_mem.page_size) - 4 {
assert u32(1) == mm_pages(u64(i))
}
for i in int(Linux_mem.page_size)-3 .. (int(Linux_mem.page_size)*2)-4 {
for i in int(Linux_mem.page_size) - 3 .. (int(Linux_mem.page_size) * 2) - 4 {
assert u32(2) == mm_pages(u64(i))
}
for i in (int(Linux_mem.page_size)*2)-3 .. (int(Linux_mem.page_size)*3)-4 {
for i in (int(Linux_mem.page_size) * 2) - 3 .. (int(Linux_mem.page_size) * 3) - 4 {
assert u32(3) == mm_pages(u64(i))
}
}
//pub fn mm_alloc(size u64) (voidptr, Errno)
// pub fn mm_alloc(size u64) (voidptr, Errno)
fn check_mm_alloc() {
for i in 1 .. 2000 {
size := u64(i*1000)
size := u64(i * 1000)
pages := mm_pages(size)
mut a, e := mm_alloc(size)
assert e == .enoerror
ap := intptr(a-4)
ap := intptr(a - 4)
assert *ap == int(pages)
assert e == .enoerror
assert !isnil(a)
if (i%111) == 0 {
if (i % 111) == 0 {
for j in 0 .. int(size) {
b := j & 0xFF
a[j] = b
@ -189,7 +248,7 @@ fn check_mm_alloc() {
}
fn check_int_array_ro() {
a := [100,110,120,130]
a := [100, 110, 120, 130]
assert a.len == 4
assert a[0] == 100
assert a[1] == 110
@ -198,13 +257,13 @@ fn check_int_array_ro() {
}
fn check_int_array_rw() {
mut a := [-10,-11,-12,-13]
mut a := [-10, -11, -12, -13]
assert a.len == 4
assert a[0] == -10
assert a[1] == -11
assert a[2] == -12
assert a[3] == -13
for i in 0..a.len {
for i in 0 .. a.len {
b := -a[i] * 10
a[i] = b
assert a[i] == b
@ -213,7 +272,7 @@ fn check_int_array_rw() {
}
fn check_int64_array_ro() {
a := [i64(1000),1100,1200,1300,1400]
a := [i64(1000), 1100, 1200, 1300, 1400]
assert a.len == 5
assert a[0] == 1000
assert a[1] == 1100
@ -229,7 +288,7 @@ fn check_voidptr_array_ro() {
voidptr(12000),
voidptr(13000),
voidptr(14000),
voidptr(15000)
voidptr(15000),
]
assert a.len == 6
assert a[0] == voidptr(10000)
@ -247,7 +306,7 @@ fn check_voidptr_array_rw() {
voidptr(-1),
voidptr(-1),
voidptr(-1),
voidptr(-1)
voidptr(-1),
]
assert a.len == 6
@ -277,23 +336,22 @@ fn check_voidptr_array_rw() {
assert a[5] == voidptr(150000)
}
fn main() {
mut fails := 0
fails += forkedtest.normal_run(check_fork_minimal, "check_fork_minimal")
fails += forkedtest.normal_run(check_munmap_fail, "check_munmap_fail")
fails += forkedtest.normal_run(check_mmap_one_page, "check_mmap_one_page")
fails += forkedtest.normal_run(check_mm_pages, "check_mm_pages")
fails += forkedtest.normal_run(check_mm_alloc, "check_mm_alloc")
fails += forkedtest.normal_run(check_read_write_pipe, "check_read_write_pipe")
fails += forkedtest.normal_run(check_read_file, "check_read_file")
fails += forkedtest.normal_run(check_fork_minimal, 'check_fork_minimal')
fails += forkedtest.normal_run(check_munmap_fail, 'check_munmap_fail')
fails += forkedtest.normal_run(check_mmap_one_page, 'check_mmap_one_page')
fails += forkedtest.normal_run(check_mm_pages, 'check_mm_pages')
fails += forkedtest.normal_run(check_mm_alloc, 'check_mm_alloc')
fails += forkedtest.normal_run(check_read_write_pipe, 'check_read_write_pipe')
fails += forkedtest.normal_run(check_read_file, 'check_read_file')
// check_print()
fails += forkedtest.normal_run(check_open_file_fail, "check_open_file_fail")
fails += forkedtest.normal_run(check_int_array_ro, "check_int_array_ro")
fails += forkedtest.normal_run(check_int_array_rw, "check_int_array_rw")
fails += forkedtest.normal_run(check_int64_array_ro, "check_int64_array_ro")
fails += forkedtest.normal_run(check_voidptr_array_ro, "check_voidptr_array_ro")
fails += forkedtest.normal_run(check_voidptr_array_rw, "check_voidptr_array_rw")
fails += forkedtest.normal_run(check_open_file_fail, 'check_open_file_fail')
fails += forkedtest.normal_run(check_int_array_ro, 'check_int_array_ro')
fails += forkedtest.normal_run(check_int_array_rw, 'check_int_array_rw')
fails += forkedtest.normal_run(check_int64_array_ro, 'check_int64_array_ro')
fails += forkedtest.normal_run(check_voidptr_array_ro, 'check_voidptr_array_ro')
fails += forkedtest.normal_run(check_voidptr_array_rw, 'check_voidptr_array_rw')
assert fails == 0
sys_exit(0)

View File

@ -1,63 +1,63 @@
module main
import forkedtest
fn check_string_eq () {
assert "monkey" != "rat"
some_animal := "a bird"
assert some_animal == "a bird"
import builtin.linux_bare.old..checks.forkedtest
fn check_string_eq() {
assert 'monkey' != 'rat'
some_animal := 'a bird'
assert some_animal == 'a bird'
}
fn check_i64_tos() {
buffer0 := []byte{len:(128)}
buffer0 := []u8{len: (128)}
buffer := byteptr(buffer0.data)
s0 := i64_tos(buffer, 70, 140, 10)
assert s0 == "140"
assert s0 == '140'
s1 := i64_tos(buffer, 70, -160, 10)
assert s1 == "-160"
assert s1 == '-160'
s2 := i64_tos(buffer, 70, 65537, 16)
assert s2 == "10001"
assert s2 == '10001'
s3 := i64_tos(buffer, 70, -160000, 10)
assert s3 == "-160000"
assert s3 == '-160000'
}
fn check_i64_str() {
assert "141" == i64_str(141, 10)
assert "-161" == i64_str(-161, 10)
assert "10002" == i64_str(65538, 16)
assert "-160001" == i64_str(-160001, 10)
assert '141' == i64_str(141, 10)
assert '-161' == i64_str(-161, 10)
assert '10002' == i64_str(65538, 16)
assert '-160001' == i64_str(-160001, 10)
}
fn check_str_clone() {
a := i64_str(1234,10)
a := i64_str(1234, 10)
b := a.clone()
assert a == b
c := i64_str(-6789,10).clone()
assert c == "-6789"
c := i64_str(-6789, 10).clone()
assert c == '-6789'
}
fn check_string_add_works(){
abc := 'abc'
combined := 'a' + 'b' + 'c'
assert abc.len == combined.len
assert abc[0] == combined[0]
assert abc[1] == combined[1]
assert abc[2] == combined[2]
assert abc[0] == `a`
assert abc == combined
}
fn check_string_add_works() {
abc := 'abc'
combined := 'a' + 'b' + 'c'
assert abc.len == combined.len
assert abc[0] == combined[0]
assert abc[1] == combined[1]
assert abc[2] == combined[2]
assert abc[0] == `a`
assert abc == combined
}
fn main () {
fn main() {
mut fails := 0
fails += forkedtest.normal_run(check_string_eq, "check_string_eq")
fails += forkedtest.normal_run(check_i64_tos, "check_i64_tos")
fails += forkedtest.normal_run(check_i64_str, "check_i64_str")
fails += forkedtest.normal_run(check_str_clone, "check_str_clone")
fails += forkedtest.normal_run(check_string_add_works, "check_string_add_works")
fails += forkedtest.normal_run(check_string_eq, 'check_string_eq')
fails += forkedtest.normal_run(check_i64_tos, 'check_i64_tos')
fails += forkedtest.normal_run(check_i64_str, 'check_i64_str')
fails += forkedtest.normal_run(check_str_clone, 'check_str_clone')
fails += forkedtest.normal_run(check_string_add_works, 'check_string_add_works')
assert fails == 0
sys_exit(0)
}

View File

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

View File

@ -44,7 +44,7 @@ Note: A V string should be/is immutable from the point of view of
pub struct string {
pub:
str &u8 = 0 // points to a C style 0 terminated string of bytes.
len int // the length of the .str field, excluding the ending 0 byte. It is always equal to strlen(.str).
len int // the length of the .str field, excluding the ending 0 byte. It is always equal to strlen(.str).
// NB string.is_lit is an enumeration of the following:
// .is_lit == 0 => a fresh string, should be freed by autofree
// .is_lit == 1 => a literal string from .rodata, should NOT be freed
@ -1215,7 +1215,7 @@ pub fn (s string) to_upper() string {
pub fn (s string) is_upper() bool {
for i in 0 .. s.len {
if s[i] >= `a` && s[i] <= `z` {
return false
return false
}
}
return true

View File

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

View File

@ -17,7 +17,7 @@ mut:
fn C.darwin_new_pasteboard() voidptr
fn C.darwin_get_pasteboard_text(voidptr) &byte
fn C.darwin_get_pasteboard_text(voidptr) &u8
fn C.darwin_set_pasteboard_text(voidptr, string) bool

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.XInternAtom(d &C.Display, typ &byte, only_if_exists int) Atom
fn C.XInternAtom(d &C.Display, typ &u8, only_if_exists int) Atom
fn C.XCreateSimpleWindow(d &C.Display, root Window, x int, y int, width u32, height u32, border_width u32, border u64, background u64) Window
fn C.XOpenDisplay(name &byte) &C.Display
fn C.XOpenDisplay(name &u8) &C.Display
fn C.XConvertSelection(d &C.Display, selection Atom, target Atom, property Atom, requestor Window, time int) int
fn C.XSync(d &C.Display, discard int) int
fn C.XGetWindowProperty(d &C.Display, w Window, property Atom, offset i64, length i64, delete int, req_type Atom, actual_type_return &Atom, actual_format_return &int, nitems &u64, bytes_after_return &u64, prop_return &&byte) int
fn C.XGetWindowProperty(d &C.Display, w Window, property Atom, offset i64, length i64, delete int, req_type Atom, actual_type_return &Atom, actual_format_return &int, nitems &u64, bytes_after_return &u64, prop_return &&u8) int
fn C.XDeleteProperty(d &C.Display, w Window, property Atom) int
@ -154,7 +154,7 @@ struct Property {
actual_type Atom
actual_format int
nitems u64
data &byte
data &u8
}
// new_clipboard returns a new `Clipboard` instance allocated on the heap.

View File

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

View File

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

View File

@ -6,7 +6,7 @@ pub const rtld_lazy = 0
fn C.LoadLibrary(libfilename &u16) voidptr
fn C.GetProcAddress(handle voidptr, procname &byte) voidptr
fn C.GetProcAddress(handle voidptr, procname &u8) voidptr
fn C.FreeLibrary(handle voidptr) bool

View File

@ -24,7 +24,7 @@ fn init_alphabets() map[string]Alphabet {
// will be encoded to and a decode table.
struct Alphabet {
mut:
decode []i8 = []i8{len: 128, init: -1}
decode []i8 = []i8{len: 128, init: -1}
encode []u8 = []u8{len: 58}
}

View File

@ -4,7 +4,7 @@ module base64
// encode_in_buffer returns the size of the encoded data in the buffer.
// Please note: The buffer should be large enough (i.e. 4/3 of the data.len, or larger) to hold the encoded data.
// Please note: The function does NOT allocate new memory, and is suitable for handling very large strings.
pub fn encode_in_buffer(data []u8, buffer &byte) int {
pub fn encode_in_buffer(data []u8, buffer &u8) int {
return encode_from_buffer(buffer, data.data, data.len)
}
@ -126,8 +126,8 @@ fn decode_from_buffer(dest &u8, src &u8, src_len int) int {
for src_len - si >= 8 {
// Converting 8 bytes of input into 6 bytes of output. Storing these in the upper bytes of an u64.
datablock_64.data = assemble64(u8(index[d[si + 0]]), u8(index[d[si + 1]]),
u8(index[d[si + 2]]), u8(index[d[si + 3]]), u8(index[d[si + 4]]),
u8(index[d[si + 5]]), u8(index[d[si + 6]]), u8(index[d[si + 7]]))
u8(index[d[si + 2]]), u8(index[d[si + 3]]), u8(index[d[si + 4]]), u8(index[d[si + 5]]),
u8(index[d[si + 6]]), u8(index[d[si + 7]]))
// Reading out the individual bytes from the u64. Watch out with endianess.
$if little_endian {

View File

@ -54,13 +54,13 @@ pub fn url_encode_str(data string) string {
// assemble64 assembles 8 base64 digits into 6 bytes.
// Each digit comes from the decode map.
// Please note: Invalid base64 digits are not expected and not handled.
fn assemble64(n1 byte, n2 byte, n3 byte, n4 byte, n5 byte, n6 byte, n7 byte, n8 byte) u64 {
fn assemble64(n1 u8, n2 u8, n3 u8, n4 u8, n5 u8, n6 u8, n7 u8, n8 u8) u64 {
return u64(n1) << 58 | u64(n2) << 52 | u64(n3) << 46 | u64(n4) << 40 | u64(n5) << 34 | u64(n6) << 28 | u64(n7) << 22 | u64(n8) << 16
}
// assemble32 assembles 4 base64 digits into 3 bytes.
// Each digit comes from the decode map.
// Please note: Invalid base64 digits are not expected and not handled.
fn assemble32(n1 byte, n2 byte, n3 byte, n4 byte) u32 {
fn assemble32(n1 u8, n2 u8, n3 u8, n4 u8) u32 {
return u32(n1) << 26 | u32(n2) << 20 | u32(n3) << 14 | u32(n4) << 8
}

View File

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

View File

@ -10,7 +10,7 @@ mut:
sb strings.Builder
pub mut:
use_crlf bool
delimiter byte
delimiter u8
}
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
fn char2nibble(b byte) ?byte {
fn char2nibble(b u8) ?u8 {
match b {
`0`...`9` { return b - u8(`0`) }
`A`...`F` { return b - u8(`A`) + 10 }

View File

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

View File

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

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.
// `width` and `height` is assigned the size of the texture dimensions.
[inline]
pub fn (s &Context) get_texture_data(width &int, height &int) &byte {
pub fn (s &Context) get_texture_data(width &int, height &int) &u8 {
return &u8(C.fonsGetTextureData(s, width, height))
}

View File

@ -18,7 +18,7 @@ fn C.fonsResetAtlas(s &C.FONScontext, width int, height int) int
// Add fonts
fn C.fonsGetFontByName(s &C.FONScontext, name &char) int
fn C.fonsAddFallbackFont(s &C.FONScontext, base int, fallback int) int
fn C.fonsAddFontMem(s &C.FONScontext, name &char, data &byte, dataSize int, freeData int) int
fn C.fonsAddFontMem(s &C.FONScontext, name &char, data &u8, dataSize int, freeData int) int
// State handling
fn C.fonsPushState(s &C.FONScontext)

View File

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

View File

@ -128,7 +128,7 @@ pub mut:
ui_mode bool // do not redraw everything 60 times/second, but only when the user requests
frame u64 // the current frame counted from the start of the application; always increasing
//
mbtn_mask byte
mbtn_mask u8
mouse_buttons MouseButtons // typed version of mbtn_mask; easier to use for user programs
mouse_pos_x int
mouse_pos_y int

View File

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

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,
// that are updated dynamically by the CPU on each frame)
pub fn (mut ctx Context) update_pixel_data(cached_image_idx int, buf &byte) {
pub fn (mut ctx Context) update_pixel_data(cached_image_idx int, buf &u8) {
mut image := ctx.get_cached_image_by_idx(cached_image_idx)
image.update_pixel_data(buf)
}
// update_pixel_data updates the sokol specific pixel data associated
// with this `Image`.
pub fn (mut img Image) update_pixel_data(buf &byte) {
pub fn (mut img Image) update_pixel_data(buf &u8) {
mut data := gfx.ImageData{}
data.subimage[0][0].ptr = buf
data.subimage[0][0].size = usize(img.width * img.height * img.nr_channels)
@ -218,7 +218,7 @@ fn create_image(file string) Image {
// memory buffer `buf` of size `bufsize`.
//
// See also: create_image_from_byte_array
pub fn (mut ctx Context) create_image_from_memory(buf &byte, bufsize int) Image {
pub fn (mut ctx Context) create_image_from_memory(buf &u8, bufsize int) Image {
stb_img := stbi.load_from_memory(buf, bufsize) or { return Image{} }
mut img := Image{
width: stb_img.width

View File

@ -116,10 +116,10 @@ pub const (
// Color represents a 32 bit color value in sRGB format
pub struct Color {
pub mut:
r byte
g byte
b byte
a byte = 255
r u8
g u8
b u8
a u8 = 255
}
// hex takes in a 32 bit integer and splits it into 4 byte values
@ -132,7 +132,7 @@ pub fn hex(color int) Color {
}
}
pub fn rgb(r byte, g byte, b byte) Color {
pub fn rgb(r u8, g u8, b u8) Color {
return Color{
r: r
g: g
@ -140,7 +140,7 @@ pub fn rgb(r byte, g byte, b byte) Color {
}
}
pub fn rgba(r byte, g byte, b byte, a byte) Color {
pub fn rgba(r u8, g u8, b u8, a u8) Color {
return Color{
r: r
g: g

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

View File

@ -2,12 +2,12 @@ module hash
//#flag -I @VEXEROOT/thirdparty/wyhash
//#include "wyhash.h"
fn C.wyhash(&byte, u64, u64, &u64) u64
fn C.wyhash(&u8, u64, u64, &u64) u64
fn C.wyhash64(u64, u64) u64
[inline]
pub fn wyhash_c(key &byte, len u64, seed u64) u64 {
pub fn wyhash_c(key &u8, len u64, seed u64) u64 {
return C.wyhash(key, len, seed, &u64(C._wyp))
}

View File

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

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

View File

@ -10,15 +10,15 @@ struct C.MYSQL_RES {
[typedef]
struct C.MYSQL_FIELD {
name &byte // Name of column
org_name &byte // Original column name, if an alias
table &byte // Table of column if column was a field
org_table &byte // Org table name, if table was an alias
db &byte // Database for table
catalog &byte // Catalog for table
def &byte // Default value (set by mysql_list_fields)
length int // Width of column (create length)
max_length int // Max width for selected set
name &u8 // Name of column
org_name &u8 // Original column name, if an alias
table &u8 // Table of column if column was a field
org_table &u8 // Org table name, if table was an alias
db &u8 // Database for table
catalog &u8 // Catalog for table
def &u8 // Default value (set by mysql_list_fields)
length int // Width of column (create length)
max_length int // Max width for selected set
name_length u32
org_name_length u32
table_length u32
@ -36,13 +36,13 @@ fn C.mysql_init(mysql &C.MYSQL) &C.MYSQL
fn C.mysql_real_connect(mysql &C.MYSQL, host &char, user &char, passwd &char, db &char, port u32, unix_socket &char, client_flag ConnectionFlag) &C.MYSQL
fn C.mysql_query(mysql &C.MYSQL, q &byte) int
fn C.mysql_query(mysql &C.MYSQL, q &u8) int
fn C.mysql_real_query(mysql &C.MYSQL, q &byte, len u32) int
fn C.mysql_real_query(mysql &C.MYSQL, q &u8, len u32) int
fn C.mysql_select_db(mysql &C.MYSQL, db &byte) int
fn C.mysql_select_db(mysql &C.MYSQL, db &u8) int
fn C.mysql_change_user(mysql &C.MYSQL, user &byte, password &byte, db &byte) bool
fn C.mysql_change_user(mysql &C.MYSQL, user &u8, password &u8, db &u8) bool
fn C.mysql_affected_rows(mysql &C.MYSQL) u64
@ -50,7 +50,7 @@ fn C.mysql_options(mysql &C.MYSQL, option int, arg voidptr) int
fn C.mysql_get_option(mysql &C.MYSQL, option int, arg voidptr) int
fn C.mysql_list_tables(mysql &C.MYSQL, wild &byte) &C.MYSQL_RES
fn C.mysql_list_tables(mysql &C.MYSQL, wild &u8) &C.MYSQL_RES
fn C.mysql_num_fields(res &C.MYSQL_RES) int
@ -66,36 +66,36 @@ fn C.mysql_ping(mysql &C.MYSQL) int
fn C.mysql_store_result(mysql &C.MYSQL) &C.MYSQL_RES
fn C.mysql_fetch_row(res &C.MYSQL_RES) &&byte
fn C.mysql_fetch_row(res &C.MYSQL_RES) &&u8
fn C.mysql_fetch_fields(res &C.MYSQL_RES) &C.MYSQL_FIELD
fn C.mysql_free_result(res &C.MYSQL_RES)
fn C.mysql_real_escape_string(mysql &C.MYSQL, to &byte, from &byte, len u64) u64
fn C.mysql_real_escape_string(mysql &C.MYSQL, to &u8, from &u8, len u64) u64
// fn C.mysql_real_escape_string_quote(mysql &C.MYSQL, to &byte, from &byte, len u64, quote byte) u64 (Don't exist in mariadb)
fn C.mysql_close(sock &C.MYSQL)
// INFO & VERSION
fn C.mysql_info(mysql &C.MYSQL) &byte
fn C.mysql_info(mysql &C.MYSQL) &u8
fn C.mysql_get_host_info(mysql &C.MYSQL) &byte
fn C.mysql_get_host_info(mysql &C.MYSQL) &u8
fn C.mysql_get_server_info(mysql &C.MYSQL) &byte
fn C.mysql_get_server_info(mysql &C.MYSQL) &u8
fn C.mysql_get_server_version(mysql &C.MYSQL) u64
fn C.mysql_get_client_version() u64
fn C.mysql_get_client_info() &byte
fn C.mysql_get_client_info() &u8
// DEBUG & ERROR INFO
fn C.mysql_error(mysql &C.MYSQL) &byte
fn C.mysql_error(mysql &C.MYSQL) &u8
fn C.mysql_errno(mysql &C.MYSQL) int
fn C.mysql_dump_debug_info(mysql &C.MYSQL) int
fn C.mysql_debug(debug &byte)
fn C.mysql_debug(debug &u8)

View File

@ -3,7 +3,7 @@ module mysql
import orm
import time
type Prims = byte | f32 | f64 | i16 | i64 | i8 | int | string | u16 | u32 | u64
type Prims = f32 | f64 | i16 | i64 | i8 | int | string | u16 | u32 | u64 | u8
// sql expr

View File

@ -33,7 +33,7 @@ pub struct Field {
}
// fetch_row - fetches the next row from a result.
pub fn (r Result) fetch_row() &&byte {
pub fn (r Result) fetch_row() &&u8 {
return C.mysql_fetch_row(r.result)
}

View File

@ -153,7 +153,7 @@ pub fn (mut stmt Stmt) bind_bool(b &bool) {
stmt.bind(mysql.mysql_type_tiny, b, 0)
}
pub fn (mut stmt Stmt) bind_u8(b &byte) {
pub fn (mut stmt Stmt) bind_u8(b &u8) {
stmt.bind(mysql.mysql_type_tiny, b, 0)
}

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -630,7 +630,7 @@ struct HeaderKeyError {
Error
code int
header string
invalid_char byte
invalid_char u8
}
pub fn (err HeaderKeyError) msg() string {
@ -662,7 +662,7 @@ fn is_valid(header string) ? {
}
// is_token checks if the byte is valid for a header token
fn is_token(b byte) bool {
fn is_token(b u8) bool {
return match b {
33, 35...39, 42, 43, 45, 46, 48...57, 65...90, 94...122, 124, 126 { true }
else { false }

View File

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

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
for {
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() ?
}
pub fn (c TcpConn) read_ptr(buf_ptr &byte, len int) ?int {
pub fn (c TcpConn) read_ptr(buf_ptr &u8, len int) ?int {
mut res := wrap_read_result(C.recv(c.sock.handle, voidptr(buf_ptr), len, 0)) ?
$if trace_tcp ? {
eprintln('<<< TcpConn.read_ptr | c.sock.handle: $c.sock.handle | buf_ptr: ${ptr_str(buf_ptr)} len: $len | res: $res')
@ -96,7 +96,7 @@ pub fn (mut c TcpConn) read_deadline() ?time.Time {
}
// write_ptr blocks and attempts to write all data
pub fn (mut c TcpConn) write_ptr(b &byte, len int) ?int {
pub fn (mut c TcpConn) write_ptr(b &u8, len int) ?int {
$if trace_tcp ? {
eprintln(
'>>> TcpConn.write_ptr | c.sock.handle: $c.sock.handle | b: ${ptr_str(b)} len: $len |\n' +

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 }
return c.write_to_ptr(remote, b, len)
}
@ -71,7 +71,7 @@ pub fn (mut c UdpConn) write_string(s string) ?int {
return c.write_ptr(s.str, s.len)
}
pub fn (mut c UdpConn) write_to_ptr(addr Addr, b &byte, len int) ?int {
pub fn (mut c UdpConn) write_to_ptr(addr Addr, b &u8, len int) ?int {
res := C.sendto(c.sock.handle, b, len, 0, voidptr(&addr), addr.len())
if res >= 0 {
return res

View File

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

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
// reserved characters correctly. See golang.org/issue/5684.
fn should_escape(c byte, mode EncodingMode) bool {
fn should_escape(c u8, mode EncodingMode) bool {
// §2.3 Unreserved characters (alphanum)
if (`a` <= c && c <= `z`) || (`A` <= c && c <= `Z`) || (`0` <= c && c <= `9`) {
return false
@ -417,7 +417,7 @@ fn get_scheme(rawurl string) ?string {
// split slices s into two substrings separated by the first occurence of
// sep. If cutc is true then sep is included with the second substring.
// If sep does not occur in s then s and the empty string is returned.
fn split(s string, sep byte, cutc bool) (string, string) {
fn split(s string, sep u8, cutc bool) (string, string) {
i := s.index_u8(sep)
if i < 0 {
return s, ''
@ -1062,7 +1062,7 @@ fn string_contains_ctl_u8(s string) bool {
return false
}
pub fn ishex(c byte) bool {
pub fn ishex(c u8) bool {
if `0` <= c && c <= `9` {
return true
} else if `a` <= c && c <= `f` {
@ -1073,7 +1073,7 @@ pub fn ishex(c byte) bool {
return false
}
fn unhex(c byte) byte {
fn unhex(c u8) u8 {
if `0` <= c && c <= `9` {
return c - `0`
} else if `a` <= c && c <= `f` {

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
fn (mut ws Client) socket_read_ptr(buf_ptr &byte, len int) ?int {
fn (mut ws Client) socket_read_ptr(buf_ptr &u8, len int) ?int {
lock {
if ws.state in [.closed, .closing] || ws.conn.sock.handle <= 1 {
return error('socket_read_ptr: trying to read a closed socket')

View File

@ -60,7 +60,7 @@ pub enum State {
pub struct Message {
pub:
opcode OPCode // websocket frame type of this message
payload []u8 // payload of the message
payload []u8 // payload of the message
}
// OPCode represents the supported websocket frame types
@ -229,7 +229,7 @@ pub fn (mut ws Client) pong() ? {
}
// write_ptr writes len bytes provided a byteptr with a websocket messagetype
pub fn (mut ws Client) write_ptr(bytes &byte, payload_len int, code OPCode) ?int {
pub fn (mut ws Client) write_ptr(bytes &u8, payload_len int, code OPCode) ?int {
// ws.debug_log('write_ptr code: $code')
if ws.state != .open || ws.conn.sock.handle < 1 {
// todo: send error here later

View File

@ -22,7 +22,7 @@ pub fn fd_write(fd int, s string) {
return
}
remaining = remaining - written
sp = unsafe { voidptr(sp + written)}
sp = unsafe { voidptr(sp + written) }
}
}

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.
// 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)
}

View File

@ -286,7 +286,7 @@ fn test_read_raw() ? {
f.close()
f = os.open_file(tfile, 'r') ?
p := f.read_raw<Point>() ?
b := f.read_raw<byte>() ?
b := f.read_raw<u8>() ?
c := f.read_raw<Color>() ?
x := f.read_raw<Permissions>() ?
f.close()
@ -309,8 +309,8 @@ fn test_read_raw_at() ? {
mut at := u64(3)
p := f.read_raw_at<Point>(at) ?
at += sizeof(Point)
b := f.read_raw_at<byte>(at) ?
at += sizeof(byte)
b := f.read_raw_at<u8>(at) ?
at += sizeof(u8)
c := f.read_raw_at<Color>(at) ?
at += sizeof(Color)
x := f.read_raw_at<Permissions>(at) ?
@ -345,7 +345,7 @@ fn test_seek() ? {
//
f.seek(i64(sizeof(Point)), .start) ?
assert f.tell() ? == sizeof(Point)
b := f.read_raw<byte>() ?
b := f.read_raw<u8>() ?
assert b == another_byte
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)
fn ntdll_fn(name &byte) FN_NTSuspendResume {
fn ntdll_fn(name &u8) FN_NTSuspendResume {
ntdll := C.GetModuleHandleA(c'NTDLL')
if ntdll == 0 {
return FN_NTSuspendResume(0)

View File

@ -38,11 +38,11 @@ pub:
dbname string
}
fn C.PQconnectdb(a &byte) &C.PGconn
fn C.PQconnectdb(a &u8) &C.PGconn
fn C.PQerrorMessage(voidptr) &byte
fn C.PQerrorMessage(voidptr) &u8
fn C.PQgetvalue(&C.PGResult, int, int) &byte
fn C.PQgetvalue(&C.PGResult, int, int) &u8
fn C.PQstatus(voidptr) int
@ -52,20 +52,20 @@ fn C.PQntuples(&C.PGResult) int
fn C.PQnfields(&C.PGResult) int
fn C.PQexec(voidptr, &byte) &C.PGResult
fn C.PQexec(voidptr, &u8) &C.PGResult
// Params:
// const Oid *paramTypes
// const char *const *paramValues
// const int *paramLengths
// const int *paramFormats
fn C.PQexecParams(conn voidptr, command &byte, nParams int, paramTypes int, paramValues &byte, paramLengths int, paramFormats int, resultFormat int) &C.PGResult
fn C.PQexecParams(conn voidptr, command &u8, nParams int, paramTypes int, paramValues &u8, paramLengths int, paramFormats int, resultFormat int) &C.PGResult
fn C.PQputCopyData(conn voidptr, buffer &byte, nbytes int) int
fn C.PQputCopyData(conn voidptr, buffer &u8, nbytes int) int
fn C.PQputCopyEnd(voidptr, &byte) int
fn C.PQputCopyEnd(voidptr, &u8) int
fn C.PQgetCopyData(conn voidptr, buffer &&byte, async int) int
fn C.PQgetCopyData(conn voidptr, buffer &&u8, async int) int
fn C.PQclear(&C.PGResult) voidptr

View File

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

View File

@ -1,7 +1,7 @@
module picohttpparser
[inline; unsafe]
fn cpy(dst &byte, src &byte, len int) int {
fn cpy(dst &u8, src &u8, len int) int {
unsafe { C.memcpy(dst, src, len) }
return len
}

View File

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

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`.
[inline]
pub fn (mut rng MT19937RNG) u8() byte {
pub fn (mut rng MT19937RNG) u8() u8 {
if rng.bytes_left >= 1 {
rng.bytes_left -= 1
value := u8(rng.buffer)

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`.
[inline]
pub fn (mut rng MuslRNG) u8() byte {
pub fn (mut rng MuslRNG) u8() u8 {
if rng.bytes_left >= 1 {
rng.bytes_left -= 1
value := u8(rng.buffer)

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`.
[inline]
pub fn (mut rng PCG32RNG) u8() byte {
pub fn (mut rng PCG32RNG) u8() u8 {
if rng.bytes_left >= 1 {
rng.bytes_left -= 1
value := u8(rng.buffer)

View File

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

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`.
[inline]
pub fn (mut rng SplitMix64RNG) u8() byte {
pub fn (mut rng SplitMix64RNG) u8() u8 {
if rng.bytes_left >= 1 {
rng.bytes_left -= 1
value := u8(rng.buffer)

View File

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

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`.
[inline]
pub fn (mut rng WyRandRNG) u8() byte {
pub fn (mut rng WyRandRNG) u8() u8 {
// Can we extract a value from the buffer?
if rng.bytes_left >= 1 {
rng.bytes_left -= 1

View File

@ -22,7 +22,7 @@ mut:
c_oflag int
c_cflag int
c_lflag int
c_line byte
c_line u8
c_cc [cclen]int
}
@ -32,7 +32,7 @@ mut:
c_oflag u32
c_cflag u32
c_lflag u32
c_line byte
c_line u8
c_cc [cclen]int
}
@ -300,7 +300,7 @@ fn (r Readline) analyse_extended_control() Action {
// analyse_extended_control_no_eat returns an `Action` based on the type of input byte given in `c`.
// analyse_extended_control_no_eat specialises in detection of delete and insert keys.
fn (r Readline) analyse_extended_control_no_eat(last_c byte) Action {
fn (r Readline) analyse_extended_control_no_eat(last_c u8) Action {
c := r.read_char()
match u8(c) {
`~` {

View File

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

View File

@ -527,9 +527,9 @@ struct C.sg_stencil_state {
enabled bool
front StencilFaceState
back StencilFaceState
read_mask byte
write_mask byte
ref byte
read_mask u8
write_mask u8
ref u8
}
pub type StencilState = C.sg_stencil_state
@ -594,7 +594,7 @@ pub type DepthAttachmentAction = C.sg_depth_attachment_action
struct C.sg_stencil_attachment_action {
pub mut:
action Action
value byte
value u8
}
pub type StencilAttachmentAction = C.sg_stencil_attachment_action

View File

@ -37,7 +37,7 @@ pub:
frame_cb fn ()
cleanup_cb fn ()
event_cb fn (&Event) //&sapp_event)
fail_cb fn (&byte)
fail_cb fn (&u8)
user_data voidptr // these are the user-provided callbacks with user data
init_userdata_cb fn (voidptr)

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.
fn write_rgba_to_ppm(path string, w int, h int, components int, pixels &byte) ? {
fn write_rgba_to_ppm(path string, w int, h int, components int, pixels &u8) ? {
mut f_out := os.create(path) ?
defer {
f_out.close()

View File

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

View File

@ -17,7 +17,7 @@ pub fn destroy(ctx &fontstash.Context) {
}
[inline]
pub fn rgba(r byte, g byte, b byte, a byte) u32 {
pub fn rgba(r u8, g u8, b u8, a u8) u32 {
return C.sfons_rgba(r, g, b, a)
}

View File

@ -4,5 +4,5 @@ import fontstash
fn C.sfons_create(width int, height int, flags int) &fontstash.Context
fn C.sfons_destroy(ctx &fontstash.Context)
fn C.sfons_rgba(r byte, g byte, b byte, a byte) u32
fn C.sfons_rgba(r u8, g u8, b u8, a u8) u32
fn C.sfons_flush(ctx &fontstash.Context)

View File

@ -240,12 +240,12 @@ pub fn c4f(r f32, g f32, b f32, a f32) {
}
[inline]
pub fn c3b(r byte, g byte, b byte) {
pub fn c3b(r u8, g u8, b u8) {
C.sgl_c3b(r, g, b)
}
[inline]
pub fn c4b(r byte, g byte, b byte, a byte) {
pub fn c4b(r u8, g u8, b u8, a u8) {
C.sgl_c4b(r, g, b, a)
}
@ -316,7 +316,7 @@ pub fn v2f_c3f(x f32, y f32, r f32, g f32, b f32) {
}
[inline]
pub fn v2f_c3b(x f32, y f32, r byte, g byte, b byte) {
pub fn v2f_c3b(x f32, y f32, r u8, g u8, b u8) {
C.sgl_v2f_c3b(x, y, r, g, b)
}
@ -326,7 +326,7 @@ pub fn v2f_c4f(x f32, y f32, r f32, g f32, b f32, a f32) {
}
[inline]
pub fn v2f_c4b(x f32, y f32, r byte, g byte, b byte, a byte) {
pub fn v2f_c4b(x f32, y f32, r u8, g u8, b u8, a u8) {
C.sgl_v2f_c4b(x, y, r, g, b, a)
}
@ -341,7 +341,7 @@ pub fn v3f_c3f(x f32, y f32, z f32, r f32, g f32, b f32) {
}
[inline]
pub fn v3f_c3b(x f32, y f32, z f32, r byte, g byte, b byte) {
pub fn v3f_c3b(x f32, y f32, z f32, r u8, g u8, b u8) {
C.sgl_v3f_c3b(x, y, z, r, g, b)
}
@ -351,7 +351,7 @@ pub fn v3f_c4f(x f32, y f32, z f32, r f32, g f32, b f32, a f32) {
}
[inline]
pub fn v3f_c4b(x f32, y f32, z f32, r byte, g byte, b byte, a byte) {
pub fn v3f_c4b(x f32, y f32, z f32, r u8, g u8, b u8, a u8) {
C.sgl_v3f_c4b(x, y, z, r, g, b, a)
}
@ -366,7 +366,7 @@ pub fn v2f_t2f_c3f(x f32, y f32, u f32, v f32, r f32, g f32, b f32) {
}
[inline]
pub fn v2f_t2f_c3b(x f32, y f32, u f32, v f32, r byte, g byte, b byte) {
pub fn v2f_t2f_c3b(x f32, y f32, u f32, v f32, r u8, g u8, b u8) {
C.sgl_v2f_t2f_c3b(x, y, u, v, r, g, b)
}
@ -376,7 +376,7 @@ pub fn v2f_t2f_c4f(x f32, y f32, u f32, v f32, r f32, g f32, b f32, a f32) {
}
[inline]
pub fn v2f_t2f_c4b(x f32, y f32, u f32, v f32, r byte, g byte, b byte, a byte) {
pub fn v2f_t2f_c4b(x f32, y f32, u f32, v f32, r u8, g u8, b u8, a u8) {
C.sgl_v2f_t2f_c4b(x, y, u, v, r, g, b, a)
}
@ -391,7 +391,7 @@ pub fn v3f_t2f_c3f(x f32, y f32, z f32, u f32, v f32, r f32, g f32, b f32) {
}
[inline]
pub fn v3f_t2f_c3b(x f32, y f32, z f32, u f32, v f32, r byte, g byte, b byte) {
pub fn v3f_t2f_c3b(x f32, y f32, z f32, u f32, v f32, r u8, g u8, b u8) {
C.sgl_v3f_t2f_c3b(x, y, z, u, v, r, g, b)
}
@ -401,7 +401,7 @@ pub fn v3f_t2f_c4f(x f32, y f32, z f32, u f32, v f32, r f32, g f32, b f32, a f32
}
[inline]
pub fn v3f_t2f_c4b(x f32, y f32, z f32, u f32, v f32, r byte, g byte, b byte, a byte) {
pub fn v3f_t2f_c4b(x f32, y f32, z f32, u f32, v f32, r u8, g u8, b u8, a u8) {
C.sgl_v3f_t2f_c4b(x, y, z, u, v, r, g, b, a)
}

View File

@ -59,8 +59,8 @@ fn C.sgl_pop_matrix()
fn C.sgl_t2f(u f32, v f32)
fn C.sgl_c3f(r f32, g f32, b f32)
fn C.sgl_c4f(r f32, g f32, b f32, a f32)
fn C.sgl_c3b(r byte, g byte, b byte)
fn C.sgl_c4b(r byte, g byte, b byte, a byte)
fn C.sgl_c3b(r u8, g u8, b u8)
fn C.sgl_c4b(r u8, g u8, b u8, a u8)
fn C.sgl_c1i(rgba u32)
fn C.sgl_point_size(s f32)
@ -76,24 +76,24 @@ fn C.sgl_v3f(x f32, y f32, z f32)
fn C.sgl_v2f_t2f(x f32, y f32, u f32, v f32)
fn C.sgl_v3f_t2f(x f32, y f32, z f32, u f32, v f32)
fn C.sgl_v2f_c3f(x f32, y f32, r f32, g f32, b f32)
fn C.sgl_v2f_c3b(x f32, y f32, r byte, g byte, b byte)
fn C.sgl_v2f_c3b(x f32, y f32, r u8, g u8, b u8)
fn C.sgl_v2f_c4f(x f32, y f32, r f32, g f32, b f32, a f32)
fn C.sgl_v2f_c4b(x f32, y f32, r byte, g byte, b byte, a byte)
fn C.sgl_v2f_c4b(x f32, y f32, r u8, g u8, b u8, a u8)
fn C.sgl_v2f_c1i(x f32, y f32, rgba u32)
fn C.sgl_v3f_c3f(x f32, y f32, z f32, r f32, g f32, b f32)
fn C.sgl_v3f_c3b(x f32, y f32, z f32, r byte, g byte, b byte)
fn C.sgl_v3f_c3b(x f32, y f32, z f32, r u8, g u8, b u8)
fn C.sgl_v3f_c4f(x f32, y f32, z f32, r f32, g f32, b f32, a f32)
fn C.sgl_v3f_c4b(x f32, y f32, z f32, r byte, g byte, b byte, a byte)
fn C.sgl_v3f_c4b(x f32, y f32, z f32, r u8, g u8, b u8, a u8)
fn C.sgl_v3f_c1i(x f32, y f32, z f32, rgba u32)
fn C.sgl_v2f_t2f_c3f(x f32, y f32, u f32, v f32, r f32, g f32, b f32)
fn C.sgl_v2f_t2f_c3b(x f32, y f32, u f32, v f32, r byte, g byte, b byte)
fn C.sgl_v2f_t2f_c3b(x f32, y f32, u f32, v f32, r u8, g u8, b u8)
fn C.sgl_v2f_t2f_c4f(x f32, y f32, u f32, v f32, r f32, g f32, b f32, a f32)
fn C.sgl_v2f_t2f_c4b(x f32, y f32, u f32, v f32, r byte, g byte, b byte, a byte)
fn C.sgl_v2f_t2f_c4b(x f32, y f32, u f32, v f32, r u8, g u8, b u8, a u8)
fn C.sgl_v2f_t2f_c1i(x f32, y f32, u f32, v f32, rgba u32)
fn C.sgl_v3f_t2f_c3f(x f32, y f32, z f32, u f32, v f32, r f32, g f32, b f32)
fn C.sgl_v3f_t2f_c3b(x f32, y f32, z f32, u f32, v f32, r byte, g byte, b byte)
fn C.sgl_v3f_t2f_c3b(x f32, y f32, z f32, u f32, v f32, r u8, g u8, b u8)
fn C.sgl_v3f_t2f_c4f(x f32, y f32, z f32, u f32, v f32, r f32, g f32, b f32, a f32)
fn C.sgl_v3f_t2f_c4b(x f32, y f32, z f32, u f32, v f32, r byte, g byte, b byte, a byte)
fn C.sgl_v3f_t2f_c4b(x f32, y f32, z f32, u f32, v f32, r u8, g u8, b u8, a u8)
fn C.sgl_v3f_t2f_c1i(x f32, y f32, z f32, u f32, v f32, rgba u32)
fn C.sgl_end()

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_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

View File

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

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
fn is_digit(x byte) bool {
fn is_digit(x u8) bool {
return (x >= strconv.c_zero && x <= strconv.c_nine) == true
}
fn is_space(x byte) bool {
fn is_space(x u8) bool {
return x == `\t` || x == `\n` || x == `\v` || x == `\f` || x == `\r` || x == ` `
}
fn is_exp(x byte) bool {
fn is_exp(x u8) bool {
return (x == `E` || x == `e`) == true
}

View File

@ -12,7 +12,7 @@ const (
max_u64 = u64(18446744073709551615) // as u64 // use this until we add support
)
pub fn byte_to_lower(c byte) byte {
pub fn byte_to_lower(c u8) u8 {
return c | (`x` - `X`)
}

View File

@ -80,7 +80,7 @@ Single format functions
*/
pub struct BF_param {
pub mut:
pad_ch byte = u8(` `) // padding char
pad_ch u8 = u8(` `) // padding char
len0 int = -1 // default len for whole the number or string
len1 int = 6 // number of decimal digits, if needed
positive bool = true // mandatory: the sign of the number passed

View File

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

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
[unsafe]
pub fn (mut b Builder) write_ptr(ptr &byte, len int) {
pub fn (mut b Builder) write_ptr(ptr &u8, len int) {
if len == 0 {
return
}
@ -51,12 +51,12 @@ pub fn (mut b Builder) write_runes(runes []rune) {
// write_b appends a single `data` byte to the accumulated buffer
[deprecated: 'Use write_u8() instead']
[deprecated_after: '2022-02-11']
pub fn (mut b Builder) write_b(data byte) {
pub fn (mut b Builder) write_b(data u8) {
b << data
}
// write_byte appends a single `data` byte to the accumulated buffer
pub fn (mut b Builder) write_u8(data byte) {
pub fn (mut b Builder) write_u8(data u8) {
b << data
}
@ -81,7 +81,7 @@ pub fn (mut b Builder) drain_builder(mut other Builder, other_new_cap int) {
// byte_at returns a byte, located at a given index `i`.
// Note: it can panic, if there are not enough bytes in the strings builder yet.
[inline]
pub fn (b &Builder) byte_at(n int) byte {
pub fn (b &Builder) byte_at(n int) u8 {
return unsafe { (&[]u8(b))[n] }
}

View File

@ -1,7 +1,7 @@
module strings
// strings.repeat - fill a string with `n` repetitions of the character `c`
pub fn repeat(c byte, n int) string {
pub fn repeat(c u8, n int) string {
if n <= 0 {
return ''
}

View File

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

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