diff --git a/analyse/analyse.v b/analyse/analyse.v index 3ce78f7..81da009 100644 --- a/analyse/analyse.v +++ b/analyse/analyse.v @@ -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}' @@ -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() @@ -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() @@ -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 { diff --git a/cli/cli.v b/cli/cli.v index 182d51c..4f7f232 100644 --- a/cli/cli.v +++ b/cli/cli.v @@ -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') { @@ -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', @@ -106,7 +106,7 @@ 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}') @@ -114,7 +114,7 @@ pub fn launch_cmd(args []string, no_use_cache bool) ! { } } 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 { @@ -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') } diff --git a/ease/ease.v b/ease/ease.v index 50f1734..24caa99 100644 --- a/ease/ease.v +++ b/ease/ease.v @@ -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 } } @@ -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 } } diff --git a/easy/easy.api.v b/easy/easy.api.v index f2f4335..90dc4c5 100644 --- a/easy/easy.api.v +++ b/easy/easy.api.v @@ -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 diff --git a/easy/particles.v b/easy/particles.v index a9448e7..4f7fdbf 100644 --- a/easy/particles.v +++ b/easy/particles.v @@ -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} ) } @@ -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'] @@ -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) { diff --git a/examples/animation/animators.v b/examples/animation/animators.v index 77a8965..35e5d96 100644 --- a/examples/animation/animators.v +++ b/examples/animation/animators.v @@ -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 diff --git a/examples/particles/simple.v b/examples/particles/simple.v index 73555d8..02dc73d 100644 --- a/examples/particles/simple.v +++ b/examples/particles/simple.v @@ -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) } diff --git a/examples/render_step/render_step.v b/examples/render_step/render_step.v index 825073a..d88df52 100644 --- a/examples/render_step/render_step.v +++ b/examples/render_step/render_step.v @@ -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 } @@ -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 } diff --git a/examples/render_step/ui_and_manual_mode.v b/examples/render_step/ui_and_manual_mode.v index a2ecf1e..387adb3 100644 --- a/examples/render_step/ui_and_manual_mode.v +++ b/examples/render_step/ui_and_manual_mode.v @@ -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 } @@ -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 } diff --git a/export/export.v b/export/export.v index 20b5507..e4070eb 100644 --- a/export/export.v +++ b/export/export.v @@ -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}') } } } diff --git a/fetch/fetch.v b/fetch/fetch.v index 48c6758..dda5ed5 100644 --- a/fetch/fetch.v +++ b/fetch/fetch.v @@ -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] @@ -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) } } @@ -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++ diff --git a/lib/animation.v b/lib/animation.v index 7704b66..147ef39 100644 --- a/lib/animation.v +++ b/lib/animation.v @@ -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 @@ -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 { diff --git a/lib/assets.v b/lib/assets.v index 4745534..8f45b58 100644 --- a/lib/assets.v +++ b/lib/assets.v @@ -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 })! } @@ -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 { diff --git a/lib/audio.b.v b/lib/audio.b.v index 4b945c6..c47c064 100644 --- a/lib/audio.b.v +++ b/lib/audio.b.v @@ -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{} diff --git a/lib/config.v b/lib/config.v index 4f24ef4..cd9c881 100644 --- a/lib/config.v +++ b/lib/config.v @@ -91,27 +91,27 @@ pub: pub struct WindowConfig { Rect pub: - title string = lib.defaults.window.title - resizable bool = lib.defaults.window.resizable - fullscreen bool = lib.defaults.window.fullscreen + title string = defaults.window.title + resizable bool = defaults.window.resizable + fullscreen bool = defaults.window.fullscreen visible bool = true - color Color = lib.defaults.window.color + color Color = defaults.window.color // TODO ? flags WindowFlag render RenderConfig } pub struct RenderConfig { pub: - update_rate f64 = lib.defaults.render.update_rate - update_multiplicity u8 = lib.defaults.render.update_multiplicity - lock_framerate bool = lib.defaults.render.lock_framerate - time_history_count u8 = lib.defaults.render.time_history_count - vsync VSync = lib.defaults.render.vsync - msaa int = lib.defaults.render.msaa + update_rate f64 = defaults.render.update_rate + update_multiplicity u8 = defaults.render.update_multiplicity + lock_framerate bool = defaults.render.lock_framerate + time_history_count u8 = defaults.render.time_history_count + vsync VSync = defaults.render.vsync + msaa int = defaults.render.msaa } pub struct InputConfig { - mice bool = lib.defaults.input.mice + mice bool = defaults.input.mice } pub fn config_from_toml_file(path string) !Config { @@ -127,22 +127,22 @@ pub fn config_from_toml_text(toml_text string) !Config { // toml_rend_c := toml_doc.value('shy.render') rend_c := RenderConfig{ - update_rate: toml_rend_c.value('update_rate').default_to(lib.defaults.render.update_rate).f64() - update_multiplicity: u8(toml_rend_c.value('update_multiplicity').default_to(int(lib.defaults.render.update_multiplicity)).int()) - lock_framerate: toml_rend_c.value('lock_framerate').default_to(lib.defaults.render.lock_framerate).bool() - time_history_count: u8(toml_rend_c.value('time_history_count').default_to(int(lib.defaults.render.time_history_count)).int()) + update_rate: toml_rend_c.value('update_rate').default_to(defaults.render.update_rate).f64() + update_multiplicity: u8(toml_rend_c.value('update_multiplicity').default_to(int(defaults.render.update_multiplicity)).int()) + lock_framerate: toml_rend_c.value('lock_framerate').default_to(defaults.render.lock_framerate).bool() + time_history_count: u8(toml_rend_c.value('time_history_count').default_to(int(defaults.render.time_history_count)).int()) vsync: vsynctype_from_string(toml_rend_c.value('vsync').default_to('on').string()) - msaa: toml_rend_c.value('msaa').default_to(lib.defaults.render.msaa).int() + msaa: toml_rend_c.value('msaa').default_to(defaults.render.msaa).int() } wc := WindowConfig{ - title: toml_wc.value('title').default_to(lib.defaults.window.title).string() - resizable: toml_wc.value('resizable').default_to(lib.defaults.window.resizable).bool() + title: toml_wc.value('title').default_to(defaults.window.title).string() + resizable: toml_wc.value('resizable').default_to(defaults.window.resizable).bool() render: rend_c } // toml_input_c := toml_doc.value('shy.input') input_c := InputConfig{ - mice: toml_input_c.value('mice').default_to(lib.defaults.input.mice).bool() + mice: toml_input_c.value('mice').default_to(defaults.input.mice).bool() } return Config{ diff --git a/lib/event.b.v b/lib/event.b.v index 7f8ef72..a57a380 100644 --- a/lib/event.b.v +++ b/lib/event.b.v @@ -45,7 +45,7 @@ pub fn (mut e Events) init() ! { e.queue.free() // free(e.queue) // TODO fail when using `-gc none` } - e.queue = []Event{len: 0, cap: 10000, init: lib.empty_event} + e.queue = []Event{len: 0, cap: 10000, init: empty_event} unsafe { e.queue.flags.set(.noslices | .noshrink | .nogrow) } analyse.max('${@MOD}.${@STRUCT}.queue.cap', e.queue.cap) } diff --git a/lib/gfx.b.v b/lib/gfx.b.v index d0fcf92..fa51880 100644 --- a/lib/gfx.b.v +++ b/lib/gfx.b.v @@ -433,7 +433,7 @@ pub fn (mut g GFX) end_easy_frame(options EndOptions) { } .passthru { pass := gfx.Pass{ - action: lib.dontcare_pass + action: dontcare_pass attachments: off.attachments } gfx.begin_pass(&pass) diff --git a/lib/script.wren_d_shy_use_wren.v b/lib/script.wren_d_shy_use_wren.v index 3084d96..3e5d831 100644 --- a/lib/script.wren_d_shy_use_wren.v +++ b/lib/script.wren_d_shy_use_wren.v @@ -63,7 +63,7 @@ pub fn (mut w WrenVM) init() ! { w.vm = vm // TODO TEST ONLY - w.eval('shy', lib.shy_in_wren) or { return error('${@STRUCT}.${@FN}: ${err}') } + w.eval('shy', shy_in_wren) or { return error('${@STRUCT}.${@FN}: ${err}') } // Register handle for the Shy.frame method w.vm.ensure_slots(1) diff --git a/lib/shy.v b/lib/shy.v index f241392..e8b7480 100644 --- a/lib/shy.v +++ b/lib/shy.v @@ -28,7 +28,7 @@ mut: struct ShyStruct { pub mut: // TODO error: field `App.shy` is not public - make this just "pub" to callers - and mut to internal system - shy &Shy = lib.null + shy &Shy = null } pub fn (s ShyStruct) str() string { @@ -43,7 +43,7 @@ fn (s ShyStruct) init() ! { fn (mut s ShyStruct) shutdown() ! { assert !isnil(s.shy), '${@STRUCT}.${@FN}' + 'shy is null' - s.shy = lib.null + s.shy = null } struct ShyFrame { @@ -247,11 +247,11 @@ pub fn (s &Shy) vet_issue(c VetCategory, area VetArea, caller string, msg string match area { .hot_code { if s.state.in_hot_code { - s.log.gwarn('${lib.vet_tag} ' + prefix, msg) + s.log.gwarn('${vet_tag} ' + prefix, msg) } } else { - s.log.gwarn('${lib.vet_tag} ' + prefix, msg) + s.log.gwarn('${vet_tag} ' + prefix, msg) } } } diff --git a/lib/window.sdl.v b/lib/window.sdl.v index bce4b4d..a357418 100644 --- a/lib/window.sdl.v +++ b/lib/window.sdl.v @@ -98,7 +98,7 @@ pub: // record_frame acts according to the config specified in `shy.frame_record_config`. @[if shy_record ?] fn (mut w Window) record_frame() { - rc := lib.frame_record_config + rc := frame_record_config frame := w.state.frame valid_window := rc.windows.len == 0 || w.id in rc.windows if !valid_window { diff --git a/log/log.v b/log/log.v index 75a8378..dcd28a5 100644 --- a/log/log.v +++ b/log/log.v @@ -16,7 +16,7 @@ const default_flags = get_default_flags_workaround() // TODO @[markused] fn todo_() { - _ := log.default_flags + _ := default_flags } fn get_default_flags_workaround() Flag { @@ -53,7 +53,7 @@ fn (lf Flag) clean_str() string { // Log makes it possible to categorize and color log entries pub struct Log { mut: - flags Flag = log.default_flags + flags Flag = default_flags buffer strings.Builder = strings.new_builder(4096) } @@ -199,10 +199,10 @@ pub fn (l &Log) info(str string) { if l.flags.has(.info) { if l.flags.has(.buffer) { unsafe { - l.buffer.writeln(log.label_info + ' ' + str) + l.buffer.writeln(label_info + ' ' + str) } } - maybe_colored := l.colorize('blue', log.label_info + ' ') + maybe_colored := l.colorize('blue', label_info + ' ') l.redirect(maybe_colored + str) } } @@ -212,10 +212,10 @@ pub fn (l &Log) warn(str string) { if l.flags.has(.warn) { if l.flags.has(.buffer) { unsafe { - l.buffer.writeln(log.label_warn + ' ' + str) + l.buffer.writeln(label_warn + ' ' + str) } } - maybe_colored := l.colorize('yellow', log.label_warn + ' ') + maybe_colored := l.colorize('yellow', label_warn + ' ') l.redirect(maybe_colored + str) } } @@ -225,10 +225,10 @@ pub fn (l &Log) error(str string) { if l.flags.has(.error) { if l.flags.has(.buffer) { unsafe { - l.buffer.writeln(log.label_error + ' ' + str) + l.buffer.writeln(label_error + ' ' + str) } } - maybe_colored := l.colorize('bright_red', log.label_error + ' ') + maybe_colored := l.colorize('bright_red', label_error + ' ') l.redirect(maybe_colored + str) } } @@ -238,10 +238,10 @@ pub fn (l &Log) critical(str string) { if l.flags.has(.critical) { if l.flags.has(.buffer) { unsafe { - l.buffer.writeln(log.label_critical + ' ' + str) + l.buffer.writeln(label_critical + ' ' + str) } } - maybe_colored := l.colorize('red', log.label_critical + ' ') + maybe_colored := l.colorize('red', label_critical + ' ') l.redirect(maybe_colored + str) } } @@ -251,10 +251,10 @@ pub fn (l &Log) debug(str string) { if l.flags.has(.debug) { if l.flags.has(.buffer) { unsafe { - l.buffer.writeln(log.label_debug + ' ' + str) + l.buffer.writeln(label_debug + ' ' + str) } } - maybe_colored := l.colorize('bright_magenta', log.label_debug + ' ') + maybe_colored := l.colorize('bright_magenta', label_debug + ' ') l.redirect(maybe_colored + str) } } @@ -279,10 +279,10 @@ pub fn (l &Log) ginfo(group string, str string) { if l.flags.has(.info) { if l.flags.has(.buffer) { unsafe { - l.buffer.writeln(log.label_info + ' ${group} ' + str) + l.buffer.writeln(label_info + ' ${group} ' + str) } } - maybe_colored := l.colorize('blue', log.label_info + ' ') + l.colorize('white', '${group} ') + maybe_colored := l.colorize('blue', label_info + ' ') + l.colorize('white', '${group} ') l.redirect(maybe_colored + str) } } @@ -292,11 +292,10 @@ pub fn (l &Log) gwarn(group string, str string) { if l.flags.has(.warn) { if l.flags.has(.buffer) { unsafe { - l.buffer.writeln(log.label_warn + ' ${group} ' + str) + l.buffer.writeln(label_warn + ' ${group} ' + str) } } - maybe_colored := l.colorize('yellow', log.label_warn + ' ') + - l.colorize('white', '${group} ') + maybe_colored := l.colorize('yellow', label_warn + ' ') + l.colorize('white', '${group} ') l.redirect(maybe_colored + str) } } @@ -306,10 +305,10 @@ pub fn (l &Log) gerror(group string, str string) { if l.flags.has(.error) { if l.flags.has(.buffer) { unsafe { - l.buffer.writeln(log.label_error + ' ${group} ' + str) + l.buffer.writeln(label_error + ' ${group} ' + str) } } - maybe_colored := l.colorize('bright_red', log.label_error + ' ') + + maybe_colored := l.colorize('bright_red', label_error + ' ') + l.colorize('white', '${group} ') l.redirect(maybe_colored + str) } @@ -320,11 +319,10 @@ pub fn (l &Log) gcritical(group string, str string) { if l.flags.has(.critical) { if l.flags.has(.buffer) { unsafe { - l.buffer.writeln(log.label_critical + ' ${group} ' + str) + l.buffer.writeln(label_critical + ' ${group} ' + str) } } - maybe_colored := l.colorize('red', log.label_critical + ' ') + - l.colorize('white', '${group} ') + maybe_colored := l.colorize('red', label_critical + ' ') + l.colorize('white', '${group} ') l.redirect(maybe_colored + str) } } @@ -334,10 +332,10 @@ pub fn (l &Log) gdebug(group string, str string) { if l.flags.has(.debug) { if l.flags.has(.buffer) { unsafe { - l.buffer.writeln(log.label_debug + ' ${group} ' + str) + l.buffer.writeln(label_debug + ' ${group} ' + str) } } - maybe_colored := l.colorize('bright_magenta', log.label_debug + ' ') + + maybe_colored := l.colorize('bright_magenta', label_debug + ' ') + l.colorize('white', '${group} ') l.redirect(maybe_colored + str) } diff --git a/mth/pure_v_math.v b/mth/pure_v_math.v index 1224058..b7d41f4 100644 --- a/mth/pure_v_math.v +++ b/mth/pure_v_math.v @@ -188,23 +188,23 @@ pub fn round_sig(x f64, sig_digits int) f64 { // round_to_even(nan) = nan pub fn round_to_even(x f64) f64 { mut bits := f64_bits(x) - mut e_ := (bits >> mth.shift) & mth.mask - if e_ >= mth.bias { + mut e_ := (bits >> shift) & mask + if e_ >= bias { // round abs(x) >= 1. // - Large numbers without fractional components, infinity, and nan are unchanged. // - Add 0.499.. or 0.5 before truncating depending on whether the truncated // number is even or odd (respectively). - half_minus_ulp := u64(u64(1) << (mth.shift - 1)) - 1 - e_ -= u64(mth.bias) - bits += (half_minus_ulp + (bits >> (mth.shift - e_)) & 1) >> e_ - bits &= mth.frac_mask >> e_ - bits ^= mth.frac_mask >> e_ - } else if e_ == mth.bias - 1 && bits & mth.frac_mask != 0 { + half_minus_ulp := u64(u64(1) << (shift - 1)) - 1 + e_ -= u64(bias) + bits += (half_minus_ulp + (bits >> (shift - e_)) & 1) >> e_ + bits &= frac_mask >> e_ + bits ^= frac_mask >> e_ + } else if e_ == bias - 1 && bits & frac_mask != 0 { // round 0.5 < abs(x) < 1. - bits = bits & mth.sign_mask | mth.uvone // +-1 + bits = bits & sign_mask | uvone // +-1 } else { // round abs(x) <= 0.5 including denormals. - bits &= mth.sign_mask // +-0 + bits &= sign_mask // +-0 } return f64_from_bits(bits) } @@ -225,13 +225,13 @@ const frac_mask = u64((u64(1) << u64(shift)) - u64(1)) // inf returns positive infinity if sign >= 0, negative infinity if sign < 0. pub fn inf(sign int) f64 { - v := if sign >= 0 { mth.uvinf } else { mth.uvneginf } + v := if sign >= 0 { uvinf } else { uvneginf } return f64_from_bits(v) } // nan returns an IEEE 754 ``not-a-number'' value. pub fn nan() f64 { - return f64_from_bits(mth.uvnan) + return f64_from_bits(uvnan) } // is_nan reports whether f is an IEEE 754 ``not-a-number'' value. @@ -252,7 +252,7 @@ pub fn is_inf(f f64, sign int) bool { // To avoid the floating-point hardware, could use: // x := f64_bits(f); // return sign >= 0 && x == uvinf || sign <= 0 && x == uvneginf; - return (sign >= 0 && f > mth.max_f64) || (sign <= 0 && f < -mth.max_f64) + return (sign >= 0 && f > max_f64) || (sign <= 0 && f < -max_f64) } pub fn is_finite(f f64) bool { @@ -264,7 +264,7 @@ pub fn is_finite(f f64) bool { pub fn normalize(x f64) (f64, int) { smallest_normal := 2.2250738585072014e-308 // 2**-1022 if abs(x) < smallest_normal { - return x * mth.normalize_smallest_mask, -52 + return x * normalize_smallest_mask, -52 } return x, 0 } @@ -282,11 +282,11 @@ const modf_maxpowtwo = 4.503599627370496000e+15 pub fn modf(f f64) (f64, f64) { abs_f := abs(f) mut i := 0.0 - if abs_f >= mth.modf_maxpowtwo { + if abs_f >= modf_maxpowtwo { i = f // it must be an integer } else { - i = abs_f + mth.modf_maxpowtwo // shift fraction off right - i -= mth.modf_maxpowtwo // shift back without fraction + i = abs_f + modf_maxpowtwo // shift fraction off right + i -= modf_maxpowtwo // shift back without fraction for i > abs_f { // above arithmetic might round i -= 1.0 // test again just to be sure } diff --git a/particle/particle.v b/particle/particle.v index c6ef4cb..0bd3407 100644 --- a/particle/particle.v +++ b/particle/particle.v @@ -21,11 +21,11 @@ pub fn (mut s System) new_particle() &Particle { position: vec.Vec2[f32]{0, 0} velocity: vec.Vec2[f32]{0, 0} acceleration: vec.Vec2[f32]{0, 0} - size: particle.default_size + size: default_size rotation: 0 scale: 1 - color: particle.default_color - life_time: particle.default_life_time + color: default_color + life_time: default_life_time } ep := ParticleState{ @@ -158,12 +158,12 @@ pub fn (mut p Particle) reset() { p.position.zero() p.acceleration.zero() p.velocity.zero() - p.color = particle.default_color + p.color = default_color p.rotation = 0 p.scale = 1 - p.life_time = particle.default_life_time + p.life_time = default_life_time p.set_init() } diff --git a/tests/visual/circle_looks_ok.v b/tests/visual/circle_looks_ok.v index fa3daaa..6fb9b23 100644 --- a/tests/visual/circle_looks_ok.v +++ b/tests/visual/circle_looks_ok.v @@ -23,7 +23,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 // .back mode: .in_out } diff --git a/vec/vec2.v b/vec/vec2.v index 18bcf58..3e33829 100644 --- a/vec/vec2.v +++ b/vec/vec2.v @@ -271,7 +271,7 @@ pub fn (v Vec2[T]) eq(u Vec2[T]) bool { // eq_epsilon returns a bool indicating if the two vectors are equal within the module `vec_epsilon` const. pub fn (v Vec2[T]) eq_epsilon(u Vec2[T]) bool { - return v.eq_approx[T, f32](u, vec.vec_epsilon) + return v.eq_approx[T, f32](u, vec_epsilon) } // x_eq_approx returns whether the `v.x` component of vector `v` is approximately equal to `x`, within `tolerance`. @@ -441,7 +441,7 @@ pub fn (v Vec2[T]) sum() T { pub fn (v Vec2[T]) move_toward[U](to Vec2[T], delta U) Vec2[T] { vdiff := to.sub(v) len := vdiff.magnitude() - if len <= delta || len < vec.vec_epsilon { + if len <= delta || len < vec_epsilon { return to } return v.add(vdiff.div_scalar(len * delta)) diff --git a/wraps/miniaudio/miniaudio.auto.c.v b/wraps/miniaudio/miniaudio.auto.c.v index f1bbab6..6c1a243 100644 --- a/wraps/miniaudio/miniaudio.auto.c.v +++ b/wraps/miniaudio/miniaudio.auto.c.v @@ -4809,7 +4809,7 @@ pub enum IosSessionCategoryOption { default_to_speaker = C.ma_ios_session_category_option_default_to_speaker // 0x08, AVAudioSessionCategoryOptionDefaultToSpeaker interrupt_spoken_audio_and_mix_with_others = C.ma_ios_session_category_option_interrupt_spoken_audio_and_mix_with_others // 0x11, AVAudioSessionCategoryOptionInterruptSpokenAudioAndMixWithOthers allow_bluetooth_a2dp = C.ma_ios_session_category_option_allow_bluetooth_a2dp // 0x20, AVAudioSessionCategoryOptionAllowBluetoothA2DP - allow_air_play = C.ma_ios_session_category_option_allow_air_play // 0x40, AVAudioSessionCategoryOptionAllowAirPlay + allow_air_play = C.ma_ios_session_category_option_allow_air_play // 0x40, AVAudioSessionCategoryOptionAllowAirPlay } // OpenslStreamType is C.ma_opensl_stream_type diff --git a/wraps/sokol/app/app.c.v b/wraps/sokol/app/app.c.v index 0265742..3c2aae8 100644 --- a/wraps/sokol/app/app.c.v +++ b/wraps/sokol/app/app.c.v @@ -26,7 +26,7 @@ pub fn create_desc() gfx.Desc { } return gfx.Desc{ - context: gfx.ContextDesc{ + context: gfx.ContextDesc{ metal: metal_desc d3d11: d3d11_desc color_format: .bgra8 diff --git a/wraps/sokol/app/sapp_structs.c.v b/wraps/sokol/app/sapp_structs.c.v index e89177f..37219f4 100644 --- a/wraps/sokol/app/sapp_structs.c.v +++ b/wraps/sokol/app/sapp_structs.c.v @@ -27,7 +27,7 @@ pub type ImageDesc = C.sapp_image_desc @[typedef] pub struct C.sapp_icon_desc { sokol_default bool - images [app.max_iconimages]ImageDesc + images [max_iconimages]ImageDesc } pub type IconDesc = C.sapp_icon_desc @@ -93,7 +93,7 @@ pub: scroll_x f32 scroll_y f32 num_touches int - touches [app.max_touchpoints]TouchPoint + touches [max_touchpoints]TouchPoint window_width int window_height int framebuffer_width int diff --git a/wraps/sokol/gfx/sokol_gfx.auto.c.v b/wraps/sokol/gfx/sokol_gfx.auto.c.v index f7d3cc3..3eefa43 100644 --- a/wraps/sokol/gfx/sokol_gfx.auto.c.v +++ b/wraps/sokol/gfx/sokol_gfx.auto.c.v @@ -706,7 +706,7 @@ pub const sg_max_mipmaps = 16 @[typedef] pub struct C.sg_image_data { pub mut: - subimage [gfx.sg_cubeface_num][gfx.sg_max_mipmaps]Range + subimage [sg_cubeface_num][sg_max_mipmaps]Range } pub type ImageData = C.sg_image_data diff --git a/wraps/sokol/sfons/sfons.c.v b/wraps/sokol/sfons/sfons.c.v index 4505add..2395544 100644 --- a/wraps/sokol/sfons/sfons.c.v +++ b/wraps/sokol/sfons/sfons.c.v @@ -38,7 +38,7 @@ pub type Allocator = C.sfons_allocator_t struct C.sfons_desc_t { 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 Allocator = sfons.default_allocator // optional memory allocation overrides + allocator Allocator = default_allocator // optional memory allocation overrides } pub type Desc = C.sfons_desc_t