From 4da9c52b91d7069e80d15b53b7dacac6651aa097 Mon Sep 17 00:00:00 2001 From: Delyan Angelov Date: Fri, 15 Apr 2022 20:31:10 +0300 Subject: [PATCH] ci: fix `v build-examples` --- vlib/builtin/js/builtin.v | 2 +- vlib/builtin/js/int.js.v | 4 ++-- vlib/builtin/js/string.js.v | 6 +++--- vlib/builtin/js/utf8.js.v | 2 +- vlib/mysql/orm.v | 2 +- vlib/v/gen/js/auto_str_methods.v | 2 +- vlib/v/gen/js/builtin_types.v | 13 ++++++------- vlib/v/gen/js/js.v | 2 +- 8 files changed, 16 insertions(+), 17 deletions(-) diff --git a/vlib/builtin/js/builtin.v b/vlib/builtin/js/builtin.v index 883bf3919a..b491f30ae2 100644 --- a/vlib/builtin/js/builtin.v +++ b/vlib/builtin/js/builtin.v @@ -84,7 +84,7 @@ fn (_ None__) str() string { } pub struct Option { - state byte + state u8 err IError = none__ } diff --git a/vlib/builtin/js/int.js.v b/vlib/builtin/js/int.js.v index 0874643b7d..a21c7b2133 100644 --- a/vlib/builtin/js/int.js.v +++ b/vlib/builtin/js/int.js.v @@ -133,7 +133,7 @@ pub fn (x int_literal) hex() string { return res } -pub fn (x byte) hex() string { +pub fn (x u8) hex() string { res := '' #res.str = x.val.toString(16) @@ -172,7 +172,7 @@ pub fn (i i64) hex2() string { return '0x' + i.hex() } -pub fn (i byte) hex2() string { +pub fn (i u8) hex2() string { return '0x' + i.hex() } diff --git a/vlib/builtin/js/string.js.v b/vlib/builtin/js/string.js.v index ce533b8b50..3b72a2f6f4 100644 --- a/vlib/builtin/js/string.js.v +++ b/vlib/builtin/js/string.js.v @@ -28,7 +28,7 @@ pub fn (s string) after(dot string) string { return string(s.str.slice(JS.Number(int(s.str.lastIndexOf(dot.str)) + 1), s.str.length)) } -pub fn (s string) after_char(dot byte) string { +pub fn (s string) after_char(dot u8) string { // TODO: Implement after byte return s } @@ -385,7 +385,7 @@ fn compare_lower_strings(a &string, b &string) int { // at returns the byte at index `idx`. // Example: assert 'ABC'.at(1) == u8(`B`) -fn (s string) at(idx int) byte { +fn (s string) at(idx int) u8 { mut result := u8(0) #result = new u8(s.str.charCodeAt(result)) @@ -491,7 +491,7 @@ pub fn (s string) strip_margin() string { // strip_margin_custom does the same as `strip_margin` but will use `del` as delimiter instead of `|` [direct_array_access] -pub fn (s string) strip_margin_custom(del byte) string { +pub fn (s string) strip_margin_custom(del u8) string { mut sep := del if sep.is_space() { eprintln('Warning: `strip_margin` cannot use white-space as a delimiter') diff --git a/vlib/builtin/js/utf8.js.v b/vlib/builtin/js/utf8.js.v index cb9ca86700..d63729f92c 100644 --- a/vlib/builtin/js/utf8.js.v +++ b/vlib/builtin/js/utf8.js.v @@ -12,6 +12,6 @@ pub fn utf8_str_len(s string) int { return s.len } -pub fn utf8_char_len(b byte) int { +pub fn utf8_char_len(b u8) int { return ((0xe5000000 >> ((b >> 3) & 0x1e)) & 3) + 1 } diff --git a/vlib/mysql/orm.v b/vlib/mysql/orm.v index 7bda4741a0..498244c84a 100644 --- a/vlib/mysql/orm.v +++ b/vlib/mysql/orm.v @@ -162,7 +162,7 @@ fn stmt_binder_match(mut stmt Stmt, data orm.Primitive) { i64 { stmt.bind_i64(&data) } - byte { + u8 { stmt.bind_u8(&data) } u16 { diff --git a/vlib/v/gen/js/auto_str_methods.v b/vlib/v/gen/js/auto_str_methods.v index 39fc79516d..2374936e8c 100644 --- a/vlib/v/gen/js/auto_str_methods.v +++ b/vlib/v/gen/js/auto_str_methods.v @@ -466,7 +466,7 @@ fn (mut g JsGen) gen_str_for_array(info ast.Array, styp string, str_fn_name stri is_elem_ptr := typ.is_ptr() sym_has_str_method, str_method_expects_ptr, _ := sym.str_method_info() mut elem_str_fn_name := g.get_str_fn(typ) - if sym.kind == .byte { + if sym.kind == .u8 { elem_str_fn_name = elem_str_fn_name + '_escaped' } diff --git a/vlib/v/gen/js/builtin_types.v b/vlib/v/gen/js/builtin_types.v index bb3a5b6feb..1de85d1c1a 100644 --- a/vlib/v/gen/js/builtin_types.v +++ b/vlib/v/gen/js/builtin_types.v @@ -26,8 +26,7 @@ fn (mut g JsGen) to_js_typ_val(t ast.Type) string { mut styp := '' mut prefix := 'new ' match sym.kind { - .i8, .i16, .int, .i64, .byte, .u8, .u16, .u32, .u64, .f32, .f64, .int_literal, - .float_literal { + .i8, .i16, .int, .i64, .u8, .u16, .u32, .u64, .f32, .f64, .int_literal, .float_literal { styp = '$prefix${g.sym_to_js_typ(sym)}(0)' } .bool { @@ -71,8 +70,8 @@ fn (mut g JsGen) sym_to_js_typ(sym ast.TypeSymbol) string { .i64 { styp = 'i64' } - .byte { - styp = 'byte' + .u8 { + styp = 'u8' } .u16 { styp = 'u16' @@ -162,8 +161,8 @@ pub fn (mut g JsGen) doc_typ(t ast.Type) string { .byteptr, .charptr { styp = '${g.sym_to_js_typ(sym)}' } - .i8, .i16, .int, .i64, .isize, .byte, .u8, .u16, .u32, .u64, .usize, .f32, .f64, - .int_literal, .float_literal { + .i8, .i16, .int, .i64, .isize, .u8, .u16, .u32, .u64, .usize, .f32, .f64, .int_literal, + .float_literal { styp = '${g.sym_to_js_typ(sym)}' } .bool { @@ -396,7 +395,7 @@ fn (mut g JsGen) gen_builtin_type_defs() { ) } } - 'byte' { + 'u8' { g.gen_builtin_prototype( typ_name: typ_name default_value: 'new Number(0)' diff --git a/vlib/v/gen/js/js.v b/vlib/v/gen/js/js.v index be6d027cda..99a76b1138 100644 --- a/vlib/v/gen/js/js.v +++ b/vlib/v/gen/js/js.v @@ -21,7 +21,7 @@ const ( // used to generate type structs v_types = ['i8', 'i16', 'int', 'i64', 'byte', 'u16', 'u32', 'u64', 'f32', 'f64', 'int_literal', 'float_literal', 'bool', 'string', 'map', 'array', 'rune', 'any', 'voidptr'] - shallow_equatables = [ast.Kind.i8, .i16, .int, .i64, .byte, .u16, .u32, .u64, .f32, .f64, + shallow_equatables = [ast.Kind.i8, .i16, .int, .i64, .u8, .u16, .u32, .u64, .f32, .f64, .int_literal, .float_literal, .bool, .string] )