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:
parent
f44af02e32
commit
37583b04b4
@ -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
|
||||
|
@ -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
|
||||
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
|
||||
}
|
||||
unsafe {
|
||||
ctx.image_cache << img
|
||||
}
|
||||
return img
|
||||
}
|
||||
mut img := create_image(file)
|
||||
img.id = ctx.image_cache.len
|
||||
unsafe {
|
||||
ctx.image_cache << img
|
||||
}
|
||||
return img
|
||||
}
|
||||
|
||||
|
@ -31,7 +31,7 @@ struct C.PGResult {
|
||||
|
||||
pub struct Config {
|
||||
pub:
|
||||
host string
|
||||
host string = 'localhost'
|
||||
port int = 5432
|
||||
user string
|
||||
password string
|
||||
|
Loading…
x
Reference in New Issue
Block a user