Skip to content

Commit

Permalink
fmt: fix and simplify align of struct fields (#21995)
Browse files Browse the repository at this point in the history
  • Loading branch information
yuyi98 authored Aug 5, 2024
1 parent 576a0ab commit ddb6685
Show file tree
Hide file tree
Showing 139 changed files with 553 additions and 519 deletions.
24 changes: 12 additions & 12 deletions .github/workflows/v_apps_and_modules_compile_ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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' }}
Expand Down
4 changes: 2 additions & 2 deletions cmd/tools/modules/testing/common.v
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions cmd/tools/modules/vgit/vgit.v
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 5 additions & 5 deletions cmd/tools/oldv.v
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
2 changes: 1 addition & 1 deletion cmd/tools/vcover/main.v
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/tools/vpm/vcs.v
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
26 changes: 13 additions & 13 deletions cmd/tools/vrepl.v
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 4 additions & 4 deletions cmd/tools/vtest-all.v
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
Expand Down
2 changes: 1 addition & 1 deletion cmd/tools/vvet/errors.v
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions doc/docs.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -7895,4 +7895,4 @@ Assignment Operators
&= |= ^=
>>= <<= >>>=
&&= ||=
```
```
6 changes: 3 additions & 3 deletions examples/brainvuck.v
Original file line number Diff line number Diff line change
Expand Up @@ -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 `[`.
}
Expand Down
2 changes: 1 addition & 1 deletion examples/clock/clock.v
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
8 changes: 4 additions & 4 deletions examples/database/orm.v
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand All @@ -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
}
Expand Down
10 changes: 5 additions & 5 deletions examples/flag/animated_help_text.v
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
10 changes: 5 additions & 5 deletions examples/flag/flag_layout_editor.v
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
2 changes: 1 addition & 1 deletion examples/gg/bezier.v
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
2 changes: 1 addition & 1 deletion examples/js_dom_draw_benchmark_chart/chart/main.v
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
2 changes: 1 addition & 1 deletion examples/js_dom_draw_benchmark_chart/v_vweb_orm/src/main.v
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
2 changes: 1 addition & 1 deletion examples/sokol/06_obj_viewer/modules/obj/struct.v
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
4 changes: 2 additions & 2 deletions examples/sokol/sounds/melody.v
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
4 changes: 2 additions & 2 deletions examples/term.ui/term_drawing.v
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
2 changes: 1 addition & 1 deletion examples/term.ui/vyper.v
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion examples/viewer/view.v
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion examples/vweb_fullstack/src/product_entities.v
Original file line number Diff line number Diff line change
Expand Up @@ -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']
Expand Down
6 changes: 3 additions & 3 deletions examples/vweb_fullstack/src/user_entities.v
Original file line number Diff line number Diff line change
Expand Up @@ -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']
}
2 changes: 1 addition & 1 deletion examples/xvweb/todo/main.v
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion tutorials/building_a_simple_web_blog_with_vweb/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
module main

struct Article {
id int @[primary; sql: serial]
id int @[primary; sql: serial]
title string
text string
}
Expand Down
2 changes: 1 addition & 1 deletion vlib/builtin/prealloc.c.v
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions vlib/cli/command.v
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading

0 comments on commit ddb6685

Please sign in to comment.