Skip to content

Commit efc8f7f

Browse files
committed
examples: fix most notices for ./v -check-unused-fn-args -N build-examples (remaining ones are triggered for vlib/x/json2/decode.v)
1 parent c116999 commit efc8f7f

31 files changed

Lines changed: 56 additions & 77 deletions

File tree

examples/animated_help_text.v

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ mut:
2121
direction int = 1
2222
}
2323

24-
fn event(e &tui.Event, mut app App) {
24+
fn event(e &tui.Event, mut _app App) {
2525
match e.typ {
2626
.mouse_down {}
2727
.mouse_drag {}

examples/archive/tar_gz_reader.v

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,17 +65,17 @@ fn new_downloader(url string) !&Downloader {
6565
return downloader
6666
}
6767

68-
fn (mut d Downloader) on_start(mut request http.Request, path string) ! {}
68+
fn (mut d Downloader) on_start(mut _request http.Request, _path string) ! {}
6969

70-
fn (mut d Downloader) on_chunk(request &http.Request, chunk []u8, already_received u64, expected u64) ! {
70+
fn (mut d Downloader) on_chunk(_request &http.Request, chunk []u8, _already_received u64, expected u64) ! {
7171
if expected == 0 {
7272
return
7373
}
7474
d.chunks++
7575
d.data << chunk
7676
}
7777

78-
fn (mut d Downloader) on_finish(request &http.Request, response &http.Response) ! {}
78+
fn (mut d Downloader) on_finish(_request &http.Request, _response &http.Response) ! {}
7979

8080
struct FileReader implements tar.Reader {
8181
ctx &Context

examples/cli.v

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,10 +71,10 @@ fn greet_func(cmd Command) ! {
7171
}
7272
}
7373

74-
fn greet_pre_func(cmd Command) ! {
74+
fn greet_pre_func(_cmd Command) ! {
7575
println('This is a function running before the main function.\n')
7676
}
7777

78-
fn greet_post_func(cmd Command) ! {
78+
fn greet_post_func(_cmd Command) ! {
7979
println('\nThis is a function running after the main function.')
8080
}

examples/eventbus/eventbus.v

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,15 @@ fn main() {
1919
println('Receiver ok: ' + r.ok.str())
2020
}
2121

22-
fn on_foo(mut receiver Receiver, e &some_module.EventMetadata, sender voidptr) {
22+
fn on_foo(mut receiver Receiver, e &some_module.EventMetadata, _sender voidptr) {
2323
receiver.ok = true
2424
println('on_foo :: ' + e.message)
2525
}
2626

27-
fn on_bar(receiver voidptr, e &some_module.EventMetadata, sender voidptr) {
27+
fn on_bar(_receiver voidptr, e &some_module.EventMetadata, _sender voidptr) {
2828
println('on_bar :: ' + e.message)
2929
}
3030

31-
fn on_baz(receiver voidptr, event voidptr, d &some_module.Duration) {
31+
fn on_baz(_receiver voidptr, _event voidptr, d &some_module.Duration) {
3232
println('on_baz :: ' + d.hours.str())
3333
}

examples/gg/cursor.v

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ fn main() {
1313
ctx.run()
1414
}
1515

16-
fn init(mut ctx gg.Context) {
16+
fn init(mut _ctx gg.Context) {
1717
sapp.set_mouse_cursor(.ibeam)
1818
}
1919

examples/gg/easing_animation.v

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ fn (mut app App) change_functions(direction int) {
8686
app.kind = all_keys[idx]
8787
}
8888

89-
fn (mut app App) on_event(ev &gg.Event, x voidptr) {
89+
fn (mut app App) on_event(ev &gg.Event, _x voidptr) {
9090
if ev.typ != .key_down {
9191
return
9292
}

examples/gg/mandelbrot.v

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ fn (mut state AppState) update() {
9191
}
9292

9393
@[direct_array_access]
94-
fn (mut state AppState) worker(id int, input chan MandelChunk, ready chan bool) {
94+
fn (mut state AppState) worker(_id int, input chan MandelChunk, ready chan bool) {
9595
for {
9696
chunk := <-input or { break }
9797
yscale := chunk.cview.height() / pheight
@@ -168,7 +168,7 @@ fn graphics_click(x f32, y f32, btn gg.MouseButton, mut state AppState) {
168168
}
169169
}
170170

171-
fn graphics_move(x f32, y f32, mut state AppState) {
171+
fn graphics_move(_x f32, _y f32, mut state AppState) {
172172
if state.gg.mouse_buttons.has(.left) {
173173
size := gg.window_size()
174174
d_x := (f64(state.gg.mouse_dx) / size.width) * state.view.width()
@@ -184,7 +184,7 @@ fn graphics_scroll(e &gg.Event, mut state AppState) {
184184
state.zoom(if e.scroll_y < 0 { zoom_factor } else { 1 / zoom_factor })
185185
}
186186

187-
fn graphics_keydown(code gg.KeyCode, mod gg.Modifier, mut state AppState) {
187+
fn graphics_keydown(code gg.KeyCode, _mod gg.Modifier, mut state AppState) {
188188
s_x := state.view.width() / 5
189189
s_y := state.view.height() / 5
190190
// movement

examples/gg/memory.v

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ fn (mut g Game) restart() {
3939
g.card2_idx = none
4040
}
4141

42-
fn (mut g Game) draw_cell(i int, cell Cell) {
42+
fn (mut g Game) draw_cell(i int) {
4343
x, y := i % g.size, i / g.size
4444
rect_x, rect_y := x * csize, header_size + y * csize
4545
if g.cells[i].is_open || g.sw.elapsed().milliseconds() <= 1000 {
@@ -57,8 +57,8 @@ fn on_frame(mut g Game) {
5757
g.ctx.begin()
5858
message := '(r)estart (esc)ape | remaining: ${g.remaining:02} | time: ${f64(g.sw.elapsed().milliseconds()) / 1000.0:06.1f}s'
5959
g.ctx.draw_text(ws.width / 2, 7, message, color: gg.light_gray, size: 22, align: .center)
60-
for i, cell in g.cells {
61-
g.draw_cell(i, cell)
60+
for i in 0 .. g.cells.len {
61+
g.draw_cell(i)
6262
}
6363
if g.revert_sw.elapsed().milliseconds() > 750 {
6464
g.revert_sw = time.new_stopwatch(auto_start: false)

examples/gg/path_finding_algorithm_visualizer/aStar.v

Lines changed: 8 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -80,10 +80,9 @@ fn main() {
8080
height: window_height // window height
8181
create_window: true // this will create a different window
8282
window_title: 'A* Path finding algorithm visusalizer' // title of the window
83-
frame_fn: frame // this is frame function update the frame
84-
event_fn: on_event // it calls on every event
85-
init_fn: init_images // run at start of application
86-
user_data: app // store user data
83+
frame_fn: frame // this is frame function update the frame
84+
event_fn: on_event // it calls on every event
85+
user_data: app // store user data
8786
)
8887
mut grid := initialise_grid() // initialize the grid variable and populate the matrix with each cell as empty
8988
app.grid = grid // set grid to app attribute so you can access it by just passing app variable or with method of app
@@ -102,17 +101,11 @@ fn main() {
102101
// this function will run for every frame actually in a loop
103102
fn frame(mut app App) {
104103
app.gg.begin()
105-
draw_grid(mut app, mut app.grid)
104+
draw_grid(mut app)
106105
draw_gridlines(mut app)
107106
app.gg.end()
108107
}
109108

110-
// this will run at start of app
111-
fn init_images(mut app App) {
112-
// app.resize()
113-
return
114-
}
115-
116109
// this will handle user event which is stored in gg.event variable
117110
fn on_event(event &gg.Event, mut app App) {
118111
match event.typ {
@@ -192,7 +185,7 @@ fn (mut app App) on_key_down(key gg.KeyCode) {
192185
app.gg.quit()
193186
}
194187
.c {
195-
draw_grid(mut app, mut app.grid)
188+
draw_grid(mut app)
196189
draw_gridlines(mut app)
197190
mut grid := initialise_grid()
198191
app.grid = grid // set grid to app attribute so you can access it by just passing app variable or with method of app
@@ -227,15 +220,6 @@ fn hf(p1 Point, p2 Point) int {
227220
return math.abs(p1.x - p2.x) + math.abs(p1.y - p2.y)
228221
}
229222

230-
// get the position of mouse in terms of which cells' row and column
231-
fn get_clicked_pos(pos Point, rows int, width int) (int, int) {
232-
x := pos.x
233-
y := pos.y
234-
row := y / rows
235-
col := x / rows
236-
return row, col
237-
}
238-
239223
// initialize grid attribute of app
240224
fn initialise_grid() [][]Cell {
241225
mut grid := [][]Cell{len: nrows, init: []Cell{len: nrows}}
@@ -259,7 +243,7 @@ fn initialise_grid() [][]Cell {
259243
}
260244

261245
// draw the cells of grid
262-
fn draw_grid(mut app App, mut grid [][]Cell) {
246+
fn draw_grid(mut app App) {
263247
for i := 0; i < nrows; i++ {
264248
for j := 0; j < nrows; j++ {
265249
pos := app.grid[i][j].pos
@@ -299,7 +283,7 @@ fn update_neighbors(mut grid [][]Cell, row int, col int) {
299283
}
300284

301285
// construct the path after finding it shows as pink color
302-
fn reconstruct_path(mut grid [][]Cell, mut came_from [][]Point, start Point, end Point) {
286+
fn reconstruct_path(mut grid [][]Cell, mut came_from [][]Point, _start Point, end Point) {
303287
mut x := end.x
304288
mut y := end.y
305289
for !(x == -1 && y == -1) {
@@ -310,7 +294,7 @@ fn reconstruct_path(mut grid [][]Cell, mut came_from [][]Point, start Point, end
310294
}
311295

312296
// a* path finding algorithm
313-
fn astar_path_finding(mut app App, mut grid [][]Cell, start Point, end Point) {
297+
fn astar_path_finding(mut _app App, mut grid [][]Cell, start Point, end Point) {
314298
mut priority_queue := &MinHeap{}
315299
mut g_score := [][]int{len: nrows, init: []int{len: nrows}}
316300
mut f_score := [][]int{len: nrows, init: []int{len: nrows}}

examples/hot_reload/tunnel.v

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ fn init_state() State {
6767
return state
6868
}
6969

70-
fn (mut state State) on_event(e &gg.Event, ctx voidptr) {
70+
fn (mut state State) on_event(e &gg.Event, _ctx voidptr) {
7171
if e.typ == .char {
7272
if e.char_code == `f` {
7373
gg.toggle_fullscreen()

0 commit comments

Comments
 (0)