1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

make v build-examples work: part 1

This commit is contained in:
Alexander Medvednikov 2020-06-02 16:09:41 +02:00
parent 78f8a8aee6
commit 4e51867612
8 changed files with 20 additions and 20 deletions

View File

@ -233,7 +233,7 @@ pub fn v_build_failing_skipped(zargs string, folder string, skipped []string) bo
mut mains := []string{} mut mains := []string{}
for f in files { for f in files {
if !f.contains('modules') && !f.contains('preludes') { if !f.contains('modules') && !f.contains('preludes') {
if f.contains('/vweb/') { if f.contains('/vweb/') || f.contains('/pg/') || f.contains('rune.v') {
continue continue
} }

View File

@ -8,6 +8,6 @@ fn main(){
some_module.do_work() 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) println(e.message)
} }

View File

@ -46,9 +46,9 @@ fn new_automaton(f [][]int) Automaton {
maxx = f[y].len maxx = f[y].len
} }
} }
size := u32(maxx * maxy) size := (maxx * maxy)
field := &A2D{ maxx: maxx maxy: maxy data: &int( vcalloc( sizeof(int) * size ) ) } field := &A2D{ maxx: maxx maxy: maxy data: &int( vcalloc( 4 * (size) ) ) }
new_field := &A2D{ maxx: maxx maxy: maxy data: &int( vcalloc( sizeof(int) * size) ) } new_field := &A2D{ maxx: maxx maxy: maxy data: &int( vcalloc( 4 * (size)) ) }
for y in 0..field.maxy { for y in 0..field.maxy {
for x in 0..field.maxx { for x in 0..field.maxx {
field.set( x, y, f[y][x] ) field.set( x, y, f[y][x] )

View File

@ -101,7 +101,7 @@ fn main() {
} }
} }
fn (ctx Context) draw() { fn (mut ctx Context) draw() {
mut y := 10 mut y := 10
for line in lines { for line in lines {
ctx.ft.draw_text_def(10,y, line) ctx.ft.draw_text_def(10,y, line)

View File

@ -34,9 +34,9 @@ pub mut:
fn advance(sys mut System, dt f64) { fn advance(sys mut System, dt f64) {
for i in 0..c_n - 1 { for i in 0..c_n - 1 {
mut _vx := sys.v[i].x mut vx := sys.v[i].x
mut _vy := sys.v[i].y mut vy := sys.v[i].y
mut _vz := sys.v[i].z mut vz := sys.v[i].z
for j := i + 1; j < c_n; j++ { for j := i + 1; j < c_n; j++ {
dx := sys.s[i].x - sys.s[j].x dx := sys.s[i].x - sys.s[j].x
@ -48,17 +48,17 @@ fn advance(sys mut System, dt f64) {
mag := (dt / (dsquared * distance)) mag := (dt / (dsquared * distance))
mi := sys.v[i].m mi := sys.v[i].m
_vx -= dx * sys.v[j].m * mag vx -= dx * sys.v[j].m * mag
_vy -= dy * sys.v[j].m * mag vy -= dy * sys.v[j].m * mag
_vz -= dz * sys.v[j].m * mag vz -= dz * sys.v[j].m * mag
sys.v[j].x += dx * mi * mag sys.v[j].x += dx * mi * mag
sys.v[j].y += dy * mi * mag sys.v[j].y += dy * mi * mag
sys.v[j].z += dz * mi * mag sys.v[j].z += dz * mi * mag
} }
sys.v[i].x = _vx sys.v[i].x = vx
sys.v[i].y = _vy sys.v[i].y = vy
sys.v[i].z = _vz sys.v[i].z = vz
} }
for i in 0..c_n { for i in 0..c_n {
@ -108,7 +108,7 @@ fn arr_momentum() []Momentum {
] ]
} }
pub fn arr_position() []Position { fn arr_position() []Position {
return [ return [
Position {0.0, 0.0, 0.0}, Position {0.0, 0.0, 0.0},
Position {4.84143144246472090e+00, -1.16032004402742839e+00, -1.03622044471123109e-01}, Position {4.84143144246472090e+00, -1.16032004402742839e+00, -1.03622044471123109e-01},

View File

@ -7,7 +7,7 @@ const (
) )
fn main() { fn main() {
rand.seed(time.now().unix) rand.seed(int(time.now().unix))
rand.next(gen_max) // skip the first rand.next(gen_max) // skip the first
mut arr := []int{} mut arr := []int{}
for _ in 0..gen_len { for _ in 0..gen_len {

View File

@ -136,7 +136,7 @@ fn (state &AppState) render_font() {
C.fonsSetColor(state.fons, white) C.fonsSetColor(state.fons, white)
dx = 50 dx = 50
dy = 350 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) C.fonsSetAlign(state.fons, C.FONS_ALIGN_LEFT | C.FONS_ALIGN_TOP)
dx = C.fonsDrawText(state.fons, dx, dy, c'Top', C.NULL) dx = C.fonsDrawText(state.fons, dx, dy, c'Top', C.NULL)
dx += 10 dx += 10
@ -150,7 +150,7 @@ fn (state &AppState) render_font() {
C.fonsDrawText(state.fons, dx, dy, c'Bottom', C.NULL) C.fonsDrawText(state.fons, dx, dy, c'Bottom', C.NULL)
dx = 150 dx = 150
dy = 400 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.fonsSetAlign(state.fons, C.FONS_ALIGN_LEFT | C.FONS_ALIGN_BASELINE)
C.fonsDrawText(state.fons, dx, dy, c'Left', C.NULL) C.fonsDrawText(state.fons, dx, dy, c'Left', C.NULL)
dy += 30 dy += 30

View File

@ -1,4 +1,4 @@
fn println(s string) { } //fn println(s string) { }
//fn test_fn() { //fn test_fn() {
//println('test fn') //println('test fn')