Skip to content

Commit

Permalink
all: byte => u8
Browse files Browse the repository at this point in the history
  • Loading branch information
medvednikov committed Apr 15, 2022
1 parent b49d873 commit d4a0d6f
Show file tree
Hide file tree
Showing 221 changed files with 1,365 additions and 1,365 deletions.
4 changes: 2 additions & 2 deletions cmd/tools/bench/wyhash.v
Expand Up @@ -16,7 +16,7 @@ fn main() {
mut bgenerating := benchmark.start()
mut bytepile := []byte{}
for _ in 0 .. sample_size * max_str_len {
bytepile << byte(rand.int_in_range(40, 125) or { 40 })
bytepile << u8(rand.int_in_range(40, 125) or { 40 })
}
mut str_lens := []int{}
for _ in 0 .. sample_size {
Expand All @@ -30,7 +30,7 @@ fn main() {
checksum = 0
for len in str_lens {
end_pos := start_pos + len
checksum ^= wyhash.wyhash_c(unsafe { &byte(bytepile.data) + start_pos }, u64(len),
checksum ^= wyhash.wyhash_c(unsafe { &u8(bytepile.data) + start_pos }, u64(len),
1)
start_pos = end_pos
}
Expand Down
6 changes: 3 additions & 3 deletions cmd/tools/vast/vast.v
Expand Up @@ -283,7 +283,7 @@ fn (t Tree) embed_file(node ast.EmbeddedFile) &Node {
obj.add('compression_type', t.string_node(node.compression_type))
obj.add('is_compressed', t.bool_node(node.is_compressed))
obj.add('len', t.number_node(node.len))
obj.add('bytes', t.array_node_byte(node.bytes))
obj.add('bytes', t.array_node_u8(node.bytes))
return obj
}

Expand Down Expand Up @@ -1216,7 +1216,7 @@ fn (t Tree) string_inter_literal(node ast.StringInterLiteral) &Node {
obj.add_terse('pluss', t.array_node_bool(node.pluss))
obj.add_terse('fills', t.array_node_bool(node.fills))
obj.add_terse('fmt_poss', t.array_node_position(node.fmt_poss))
obj.add_terse('fmts', t.array_node_byte(node.fmts))
obj.add_terse('fmts', t.array_node_u8(node.fmts))
obj.add_terse('need_fmts', t.array_node_bool(node.need_fmts))
obj.add('pos', t.pos(node.pos))
return obj
Expand Down Expand Up @@ -2209,7 +2209,7 @@ fn (t Tree) array_node_int(nodes []int) &Node {
return arr
}

fn (t Tree) array_node_byte(nodes []byte) &Node {
fn (t Tree) array_node_u8(nodes []byte) &Node {
mut arr := new_array()
for node in nodes {
arr.add_item(t.number_node(node))
Expand Down
2 changes: 1 addition & 1 deletion cmd/tools/vbin2v.v
Expand Up @@ -51,7 +51,7 @@ fn (context Context) file2v(bname string, fbytes []byte, bn_max int) string {
bn_diff_len := bn_max - bname.len
sb.write_string('\t${bname}_len' + ' '.repeat(bn_diff_len - 4) + ' = $fbytes.len\n')
fbyte := fbytes[0]
bnmae_line := '\t$bname' + ' '.repeat(bn_diff_len) + ' = [byte($fbyte), '
bnmae_line := '\t$bname' + ' '.repeat(bn_diff_len) + ' = [u8($fbyte), '
sb.write_string(bnmae_line)
mut line_len := bnmae_line.len + 3
for i := 1; i < fbytes.len; i++ {
Expand Down
2 changes: 1 addition & 1 deletion cmd/tools/vdoc/html.v
Expand Up @@ -370,7 +370,7 @@ fn html_highlight(code string, tb &ast.Table) string {
break
}
} else {
buf.write_byte(code[i])
buf.write_u8(code[i])
i++
}
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/tools/vdoc/utils.v
Expand Up @@ -271,7 +271,7 @@ fn color_highlight(code string, tb &ast.Table) string {
tok = next_tok
next_tok = s.scan()
} else {
buf.write_byte(code[i])
buf.write_u8(code[i])
i++
}
}
Expand Down
4 changes: 2 additions & 2 deletions cmd/tools/vdoc/vdoc.v
Expand Up @@ -132,9 +132,9 @@ fn (vd VDoc) write_plaintext_content(contents []doc.DocNode, mut pw strings.Buil
for ex in examples {
pw.write_string(' Example: ')
mut fex := ex
if ex.index_byte(`\n`) >= 0 {
if ex.index_u8(`\n`) >= 0 {
// multi-line example
pw.write_byte(`\n`)
pw.write_u8(`\n`)
fex = indent(ex)
}
if cfg.is_color {
Expand Down
2 changes: 1 addition & 1 deletion examples/fireworks/fireworks.v
Expand Up @@ -25,7 +25,7 @@ fn on_frame(mut app App) {
for mut frame in app.frames {
for mut rocket in frame {
if !rocket.exploded {
rocket.color.a = byte(f32_max(rocket.color.a - 8, 0))
rocket.color.a = u8(f32_max(rocket.color.a - 8, 0))
rocket.draw(mut app.gg)
}
}
Expand Down
6 changes: 3 additions & 3 deletions examples/fireworks/modules/objects/color.v
Expand Up @@ -5,8 +5,8 @@ import rand

pub fn random_color() gx.Color {
return gx.Color{
r: rand.byte()
g: rand.byte()
b: rand.byte()
r: rand.u8()
g: rand.u8()
b: rand.u8()
}
}
2 changes: 1 addition & 1 deletion examples/fireworks/modules/objects/particle.v
Expand Up @@ -19,7 +19,7 @@ pub fn (particle Particle) draw(mut ctx gg.Context) {

pub fn (mut particle Particle) tick(mut rocket Rocket, mut ctx gg.Context) {
particle.lifespan -= get_params().age_rate
particle.color.a = byte(particle.lifespan)
particle.color.a = u8(particle.lifespan)

if particle.lifespan <= 0 {
rocket.dead = true
Expand Down
26 changes: 13 additions & 13 deletions examples/sokol/01_cubes/cube.v
Expand Up @@ -50,7 +50,7 @@ fn create_texture(w int, h int, buf &u8) gfx.Image {
// usage: .dynamic
wrap_u: .clamp_to_edge
wrap_v: .clamp_to_edge
label: &byte(0)
label: &u8(0)
d3d11_texture: 0
}
// commen if .dynamic is enabled
Expand Down Expand Up @@ -352,23 +352,23 @@ fn my_init(mut app App) {
x := (i & 0xFF) >> 5 // 8 cell
// upper left corner
if x == 0 && y == 0 {
tmp_txt[i] = byte(0xFF)
tmp_txt[i + 1] = byte(0)
tmp_txt[i + 2] = byte(0)
tmp_txt[i + 3] = byte(0xFF)
tmp_txt[i] = u8(0xFF)
tmp_txt[i + 1] = u8(0)
tmp_txt[i + 2] = u8(0)
tmp_txt[i + 3] = u8(0xFF)
}
// low right corner
else if x == 7 && y == 7 {
tmp_txt[i] = byte(0)
tmp_txt[i + 1] = byte(0xFF)
tmp_txt[i + 2] = byte(0)
tmp_txt[i + 3] = byte(0xFF)
tmp_txt[i] = u8(0)
tmp_txt[i + 1] = u8(0xFF)
tmp_txt[i + 2] = u8(0)
tmp_txt[i + 3] = u8(0xFF)
} else {
col := if ((x + y) & 1) == 1 { 0xFF } else { 0 }
tmp_txt[i] = byte(col) // red
tmp_txt[i + 1] = byte(col) // green
tmp_txt[i + 2] = byte(col) // blue
tmp_txt[i + 3] = byte(0xFF) // alpha
tmp_txt[i] = u8(col) // red
tmp_txt[i + 1] = u8(col) // green
tmp_txt[i + 2] = u8(col) // blue
tmp_txt[i + 3] = u8(0xFF) // alpha
}
i += 4
}
Expand Down
26 changes: 13 additions & 13 deletions examples/sokol/02_cubes_glsl/cube_glsl.v
Expand Up @@ -66,7 +66,7 @@ fn create_texture(w int, h int, buf &byte) gfx.Image {
// usage: .dynamic
wrap_u: .clamp_to_edge
wrap_v: .clamp_to_edge
label: &byte(0)
label: &u8(0)
d3d11_texture: 0
}
// comment if .dynamic is enabled
Expand Down Expand Up @@ -524,23 +524,23 @@ fn my_init(mut app App) {
x := (i & 0xFF) >> 5 // 8 cell
// upper left corner
if x == 0 && y == 0 {
tmp_txt[i] = byte(0xFF)
tmp_txt[i + 1] = byte(0)
tmp_txt[i + 2] = byte(0)
tmp_txt[i + 3] = byte(0xFF)
tmp_txt[i] = u8(0xFF)
tmp_txt[i + 1] = u8(0)
tmp_txt[i + 2] = u8(0)
tmp_txt[i + 3] = u8(0xFF)
}
// low right corner
else if x == 7 && y == 7 {
tmp_txt[i + 0] = byte(0)
tmp_txt[i + 1] = byte(0xFF)
tmp_txt[i + 2] = byte(0)
tmp_txt[i + 3] = byte(0xFF)
tmp_txt[i + 0] = u8(0)
tmp_txt[i + 1] = u8(0xFF)
tmp_txt[i + 2] = u8(0)
tmp_txt[i + 3] = u8(0xFF)
} else {
col := if ((x + y) & 1) == 1 { 0xFF } else { 128 }
tmp_txt[i + 0] = byte(col) // red
tmp_txt[i + 1] = byte(col) // green
tmp_txt[i + 2] = byte(col) // blue
tmp_txt[i + 3] = byte(0xFF) // alpha
tmp_txt[i + 0] = u8(col) // red
tmp_txt[i + 1] = u8(col) // green
tmp_txt[i + 2] = u8(col) // blue
tmp_txt[i + 3] = u8(0xFF) // alpha
}
i += 4
}
Expand Down
26 changes: 13 additions & 13 deletions examples/sokol/03_march_tracing_glsl/rt_glsl.v
Expand Up @@ -65,7 +65,7 @@ fn create_texture(w int, h int, buf &byte) gfx.Image {
// usage: .dynamic
wrap_u: .clamp_to_edge
wrap_v: .clamp_to_edge
label: &byte(0)
label: &u8(0)
d3d11_texture: 0
}
// comment if .dynamic is enabled
Expand Down Expand Up @@ -342,23 +342,23 @@ fn my_init(mut app App) {
x := (i & 0xFF) >> 5 // 8 cell
// upper left corner
if x == 0 && y == 0 {
tmp_txt[i + 0] = byte(0xFF)
tmp_txt[i + 1] = byte(0)
tmp_txt[i + 2] = byte(0)
tmp_txt[i + 3] = byte(0xFF)
tmp_txt[i + 0] = u8(0xFF)
tmp_txt[i + 1] = u8(0)
tmp_txt[i + 2] = u8(0)
tmp_txt[i + 3] = u8(0xFF)
}
// low right corner
else if x == 7 && y == 7 {
tmp_txt[i + 0] = byte(0)
tmp_txt[i + 1] = byte(0xFF)
tmp_txt[i + 2] = byte(0)
tmp_txt[i + 3] = byte(0xFF)
tmp_txt[i + 0] = u8(0)
tmp_txt[i + 1] = u8(0xFF)
tmp_txt[i + 2] = u8(0)
tmp_txt[i + 3] = u8(0xFF)
} else {
col := if ((x + y) & 1) == 1 { 0xFF } else { 128 }
tmp_txt[i + 0] = byte(col) // red
tmp_txt[i + 1] = byte(col) // green
tmp_txt[i + 2] = byte(col) // blue
tmp_txt[i + 3] = byte(0xFF) // alpha
tmp_txt[i + 0] = u8(col) // red
tmp_txt[i + 1] = u8(col) // green
tmp_txt[i + 2] = u8(col) // blue
tmp_txt[i + 3] = u8(0xFF) // alpha
}
i += 4
}
Expand Down
26 changes: 13 additions & 13 deletions examples/sokol/04_multi_shader_glsl/rt_glsl.v
Expand Up @@ -67,7 +67,7 @@ fn create_texture(w int, h int, buf byteptr) gfx.Image {
// usage: .dynamic
wrap_u: .clamp_to_edge
wrap_v: .clamp_to_edge
label: &byte(0)
label: &u8(0)
d3d11_texture: 0
}
// comment if .dynamic is enabled
Expand Down Expand Up @@ -530,23 +530,23 @@ fn my_init(mut app App) {
x := (i & 0xFF) >> 5 // 8 cell
// upper left corner
if x == 0 && y == 0 {
tmp_txt[i + 0] = byte(0xFF)
tmp_txt[i + 1] = byte(0)
tmp_txt[i + 2] = byte(0)
tmp_txt[i + 3] = byte(0xFF)
tmp_txt[i + 0] = u8(0xFF)
tmp_txt[i + 1] = u8(0)
tmp_txt[i + 2] = u8(0)
tmp_txt[i + 3] = u8(0xFF)
}
// low right corner
else if x == 7 && y == 7 {
tmp_txt[i + 0] = byte(0)
tmp_txt[i + 1] = byte(0xFF)
tmp_txt[i + 2] = byte(0)
tmp_txt[i + 3] = byte(0xFF)
tmp_txt[i + 0] = u8(0)
tmp_txt[i + 1] = u8(0xFF)
tmp_txt[i + 2] = u8(0)
tmp_txt[i + 3] = u8(0xFF)
} else {
col := if ((x + y) & 1) == 1 { 0xFF } else { 128 }
tmp_txt[i + 0] = byte(col) // red
tmp_txt[i + 1] = byte(col) // green
tmp_txt[i + 2] = byte(col) // blue
tmp_txt[i + 3] = byte(0xFF) // alpha
tmp_txt[i + 0] = u8(col) // red
tmp_txt[i + 1] = u8(col) // green
tmp_txt[i + 2] = u8(col) // blue
tmp_txt[i + 3] = u8(0xFF) // alpha
}
i += 4
}
Expand Down
26 changes: 13 additions & 13 deletions examples/sokol/05_instancing_glsl/rt_glsl.v
Expand Up @@ -80,7 +80,7 @@ fn create_texture(w int, h int, buf byteptr) gfx.Image{
//usage: .dynamic
wrap_u: .clamp_to_edge
wrap_v: .clamp_to_edge
label: &byte(0)
label: &u8(0)
d3d11_texture: 0
}
// comment if .dynamic is enabled
Expand Down Expand Up @@ -406,23 +406,23 @@ fn my_init(mut app App) {
x := (i & 0xFF) >> 5 // 8 cell
// upper left corner
if x == 0 && y == 0 {
tmp_txt[i + 0] = byte(0xFF)
tmp_txt[i + 1] = byte(0)
tmp_txt[i + 2] = byte(0)
tmp_txt[i + 3] = byte(0xFF)
tmp_txt[i + 0] = u8(0xFF)
tmp_txt[i + 1] = u8(0)
tmp_txt[i + 2] = u8(0)
tmp_txt[i + 3] = u8(0xFF)
}
// low right corner
else if x == 7 && y == 7 {
tmp_txt[i + 0] = byte(0)
tmp_txt[i + 1] = byte(0xFF)
tmp_txt[i + 2] = byte(0)
tmp_txt[i + 3] = byte(0xFF)
tmp_txt[i + 0] = u8(0)
tmp_txt[i + 1] = u8(0xFF)
tmp_txt[i + 2] = u8(0)
tmp_txt[i + 3] = u8(0xFF)
} else {
col := if ((x + y) & 1) == 1 { 0xFF } else { 128 }
tmp_txt[i + 0] = byte(col) // red
tmp_txt[i + 1] = byte(col) // green
tmp_txt[i + 2] = byte(col) // blue
tmp_txt[i + 3] = byte(0xFF) // alpha
tmp_txt[i + 0] = u8(col) // red
tmp_txt[i + 1] = u8(col) // green
tmp_txt[i + 2] = u8(col) // blue
tmp_txt[i + 3] = u8(0xFF) // alpha
}
i += 4
}
Expand Down
2 changes: 1 addition & 1 deletion examples/sokol/06_obj_viewer/modules/obj/rend.v
Expand Up @@ -29,7 +29,7 @@ pub fn create_texture(w int, h int, buf &byte) gfx.Image {
// usage: .dynamic
wrap_u: .clamp_to_edge
wrap_v: .clamp_to_edge
label: &byte(0)
label: &u8(0)
d3d11_texture: 0
}
// comment if .dynamic is enabled
Expand Down
8 changes: 4 additions & 4 deletions examples/sokol/06_obj_viewer/show_obj.v
Expand Up @@ -220,10 +220,10 @@ fn my_init(mut app App) {
// 1x1 pixel white, default texture
unsafe {
tmp_txt := malloc(4)
tmp_txt[0] = byte(0xFF)
tmp_txt[1] = byte(0xFF)
tmp_txt[2] = byte(0xFF)
tmp_txt[3] = byte(0xFF)
tmp_txt[0] = u8(0xFF)
tmp_txt[1] = u8(0xFF)
tmp_txt[2] = u8(0xFF)
tmp_txt[3] = u8(0xFF)
app.texture = obj.create_texture(1, 1, tmp_txt)
free(tmp_txt)
}
Expand Down
8 changes: 4 additions & 4 deletions examples/sokol/particles/modules/particle/particle.v
Expand Up @@ -46,10 +46,10 @@ pub fn (mut p Particle) update(dt f64) {
lt := p.life_time - (1000 * dt)
if lt > 0 {
p.life_time = lt
p.color.r = p.color.r - 1 // byte(remap(p.life_time,0.0,p.life_time_init,0,p.color.r))
p.color.g = p.color.g - 1 // byte(remap(p.life_time,0.0,p.life_time_init,0,p.color.g))
p.color.b = p.color.b - 1 // byte(remap(p.life_time,0.0,p.life_time_init,0,p.color.b))
p.color.a = byte(int(remap(p.life_time, 0.0, p.life_time_init, 0, 255))) - 10
p.color.r = p.color.r - 1 // u8(remap(p.life_time,0.0,p.life_time_init,0,p.color.r))
p.color.g = p.color.g - 1 // u8(remap(p.life_time,0.0,p.life_time_init,0,p.color.g))
p.color.b = p.color.b - 1 // u8(remap(p.life_time,0.0,p.life_time_init,0,p.color.b))
p.color.a = u8(int(remap(p.life_time, 0.0, p.life_time_init, 0, 255))) - 10
} else {
p.life_time = 0
}
Expand Down
4 changes: 2 additions & 2 deletions examples/sokol/sounds/melody.v
Expand Up @@ -22,7 +22,7 @@ fn my_audio_stream_callback(buffer &f32, num_frames int, num_channels int, mut a
for ch := 0; ch < num_channels; ch++ {
idx := frame * num_channels + ch
unsafe {
a := f32(byte(y) - 127) / 255.0
a := f32(u8(y) - 127) / 255.0
soundbuffer[idx] = a
acontext.frames[idx & 2047] = a
}
Expand Down Expand Up @@ -62,7 +62,7 @@ fn graphics_frame(mut state AppState) {

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

fn (mut state AppState) draw() {
Expand Down

0 comments on commit d4a0d6f

Please sign in to comment.