Skip to content

Commit

Permalink
all: run v fmt -w . in project root (#14)
Browse files Browse the repository at this point in the history
  • Loading branch information
larpon authored Oct 3, 2024
1 parent 7ba44be commit c52b0ac
Show file tree
Hide file tree
Showing 30 changed files with 135 additions and 137 deletions.
8 changes: 4 additions & 4 deletions analyse/analyse.v
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ mut:
// increase it's value by `amount`.
@[if shy_analyse ?]
fn tagged_count[T](tag string, key string, amount T) {
mut a := unsafe { analyse.hack } // TODO
mut a := unsafe { hack } // TODO
nkey := '[${tag}]${key}'
$if T is int {
a.entries[nkey] = '${a.entries[nkey].int() + amount}'
Expand Down Expand Up @@ -63,7 +63,7 @@ pub fn count_and_sum[T](key string, amount T) {

@[if shy_analyse ?]
pub fn max[T](key string, amount T) {
mut a := unsafe { analyse.hack } // TODO
mut a := unsafe { hack } // TODO
nkey := '[${@FN}]${key}'
$if T is int {
cur_amount := a.entries[nkey].int()
Expand Down Expand Up @@ -103,7 +103,7 @@ pub fn max[T](key string, amount T) {

@[if shy_analyse ?]
pub fn min[T](key string, amount T) {
mut a := unsafe { analyse.hack } // TODO
mut a := unsafe { hack } // TODO
nkey := '[${@FN}]${key}'
$if T is int {
cur_amount := a.entries[nkey].int()
Expand Down Expand Up @@ -144,7 +144,7 @@ pub fn min[T](key string, amount T) {
// eprintln_report prints the report via `eprintln`.
@[if shy_analyse ?]
pub fn eprintln_report() {
a := analyse.hack
a := hack
eprintln('--- analysis report ---')
mut sorted_keys := a.entries.keys()
sorted_keys.sort_with_compare(fn (a &string, b &string) int {
Expand Down
12 changes: 6 additions & 6 deletions cli/cli.v
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ pub fn launch_cmd(args []string, no_use_cache bool) ! {
cmd = cmd.all_after('test-')
}
v := vxt.vexe()
mut tool_src := os.join_path(cli.exe_dir, 'cmd', cmd)
mut tool_src := os.join_path(exe_dir, 'cmd', cmd)
tool_exe := tool_src + '.exe'
if !os.is_dir(tool_src) {
if os.is_file(tool_src + '.v') {
Expand All @@ -88,13 +88,13 @@ pub fn launch_cmd(args []string, no_use_cache bool) ! {
}
}
if os.is_executable(v) {
hash_file := os.join_path(cli.exe_dir, 'cmd', '.' + cmd + '.hash')
hash_file := os.join_path(exe_dir, 'cmd', '.' + cmd + '.hash')

mut hash := ''
if os.is_file(hash_file) {
hash = os.read_file(hash_file) or { '' }
}
if hash != cli.exe_git_hash || no_use_cache {
if hash != exe_git_hash || no_use_cache {
v_cmd := [
v,
'-o',
Expand All @@ -106,15 +106,15 @@ pub fn launch_cmd(args []string, no_use_cache bool) ! {
return error('${@MOD}.${@FN} failed compiling "${cmd}": ${res.output}')
}
if res.exit_code == 0 {
os.write_file(hash_file, cli.exe_git_hash) or {}
os.write_file(hash_file, exe_git_hash) or {}
} else {
vcmd := v_cmd.join(' ')
return error('${@MOD}.${@FN} "${vcmd}" failed:\n${res.output}')
}
}
}
if os.is_executable(tool_exe) {
os.setenv('SHY_EXE', os.join_path(cli.exe_dir, cli.exe_name), true)
os.setenv('SHY_EXE', os.join_path(exe_dir, exe_name), true)
$if windows {
exit(os.system('${os.quoted_path(tool_exe)} ${args}'))
} $else $if js {
Expand Down Expand Up @@ -174,7 +174,7 @@ pub fn string_to_args(input string) ![]string {
pub fn validate_input(input string) ! {
input_ext := os.file_ext(input)

accepted_input_ext := input_ext in cli.accepted_input_files
accepted_input_ext := input_ext in accepted_input_files
if !(os.is_dir(input) || accepted_input_ext) {
return error('input should be a V file or a directory containing V sources')
}
Expand Down
16 changes: 8 additions & 8 deletions ease/ease.v
Original file line number Diff line number Diff line change
Expand Up @@ -433,20 +433,20 @@ pub fn elastic(t f64, mode Mode) f64 {

@[inline]
pub fn in_elastic(t f64) f64 {
return -math.pow(2, 10 * t) * math.sin((t * 10 - 10.75) * ease.c4)
return -math.pow(2, 10 * t) * math.sin((t * 10 - 10.75) * c4)
}

@[inline]
pub fn out_elastic(t f64) f64 {
return math.pow(2, -10 * t) * math.sin((t * 10 - 0.75) * ease.c4) + 1
return math.pow(2, -10 * t) * math.sin((t * 10 - 0.75) * c4) + 1
}

@[inline]
pub fn in_out_elastic(t f64) f64 {
return if t < 0.5 {
-(math.pow(2, 20 * t - 10) * math.sin((20 * t - 11.125) * ease.c5)) / 2
-(math.pow(2, 20 * t - 10) * math.sin((20 * t - 11.125) * c5)) / 2
} else {
(math.pow(2, -20 * t + 10) * math.sin((20 * t - 11.125) * ease.c5)) / 2 + 1
(math.pow(2, -20 * t + 10) * math.sin((20 * t - 11.125) * c5)) / 2 + 1
}
}

Expand All @@ -466,20 +466,20 @@ pub fn back(t f64, mode Mode) f64 {

@[inline]
pub fn in_back(t f64) f64 {
return ease.c3 * t * t * t - ease.c1 * t * t
return c3 * t * t * t - c1 * t * t
}

@[inline]
pub fn out_back(t f64) f64 {
return 1.0 + ease.c3 * math.pow(t - 1, 3) + ease.c1 * math.pow(t - 1, 2)
return 1.0 + c3 * math.pow(t - 1, 3) + c1 * math.pow(t - 1, 2)
}

@[inline]
pub fn in_out_back(t f64) f64 {
return if t < 0.5 {
(math.pow(2 * t, 2) * ((ease.c2 + 1) * 2 * t - ease.c2)) / 2
(math.pow(2 * t, 2) * ((c2 + 1) * 2 * t - c2)) / 2
} else {
(math.pow(2 * t - 2, 2) * ((ease.c2 + 1) * (t * 2 - 2) + ease.c2) + 2) / 2
(math.pow(2 * t - 2, 2) * ((c2 + 1) * (t * 2 - 2) + c2) + 2) / 2
}
}

Expand Down
4 changes: 2 additions & 2 deletions easy/easy.api.v
Original file line number Diff line number Diff line change
Expand Up @@ -696,8 +696,8 @@ pub fn (e &Easy) image(eic ImageConfig) Image {
}

return Image{
shy: e.shy
Rect: shy.Rect{
shy: e.shy
Rect: shy.Rect{
x: 0
y: 0
width: 0
Expand Down
8 changes: 4 additions & 4 deletions easy/particles.v
Original file line number Diff line number Diff line change
Expand Up @@ -110,11 +110,11 @@ pub fn (mut e Easy) image_particle_painter(config ImageParticlePainterConfig) Im

fn default_particle_painter(mut e Easy) ImageParticlePainter {
e.quick.load(shy.ImageOptions{
source: easy.default_particle_image
source: default_particle_image
}) or { panic(err) }

return e.image_particle_painter(
source: easy.default_particle_image
source: default_particle_image
color_variation: shy.ColorVariation{0, 0, 0, 0.3}
)
}
Expand All @@ -125,7 +125,7 @@ pub:
groups []string = ['default']
color shy.Color = shy.colors.shy.white
color_variation shy.ColorVariation
source shy.AssetSource = easy.default_particle_image
source shy.AssetSource = default_particle_image
}

@[noinit: 'Easy.make_image_particle_painter']
Expand All @@ -135,7 +135,7 @@ mut:
groups []string = ['default']
color shy.Color = shy.colors.shy.white
color_variation shy.ColorVariation
source shy.AssetSource = easy.default_particle_image
source shy.AssetSource = default_particle_image
}

fn (mut ip ImageParticlePainter) init(mut p particle.Particle) {
Expand Down
2 changes: 1 addition & 1 deletion examples/animation/animators.v
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ pub fn (mut a App) init() ! {
a.ExampleApp.init()!

a_config := shy.AnimatorConfig{
ease: ease.Ease{
ease: ease.Ease{
kind: .sine
mode: .in_out
// custom_fn: custom_ease
Expand Down
6 changes: 3 additions & 3 deletions examples/particles/simple.v
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ pub fn (mut a App) init() ! {

scale := f32(6.0)
a.eps.add(particle.Emitter{
rate: 50
position: shy.vec2[f32](shy.half * a.window.width, shy.half * a.window.height)
velocity: particle.PointDirection{
rate: 50
position: shy.vec2[f32](shy.half * a.window.width, shy.half * a.window.height)
velocity: particle.PointDirection{
point: shy.vec2[f32](0.0, -0.5 * scale * 0.5)
point_variation: shy.vec2[f32](0.2, 0.5)
}
Expand Down
4 changes: 2 additions & 2 deletions examples/render_step/render_step.v
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ mut:
pub fn (mut a App) init() ! {
a.ExampleApp.init()!
a.a_r = a.shy.new_animator[f32](
ease: ease.Ease{
ease: ease.Ease{
kind: .sine
mode: .in_out
}
Expand All @@ -33,7 +33,7 @@ pub fn (mut a App) init() ! {
loop: .pingpong
)
a.a_s = a.shy.new_animator[f32](
ease: ease.Ease{
ease: ease.Ease{
kind: .back
mode: .in_out
}
Expand Down
4 changes: 2 additions & 2 deletions examples/render_step/ui_and_manual_mode.v
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ pub fn (mut a App) event(e shy.Event) {
end_value := a.a_r.value()
if a.window.mode == .immediate {
a.a_r = a.shy.new_animator[f32](
ease: ease.Ease{
ease: ease.Ease{
kind: .sine
mode: .in_out
}
Expand All @@ -106,7 +106,7 @@ pub fn (mut a App) event(e shy.Event) {
)
} else {
a.a_r = a.shy.new_animator[f32](
ease: ease.Ease{
ease: ease.Ease{
kind: .sine
mode: .in_out
}
Expand Down
2 changes: 1 addition & 1 deletion export/export.v
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ pub fn string_to_export_format(str string) !Format {
.android_aab
}
else {
error('${@MOD}.${@FN}: unsupported format "${str}". Available: ${export.available_format_strings}')
error('${@MOD}.${@FN}: unsupported format "${str}". Available: ${available_format_strings}')
}
}
}
Expand Down
8 changes: 4 additions & 4 deletions fetch/fetch.v
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ mut:
job_queue []LoadJob
ch_in chan LoadJob
ch_out chan JobStatus
threads []thread = []thread{cap: int(fetch.c_max_threads)}
threads []thread = []thread{cap: int(c_max_threads)}
}

@[params]
Expand Down Expand Up @@ -88,7 +88,7 @@ pub:

pub fn (mut l Loader) init() ! {
// l.threads := []thread{cap: c_max_threads}
for t in 0 .. fetch.c_max_threads {
for t in 0 .. c_max_threads {
l.threads << spawn l.worker(t, l.ch_in, l.ch_out)
}
}
Expand Down Expand Up @@ -214,10 +214,10 @@ fn (mut l Loader) worker(thread_id int, ch_in chan LoadJob, ch_out chan JobStatu
bytes_total := bytes.len
mut bytes_sent := 0
for bytes_sent < bytes_total {
mut chunk := [fetch.c_chunk_size]u8{}
mut chunk := [c_chunk_size]u8{}
mut size := u16(0)
mut one_byte := bytes[bytes_sent]
for i := 0; i < fetch.c_chunk_size; i++ {
for i := 0; i < c_chunk_size; i++ {
chunk[i] = one_byte
size++
bytes_sent++
Expand Down
4 changes: 2 additions & 2 deletions lib/animation.v
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,7 @@ fn (mut a Animator[T]) ended() {
if a.loops > 0 {
a.loops--
a.restart()
} else if a.loops == lib.infinite {
} else if a.loops == infinite {
a.restart()
} else {
a.running = false
Expand All @@ -338,7 +338,7 @@ fn (mut a Animator[T]) ended() {
a.from, a.to = a.to, a.from
a.loops--
a.restart()
} else if a.loops == lib.infinite {
} else if a.loops == infinite {
a.from, a.to = a.to, a.from
a.restart()
} else {
Expand Down
26 changes: 13 additions & 13 deletions lib/assets.v
Original file line number Diff line number Diff line change
Expand Up @@ -92,24 +92,24 @@ fn (mut a Assets) load_error_assets() ! {
status: .error
}
ass_image := a.load(
source: lib.c_embedded_asset_error_image
source: c_embedded_asset_error_image
)!
a.error_image = ass_image.to[Image](ImageOptions{
source: lib.c_embedded_asset_error_image
source: c_embedded_asset_error_image
})!

ass_blob := a.load(
source: lib.c_embedded_asset_error_blob
source: c_embedded_asset_error_blob
)!
a.error_blob = ass_blob.to[Blob](BlobOptions{
source: lib.c_embedded_asset_error_blob
source: c_embedded_asset_error_blob
})!

ass_sound := a.load(
source: lib.c_embedded_asset_error_sound
source: c_embedded_asset_error_sound
)!
a.error_sound = ass_sound.to[Sound](SoundOptions{
source: lib.c_embedded_asset_error_sound
source: c_embedded_asset_error_sound
})!
}

Expand Down Expand Up @@ -821,15 +821,15 @@ pub enum ImageKind {
}

pub enum ImageFillMode {
stretch // image is stretched to fit all of image width and height
stretch // image is stretched to fit all of image width and height
stretch_horizontally_tile_vertically // image is stretched to fit image width and tiled along the y axis (height/vertically)
stretch_vertically_tile_horizontally // image is stretched to fit image height and tiled along the x axis (width/horizontally)
aspect_fit // image is scaled uniformly to fit with no cropping into image width and height
aspect_crop // image is scaled uniformly to fill image width and height and cropped if necessary
tile // image is duplicated horizontally and vertically
tile_vertically // image is stretched horizontally and tiled vertically
tile_horizontally // image is stretched vertically and tiled horizontally
pad // image is not transformed, leaving empty space if image width and/or height is > that loaded bitmap width/height
aspect_fit // image is scaled uniformly to fit with no cropping into image width and height
aspect_crop // image is scaled uniformly to fill image width and height and cropped if necessary
tile // image is duplicated horizontally and vertically
tile_vertically // image is stretched horizontally and tiled vertically
tile_horizontally // image is stretched vertically and tiled horizontally
pad // image is not transformed, leaving empty space if image width and/or height is > that loaded bitmap width/height
}

pub fn (ifm ImageFillMode) next() ImageFillMode {
Expand Down
6 changes: 3 additions & 3 deletions lib/audio.b.v
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,11 @@ pub fn (mut a Audio) init() ! {

pub fn (mut a Audio) new_engine() !&AudioEngine {
a.shy.vet_issue(.warn, .hot_code, '${@STRUCT}.${@FN}', 'memory fragmentation can happen when allocating in hot code paths. It is, in general, better to pre-load data')
if a.engine_id >= lib.max_audio_engine_instances - 1 {
if a.engine_id == lib.max_audio_engine_instances - 1 {
if a.engine_id >= max_audio_engine_instances - 1 {
if a.engine_id == max_audio_engine_instances - 1 {
a.shy.log.gwarn('${@STRUCT}.${@FN}', 'creating last AudioEngine instance')
} else {
return error('the maximum amount of audio engines (${lib.max_audio_engine_instances}) is reached')
return error('the maximum amount of audio engines (${max_audio_engine_instances}) is reached')
}
}
mini_audio_engine := &ma.Engine{}
Expand Down
Loading

0 comments on commit c52b0ac

Please sign in to comment.