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

gg: make create_image's receiver immutable

This commit is contained in:
Alexander Medvednikov 2022-11-14 17:25:39 +03:00
parent f44af02e32
commit 37583b04b4
3 changed files with 14 additions and 9 deletions

View File

@ -295,8 +295,7 @@ fn gg_init_sokol_window(user_data voidptr) {
}
}
fn gg_frame_fn(user_data voidptr) {
mut ctx := unsafe { &Context(user_data) }
fn gg_frame_fn(mut ctx Context) {
ctx.frame++
if ctx.config.frame_fn == unsafe { nil } {
return

View File

@ -25,8 +25,8 @@ pub mut:
}
// create_image creates an `Image` from `file`.
// TODO return ?Image
pub fn (mut ctx Context) create_image(file string) Image {
// TODO return !Image
pub fn (ctx &Context) create_image(file string) Image {
// println('\ncreate_image("$file")')
if !os.exists(file) {
return Image{}
@ -38,7 +38,9 @@ pub fn (mut ctx Context) create_image(file string) Image {
// println('created macos image: $img.path w=$img.width')
// C.printf('p = %p\n', img.data)
img.id = ctx.image_cache.len
ctx.image_cache << img
unsafe {
ctx.image_cache << img
}
return img
}
}
@ -56,12 +58,16 @@ pub fn (mut ctx Context) create_image(file string) Image {
path: file
id: ctx.image_cache.len
}
ctx.image_cache << img
unsafe {
ctx.image_cache << img
}
return img
}
mut img := create_image(file)
img.id = ctx.image_cache.len
ctx.image_cache << img
unsafe {
ctx.image_cache << img
}
return img
}

View File

@ -31,8 +31,8 @@ struct C.PGResult {
pub struct Config {
pub:
host string
port int = 5432
host string = 'localhost'
port int = 5432
user string
password string
dbname string