mirror of
https://github.com/vlang/v.git
synced 2025-09-13 22:42:26 +03:00
fmt: remove inline comments (#19263)
This commit is contained in:
parent
3d2731fca7
commit
18e60e77de
50 changed files with 951 additions and 1034 deletions
|
@ -6,7 +6,7 @@ import v.util
|
||||||
|
|
||||||
const (
|
const (
|
||||||
known_failing_exceptions = [
|
known_failing_exceptions = [
|
||||||
'vlib/crypto/aes/const.v' /* const array wrapped in too many lines */,
|
'vlib/crypto/aes/const.v', // const array wrapped in too many lines
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -85,13 +85,13 @@ const (
|
||||||
]
|
]
|
||||||
skip_test_files = [
|
skip_test_files = [
|
||||||
'do_not_remove',
|
'do_not_remove',
|
||||||
'cmd/tools/vdoc/html_tag_escape_test.v', /* can't locate local module: markdown */
|
'cmd/tools/vdoc/html_tag_escape_test.v', // can't locate local module: markdown
|
||||||
'cmd/tools/vdoc/tests/vdoc_file_test.v', /* fails on Windows; order of output is not as expected */
|
'cmd/tools/vdoc/tests/vdoc_file_test.v', // fails on Windows; order of output is not as expected
|
||||||
'vlib/context/deadline_test.v' /* sometimes blocks */,
|
'vlib/context/deadline_test.v', // sometimes blocks
|
||||||
'vlib/context/onecontext/onecontext_test.v' /* backtrace_symbols is missing. */,
|
'vlib/context/onecontext/onecontext_test.v', // backtrace_symbols is missing
|
||||||
'vlib/db/mysql/mysql_orm_test.v' /* mysql not installed */,
|
'vlib/db/mysql/mysql_orm_test.v', // mysql not installed
|
||||||
'vlib/db/mysql/mysql_test.v' /* mysql not installed */,
|
'vlib/db/mysql/mysql_test.v', // mysql not installed
|
||||||
'vlib/db/pg/pg_orm_test.v' /* pg not installed */,
|
'vlib/db/pg/pg_orm_test.v', // pg not installed
|
||||||
]
|
]
|
||||||
// These tests are too slow to be run in the CI on each PR/commit
|
// These tests are too slow to be run in the CI on each PR/commit
|
||||||
// in the sanitized modes:
|
// in the sanitized modes:
|
||||||
|
|
|
@ -54,17 +54,17 @@ const (
|
||||||
game_over_color: gx.rgb(190, 50, 50)
|
game_over_color: gx.rgb(190, 50, 50)
|
||||||
text_color: gx.black
|
text_color: gx.black
|
||||||
tile_colors: [
|
tile_colors: [
|
||||||
gx.rgb(205, 193, 180), /* Empty / 0 tile */
|
gx.rgb(205, 193, 180), // Empty / 0 tile
|
||||||
gx.rgb(238, 228, 218), /* 2 */
|
gx.rgb(238, 228, 218), // 2
|
||||||
gx.rgb(237, 224, 200), /* 4 */
|
gx.rgb(237, 224, 200), // 4
|
||||||
gx.rgb(242, 177, 121), /* 8 */
|
gx.rgb(242, 177, 121), // 8
|
||||||
gx.rgb(245, 149, 99), /* 16 */
|
gx.rgb(245, 149, 99), // 16
|
||||||
gx.rgb(246, 124, 95), /* 32 */
|
gx.rgb(246, 124, 95), // 32
|
||||||
gx.rgb(246, 94, 59), /* 64 */
|
gx.rgb(246, 94, 59), // 64
|
||||||
gx.rgb(237, 207, 114), /* 128 */
|
gx.rgb(237, 207, 114), // 128
|
||||||
gx.rgb(237, 204, 97), /* 256 */
|
gx.rgb(237, 204, 97), // 256
|
||||||
gx.rgb(237, 200, 80), /* 512 */
|
gx.rgb(237, 200, 80), // 512
|
||||||
gx.rgb(237, 197, 63), /* 1024 */
|
gx.rgb(237, 197, 63), // 1024
|
||||||
gx.rgb(237, 194, 46),
|
gx.rgb(237, 194, 46),
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
|
|
@ -173,63 +173,63 @@ const (
|
||||||
e: Vec{}
|
e: Vec{}
|
||||||
c: Vec{.75, .25, .25}
|
c: Vec{.75, .25, .25}
|
||||||
refl: .diff
|
refl: .diff
|
||||||
}, /* Left */
|
}, // Left
|
||||||
Sphere{
|
Sphere{
|
||||||
rad: 1e+5
|
rad: 1e+5
|
||||||
p: Vec{-1e+5 + 99, 40.8, 81.6}
|
p: Vec{-1e+5 + 99, 40.8, 81.6}
|
||||||
e: Vec{}
|
e: Vec{}
|
||||||
c: Vec{.25, .25, .75}
|
c: Vec{.25, .25, .75}
|
||||||
refl: .diff
|
refl: .diff
|
||||||
}, /* Rght */
|
}, // Rght
|
||||||
Sphere{
|
Sphere{
|
||||||
rad: 1e+5
|
rad: 1e+5
|
||||||
p: Vec{50, 40.8, 1e+5}
|
p: Vec{50, 40.8, 1e+5}
|
||||||
e: Vec{}
|
e: Vec{}
|
||||||
c: Vec{.75, .75, .75}
|
c: Vec{.75, .75, .75}
|
||||||
refl: .diff
|
refl: .diff
|
||||||
}, /* Back */
|
}, // Back
|
||||||
Sphere{
|
Sphere{
|
||||||
rad: 1e+5
|
rad: 1e+5
|
||||||
p: Vec{50, 40.8, -1e+5 + 170}
|
p: Vec{50, 40.8, -1e+5 + 170}
|
||||||
e: Vec{}
|
e: Vec{}
|
||||||
c: Vec{}
|
c: Vec{}
|
||||||
refl: .diff
|
refl: .diff
|
||||||
}, /* Frnt */
|
}, // Frnt
|
||||||
Sphere{
|
Sphere{
|
||||||
rad: 1e+5
|
rad: 1e+5
|
||||||
p: Vec{50, 1e+5, 81.6}
|
p: Vec{50, 1e+5, 81.6}
|
||||||
e: Vec{}
|
e: Vec{}
|
||||||
c: Vec{.75, .75, .75}
|
c: Vec{.75, .75, .75}
|
||||||
refl: .diff
|
refl: .diff
|
||||||
}, /* Botm */
|
}, // Botm
|
||||||
Sphere{
|
Sphere{
|
||||||
rad: 1e+5
|
rad: 1e+5
|
||||||
p: Vec{50, -1e+5 + 81.6, 81.6}
|
p: Vec{50, -1e+5 + 81.6, 81.6}
|
||||||
e: Vec{}
|
e: Vec{}
|
||||||
c: Vec{.75, .75, .75}
|
c: Vec{.75, .75, .75}
|
||||||
refl: .diff
|
refl: .diff
|
||||||
}, /* Top */
|
}, // Top
|
||||||
Sphere{
|
Sphere{
|
||||||
rad: 16.5
|
rad: 16.5
|
||||||
p: Vec{27, 16.5, 47}
|
p: Vec{27, 16.5, 47}
|
||||||
e: Vec{}
|
e: Vec{}
|
||||||
c: Vec{1, 1, 1}.mult_s(.999)
|
c: Vec{1, 1, 1}.mult_s(.999)
|
||||||
refl: .spec
|
refl: .spec
|
||||||
}, /* Mirr */
|
}, // Mirr
|
||||||
Sphere{
|
Sphere{
|
||||||
rad: 16.5
|
rad: 16.5
|
||||||
p: Vec{73, 16.5, 78}
|
p: Vec{73, 16.5, 78}
|
||||||
e: Vec{}
|
e: Vec{}
|
||||||
c: Vec{1, 1, 1}.mult_s(.999)
|
c: Vec{1, 1, 1}.mult_s(.999)
|
||||||
refl: .refr
|
refl: .refr
|
||||||
}, /* Glas */
|
}, // Glas
|
||||||
Sphere{
|
Sphere{
|
||||||
rad: 600
|
rad: 600
|
||||||
p: Vec{50, 681.6 - .27, 81.6}
|
p: Vec{50, 681.6 - .27, 81.6}
|
||||||
e: Vec{12, 12, 12}
|
e: Vec{12, 12, 12}
|
||||||
c: Vec{}
|
c: Vec{}
|
||||||
refl: .diff
|
refl: .diff
|
||||||
} /* Lite */,
|
}, // Lite
|
||||||
],
|
],
|
||||||
[// scene 1 sunset
|
[// scene 1 sunset
|
||||||
Sphere{
|
Sphere{
|
||||||
|
@ -238,63 +238,63 @@ const (
|
||||||
e: Vec{1.0, .9, .8}.mult_s(1.2e+1 * 1.56 * 2)
|
e: Vec{1.0, .9, .8}.mult_s(1.2e+1 * 1.56 * 2)
|
||||||
c: Vec{}
|
c: Vec{}
|
||||||
refl: .diff
|
refl: .diff
|
||||||
}, /* sun */
|
}, // sun
|
||||||
Sphere{
|
Sphere{
|
||||||
rad: 1560
|
rad: 1560
|
||||||
p: Vec{1, 0, 2}.mult_s(3500)
|
p: Vec{1, 0, 2}.mult_s(3500)
|
||||||
e: Vec{1.0, .5, .05}.mult_s(4.8e+1 * 1.56 * 2)
|
e: Vec{1.0, .5, .05}.mult_s(4.8e+1 * 1.56 * 2)
|
||||||
c: Vec{}
|
c: Vec{}
|
||||||
refl: .diff
|
refl: .diff
|
||||||
}, /* horizon sun2 */
|
}, // horizon sun2
|
||||||
Sphere{
|
Sphere{
|
||||||
rad: 10000
|
rad: 10000
|
||||||
p: cen + Vec{0, 0, -200}
|
p: cen + Vec{0, 0, -200}
|
||||||
e: Vec{0.00063842, 0.02001478, 0.28923243}.mult_s(6e-2 * 8)
|
e: Vec{0.00063842, 0.02001478, 0.28923243}.mult_s(6e-2 * 8)
|
||||||
c: Vec{.7, .7, 1}.mult_s(.25)
|
c: Vec{.7, .7, 1}.mult_s(.25)
|
||||||
refl: .diff
|
refl: .diff
|
||||||
}, /* sky */
|
}, // sky
|
||||||
Sphere{
|
Sphere{
|
||||||
rad: 100000
|
rad: 100000
|
||||||
p: Vec{50, -100000, 0}
|
p: Vec{50, -100000, 0}
|
||||||
e: Vec{}
|
e: Vec{}
|
||||||
c: Vec{.3, .3, .3}
|
c: Vec{.3, .3, .3}
|
||||||
refl: .diff
|
refl: .diff
|
||||||
}, /* grnd */
|
}, // grnd
|
||||||
Sphere{
|
Sphere{
|
||||||
rad: 110000
|
rad: 110000
|
||||||
p: Vec{50, -110048.5, 0}
|
p: Vec{50, -110048.5, 0}
|
||||||
e: Vec{.9, .5, .05}.mult_s(4)
|
e: Vec{.9, .5, .05}.mult_s(4)
|
||||||
c: Vec{}
|
c: Vec{}
|
||||||
refl: .diff
|
refl: .diff
|
||||||
}, /* horizon brightener */
|
}, // horizon brightener
|
||||||
Sphere{
|
Sphere{
|
||||||
rad: 4e+4
|
rad: 4e+4
|
||||||
p: Vec{50, -4e+4 - 30, -3000}
|
p: Vec{50, -4e+4 - 30, -3000}
|
||||||
e: Vec{}
|
e: Vec{}
|
||||||
c: Vec{.2, .2, .2}
|
c: Vec{.2, .2, .2}
|
||||||
refl: .diff
|
refl: .diff
|
||||||
}, /* mountains */
|
}, // mountains
|
||||||
Sphere{
|
Sphere{
|
||||||
rad: 26.5
|
rad: 26.5
|
||||||
p: Vec{22, 26.5, 42}
|
p: Vec{22, 26.5, 42}
|
||||||
e: Vec{}
|
e: Vec{}
|
||||||
c: Vec{1, 1, 1}.mult_s(.596)
|
c: Vec{1, 1, 1}.mult_s(.596)
|
||||||
refl: .spec
|
refl: .spec
|
||||||
}, /* white Mirr */
|
}, // white Mirr
|
||||||
Sphere{
|
Sphere{
|
||||||
rad: 13
|
rad: 13
|
||||||
p: Vec{75, 13, 82}
|
p: Vec{75, 13, 82}
|
||||||
e: Vec{}
|
e: Vec{}
|
||||||
c: Vec{.96, .96, .96}.mult_s(.96)
|
c: Vec{.96, .96, .96}.mult_s(.96)
|
||||||
refl: .refr
|
refl: .refr
|
||||||
}, /* Glas */
|
}, // Glas
|
||||||
Sphere{
|
Sphere{
|
||||||
rad: 22
|
rad: 22
|
||||||
p: Vec{87, 22, 24}
|
p: Vec{87, 22, 24}
|
||||||
e: Vec{}
|
e: Vec{}
|
||||||
c: Vec{.6, .6, .6}.mult_s(.696)
|
c: Vec{.6, .6, .6}.mult_s(.696)
|
||||||
refl: .refr
|
refl: .refr
|
||||||
} /* Glas2 */,
|
}, // Glas2
|
||||||
],
|
],
|
||||||
[// scene 3 Psychedelic
|
[// scene 3 Psychedelic
|
||||||
Sphere{
|
Sphere{
|
||||||
|
|
|
@ -411,9 +411,9 @@ fn draw_cube_glsl(app App) {
|
||||||
time_ticks := f32(time.ticks() - app.ticks) / 1000
|
time_ticks := f32(time.ticks() - app.ticks) / 1000
|
||||||
mut text_res := [
|
mut text_res := [
|
||||||
f32(512),
|
f32(512),
|
||||||
512, /* x,y resolution to pass to FS */
|
512, // x,y resolution to pass to FS
|
||||||
time_ticks, /* time as f32 */
|
time_ticks, // time as f32
|
||||||
0 /* padding 4 Bytes == 1 f32 */,
|
0, // padding 4 Bytes == 1 f32
|
||||||
]!
|
]!
|
||||||
fs_uniforms_range := gfx.Range{
|
fs_uniforms_range := gfx.Range{
|
||||||
ptr: unsafe { &text_res }
|
ptr: unsafe { &text_res }
|
||||||
|
|
|
@ -286,7 +286,7 @@ fn init_cube_glsl_p(mut app App) {
|
||||||
vert_buffer_desc.@type = .vertexbuffer
|
vert_buffer_desc.@type = .vertexbuffer
|
||||||
vbuf := gfx.make_buffer(&vert_buffer_desc)
|
vbuf := gfx.make_buffer(&vert_buffer_desc)
|
||||||
|
|
||||||
/* create an index buffer for the cube */
|
// create an index buffer for the cube
|
||||||
// vfmt off
|
// vfmt off
|
||||||
indices := [
|
indices := [
|
||||||
/*
|
/*
|
||||||
|
@ -408,8 +408,8 @@ fn draw_cube_glsl_m(app App) {
|
||||||
ws.height * ratio, // x,y resolution to pass to FS
|
ws.height * ratio, // x,y resolution to pass to FS
|
||||||
0,
|
0,
|
||||||
0, // dont send mouse position
|
0, // dont send mouse position
|
||||||
/* app.mouse_x, // mouse x */
|
// app.mouse_x, // mouse x
|
||||||
/* ws.height - app.mouse_y*2, // mouse y scaled */
|
// ws.height - app.mouse_y*2, // mouse y scaled
|
||||||
time_ticks, // time as f32
|
time_ticks, // time as f32
|
||||||
app.frame_count, // frame count
|
app.frame_count, // frame count
|
||||||
0,
|
0,
|
||||||
|
|
|
@ -52,14 +52,14 @@ const (
|
||||||
]
|
]
|
||||||
// Each tetro has its unique color
|
// Each tetro has its unique color
|
||||||
colors = [
|
colors = [
|
||||||
gx.rgb(0, 0, 0), /* unused ? */
|
gx.rgb(0, 0, 0), // unused ?
|
||||||
gx.rgb(255, 242, 0), /* yellow quad */
|
gx.rgb(255, 242, 0), // yellow quad
|
||||||
gx.rgb(174, 0, 255), /* purple triple */
|
gx.rgb(174, 0, 255), // purple triple
|
||||||
gx.rgb(60, 255, 0), /* green short topright */
|
gx.rgb(60, 255, 0), // green short topright
|
||||||
gx.rgb(255, 0, 0), /* red short topleft */
|
gx.rgb(255, 0, 0), // red short topleft
|
||||||
gx.rgb(255, 180, 31), /* orange long topleft */
|
gx.rgb(255, 180, 31), // orange long topleft
|
||||||
gx.rgb(33, 66, 255), /* blue long topright */
|
gx.rgb(33, 66, 255), // blue long topright
|
||||||
gx.rgb(74, 198, 255), /* lightblue longest */
|
gx.rgb(74, 198, 255), // lightblue longest
|
||||||
gx.rgb(0, 170, 170),
|
gx.rgb(0, 170, 170),
|
||||||
]
|
]
|
||||||
background_color = gx.white
|
background_color = gx.white
|
||||||
|
|
|
@ -53,14 +53,14 @@ const (
|
||||||
]
|
]
|
||||||
// Each tetro has its unique color
|
// Each tetro has its unique color
|
||||||
colors = [
|
colors = [
|
||||||
gx.rgb(0, 0, 0), /* unused ? */
|
gx.rgb(0, 0, 0), // unused ?
|
||||||
gx.rgb(255, 242, 0), /* yellow quad */
|
gx.rgb(255, 242, 0), // yellow quad
|
||||||
gx.rgb(174, 0, 255), /* purple triple */
|
gx.rgb(174, 0, 255), // purple triple
|
||||||
gx.rgb(60, 255, 0), /* green short topright */
|
gx.rgb(60, 255, 0), // green short topright
|
||||||
gx.rgb(255, 0, 0), /* red short topleft */
|
gx.rgb(255, 0, 0), // red short topleft
|
||||||
gx.rgb(255, 180, 31), /* orange long topleft */
|
gx.rgb(255, 180, 31), // orange long topleft
|
||||||
gx.rgb(33, 66, 255), /* blue long topright */
|
gx.rgb(33, 66, 255), // blue long topright
|
||||||
gx.rgb(74, 198, 255), /* lightblue longest */
|
gx.rgb(74, 198, 255), // lightblue longest
|
||||||
gx.rgb(0, 170, 170),
|
gx.rgb(0, 170, 170),
|
||||||
]
|
]
|
||||||
background_color = gx.white
|
background_color = gx.white
|
||||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -72,10 +72,10 @@ pub fn look_at(eye Vec4, center Vec4, up Vec4) Mat4 {
|
||||||
u := (s % f)
|
u := (s % f)
|
||||||
// vfmt off
|
// vfmt off
|
||||||
return Mat4{e: [
|
return Mat4{e: [
|
||||||
/* [0][0] */ s.e[0], /* [0][1] */ u.e[0], /* [0][2] */ -f.e[0], /* [0][3] */ 0,
|
s.e[0], u.e[0], -f.e[0], 0,
|
||||||
/* [1][1] */ s.e[1], /* [1][1] */ u.e[1], /* [1][2] */ -f.e[1], /* [1][3] */ 0,
|
s.e[1], u.e[1], -f.e[1], 0,
|
||||||
/* [2][0] */ s.e[2], /* [2][1] */ u.e[2], /* [2][2] */ -f.e[2], /* [2][3] */ 0,
|
s.e[2], u.e[2], -f.e[2], 0,
|
||||||
/* [3][0] */ -(s * eye), /* [3][1] */ -(u * eye), /* [3][2] */ f * eye, /* [3][3] */ 1,
|
-(s * eye), -(u * eye), f * eye, 1,
|
||||||
]!}
|
]!}
|
||||||
// vfmt on
|
// vfmt on
|
||||||
}
|
}
|
||||||
|
|
|
@ -360,25 +360,25 @@ pub fn (a Mat4) * (b Mat4) Mat4 {
|
||||||
unsafe {
|
unsafe {
|
||||||
// vfmt off
|
// vfmt off
|
||||||
return Mat4{ e: [
|
return Mat4{ e: [
|
||||||
/* [0][0] */ a.f[0][0] * b.f[0][0] + a.f[0][1] * b.f[1][0] + a.f[0][2] * b.f[2][0] + a.f[0][3] * b.f[3][0],
|
a.f[0][0] * b.f[0][0] + a.f[0][1] * b.f[1][0] + a.f[0][2] * b.f[2][0] + a.f[0][3] * b.f[3][0], // [0][0]
|
||||||
/* [0][1] */ a.f[0][0] * b.f[0][1] + a.f[0][1] * b.f[1][1] + a.f[0][2] * b.f[2][1] + a.f[0][3] * b.f[3][1],
|
a.f[0][0] * b.f[0][1] + a.f[0][1] * b.f[1][1] + a.f[0][2] * b.f[2][1] + a.f[0][3] * b.f[3][1], // [0][1]
|
||||||
/* [0][2] */ a.f[0][0] * b.f[0][2] + a.f[0][1] * b.f[1][2] + a.f[0][2] * b.f[2][2] + a.f[0][3] * b.f[3][2],
|
a.f[0][0] * b.f[0][2] + a.f[0][1] * b.f[1][2] + a.f[0][2] * b.f[2][2] + a.f[0][3] * b.f[3][2], // [0][2]
|
||||||
/* [0][3] */ a.f[0][0] * b.f[0][3] + a.f[0][1] * b.f[1][3] + a.f[0][2] * b.f[2][3] + a.f[0][3] * b.f[3][3],
|
a.f[0][0] * b.f[0][3] + a.f[0][1] * b.f[1][3] + a.f[0][2] * b.f[2][3] + a.f[0][3] * b.f[3][3], // [0][3]
|
||||||
|
|
||||||
/* [1][0] */ a.f[1][0] * b.f[0][0] + a.f[1][1] * b.f[1][0] + a.f[1][2] * b.f[2][0] + a.f[1][3] * b.f[3][0],
|
a.f[1][0] * b.f[0][0] + a.f[1][1] * b.f[1][0] + a.f[1][2] * b.f[2][0] + a.f[1][3] * b.f[3][0], // [1][0]
|
||||||
/* [1][1] */ a.f[1][0] * b.f[0][1] + a.f[1][1] * b.f[1][1] + a.f[1][2] * b.f[2][1] + a.f[1][3] * b.f[3][1],
|
a.f[1][0] * b.f[0][1] + a.f[1][1] * b.f[1][1] + a.f[1][2] * b.f[2][1] + a.f[1][3] * b.f[3][1], // [1][1]
|
||||||
/* [1][2] */ a.f[1][0] * b.f[0][2] + a.f[1][1] * b.f[1][2] + a.f[1][2] * b.f[2][2] + a.f[1][3] * b.f[3][2],
|
a.f[1][0] * b.f[0][2] + a.f[1][1] * b.f[1][2] + a.f[1][2] * b.f[2][2] + a.f[1][3] * b.f[3][2], // [1][2]
|
||||||
/* [1][3] */ a.f[1][0] * b.f[0][3] + a.f[1][1] * b.f[1][3] + a.f[1][2] * b.f[2][3] + a.f[1][3] * b.f[3][3],
|
a.f[1][0] * b.f[0][3] + a.f[1][1] * b.f[1][3] + a.f[1][2] * b.f[2][3] + a.f[1][3] * b.f[3][3], // [1][3]
|
||||||
|
|
||||||
/* [2][0] */ a.f[2][0] * b.f[0][0] + a.f[2][1] * b.f[1][0] + a.f[2][2] * b.f[2][0] + a.f[2][3] * b.f[3][0],
|
a.f[2][0] * b.f[0][0] + a.f[2][1] * b.f[1][0] + a.f[2][2] * b.f[2][0] + a.f[2][3] * b.f[3][0], // [2][0]
|
||||||
/* [2][1] */ a.f[2][0] * b.f[0][1] + a.f[2][1] * b.f[1][1] + a.f[2][2] * b.f[2][1] + a.f[2][3] * b.f[3][1],
|
a.f[2][0] * b.f[0][1] + a.f[2][1] * b.f[1][1] + a.f[2][2] * b.f[2][1] + a.f[2][3] * b.f[3][1], // [2][1]
|
||||||
/* [2][2] */ a.f[2][0] * b.f[0][2] + a.f[2][1] * b.f[1][2] + a.f[2][2] * b.f[2][2] + a.f[2][3] * b.f[3][2],
|
a.f[2][0] * b.f[0][2] + a.f[2][1] * b.f[1][2] + a.f[2][2] * b.f[2][2] + a.f[2][3] * b.f[3][2], // [2][2]
|
||||||
/* [2][3] */ a.f[2][0] * b.f[0][3] + a.f[2][1] * b.f[1][3] + a.f[2][2] * b.f[2][3] + a.f[2][3] * b.f[3][3],
|
a.f[2][0] * b.f[0][3] + a.f[2][1] * b.f[1][3] + a.f[2][2] * b.f[2][3] + a.f[2][3] * b.f[3][3], // [2][3]
|
||||||
|
|
||||||
/* [3][0] */ a.f[3][0] * b.f[0][0] + a.f[3][1] * b.f[1][0] + a.f[3][2] * b.f[2][0] + a.f[3][3] * b.f[3][0],
|
a.f[3][0] * b.f[0][0] + a.f[3][1] * b.f[1][0] + a.f[3][2] * b.f[2][0] + a.f[3][3] * b.f[3][0], // [3][0]
|
||||||
/* [3][1] */ a.f[3][0] * b.f[0][1] + a.f[3][1] * b.f[1][1] + a.f[3][2] * b.f[2][1] + a.f[3][3] * b.f[3][1],
|
a.f[3][0] * b.f[0][1] + a.f[3][1] * b.f[1][1] + a.f[3][2] * b.f[2][1] + a.f[3][3] * b.f[3][1], // [3][1]
|
||||||
/* [3][2] */ a.f[3][0] * b.f[0][2] + a.f[3][1] * b.f[1][2] + a.f[3][2] * b.f[2][2] + a.f[3][3] * b.f[3][2],
|
a.f[3][0] * b.f[0][2] + a.f[3][1] * b.f[1][2] + a.f[3][2] * b.f[2][2] + a.f[3][3] * b.f[3][2], // [3][2]
|
||||||
/* [3][3] */ a.f[3][0] * b.f[0][3] + a.f[3][1] * b.f[1][3] + a.f[3][2] * b.f[2][3] + a.f[3][3] * b.f[3][3],
|
a.f[3][0] * b.f[0][3] + a.f[3][1] * b.f[1][3] + a.f[3][2] * b.f[2][3] + a.f[3][3] * b.f[3][3], // [3][3]
|
||||||
]!}
|
]!}
|
||||||
// vfmt on
|
// vfmt on
|
||||||
}
|
}
|
||||||
|
@ -551,10 +551,10 @@ pub fn rotate(angle f32, w Vec4) Mat4 {
|
||||||
|
|
||||||
// vfmt off
|
// vfmt off
|
||||||
return Mat4{ e: [
|
return Mat4{ e: [
|
||||||
/* [0][0] */ (ax * ax * cv) + cs , /* [0][1] */ (ax * ay * cv) + az * sn , /* [0][2] */ (ax * az * cv) - ay * sn , /* [0][3] */ 0,
|
(ax * ax * cv) + cs, (ax * ay * cv) + az * sn, (ax * az * cv) - ay * sn, 0,
|
||||||
/* [1][0] */ (ay * ax * cv) - az * sn , /* [1][1] */ (ay * ay * cv) + cs , /* [1][2] */ (ay * az * cv) + ax * sn , /* [1][3] */ 0,
|
(ay * ax * cv) - az * sn, (ay * ay * cv) + cs, (ay * az * cv) + ax * sn, 0,
|
||||||
/* [2][0] */ (az * ax * cv) + ay * sn , /* [2][1] */ (az * ay * cv) - ax * sn , /* [2][2] */ (az * az * cv) + cs , /* [2][3] */ 0,
|
(az * ax * cv) + ay * sn, (az * ay * cv) - ax * sn, (az * az * cv) + cs, 0,
|
||||||
/* [3][0] */ 0, /* [3][1] */ 0 , /* [3][2] */ 0 , /* [3][3] */ 1,
|
0, 0, 0, 1,
|
||||||
]!}
|
]!}
|
||||||
// vfmt on
|
// vfmt on
|
||||||
}
|
}
|
||||||
|
|
|
@ -331,21 +331,41 @@ fn test_atan2() {
|
||||||
[pi, inf(1)], [pi, nan()], [inf(1), inf(-1)], [inf(1), -pi],
|
[pi, inf(1)], [pi, nan()], [inf(1), inf(-1)], [inf(1), -pi],
|
||||||
[inf(1), 0], [inf(1), pi], [inf(1), inf(1)], [inf(1), nan()],
|
[inf(1), 0], [inf(1), pi], [inf(1), inf(1)], [inf(1), nan()],
|
||||||
[nan(), nan()]]
|
[nan(), nan()]]
|
||||||
atan2_sc_ := [f64(-3.0) * pi / 4.0, /* atan2(-inf, -inf) */ -pi / 2, /* atan2(-inf, -pi) */
|
atan2_sc_ := [f64(-3.0) * pi / 4.0, // atan2(-inf, -inf)
|
||||||
-pi / 2,
|
-pi / 2, // atan2(-inf, -pi)
|
||||||
/* atan2(-inf, +0) */ -pi / 2, /* atan2(-inf, pi) */ -pi / 4, /* atan2(-inf, +inf) */
|
-pi / 2, // atan2(-inf, +0)
|
||||||
nan(), /* atan2(-inf, nan) */ -pi, /* atan2(-pi, -inf) */ -pi / 2, /* atan2(-pi, +0) */
|
-pi / 2, // atan2(-inf, pi)
|
||||||
-0.0,
|
-pi / 4, // atan2(-inf, +inf)
|
||||||
/* atan2(-pi, inf) */ nan(), /* atan2(-pi, nan) */ -pi, /* atan2(-0, -inf) */ -pi,
|
nan(), // atan2(-inf, nan)
|
||||||
/* atan2(-0, -pi) */ -pi, /* atan2(-0, -0) */ -0.0, /* atan2(-0, +0) */ -0.0, /* atan2(-0, pi) */
|
-pi, // atan2(-pi, -inf)
|
||||||
-0.0,
|
-pi / 2, // atan2(-pi, +0)
|
||||||
/* atan2(-0, +inf) */ nan(), /* atan2(-0, nan) */ pi, /* atan2(+0, -inf) */ pi, /* atan2(+0, -pi) */
|
-0.0, // atan2(-pi, inf)
|
||||||
pi, /* atan2(+0, -0) */ 0, /* atan2(+0, +0) */ 0, /* atan2(+0, pi) */ 0, /* atan2(+0, +inf) */
|
nan(), // atan2(-pi, nan)
|
||||||
nan(), /* atan2(+0, nan) */ pi, /* atan2(pi, -inf) */ pi / 2, /* atan2(pi, +0) */ 0,
|
-pi, // atan2(-0, -inf)
|
||||||
/* atan2(pi, +inf) */ nan(), /* atan2(pi, nan) */ 3.0 * pi / 4, /* atan2(+inf, -inf) */
|
-pi, // atan2(-0, -pi)
|
||||||
pi / 2, /* atan2(+inf, -pi) */ pi / 2, /* atan2(+inf, +0) */ pi / 2, /* atan2(+inf, pi) */
|
-pi, // atan2(-0, -0)
|
||||||
pi / 4, /* atan2(+inf, +inf) */ nan(), /* atan2(+inf, nan) */
|
-0.0, // atan2(-0, +0)
|
||||||
nan(), /* atan2(nan, nan) */
|
-0.0, // atan2(-0, pi)
|
||||||
|
-0.0, // atan2(-0, +inf)
|
||||||
|
nan(), // atan2(-0, nan)
|
||||||
|
pi, // atan2(+0, -inf)
|
||||||
|
pi, // atan2(+0, -pi)
|
||||||
|
pi, // atan2(+0, -0)
|
||||||
|
0, // atan2(+0, +0)
|
||||||
|
0, // atan2(+0, pi)
|
||||||
|
0, // atan2(+0, +inf)
|
||||||
|
nan(), // atan2(+0, nan)
|
||||||
|
pi, // atan2(pi, -inf)
|
||||||
|
pi / 2, // atan2(pi, +0)
|
||||||
|
0, // atan2(pi, +inf)
|
||||||
|
nan(), // atan2(pi, nan)
|
||||||
|
3.0 * pi / 4, // atan2(+inf, -inf)
|
||||||
|
pi / 2, // atan2(+inf, -pi)
|
||||||
|
pi / 2, // atan2(+inf, +0)
|
||||||
|
pi / 2, // atan2(+inf, pi)
|
||||||
|
pi / 4, // atan2(+inf, +inf)
|
||||||
|
nan(), // atan2(+inf, nan)
|
||||||
|
nan(), // atan2(nan, nan)
|
||||||
]
|
]
|
||||||
for i := 0; i < vfatan2_sc_.len; i++ {
|
for i := 0; i < vfatan2_sc_.len; i++ {
|
||||||
f := atan2(vfatan2_sc_[i][0], vfatan2_sc_[i][1])
|
f := atan2(vfatan2_sc_[i][0], vfatan2_sc_[i][1])
|
||||||
|
@ -528,10 +548,10 @@ fn test_exp() {
|
||||||
f := exp(math.vf_[i])
|
f := exp(math.vf_[i])
|
||||||
assert veryclose(math.exp_[i], f)
|
assert veryclose(math.exp_[i], f)
|
||||||
}
|
}
|
||||||
vfexp_sc_ := [inf(-1), -2000, 2000, inf(1), nan(), /* smallest f64 that overflows Exp(x) */
|
vfexp_sc_ := [inf(-1), -2000, 2000, inf(1), nan(), // smallest f64 that overflows Exp(x)
|
||||||
7.097827128933841e+02, 1.48852223e+09, 1.4885222e+09, 1, /* near zero */
|
7.097827128933841e+02, 1.48852223e+09, 1.4885222e+09, 1, // near zero
|
||||||
3.725290298461915e-09,
|
3.725290298461915e-09, -740, // denormal
|
||||||
/* denormal */ -740]
|
]
|
||||||
exp_sc_ := [f64(0), 0, inf(1), inf(1), nan(), inf(1), inf(1),
|
exp_sc_ := [f64(0), 0, inf(1), inf(1), nan(), inf(1), inf(1),
|
||||||
inf(1), 2.718281828459045, 1.0000000037252903, 4.2e-322]
|
inf(1), 2.718281828459045, 1.0000000037252903, 4.2e-322]
|
||||||
for i := 0; i < vfexp_sc_.len; i++ {
|
for i := 0; i < vfexp_sc_.len; i++ {
|
||||||
|
@ -545,8 +565,10 @@ fn test_exp2() {
|
||||||
f := exp2(math.vf_[i])
|
f := exp2(math.vf_[i])
|
||||||
assert soclose(math.exp2_[i], f, 1e-9)
|
assert soclose(math.exp2_[i], f, 1e-9)
|
||||||
}
|
}
|
||||||
vfexp2_sc_ := [f64(-2000), 2000, inf(1), nan(), /* smallest f64 that overflows Exp2(x) */
|
vfexp2_sc_ := [f64(-2000), 2000, inf(1), nan(), // smallest f64 that overflows Exp2(x)
|
||||||
1024, /* near underflow */ -1.07399999999999e+03, /* near zero */ 3.725290298461915e-09]
|
1024, -1.07399999999999e+03, // near underflow
|
||||||
|
3.725290298461915e-09, // near zero
|
||||||
|
]
|
||||||
exp2_sc_ := [f64(0), inf(1), inf(1), nan(), inf(1), 5e-324, 1.0000000025821745]
|
exp2_sc_ := [f64(0), inf(1), inf(1), nan(), inf(1), 5e-324, 1.0000000025821745]
|
||||||
for i := 0; i < vfexp2_sc_.len; i++ {
|
for i := 0; i < vfexp2_sc_.len; i++ {
|
||||||
f := exp2(vfexp2_sc_[i])
|
f := exp2(vfexp2_sc_[i])
|
||||||
|
@ -577,7 +599,8 @@ fn test_gamma() {
|
||||||
vfgamma_ := [[inf(1), inf(1)], [inf(-1), nan()], [f64(0), inf(1)],
|
vfgamma_ := [[inf(1), inf(1)], [inf(-1), nan()], [f64(0), inf(1)],
|
||||||
[f64(-0.0), inf(-1)], [nan(), nan()], [f64(-1), nan()],
|
[f64(-0.0), inf(-1)], [nan(), nan()], [f64(-1), nan()],
|
||||||
[f64(-2), nan()], [f64(-3), nan()], [f64(-1e+16), nan()],
|
[f64(-2), nan()], [f64(-3), nan()], [f64(-1e+16), nan()],
|
||||||
[f64(-1e+300), nan()], [f64(1.7e+308), inf(1)], /* Test inputs inspi_red by Python test suite. */
|
[f64(-1e+300), nan()], [f64(1.7e+308), inf(1)], // Test inputs inspi_red by Python test suite
|
||||||
|
|
||||||
// Outputs computed at high precision by PARI/GP.
|
// Outputs computed at high precision by PARI/GP.
|
||||||
// If recomputing table entries), be careful to use
|
// If recomputing table entries), be careful to use
|
||||||
// high-precision (%.1000g) formatting of the f64 inputs.
|
// high-precision (%.1000g) formatting of the f64 inputs.
|
||||||
|
@ -646,12 +669,11 @@ fn test_hypot() {
|
||||||
vfhypot_sc_ := [[inf(-1), inf(-1)], [inf(-1), 0], [inf(-1),
|
vfhypot_sc_ := [[inf(-1), inf(-1)], [inf(-1), 0], [inf(-1),
|
||||||
inf(1)],
|
inf(1)],
|
||||||
[inf(-1), nan()], [f64(-0.0), -0.0], [f64(-0.0), 0], [f64(0), -0.0],
|
[inf(-1), nan()], [f64(-0.0), -0.0], [f64(-0.0), 0], [f64(0), -0.0],
|
||||||
[f64(0), 0], /* +0,0 */ [f64(0), inf(-1)], [f64(0), inf(1)],
|
[f64(0), 0], [f64(0), inf(-1)], [f64(0), inf(1)], [f64(0), nan()],
|
||||||
[f64(0), nan()], [inf(1), inf(-1)], [inf(1), 0], [inf(1),
|
[inf(1), inf(-1)], [inf(1), 0], [inf(1), inf(1)], [inf(1),
|
||||||
inf(1)],
|
nan()],
|
||||||
[inf(1), nan()], [nan(), inf(-1)], [nan(), 0], [nan(),
|
[nan(), inf(-1)], [nan(), 0], [nan(), inf(1)], [nan(),
|
||||||
inf(1)],
|
nan()]]
|
||||||
[nan(), nan()]]
|
|
||||||
hypot_sc_ := [inf(1), inf(1), inf(1), inf(1), 0, 0, 0, 0, inf(1),
|
hypot_sc_ := [inf(1), inf(1), inf(1), inf(1), 0, 0, 0, 0, inf(1),
|
||||||
inf(1), nan(), inf(1), inf(1), inf(1), inf(1), inf(1),
|
inf(1), nan(), inf(1), inf(1), inf(1), inf(1), inf(1),
|
||||||
nan(), inf(1), nan()]
|
nan(), inf(1), nan()]
|
||||||
|
@ -755,27 +777,69 @@ fn test_pow() {
|
||||||
[inf(1), 1], [inf(1), pi], [inf(1), nan()], [nan(), -pi],
|
[inf(1), 1], [inf(1), pi], [inf(1), nan()], [nan(), -pi],
|
||||||
[nan(), -0.0], [nan(), 0], [nan(), 1], [nan(), pi], [nan(),
|
[nan(), -0.0], [nan(), 0], [nan(), 1], [nan(), pi], [nan(),
|
||||||
nan()]]
|
nan()]]
|
||||||
pow_sc_ := [f64(0), /* pow(-inf, -pi) */ -0.0, /* pow(-inf, -3) */ 1, /* pow(-inf, -0) */ 1, /* pow(-inf, +0) */
|
pow_sc_ := [f64(0), // pow(-inf, -pi)
|
||||||
inf(-1), /* pow(-inf, 1) */ inf(-1), /* pow(-inf, 3) */
|
-0.0, // pow(-inf, -3)
|
||||||
inf(1), /* pow(-inf, pi) */ inf(1), /* pow(-inf, 0.5) */
|
1, // pow(-inf, -0)
|
||||||
nan(), /* pow(-inf, nan) */ 0, /* pow(-pi, -inf) */ nan(), /* pow(-pi, -pi) */
|
1, // pow(-inf, +0)
|
||||||
1, /* pow(-pi, -0) */ 1, /* pow(-pi, +0) */ -pi, /* pow(-pi, 1) */ nan(), /* pow(-pi, pi) */
|
inf(-1), // pow(-inf, 1)
|
||||||
inf(1), /* pow(-pi, +inf) */ nan(), /* pow(-pi, nan) */ 1, /* pow(-1, -inf) IEEE 754-2008 */
|
inf(-1), // pow(-inf, 3)
|
||||||
1, /* pow(-1, +inf) IEEE 754-2008 */ nan(), /* pow(-1, nan) */
|
inf(1), // pow(-inf, pi)
|
||||||
inf(1), /* pow(-1/2, -inf) */ 0, /* pow(-1/2, +inf) */ inf(1), /* pow(-0, -inf) */
|
inf(1), // pow(-inf, 0.5)
|
||||||
inf(1), /* pow(-0, -pi) */ inf(1), /* pow(-0, -0.5) */
|
nan(), // pow(-inf, nan)
|
||||||
inf(-1), /* pow(-0, -3) IEEE 754-2008 */ -0.0, /* pow(-0, 3) IEEE 754-2008 */ 0, /* pow(-0, pi) */
|
0, // pow(-pi, -inf)
|
||||||
0, /* pow(-0, 0.5) */ 0, /* pow(-0, +inf) */ inf(1), /* pow(+0, -inf) */
|
nan(), // pow(-pi, -pi)
|
||||||
inf(1), /* pow(+0, -pi) */ inf(1), /* pow(+0, -3) */ 1, /* pow(+0, -0) */ 1, /* pow(+0, +0) */
|
1, // pow(-pi, -0)
|
||||||
0, /* pow(+0, 3) */ 0,
|
1, // pow(-pi, +0)
|
||||||
/* pow(+0, pi) */ 0, /* pow(+0, +inf) */ nan(), /* pow(+0, nan) */
|
-pi, // pow(-pi, 1)
|
||||||
inf(1), /* pow(1/2, -inf) */ 0, /* pow(1/2, +inf) */ 1, /* pow(1, -inf) IEEE 754-2008 */
|
nan(), // pow(-pi, pi)
|
||||||
1, /* pow(1, +inf) IEEE 754-2008 */ 1, /* pow(1, nan) IEEE 754-2008 */ 0, /* pow(pi, -inf) */
|
inf(1), // pow(-pi, +inf)
|
||||||
1, /* pow(pi, -0) */ 1, /* pow(pi, +0) */ pi, /* pow(pi, 1) */ inf(1), /* pow(pi, +inf) */
|
nan(), // pow(-pi, nan)
|
||||||
nan(), /* pow(pi, nan) */ 0, /* pow(+inf, -pi) */ 1, /* pow(+inf, -0) */ 1, /* pow(+inf, +0) */
|
1, // pow(-1, -inf) IEEE 754-2008
|
||||||
inf(1), /* pow(+inf, 1) */ inf(1), /* pow(+inf, pi) */
|
1, // pow(-1, +inf) IEEE 754-2008
|
||||||
nan(), /* pow(+inf, nan) */ nan(), /* pow(nan, -pi) */ 1, /* pow(nan, -0) */ 1, /* pow(nan, +0) */
|
nan(), // pow(-1, nan)
|
||||||
nan(), /* pow(nan, 1) */ nan(), /* pow(nan, pi) */ nan(), /* pow(nan, nan) */]
|
inf(1), // pow(-1/2, -inf)
|
||||||
|
0, // pow(-1/2, +inf)
|
||||||
|
inf(1), // pow(-0, -inf)
|
||||||
|
inf(1), // pow(-0, -pi)
|
||||||
|
inf(1), // pow(-0, -0.5)
|
||||||
|
inf(-1), // pow(-0, -3) IEEE 754-2008
|
||||||
|
-0.0, // pow(-0, 3) IEEE 754-2008
|
||||||
|
0, // pow(-0, pi)
|
||||||
|
0, // pow(-0, 0.5)
|
||||||
|
0, // pow(-0, +inf)
|
||||||
|
inf(1), // pow(+0, -inf)
|
||||||
|
inf(1), // pow(+0, -pi)
|
||||||
|
inf(1), // pow(+0, -3)
|
||||||
|
1, // pow(+0, -0)
|
||||||
|
1, // pow(+0, +0)
|
||||||
|
0, // pow(+0, 3)
|
||||||
|
0, // pow(+0, pi)
|
||||||
|
0, // pow(+0, +inf)
|
||||||
|
nan(), // pow(+0, nan)
|
||||||
|
inf(1), // pow(1/2, -inf)
|
||||||
|
0, // pow(1/2, +inf)
|
||||||
|
1, // pow(1, -inf) IEEE 754-2008
|
||||||
|
1, // pow(1, +inf) IEEE 754-2008
|
||||||
|
1, // pow(1, nan) IEEE 754-2008
|
||||||
|
0, // pow(pi, -inf)
|
||||||
|
1, // pow(pi, -0)
|
||||||
|
1, // pow(pi, +0)
|
||||||
|
pi, // pow(pi, 1)
|
||||||
|
inf(1), // pow(pi, +inf)
|
||||||
|
nan(), // pow(pi, nan)
|
||||||
|
0, // pow(+inf, -pi)
|
||||||
|
1, // pow(+inf, -0)
|
||||||
|
1, // pow(+inf, +0)
|
||||||
|
inf(1), // pow(+inf, 1)
|
||||||
|
inf(1), // pow(+inf, pi)
|
||||||
|
nan(), // pow(+inf, nan)
|
||||||
|
nan(), // pow(nan, -pi)
|
||||||
|
1, // pow(nan, -0)
|
||||||
|
1, // pow(nan, +0)
|
||||||
|
nan(), // pow(nan, 1)
|
||||||
|
nan(), // pow(nan, pi)
|
||||||
|
nan(), // pow(nan, nan)
|
||||||
|
]
|
||||||
for i := 0; i < vfpow_sc_.len; i++ {
|
for i := 0; i < vfpow_sc_.len; i++ {
|
||||||
f := pow(vfpow_sc_[i][0], vfpow_sc_[i][1])
|
f := pow(vfpow_sc_[i][0], vfpow_sc_[i][1])
|
||||||
assert alike(pow_sc_[i], f)
|
assert alike(pow_sc_[i], f)
|
||||||
|
@ -793,14 +857,14 @@ fn test_round() {
|
||||||
assert alike(math.round_[i], f)
|
assert alike(math.round_[i], f)
|
||||||
}
|
}
|
||||||
vfround_sc_ := [[f64(0), 0], [nan(), nan()], [inf(1), inf(1)]]
|
vfround_sc_ := [[f64(0), 0], [nan(), nan()], [inf(1), inf(1)]]
|
||||||
// vfround_even_sc_ := [[f64(0), 0], [f64(1.390671161567e-309), 0], /* denormal */
|
// vfround_even_sc_ := [[f64(0), 0], [f64(1.390671161567e-309), 0], // denormal
|
||||||
// [f64(0.49999999999999994), 0], /* 0.5-epsilon */ [f64(0.5), 0],
|
// [f64(0.49999999999999994), 0], // 0.5-epsilon [f64(0.5), 0],
|
||||||
// [f64(0.5000000000000001), 1], /* 0.5+epsilon */ [f64(-1.5), -2],
|
// [f64(0.5000000000000001), 1], // 0.5+epsilon [f64(-1.5), -2],
|
||||||
// [f64(-2.5), -2], [nan(), nan()], [inf(1), inf(1)],
|
// [f64(-2.5), -2], [nan(), nan()], [inf(1), inf(1)],
|
||||||
// [f64(2251799813685249.5), 2251799813685250],
|
// [f64(2251799813685249.5), 2251799813685250],
|
||||||
// // 1 bit fractian [f64(2251799813685250.5), 2251799813685250],
|
// // 1 bit fractian [f64(2251799813685250.5), 2251799813685250],
|
||||||
// [f64(4503599627370495.5), 4503599627370496], /* 1 bit fraction, rounding to 0 bit fractian */
|
// [f64(4503599627370495.5), 4503599627370496], // 1 bit fraction, rounding to 0 bit fractian
|
||||||
// [f64(4503599627370497), 4503599627370497], /* large integer */
|
// [f64(4503599627370497), 4503599627370497], // large integer
|
||||||
// ]
|
// ]
|
||||||
for i := 0; i < vfround_sc_.len; i++ {
|
for i := 0; i < vfround_sc_.len; i++ {
|
||||||
f := round(vfround_sc_[i][0])
|
f := round(vfround_sc_[i][0])
|
||||||
|
|
|
@ -712,7 +712,10 @@ pub fn executable() string {
|
||||||
}
|
}
|
||||||
$if freebsd {
|
$if freebsd {
|
||||||
bufsize := usize(max_path_buffer_size)
|
bufsize := usize(max_path_buffer_size)
|
||||||
mib := [1 /* CTL_KERN */, 14 /* KERN_PROC */, 12 /* KERN_PROC_PATHNAME */, -1]
|
mib := [1, // CTL_KERN
|
||||||
|
14, // KERN_PROC
|
||||||
|
12, // KERN_PROC_PATHNAME
|
||||||
|
-1]
|
||||||
unsafe { C.sysctl(mib.data, mib.len, &result[0], &bufsize, 0, 0) }
|
unsafe { C.sysctl(mib.data, mib.len, &result[0], &bufsize, 0, 0) }
|
||||||
res := unsafe { tos_clone(&result[0]) }
|
res := unsafe { tos_clone(&result[0]) }
|
||||||
return res
|
return res
|
||||||
|
|
40
vlib/os/os.v
40
vlib/os/os.v
|
@ -162,17 +162,37 @@ pub fn sigint_to_signal_name(si int) string {
|
||||||
match si {
|
match si {
|
||||||
// TODO dependent on platform
|
// TODO dependent on platform
|
||||||
// works only on x86/ARM/most others
|
// works only on x86/ARM/most others
|
||||||
10 /* , 30, 16 */ { return 'SIGUSR1' }
|
10 { // , 30, 16
|
||||||
12 /* , 31, 17 */ { return 'SIGUSR2' }
|
return 'SIGUSR1'
|
||||||
17 /* , 20, 18 */ { return 'SIGCHLD' }
|
}
|
||||||
18 /* , 19, 25 */ { return 'SIGCONT' }
|
12 { // , 31, 17
|
||||||
19 /* , 17, 23 */ { return 'SIGSTOP' }
|
return 'SIGUSR2'
|
||||||
20 /* , 18, 24 */ { return 'SIGTSTP' }
|
}
|
||||||
21 /* , 26 */ { return 'SIGTTIN' }
|
17 { // , 20, 18
|
||||||
22 /* , 27 */ { return 'SIGTTOU' }
|
return 'SIGCHLD'
|
||||||
|
}
|
||||||
|
18 { // , 19, 25
|
||||||
|
return 'SIGCONT'
|
||||||
|
}
|
||||||
|
19 { // , 17, 23
|
||||||
|
return 'SIGSTOP'
|
||||||
|
}
|
||||||
|
20 { // , 18, 24
|
||||||
|
return 'SIGTSTP'
|
||||||
|
}
|
||||||
|
21 { // , 26
|
||||||
|
return 'SIGTTIN'
|
||||||
|
}
|
||||||
|
22 { // , 27
|
||||||
|
return 'SIGTTOU'
|
||||||
|
}
|
||||||
// /////////////////////////////
|
// /////////////////////////////
|
||||||
5 { return 'SIGTRAP' }
|
5 {
|
||||||
7 { return 'SIGBUS' }
|
return 'SIGTRAP'
|
||||||
|
}
|
||||||
|
7 {
|
||||||
|
return 'SIGBUS'
|
||||||
|
}
|
||||||
else {}
|
else {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -86,7 +86,7 @@ fn C.sapp_get_clipboard_string() &u8
|
||||||
// set the window title (only on desktop platforms)
|
// set the window title (only on desktop platforms)
|
||||||
fn C.sapp_set_window_title(&char)
|
fn C.sapp_set_window_title(&char)
|
||||||
|
|
||||||
// /* set the window icon (only on Windows and Linux) */
|
// set the window icon (only on Windows and Linux)
|
||||||
// SOKOL_APP_API_DECL void sapp_set_icon(const sapp_icon_desc* icon_desc);
|
// SOKOL_APP_API_DECL void sapp_set_icon(const sapp_icon_desc* icon_desc);
|
||||||
|
|
||||||
// Get number of dropped files
|
// Get number of dropped files
|
||||||
|
@ -104,10 +104,10 @@ fn C.sapp_gles2() bool
|
||||||
// HTML5: enable or disable the hardwired "Leave Site?" dialog box
|
// HTML5: enable or disable the hardwired "Leave Site?" dialog box
|
||||||
fn C.sapp_html5_ask_leave_site(ask bool)
|
fn C.sapp_html5_ask_leave_site(ask bool)
|
||||||
|
|
||||||
// /* HTML5: get byte size of a dropped file */
|
// HTML5: get byte size of a dropped file
|
||||||
// SOKOL_APP_API_DECL uint32_t sapp_html5_get_dropped_file_size(int index);
|
// SOKOL_APP_API_DECL uint32_t sapp_html5_get_dropped_file_size(int index);
|
||||||
|
|
||||||
// /* HTML5: asynchronously load the content of a dropped file */
|
// HTML5: asynchronously load the content of a dropped file
|
||||||
// SOKOL_APP_API_DECL void sapp_html5_fetch_dropped_file(const sapp_html5_fetch_request* request);
|
// SOKOL_APP_API_DECL void sapp_html5_fetch_dropped_file(const sapp_html5_fetch_request* request);
|
||||||
|
|
||||||
// Metal: get ARC-bridged pointer to Metal device object
|
// Metal: get ARC-bridged pointer to Metal device object
|
||||||
|
|
|
@ -255,7 +255,7 @@ fn (mut ctx Context) parse_events() {
|
||||||
modifiers: modifiers
|
modifiers: modifiers
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
0x0008 /* C.MOUSE_HWHEELED */ {
|
0x0008 { // C.MOUSE_HWHEELED
|
||||||
ctx.event(&Event{
|
ctx.event(&Event{
|
||||||
typ: .mouse_scroll
|
typ: .mouse_scroll
|
||||||
direction: if i16(e.dwButtonState >> 16) < 0 {
|
direction: if i16(e.dwButtonState >> 16) < 0 {
|
||||||
|
@ -268,7 +268,7 @@ fn (mut ctx Context) parse_events() {
|
||||||
modifiers: modifiers
|
modifiers: modifiers
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
0 /* CLICK */, C.DOUBLE_CLICK {
|
0, C.DOUBLE_CLICK {
|
||||||
button := match int(e.dwButtonState) {
|
button := match int(e.dwButtonState) {
|
||||||
0 { ctx.mouse_down }
|
0 { ctx.mouse_down }
|
||||||
1 { MouseButton.left }
|
1 { MouseButton.left }
|
||||||
|
|
|
@ -1609,10 +1609,10 @@ pub const (
|
||||||
// map register size -> register name
|
// map register size -> register name
|
||||||
x86_no_number_register_list = {
|
x86_no_number_register_list = {
|
||||||
8: ['al', 'ah', 'bl', 'bh', 'cl', 'ch', 'dl', 'dh', 'bpl', 'sil', 'dil', 'spl']
|
8: ['al', 'ah', 'bl', 'bh', 'cl', 'ch', 'dl', 'dh', 'bpl', 'sil', 'dil', 'spl']
|
||||||
16: ['ax', 'bx', 'cx', 'dx', 'bp', 'si', 'di', 'sp', /* segment registers */ 'cs', 'ss',
|
16: ['ax', 'bx', 'cx', 'dx', 'bp', 'si', 'di', 'sp', // segment registers
|
||||||
'ds', 'es', 'fs', 'gs', 'flags', 'ip', /* task registers */ 'gdtr', 'idtr', 'tr', 'ldtr',
|
'cs', 'ss', 'ds', 'es', 'fs', 'gs', 'flags', 'ip', // task registers
|
||||||
// CSR register 'msw', /* FP core registers */ 'cw', 'sw', 'tw', 'fp_ip', 'fp_dp',
|
'gdtr', 'idtr', 'tr', 'ldtr', // CSR register 'msw', /* FP core registers */ 'cw', 'sw', 'tw', 'fp_ip', 'fp_dp', 'fp_cs',
|
||||||
'fp_cs', 'fp_ds', 'fp_opc']
|
'fp_ds', 'fp_opc']
|
||||||
32: [
|
32: [
|
||||||
'eax',
|
'eax',
|
||||||
'ebx',
|
'ebx',
|
||||||
|
@ -1623,8 +1623,8 @@ pub const (
|
||||||
'edi',
|
'edi',
|
||||||
'esp',
|
'esp',
|
||||||
'eflags',
|
'eflags',
|
||||||
'eip', /* CSR register */
|
'eip', // CSR register
|
||||||
'mxcsr' /* 32-bit FP core registers 'fp_dp', 'fp_ip' (TODO: why are there duplicates?) */,
|
'mxcsr', // 32-bit FP core registers 'fp_dp', 'fp_ip' (TODO: why are there duplicates?)
|
||||||
]
|
]
|
||||||
64: ['rax', 'rbx', 'rcx', 'rdx', 'rbp', 'rsi', 'rdi', 'rsp', 'rflags', 'rip']
|
64: ['rax', 'rbx', 'rcx', 'rdx', 'rbp', 'rsi', 'rdi', 'rsp', 'rflags', 'rip']
|
||||||
}
|
}
|
||||||
|
@ -1667,9 +1667,11 @@ pub const (
|
||||||
|
|
||||||
// TODO: saved priviled registers for arm
|
// TODO: saved priviled registers for arm
|
||||||
pub const (
|
pub const (
|
||||||
arm_no_number_register_list = ['fp' /* aka r11 */, /* not instruction pointer: */ 'ip' /* aka r12 */,
|
arm_no_number_register_list = ['fp', // aka r11
|
||||||
'sp' /* aka r13 */, 'lr' /* aka r14 */, /* this is instruction pointer ('program counter'): */
|
'ip', // not instruction pointer: aka r12
|
||||||
'pc' /* aka r15 */,
|
'sp', // aka r13
|
||||||
|
'lr', // aka r14
|
||||||
|
'pc', // this is instruction pointer ('program counter'): aka r15
|
||||||
] // 'cpsr' and 'apsr' are special flags registers, but cannot be referred to directly
|
] // 'cpsr' and 'apsr' are special flags registers, but cannot be referred to directly
|
||||||
arm_with_number_register_list = {
|
arm_with_number_register_list = {
|
||||||
'r#': 16
|
'r#': 16
|
||||||
|
|
|
@ -148,14 +148,14 @@ fn (mut v Builder) setup_ccompiler_options(ccompiler string) {
|
||||||
'-Wno-type-limits',
|
'-Wno-type-limits',
|
||||||
'-Wno-tautological-compare',
|
'-Wno-tautological-compare',
|
||||||
// these cause various issues:
|
// these cause various issues:
|
||||||
'-Wno-shadow' /* the V compiler already catches this for user code, and enabling this causes issues with e.g. the `it` variable */,
|
'-Wno-shadow', // the V compiler already catches this for user code, and enabling this causes issues with e.g. the `it` variable
|
||||||
'-Wno-int-to-pointer-cast' /* gcc version of the above */,
|
'-Wno-int-to-pointer-cast', // gcc version of the above
|
||||||
'-Wno-trigraphs' /* see stackoverflow.com/a/8435413 */,
|
'-Wno-trigraphs', // see stackoverflow.com/a/8435413
|
||||||
'-Wno-missing-braces' /* see stackoverflow.com/q/13746033 */,
|
'-Wno-missing-braces', // see stackoverflow.com/q/13746033
|
||||||
// enable additional warnings:
|
// enable additional warnings:
|
||||||
'-Wno-unknown-warning' /* if a C compiler does not understand a certain flag, it should just ignore it */,
|
'-Wno-unknown-warning', // if a C compiler does not understand a certain flag, it should just ignore it
|
||||||
'-Wno-unknown-warning-option' /* clang equivalent of the above */,
|
'-Wno-unknown-warning-option', // clang equivalent of the above
|
||||||
'-Wno-excess-initializers' /* vlib/v/tests/struct_init_with_complex_fields_test.v fails without that on macos clang 13 */,
|
'-Wno-excess-initializers', // vlib/v/tests/struct_init_with_complex_fields_test.v fails without that on macos clang 13
|
||||||
'-Wdate-time',
|
'-Wdate-time',
|
||||||
'-Wduplicated-branches',
|
'-Wduplicated-branches',
|
||||||
'-Wduplicated-cond',
|
'-Wduplicated-cond',
|
||||||
|
@ -232,8 +232,8 @@ fn (mut v Builder) setup_ccompiler_options(ccompiler string) {
|
||||||
}
|
}
|
||||||
ccoptions.wargs << [
|
ccoptions.wargs << [
|
||||||
'-Wno-tautological-bitwise-compare',
|
'-Wno-tautological-bitwise-compare',
|
||||||
'-Wno-enum-conversion' /* used in vlib/sokol, where C enums in C structs are typed as V structs instead */,
|
'-Wno-enum-conversion', // used in vlib/sokol, where C enums in C structs are typed as V structs instead
|
||||||
'-Wno-sometimes-uninitialized' /* produced after exhaustive matches */,
|
'-Wno-sometimes-uninitialized', // produced after exhaustive matches
|
||||||
'-Wno-int-to-void-pointer-cast',
|
'-Wno-int-to-void-pointer-cast',
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
|
@ -1847,7 +1847,7 @@ fn (mut c Checker) enum_decl(mut node ast.EnumDecl) {
|
||||||
c.ident(mut field.expr)
|
c.ident(mut field.expr)
|
||||||
}
|
}
|
||||||
if field.expr.kind == .constant && field.expr.obj.typ.is_int() {
|
if field.expr.kind == .constant && field.expr.obj.typ.is_int() {
|
||||||
/* accepts int constants as enum value */
|
// accepts int constants as enum value
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -777,8 +777,10 @@ fn expr_is_single_line(expr ast.Expr) bool {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ast.ArrayInit {
|
ast.ArrayInit {
|
||||||
if expr.exprs.len > 0 {
|
for e in expr.exprs {
|
||||||
return expr_is_single_line(expr.exprs[0])
|
if !expr_is_single_line(e) {
|
||||||
|
return false
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ast.ConcatExpr {
|
ast.ConcatExpr {
|
||||||
|
@ -1766,9 +1768,11 @@ pub fn (mut f Fmt) array_init(node ast.ArrayInit) {
|
||||||
}
|
}
|
||||||
f.write(' ')
|
f.write(' ')
|
||||||
f.comment(cmt)
|
f.comment(cmt)
|
||||||
|
if !line_break {
|
||||||
|
f.writeln('')
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
last_comment_was_inline = cmt.is_inline
|
|
||||||
}
|
}
|
||||||
} else if i == node.exprs.len - 1 && !line_break {
|
} else if i == node.exprs.len - 1 && !line_break {
|
||||||
is_new_line = false
|
is_new_line = false
|
||||||
|
|
|
@ -5,5 +5,4 @@ v := [
|
||||||
// 2-3
|
// 2-3
|
||||||
3, // 3
|
3, // 3
|
||||||
// 4
|
// 4
|
||||||
/* 5 */
|
|
||||||
]
|
]
|
||||||
|
|
|
@ -5,5 +5,4 @@ v := [
|
||||||
// 2-3
|
// 2-3
|
||||||
3, // 3
|
3, // 3
|
||||||
// 4
|
// 4
|
||||||
/* 5 */
|
|
||||||
]
|
]
|
||||||
|
|
|
@ -1,2 +0,0 @@
|
||||||
a := [1 /* y */, /* x */ 2, 3]
|
|
||||||
println(a)
|
|
|
@ -1,7 +0,0 @@
|
||||||
module main
|
|
||||||
|
|
||||||
fn main() {
|
|
||||||
println('Hello World!')
|
|
||||||
}
|
|
||||||
|
|
||||||
fn C.f( /* mut */ buff &char) i64
|
|
|
@ -1,7 +0,0 @@
|
||||||
module main
|
|
||||||
|
|
||||||
fn main() {
|
|
||||||
println('Hello World!')
|
|
||||||
}
|
|
||||||
|
|
||||||
fn C.f(/*mut*/buff &char) i64
|
|
|
@ -9,7 +9,7 @@ fn main() {
|
||||||
// below expr
|
// below expr
|
||||||
]
|
]
|
||||||
_ := [
|
_ := [
|
||||||
8, /* I don't know why this still is a block comment */
|
8, // I don't know why this still is a block comment
|
||||||
9,
|
9,
|
||||||
]
|
]
|
||||||
arr := [
|
arr := [
|
||||||
|
@ -18,39 +18,27 @@ fn main() {
|
||||||
// test 1
|
// test 1
|
||||||
2,
|
2,
|
||||||
// test 2
|
// test 2
|
||||||
3, /* 3 */
|
3, // 3
|
||||||
4, /* 4-1 */ /* 4-2 */
|
4, // 4-1
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
fn only_comments_array() {
|
fn only_comments_array() {
|
||||||
_ := [/* on a single line */ /* too */]
|
_ := []
|
||||||
_ := [
|
_ := [
|
||||||
// 1,
|
// 1,
|
||||||
// 2,
|
// 2,
|
||||||
// 3,
|
// 3,
|
||||||
]
|
]
|
||||||
_ := [
|
_ := [
|
||||||
/* whatever */ /* this is */ // 3,
|
// whatever */ /* this is */ // 3,
|
||||||
// 4,
|
// 4,
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
fn single_line_array_pre_comments() {
|
|
||||||
_ := [/* 2, */ 3]
|
|
||||||
_ := [/* 4, */ /* 5, */ 6]
|
|
||||||
_ := [/* cmt */ -4]
|
|
||||||
}
|
|
||||||
|
|
||||||
fn single_line_array_iembed_comments() {
|
|
||||||
_ := [1, /* betw single line */ 2]
|
|
||||||
// This caused a bug where the ´-´ was parsed as InfixExpr and not as part of an IntegerLiteral
|
|
||||||
_ := [1, /* cmt */ -4]
|
|
||||||
}
|
|
||||||
|
|
||||||
fn mixed_comments() {
|
fn mixed_comments() {
|
||||||
_ := [
|
_ := [
|
||||||
3 /* iembed */,
|
3, // iembed
|
||||||
// keep line comment here
|
// keep line comment here
|
||||||
// and here
|
// and here
|
||||||
5,
|
5,
|
||||||
|
@ -68,12 +56,3 @@ fn keep_real_block_comment() {
|
||||||
'eggs',
|
'eggs',
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
fn comment_at_line_start_with_expressions_after() {
|
|
||||||
arr := [123456789012345, 234567890123456, 678901234567890, 789012345678901, /* at the end */
|
|
||||||
345678901234567, /* in between */ 456789012345678,
|
|
||||||
/* line start */ 567890123456789, 890123456789012]
|
|
||||||
arr2 := [/* same line pre comment */ Foo{
|
|
||||||
a: 123
|
|
||||||
}]
|
|
||||||
}
|
|
||||||
|
|
|
@ -6,23 +6,24 @@ comment
|
||||||
*/
|
*/
|
||||||
|
|
||||||
fn fun() int {
|
fn fun() int {
|
||||||
return /* comment zero */ 0 // another comment
|
return 0 // another comment
|
||||||
}
|
}
|
||||||
|
|
||||||
fn mr_fun() (int, int) {
|
fn mr_fun() (int, int) {
|
||||||
return /* one comment */ 1, /* another comment */ 2
|
return 1, // one comment
|
||||||
|
2 // another comment
|
||||||
}
|
}
|
||||||
|
|
||||||
fn single_line_blocks() {
|
fn single_line_blocks() {
|
||||||
/* 1 */
|
// 1
|
||||||
println('')
|
println('')
|
||||||
/* 2 */
|
// 2
|
||||||
println('')
|
println('')
|
||||||
/* 3 */
|
// 3
|
||||||
/* 4 */
|
// 4
|
||||||
println('')
|
println('')
|
||||||
// 5
|
// 5
|
||||||
/* 6 */
|
// 6
|
||||||
}
|
}
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
|
@ -35,28 +36,15 @@ fn main() {
|
||||||
/*
|
/*
|
||||||
block3
|
block3
|
||||||
*/
|
*/
|
||||||
a := /* this is a comment */ 1
|
a := 1 // this is a comment
|
||||||
b, c := /* and another comment */ a, /* just to make it worse */ 2
|
|
||||||
d := c // and an extra one
|
d := c // and an extra one
|
||||||
e := c
|
e := c
|
||||||
// more comments = more good
|
// more comments = more good
|
||||||
arr := [
|
arr := [
|
||||||
/* block foo bar */
|
// block foo bar
|
||||||
// inline foo bar
|
// inline foo bar
|
||||||
0,
|
0,
|
||||||
]
|
]
|
||||||
println( /* before arg comment */ 'this is a test' /* after arg comment */ )
|
|
||||||
if /* before if expr */ true /* after if expr */ {
|
|
||||||
println('if')
|
|
||||||
}
|
|
||||||
// before else if
|
|
||||||
else if /* between else if */ false {
|
|
||||||
println('else if')
|
|
||||||
}
|
|
||||||
// before else
|
|
||||||
else {
|
|
||||||
println('else')
|
|
||||||
}
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -96,32 +84,12 @@ for // comments
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|
||||||
for /* comments */ {
|
|
||||||
break
|
|
||||||
}
|
|
||||||
|
|
||||||
for i := 0; i < 1; i++ // comments
|
for i := 0; i < 1; i++ // comments
|
||||||
{
|
{
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|
||||||
for i := 0; i < 1; i++ /* comments */ {
|
|
||||||
break
|
|
||||||
}
|
|
||||||
|
|
||||||
for /* comments1 */ i := 0; /* comments2 */ i < 1; /* comments3 */ i++ /* comments4 */ {
|
|
||||||
break
|
|
||||||
}
|
|
||||||
|
|
||||||
for _ in [1, 2] /* comments */ {
|
|
||||||
break
|
|
||||||
}
|
|
||||||
|
|
||||||
for _ in [1, 2] // comments
|
for _ in [1, 2] // comments
|
||||||
{
|
{
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|
||||||
for /* comments1 */ _ in /* comments2 */ [1, 2] /* comments3 */ {
|
|
||||||
break
|
|
||||||
}
|
|
||||||
|
|
|
@ -5,23 +5,24 @@ comment
|
||||||
*/
|
*/
|
||||||
|
|
||||||
fn fun() int {
|
fn fun() int {
|
||||||
return /* comment zero */ 0 // another comment
|
return 0 // another comment
|
||||||
}
|
}
|
||||||
|
|
||||||
fn mr_fun() (int, int) {
|
fn mr_fun() (int, int) {
|
||||||
return /* one comment */ 1, /* another comment */ 2
|
return 1, // one comment
|
||||||
|
2 // another comment
|
||||||
}
|
}
|
||||||
|
|
||||||
fn single_line_blocks() {
|
fn single_line_blocks() {
|
||||||
/* 1 */
|
// 1
|
||||||
println('')
|
println('')
|
||||||
/* 2 */
|
// 2
|
||||||
println('')
|
println('')
|
||||||
/* 3 */
|
// 3
|
||||||
/* 4 */
|
// 4
|
||||||
println('')
|
println('')
|
||||||
// 5
|
// 5
|
||||||
/* 6 */
|
// 6
|
||||||
}
|
}
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
|
@ -34,28 +35,15 @@ fn main() {
|
||||||
block3
|
block3
|
||||||
|
|
||||||
*/
|
*/
|
||||||
a := /* this is a comment */ 1
|
a := 1 // this is a comment
|
||||||
b, c := /* and another comment */ a, /* just to make it worse */ 2
|
|
||||||
d := c // and an extra one
|
d := c // and an extra one
|
||||||
e := c
|
e := c
|
||||||
// more comments = more good
|
// more comments = more good
|
||||||
arr := [
|
arr := [
|
||||||
/* block foo bar */
|
// block foo bar
|
||||||
// inline foo bar
|
// inline foo bar
|
||||||
0,
|
0,
|
||||||
]
|
]
|
||||||
println(/* before arg comment */ 'this is a test' /* after arg comment */)
|
|
||||||
if /* before if expr */ true /* after if expr */ {
|
|
||||||
println('if')
|
|
||||||
}
|
|
||||||
// before else if
|
|
||||||
else /* between else if */ if false {
|
|
||||||
println('else if')
|
|
||||||
}
|
|
||||||
// before else
|
|
||||||
else /* after else */ {
|
|
||||||
println('else')
|
|
||||||
}
|
|
||||||
return // empty return
|
return // empty return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -93,32 +81,12 @@ for // comments
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|
||||||
for /* comments */ {
|
|
||||||
break
|
|
||||||
}
|
|
||||||
|
|
||||||
for i := 0; i < 1; i++ // comments
|
for i := 0; i < 1; i++ // comments
|
||||||
{
|
{
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|
||||||
for i := 0; i < 1; i++ /* comments */ {
|
|
||||||
break
|
|
||||||
}
|
|
||||||
|
|
||||||
for /* comments1 */ i := 0; /* comments2 */ i < 1; /* comments3 */ i++ /* comments4 */ {
|
|
||||||
break
|
|
||||||
}
|
|
||||||
|
|
||||||
for _ in [1, 2] /* comments */ {
|
|
||||||
break
|
|
||||||
}
|
|
||||||
|
|
||||||
for _ in [1, 2] // comments
|
for _ in [1, 2] // comments
|
||||||
{
|
{
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|
||||||
for /* comments1 */ _ in /* comments2 */ [1, 2] /* comments3 */ {
|
|
||||||
break
|
|
||||||
}
|
|
||||||
|
|
|
@ -1,2 +0,0 @@
|
||||||
if true /* comments */ {
|
|
||||||
}
|
|
|
@ -1,2 +0,0 @@
|
||||||
if true /* comments */ {
|
|
||||||
}
|
|
|
@ -9,7 +9,7 @@ const two = 2
|
||||||
move
|
move
|
||||||
*/
|
*/
|
||||||
|
|
||||||
const three = 3 /* rewrite and leave */
|
const three = 3 // rewrite and leave
|
||||||
|
|
||||||
// leave
|
// leave
|
||||||
const four = 4 // leave
|
const four = 4 // leave
|
||||||
|
|
|
@ -5,7 +5,7 @@ const one = 1 // leave
|
||||||
const two = 2 /* move
|
const two = 2 /* move
|
||||||
*/
|
*/
|
||||||
|
|
||||||
const three = 3 /* rewrite and leave */
|
const three = 3 // rewrite and leave
|
||||||
|
|
||||||
// leave
|
// leave
|
||||||
const four = 4 // leave
|
const four = 4 // leave
|
||||||
|
|
|
@ -1,12 +1,8 @@
|
||||||
fn C.Mix_LoadMUS1(file byteptr) voidptr // *Mix_Music
|
fn C.Mix_LoadMUS1(file byteptr) voidptr // *Mix_Music
|
||||||
|
|
||||||
fn C.Mix_LoadMUS2(file byteptr) voidptr /* *Mix_Music */
|
fn C.Mix_LoadMUS2(file byteptr) voidptr // *Mix_Music*
|
||||||
|
|
||||||
fn C.Mix_LoadMUS3(file byteptr) voidptr /* 1 */
|
fn C.Mix_LoadMUS3(file byteptr) voidptr // 1 2 3
|
||||||
|
|
||||||
/* 2 */
|
|
||||||
|
|
||||||
/* 3 */
|
|
||||||
|
|
||||||
// Loads music
|
// Loads music
|
||||||
fn C.Mix_LoadMUS4(file byteptr) voidptr
|
fn C.Mix_LoadMUS4(file byteptr) voidptr
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
fn C.Mix_LoadMUS1(file byteptr) voidptr // *Mix_Music
|
fn C.Mix_LoadMUS1(file byteptr) voidptr // *Mix_Music
|
||||||
|
|
||||||
fn C.Mix_LoadMUS2(file byteptr) voidptr /* *Mix_Music */
|
fn C.Mix_LoadMUS2(file byteptr) voidptr // *Mix_Music*
|
||||||
|
|
||||||
fn C.Mix_LoadMUS3(file byteptr) voidptr /* 1 */ /* 2 */ /* 3 */
|
fn C.Mix_LoadMUS3(file byteptr) voidptr // 1 2 3
|
||||||
|
|
||||||
// Loads music
|
// Loads music
|
||||||
fn C.Mix_LoadMUS4(file byteptr) voidptr /* Test
|
fn C.Mix_LoadMUS4(file byteptr) voidptr /* Test
|
||||||
|
|
|
@ -1,8 +0,0 @@
|
||||||
fn /* main */ main() {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
fn // hi
|
|
||||||
print_hi() {
|
|
||||||
println('hi')
|
|
||||||
}
|
|
|
@ -1,6 +0,0 @@
|
||||||
fn /*main*/main() {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
fn // hi
|
|
||||||
print_hi(){println('hi')}
|
|
|
@ -1,8 +0,0 @@
|
||||||
fn foo(
|
|
||||||
// Foo
|
|
||||||
s string) {
|
|
||||||
}
|
|
||||||
|
|
||||||
fn bar( /* p1 */ a string, /* p2 */ b int) {
|
|
||||||
println('hello')
|
|
||||||
}
|
|
|
@ -1,8 +0,0 @@
|
||||||
fn foo(
|
|
||||||
// Foo
|
|
||||||
s string) {
|
|
||||||
}
|
|
||||||
|
|
||||||
fn bar(/*p1*/a string, /*p2*/b int) {
|
|
||||||
println('hello')
|
|
||||||
}
|
|
|
@ -1,5 +1,6 @@
|
||||||
fn main() {
|
fn main() {
|
||||||
filtered_links := text_processing.filter_links(links, /* unwanted_domains = */ [
|
filtered_links := text_processing.filter_links(links, // unwanted_domains
|
||||||
|
[
|
||||||
'www.kickstarter.com',
|
'www.kickstarter.com',
|
||||||
'www.pepper.pl',
|
'www.pepper.pl',
|
||||||
'tenor.com',
|
'tenor.com',
|
||||||
|
|
|
@ -1,12 +0,0 @@
|
||||||
fn main() {
|
|
||||||
a, b := true, true
|
|
||||||
|
|
||||||
if a || b // a
|
|
||||||
{
|
|
||||||
println('hi')
|
|
||||||
}
|
|
||||||
|
|
||||||
if a || b /* a */ {
|
|
||||||
println('hi')
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,10 +0,0 @@
|
||||||
fn main() {
|
|
||||||
a, b := true, true
|
|
||||||
|
|
||||||
if a || // a
|
|
||||||
b {
|
|
||||||
println('hi')
|
|
||||||
}
|
|
||||||
|
|
||||||
if a /* a */ || b {println('hi')}
|
|
||||||
}
|
|
|
@ -1,9 +1,9 @@
|
||||||
fn main() {
|
fn main() {
|
||||||
a := 4 // comment1
|
a := 4 // comment1
|
||||||
+ /* comment2 */ 6
|
+ 6 // comment2
|
||||||
|
|
||||||
b := 5 /* comment1 */ + // comment2
|
b := 5 + // comment2
|
||||||
6
|
6
|
||||||
|
|
||||||
c := 4 /* comment1 */ + /* comment2 */ 6 // comment3
|
c := 4 + 6 // comment3
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,22 +0,0 @@
|
||||||
fn foo1() int {
|
|
||||||
return (0 /* some comment */ )
|
|
||||||
}
|
|
||||||
|
|
||||||
fn foo2() int {
|
|
||||||
return ( /* some comment */ 0)
|
|
||||||
}
|
|
||||||
|
|
||||||
fn foo3() int {
|
|
||||||
return ( /* some comment1 */ 0 /* some comment2 */ )
|
|
||||||
}
|
|
||||||
|
|
||||||
fn foo4() int {
|
|
||||||
return ( /* some comment1 */ /* some comment2 */ 0)
|
|
||||||
}
|
|
||||||
|
|
||||||
fn foo5() int {
|
|
||||||
return ( /* some comment1 */ /* some comment2 */ 0 /* some comment3 */ /* some comment4 */ )
|
|
||||||
}
|
|
||||||
|
|
||||||
fn main() {
|
|
||||||
}
|
|
|
@ -41,11 +41,11 @@ struct SomeStruct {
|
||||||
mut:
|
mut:
|
||||||
// 2
|
// 2
|
||||||
// 3
|
// 3
|
||||||
somefield /* 4 */ /* 5 */ int /* 6 */ /* 7 */ /* 8 */ /*
|
somefield int /*
|
||||||
9
|
9
|
||||||
10
|
10
|
||||||
*/
|
*/
|
||||||
somefield2 /* 11 */ int // 12
|
somefield2 int // 12
|
||||||
pub:
|
pub:
|
||||||
somefield3 int
|
somefield3 int
|
||||||
|
|
||||||
|
|
|
@ -41,11 +41,11 @@ struct SomeStruct {
|
||||||
mut:
|
mut:
|
||||||
// 2
|
// 2
|
||||||
// 3
|
// 3
|
||||||
somefield /*4*/ /*5*/ int /*6*/ /*7*/ /*8*/ /*
|
somefield int /*
|
||||||
9
|
9
|
||||||
10
|
10
|
||||||
*/
|
*/
|
||||||
somefield2 /*11*/ int // 12
|
somefield2 int // 12
|
||||||
pub:
|
pub:
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -23,8 +23,8 @@ fn test_decode_a() {
|
||||||
TestData{'D', -1},
|
TestData{'D', -1},
|
||||||
TestData{'2H', 123},
|
TestData{'2H', 123},
|
||||||
TestData{'qxmvrH', 123456789},
|
TestData{'qxmvrH', 123456789},
|
||||||
TestData{'+/////B', 1073741823} /* 2^30-1 */,
|
TestData{'+/////B', 1073741823}, // 2^30-1
|
||||||
// TestData{'hgggggggggggI', 9_223_372_036_854_775_808} /* 2^63 */,
|
// TestData{'hgggggggggggI', 9_223_372_036_854_775_808} // 2^63
|
||||||
]
|
]
|
||||||
|
|
||||||
for _, test_data in decode_values {
|
for _, test_data in decode_values {
|
||||||
|
|
|
@ -17,8 +17,8 @@ fn test_encode_a() {
|
||||||
TestData{'D', -1},
|
TestData{'D', -1},
|
||||||
TestData{'2H', 123},
|
TestData{'2H', 123},
|
||||||
TestData{'qxmvrH', 123456789},
|
TestData{'qxmvrH', 123456789},
|
||||||
TestData{'+/////B', 1073741823} /* 2^30-1 */,
|
TestData{'+/////B', 1073741823}, // 2^30-1
|
||||||
// TestData{'hgggggggggggI', 9_223_372_036_854_775_808} /* 2^63 */,
|
// TestData{'hgggggggggggI', 9_223_372_036_854_775_808} // 2^63
|
||||||
]
|
]
|
||||||
for _, test_data in decode_values {
|
for _, test_data in decode_values {
|
||||||
mut output := TestWriter{}
|
mut output := TestWriter{}
|
||||||
|
|
|
@ -26,8 +26,8 @@ pub fn mark_used(mut table ast.Table, pref_ &pref.Preferences, ast_files []&ast.
|
||||||
'__new_array_with_default',
|
'__new_array_with_default',
|
||||||
'__new_array_with_multi_default',
|
'__new_array_with_multi_default',
|
||||||
'__new_array_with_array_default',
|
'__new_array_with_array_default',
|
||||||
'init_global_allocator' /* needed for linux_bare and wasm_bare */,
|
'init_global_allocator', // needed for linux_bare and wasm_bare
|
||||||
'v_realloc' /* needed for _STR */,
|
'v_realloc', // needed for _STR
|
||||||
'malloc',
|
'malloc',
|
||||||
'malloc_noscan',
|
'malloc_noscan',
|
||||||
'vcalloc',
|
'vcalloc',
|
||||||
|
@ -89,12 +89,12 @@ pub fn mark_used(mut table ast.Table, pref_ &pref.Preferences, ast_files []&ast.
|
||||||
'22.set',
|
'22.set',
|
||||||
'22.get_unsafe',
|
'22.get_unsafe',
|
||||||
'22.set_unsafe',
|
'22.set_unsafe',
|
||||||
'22.get_with_check' /* used for `x := a[i] or {}` */,
|
'22.get_with_check', // used for `x := a[i] or {}`
|
||||||
'22.clone_static_to_depth',
|
'22.clone_static_to_depth',
|
||||||
'22.clone_to_depth',
|
'22.clone_to_depth',
|
||||||
'22.first',
|
'22.first',
|
||||||
'22.last',
|
'22.last',
|
||||||
'22.pointers' /* TODO: handle generic methods calling array primitives more precisely in pool_test.v */,
|
'22.pointers', // TODO: handle generic methods calling array primitives more precisely in pool_test.v
|
||||||
'22.reverse',
|
'22.reverse',
|
||||||
'22.repeat_to_depth',
|
'22.repeat_to_depth',
|
||||||
'22.slice',
|
'22.slice',
|
||||||
|
|
|
@ -1111,9 +1111,17 @@ fn (mut s Scanner) text_scan() token.Token {
|
||||||
}
|
}
|
||||||
s.pos++
|
s.pos++
|
||||||
if s.should_parse_comment() {
|
if s.should_parse_comment() {
|
||||||
mut comment := s.text[start..(s.pos - 1)].trim(' ')
|
mut comment := s.text[start..(s.pos - 1)]
|
||||||
if !comment.contains('\n') {
|
if !comment.contains('\n') {
|
||||||
comment = '\x01' + comment
|
comment_pos := token.Pos{
|
||||||
|
line_nr: start_line
|
||||||
|
len: comment.len + 4
|
||||||
|
pos: start
|
||||||
|
col: s.current_column() - comment.len - 4
|
||||||
|
}
|
||||||
|
s.error_with_pos('inline comment is deprecated, please use line comment',
|
||||||
|
comment_pos)
|
||||||
|
comment = '\x01' + comment.trim(' ')
|
||||||
}
|
}
|
||||||
return s.new_multiline_token(.comment, comment, comment.len + 4,
|
return s.new_multiline_token(.comment, comment, comment.len + 4,
|
||||||
start_line)
|
start_line)
|
||||||
|
|
|
@ -1161,21 +1161,21 @@ fn tst() {
|
||||||
mut tf := TTF_File{}
|
mut tf := TTF_File{}
|
||||||
|
|
||||||
tf.buf = [
|
tf.buf = [
|
||||||
u8(0xFF), /* 8 bit */
|
u8(0xFF), // 8 bit
|
||||||
0xF1,
|
0xF1,
|
||||||
0xF2, /* 16 bit */
|
0xF2, // 16 bit
|
||||||
0x81,
|
0x81,
|
||||||
0x23,
|
0x23,
|
||||||
0x45,
|
0x45,
|
||||||
0x67, /* 32 bit */
|
0x67, // 32 bit
|
||||||
0x12,
|
0x12,
|
||||||
0x34,
|
0x34,
|
||||||
0x12,
|
0x12,
|
||||||
0x34, /* get_2dot14 16 bit */
|
0x34, // get_2dot14 16 bit
|
||||||
0x12,
|
0x12,
|
||||||
0x34,
|
0x34,
|
||||||
0x12,
|
0x12,
|
||||||
0x34 /* get_fixed 32 bit int */,
|
0x34, // get_fixed 32 bit int
|
||||||
]
|
]
|
||||||
assert tf.get_u8().hex() == 'ff'
|
assert tf.get_u8().hex() == 'ff'
|
||||||
assert tf.get_u16().hex() == 'f1f2'
|
assert tf.get_u16().hex() == 'f1f2'
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue