From ddb6685d8a0cb498b5031c644f16d05ac3121ced Mon Sep 17 00:00:00 2001 From: yuyi Date: Tue, 6 Aug 2024 01:23:39 +0800 Subject: [PATCH] fmt: fix and simplify align of struct fields (#21995) --- .../v_apps_and_modules_compile_ci.yml | 24 +++--- cmd/tools/modules/testing/common.v | 4 +- cmd/tools/modules/vgit/vgit.v | 4 +- cmd/tools/oldv.v | 10 +-- cmd/tools/vcover/main.v | 2 +- cmd/tools/vpm/vcs.v | 2 +- cmd/tools/vrepl.v | 26 +++--- cmd/tools/vtest-all.v | 8 +- cmd/tools/vvet/errors.v | 2 +- doc/docs.md | 4 +- examples/brainvuck.v | 6 +- examples/clock/clock.v | 2 +- examples/database/orm.v | 8 +- examples/flag/animated_help_text.v | 10 +-- examples/flag/flag_layout_editor.v | 10 +-- examples/gg/bezier.v | 2 +- .../js_dom_draw_benchmark_chart/chart/main.v | 2 +- .../v_vweb_orm/src/main.v | 2 +- .../sokol/06_obj_viewer/modules/obj/struct.v | 2 +- examples/sokol/sounds/melody.v | 4 +- examples/term.ui/term_drawing.v | 4 +- examples/term.ui/vyper.v | 2 +- examples/viewer/view.v | 2 +- .../vweb_fullstack/src/product_entities.v | 2 +- examples/vweb_fullstack/src/user_entities.v | 6 +- examples/xvweb/todo/main.v | 2 +- .../README.md | 2 +- .../code/blog/article.v | 2 +- vlib/builtin/prealloc.c.v | 2 +- vlib/cli/command.v | 6 +- vlib/compress/zstd/zstd.c.v | 4 +- vlib/db/mysql/mysql_orm_test.v | 4 +- vlib/db/pg/pg_orm_test.v | 4 +- vlib/db/sqlite/parent_child_test.v | 6 +- vlib/db/sqlite/sqlite.c.v | 2 +- vlib/db/sqlite/sqlite_orm_test.v | 12 +-- vlib/db/sqlite/sqlite_test.v | 2 +- vlib/db/sqlite/vfs_lowlevel.c.v | 6 +- vlib/dlmalloc/dlmalloc.v | 6 +- vlib/encoding/csv/csv_reader_random_access.v | 14 +-- vlib/encoding/csv/csv_reader_sequential.v | 10 +-- vlib/encoding/xml/types.v | 4 +- vlib/flag/README.md | 6 +- vlib/flag/cmd_exe_style_flags_test.v | 4 +- vlib/flag/flag_to.v | 10 +-- vlib/flag/flag_to_doc_test.v | 10 +-- vlib/flag/flag_to_misc_test.v | 8 +- vlib/flag/go_flag_style_flags_test.v | 6 +- vlib/flag/posix_style_flags_test.v | 4 +- vlib/flag/v_style_flags_test.v | 6 +- vlib/gg/gg.c.v | 16 ++-- vlib/gg/gg.js.v | 12 +-- vlib/gg/gg.v | 2 +- vlib/gg/image.c.v | 4 +- vlib/gg/image.v | 2 +- vlib/gg/text_rendering.c.v | 4 +- vlib/gx/text.v | 4 +- vlib/io/buffered_reader.v | 2 +- vlib/json/README.md | 4 +- vlib/json/json_encode_recursive_ptr_test.v | 4 +- vlib/json/json_generic_array_test.v | 2 +- vlib/json/json_test.v | 2 +- vlib/log/log.v | 2 +- vlib/net/http/file/static_server.v | 8 +- vlib/net/http/http.v | 2 +- vlib/net/http/request.v | 2 +- vlib/net/http/server.v | 10 +-- vlib/net/urllib/urllib.v | 14 +-- vlib/net/websocket/websocket_client.v | 14 +-- vlib/net/websocket/websocket_server.v | 2 +- vlib/orm/orm_custom_operators_test.v | 2 +- vlib/orm/orm_fk_test.v | 6 +- vlib/orm/orm_fn_calls_test.v | 2 +- vlib/orm/orm_insert_reserved_name_test.v | 2 +- vlib/orm/orm_insert_test.v | 10 +-- vlib/orm/orm_interface_test.v | 2 +- vlib/orm/orm_last_id_test.v | 2 +- vlib/orm/orm_mut_db_test.v | 2 +- vlib/orm/orm_null_test.v | 4 +- vlib/orm/orm_option_time_test.v | 10 +-- vlib/orm/orm_references_test.v | 2 +- vlib/orm/orm_result_test.v | 4 +- .../orm_string_interpolation_in_where_test.v | 2 +- vlib/orm/orm_test.v | 8 +- vlib/os/os_android_outside_termux.c.v | 4 +- vlib/os/process.v | 12 +-- vlib/picoev/picoev.v | 18 ++-- vlib/readline/readline.v | 4 +- vlib/regex/regex.v | 14 +-- vlib/sokol/sapp/sapp_structs.c.v | 42 ++++----- vlib/sokol/sfons/sfons_funcs.c.v | 4 +- vlib/sokol/sgl/sgl_structs.c.v | 12 +-- vlib/strconv/format.v | 8 +- vlib/sync/channels.c.v | 2 +- vlib/toml/parser/parser.v | 4 +- vlib/v/ast/ast.v | 12 +-- vlib/v/ast/table.v | 8 +- vlib/v/builder/builder.v | 6 +- vlib/v/callgraph/callgraph.v | 6 +- vlib/v/checker/checker.v | 8 +- vlib/v/debug/debug.v | 16 ++-- vlib/v/doc/doc.v | 2 +- vlib/v/dotgraph/dotgraph.v | 4 +- vlib/v/fmt/align.v | 30 +++---- vlib/v/fmt/fmt.v | 85 ++++++++++++++----- vlib/v/fmt/struct.v | 56 ++++++------ .../struct_default_field_expressions_keep.vv | 6 +- vlib/v/fmt/tests/structs_comments_keep.vv | 2 +- vlib/v/gen/c/cgen.v | 46 +++++----- vlib/v/gen/js/js.v | 2 +- vlib/v/gen/js/sourcemap/source_map.v | 8 +- vlib/v/gen/wasm/gen.v | 2 +- vlib/v/live/common.c.v | 16 ++-- vlib/v/parser/parser.v | 10 +-- vlib/v/pref/pref.v | 20 ++--- vlib/v/reflection/reflection.v | 16 ++-- vlib/v/scanner/scanner.v | 12 +-- vlib/v/tests/fn_literal_type_test.v | 2 +- ...s_struct_field_with_default_fn_type_test.v | 8 +- vlib/v/tests/orm_create_several_tables_test.v | 6 +- vlib/v/tests/orm_enum_test.v | 2 +- .../orm_stmt_wrong_return_checking_test.v | 2 +- vlib/v/tests/orm_sub_array_struct_test.v | 6 +- vlib/v/tests/orm_sub_struct_test.v | 4 +- .../tests/sql_statement_inside_fn_call_test.v | 2 +- ...w_both_field_defaults_and_skip_flag_test.v | 4 +- vlib/veb/auth/README.md | 3 +- vlib/veb/auth/auth.v | 2 +- vlib/vweb/csrf/csrf_test.v | 2 +- vlib/vweb/vweb.v | 6 +- .../encode_struct_skippable_fields_test.v | 16 ++-- .../json_test.v | 2 +- vlib/x/sessions/db_store.v | 2 +- vlib/x/sessions/sessions.v | 2 +- .../templating/dtm/dynamic_template_manager.v | 4 +- vlib/x/ttf/README.md | 8 +- vlib/x/ttf/render_bmp.v | 20 ++--- vlib/x/ttf/render_sokol_cpu.v | 2 +- vlib/x/ttf/text_block.v | 8 +- 139 files changed, 553 insertions(+), 519 deletions(-) diff --git a/.github/workflows/v_apps_and_modules_compile_ci.yml b/.github/workflows/v_apps_and_modules_compile_ci.yml index e4ab3d0763..0148458a3e 100644 --- a/.github/workflows/v_apps_and_modules_compile_ci.yml +++ b/.github/workflows/v_apps_and_modules_compile_ci.yml @@ -155,18 +155,18 @@ jobs: echo "Build v-analyzer release" v build.vsh release - - name: Format vlang/v-analyzer - if: ${{ !cancelled() && steps.build.outcome == 'success' }} - run: | - cd /tmp/v-analyzer - set +e - v fmt -c . - exit_code=$? - if [[ $exit_code -ne 0 && $exit_code -ne 5 ]]; then - # Don't fail if there are only internal errors (exit code 5). - v fmt -diff . - exit 1 - fi + # - name: Format vlang/v-analyzer + # if: ${{ !cancelled() && steps.build.outcome == 'success' }} + # run: | + # cd /tmp/v-analyzer + # set +e + # v fmt -c . + # exit_code=$? + # if [[ $exit_code -ne 0 && $exit_code -ne 5 ]]; then + # # Don't fail if there are only internal errors (exit code 5). + # v fmt -diff . + # exit 1 + # fi - name: Build vlang/go2v if: ${{ !cancelled() && steps.build.outcome == 'success' && matrix.os != 'macos-14' }} diff --git a/cmd/tools/modules/testing/common.v b/cmd/tools/modules/testing/common.v index 8095a733ec..74b8f0e099 100644 --- a/cmd/tools/modules/testing/common.v +++ b/cmd/tools/modules/testing/common.v @@ -87,9 +87,9 @@ pub mut: show_stats bool show_asserts bool progress_mode bool - root_relative bool // used by CI runs, so that the output is stable everywhere + root_relative bool // used by CI runs, so that the output is stable everywhere nmessages chan LogMessage // many publishers, single consumer/printer - nmessage_idx int // currently printed message index + nmessage_idx int // currently printed message index failed_cmds shared []string reporter Reporter = Reporter(NormalReporter{}) hash string // used as part of the name of the temporary directory created for tests, to ease cleanup diff --git a/cmd/tools/modules/vgit/vgit.v b/cmd/tools/modules/vgit/vgit.v index 30d114a62b..64abf3c9da 100644 --- a/cmd/tools/modules/vgit/vgit.v +++ b/cmd/tools/modules/vgit/vgit.v @@ -121,8 +121,8 @@ pub fn clone_or_pull(remote_git_url string, local_worktree_path string) { pub struct VGitContext { pub: - cc string = 'cc' // what compiler to use - workdir string = '/tmp' // the base working folder + cc string = 'cc' // what compiler to use + workdir string = '/tmp' // the base working folder commit_v string = 'master' // the commit-ish that needs to be prepared path_v string // where is the local working copy v repo path_vc string // where is the local working copy vc repo diff --git a/cmd/tools/oldv.v b/cmd/tools/oldv.v index 19b1eb3e47..bcf9900b95 100644 --- a/cmd/tools/oldv.v +++ b/cmd/tools/oldv.v @@ -35,11 +35,11 @@ mut: path_vc string // the full path to the vc folder inside workdir. cmd_to_run string // the command that you want to run *in* the oldv repo cc string = 'cc' // the C compiler to use for bootstrapping. - cleanup bool // should the tool run a cleanup first - use_cache bool // use local cached copies for --vrepo and --vcrepo in - fresh_tcc bool // do use `make fresh_tcc` - is_bisect bool // bisect mode; usage: `cmd/tools/oldv -b -c './v run bug.v'` - show_vccommit bool // show the V and VC commits, corresponding to the V commit-ish, that can be used to build V + cleanup bool // should the tool run a cleanup first + use_cache bool // use local cached copies for --vrepo and --vcrepo in + fresh_tcc bool // do use `make fresh_tcc` + is_bisect bool // bisect mode; usage: `cmd/tools/oldv -b -c './v run bug.v'` + show_vccommit bool // show the V and VC commits, corresponding to the V commit-ish, that can be used to build V } fn (mut c Context) compile_oldv_if_needed() { diff --git a/cmd/tools/vcover/main.v b/cmd/tools/vcover/main.v index 6d3c7ff954..3639743eb2 100644 --- a/cmd/tools/vcover/main.v +++ b/cmd/tools/vcover/main.v @@ -26,7 +26,7 @@ mut: meta map[string]MetaData // aggregated meta data, read from all .json files all_lines_per_file map[string][]int // aggregated by load_meta // - counters map[string]u64 // incremented by process_target, based on each .csv file + counters map[string]u64 // incremented by process_target, based on each .csv file lines_per_file map[string]map[int]int // incremented by process_target, based on each .csv file processed_points u64 } diff --git a/cmd/tools/vpm/vcs.v b/cmd/tools/vpm/vcs.v index 5df6bb7018..ccd6db6f4b 100644 --- a/cmd/tools/vpm/vcs.v +++ b/cmd/tools/vpm/vcs.v @@ -10,7 +10,7 @@ enum VCS { } struct VCSInfo { - dir string @[required] + dir string @[required] args struct { install string @[required] version string @[required] // flag to specify a version, added to install. diff --git a/cmd/tools/vrepl.v b/cmd/tools/vrepl.v index 0cdd1df96b..ee48f9ac3f 100644 --- a/cmd/tools/vrepl.v +++ b/cmd/tools/vrepl.v @@ -23,20 +23,20 @@ mut: folder string // the folder in which the repl will write its temporary source files last_output string // the last repl output // - modules []string // all the import modules + modules []string // all the import modules alias map[string]string // all the alias used in the import - includes []string // all the #include statements - functions []string // all the user function declarations - functions_name []string // all the user function names - structs []string // all the struct definitions - enums []string // all the enum definitions - consts []string // all the const definitions - types []string // all the type definitions - interfaces []string // all the interface definitions - lines []string // all the other lines/statements - temp_lines []string // all the temporary expressions/printlns - vstartup_lines []string // lines in the `VSTARTUP` file - eval_func_lines []string // same line of the `VSTARTUP` file, but used to test fn type + includes []string // all the #include statements + functions []string // all the user function declarations + functions_name []string // all the user function names + structs []string // all the struct definitions + enums []string // all the enum definitions + consts []string // all the const definitions + types []string // all the type definitions + interfaces []string // all the interface definitions + lines []string // all the other lines/statements + temp_lines []string // all the temporary expressions/printlns + vstartup_lines []string // lines in the `VSTARTUP` file + eval_func_lines []string // same line of the `VSTARTUP` file, but used to test fn type } const is_stdin_a_pipe = os.is_atty(0) == 0 diff --git a/cmd/tools/vtest-all.v b/cmd/tools/vtest-all.v index 88f3c5fd94..32decbd49f 100644 --- a/cmd/tools/vtest-all.v +++ b/cmd/tools/vtest-all.v @@ -74,10 +74,10 @@ mut: errmsg string rmfile string runcmd RunCommandKind = .system - expect string = expect_nothing - starts_with string = starts_with_nothing - ends_with string = ends_with_nothing - contains string = contains_nothing + expect string = expect_nothing + starts_with string = starts_with_nothing + ends_with string = ends_with_nothing + contains string = contains_nothing output string before_cb FnCheck = unsafe { nil } after_cb FnCheck = unsafe { nil } diff --git a/cmd/tools/vvet/errors.v b/cmd/tools/vvet/errors.v index 01e2895df3..1e9b19233c 100644 --- a/cmd/tools/vvet/errors.v +++ b/cmd/tools/vvet/errors.v @@ -28,7 +28,7 @@ pub mut: kind ErrorKind @[required] pub: // General message - message string @[required] + message string @[required] details string // Details about how to resolve or fix the situation file_path string // file where the error have origin pos token.Pos // position in the file diff --git a/doc/docs.md b/doc/docs.md index 478b7c8f37..eedb01ff9a 100644 --- a/doc/docs.md +++ b/doc/docs.md @@ -5136,7 +5136,7 @@ import db.sqlite // sets a custom table name. Default is struct name (case-sensitive) @[table: 'customers'] struct Customer { - id int @[primary; sql: serial] // a field named `id` of integer type must be the first field + id int @[primary; sql: serial] // a field named `id` of integer type must be the first field name string nr_orders int country ?string @@ -7895,4 +7895,4 @@ Assignment Operators &= |= ^= >>= <<= >>>= &&= ||= -``` \ No newline at end of file +``` diff --git a/examples/brainvuck.v b/examples/brainvuck.v index 9f4729cb49..2e76f16a8f 100644 --- a/examples/brainvuck.v +++ b/examples/brainvuck.v @@ -11,9 +11,9 @@ const show_state = os.getenv('VERBOSE') != '' struct BFState { mut: - pc u16 // program counter (PC) register - address u16 // a 16-bit address register, serving as an index to the memory below - program string // the BF program + pc u16 // program counter (PC) register + address u16 // a 16-bit address register, serving as an index to the memory below + program string // the BF program memory []u8 = []u8{len: 65536} // we have 2^16 bytes of memory targets map[int]int // a mapping for the program address of a `[` to its corresponding `]`, and from a `]` to its corresponding opening `[`. } diff --git a/examples/clock/clock.v b/examples/clock/clock.v index 92f479a017..2fc3ee726c 100644 --- a/examples/clock/clock.v +++ b/examples/clock/clock.v @@ -42,7 +42,7 @@ struct App { mut: gg &gg.Context = unsafe { nil } draw_flag bool = true - dpi_scale f32 = 1.0 + dpi_scale f32 = 1.0 } fn on_frame(mut app App) { diff --git a/examples/database/orm.v b/examples/database/orm.v index 090e5b5300..d2080352de 100644 --- a/examples/database/orm.v +++ b/examples/database/orm.v @@ -33,9 +33,9 @@ const pg_db = os.getenv_opt('PGDATABASE') or { 'test' } @[table: 'modules'] struct Module { - id int @[primary; sql: serial] + id int @[primary; sql: serial] name string - nr_downloads int @[sql: u64] + nr_downloads int @[sql: u64] creator User } @@ -48,13 +48,13 @@ struct User { } struct Parent { - id int @[primary; sql: serial] + id int @[primary; sql: serial] name string children []Child @[fkey: 'parent_id'] } struct Child { - id int @[primary; sql: serial] + id int @[primary; sql: serial] parent_id int name string } diff --git a/examples/flag/animated_help_text.v b/examples/flag/animated_help_text.v index b8b3b85a2c..720f230132 100644 --- a/examples/flag/animated_help_text.v +++ b/examples/flag/animated_help_text.v @@ -2,13 +2,13 @@ import term.ui as tui import flag struct DocTest { - show_version bool @[short: v; xdoc: 'Show version and exit'] - debug_level int @[long: debug; short: d; xdoc: 'Debug level'] - level f32 @[only: l; xdoc: 'Do not show this'] + show_version bool @[short: v; xdoc: 'Show version and exit'] + debug_level int @[long: debug; short: d; xdoc: 'Debug level'] + level f32 @[only: l; xdoc: 'Do not show this'] example string square bool - multi int @[only: m; repeats] - wroom []int @[short: w] + multi int @[only: m; repeats] + wroom []int @[short: w] the_limit string } diff --git a/examples/flag/flag_layout_editor.v b/examples/flag/flag_layout_editor.v index 27e979fba0..c4f596162a 100644 --- a/examples/flag/flag_layout_editor.v +++ b/examples/flag/flag_layout_editor.v @@ -4,13 +4,13 @@ import flag @[name: 'flag_layout_editor'] @[version: '1.0'] struct DocTest { - show_version bool @[short: v; xdoc: 'Show version and exit'] - debug_level int @[long: debug; short: d; xdoc: 'Debug level'] - level f32 @[only: l; xdoc: 'Do not show this'] + show_version bool @[short: v; xdoc: 'Show version and exit'] + debug_level int @[long: debug; short: d; xdoc: 'Debug level'] + level f32 @[only: l; xdoc: 'Do not show this'] example string square bool - multi int @[only: m; repeats] - wroom []int @[short: w] + multi int @[only: m; repeats] + wroom []int @[short: w] the_limit string } diff --git a/examples/gg/bezier.v b/examples/gg/bezier.v index 4f64c4b868..09aaac4811 100644 --- a/examples/gg/bezier.v +++ b/examples/gg/bezier.v @@ -8,7 +8,7 @@ const points = [f32(200.0), 200.0, 200.0, 100.0, 400.0, 100.0, 400.0, 300.0] struct App { mut: gg &gg.Context = unsafe { nil } - steps int = 30 + steps int = 30 } fn main() { diff --git a/examples/js_dom_draw_benchmark_chart/chart/main.v b/examples/js_dom_draw_benchmark_chart/chart/main.v index 3bf74fee42..ada9fc6de9 100644 --- a/examples/js_dom_draw_benchmark_chart/chart/main.v +++ b/examples/js_dom_draw_benchmark_chart/chart/main.v @@ -11,7 +11,7 @@ import v.util.version @[table: 'benchmark'] struct Task { mut: - id u32 @[primary; serial; sql: serial] + id u32 @[primary; serial; sql: serial] title string status string } diff --git a/examples/js_dom_draw_benchmark_chart/v_vweb_orm/src/main.v b/examples/js_dom_draw_benchmark_chart/v_vweb_orm/src/main.v index f2920ec125..a5fccb3446 100644 --- a/examples/js_dom_draw_benchmark_chart/v_vweb_orm/src/main.v +++ b/examples/js_dom_draw_benchmark_chart/v_vweb_orm/src/main.v @@ -11,7 +11,7 @@ struct App { @[table: 'benchmark'] struct Task { mut: - id u32 @[primary; serial; sql: serial] + id u32 @[primary; serial; sql: serial] title string status string } diff --git a/examples/sokol/06_obj_viewer/modules/obj/struct.v b/examples/sokol/06_obj_viewer/modules/obj/struct.v index 4508060651..07c65e09ef 100644 --- a/examples/sokol/06_obj_viewer/modules/obj/struct.v +++ b/examples/sokol/06_obj_viewer/modules/obj/struct.v @@ -53,7 +53,7 @@ pub mut: mat_map map[string]int // mapping material name to its material index texture map[string]gfx.Image // GPU loaded texture map sampler map[string]gfx.Sampler // GPU loaded sampler - material_file string // .mtl file name for the .obj + material_file string // .mtl file name for the .obj rend_data []Render_data // render data used for the rendering diff --git a/examples/sokol/sounds/melody.v b/examples/sokol/sounds/melody.v index 9c01ffb713..83d7e73181 100644 --- a/examples/sokol/sounds/melody.v +++ b/examples/sokol/sounds/melody.v @@ -3,8 +3,8 @@ import sokol.audio struct AppState { mut: - frame_0 int // offset of the current audio frames, relative to the start of the music - frames [2048]f32 // a copy of the last rendered audio frames + frame_0 int // offset of the current audio frames, relative to the start of the music + frames [2048]f32 // a copy of the last rendered audio frames gg &gg.Context = unsafe { nil } // used for drawing } diff --git a/examples/term.ui/term_drawing.v b/examples/term.ui/term_drawing.v index b89eb7a98e..e3cf9e89f2 100644 --- a/examples/term.ui/term_drawing.v +++ b/examples/term.ui/term_drawing.v @@ -98,8 +98,8 @@ mut: secondary_color_idx int = 28 bg_color ui.Color = ui.Color{0, 0, 0} drawing [][]ui.Color = [][]ui.Color{len: h, init: []ui.Color{len: w}} - size int = 1 - should_redraw bool = true + size int = 1 + should_redraw bool = true is_dragging bool } diff --git a/examples/term.ui/vyper.v b/examples/term.ui/vyper.v index 3a97cd4262..45e1b0afbb 100644 --- a/examples/term.ui/vyper.v +++ b/examples/term.ui/vyper.v @@ -245,7 +245,7 @@ mut: } captured bool color termui.Color = grey - app &App = unsafe { nil } + app &App = unsafe { nil } } // randomize spawn the rat in a new spot within the playable field diff --git a/examples/viewer/view.v b/examples/viewer/view.v index 45fde9ca91..fecfcda4f8 100644 --- a/examples/viewer/view.v +++ b/examples/viewer/view.v @@ -90,7 +90,7 @@ mut: show_help_flag bool // zip container zip &szip.Zip = unsafe { nil } // pointer to the szip structure - zip_index int = -1 // index of the zip container item + zip_index int = -1 // index of the zip container item // memory buffer mem_buf voidptr // buffer used to load items from files/containers mem_buf_size int // size of the buffer diff --git a/examples/vweb_fullstack/src/product_entities.v b/examples/vweb_fullstack/src/product_entities.v index 8b8d2ba28c..8d9729eaa6 100644 --- a/examples/vweb_fullstack/src/product_entities.v +++ b/examples/vweb_fullstack/src/product_entities.v @@ -2,7 +2,7 @@ module main @[table: 'products'] struct Product { - id int @[primary; sql: serial] + id int @[primary; sql: serial] user_id int name string @[sql_type: 'TEXT'] created_at string @[default: 'CURRENT_TIMESTAMP'] diff --git a/examples/vweb_fullstack/src/user_entities.v b/examples/vweb_fullstack/src/user_entities.v index 546691facb..1cdd8372cb 100644 --- a/examples/vweb_fullstack/src/user_entities.v +++ b/examples/vweb_fullstack/src/user_entities.v @@ -3,9 +3,9 @@ module main @[table: 'users'] pub struct User { mut: - id int @[primary; sql: serial] - username string @[sql_type: 'TEXT'; unique] - password string @[sql_type: 'TEXT'] + id int @[primary; sql: serial] + username string @[sql_type: 'TEXT'; unique] + password string @[sql_type: 'TEXT'] active bool products []Product @[fkey: 'user_id'] } diff --git a/examples/xvweb/todo/main.v b/examples/xvweb/todo/main.v index e05ec2aeb7..d1cb87e2b2 100644 --- a/examples/xvweb/todo/main.v +++ b/examples/xvweb/todo/main.v @@ -13,7 +13,7 @@ struct Todo { pub mut: // `id` is the primary field. The attribute `sql: serial` acts like AUTO INCREMENT in sql. // You can use this attribute if you want a unique id for each row. - id int @[primary; sql: serial] + id int @[primary; sql: serial] name string completed bool created time.Time diff --git a/tutorials/building_a_simple_web_blog_with_vweb/README.md b/tutorials/building_a_simple_web_blog_with_vweb/README.md index f44be8fee3..74e677f6f5 100644 --- a/tutorials/building_a_simple_web_blog_with_vweb/README.md +++ b/tutorials/building_a_simple_web_blog_with_vweb/README.md @@ -234,7 +234,7 @@ Create a new file `article.v`: module main struct Article { - id int @[primary; sql: serial] + id int @[primary; sql: serial] title string text string } diff --git a/tutorials/building_a_simple_web_blog_with_vweb/code/blog/article.v b/tutorials/building_a_simple_web_blog_with_vweb/code/blog/article.v index e9a1694729..472cb95fe1 100644 --- a/tutorials/building_a_simple_web_blog_with_vweb/code/blog/article.v +++ b/tutorials/building_a_simple_web_blog_with_vweb/code/blog/article.v @@ -1,7 +1,7 @@ module main struct Article { - id int @[primary; sql: serial] + id int @[primary; sql: serial] title string text string } diff --git a/vlib/builtin/prealloc.c.v b/vlib/builtin/prealloc.c.v index 5e45fd5d51..3808f8ef4c 100644 --- a/vlib/builtin/prealloc.c.v +++ b/vlib/builtin/prealloc.c.v @@ -22,7 +22,7 @@ struct VMemoryBlock { mut: id int cap isize - start &u8 = 0 + start &u8 = 0 previous &VMemoryBlock = 0 remaining isize current &u8 = 0 diff --git a/vlib/cli/command.v b/vlib/cli/command.v index ebfa9fc934..0b4fae66a3 100644 --- a/vlib/cli/command.v +++ b/vlib/cli/command.v @@ -21,9 +21,9 @@ pub mut: pre_execute FnCommandCallback = unsafe { nil } execute FnCommandCallback = unsafe { nil } post_execute FnCommandCallback = unsafe { nil } - disable_help bool @[deprecated: 'use defaults.help instead'; deprecated_after: '2024-06-31'] - disable_man bool @[deprecated: 'use defaults.man instead'; deprecated_after: '2024-06-31'] - disable_version bool @[deprecated: 'use defaults.version instead'; deprecated_after: '2024-06-31'] + disable_help bool @[deprecated: 'use defaults.help instead'; deprecated_after: '2024-06-31'] + disable_man bool @[deprecated: 'use defaults.man instead'; deprecated_after: '2024-06-31'] + disable_version bool @[deprecated: 'use defaults.version instead'; deprecated_after: '2024-06-31'] disable_flags bool sort_flags bool sort_commands bool diff --git a/vlib/compress/zstd/zstd.c.v b/vlib/compress/zstd/zstd.c.v index 44b3fbaccd..4bcd8ce806 100644 --- a/vlib/compress/zstd/zstd.c.v +++ b/vlib/compress/zstd/zstd.c.v @@ -392,8 +392,8 @@ pub fn default_c_level() int { pub struct CompressParams { pub: compression_level int // 1~22 - nb_threads int = 1 // how many threads will be spawned to compress in parallel - checksum_flag bool = true + nb_threads int = 1 // how many threads will be spawned to compress in parallel + checksum_flag bool = true strategy ZSTD_strategy = ZSTD_strategy.zstd_default } diff --git a/vlib/db/mysql/mysql_orm_test.v b/vlib/db/mysql/mysql_orm_test.v index 20411c54c7..f815bee8bf 100644 --- a/vlib/db/mysql/mysql_orm_test.v +++ b/vlib/db/mysql/mysql_orm_test.v @@ -13,7 +13,7 @@ struct TestCustomSqlType { } struct TestCustomWrongSqlType { - id int @[primary; sql: serial] + id int @[primary; sql: serial] custom string custom1 string @[sql_type: 'VARCHAR'] custom2 string @[sql_type: 'money'] @@ -22,7 +22,7 @@ struct TestCustomWrongSqlType { struct TestTimeType { mut: - id int @[primary; sql: serial] + id int @[primary; sql: serial] username string created_at time.Time @[sql_type: 'DATETIME'] updated_at string @[sql_type: 'DATETIME'] diff --git a/vlib/db/pg/pg_orm_test.v b/vlib/db/pg/pg_orm_test.v index 8cf47ec22f..427bcb1a18 100644 --- a/vlib/db/pg/pg_orm_test.v +++ b/vlib/db/pg/pg_orm_test.v @@ -13,7 +13,7 @@ struct TestCustomSqlType { } struct TestCustomWrongSqlType { - id int @[primary; sql: serial] + id int @[primary; sql: serial] custom string custom1 string @[sql_type: 'VARCHAR'] custom2 string @[sql_type: 'money'] @@ -22,7 +22,7 @@ struct TestCustomWrongSqlType { struct TestTimeType { mut: - id int @[primary; sql: serial] + id int @[primary; sql: serial] username string created_at time.Time @[sql_type: 'TIMESTAMP'] updated_at string @[sql_type: 'TIMESTAMP'] diff --git a/vlib/db/sqlite/parent_child_test.v b/vlib/db/sqlite/parent_child_test.v index 8d9cc604ef..3901ebd768 100644 --- a/vlib/db/sqlite/parent_child_test.v +++ b/vlib/db/sqlite/parent_child_test.v @@ -1,20 +1,20 @@ import db.sqlite struct Parent { - id int @[primary; sql: serial] + id int @[primary; sql: serial] name string children []Child @[fkey: 'parent_id'] } struct Child { - id int @[primary; sql: serial] + id int @[primary; sql: serial] name string parent_id int babies []Baby @[fkey: 'child_id'] } struct Baby { - id int @[primary; sql: serial] + id int @[primary; sql: serial] name string child_id int } diff --git a/vlib/db/sqlite/sqlite.c.v b/vlib/db/sqlite/sqlite.c.v index 0f9a7afa91..df32a5c735 100644 --- a/vlib/db/sqlite/sqlite.c.v +++ b/vlib/db/sqlite/sqlite.c.v @@ -59,7 +59,7 @@ pub struct C.sqlite3_stmt { @[heap] pub struct Stmt { stmt &C.sqlite3_stmt = unsafe { nil } - db &DB = unsafe { nil } + db &DB = unsafe { nil } } struct SQLError { diff --git a/vlib/db/sqlite/sqlite_orm_test.v b/vlib/db/sqlite/sqlite_orm_test.v index 0811045933..b639ef3922 100644 --- a/vlib/db/sqlite/sqlite_orm_test.v +++ b/vlib/db/sqlite/sqlite_orm_test.v @@ -3,18 +3,18 @@ import db.sqlite import time struct TestCustomSqlType { - id int @[primary; sql: serial] - custom string @[sql_type: 'INTEGER'] - custom1 string @[sql_type: 'TEXT'] - custom2 string @[sql_type: 'REAL'] - custom3 string @[sql_type: 'NUMERIC'] + id int @[primary; sql: serial] + custom string @[sql_type: 'INTEGER'] + custom1 string @[sql_type: 'TEXT'] + custom2 string @[sql_type: 'REAL'] + custom3 string @[sql_type: 'NUMERIC'] custom4 string custom5 int custom6 time.Time } struct TestDefaultAttribute { - id string @[primary; sql: serial] + id string @[primary; sql: serial] name string created_at ?string @[default: 'CURRENT_TIME'] created_at1 ?string @[default: 'CURRENT_DATE'] diff --git a/vlib/db/sqlite/sqlite_test.v b/vlib/db/sqlite/sqlite_test.v index 26e44d9eaa..7b334fd16f 100644 --- a/vlib/db/sqlite/sqlite_test.v +++ b/vlib/db/sqlite/sqlite_test.v @@ -4,7 +4,7 @@ type Connection = sqlite.DB struct User { pub: - id int @[primary; sql: serial] + id int @[primary; sql: serial] name string } diff --git a/vlib/db/sqlite/vfs_lowlevel.c.v b/vlib/db/sqlite/vfs_lowlevel.c.v index c1b9aeaf38..eb1eda6ed6 100644 --- a/vlib/db/sqlite/vfs_lowlevel.c.v +++ b/vlib/db/sqlite/vfs_lowlevel.c.v @@ -52,9 +52,9 @@ pub type Sqlite3_vfs = C.sqlite3_vfs pub struct C.sqlite3_vfs { pub mut: // version 1 and later fields - iVersion int // Structure version number (currently 3) - szOsFile int // Size of subclassed sqlite3_file - mxPathname int // Maximum file pathname length + iVersion int // Structure version number (currently 3) + szOsFile int // Size of subclassed sqlite3_file + mxPathname int // Maximum file pathname length pNext &Sqlite3_vfs // Next registered VFS zName &char // Name of this virtual file system pAppData voidptr // Pointer to application-specific data diff --git a/vlib/dlmalloc/dlmalloc.v b/vlib/dlmalloc/dlmalloc.v index f608db2317..70123d3082 100644 --- a/vlib/dlmalloc/dlmalloc.v +++ b/vlib/dlmalloc/dlmalloc.v @@ -206,10 +206,10 @@ fn overhead_for(c &Chunk) usize { // Why not `interface?` Interfaces require memory allocation so it is simpler to pass a struct. pub struct Allocator { pub: - alloc fn (voidptr, usize) (voidptr, usize, u32) = unsafe { nil } + alloc fn (voidptr, usize) (voidptr, usize, u32) = unsafe { nil } remap fn (voidptr, voidptr, usize, usize, bool) voidptr = unsafe { nil } - free_part fn (voidptr, voidptr, usize, usize) bool = unsafe { nil } - free_ fn (voidptr, voidptr, usize) bool = unsafe { nil } + free_part fn (voidptr, voidptr, usize, usize) bool = unsafe { nil } + free_ fn (voidptr, voidptr, usize) bool = unsafe { nil } can_release_part fn (voidptr, u32) bool = unsafe { nil } allocates_zeros fn (voidptr) bool = unsafe { nil } page_size fn (voidptr) usize = unsafe { nil } // not a constant field because some platforms might have different page sizes depending on configs diff --git a/vlib/encoding/csv/csv_reader_random_access.v b/vlib/encoding/csv/csv_reader_random_access.v index f9d79fc060..e4e0b4005e 100644 --- a/vlib/encoding/csv/csv_reader_random_access.v +++ b/vlib/encoding/csv/csv_reader_random_access.v @@ -56,16 +56,16 @@ pub mut: end_line u8 = `\n` end_line_len int = csv.endline_cr_len // size of the endline rune \n = 1, \r\n = 2 - separator u8 = `,` // comma is the default separator - separator_len int = 1 // size of the separator rune - quote u8 = `"` // double quote is the standard quote char + separator u8 = `,` // comma is the default separator + separator_len int = 1 // size of the separator rune + quote u8 = `"` // double quote is the standard quote char quote_remove bool // if true clear the cell from the quotes comment u8 = `#` // every line that start with the quote char is ignored default_cell string = '*' // return this string if out of the csv boundaries empty_cell string = '#' // retunrn this if empty cell // ram buffer - mem_buf_type u32 // buffer type 0=File,1=RAM + mem_buf_type u32 // buffer type 0=File,1=RAM mem_buf voidptr // buffer used to load chars from file mem_buf_size i64 // size of the buffer mem_buf_start i64 = -1 // start index in the file of the read buffer @@ -74,7 +74,7 @@ pub mut: csv_map [][]i64 // header header_row int = -1 // row index of the header in the csv_map - header_list []HeaderItem // list of the header item + header_list []HeaderItem // list of the header item header_map map[string]int // map from header label to column index } @@ -92,8 +92,8 @@ pub: default_cell string = '*' // return this string if out of the csv boundaries empty_cell string // return this string if empty cell end_line_len int = csv.endline_cr_len // size of the endline rune - quote u8 = `"` // double quote is the standard quote char - quote_remove bool // if true clear the cell from the quotes + quote u8 = `"` // double quote is the standard quote char + quote_remove bool // if true clear the cell from the quotes } /****************************************************************************** diff --git a/vlib/encoding/csv/csv_reader_sequential.v b/vlib/encoding/csv/csv_reader_sequential.v index ea1325876b..adac909625 100644 --- a/vlib/encoding/csv/csv_reader_sequential.v +++ b/vlib/encoding/csv/csv_reader_sequential.v @@ -25,7 +25,7 @@ pub: default_cell string = '*' // return this string if out of the csv boundaries empty_cell string // return this string if empty cell end_line_len int = endline_cr_len // size of the endline rune - quote u8 = `"` // double quote is the standard quote char + quote u8 = `"` // double quote is the standard quote char } pub struct SequentialReader { @@ -41,16 +41,16 @@ pub mut: end_line u8 = `\n` end_line_len int = endline_cr_len // size of the endline rune \n = 1, \r\n = 2 - separator u8 = `,` // comma is the default separator - separator_len int = 1 // size of the separator rune - quote u8 = `"` // double quote is the standard quote char + separator u8 = `,` // comma is the default separator + separator_len int = 1 // size of the separator rune + quote u8 = `"` // double quote is the standard quote char comment u8 = `#` // every line that start with the quote char is ignored default_cell string = '*' // return this string if out of the csv boundaries empty_cell string = '#' // retunrn this if empty cell // ram buffer - mem_buf_type u32 // buffer type 0=File,1=RAM + mem_buf_type u32 // buffer type 0=File,1=RAM mem_buf voidptr // buffer used to load chars from file mem_buf_size i64 // size of the buffer mem_buf_start i64 = -1 // start index in the file of the read buffer diff --git a/vlib/encoding/xml/types.v b/vlib/encoding/xml/types.v index 830eaff562..2b7f25d249 100644 --- a/vlib/encoding/xml/types.v +++ b/vlib/encoding/xml/types.v @@ -17,7 +17,7 @@ pub: // other XML nodes, CDATA, plain text, or comments. pub struct XMLNode { pub: - name string @[required] + name string @[required] attributes map[string]string children []XMLNodeContents } @@ -56,7 +56,7 @@ pub: pub struct DocumentType { pub: - name string @[required] + name string @[required] dtd DTDInfo } diff --git a/vlib/flag/README.md b/vlib/flag/README.md index 4530c82a42..94c45a129d 100644 --- a/vlib/flag/README.md +++ b/vlib/flag/README.md @@ -42,9 +42,9 @@ import os @[version: '1.2.3'] @[name: 'app'] struct Config { - show_version bool @[short: v; xdoc: 'Show version and exit'] - debug_level int @[long: debug; short: d; xdoc: 'Debug level'] - level f32 @[only: l; xdoc: 'This doc text is overwritten'] + show_version bool @[short: v; xdoc: 'Show version and exit'] + debug_level int @[long: debug; short: d; xdoc: 'Debug level'] + level f32 @[only: l; xdoc: 'This doc text is overwritten'] example string square bool show_help bool @[long: help; short: h] diff --git a/vlib/flag/cmd_exe_style_flags_test.v b/vlib/flag/cmd_exe_style_flags_test.v index ca6f585183..e44369503f 100644 --- a/vlib/flag/cmd_exe_style_flags_test.v +++ b/vlib/flag/cmd_exe_style_flags_test.v @@ -15,8 +15,8 @@ struct Config { paths []string @[tail] not_mapped string = 'not changed' e bool - b bool @[long: Dev; only: d] - u string @[short: c] + b bool @[long: Dev; only: d] + u string @[short: c] } fn test_cmd_exe() { diff --git a/vlib/flag/flag_to.v b/vlib/flag/flag_to.v index 2e09fdc581..edf272a269 100644 --- a/vlib/flag/flag_to.v +++ b/vlib/flag/flag_to.v @@ -1,8 +1,8 @@ module flag struct FlagData { - raw string @[required] - field_name string @[required] + raw string @[required] + field_name string @[required] delimiter string name string arg ?string @@ -28,7 +28,7 @@ pub enum Style { } struct StructInfo { - name string // name of the struct itself + name string // name of the struct itself attrs map[string]string // collection of `@[x: y]` sat on the struct, read via reflection fields map[string]StructField } @@ -72,7 +72,7 @@ fn (sf StructField) shortest_match_name() ?string { @[params] pub struct ParseConfig { pub: - delimiter string = '-' // delimiter used for flags + delimiter string = '-' // delimiter used for flags style Style = .short_long // expected flag style stop ?string // single, usually '--', string that stops parsing flags/options skip u16 // skip this amount in the input argument array, usually `1` for skipping executable or subcmd entry @@ -81,7 +81,7 @@ pub: @[params] pub struct DocConfig { pub: - delimiter string = '-' // delimiter used for flags + delimiter string = '-' // delimiter used for flags style Style = .short_long // expected flag style pub mut: name string // application name diff --git a/vlib/flag/flag_to_doc_test.v b/vlib/flag/flag_to_doc_test.v index b26cb0f3ca..4b5489c372 100644 --- a/vlib/flag/flag_to_doc_test.v +++ b/vlib/flag/flag_to_doc_test.v @@ -153,13 +153,13 @@ Footer content' @[name: 'flag_to_doc_test'] @[version: '1.0'] struct DocTest { - show_version bool @[short: v; xdoc: 'Show version and exit'] - debug_level int @[long: debug; short: d; xdoc: 'Debug level'] - level f32 @[only: l; xdoc: 'Override this doc string'] + show_version bool @[short: v; xdoc: 'Show version and exit'] + debug_level int @[long: debug; short: d; xdoc: 'Debug level'] + level f32 @[only: l; xdoc: 'Override this doc string'] example string square bool - multi int @[only: m; repeats] - wroom []int @[short: w] + multi int @[only: m; repeats] + wroom []int @[short: w] the_limit string } diff --git a/vlib/flag/flag_to_misc_test.v b/vlib/flag/flag_to_misc_test.v index 7273317b4b..00ea6b4b85 100644 --- a/vlib/flag/flag_to_misc_test.v +++ b/vlib/flag/flag_to_misc_test.v @@ -28,9 +28,9 @@ struct Config { device []string @[short: d] paths []string @[tail] amount int = 1 - verbosity int @[repeats; short: v] - show_version bool @[long: version] - no_long_beef bool @[only: n] + verbosity int @[repeats; short: v] + show_version bool @[long: version] + no_long_beef bool @[only: n] } struct LongConfig { @@ -39,7 +39,7 @@ struct LongConfig { some_test string = 'abc' @[long: test] path string @[tail] amount int = 1 - show_version bool @[long: version] + show_version bool @[long: version] } struct IgnoreConfig { diff --git a/vlib/flag/go_flag_style_flags_test.v b/vlib/flag/go_flag_style_flags_test.v index 02c4d28440..5666beb1ec 100644 --- a/vlib/flag/go_flag_style_flags_test.v +++ b/vlib/flag/go_flag_style_flags_test.v @@ -9,9 +9,9 @@ const exe_and_go_flag_args_with_tail = ['/path/to/exe', '-version', '--flag', '- struct Prefs { flag bool flag_value string - version bool @[short: v] - is_live bool @[long: live] - is_done bool @[long: done] + version bool @[short: v] + is_live bool @[long: live] + is_done bool @[long: done] test string defines []string @[long: define; short: d] tail []string @[tail] diff --git a/vlib/flag/posix_style_flags_test.v b/vlib/flag/posix_style_flags_test.v index 8120903868..69c44b6dc4 100644 --- a/vlib/flag/posix_style_flags_test.v +++ b/vlib/flag/posix_style_flags_test.v @@ -21,8 +21,8 @@ struct Config { verbosity int @[repeats; short: v] not_mapped string = 'not changed' x bool - b bool @[only: y] - u int @[short: z] + b bool @[only: y] + u int @[short: z] } fn test_pure_posix_short() { diff --git a/vlib/flag/v_style_flags_test.v b/vlib/flag/v_style_flags_test.v index c8ca7a4847..8af79f09f3 100644 --- a/vlib/flag/v_style_flags_test.v +++ b/vlib/flag/v_style_flags_test.v @@ -7,9 +7,9 @@ const exe_and_v_args_with_tail = ['/path/to/exe', '-version', '-d', 'ident=val', '-done', '-d', 'two', '-live', 'run', '/path/to'] struct Prefs { - version bool @[short: v] - is_live bool @[long: live] - is_done bool @[long: done] + version bool @[short: v] + is_live bool @[long: live] + is_done bool @[long: done] test string defines []string @[long: define; short: d] tail []string @[tail] diff --git a/vlib/gg/gg.c.v b/vlib/gg/gg.c.v index fa445f54c6..5a260a5b71 100644 --- a/vlib/gg/gg.c.v +++ b/vlib/gg/gg.c.v @@ -84,28 +84,28 @@ pub: resized_fn FNEvent = unsafe { nil } // Called once when the window has changed its size. scroll_fn FNEvent = unsafe { nil } // Called while the user is scrolling. The direction of scrolling is indicated by either 1 or -1. // wait_events bool // set this to true for UIs, to save power - fullscreen bool // set this to true, if you want your window to start in fullscreen mode (suitable for games/demos/screensavers) + fullscreen bool // set this to true, if you want your window to start in fullscreen mode (suitable for games/demos/screensavers) scale f32 = 1.0 - sample_count int // bigger values usually have performance impact, but can produce smoother/antialiased lines, if you draw lines or polygons (2 is usually good enough) + sample_count int // bigger values usually have performance impact, but can produce smoother/antialiased lines, if you draw lines or polygons (2 is usually good enough) swap_interval int = 1 // 1 = 60fps, 2 = 30fps etc. The preferred swap interval (ignored on some platforms) // ved needs this // init_text bool font_path string custom_bold_font_path string - ui_mode bool // refreshes only on events to save CPU usage + ui_mode bool // refreshes only on events to save CPU usage // font bytes for embedding font_bytes_normal []u8 font_bytes_bold []u8 font_bytes_mono []u8 font_bytes_italic []u8 - native_rendering bool // Cocoa on macOS/iOS, GDI+ on Windows + native_rendering bool // Cocoa on macOS/iOS, GDI+ on Windows // drag&drop enable_dragndrop bool // enable file dropping (drag'n'drop), default is false - max_dropped_files int = 1 // max number of dropped files to process (default: 1) + max_dropped_files int = 1 // max number of dropped files to process (default: 1) max_dropped_file_path_length int = 2048 // max length in bytes of a dropped UTF-8 file path (default: 2048) // min_width int // desired minimum width of the window - min_height int // desired minimum height of the window + min_height int // desired minimum height of the window } @[heap] @@ -179,8 +179,8 @@ pub mut: scroll_x int scroll_y int // - key_modifiers Modifier // the current key modifiers - key_repeat bool // whether the pressed key was an autorepeated one + key_modifiers Modifier // the current key modifiers + key_repeat bool // whether the pressed key was an autorepeated one pressed_keys [key_code_max]bool // an array representing all currently pressed keys pressed_keys_edge [key_code_max]bool // true when the previous state of pressed_keys, // *before* the current event was different diff --git a/vlib/gg/gg.js.v b/vlib/gg/gg.js.v index 46383a9712..d6251d86fe 100644 --- a/vlib/gg/gg.js.v +++ b/vlib/gg/gg.js.v @@ -249,9 +249,9 @@ pub: font_bytes_italic []u8 native_rendering bool // Cocoa on macOS/iOS, GDI+ on Windows // drag&drop - enable_dragndrop bool // enable file dropping (drag'n'drop), default is false - max_dropped_files int = 1 // max number of dropped files to process (default: 1) - max_dropped_file_path_length int = 2048 // max length in bytes of a dropped UTF-8 file path (default: 2048) + enable_dragndrop bool // enable file dropping (drag'n'drop), default is false + max_dropped_files int = 1 // max number of dropped files to process (default: 1) + max_dropped_file_path_length int = 2048 // max length in bytes of a dropped UTF-8 file path (default: 2048) html5_canvas_name string = 'canvas' // the id/name of the canvas element, that will be used to render GG apps } @@ -271,7 +271,7 @@ pub mut: scale f32 = 1.0 width int height int - window JS.Window @[noinit] + window JS.Window @[noinit] config Config user_data voidptr ui_mode bool @@ -285,8 +285,8 @@ pub mut: scroll_x int scroll_y int // - key_modifiers Modifier // the current key modifiers - key_repeat bool // whether the pressed key was an autorepeated one + key_modifiers Modifier // the current key modifiers + key_repeat bool // whether the pressed key was an autorepeated one pressed_keys [key_code_max]bool // an array representing all currently pressed keys pressed_keys_edge [key_code_max]bool // true when the previous state of pressed_keys, context JS.CanvasRenderingContext2D @[noinit] diff --git a/vlib/gg/gg.v b/vlib/gg/gg.v index 6924d15f18..e738da6733 100644 --- a/vlib/gg/gg.v +++ b/vlib/gg/gg.v @@ -29,7 +29,7 @@ pub struct PenConfig { pub: color gx.Color line_type PenLineType = .solid - thickness int = 1 + thickness int = 1 } pub struct Size { diff --git a/vlib/gg/image.c.v b/vlib/gg/image.c.v index 2a1cbdc49a..673218b292 100644 --- a/vlib/gg/image.c.v +++ b/vlib/gg/image.c.v @@ -279,8 +279,8 @@ pub: wrap_v gfx.Wrap = .clamp_to_edge min_filter gfx.Filter = .linear mag_filter gfx.Filter = .linear - num_mipmaps int = 1 - num_slices int = 1 + num_mipmaps int = 1 + num_slices int = 1 } // draw_image_with_config takes in a config that details how the diff --git a/vlib/gg/image.v b/vlib/gg/image.v index f0c9c1e732..36e6918783 100644 --- a/vlib/gg/image.v +++ b/vlib/gg/image.v @@ -14,7 +14,7 @@ pub mut: img_id int img_rect Rect // defines the size and position on image when rendering to the screen part_rect Rect // defines the size and position of part of the image to use when rendering - rotate f32 @[deprecated: 'use `rotation` instead of `rotate`'; deprecated_after: '2024-07-30'] + rotate f32 @[deprecated: 'use `rotation` instead of `rotate`'; deprecated_after: '2024-07-30'] z f32 color gx.Color = gx.white effect ImageEffect = .alpha diff --git a/vlib/gg/text_rendering.c.v b/vlib/gg/text_rendering.c.v index 27e37b1e34..b4847c2a8e 100644 --- a/vlib/gg/text_rendering.c.v +++ b/vlib/gg/text_rendering.c.v @@ -171,8 +171,8 @@ pub: y int text string - color Color = gx.black - size int = 16 + color Color = gx.black + size int = 16 align gx.HorizontalAlign = .left vertical_align gx.VerticalAlign = .top max_width int diff --git a/vlib/gx/text.v b/vlib/gx/text.v index 8a450a57a2..2a794e6c93 100644 --- a/vlib/gx/text.v +++ b/vlib/gx/text.v @@ -7,8 +7,8 @@ pub const align_right = HorizontalAlign.right @[params] pub struct TextCfg { pub: - color Color = black - size int = 16 + color Color = black + size int = 16 align HorizontalAlign = .left vertical_align VerticalAlign = .top max_width int diff --git a/vlib/io/buffered_reader.v b/vlib/io/buffered_reader.v index d219ce49ae..ff354bcde4 100644 --- a/vlib/io/buffered_reader.v +++ b/vlib/io/buffered_reader.v @@ -19,7 +19,7 @@ pub struct BufferedReaderConfig { pub: reader Reader cap int = 128 * 1024 // large for fast reading of big(ish) files - retries int = 2 // how many times to retry before assuming the stream ended + retries int = 2 // how many times to retry before assuming the stream ended } // BufferedReadLineConfig are options that can be given to the read_line() function. diff --git a/vlib/json/README.md b/vlib/json/README.md index 0a27b4ddfe..c9538d2273 100644 --- a/vlib/json/README.md +++ b/vlib/json/README.md @@ -22,11 +22,11 @@ enum JobTitle { struct Employee { mut: name string - family string @[json: '-'] // this field will be skipped + family string @[json: '-'] // this field will be skipped age int salary f32 title JobTitle @[json: 'ETitle'] // the key for this field will be 'ETitle', not 'title' - notes string @[omitempty] // the JSON property is not created if the string is equal to '' (an empty string). + notes string @[omitempty] // the JSON property is not created if the string is equal to '' (an empty string). // TODO: document @[raw] } diff --git a/vlib/json/json_encode_recursive_ptr_test.v b/vlib/json/json_encode_recursive_ptr_test.v index 7836cd5aec..69284f00b1 100644 --- a/vlib/json/json_encode_recursive_ptr_test.v +++ b/vlib/json/json_encode_recursive_ptr_test.v @@ -4,8 +4,8 @@ struct PostTag { id string parent ?&PostTag visibility string - created_at string @[json: 'createdAt'] - metadata string @[raw] + created_at string @[json: 'createdAt'] + metadata string @[raw] } fn test_main() { diff --git a/vlib/json/json_generic_array_test.v b/vlib/json/json_generic_array_test.v index cc4c0c858c..9c09341a8a 100644 --- a/vlib/json/json_generic_array_test.v +++ b/vlib/json/json_generic_array_test.v @@ -9,7 +9,7 @@ pub: skip ?int fields ?[]string // This breaks the compiler when encoding to JSON conflicts ?bool - read_quorum ?int @[json: r] + read_quorum ?int @[json: r] update ?bool stable ?bool stale ?string diff --git a/vlib/json/json_test.v b/vlib/json/json_test.v index c0699a34b6..e00976e7e5 100644 --- a/vlib/json/json_test.v +++ b/vlib/json/json_test.v @@ -449,7 +449,7 @@ fn test_pretty() { struct Foo3 { name string - age int @[omitempty] + age int @[omitempty] } fn test_omit_empty() { diff --git a/vlib/log/log.v b/vlib/log/log.v index fa85081b1c..6d38b84626 100644 --- a/vlib/log/log.v +++ b/vlib/log/log.v @@ -34,7 +34,7 @@ mut: time_format TimeFormat custom_time_format string = 'MMMM Do YY N kk:mm:ss A' // timestamp with custom format short_tag bool - always_flush bool // flush after every single .fatal(), .error(), .warn(), .info(), .debug() call + always_flush bool // flush after every single .fatal(), .error(), .warn(), .info(), .debug() call pub mut: output_file_name string // log output to this file } diff --git a/vlib/net/http/file/static_server.v b/vlib/net/http/file/static_server.v index 1f6ffbc8db..864a880e49 100644 --- a/vlib/net/http/file/static_server.v +++ b/vlib/net/http/file/static_server.v @@ -10,10 +10,10 @@ import net.http.mime @[params] pub struct StaticServeParams { pub mut: - folder string = '.' // the folder, that will be used as a base for serving all static resources; If it was /tmp, then: http://localhost:4001/x.txt => /tmp/x.txt - index_file string = 'index.html' // A request for http://localhost:4001/ will map to index.html, if that file is present. - auto_index bool = true // when an index_file is *not* present, a request for http://localhost:4001/ will list automatically all files in the folder. - filter_myexe bool = true // whether to filter the name of the static file executable from the automatic folder listings for / . Useful with `v -e 'import net.http.file; file.serve()'` + folder string = '.' // the folder, that will be used as a base for serving all static resources; If it was /tmp, then: http://localhost:4001/x.txt => /tmp/x.txt + index_file string = 'index.html' // A request for http://localhost:4001/ will map to index.html, if that file is present. + auto_index bool = true // when an index_file is *not* present, a request for http://localhost:4001/ will list automatically all files in the folder. + filter_myexe bool = true // whether to filter the name of the static file executable from the automatic folder listings for / . Useful with `v -e 'import net.http.file; file.serve()'` on string = 'localhost:4001' // on which address:port to listen for http requests workers int = runtime.nr_jobs() // how many worker threads to use for serving the responses, by default it is limited to the number of available cores; can be controlled with setting VJOBS shutdown_after time.Duration = time.infinite // after this time has passed, the webserver will gracefully shutdown on its own diff --git a/vlib/net/http/http.v b/vlib/net/http/http.v index 55fa2b330f..32c83a0a8f 100644 --- a/vlib/net/http/http.v +++ b/vlib/net/http/http.v @@ -31,7 +31,7 @@ pub mut: cert_key string // the path to a key.pem file, containing private keys for the client certificate(s) in_memory_verification bool // if true, verify, cert, and cert_key are read from memory, not from a file allow_redirect bool = true // whether to allow redirect - max_retries int = 5 // maximum number of retries required when an underlying socket error occurs + max_retries int = 5 // maximum number of retries required when an underlying socket error occurs // callbacks to allow custom reporting code to run, while the request is running, and to implement streaming on_redirect RequestRedirectFn = unsafe { nil } on_progress RequestProgressFn = unsafe { nil } diff --git a/vlib/net/http/request.v b/vlib/net/http/request.v index bf31c62830..4b992b1ed7 100644 --- a/vlib/net/http/request.v +++ b/vlib/net/http/request.v @@ -44,7 +44,7 @@ pub mut: cert_key string in_memory_verification bool // if true, verify, cert, and cert_key are read from memory, not from a file allow_redirect bool = true // whether to allow redirect - max_retries int = 5 // maximum number of retries required when an underlying socket error occurs + max_retries int = 5 // maximum number of retries required when an underlying socket error occurs // callbacks to allow custom reporting code to run, while the request is running, and to implement streaming on_redirect RequestRedirectFn = unsafe { nil } on_progress RequestProgressFn = unsafe { nil } diff --git a/vlib/net/http/server.v b/vlib/net/http/server.v index 1d3a52a53d..29d8dac5b3 100644 --- a/vlib/net/http/server.v +++ b/vlib/net/http/server.v @@ -29,14 +29,14 @@ pub struct Server { mut: state ServerStatus = .closed pub mut: - addr string = ':${http.default_server_port}' - port int = http.default_server_port @[deprecated: 'use addr'] + addr string = ':${http.default_server_port}' + port int = http.default_server_port @[deprecated: 'use addr'] handler Handler = DebugHandler{} read_timeout time.Duration = 30 * time.second write_timeout time.Duration = 30 * time.second accept_timeout time.Duration = 30 * time.second - pool_channel_slots int = 1024 - worker_num int = runtime.nr_jobs() + pool_channel_slots int = 1024 + worker_num int = runtime.nr_jobs() listener net.TcpListener // on_running fn (mut s Server) = unsafe { nil } // Blocking cb. If set, ran by the web server on transitions to its .running state. @@ -145,7 +145,7 @@ pub fn (s &Server) status() ServerStatus { pub struct WaitTillRunningParams { pub: max_retries int = 100 // how many times to check for the status, for each single s.wait_till_running() call - retry_period_ms int = 10 // how much time to wait between each check for the status, in milliseconds + retry_period_ms int = 10 // how much time to wait between each check for the status, in milliseconds } // wait_till_running allows you to synchronise your calling (main) thread, with the state of the server diff --git a/vlib/net/urllib/urllib.v b/vlib/net/urllib/urllib.v index 4ed8bb6b25..a0337d568d 100644 --- a/vlib/net/urllib/urllib.v +++ b/vlib/net/urllib/urllib.v @@ -317,14 +317,14 @@ fn escape(s string, mode EncodingMode) string { pub struct URL { pub mut: scheme string - opaque string // encoded opaque data + opaque string // encoded opaque data user &Userinfo = unsafe { nil } // username and password information - host string // host or host:port - path string // path (relative paths may omit leading slash) - raw_path string // encoded path hint (see escaped_path method) - force_query bool // append a query ('?') even if raw_query is empty - raw_query string // encoded query values, without '?' - fragment string // fragment for references, without '#' + host string // host or host:port + path string // path (relative paths may omit leading slash) + raw_path string // encoded path hint (see escaped_path method) + force_query bool // append a query ('?') even if raw_query is empty + raw_query string // encoded query values, without '?' + fragment string // fragment for references, without '#' } // debug returns a string representation of *ALL* the fields of the given URL diff --git a/vlib/net/websocket/websocket_client.v b/vlib/net/websocket/websocket_client.v index 27a4c17000..e976210edb 100644 --- a/vlib/net/websocket/websocket_client.v +++ b/vlib/net/websocket/websocket_client.v @@ -24,8 +24,8 @@ pub struct Client { is_server bool mut: ssl_conn &ssl.SSLConn = unsafe { nil } // secure connection used when wss is used - flags []Flag // flags used in handshake - fragments []Fragment // current fragments + flags []Flag // flags used in handshake + fragments []Fragment // current fragments message_callbacks []MessageEventHandler // all callbacks on_message error_callbacks []ErrorEventHandler // all callbacks on_error open_callbacks []OpenEventHandler // all callbacks on_open @@ -37,10 +37,10 @@ pub: read_timeout i64 write_timeout i64 pub mut: - header http.Header // headers that will be passed when connecting + header http.Header // headers that will be passed when connecting conn &net.TcpConn = unsafe { nil } // underlying TCP socket connection - nonce_size int = 16 // size of nounce used for masking - panic_on_callback bool // set to true of callbacks can panic + nonce_size int = 16 // size of nounce used for masking + panic_on_callback bool // set to true of callbacks can panic client_state shared ClientState // current state of connection // logger used to log messages logger &log.Logger = default_logger @@ -83,8 +83,8 @@ pub enum OPCode { @[params] pub struct ClientOpt { pub: - read_timeout i64 = 30 * time.second - write_timeout i64 = 30 * time.second + read_timeout i64 = 30 * time.second + write_timeout i64 = 30 * time.second logger &log.Logger = default_logger } diff --git a/vlib/net/websocket/websocket_server.v b/vlib/net/websocket/websocket_server.v index c67f379d67..558b6034f0 100644 --- a/vlib/net/websocket/websocket_server.v +++ b/vlib/net/websocket/websocket_server.v @@ -8,7 +8,7 @@ import rand pub struct ServerState { mut: - ping_interval int = 30 // interval for sending ping to clients (seconds) + ping_interval int = 30 // interval for sending ping to clients (seconds) state State = .closed // current state of connection pub mut: clients map[string]&ServerClient // clients connected to this server diff --git a/vlib/orm/orm_custom_operators_test.v b/vlib/orm/orm_custom_operators_test.v index 3156a3ece3..df12941775 100644 --- a/vlib/orm/orm_custom_operators_test.v +++ b/vlib/orm/orm_custom_operators_test.v @@ -3,7 +3,7 @@ import db.sqlite struct User { - id int @[primary; sql: serial] + id int @[primary; sql: serial] name string country string } diff --git a/vlib/orm/orm_fk_test.v b/vlib/orm/orm_fk_test.v index 62cbb39d0e..8ce7613070 100644 --- a/vlib/orm/orm_fk_test.v +++ b/vlib/orm/orm_fk_test.v @@ -3,7 +3,7 @@ import db.sqlite struct Person { - id int @[primary; sql: serial] + id int @[primary; sql: serial] age int brothers []Brother @[fkey: 'person_id'] sisters []Sister @[fkey: 'person_id'] @@ -11,13 +11,13 @@ struct Person { } struct Brother { - id int @[primary; sql: serial] + id int @[primary; sql: serial] person_id int name string } struct Sister { - id int @[primary; sql: serial] + id int @[primary; sql: serial] person_id int name string } diff --git a/vlib/orm/orm_fn_calls_test.v b/vlib/orm/orm_fn_calls_test.v index e408b0ad2f..3a94f49f17 100644 --- a/vlib/orm/orm_fn_calls_test.v +++ b/vlib/orm/orm_fn_calls_test.v @@ -3,7 +3,7 @@ import db.sqlite struct User { - id int @[primary; sql: serial] + id int @[primary; sql: serial] name string age int } diff --git a/vlib/orm/orm_insert_reserved_name_test.v b/vlib/orm/orm_insert_reserved_name_test.v index 7138d07487..b0d7651bfb 100644 --- a/vlib/orm/orm_insert_reserved_name_test.v +++ b/vlib/orm/orm_insert_reserved_name_test.v @@ -4,7 +4,7 @@ import db.sqlite @[table: 'bad_table'] struct Bad { - id int @[primary; sql: serial] + id int @[primary; sql: serial] link string } diff --git a/vlib/orm/orm_insert_test.v b/vlib/orm/orm_insert_test.v index 9498b32c9b..9ae5326327 100644 --- a/vlib/orm/orm_insert_test.v +++ b/vlib/orm/orm_insert_test.v @@ -4,7 +4,7 @@ import db.sqlite import rand struct Parent { - id int @[primary; sql: serial] + id int @[primary; sql: serial] name string children []Child @[fkey: 'parent_id'] notes []Note @[fkey: 'owner_id'] @@ -12,14 +12,14 @@ struct Parent { struct Child { mut: - id int @[primary; sql: serial] + id int @[primary; sql: serial] parent_id int name string } struct Note { mut: - id int @[primary; sql: serial] + id int @[primary; sql: serial] owner_id int text string } @@ -52,7 +52,7 @@ struct Entity { } struct EntityWithFloatPrimary { - id f64 @[primary] + id f64 @[primary] name string } @@ -398,7 +398,7 @@ fn test_orm_insert_with_child_element_and_no_table() { @[table: 'customers'] struct Customer { - id i64 @[primary; sql: serial] + id i64 @[primary; sql: serial] name string } diff --git a/vlib/orm/orm_interface_test.v b/vlib/orm/orm_interface_test.v index 14c6b3ca01..7a7041f7fb 100644 --- a/vlib/orm/orm_interface_test.v +++ b/vlib/orm/orm_interface_test.v @@ -4,7 +4,7 @@ import db.sqlite import orm struct User { - id int @[primary; sql: serial] + id int @[primary; sql: serial] name string } diff --git a/vlib/orm/orm_last_id_test.v b/vlib/orm/orm_last_id_test.v index 680d021e7f..dfb74cfd33 100644 --- a/vlib/orm/orm_last_id_test.v +++ b/vlib/orm/orm_last_id_test.v @@ -3,7 +3,7 @@ import db.sqlite struct User { - id int @[primary; sql: serial] + id int @[primary; sql: serial] name string } diff --git a/vlib/orm/orm_mut_db_test.v b/vlib/orm/orm_mut_db_test.v index be7c46b6ce..63e7258612 100644 --- a/vlib/orm/orm_mut_db_test.v +++ b/vlib/orm/orm_mut_db_test.v @@ -3,7 +3,7 @@ import db.sqlite struct User { - id int @[primary; sql: serial] + id int @[primary; sql: serial] name string } diff --git a/vlib/orm/orm_null_test.v b/vlib/orm/orm_null_test.v index 27dec5ed07..08f4d687dc 100644 --- a/vlib/orm/orm_null_test.v +++ b/vlib/orm/orm_null_test.v @@ -101,7 +101,7 @@ fn (db MockDB) last_id() int { @[table: 'foo'] struct Foo { mut: - id u64 @[primary; sql: serial] + id u64 @[primary; sql: serial] a string // b string [default: '"yes"'] c ?string @@ -222,7 +222,7 @@ fn test_option_struct_fields_and_none() { } struct Bar { - id u64 @[primary; sql: serial] + id u64 @[primary; sql: serial] name ?string age int } diff --git a/vlib/orm/orm_option_time_test.v b/vlib/orm/orm_option_time_test.v index d8c675e133..ea3265474c 100644 --- a/vlib/orm/orm_option_time_test.v +++ b/vlib/orm/orm_option_time_test.v @@ -5,16 +5,16 @@ import time @[table: 'foos'] struct Foo { - id int @[primary; sql: serial] + id int @[primary; sql: serial] name string - created_at time.Time @[default: 'CURRENT_TIME'] - updated_at ?string @[sql_type: 'TIMESTAMP'] + created_at time.Time @[default: 'CURRENT_TIME'] + updated_at ?string @[sql_type: 'TIMESTAMP'] deleted_at ?time.Time - children []Child @[fkey: 'parent_id'] + children []Child @[fkey: 'parent_id'] } struct Child { - id int @[primary; sql: serial] + id int @[primary; sql: serial] parent_id int name string } diff --git a/vlib/orm/orm_references_test.v b/vlib/orm/orm_references_test.v index efc1a4c04c..08e42510b1 100644 --- a/vlib/orm/orm_references_test.v +++ b/vlib/orm/orm_references_test.v @@ -10,7 +10,7 @@ struct Boat { } struct Color { - id int @[primary; sql: serial] + id int @[primary; sql: serial] hex string } diff --git a/vlib/orm/orm_result_test.v b/vlib/orm/orm_result_test.v index 23bff71a35..98335368ed 100644 --- a/vlib/orm/orm_result_test.v +++ b/vlib/orm/orm_result_test.v @@ -3,12 +3,12 @@ import db.sqlite struct Account { - id int @[primary; sql: serial] + id int @[primary; sql: serial] name string } struct Note { - id int @[primary; sql: serial] + id int @[primary; sql: serial] content string } diff --git a/vlib/orm/orm_string_interpolation_in_where_test.v b/vlib/orm/orm_string_interpolation_in_where_test.v index 886586f0dd..1f0b76b927 100644 --- a/vlib/orm/orm_string_interpolation_in_where_test.v +++ b/vlib/orm/orm_string_interpolation_in_where_test.v @@ -3,7 +3,7 @@ import db.sqlite struct User { - id int @[primary; sql: serial] + id int @[primary; sql: serial] name string } diff --git a/vlib/orm/orm_test.v b/vlib/orm/orm_test.v index 52b9ae55dc..91c062d80e 100644 --- a/vlib/orm/orm_test.v +++ b/vlib/orm/orm_test.v @@ -8,7 +8,7 @@ import db.sqlite const offset_const = 2 struct Module { - id int @[primary; sql: serial] + id int @[primary; sql: serial] name string nr_downloads int test_id u64 @@ -18,9 +18,9 @@ struct Module { @[table: 'userlist'] struct User { - id int @[primary; sql: serial] + id int @[primary; sql: serial] age int - name string @[sql: 'username'] + name string @[sql: 'username'] is_customer bool skipped_string string @[skip] skipped_string2 string @[sql: '-'] @@ -33,7 +33,7 @@ struct Foo { } struct TestTime { - id int @[primary; sql: serial] + id int @[primary; sql: serial] create time.Time } diff --git a/vlib/os/os_android_outside_termux.c.v b/vlib/os/os_android_outside_termux.c.v index 84acd4f234..fef1c4b86b 100644 --- a/vlib/os/os_android_outside_termux.c.v +++ b/vlib/os/os_android_outside_termux.c.v @@ -15,8 +15,8 @@ pub enum AssetMode { pub struct C.ANativeActivity { pub: assetManager &AssetManager = unsafe { nil } // Pointer to the Asset Manager instance for the application. - clazz voidptr // (jobject) The NativeActivity object handle. - env voidptr // (JNIEnv *) JNI context for the main thread of the app. + clazz voidptr // (jobject) The NativeActivity object handle. + env voidptr // (JNIEnv *) JNI context for the main thread of the app. externalDataPath &char // Path to this application's external (removable/mountable) data directory. instance voidptr // This is the native instance of the application. internalDataPath &char // Path to this application's internal data directory. diff --git a/vlib/os/process.v b/vlib/os/process.v index 3e447854cf..9052c5d299 100644 --- a/vlib/os/process.v +++ b/vlib/os/process.v @@ -18,13 +18,13 @@ pub enum ProcessState { @[heap] pub struct Process { pub mut: - filename string // the process's command file path - pid int // the PID of the process - code int = -1 // the exit code of the process, != -1 *only* when status is .exited *and* the process was not aborted + filename string // the process's command file path + pid int // the PID of the process + code int = -1 // the exit code of the process, != -1 *only* when status is .exited *and* the process was not aborted status ProcessState = .not_started // the current status of the process - err string // if the process fails, contains the reason why - args []string // the arguments that the command takes - work_folder string // the initial working folder of the process. When '', reuse the same folder as the parent process. + err string // if the process fails, contains the reason why + args []string // the arguments that the command takes + work_folder string // the initial working folder of the process. When '', reuse the same folder as the parent process. env_is_custom bool // true, when the environment was customized with .set_environment env []string // the environment with which the process was started (list of 'var=val') use_stdio_ctl bool // when true, then you can use p.stdin_write(), p.stdout_slurp() and p.stderr_slurp() diff --git a/vlib/picoev/picoev.v b/vlib/picoev/picoev.v index c52643a514..0a42c7eb3d 100644 --- a/vlib/picoev/picoev.v +++ b/vlib/picoev/picoev.v @@ -44,15 +44,15 @@ pub mut: pub struct Config { pub: port int = 8080 - cb fn (voidptr, picohttpparser.Request, mut picohttpparser.Response) = unsafe { nil } + cb fn (voidptr, picohttpparser.Request, mut picohttpparser.Response) = unsafe { nil } err_cb fn (voidptr, picohttpparser.Request, mut picohttpparser.Response, IError) = default_error_callback raw_cb fn (mut Picoev, int, int) = unsafe { nil } - user_data voidptr = unsafe { nil } - timeout_secs int = 8 - max_headers int = 100 - max_read int = 4096 - max_write int = 8192 - family net.AddrFamily = .ip6 + user_data voidptr = unsafe { nil } + timeout_secs int = 8 + max_headers int = 100 + max_read int = 4096 + max_write int = 8192 + family net.AddrFamily = .ip6 host string } @@ -60,7 +60,7 @@ pub: // Contains event loop, file descriptor table, timeouts, buffers, and configuration. @[heap] pub struct Picoev { - cb fn (voidptr, picohttpparser.Request, mut picohttpparser.Response) = unsafe { nil } + cb fn (voidptr, picohttpparser.Request, mut picohttpparser.Response) = unsafe { nil } error_callback fn (voidptr, picohttpparser.Request, mut picohttpparser.Response, IError) = default_error_callback raw_callback fn (mut Picoev, int, int) = unsafe { nil } @@ -70,7 +70,7 @@ pub struct Picoev { max_write int = 8192 err_cb fn (voidptr, picohttpparser.Request, mut picohttpparser.Response, IError) = default_error_callback @[deprecated: 'use `error_callback` instead'] - raw_cb fn (mut Picoev, int, int) = unsafe { nil } @[deprecated: 'use `raw_callback` instead'] + raw_cb fn (mut Picoev, int, int) = unsafe { nil } @[deprecated: 'use `raw_callback` instead'] mut: loop &LoopType = unsafe { nil } file_descriptors [max_fds]&Target diff --git a/vlib/readline/readline.v b/vlib/readline/readline.v index 8636d53b1b..ee075a3e89 100644 --- a/vlib/readline/readline.v +++ b/vlib/readline/readline.v @@ -23,8 +23,8 @@ pub struct Readline { pub mut: is_raw bool orig_termios termios.Termios // Linux - current []rune // Line being edited - cursor int // Cursor position + current []rune // Line being edited + cursor int // Cursor position overwrite bool cursor_row_offset int prompt string diff --git a/vlib/regex/regex.v b/vlib/regex/regex.v index a550ba5464..f4af0ff029 100644 --- a/vlib/regex/regex.v +++ b/vlib/regex/regex.v @@ -295,7 +295,7 @@ pub mut: prog_len int // regex program len // char classes storage cc []CharClass // char class list - cc_index int // index + cc_index int // index // groups group_count int // number of groups in this regex struct groups []int // groups index results @@ -314,7 +314,7 @@ pub mut: // flags flag int // flag for optional parameters // Debug/log - debug int // enable in order to have the unroll of the code 0 = NO_DEBUG, 1 = LIGHT 2 = VERBOSE + debug int // enable in order to have the unroll of the code 0 = NO_DEBUG, 1 = LIGHT 2 = VERBOSE log_func FnLog = simple_log // log function, can be customized by the user query string // query string } @@ -375,7 +375,7 @@ fn (mut re RE) reset_src() { * ******************************************************************************/ struct BslsStruct { - ch rune // meta char + ch rune // meta char validator FnValidator = unsafe { nil } // validator function pointer } @@ -525,9 +525,9 @@ const cc_end = 4 struct CharClass { mut: - cc_type int // type of cc token - ch0 rune // first char of the interval a-b a in this case - ch1 rune // second char of the interval a-b b in this case + cc_type int // type of cc token + ch0 rune // first char of the interval a-b a in this case + ch1 rune // second char of the interval a-b b in this case validator FnValidator = unsafe { nil } // validator function pointer } @@ -1812,7 +1812,7 @@ pub mut: first_match int = -1 // index of the first match pc int = -1 // program counter i int = -1 // source string index - char_len int // last char legth + char_len int // last char legth last_dot_pc int = -1 // last dot chat pc } diff --git a/vlib/sokol/sapp/sapp_structs.c.v b/vlib/sokol/sapp/sapp_structs.c.v index c0bb9dc5c0..1a9fd368df 100644 --- a/vlib/sokol/sapp/sapp_structs.c.v +++ b/vlib/sokol/sapp/sapp_structs.c.v @@ -45,9 +45,9 @@ pub: // fail_cb fn (&u8) = unsafe { nil } user_data voidptr // these are the user-provided callbacks with user data - init_userdata_cb fn (voidptr) = unsafe { nil } - frame_userdata_cb fn (voidptr) = unsafe { nil } - cleanup_userdata_cb fn (voidptr) = unsafe { nil } + init_userdata_cb fn (voidptr) = unsafe { nil } + frame_userdata_cb fn (voidptr) = unsafe { nil } + cleanup_userdata_cb fn (voidptr) = unsafe { nil } event_userdata_cb fn (&Event, voidptr) = unsafe { nil } // fail_userdata_cb fn (&char, voidptr) = unsafe { nil } @@ -89,25 +89,25 @@ pub type Desc = C.sapp_desc @[typedef] pub struct C.sapp_event { pub: - frame_count u64 // current frame counter, always valid, useful for checking if two events were issued in the same frame - @type EventType // the event type, always valid - key_code KeyCode // the virtual key code, only valid in KEY_UP, KEY_DOWN - char_code u32 // the UTF-32 character code, only valid in CHAR events - key_repeat bool // true if this is a key-repeat event, valid in KEY_UP, KEY_DOWN and CHAR - modifiers u32 // current modifier keys, valid in all key-, char- and mouse-events - mouse_button MouseButton // mouse button that was pressed or released, valid in MOUSE_DOWN, MOUSE_UP - mouse_x f32 // current horizontal mouse position in pixels, always valid except during mouse lock - mouse_y f32 // current vertical mouse position in pixels, always valid except during mouse lock - mouse_dx f32 // relative horizontal mouse movement since last frame, always valid - mouse_dy f32 // relative vertical mouse movement since last frame, always valid - scroll_x f32 // horizontal mouse wheel scroll distance, valid in MOUSE_SCROLL events - scroll_y f32 // vertical mouse wheel scroll distance, valid in MOUSE_SCROLL events - num_touches int // number of valid items in the touches[] array + frame_count u64 // current frame counter, always valid, useful for checking if two events were issued in the same frame + @type EventType // the event type, always valid + key_code KeyCode // the virtual key code, only valid in KEY_UP, KEY_DOWN + char_code u32 // the UTF-32 character code, only valid in CHAR events + key_repeat bool // true if this is a key-repeat event, valid in KEY_UP, KEY_DOWN and CHAR + modifiers u32 // current modifier keys, valid in all key-, char- and mouse-events + mouse_button MouseButton // mouse button that was pressed or released, valid in MOUSE_DOWN, MOUSE_UP + mouse_x f32 // current horizontal mouse position in pixels, always valid except during mouse lock + mouse_y f32 // current vertical mouse position in pixels, always valid except during mouse lock + mouse_dx f32 // relative horizontal mouse movement since last frame, always valid + mouse_dy f32 // relative vertical mouse movement since last frame, always valid + scroll_x f32 // horizontal mouse wheel scroll distance, valid in MOUSE_SCROLL events + scroll_y f32 // vertical mouse wheel scroll distance, valid in MOUSE_SCROLL events + num_touches int // number of valid items in the touches[] array touches [max_touchpoints]TouchPoint // current touch points, valid in TOUCHES_BEGIN, TOUCHES_MOVED, TOUCHES_ENDED - window_width int // current window- and framebuffer width in pixels, always valid - window_height int // current window- and framebuffer height in pixels, always valid - framebuffer_width int // = window_width * dpi_scale - framebuffer_height int // = window_height * dpi_scale + window_width int // current window- and framebuffer width in pixels, always valid + window_height int // current window- and framebuffer height in pixels, always valid + framebuffer_width int // = window_width * dpi_scale + framebuffer_height int // = window_height * dpi_scale } pub type Event = C.sapp_event diff --git a/vlib/sokol/sfons/sfons_funcs.c.v b/vlib/sokol/sfons/sfons_funcs.c.v index 49fddce2ea..18059764e5 100644 --- a/vlib/sokol/sfons/sfons_funcs.c.v +++ b/vlib/sokol/sfons/sfons_funcs.c.v @@ -14,8 +14,8 @@ pub: @[typedef] pub struct C.sfons_desc_t { pub: - width int // initial width of font atlas texture (default: 512, must be power of 2) - height int // initial height of font atlas texture (default: 512, must be power of 2) + width int // initial width of font atlas texture (default: 512, must be power of 2) + height int // initial height of font atlas texture (default: 512, must be power of 2) allocator C.sfons_allocator_t // optional memory allocation overrides } diff --git a/vlib/sokol/sgl/sgl_structs.c.v b/vlib/sokol/sgl/sgl_structs.c.v index aa3eb8de48..5cd1db3c95 100644 --- a/vlib/sokol/sgl/sgl_structs.c.v +++ b/vlib/sokol/sgl/sgl_structs.c.v @@ -26,8 +26,8 @@ pub type ContextDesc = C.sgl_context_desc_t @[typedef] pub struct C.sgl_context_desc_t { - max_vertices int // default: 64k - max_commands int // default: 16k + max_vertices int // default: 64k + max_commands int // default: 16k color_format gfx.PixelFormat // C.sg_pixel_format depth_format gfx.PixelFormat // C.sg_pixel_format sample_count int @@ -38,10 +38,10 @@ pub type Desc = C.sgl_desc_t @[typedef] pub struct C.sgl_desc_t { pub: - max_vertices int // size for vertex buffer - max_commands int // size of uniform- and command-buffers - context_pool_size int // max number of contexts (including default context), default: 4 - pipeline_pool_size int // size of internal pipeline pool, default: 64 + max_vertices int // size for vertex buffer + max_commands int // size of uniform- and command-buffers + context_pool_size int // max number of contexts (including default context), default: 4 + pipeline_pool_size int // size of internal pipeline pool, default: 64 color_format gfx.PixelFormat // C.sg_pixel_format depth_format gfx.PixelFormat // C.sg_pixel_format sample_count int diff --git a/vlib/strconv/format.v b/vlib/strconv/format.v index d62f653bac..d53af4f80b 100644 --- a/vlib/strconv/format.v +++ b/vlib/strconv/format.v @@ -79,10 +79,10 @@ Single format functions pub struct BF_param { pub mut: 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 - sign_flag bool // flag for print sign as prefix in padding + 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 + sign_flag bool // flag for print sign as prefix in padding align Align_text = .right // alignment of the string allign Align_text = .right @[deprecated: 'use align instead'; deprecated_after: '2023-11-30'] rm_tail_zero bool // remove the tail zeros from floats diff --git a/vlib/sync/channels.c.v b/vlib/sync/channels.c.v index 08e8ce09f2..89d470d823 100644 --- a/vlib/sync/channels.c.v +++ b/vlib/sync/channels.c.v @@ -42,7 +42,7 @@ mut: // atomic read_adr C.atomic_uintptr_t // if != NULL an obj can be read from here without wait adr_read C.atomic_uintptr_t // used to identify origin of writesem adr_written C.atomic_uintptr_t // used to identify origin of readsem - write_free u32 // for queue state + write_free u32 // for queue state read_avail u32 buf_elem_write_idx u32 buf_elem_read_idx u32 diff --git a/vlib/toml/parser/parser.v b/vlib/toml/parser/parser.v index 97cb5fca4e..3c8500f41e 100644 --- a/vlib/toml/parser/parser.v +++ b/vlib/toml/parser/parser.v @@ -75,8 +75,8 @@ mut: pub struct Config { pub: scanner &scanner.Scanner = unsafe { nil } - run_checks bool = true - decode_values bool = true + run_checks bool = true + decode_values bool = true } // new_parser returns a new, stack allocated, `Parser`. diff --git a/vlib/v/ast/ast.v b/vlib/v/ast/ast.v index 76f374cdbe..6d6db5fe45 100644 --- a/vlib/v/ast/ast.v +++ b/vlib/v/ast/ast.v @@ -389,7 +389,7 @@ pub: pub mut: fields []ConstField // all the const fields in the `const (...)` block end_comments []Comment // comments that after last const field - is_block bool // const() block + is_block bool // const() block } @[minify] @@ -528,7 +528,7 @@ pub struct AnonFn { pub mut: decl FnDecl inherited_vars []Param - typ Type // the type of anonymous fn. Both .typ and .decl.name are auto generated + typ Type // the type of anonymous fn. Both .typ and .decl.name are auto generated has_gen map[string]bool // a map of the names of all generic anon functions, generated from it } @@ -583,7 +583,7 @@ pub mut: return_type Type return_type_pos token.Pos // `string` in `fn (u User) name() string` position has_return bool - should_be_skipped bool // true, when -skip-unused could not find any usages of that function, starting from main + other known used functions + should_be_skipped bool // true, when -skip-unused could not find any usages of that function, starting from main + other known used functions ninstances int // 0 for generic functions with no concrete instances has_await bool // 'true' if this function uses JS.await @@ -665,7 +665,7 @@ pub mut: is_conditional bool // true for `[if abc]fn(){}` ctdefine_idx int // the index of the attribute, containing the compile time define [if mytag] from_embedded_type Type // for interface only, fn from the embedded interface - from_embeded_type Type @[deprecated: 'use from_embedded_type instead'; deprecated_after: '2024-03-31'] + from_embeded_type Type @[deprecated: 'use from_embedded_type instead'; deprecated_after: '2024-03-31'] } fn (f &Fn) method_equals(o &Fn) bool { @@ -855,8 +855,8 @@ pub mut: // [11, 12, 13] <- cast order (smartcasts) // 12 <- the current casted type (typ) pos token.Pos - is_used bool // whether the local variable was used in other expressions - is_changed bool // to detect mutable vars that are never changed + is_used bool // whether the local variable was used in other expressions + is_changed bool // to detect mutable vars that are never changed ct_type_var ComptimeVarKind // comptime variable type // (for setting the position after the or block for autofree) is_or bool // `x := foo() or { ... }` diff --git a/vlib/v/ast/table.v b/vlib/v/ast/table.v index 98fd56d2c4..8247a64b64 100644 --- a/vlib/v/ast/table.v +++ b/vlib/v/ast/table.v @@ -30,14 +30,14 @@ pub mut: used_fns map[string]bool // filled in by the checker, when pref.skip_unused = true; used_consts map[string]bool // filled in by the checker, when pref.skip_unused = true; used_globals map[string]bool // filled in by the checker, when pref.skip_unused = true; - used_vweb_types []Type // vweb context types, filled in by checker, when pref.skip_unused = true; - used_maps int // how many times maps were used, filled in by checker, when pref.skip_unused = true; + used_vweb_types []Type // vweb context types, filled in by checker, when pref.skip_unused = true; + used_maps int // how many times maps were used, filled in by checker, when pref.skip_unused = true; panic_handler FnPanicHandler = default_table_panic_handler panic_userdata voidptr = unsafe { nil } // can be used to pass arbitrary data to panic_handler; panic_npanics int cur_fn &FnDecl = unsafe { nil } // previously stored in Checker.cur_fn and Gen.cur_fn - cur_concrete_types []Type // current concrete types, e.g. - gostmts int // how many `go` statements there were in the parsed files. + cur_concrete_types []Type // current concrete types, e.g. + gostmts int // how many `go` statements there were in the parsed files. // When table.gostmts > 0, __VTHREADS__ is defined, which can be checked with `$if threads {` enum_decls map[string]EnumDecl module_deprecated map[string]bool diff --git a/vlib/v/builder/builder.v b/vlib/v/builder/builder.v index a2c170cfaf..6a2ec03d61 100644 --- a/vlib/v/builder/builder.v +++ b/vlib/v/builder/builder.v @@ -20,7 +20,7 @@ pub: compiled_dir string // contains os.real_path() of the dir of the final file being compiled, or the dir itself when doing `v .` module_path string pub mut: - checker &checker.Checker = unsafe { nil } + checker &checker.Checker = unsafe { nil } transformer &transformer.Transformer = unsafe { nil } out_name_c string out_name_js string @@ -42,8 +42,8 @@ pub mut: mod_invalidates_paths map[string][]string // changes in mod `os`, invalidate only .v files, that do `import os` mod_invalidates_mods map[string][]string // changes in mod `os`, force invalidation of mods, that do `import os` path_invalidates_mods map[string][]string // changes in a .v file from `os`, invalidates `os` - crun_cache_keys []string // target executable + top level source files; filled in by Builder.should_rebuild - executable_exists bool // if the executable already exists, don't remove new executable after `v run` + crun_cache_keys []string // target executable + top level source files; filled in by Builder.should_rebuild + executable_exists bool // if the executable already exists, don't remove new executable after `v run` } pub fn new_builder(pref_ &pref.Preferences) Builder { diff --git a/vlib/v/callgraph/callgraph.v b/vlib/v/callgraph/callgraph.v index 7d5ba8befd..db99c596da 100644 --- a/vlib/v/callgraph/callgraph.v +++ b/vlib/v/callgraph/callgraph.v @@ -27,9 +27,9 @@ struct Mapper { mut: pref &pref.Preferences = unsafe { nil } table &ast.Table = unsafe { nil } - file &ast.File = unsafe { nil } - node &ast.Node = unsafe { nil } - fn_decl &ast.FnDecl = unsafe { nil } + file &ast.File = unsafe { nil } + node &ast.Node = unsafe { nil } + fn_decl &ast.FnDecl = unsafe { nil } caller_name string dot_caller_name string is_caller_used bool diff --git a/vlib/v/checker/checker.v b/vlib/v/checker/checker.v index b7178493e2..b21f63ee6a 100644 --- a/vlib/v/checker/checker.v +++ b/vlib/v/checker/checker.v @@ -59,9 +59,9 @@ pub mut: should_abort bool // when too many errors/warnings/notices are accumulated, .should_abort becomes true. It is checked in statement/expression loops, so the checker can return early, instead of wasting time. // expected_type ast.Type - expected_or_type ast.Type // fn() or { 'this type' } eg. string. expected or block type - expected_expr_type ast.Type // if/match is_expr: expected_type - mod string // current module name + expected_or_type ast.Type // fn() or { 'this type' } eg. string. expected or block type + expected_expr_type ast.Type // if/match is_expr: expected_type + mod string // current module name const_var &ast.ConstField = unsafe { nil } // the current constant, when checking const declarations const_deps []string const_names []string @@ -128,7 +128,7 @@ mut: // doing_line_info int // a quick single file run when called with v -line-info (contains line nr to inspect) // doing_line_path string // same, but stores the path being parsed is_index_assign bool - comptime_call_pos int // needed for correctly checking use before decl for templates + comptime_call_pos int // needed for correctly checking use before decl for templates goto_labels map[string]ast.GotoLabel // to check for unused goto labels enum_data_type ast.Type field_data_type ast.Type diff --git a/vlib/v/debug/debug.v b/vlib/v/debug/debug.v index 31a677b56a..262fa2c992 100644 --- a/vlib/v/debug/debug.v +++ b/vlib/v/debug/debug.v @@ -52,14 +52,14 @@ pub struct DebugContextVar { // DebugContextInfo has the context info for the debugger repl pub struct DebugContextInfo { - is_anon bool // cur fn is anon? - is_generic bool // cur fn is a generic? - is_method bool // cur fn is a bool? - receiver_typ_name string // cur receiver type name (method only) - line int // cur line number - file string // cur file name - mod string // cur module name - fn_name string // cur function name + is_anon bool // cur fn is anon? + is_generic bool // cur fn is a generic? + is_method bool // cur fn is a bool? + receiver_typ_name string // cur receiver type name (method only) + line int // cur line number + file string // cur file name + mod string // cur module name + fn_name string // cur function name scope map[string]DebugContextVar // scope var data } diff --git a/vlib/v/doc/doc.v b/vlib/v/doc/doc.v index dc96f3bd57..f053cc98bc 100644 --- a/vlib/v/doc/doc.v +++ b/vlib/v/doc/doc.v @@ -141,7 +141,7 @@ pub mut: children []DocNode attrs map[string]string @[json: attributes] from_scope bool - is_pub bool @[json: public] + is_pub bool @[json: public] platform Platform } diff --git a/vlib/v/dotgraph/dotgraph.v b/vlib/v/dotgraph/dotgraph.v index 60d7c23f17..45f45ce70b 100644 --- a/vlib/v/dotgraph/dotgraph.v +++ b/vlib/v/dotgraph/dotgraph.v @@ -39,7 +39,7 @@ pub: node_name string should_highlight bool tooltip string - ctx voidptr = unsafe { nil } + ctx voidptr = unsafe { nil } name2node_fn FnLabel2NodeName = node_name } @@ -60,7 +60,7 @@ pub fn (mut d DotGraph) new_node(nlabel string, cfg NewNodeConfig) { pub struct NewEdgeConfig { pub: should_highlight bool - ctx voidptr = unsafe { nil } + ctx voidptr = unsafe { nil } name2node_fn FnLabel2NodeName = node_name } diff --git a/vlib/v/fmt/align.v b/vlib/v/fmt/align.v index 7a0fafea59..c9ea88ad8d 100644 --- a/vlib/v/fmt/align.v +++ b/vlib/v/fmt/align.v @@ -3,47 +3,46 @@ // that can be found in the LICENSE file. module fmt -import v.mathutil - struct AlignInfo { mut: - line_nr int - max_len int - max_type_len int + line_nr int + max_len int } @[params] struct AddInfoConfig { pub: use_threshold bool - threshold int = 8 + threshold int = 25 } -fn (mut infos []AlignInfo) add_new_info(len int, type_len int, line int) { +fn (mut infos []AlignInfo) add_new_info(len int, line int) { infos << AlignInfo{ line_nr: line max_len: len - max_type_len: type_len } } @[direct_array_access] -fn (mut infos []AlignInfo) add_info(len int, type_len int, line int, cfg AddInfoConfig) { +fn (mut infos []AlignInfo) add_info(len int, line int, cfg AddInfoConfig) { if infos.len == 0 { - infos.add_new_info(len, type_len, line) + infos.add_new_info(len, line) return } i := infos.len - 1 if line - infos[i].line_nr > 1 { - infos.add_new_info(len, type_len, line) + infos.add_new_info(len, line) return } if cfg.use_threshold { - len_diff := mathutil.abs(infos[i].max_len - len) + - mathutil.abs(infos[i].max_type_len - type_len) + len_diff := if infos[i].max_len >= len { + infos[i].max_len - len + } else { + len - infos[i].max_len + } if len_diff >= cfg.threshold { - infos.add_new_info(len, type_len, line) + infos.add_new_info(len, line) return } } @@ -51,7 +50,4 @@ fn (mut infos []AlignInfo) add_info(len int, type_len int, line int, cfg AddInfo if len > infos[i].max_len { infos[i].max_len = len } - if type_len > infos[i].max_type_len { - infos[i].max_type_len = type_len - } } diff --git a/vlib/v/fmt/fmt.v b/vlib/v/fmt/fmt.v index f582abdb3c..2a581fad18 100644 --- a/vlib/v/fmt/fmt.v +++ b/vlib/v/fmt/fmt.v @@ -32,7 +32,7 @@ pub mut: single_line_if bool cur_mod string did_imports bool - import_pos int // position of the imports in the resulting string + import_pos int // position of the imports in the resulting string auto_imports map[string]bool // potentially hidden imports(`sync` when using channels) and preludes(when embedding files) used_imports map[string]bool // to remove unused imports import_syms_used map[string]bool // to remove unused import symbols @@ -1374,22 +1374,23 @@ pub fn (mut f Fmt) interface_decl(node ast.InterfaceDecl) { } } - mut field_aligns := []AlignInfo{} + mut type_aligns := []AlignInfo{} mut comment_aligns := []AlignInfo{} mut default_expr_aligns := []AlignInfo{} + mut attr_aligns := []AlignInfo{} mut field_types := []string{cap: node.fields.len} // Calculate the alignments first - f.calculate_alignment(node.fields, mut field_aligns, mut comment_aligns, mut default_expr_aligns, mut - field_types) + f.calculate_alignment(node.fields, mut type_aligns, mut comment_aligns, mut default_expr_aligns, mut + attr_aligns, mut field_types) - mut field_align_i := 0 + mut type_align_i := 0 // TODO: alignment, comments, etc. for field in immut_fields { - if field_aligns[field_align_i].line_nr < field.pos.line_nr { - field_align_i++ + if type_aligns[type_align_i].line_nr < field.pos.line_nr { + type_align_i++ } - f.interface_field(field, field_aligns[field_align_i]) + f.interface_field(field, type_aligns[type_align_i]) } for method in immut_methods { f.interface_method(method) @@ -1397,10 +1398,10 @@ pub fn (mut f Fmt) interface_decl(node ast.InterfaceDecl) { if mut_fields.len + mut_methods.len > 0 { f.writeln('mut:') for field in mut_fields { - if field_aligns[field_align_i].line_nr < field.pos.line_nr { - field_align_i++ + if type_aligns[type_align_i].line_nr < field.pos.line_nr { + type_align_i++ } - f.interface_field(field, field_aligns[field_align_i]) + f.interface_field(field, type_aligns[type_align_i]) } for method in mut_methods { f.interface_method(method) @@ -1409,31 +1410,69 @@ pub fn (mut f Fmt) interface_decl(node ast.InterfaceDecl) { f.writeln('}\n') } -pub fn (mut f Fmt) calculate_alignment(fields []ast.StructField, mut field_aligns []AlignInfo, mut comment_aligns []AlignInfo, - mut default_expr_aligns []AlignInfo, mut field_types []string) { +enum AlignState { + plain + has_attributes + has_default_expression + has_everything +} + +pub fn (mut f Fmt) calculate_alignment(fields []ast.StructField, mut type_aligns []AlignInfo, mut comment_aligns []AlignInfo, + mut default_expr_aligns []AlignInfo, mut attr_aligns []AlignInfo, mut field_types []string) { // Calculate the alignments first - for i, field in fields { + mut prev_state := AlignState.plain + for field in fields { ft := f.no_cur_mod(f.table.type_to_str_using_aliases(field.typ, f.mod2alias)) // Handle anon structs recursively field_types << ft attrs_len := inline_attrs_len(field.attrs) end_pos := field.pos.pos + field.pos.len + type_aligns.add_info(field.name.len, field.pos.line_nr) + if field.has_default_expr { + default_expr_aligns.add_info(ft.len, field.pos.line_nr, + use_threshold: true + ) + } + if field.attrs.len > 0 { + attr_aligns.add_info(ft.len, field.pos.line_nr, use_threshold: true) + } for comment in field.comments { if comment.pos.pos >= end_pos { if comment.pos.line_nr == field.pos.line_nr { - comment_aligns.add_info(attrs_len, field_types[i].len, comment.pos.line_nr, - use_threshold: true - ) + if field.attrs.len > 0 { + if prev_state != AlignState.has_attributes { + comment_aligns.add_new_info(attrs_len, comment.pos.line_nr) + } else { + comment_aligns.add_info(attrs_len, comment.pos.line_nr, + use_threshold: true + ) + } + prev_state = AlignState.has_attributes + } else if field.has_default_expr { + if prev_state != AlignState.has_default_expression { + comment_aligns.add_new_info(field.default_expr.str().len + 2, + comment.pos.line_nr) + } else { + comment_aligns.add_info(field.default_expr.str().len + 2, + comment.pos.line_nr, + use_threshold: true + ) + } + prev_state = AlignState.has_default_expression + } else { + if prev_state != AlignState.has_everything { + comment_aligns.add_new_info(ft.len, comment.pos.line_nr) + } else { + comment_aligns.add_info(ft.len, comment.pos.line_nr, + use_threshold: true + ) + } + prev_state = AlignState.has_everything + } } continue } } - field_aligns.add_info(field.name.len, ft.len, field.pos.line_nr) - if field.has_default_expr { - default_expr_aligns.add_info(attrs_len, field_types[i].len, field.pos.line_nr, - use_threshold: true - ) - } } } diff --git a/vlib/v/fmt/struct.v b/vlib/v/fmt/struct.v index 98ced8d3db..347cbaeb6d 100644 --- a/vlib/v/fmt/struct.v +++ b/vlib/v/fmt/struct.v @@ -27,13 +27,14 @@ pub fn (mut f Fmt) struct_decl(node ast.StructDecl, is_anon bool) { f.writeln(' {}') return } - mut field_aligns := []AlignInfo{} - mut comment_aligns := []AlignInfo{} + mut type_aligns := []AlignInfo{} mut default_expr_aligns := []AlignInfo{} + mut attr_aligns := []AlignInfo{} + mut comment_aligns := []AlignInfo{} mut field_types := []string{cap: node.fields.len} // Calculate the alignments first - f.calculate_alignment(node.fields, mut field_aligns, mut comment_aligns, mut default_expr_aligns, mut - field_types) + f.calculate_alignment(node.fields, mut type_aligns, mut comment_aligns, mut default_expr_aligns, mut + attr_aligns, mut field_types) f.writeln(' {') if node.pre_comments.len > 0 { f.comments_before_field(node.pre_comments) @@ -54,9 +55,10 @@ pub fn (mut f Fmt) struct_decl(node ast.StructDecl, is_anon bool) { } } // Now handle each field - mut field_align_i := 0 + mut type_align_i := 0 mut comment_align_i := 0 mut default_expr_align_i := 0 + mut attr_align_i := 0 mut inc_indent := false // for correct indents with multi line default exprs for i, field in node.fields { match true { @@ -112,32 +114,23 @@ pub fn (mut f Fmt) struct_decl(node ast.StructDecl, is_anon bool) { f.comments_before_field(pre_cmts) volatile_prefix := if field.is_volatile { 'volatile ' } else { '' } f.write('\t${volatile_prefix}${field.name} ') - if field_aligns[field_align_i].line_nr < field.pos.line_nr { - field_align_i++ + if type_aligns[type_align_i].line_nr < field.pos.line_nr { + type_align_i++ } - field_align := field_aligns[field_align_i] - f.write(strings.repeat(` `, field_align.max_len - field.name.len)) + type_align := type_aligns[type_align_i] + f.write(strings.repeat(` `, type_align.max_len - field.name.len)) // Handle anon structs recursively if !f.write_anon_struct_field_decl(field.typ, field.anon_struct_decl) { f.write(field_types[i]) } f.mark_types_import_as_used(field.typ) attrs_len := inline_attrs_len(field.attrs) - has_attrs := field.attrs.len > 0 - // has_at := if has_attrs { field.attrs[0].has_at } else { false } - has_at := true - // TODO: this will get removed in next stage - if has_attrs && !has_at { - f.write(strings.repeat(` `, field_align.max_type_len - field_types[i].len)) - f.single_line_attrs(field.attrs, same_line: true) - } if field.has_default_expr { if default_expr_aligns[default_expr_align_i].line_nr < field.pos.line_nr { default_expr_align_i++ } align := default_expr_aligns[default_expr_align_i] - pad_len := align.max_len - attrs_len + align.max_type_len - field_types[i].len - f.write(strings.repeat(` `, pad_len)) + f.write(strings.repeat(` `, align.max_len - field_types[i].len)) f.write(' = ') if !expr_is_single_line(field.default_expr) { f.indent++ @@ -149,19 +142,26 @@ pub fn (mut f Fmt) struct_decl(node ast.StructDecl, is_anon bool) { inc_indent = false } } - if has_attrs && has_at { - f.write(strings.repeat(` `, field_align.max_type_len - field_types[i].len)) + if field.attrs.len > 0 { + if attr_aligns[attr_align_i].line_nr < field.pos.line_nr { + attr_align_i++ + } + align := attr_aligns[attr_align_i] + f.write(strings.repeat(` `, align.max_len - field_types[i].len)) f.single_line_attrs(field.attrs, same_line: true) } // Handle comments at the end of the line if end_cmts.len > 0 { - if !field.has_default_expr { - if comment_aligns[comment_align_i].line_nr < field.pos.line_nr { - comment_align_i++ - } - align := comment_aligns[comment_align_i] - pad_len := align.max_len - attrs_len + align.max_type_len - field_types[i].len - f.write(strings.repeat(` `, pad_len)) + if comment_aligns[comment_align_i].line_nr < field.pos.line_nr { + comment_align_i++ + } + align := comment_aligns[comment_align_i] + if field.has_default_expr { + f.write(strings.repeat(` `, align.max_len - field.default_expr.str().len - 2)) + } else if field.attrs.len > 0 { + f.write(strings.repeat(` `, align.max_len - attrs_len)) + } else { + f.write(strings.repeat(` `, align.max_len - field_types[i].len)) } f.write(' ') f.comments(end_cmts, level: .indent) diff --git a/vlib/v/fmt/tests/struct_default_field_expressions_keep.vv b/vlib/v/fmt/tests/struct_default_field_expressions_keep.vv index a321345825..1372143135 100644 --- a/vlib/v/fmt/tests/struct_default_field_expressions_keep.vv +++ b/vlib/v/fmt/tests/struct_default_field_expressions_keep.vv @@ -3,12 +3,12 @@ struct Foo { } struct Bar { - f Foo = &Foo(0) + f Foo = &Foo(0) z int = -1 @[skip] } struct Baz { - x int = 1 // It's one + x int = 1 // It's one y string = 'one' // It's one written out - z bool = true // Also one + z bool = true // Also one } diff --git a/vlib/v/fmt/tests/structs_comments_keep.vv b/vlib/v/fmt/tests/structs_comments_keep.vv index e4c2a70224..764a566306 100644 --- a/vlib/v/fmt/tests/structs_comments_keep.vv +++ b/vlib/v/fmt/tests/structs_comments_keep.vv @@ -2,7 +2,7 @@ struct User { name string // name name2 []rune // name2 very_long_field bool - age int // age + age int // age very_long_type_field1 very_looooog_type // long very_long_type_field2 very_loooooooong_type // long } diff --git a/vlib/v/gen/c/cgen.v b/vlib/v/gen/c/cgen.v index dbfeb40956..8418532e83 100644 --- a/vlib/v/gen/c/cgen.v +++ b/vlib/v/gen/c/cgen.v @@ -66,20 +66,20 @@ mut: comptime_definitions strings.Builder // custom defines, given by -d/-define flags on the CLI cleanup strings.Builder cleanups map[string]strings.Builder // contents of `void _vcleanup(){}` - gowrappers strings.Builder // all go callsite wrappers - auto_str_funcs strings.Builder // function bodies of all auto generated _str funcs - dump_funcs strings.Builder // function bodies of all auto generated _str funcs - pcs_declarations strings.Builder // -prof profile counter declarations for each function - cov_declarations strings.Builder // -cov coverage - embedded_data strings.Builder // data to embed in the executable/binary - shared_types strings.Builder // shared/lock types - shared_functions strings.Builder // shared constructors - out_options_forward strings.Builder // forward `option_xxxx` types - out_options strings.Builder // `option_xxxx` types - out_results_forward strings.Builder // forward`result_xxxx` types - out_results strings.Builder // `result_xxxx` types - json_forward_decls strings.Builder // json type forward decls - sql_buf strings.Builder // for writing exprs to args via `sqlite3_bind_int()` etc + gowrappers strings.Builder // all go callsite wrappers + auto_str_funcs strings.Builder // function bodies of all auto generated _str funcs + dump_funcs strings.Builder // function bodies of all auto generated _str funcs + pcs_declarations strings.Builder // -prof profile counter declarations for each function + cov_declarations strings.Builder // -cov coverage + embedded_data strings.Builder // data to embed in the executable/binary + shared_types strings.Builder // shared/lock types + shared_functions strings.Builder // shared constructors + out_options_forward strings.Builder // forward `option_xxxx` types + out_options strings.Builder // `option_xxxx` types + out_results_forward strings.Builder // forward`result_xxxx` types + out_results strings.Builder // `result_xxxx` types + json_forward_decls strings.Builder // json type forward decls + sql_buf strings.Builder // for writing exprs to args via `sqlite3_bind_int()` etc global_const_defs map[string]GlobalConstDef sorted_global_const_names []string file &ast.File = unsafe { nil } @@ -87,7 +87,7 @@ mut: unique_file_path_hash u64 // a hash of file.path, used for making auxiliary fn generation unique (like `compare_xyz`) fn_decl &ast.FnDecl = unsafe { nil } // pointer to the FnDecl we are currently inside otherwise 0 last_fn_c_name string - tmp_count int // counter for unique tmp vars (_tmp1, _tmp2 etc); resets at the start of each fn. + tmp_count int // counter for unique tmp vars (_tmp1, _tmp2 etc); resets at the start of each fn. tmp_count_af int // a separate tmp var counter for autofree fn calls tmp_count_declarations int // counter for unique tmp names (_d1, _d2 etc); does NOT reset, used for C declarations global_tmp_count int // like tmp_count but global and not reset in each function @@ -107,17 +107,17 @@ mut: is_fn_index_call bool is_cc_msvc bool // g.pref.ccompiler == 'msvc' is_option_auto_heap bool - vlines_path string // set to the proper path for generating #line directives - options_pos_forward int // insertion point to forward - options_forward []string // to forward + vlines_path string // set to the proper path for generating #line directives + options_pos_forward int // insertion point to forward + options_forward []string // to forward options map[string]string // to avoid duplicates - results_forward []string // to forward + results_forward []string // to forward results map[string]string // to avoid duplicates done_options shared []string // to avoid duplicates done_results shared []string // to avoid duplicates chan_pop_options map[string]string // types for `x := <-ch or {...}` chan_push_options map[string]string // types for `ch <- x or {...}` - mtxs string // array of mutexes if the `lock` has multiple variables + mtxs string // array of mutexes if the `lock` has multiple variables labeled_loops map[string]&ast.Stmt inner_loop &ast.Stmt = unsafe { nil } shareds map[int]string // types with hidden mutex for which decl has been emitted @@ -186,7 +186,7 @@ mut: anon_fn_definitions []string // anon generated functions definition list sumtype_definitions map[int]bool // `_TypeA_to_sumtype_TypeB()` fns that have been generated trace_fn_definitions []string - json_types []ast.Type // to avoid json gen duplicates + json_types []ast.Type // to avoid json gen duplicates pcs []ProfileCounterMeta // -prof profile counter fn_names => fn counter name hotcode_fn_names []string hotcode_fpaths []string @@ -225,7 +225,7 @@ mut: curr_var_name []string // curr var name on assignment called_fn_name string timers &util.Timers = util.get_timers() - force_main_console bool // true when @[console] used on fn main() + force_main_console bool // true when @[console] used on fn main() as_cast_type_names map[string]string // table for type name lookup in runtime (for __as_cast) obf_table map[string]string referenced_fns shared map[string]bool // functions that have been referenced @@ -237,7 +237,7 @@ mut: has_main bool // main_fn_decl_node ast.FnDecl cur_mod ast.Module - cur_concrete_types []ast.Type // do not use table.cur_concrete_types because table is global, so should not be accessed by different threads + cur_concrete_types []ast.Type // do not use table.cur_concrete_types because table is global, so should not be accessed by different threads cur_fn &ast.FnDecl = unsafe { nil } // same here cur_lock ast.LockExpr cur_struct_init_typ ast.Type diff --git a/vlib/v/gen/js/js.v b/vlib/v/gen/js/js.v index 27a1a01924..833a81a519 100644 --- a/vlib/v/gen/js/js.v +++ b/vlib/v/gen/js/js.v @@ -64,7 +64,7 @@ mut: defer_stmts []ast.DeferStmt fn_decl &ast.FnDecl = unsafe { nil } // pointer to the FnDecl we are currently inside otherwise 0 generated_str_fns []StrType - str_types []StrType // types that need automatic str() generation + str_types []StrType // types that need automatic str() generation copy_types []StrType // types that need to be deep copied generated_copy_fns []StrType array_fn_definitions []string // array equality functions that have been defined diff --git a/vlib/v/gen/js/sourcemap/source_map.v b/vlib/v/gen/js/sourcemap/source_map.v index 54668fadcb..395f0352f9 100644 --- a/vlib/v/gen/js/sourcemap/source_map.v +++ b/vlib/v/gen/js/sourcemap/source_map.v @@ -10,10 +10,10 @@ type SourceMapJson = map[string]json2.Any pub struct SourceMap { pub mut: - version int @[json: version] - file string @[json: file] - source_root string @[json: source_root] - sources Sets @[json: sources] + version int @[json: version] + file string @[json: file] + source_root string @[json: source_root] + sources Sets @[json: sources] sources_content map[string]string names Sets mappings Mappings diff --git a/vlib/v/gen/wasm/gen.v b/vlib/v/gen/wasm/gen.v index 9fa037f3fc..049261f90b 100644 --- a/vlib/v/gen/wasm/gen.v +++ b/vlib/v/gen/wasm/gen.v @@ -40,7 +40,7 @@ mut: heap_base ?wasm.GlobalIndex fn_local_idx_end int fn_name string - stack_frame int // Size of the current stack frame, if needed + stack_frame int // Size of the current stack frame, if needed is_leaf_function bool = true loop_breakpoint_stack []LoopBreakpoint stack_top int // position in linear memory diff --git a/vlib/v/live/common.c.v b/vlib/v/live/common.c.v index edd63f2dcb..9ba61c3bd9 100644 --- a/vlib/v/live/common.c.v +++ b/vlib/v/live/common.c.v @@ -11,16 +11,16 @@ pub: original string // full path to the original source file, compiled with -live live_fn_mutex voidptr // the address of the C mutex, that locks the @[live] fns during reloads. live_linkfn FNLinkLiveSymbols = unsafe { nil } // generated C callback; receives a dlopen handle - so_extension string // .so or .dll + so_extension string // .so or .dll so_name_template string // a template for the shared libraries location pub mut: - monitored_files []string // an array, containing all paths that should be monitored for changes - live_lib voidptr // the result of dl.open - reloads int // how many times a reloading was tried - reloads_ok int // how many times the reloads succeeded - reload_time_ms int // how much time the last reload took (compilation + loading) - last_mod_ts i64 // a timestamp for when the original was last changed - recheck_period_ms int = 100 // how often do you want to check for changes + monitored_files []string // an array, containing all paths that should be monitored for changes + live_lib voidptr // the result of dl.open + reloads int // how many times a reloading was tried + reloads_ok int // how many times the reloads succeeded + reload_time_ms int // how much time the last reload took (compilation + loading) + last_mod_ts i64 // a timestamp for when the original was last changed + recheck_period_ms int = 100 // how often do you want to check for changes cb_recheck FNLiveReloadCB = unsafe { nil } // executed periodically cb_compile_failed FNLiveReloadCB = unsafe { nil } // executed when a reload compilation failed cb_before FNLiveReloadCB = unsafe { nil } // executed before a reload try happens diff --git a/vlib/v/parser/parser.v b/vlib/v/parser/parser.v index ffec096b9e..8f7e3b715f 100644 --- a/vlib/v/parser/parser.v +++ b/vlib/v/parser/parser.v @@ -34,9 +34,9 @@ mut: peek_tok token.Token language ast.Language fn_language ast.Language // .c for `fn C.abcd()` declarations - expr_level int // prevent too deep recursions for pathological programs - inside_vlib_file bool // true for all vlib/ files - inside_test_file bool // when inside _test.v or _test.vv file + expr_level int // prevent too deep recursions for pathological programs + inside_vlib_file bool // true for all vlib/ files + inside_test_file bool // when inside _test.v or _test.vv file inside_if bool inside_comptime_if bool inside_if_expr bool @@ -83,8 +83,8 @@ mut: expr_mod string // for constructing full type names in parse_type() imports map[string]string // alias => mod_name ast_imports []ast.Import // mod_names - used_imports []string // alias - auto_imports []string // imports, the user does not need to specify + used_imports []string // alias + auto_imports []string // imports, the user does not need to specify imported_symbols map[string]string is_amp bool // for generating the right code for `&Foo{}` returns bool diff --git a/vlib/v/pref/pref.v b/vlib/v/pref/pref.v index f13c5be1ce..674cccb528 100644 --- a/vlib/v/pref/pref.v +++ b/vlib/v/pref/pref.v @@ -129,8 +129,8 @@ pub mut: hide_auto_str bool // `v -hide-auto-str program.v`, doesn't generate str() with struct data // Note: passing -cg instead of -g will set is_vlines to false and is_debug to true, thus making v generate cleaner C files, // which are sometimes easier to debug / inspect manually than the .tmp.c files by plain -g (when/if v line number generation breaks). - sanitize bool // use Clang's new "-fsanitize" option - sourcemap bool // JS Backend: -sourcemap will create a source map - default false + sanitize bool // use Clang's new "-fsanitize" option + sourcemap bool // JS Backend: -sourcemap will create a source map - default false sourcemap_inline bool = true // JS Backend: -sourcemap-inline will embed the source map in the generated JaaScript file - currently default true only implemented sourcemap_src_included bool // JS Backend: -sourcemap-src-included includes V source code in source map - default false show_cc bool // -showcc, print cc command @@ -143,7 +143,7 @@ pub mut: dump_defines string // `-dump-defines defines.txt` - let V store all the defines that affect the current program and their values, one define per line + `,` + its value. use_cache bool // when set, use cached modules to speed up subsequent compilations, at the cost of slower initial ones (while the modules are cached) retry_compilation bool = true // retry the compilation with another C compiler, if tcc fails. - use_os_system_to_run bool // when set, use os.system() to run the produced executable, instead of os.new_process; works around segfaults on macos, that may happen when xcode is updated + use_os_system_to_run bool // when set, use os.system() to run the produced executable, instead of os.new_process; works around segfaults on macos, that may happen when xcode is updated macosx_version_min string = '0' // relevant only for macos and ios targets // TODO: Convert this into a []string cflags string // Additional options which will be passed to the C compiler *before* other options. @@ -191,8 +191,8 @@ pub mut: // Only test_ functions that match these patterns will be run. -run-only is valid only for _test.v files. // // -d vfmt and -d another=0 for `$if vfmt { will execute }` and `$if another ? { will NOT get here }` - compile_defines []string // just ['vfmt'] - compile_defines_all []string // contains both: ['vfmt','another'] + compile_defines []string // just ['vfmt'] + compile_defines_all []string // contains both: ['vfmt','another'] compile_values map[string]string // the map will contain for `-d key=value`: compile_values['key'] = 'value', and for `-d ident`, it will be: compile_values['ident'] = 'true' // run_args []string // `v run x.v 1 2 3` => `1 2 3` @@ -224,7 +224,7 @@ pub mut: build_options []string // list of options, that should be passed down to `build-module`, if needed for -usecache cache_manager vcache.CacheManager gc_mode GarbageCollectionMode = .unknown // .no_gc, .boehm, .boehm_leak, ... - assert_failure_mode AssertFailureMode // whether to call abort() or print_backtrace() after an assertion failure + assert_failure_mode AssertFailureMode // whether to call abort() or print_backtrace() after an assertion failure message_limit int = 150 // the maximum amount of warnings/errors/notices that will be accumulated nofloat bool // for low level code, like kernels: replaces f32 with u32 and f64 with u64 use_coroutines bool // experimental coroutines @@ -244,10 +244,10 @@ pub mut: pub struct LineInfo { pub mut: - line_nr int // a quick single file run when called with v -line-info (contains line nr to inspect) - path string // same, but stores the path being parsed - expr string // "foo" or "foo.bar" V code (expression) which needs autocomplete - is_running bool // so that line info is fetched only on the second checker run + line_nr int // a quick single file run when called with v -line-info (contains line nr to inspect) + path string // same, but stores the path being parsed + expr string // "foo" or "foo.bar" V code (expression) which needs autocomplete + is_running bool // so that line info is fetched only on the second checker run vars_printed map[string]bool // to avoid dups } diff --git a/vlib/v/reflection/reflection.v b/vlib/v/reflection/reflection.v index 190f20bbdb..54dca27c71 100644 --- a/vlib/v/reflection/reflection.v +++ b/vlib/v/reflection/reflection.v @@ -131,7 +131,7 @@ pub: name string // interface name methods []Function // methods fields []StructField // fields - is_generic bool // is generic? + is_generic bool // is generic? } pub struct None { @@ -225,13 +225,13 @@ pub: mod_name string // module name name string // function/method name args []FunctionArg // function/method args - file_idx int // source file name - line_start int // decl start line - line_end int // decl end line - is_variadic bool // is variadic? - return_typ VType // return type idx - receiver_typ VType // receiver type idx (is a method) - is_pub bool // is pub? + file_idx int // source file name + line_start int // decl start line + line_end int // decl end line + is_variadic bool // is variadic? + return_typ VType // return type idx + receiver_typ VType // receiver type idx (is a method) + is_pub bool // is pub? } // API module diff --git a/vlib/v/scanner/scanner.v b/vlib/v/scanner/scanner.v index 9710050561..dcaca4464f 100644 --- a/vlib/v/scanner/scanner.v +++ b/vlib/v/scanner/scanner.v @@ -29,10 +29,10 @@ pub mut: pos int // current position in the file, first character is s.text[0] line_nr int // current line number last_nl_pos int = -1 // for calculating column - is_crlf bool // special check when computing columns - is_inside_string bool // set to true in a string, *at the start* of an $var or ${expr} - is_nested_string bool // '${'abc':-12s}' - is_inter_start bool // for hacky string interpolation TODO simplify + is_crlf bool // special check when computing columns + is_inside_string bool // set to true in a string, *at the start* of an $var or ${expr} + is_nested_string bool // '${'abc':-12s}' + is_inter_start bool // for hacky string interpolation TODO simplify is_inter_end bool is_enclosed_inter bool is_nested_enclosed_inter bool @@ -42,14 +42,14 @@ pub mut: is_print_line_on_error bool is_print_colored_error bool is_print_rel_paths_on_error bool - quote u8 // which quote is used to denote current string: ' or " + quote u8 // which quote is used to denote current string: ' or " inter_quote u8 just_closed_inter bool // if is_enclosed_inter was set to false on the previous character: `}` nr_lines int // total number of lines in the source file that were scanned is_vh bool // Keep newlines is_fmt bool // Used for v fmt. comments_mode CommentsMode - is_inside_toplvl_statement bool // *only* used in comments_mode: .toplevel_comments, toggled by parser + is_inside_toplvl_statement bool // *only* used in comments_mode: .toplevel_comments, toggled by parser all_tokens []token.Token // *only* used in comments_mode: .toplevel_comments, contains all tokens tidx int eofs int diff --git a/vlib/v/tests/fn_literal_type_test.v b/vlib/v/tests/fn_literal_type_test.v index a6f3dcdb8a..54a7d40683 100644 --- a/vlib/v/tests/fn_literal_type_test.v +++ b/vlib/v/tests/fn_literal_type_test.v @@ -2,7 +2,7 @@ import db.sqlite @[table: 'Users'] struct User { - id int @[primary; sql: serial] + id int @[primary; sql: serial] name string } diff --git a/vlib/v/tests/generics_struct_field_with_default_fn_type_test.v b/vlib/v/tests/generics_struct_field_with_default_fn_type_test.v index 60515f5bf2..f0e0d750b1 100644 --- a/vlib/v/tests/generics_struct_field_with_default_fn_type_test.v +++ b/vlib/v/tests/generics_struct_field_with_default_fn_type_test.v @@ -1,15 +1,15 @@ @[heap] struct BloomFilter1[T] { hash_func fn (T) u32 = unsafe { nil } // hash function, input [T] , output u32 - table_size int // every entry is one-bit, packed into `table` - num_functions int // 1~16 + table_size int // every entry is one-bit, packed into `table` + num_functions int // 1~16 } @[heap] struct BloomFilter2[T] { hash_func fn (T) u32 = default_cb[T] // hash function, input [T] , output u32 - table_size int // every entry is one-bit, packed into `table` - num_functions int // 1~16 + table_size int // every entry is one-bit, packed into `table` + num_functions int // 1~16 mut: table []u8 } diff --git a/vlib/v/tests/orm_create_several_tables_test.v b/vlib/v/tests/orm_create_several_tables_test.v index 9385048fc8..fabdf05e0d 100644 --- a/vlib/v/tests/orm_create_several_tables_test.v +++ b/vlib/v/tests/orm_create_several_tables_test.v @@ -4,20 +4,20 @@ import db.sqlite @[table: 'visits'] struct Visit { - id int @[primary; sql: serial] + id int @[primary; sql: serial] site string } @[table: 'sites'] struct Site { - hostname string @[primary] + hostname string @[primary] owner int visits []Visit @[fkey: 'site'] } @[table: 'users'] struct User { - id int @[primary; sql: serial] + id int @[primary; sql: serial] name string sites []Site @[fkey: 'owner'] } diff --git a/vlib/v/tests/orm_enum_test.v b/vlib/v/tests/orm_enum_test.v index e9f7ab41fe..66a4fe0b65 100644 --- a/vlib/v/tests/orm_enum_test.v +++ b/vlib/v/tests/orm_enum_test.v @@ -9,7 +9,7 @@ enum Number { } struct Counter { - id int @[primary; sql: serial] + id int @[primary; sql: serial] number Number } diff --git a/vlib/v/tests/orm_stmt_wrong_return_checking_test.v b/vlib/v/tests/orm_stmt_wrong_return_checking_test.v index 925c7ac31a..4bbab36271 100644 --- a/vlib/v/tests/orm_stmt_wrong_return_checking_test.v +++ b/vlib/v/tests/orm_stmt_wrong_return_checking_test.v @@ -2,7 +2,7 @@ import db.sqlite struct Target { pub mut: - id int @[primary; sql: serial] + id int @[primary; sql: serial] kind ?string } diff --git a/vlib/v/tests/orm_sub_array_struct_test.v b/vlib/v/tests/orm_sub_array_struct_test.v index da8e4f5266..e9d69b1f2b 100644 --- a/vlib/v/tests/orm_sub_array_struct_test.v +++ b/vlib/v/tests/orm_sub_array_struct_test.v @@ -1,14 +1,14 @@ import db.sqlite struct Parent { - id int @[primary; sql: serial] + id int @[primary; sql: serial] name string children []Child @[fkey: 'parent_id'] } struct Child { mut: - id int @[primary; sql: serial] + id int @[primary; sql: serial] parent_id int name string } @@ -20,7 +20,7 @@ struct ParentString { struct ChildString { mut: - id int @[primary; sql: serial] + id int @[primary; sql: serial] parent_name string name string } diff --git a/vlib/v/tests/orm_sub_struct_test.v b/vlib/v/tests/orm_sub_struct_test.v index 3bd67bf99d..b520074c26 100644 --- a/vlib/v/tests/orm_sub_struct_test.v +++ b/vlib/v/tests/orm_sub_struct_test.v @@ -1,12 +1,12 @@ import db.sqlite struct Upper { - id int @[primary; sql: serial] + id int @[primary; sql: serial] sub SubStruct } struct SubStruct { - id int @[primary; sql: serial] + id int @[primary; sql: serial] name string } diff --git a/vlib/v/tests/sql_statement_inside_fn_call_test.v b/vlib/v/tests/sql_statement_inside_fn_call_test.v index ecf43b12d5..19636bb874 100644 --- a/vlib/v/tests/sql_statement_inside_fn_call_test.v +++ b/vlib/v/tests/sql_statement_inside_fn_call_test.v @@ -1,7 +1,7 @@ import db.sqlite struct Movie { - id int @[primary] + id int @[primary] name string } diff --git a/vlib/v/tests/struct_allow_both_field_defaults_and_skip_flag_test.v b/vlib/v/tests/struct_allow_both_field_defaults_and_skip_flag_test.v index 5b0ea045d5..7c99bed268 100644 --- a/vlib/v/tests/struct_allow_both_field_defaults_and_skip_flag_test.v +++ b/vlib/v/tests/struct_allow_both_field_defaults_and_skip_flag_test.v @@ -1,9 +1,9 @@ import json struct Foo { - x int = 123 + x int = 123 bar int = -112233 @[skip] - y int = 456 + y int = 456 } fn test_check_field_default_expr() { diff --git a/vlib/veb/auth/README.md b/vlib/veb/auth/README.md index b36bcd4e00..863cb2639a 100644 --- a/vlib/veb/auth/README.md +++ b/vlib/veb/auth/README.md @@ -29,7 +29,7 @@ pub struct Context { } struct User { - id int @[primary; sql: serial] + id int @[primary; sql: serial] name string password_hash string salt string @@ -98,4 +98,3 @@ algorithm and multiple iterations. See also: - [OWASP Password Storage Cheat Sheet](https://cheatsheetseries.owasp.org/cheatsheets/Password_Storage_Cheat_Sheet.html) - diff --git a/vlib/veb/auth/auth.v b/vlib/veb/auth/auth.v index 57baeaea13..4ca95f81de 100644 --- a/vlib/veb/auth/auth.v +++ b/vlib/veb/auth/auth.v @@ -18,7 +18,7 @@ pub struct Auth[T] { pub struct Token { pub: - id int @[primary; sql: serial] + id int @[primary; sql: serial] user_id int value string // ip string diff --git a/vlib/vweb/csrf/csrf_test.v b/vlib/vweb/csrf/csrf_test.v index 710af1270d..600fa04849 100644 --- a/vlib/vweb/csrf/csrf_test.v +++ b/vlib/vweb/csrf/csrf_test.v @@ -169,7 +169,7 @@ fn test_invalid_origin() { struct App { vweb.Context pub mut: - csrf csrf.CsrfApp @[vweb_global] + csrf csrf.CsrfApp @[vweb_global] middlewares map[string][]vweb.Middleware } diff --git a/vlib/vweb/vweb.v b/vlib/vweb/vweb.v index ea3754d25a..916443058b 100644 --- a/vlib/vweb/vweb.v +++ b/vlib/vweb/vweb.v @@ -153,8 +153,8 @@ pub const default_port = 8080 // It has fields for the query, form, files. pub struct Context { mut: - content_type string = 'text/plain' - status string = '200 OK' + content_type string = 'text/plain' + status string = '200 OK' ctx context.Context = context.EmptyContext{} pub mut: // HTTP Request @@ -1222,7 +1222,7 @@ fn (mut w Worker[T]) process_incoming_requests() { pub struct PoolParams[T] { pub: handler fn () T = unsafe { nil } @[required] - nr_workers int = runtime.nr_jobs() + nr_workers int = runtime.nr_jobs() } // database_pool creates a pool of database connections diff --git a/vlib/x/json2/tests/encode_struct_skippable_fields_test.v b/vlib/x/json2/tests/encode_struct_skippable_fields_test.v index cf329677a3..1c894b5c6a 100644 --- a/vlib/x/json2/tests/encode_struct_skippable_fields_test.v +++ b/vlib/x/json2/tests/encode_struct_skippable_fields_test.v @@ -35,7 +35,7 @@ mut: struct StructTypeSkippedFields4 { mut: - val string @[json: '-'] + val string @[json: '-'] val1 i64 val2 f64 val3 time.Time @@ -43,32 +43,32 @@ mut: struct StructTypeSkippedFields5 { mut: - val string @[json: '-'] - val1 i64 @[json: '-'] + val string @[json: '-'] + val1 i64 @[json: '-'] val2 f64 val3 time.Time } struct StructTypeSkippedFields6 { mut: - val string @[json: '-'] + val string @[json: '-'] val1 i64 - val2 f64 @[json: '-'] + val2 f64 @[json: '-'] val3 time.Time } struct StructTypeSkippedFields7 { mut: val string - val1 i64 @[json: '-'] - val2 f64 @[json: '-'] + val1 i64 @[json: '-'] + val2 f64 @[json: '-'] val3 time.Time } struct StructTypeSkippedFields8 { mut: val string - val1 i64 @[json: '-'] + val1 i64 @[json: '-'] val2 f64 val3 time.Time @[json: '-'] } diff --git a/vlib/x/json2/tests/json_module_compatibility_test/json_test.v b/vlib/x/json2/tests/json_module_compatibility_test/json_test.v index a4f389e1b5..5b6a9ffeb2 100644 --- a/vlib/x/json2/tests/json_module_compatibility_test/json_test.v +++ b/vlib/x/json2/tests/json_module_compatibility_test/json_test.v @@ -393,7 +393,7 @@ fn test_encode_decode_sumtype() { struct Foo3 { name string - age int @[omitempty] + age int @[omitempty] } // fn test_omit_empty() { diff --git a/vlib/x/sessions/db_store.v b/vlib/x/sessions/db_store.v index fbd3f71a98..b83d95342e 100644 --- a/vlib/x/sessions/db_store.v +++ b/vlib/x/sessions/db_store.v @@ -8,7 +8,7 @@ import time // a session data record pub struct DBStoreSessions { pub mut: - session_id string @[primary] + session_id string @[primary] created_at time.Time data string } diff --git a/vlib/x/sessions/sessions.v b/vlib/x/sessions/sessions.v index 1cf472ed79..4209439737 100644 --- a/vlib/x/sessions/sessions.v +++ b/vlib/x/sessions/sessions.v @@ -76,7 +76,7 @@ pub: @[heap] pub struct Sessions[T] { pub: - secret []u8 @[required] + secret []u8 @[required] cookie_options CookieOptions // max age of session data and id, default is 30 days max_age time.Duration = time.hour * 24 * 30 diff --git a/vlib/x/templating/dtm/dynamic_template_manager.v b/vlib/x/templating/dtm/dynamic_template_manager.v index 363c634b8e..7bdbbf41fb 100644 --- a/vlib/x/templating/dtm/dynamic_template_manager.v +++ b/vlib/x/templating/dtm/dynamic_template_manager.v @@ -70,7 +70,7 @@ mut: // cache database template_caches shared []TemplateCache = []TemplateCache{} // counter for each individual TemplateCache created/updated - id_counter int = 1 + id_counter int = 1 ch_cache_handler chan TemplateCache = chan TemplateCache{cap: dtm.cache_handler_channel_cap} // 'id_to_handlered' field is used exclusively by the cache handler to update or delete specific 'TemplateCache' in the cache database. id_to_handlered int @@ -161,7 +161,7 @@ struct HtmlFileInfo { pub struct TemplateCacheParams { pub: placeholders &map[string]DtmMultiTypeMap = &map[string]DtmMultiTypeMap{} - cache_delay_expiration i64 = dtm.cache_delay_expiration_by_default + cache_delay_expiration i64 = dtm.cache_delay_expiration_by_default } // DynamicTemplateManagerInitialisationParams is used with 'initialize' function. (See below at initialize section) diff --git a/vlib/x/ttf/README.md b/vlib/x/ttf/README.md index a219843130..0c6628da51 100644 --- a/vlib/x/ttf/README.md +++ b/vlib/x/ttf/README.md @@ -210,10 +210,10 @@ A text block is defined from a `Text_block` struct: ```v struct Text_block { - x int // x position of the left high corner - y int // y position of the left high corner - w int // width of the text block - h int // height of the text block + x int // x position of the left high corner + y int // y position of the left high corner + w int // width of the text block + h int // height of the text block cut_lines bool = true // force to cut the line if the length is over the text block width } ``` diff --git a/vlib/x/ttf/render_bmp.v b/vlib/x/ttf/render_bmp.v index d03a56ba4f..b4ac048fd1 100644 --- a/vlib/x/ttf/render_bmp.v +++ b/vlib/x/ttf/render_bmp.v @@ -21,26 +21,26 @@ pub mut: tf &TTF_File = unsafe { nil } buf &u8 = unsafe { nil } // pointer to the memory buffer buf_size int // allocated buf size in bytes - width int = 1 // width of the buffer - height int = 1 // height of the buffer - bp int = 4 // byte per pixel of the buffer + width int = 1 // width of the buffer + height int = 1 // height of the buffer + bp int = 4 // byte per pixel of the buffer bg_color u32 = 0xFFFFFF_00 // background RGBA format color u32 = 0x000000_FF // RGBA format - scale f32 = 1.0 // internal usage!! - scale_x f32 = 1.0 // X scale of the single glyph - scale_y f32 = 1.0 // Y scale of the single glyph - angle f32 = 0.0 // angle of rotation of the bitmap + scale f32 = 1.0 // internal usage!! + scale_x f32 = 1.0 // X scale of the single glyph + scale_y f32 = 1.0 // Y scale of the single glyph + angle f32 = 0.0 // angle of rotation of the bitmap // spaces - space_cw f32 = 1.0 // width of the space glyph internal usage!! + space_cw f32 = 1.0 // width of the space glyph internal usage!! space_mult f32 = f32(0.0) // 1.0/16.0 // space between letter, is a multiplier for a standard space ax // used only by internal text rendering!! tr_matrix []f32 = [f32(1), 0, 0, 0, 1, 0, 0, 0, 0] // transformation matrix ch_matrix []f32 = [f32(1), 0, 0, 0, 1, 0, 0, 0, 0] // character matrix style Style = .filled // default style - align Text_align = .left // default text align + align Text_align = .left // default text align justify bool // justify text flag, default deactivated justify_fill_ratio f32 = 0.5 // justify fill ratio, if the ratio of the filled row is >= of this then justify the text - filler [][]int // filler buffer for the renderer + filler [][]int // filler buffer for the renderer // flag to force font embedded metrics use_font_metrics bool } diff --git a/vlib/x/ttf/render_sokol_cpu.v b/vlib/x/ttf/render_sokol_cpu.v index 0d540f8ae2..0e54ecfc3d 100644 --- a/vlib/x/ttf/render_sokol_cpu.v +++ b/vlib/x/ttf/render_sokol_cpu.v @@ -24,7 +24,7 @@ pub mut: sg_img gfx.Image // sokol image sg_smp gfx.Sampler // sokol sampler scale_reduct f32 = 2.0 // scale of the cpu texture for filtering - device_dpi int = 72 // device DPI + device_dpi int = 72 // device DPI } /****************************************************************************** diff --git a/vlib/x/ttf/text_block.v b/vlib/x/ttf/text_block.v index 5f4cf1ae68..c20af1ec96 100644 --- a/vlib/x/ttf/text_block.v +++ b/vlib/x/ttf/text_block.v @@ -13,10 +13,10 @@ module ttf * TODO: **********************************************************************/ pub struct Text_block { - x int // x position of the left high corner - y int // y position of the left high corner - w int // width of the text block - h int // height of the text block + x int // x position of the left high corner + y int // y position of the left high corner + w int // width of the text block + h int // height of the text block cut_lines bool = true // force to cut the line if the length is over the text block width }