mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
vfmt: voidptr(0) => unsafe { nil } (p.1)
This commit is contained in:
@@ -61,26 +61,26 @@ pub:
|
||||
borderless_window bool
|
||||
always_on_top bool
|
||||
bg_color gx.Color
|
||||
init_fn FNCb = voidptr(0)
|
||||
frame_fn FNCb = voidptr(0)
|
||||
native_frame_fn FNCb = voidptr(0)
|
||||
cleanup_fn FNCb = voidptr(0)
|
||||
fail_fn FNFail = voidptr(0)
|
||||
init_fn FNCb = unsafe { nil }
|
||||
frame_fn FNCb = unsafe { nil }
|
||||
native_frame_fn FNCb = unsafe { nil }
|
||||
cleanup_fn FNCb = unsafe { nil }
|
||||
fail_fn FNFail = unsafe { nil }
|
||||
//
|
||||
event_fn FNEvent = voidptr(0)
|
||||
quit_fn FNEvent = voidptr(0)
|
||||
event_fn FNEvent = unsafe { nil }
|
||||
quit_fn FNEvent = unsafe { nil }
|
||||
//
|
||||
keydown_fn FNKeyDown = voidptr(0)
|
||||
keyup_fn FNKeyUp = voidptr(0)
|
||||
char_fn FNChar = voidptr(0)
|
||||
keydown_fn FNKeyDown = unsafe { nil }
|
||||
keyup_fn FNKeyUp = unsafe { nil }
|
||||
char_fn FNChar = unsafe { nil }
|
||||
//
|
||||
move_fn FNMove = voidptr(0)
|
||||
click_fn FNClick = voidptr(0)
|
||||
unclick_fn FNUnClick = voidptr(0)
|
||||
leave_fn FNEvent = voidptr(0)
|
||||
enter_fn FNEvent = voidptr(0)
|
||||
resized_fn FNEvent = voidptr(0)
|
||||
scroll_fn FNEvent = voidptr(0)
|
||||
move_fn FNMove = unsafe { nil }
|
||||
click_fn FNClick = unsafe { nil }
|
||||
unclick_fn FNUnClick = unsafe { nil }
|
||||
leave_fn FNEvent = unsafe { nil }
|
||||
enter_fn FNEvent = unsafe { nil }
|
||||
resized_fn FNEvent = unsafe { nil }
|
||||
scroll_fn FNEvent = unsafe { nil }
|
||||
// wait_events bool // set this to true for UIs, to save power
|
||||
fullscreen bool
|
||||
scale f32 = 1.0
|
||||
@@ -222,7 +222,7 @@ fn gg_init_sokol_window(user_data voidptr) {
|
||||
|
||||
ctx.timage_pip = sgl.make_pipeline(&pipdesc)
|
||||
//
|
||||
if ctx.config.init_fn != voidptr(0) {
|
||||
if ctx.config.init_fn != unsafe { nil } {
|
||||
$if android {
|
||||
// NOTE on Android sokol can emit resize events *before* the init function is
|
||||
// called (Android has to initialize a lot more through the Activity system to
|
||||
@@ -233,7 +233,7 @@ fn gg_init_sokol_window(user_data voidptr) {
|
||||
if ctx.width != win_size.width || ctx.height != win_size.height {
|
||||
ctx.width = win_size.width
|
||||
ctx.height = win_size.height
|
||||
if ctx.config.resized_fn != voidptr(0) {
|
||||
if ctx.config.resized_fn != unsafe { nil } {
|
||||
e := Event{
|
||||
typ: .resized
|
||||
window_width: ctx.width
|
||||
@@ -260,7 +260,7 @@ fn gg_init_sokol_window(user_data voidptr) {
|
||||
fn gg_frame_fn(user_data voidptr) {
|
||||
mut ctx := unsafe { &Context(user_data) }
|
||||
ctx.frame++
|
||||
if ctx.config.frame_fn == voidptr(0) {
|
||||
if ctx.config.frame_fn == unsafe { nil } {
|
||||
return
|
||||
}
|
||||
if ctx.native_rendering {
|
||||
@@ -323,64 +323,64 @@ fn gg_event_fn(ce voidptr, user_data voidptr) {
|
||||
ctx.pressed_keys[key_idx] = next
|
||||
ctx.pressed_keys_edge[key_idx] = prev != next
|
||||
}
|
||||
if ctx.config.event_fn != voidptr(0) {
|
||||
if ctx.config.event_fn != unsafe { nil } {
|
||||
ctx.config.event_fn(e, ctx.config.user_data)
|
||||
}
|
||||
match e.typ {
|
||||
.mouse_move {
|
||||
if ctx.config.move_fn != voidptr(0) {
|
||||
if ctx.config.move_fn != unsafe { nil } {
|
||||
ctx.config.move_fn(e.mouse_x / ctx.scale, e.mouse_y / ctx.scale, ctx.config.user_data)
|
||||
}
|
||||
}
|
||||
.mouse_down {
|
||||
if ctx.config.click_fn != voidptr(0) {
|
||||
if ctx.config.click_fn != unsafe { nil } {
|
||||
ctx.config.click_fn(e.mouse_x / ctx.scale, e.mouse_y / ctx.scale, e.mouse_button,
|
||||
ctx.config.user_data)
|
||||
}
|
||||
}
|
||||
.mouse_up {
|
||||
if ctx.config.unclick_fn != voidptr(0) {
|
||||
if ctx.config.unclick_fn != unsafe { nil } {
|
||||
ctx.config.unclick_fn(e.mouse_x / ctx.scale, e.mouse_y / ctx.scale, e.mouse_button,
|
||||
ctx.config.user_data)
|
||||
}
|
||||
}
|
||||
.mouse_leave {
|
||||
if ctx.config.leave_fn != voidptr(0) {
|
||||
if ctx.config.leave_fn != unsafe { nil } {
|
||||
ctx.config.leave_fn(e, ctx.config.user_data)
|
||||
}
|
||||
}
|
||||
.mouse_enter {
|
||||
if ctx.config.enter_fn != voidptr(0) {
|
||||
if ctx.config.enter_fn != unsafe { nil } {
|
||||
ctx.config.enter_fn(e, ctx.config.user_data)
|
||||
}
|
||||
}
|
||||
.mouse_scroll {
|
||||
if ctx.config.scroll_fn != voidptr(0) {
|
||||
if ctx.config.scroll_fn != unsafe { nil } {
|
||||
ctx.config.scroll_fn(e, ctx.config.user_data)
|
||||
}
|
||||
}
|
||||
.key_down {
|
||||
if ctx.config.keydown_fn != voidptr(0) {
|
||||
if ctx.config.keydown_fn != unsafe { nil } {
|
||||
ctx.config.keydown_fn(e.key_code, Modifier(e.modifiers), ctx.config.user_data)
|
||||
}
|
||||
}
|
||||
.key_up {
|
||||
if ctx.config.keyup_fn != voidptr(0) {
|
||||
if ctx.config.keyup_fn != unsafe { nil } {
|
||||
ctx.config.keyup_fn(e.key_code, Modifier(e.modifiers), ctx.config.user_data)
|
||||
}
|
||||
}
|
||||
.char {
|
||||
if ctx.config.char_fn != voidptr(0) {
|
||||
if ctx.config.char_fn != unsafe { nil } {
|
||||
ctx.config.char_fn(e.char_code, ctx.config.user_data)
|
||||
}
|
||||
}
|
||||
.resized {
|
||||
if ctx.config.resized_fn != voidptr(0) {
|
||||
if ctx.config.resized_fn != unsafe { nil } {
|
||||
ctx.config.resized_fn(e, ctx.config.user_data)
|
||||
}
|
||||
}
|
||||
.quit_requested {
|
||||
if ctx.config.quit_fn != voidptr(0) {
|
||||
if ctx.config.quit_fn != unsafe { nil } {
|
||||
ctx.config.quit_fn(e, ctx.config.user_data)
|
||||
}
|
||||
}
|
||||
@@ -392,7 +392,7 @@ fn gg_event_fn(ce voidptr, user_data voidptr) {
|
||||
|
||||
fn gg_cleanup_fn(user_data voidptr) {
|
||||
mut ctx := unsafe { &Context(user_data) }
|
||||
if ctx.config.cleanup_fn != voidptr(0) {
|
||||
if ctx.config.cleanup_fn != unsafe { nil } {
|
||||
ctx.config.cleanup_fn(ctx.config.user_data)
|
||||
}
|
||||
gfx.shutdown()
|
||||
@@ -401,7 +401,7 @@ fn gg_cleanup_fn(user_data voidptr) {
|
||||
fn gg_fail_fn(msg &char, user_data voidptr) {
|
||||
mut ctx := unsafe { &Context(user_data) }
|
||||
vmsg := unsafe { tos3(msg) }
|
||||
if ctx.config.fail_fn != voidptr(0) {
|
||||
if ctx.config.fail_fn != unsafe { nil } {
|
||||
ctx.config.fail_fn(vmsg, ctx.config.user_data)
|
||||
} else {
|
||||
eprintln('gg error: $vmsg')
|
||||
|
||||
Reference in New Issue
Block a user