mirror of
https://github.com/vlang/v.git
synced 2025-09-13 22:42:26 +03:00
fmt: fix alignment of struct init fields (#22025)
This commit is contained in:
parent
99da5726db
commit
c51d30bf53
671 changed files with 18817 additions and 18787 deletions
|
@ -28,19 +28,19 @@ pub fn new_app(args simargs.ParallelArgs) &App {
|
|||
total_pixels := args.grid.height * args.grid.width
|
||||
|
||||
mut app := &App{
|
||||
args: args
|
||||
pixels: []u32{len: total_pixels}
|
||||
args: args
|
||||
pixels: []u32{len: total_pixels}
|
||||
request_chan: chan &sim.SimRequest{cap: args.grid.width}
|
||||
}
|
||||
app.gg = gg.new_context(
|
||||
width: args.grid.width
|
||||
height: args.grid.height
|
||||
width: args.grid.width
|
||||
height: args.grid.height
|
||||
create_window: true
|
||||
window_title: 'V Pendulum Simulation'
|
||||
user_data: app
|
||||
bg_color: anim.bg_color
|
||||
frame_fn: frame
|
||||
init_fn: init
|
||||
window_title: 'V Pendulum Simulation'
|
||||
user_data: app
|
||||
bg_color: anim.bg_color
|
||||
frame_fn: frame
|
||||
init_fn: init
|
||||
)
|
||||
return app
|
||||
}
|
||||
|
|
|
@ -69,23 +69,23 @@ fn parse_sequential_args() !SequentialArgs {
|
|||
}
|
||||
|
||||
params := sim.sim_params(
|
||||
rope_length: rope_length
|
||||
bearing_mass: bearing_mass
|
||||
magnet_spacing: magnet_spacing
|
||||
magnet_height: magnet_height
|
||||
rope_length: rope_length
|
||||
bearing_mass: bearing_mass
|
||||
magnet_spacing: magnet_spacing
|
||||
magnet_height: magnet_height
|
||||
magnet_strength: magnet_strength
|
||||
gravity: gravity
|
||||
gravity: gravity
|
||||
)
|
||||
|
||||
grid := sim.new_grid_settings(
|
||||
width: width
|
||||
width: width
|
||||
height: height
|
||||
)
|
||||
|
||||
args := SequentialArgs{
|
||||
params: params
|
||||
params: params
|
||||
filename: filename
|
||||
grid: grid
|
||||
grid: grid
|
||||
}
|
||||
|
||||
sim.log('${args}')
|
||||
|
@ -122,24 +122,24 @@ fn parse_parallel_args(extra_workers int) !ParallelArgs {
|
|||
}
|
||||
|
||||
params := sim.sim_params(
|
||||
rope_length: rope_length
|
||||
bearing_mass: bearing_mass
|
||||
magnet_spacing: magnet_spacing
|
||||
magnet_height: magnet_height
|
||||
rope_length: rope_length
|
||||
bearing_mass: bearing_mass
|
||||
magnet_spacing: magnet_spacing
|
||||
magnet_height: magnet_height
|
||||
magnet_strength: magnet_strength
|
||||
gravity: gravity
|
||||
gravity: gravity
|
||||
)
|
||||
|
||||
grid := sim.new_grid_settings(
|
||||
width: width
|
||||
width: width
|
||||
height: height
|
||||
)
|
||||
|
||||
args := ParallelArgs{
|
||||
params: params
|
||||
params: params
|
||||
filename: filename
|
||||
grid: grid
|
||||
workers: get_workers(workers, extra_workers)
|
||||
grid: grid
|
||||
workers: get_workers(workers, extra_workers)
|
||||
}
|
||||
sim.log('${args}')
|
||||
|
||||
|
|
|
@ -20,14 +20,14 @@ pub fn new_image_settings(settings ImageSettings) ImageSettings {
|
|||
|
||||
pub fn image_settings_from_grid(grid sim.GridSettings) ImageSettings {
|
||||
return ImageSettings{
|
||||
width: grid.width
|
||||
width: grid.width
|
||||
height: grid.height
|
||||
}
|
||||
}
|
||||
|
||||
pub fn (s ImageSettings) to_grid_settings() sim.GridSettings {
|
||||
return sim.GridSettings{
|
||||
width: s.width
|
||||
width: s.width
|
||||
height: s.height
|
||||
}
|
||||
}
|
||||
|
@ -42,7 +42,7 @@ mut:
|
|||
pub fn ppm_writer_for_fname(fname string, settings ImageSettings) !&PPMWriter {
|
||||
mut writer := &PPMWriter{
|
||||
cache_size: settings.cache_size
|
||||
cache: []u8{cap: settings.cache_size}
|
||||
cache: []u8{cap: settings.cache_size}
|
||||
}
|
||||
writer.start_for_file(fname, settings)!
|
||||
return writer
|
||||
|
|
|
@ -23,9 +23,9 @@ pub fn new_image_writer(mut writer PPMWriter, settings ImageSettings) &ImageWrit
|
|||
valid: false
|
||||
}}
|
||||
return &ImageWriter{
|
||||
writer: writer
|
||||
writer: writer
|
||||
settings: settings
|
||||
buffer: buffer
|
||||
buffer: buffer
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -3,12 +3,12 @@ module sim
|
|||
import math
|
||||
|
||||
const params_test_mock_params = SimParams{
|
||||
rope_length: 0.25
|
||||
bearing_mass: 0.03
|
||||
magnet_spacing: 0.05
|
||||
magnet_height: 0.03
|
||||
rope_length: 0.25
|
||||
bearing_mass: 0.03
|
||||
magnet_spacing: 0.05
|
||||
magnet_height: 0.03
|
||||
magnet_strength: 10
|
||||
gravity: 4.9
|
||||
gravity: 4.9
|
||||
}
|
||||
const params_test_mock_state = SimState{
|
||||
position: vector(
|
||||
|
|
|
@ -70,8 +70,8 @@ pub fn run(params SimParams, settings RunnerSettings) {
|
|||
|
||||
state.satisfy_rope_constraint(params)
|
||||
request := &SimRequest{
|
||||
id: index
|
||||
state: state
|
||||
id: index
|
||||
state: state
|
||||
params: params
|
||||
}
|
||||
settings.on_request(request) or {
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
module sim
|
||||
|
||||
const sim_test_mock_params = SimParams{
|
||||
rope_length: 0.25
|
||||
bearing_mass: 0.03
|
||||
magnet_spacing: 0.05
|
||||
magnet_height: 0.03
|
||||
rope_length: 0.25
|
||||
bearing_mass: 0.03
|
||||
magnet_spacing: 0.05
|
||||
magnet_height: 0.03
|
||||
magnet_strength: 10
|
||||
gravity: 4.9
|
||||
gravity: 4.9
|
||||
}
|
||||
const sim_test_mock_state = SimState{
|
||||
position: vector(
|
||||
|
|
|
@ -56,8 +56,8 @@ pub fn compute_result(request SimRequest) &SimResult {
|
|||
id := request.id
|
||||
|
||||
return &SimResult{
|
||||
id: id
|
||||
state: state
|
||||
id: id
|
||||
state: state
|
||||
magnet1_distance: m1_dist
|
||||
magnet2_distance: m2_dist
|
||||
magnet3_distance: m3_dist
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
module sim
|
||||
|
||||
const worker_test_mock_params = SimParams{
|
||||
rope_length: 0.25
|
||||
bearing_mass: 0.03
|
||||
magnet_spacing: 0.05
|
||||
magnet_height: 0.03
|
||||
rope_length: 0.25
|
||||
bearing_mass: 0.03
|
||||
magnet_spacing: 0.05
|
||||
magnet_height: 0.03
|
||||
magnet_strength: 10
|
||||
gravity: 4.9
|
||||
gravity: 4.9
|
||||
}
|
||||
const worker_test_mock_state = SimState{
|
||||
position: vector(
|
||||
|
@ -28,9 +28,9 @@ const worker_test_mock_state = SimState{
|
|||
|
||||
fn test_compute_result() {
|
||||
request := SimRequest{
|
||||
id: 0
|
||||
id: 0
|
||||
params: sim.worker_test_mock_params
|
||||
state: sim.worker_test_mock_state
|
||||
state: sim.worker_test_mock_state
|
||||
}
|
||||
expected_state := SimState{
|
||||
position: vector(
|
||||
|
@ -50,8 +50,8 @@ fn test_compute_result() {
|
|||
)
|
||||
}
|
||||
expected := &SimResult{
|
||||
state: expected_state
|
||||
id: 0
|
||||
state: expected_state
|
||||
id: 0
|
||||
magnet1_distance: 0.07993696666249225
|
||||
magnet2_distance: 0.07993696666249224
|
||||
magnet3_distance: 0.03609361938278008
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue