From 4e518676122509bb6da088f1633fe0f8a4e046df Mon Sep 17 00:00:00 2001 From: Alexander Medvednikov Date: Tue, 2 Jun 2020 16:09:41 +0200 Subject: [PATCH] make v build-examples work: part 1 --- cmd/tools/modules/testing/common.v | 2 +- examples/eventbus/eventbus.v | 2 +- .../modules/automaton/automaton.v | 6 +++--- examples/gg/gg_freetype.v | 2 +- examples/nbody.v | 20 +++++++++---------- examples/quick_sort.v | 2 +- examples/sokol/fonts.v | 4 ++-- examples/x64/hello_world.v | 2 +- 8 files changed, 20 insertions(+), 20 deletions(-) diff --git a/cmd/tools/modules/testing/common.v b/cmd/tools/modules/testing/common.v index 34737994b4..c6e0eeec5b 100644 --- a/cmd/tools/modules/testing/common.v +++ b/cmd/tools/modules/testing/common.v @@ -233,7 +233,7 @@ pub fn v_build_failing_skipped(zargs string, folder string, skipped []string) bo mut mains := []string{} for f in files { if !f.contains('modules') && !f.contains('preludes') { - if f.contains('/vweb/') { + if f.contains('/vweb/') || f.contains('/pg/') || f.contains('rune.v') { continue } diff --git a/examples/eventbus/eventbus.v b/examples/eventbus/eventbus.v index 0188c05e1f..82268abe8a 100644 --- a/examples/eventbus/eventbus.v +++ b/examples/eventbus/eventbus.v @@ -8,6 +8,6 @@ fn main(){ some_module.do_work() } -fn on_error(sender voidptr, e &some_module.Error) { +fn on_error(sender voidptr, e &some_module.Error, x voidptr) { println(e.message) } diff --git a/examples/game_of_life/modules/automaton/automaton.v b/examples/game_of_life/modules/automaton/automaton.v index aedaac16cb..d4cd5a90d7 100644 --- a/examples/game_of_life/modules/automaton/automaton.v +++ b/examples/game_of_life/modules/automaton/automaton.v @@ -46,9 +46,9 @@ fn new_automaton(f [][]int) Automaton { maxx = f[y].len } } - size := u32(maxx * maxy) - field := &A2D{ maxx: maxx maxy: maxy data: &int( vcalloc( sizeof(int) * size ) ) } - new_field := &A2D{ maxx: maxx maxy: maxy data: &int( vcalloc( sizeof(int) * size) ) } + size := (maxx * maxy) + field := &A2D{ maxx: maxx maxy: maxy data: &int( vcalloc( 4 * (size) ) ) } + new_field := &A2D{ maxx: maxx maxy: maxy data: &int( vcalloc( 4 * (size)) ) } for y in 0..field.maxy { for x in 0..field.maxx { field.set( x, y, f[y][x] ) diff --git a/examples/gg/gg_freetype.v b/examples/gg/gg_freetype.v index 78e54302df..9f2f33b995 100644 --- a/examples/gg/gg_freetype.v +++ b/examples/gg/gg_freetype.v @@ -101,7 +101,7 @@ fn main() { } } -fn (ctx Context) draw() { +fn (mut ctx Context) draw() { mut y := 10 for line in lines { ctx.ft.draw_text_def(10,y, line) diff --git a/examples/nbody.v b/examples/nbody.v index d88ba8dd3f..0d434c61ec 100644 --- a/examples/nbody.v +++ b/examples/nbody.v @@ -34,9 +34,9 @@ pub mut: fn advance(sys mut System, dt f64) { for i in 0..c_n - 1 { - mut _vx := sys.v[i].x - mut _vy := sys.v[i].y - mut _vz := sys.v[i].z + mut vx := sys.v[i].x + mut vy := sys.v[i].y + mut vz := sys.v[i].z for j := i + 1; j < c_n; j++ { dx := sys.s[i].x - sys.s[j].x @@ -48,17 +48,17 @@ fn advance(sys mut System, dt f64) { mag := (dt / (dsquared * distance)) mi := sys.v[i].m - _vx -= dx * sys.v[j].m * mag - _vy -= dy * sys.v[j].m * mag - _vz -= dz * sys.v[j].m * mag + vx -= dx * sys.v[j].m * mag + vy -= dy * sys.v[j].m * mag + vz -= dz * sys.v[j].m * mag sys.v[j].x += dx * mi * mag sys.v[j].y += dy * mi * mag sys.v[j].z += dz * mi * mag } - sys.v[i].x = _vx - sys.v[i].y = _vy - sys.v[i].z = _vz + sys.v[i].x = vx + sys.v[i].y = vy + sys.v[i].z = vz } for i in 0..c_n { @@ -108,7 +108,7 @@ fn arr_momentum() []Momentum { ] } -pub fn arr_position() []Position { +fn arr_position() []Position { return [ Position {0.0, 0.0, 0.0}, Position {4.84143144246472090e+00, -1.16032004402742839e+00, -1.03622044471123109e-01}, diff --git a/examples/quick_sort.v b/examples/quick_sort.v index c6857018b2..d424dbdb81 100644 --- a/examples/quick_sort.v +++ b/examples/quick_sort.v @@ -7,7 +7,7 @@ const ( ) fn main() { - rand.seed(time.now().unix) + rand.seed(int(time.now().unix)) rand.next(gen_max) // skip the first mut arr := []int{} for _ in 0..gen_len { diff --git a/examples/sokol/fonts.v b/examples/sokol/fonts.v index 0e25f2147b..fa99a11161 100644 --- a/examples/sokol/fonts.v +++ b/examples/sokol/fonts.v @@ -136,7 +136,7 @@ fn (state &AppState) render_font() { C.fonsSetColor(state.fons, white) dx = 50 dy = 350 - line(dx - 10, dy, dx + 250, dy) + line(f32(dx - 10), f32(dy), f32(dx + 250), f32(dy)) C.fonsSetAlign(state.fons, C.FONS_ALIGN_LEFT | C.FONS_ALIGN_TOP) dx = C.fonsDrawText(state.fons, dx, dy, c'Top', C.NULL) dx += 10 @@ -150,7 +150,7 @@ fn (state &AppState) render_font() { C.fonsDrawText(state.fons, dx, dy, c'Bottom', C.NULL) dx = 150 dy = 400 - line(dx, dy - 30, dx, dy + 80.0) + line(f32(dx), f32(dy - 30), f32(dx), f32(dy + 80.0)) C.fonsSetAlign(state.fons, C.FONS_ALIGN_LEFT | C.FONS_ALIGN_BASELINE) C.fonsDrawText(state.fons, dx, dy, c'Left', C.NULL) dy += 30 diff --git a/examples/x64/hello_world.v b/examples/x64/hello_world.v index 8c538cf58b..2be203cde3 100644 --- a/examples/x64/hello_world.v +++ b/examples/x64/hello_world.v @@ -1,4 +1,4 @@ -fn println(s string) { } +//fn println(s string) { } //fn test_fn() { //println('test fn')