mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
checker: require unsafe for Struct(voidptr) casts
This commit is contained in:
@@ -25,9 +25,7 @@ mut:
|
||||
cut_rate f64 = 5
|
||||
}
|
||||
|
||||
fn frame(x voidptr) {
|
||||
mut app := &App(x)
|
||||
|
||||
fn frame(mut app App) {
|
||||
app.tui.clear()
|
||||
|
||||
if app.points.len > 0 {
|
||||
@@ -55,9 +53,7 @@ fn frame(x voidptr) {
|
||||
app.tui.flush()
|
||||
}
|
||||
|
||||
fn event(e &tui.Event, x voidptr) {
|
||||
mut app := &App(x)
|
||||
|
||||
fn event(e &tui.Event, mut app App) {
|
||||
match e.typ {
|
||||
.key_down {
|
||||
match e.code {
|
||||
|
||||
@@ -5,8 +5,7 @@ mut:
|
||||
tui &tui.Context = unsafe { nil }
|
||||
}
|
||||
|
||||
fn event(e &tui.Event, x voidptr) {
|
||||
mut app := &App(x)
|
||||
fn event(e &tui.Event, mut app App) {
|
||||
app.tui.clear()
|
||||
app.tui.set_cursor_position(0, 0)
|
||||
app.tui.write('V term.input event viewer (press `esc` to exit)\n\n')
|
||||
|
||||
@@ -458,18 +458,15 @@ fn (mut g Game) free() {
|
||||
}
|
||||
|
||||
// TODO Remove these wrapper functions when we can assign methods as callbacks
|
||||
fn init(x voidptr) {
|
||||
mut app := &App(x)
|
||||
fn init(mut app App) {
|
||||
app.init()
|
||||
}
|
||||
|
||||
fn frame(x voidptr) {
|
||||
mut app := &App(x)
|
||||
fn frame(mut app App) {
|
||||
app.frame()
|
||||
}
|
||||
|
||||
fn cleanup(x voidptr) {
|
||||
mut app := &App(x)
|
||||
fn cleanup(mut app App) {
|
||||
unsafe {
|
||||
app.free()
|
||||
}
|
||||
@@ -479,8 +476,7 @@ fn fail(error string) {
|
||||
eprintln(error)
|
||||
}
|
||||
|
||||
fn event(e &ui.Event, x voidptr) {
|
||||
mut app := &App(x)
|
||||
fn event(e &ui.Event, mut app App) {
|
||||
app.event(e)
|
||||
}
|
||||
|
||||
|
||||
@@ -27,8 +27,7 @@ fn random_color() tui.Color {
|
||||
}
|
||||
}
|
||||
|
||||
fn event(e &tui.Event, x voidptr) {
|
||||
mut app := &App(x)
|
||||
fn event(e &tui.Event, mut app App) {
|
||||
match e.typ {
|
||||
.mouse_down {
|
||||
app.is_drag = true
|
||||
@@ -60,8 +59,7 @@ fn event(e &tui.Event, x voidptr) {
|
||||
app.redraw = true
|
||||
}
|
||||
|
||||
fn frame(x voidptr) {
|
||||
mut app := &App(x)
|
||||
fn frame(mut app App) {
|
||||
if !app.redraw {
|
||||
return
|
||||
}
|
||||
|
||||
@@ -128,8 +128,7 @@ fn main() {
|
||||
app.ui.run()?
|
||||
}
|
||||
|
||||
fn frame(x voidptr) {
|
||||
mut app := &App(x)
|
||||
fn frame(mut app App) {
|
||||
mut redraw := app.should_redraw
|
||||
if app.msg != '' && app.ui.frame_count >= app.msg_hide_tick {
|
||||
app.msg = ''
|
||||
@@ -141,8 +140,7 @@ fn frame(x voidptr) {
|
||||
}
|
||||
}
|
||||
|
||||
fn event(event &ui.Event, x voidptr) {
|
||||
mut app := &App(x)
|
||||
fn event(event &ui.Event, mut app App) {
|
||||
match event.typ {
|
||||
.mouse_down {
|
||||
app.is_dragging = true
|
||||
|
||||
@@ -473,9 +473,8 @@ fn (c Cursor) xy() (int, int) {
|
||||
}
|
||||
|
||||
// App callbacks
|
||||
fn init(x voidptr) {
|
||||
mut a := &App(x)
|
||||
a.init_file()
|
||||
fn init(mut app App) {
|
||||
app.init_file()
|
||||
}
|
||||
|
||||
fn (mut a App) init_file() {
|
||||
@@ -523,8 +522,7 @@ fn (mut a App) magnet_cursor_x() {
|
||||
}
|
||||
}
|
||||
|
||||
fn frame(x voidptr) {
|
||||
mut a := &App(x)
|
||||
fn frame(mut a App) {
|
||||
mut ed := a.ed
|
||||
a.tui.clear()
|
||||
scroll_limit := a.view_height()
|
||||
@@ -551,8 +549,7 @@ fn frame(x voidptr) {
|
||||
a.tui.flush()
|
||||
}
|
||||
|
||||
fn event(e &tui.Event, x voidptr) {
|
||||
mut a := &App(x)
|
||||
fn event(e &tui.Event, mut a App) {
|
||||
mut buffer := a.ed
|
||||
if e.typ == .key_down {
|
||||
match e.code {
|
||||
|
||||
@@ -286,8 +286,7 @@ fn (mut a App) new_game() {
|
||||
}
|
||||
|
||||
// initialize the app and record the width and height of the window
|
||||
fn init(x voidptr) {
|
||||
mut app := &App(x)
|
||||
fn init(mut app App) {
|
||||
w, h := app.termui.window_width, app.termui.window_height
|
||||
app.width = w
|
||||
app.height = h
|
||||
@@ -295,8 +294,7 @@ fn init(x voidptr) {
|
||||
}
|
||||
|
||||
// event handles different events for the app as they occur
|
||||
fn event(e &termui.Event, x voidptr) {
|
||||
mut app := &App(x)
|
||||
fn event(e &termui.Event, mut app App) {
|
||||
match e.typ {
|
||||
.mouse_down {}
|
||||
.mouse_drag {}
|
||||
@@ -324,8 +322,7 @@ fn event(e &termui.Event, x voidptr) {
|
||||
}
|
||||
|
||||
// frame perform actions on every tick
|
||||
fn frame(x voidptr) {
|
||||
mut app := &App(x)
|
||||
fn frame(mut app App) {
|
||||
app.update()
|
||||
app.draw()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user