diff --git a/examples/tetris/tetris.v b/examples/tetris/tetris.v index f88b9099bf..eab2538572 100644 --- a/examples/tetris/tetris.v +++ b/examples/tetris/tetris.v @@ -38,39 +38,18 @@ const ( const ( // Tetros' 4 possible states are encoded in binaries + // 0000 0 0000 0 0000 0 0000 0 0000 0 0000 0 + // 0000 0 0000 0 0000 0 0000 0 0011 3 0011 3 + // 0110 6 0010 2 0011 3 0110 6 0001 1 0010 2 + // 0110 6 0111 7 0110 6 0011 3 0001 1 0010 2 + // There is a special case 1111, since 15 can't be used. b_tetros = [ - // 0000 0 - // 0000 0 - // 0110 6 - // 0110 6 [66, 66, 66, 66], - // 0000 0 - // 0000 0 - // 0010 2 - // 0111 7 [27, 131, 72, 232], - // 0000 0 - // 0000 0 - // 0011 3 - // 0110 6 [36, 231, 36, 231], - // 0000 0 - // 0000 0 - // 0110 6 - // 0011 3 [63, 132, 63, 132], - // 0000 0 - // 0011 3 - // 0001 1 - // 0001 1 [311, 17, 223, 74], - // 0000 0 - // 0011 3 - // 0010 2 - // 0010 2 [322, 71, 113, 47], - // Special case since 15 can't be used - // 1111 [1111, 9, 1111, 9], ] // Each tetro has its unique color diff --git a/vlib/builtin/string_test.v b/vlib/builtin/string_test.v index 69684973d8..6a1b6ac652 100644 --- a/vlib/builtin/string_test.v +++ b/vlib/builtin/string_test.v @@ -808,7 +808,8 @@ fn test_double_quote_inter() { fn test_string_map() { $if windows { - return // TODO + // TODO + return } original := 'Hello' println('original.len = $original.len') diff --git a/vlib/builtin/utf8.v b/vlib/builtin/utf8.v index f11d349788..a9078e7c5c 100644 --- a/vlib/builtin/utf8.v +++ b/vlib/builtin/utf8.v @@ -18,35 +18,26 @@ pub fn utf32_to_str_no_malloc(code u32, buf voidptr) string { icode := int(code) // Prevents doing casts everywhere unsafe { mut buffer := byteptr(buf) - if icode <= 127/* 0x7F */ { + if icode <= 127 { /* 0x7F */ buffer[0] = byte(icode) return tos(buffer, 1) } - if icode <= 2047/* 0x7FF */ { - buffer[0] = 192/*0xC0*/ | byte(icode>>6)/* 110xxxxx */ - - buffer[1] = 128/*0x80*/ | byte(icode & 63/*0x3F*/)/* 10xxxxxx */ - + if icode <= 2047 { /* 0x7FF */ + buffer[0] = 192 | byte(icode>>6) /* 0xC0 - 110xxxxx */ + buffer[1] = 128 | byte(icode & 63) /* 0x80 - 0x3F - 10xxxxxx */ return tos(buffer, 2) } - if icode <= 65535/* 0xFFFF */ { - buffer[0] = 224/*0xE0*/ | byte(icode>>12)/* 1110xxxx */ - - buffer[1] = 128/*0x80*/ | (byte(icode>>6) & 63/*0x3F*/)/* 10xxxxxx */ - - buffer[2] = 128/*0x80*/ | byte(icode & 63/*0x3F*/)/* 10xxxxxx */ - + if icode <= 65535 { /* 0xFFFF */ + buffer[0] = 224 | byte(icode>>12)/* 0xE0 - 1110xxxx */ + buffer[1] = 128 | (byte(icode>>6) & 63) /* 0x80 - 0x3F - 10xxxxxx */ + buffer[2] = 128 | byte(icode & 63) /* 0x80 - 0x3F - 10xxxxxx */ return tos(buffer, 3) } if icode <= 1114111/* 0x10FFFF */ { - buffer[0] = 240/*0xF0*/ | byte(icode>>18)/* 11110xxx */ - - buffer[1] = 128/*0x80*/ | (byte(icode>>12) & 63/*0x3F*/)/* 10xxxxxx */ - - buffer[2] = 128/*0x80*/ | (byte(icode>>6) & 63/*0x3F*/)/* 10xxxxxx */ - - buffer[3] = 128/*0x80*/ | byte(icode & 63/*0x3F*/)/* 10xxxxxx */ - + buffer[0] = 240 | byte(icode>>18) /* 0xF0 - 11110xxx */ + buffer[1] = 128 | (byte(icode>>12) & 63) /* 0x80 - 0x3F - 10xxxxxx */ + buffer[2] = 128 | (byte(icode>>6) & 63) /* 0x80 - 0x3F - 10xxxxxx */ + buffer[3] = 128 | byte(icode & 63) /* 0x80 - 0x3F - 10xxxxxx */ return tos(buffer, 4) } } @@ -186,10 +177,14 @@ fn utf8_str_visible_length(s string) int { } } else if c == 0xe1 || c == 0xe2 || c == 0xef { r := (u32(c) << 16) | unsafe {(u32(s.str[i+1]) << 8) | s.str[i+2]} - if (r >= 0xe1aab0 && r < 0xe1ac80) // diacritical marks extended - || (r >= 0xe1b780 && r < 0xe1b880) // diacritical marks supplement - || (r >= 0xe28390 && r < 0xe28480) // diacritical marks for symbols - || (r >= 0xefb8a0 && r < 0xefb8b0) { // half marks + // diacritical marks extended 0xe1aab0 - 0xe1ac80 + // diacritical marks supplement 0xe1b780 - 0xe1b880 + // diacritical marks for symbols 0xe28390 - 0xe28480 + // half marks 0xefb8a0 - 0xefb8b0 + if (r >= 0xe1aab0 && r < 0xe1ac80) + || (r >= 0xe1b780 && r < 0xe1b880) + || (r >= 0xe28390 && r < 0xe28480) + || (r >= 0xefb8a0 && r < 0xefb8b0) { l-- } } diff --git a/vlib/clipboard/clipboard_linux.c.v b/vlib/clipboard/clipboard_linux.c.v index 71320786a8..37a786be79 100644 --- a/vlib/clipboard/clipboard_linux.c.v +++ b/vlib/clipboard/clipboard_linux.c.v @@ -260,7 +260,8 @@ fn (mut cb Clipboard) start_listener(){ match event.@type { C.DestroyNotify { if event.xdestroywindow.window == cb.window { - return // we are done + // we are done + return } } C.SelectionClear { diff --git a/vlib/clipboard/clipboard_test.v b/vlib/clipboard/clipboard_test.v index bbe7a36e41..4c1a1c5837 100644 --- a/vlib/clipboard/clipboard_test.v +++ b/vlib/clipboard/clipboard_test.v @@ -14,8 +14,8 @@ fn run_test(is_primary bool){ fn test_primary(){ $if linux { - return //run_test(true) + return } } diff --git a/vlib/hash/hash.v b/vlib/hash/hash.v index ce6f5413e2..f2109473d0 100644 --- a/vlib/hash/hash.v +++ b/vlib/hash/hash.v @@ -1,7 +1,6 @@ // Copyright (c) 2019-2020 Alexander Medvednikov. All rights reserved. // Use of this source code is governed by an MIT license // that can be found in the LICENSE file. - module hash interface Hasher { diff --git a/vlib/sokol/gfx/gfx_funcs.v b/vlib/sokol/gfx/gfx_funcs.v index a242393eba..b4ba4e3049 100644 --- a/vlib/sokol/gfx/gfx_funcs.v +++ b/vlib/sokol/gfx/gfx_funcs.v @@ -28,7 +28,8 @@ fn C.sg_apply_viewport(x int, y int, width int, height int, origin_top_left bool fn C.sg_apply_scissor_rect(x int, y int, width int, height int, origin_top_left bool) fn C.sg_apply_pipeline(pip C.sg_pipeline) fn C.sg_apply_bindings(bindings &C.sg_bindings) -fn C.sg_apply_uniforms(stage int /*sg_shader_stage*/, ub_index int, data voidptr, num_bytes int) +// stage == sg_shader_stage +fn C.sg_apply_uniforms(stage int, ub_index int, data voidptr, num_bytes int) fn C.sg_draw(base_element int, num_elements int, num_instances int) fn C.sg_end_pass() fn C.sg_commit() diff --git a/vlib/sync/channel_select_2_test.v b/vlib/sync/channel_select_2_test.v index 055b49abbc..5640fc7d94 100644 --- a/vlib/sync/channel_select_2_test.v +++ b/vlib/sync/channel_select_2_test.v @@ -56,8 +56,8 @@ fn test_select() { } } // Use Gauß' formula for the first 2 contributions + // the 3rd contribution is `byte` and must be seen modulo 256 expected_sum := 2 * (300 * (300 - 1) / 2) + - // the 3rd contribution is `byte` and must be seen modulo 256 256 * (256 - 1) / 2 + 44 * (44 - 1) / 2 assert sum == expected_sum diff --git a/vlib/sync/channel_select_test.v b/vlib/sync/channel_select_test.v index 2d99cd2a05..384a8e9ab5 100644 --- a/vlib/sync/channel_select_test.v +++ b/vlib/sync/channel_select_test.v @@ -76,8 +76,8 @@ fn test_select() { } } // Use Gauß' formula for the first 2 contributions + // the 3rd contribution is `byte` and must be seen modulo 256 expected_sum := 2 * (300 * (300 - 1) / 2) + - // the 3rd contribution is `byte` and must be seen modulo 256 256 * (256 - 1) / 2 + 44 * (44 - 1) / 2 assert sum == expected_sum diff --git a/vlib/sync/select_close_test.v b/vlib/sync/select_close_test.v index 6b5e5e2b99..4d282a91f1 100644 --- a/vlib/sync/select_close_test.v +++ b/vlib/sync/select_close_test.v @@ -85,8 +85,8 @@ fn test_select() { } } // Use Gauß' formula for the first 2 contributions + // the 3rd contribution is `byte` and must be seen modulo 256 expected_sum := 2 * (300 * (300 - 1) / 2) + - // the 3rd contribution is `byte` and must be seen modulo 256 256 * (256 - 1) / 2 + 44 * (44 - 1) / 2 assert sum == expected_sum