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) {
|
fn gg_frame_fn(mut ctx Context) {
|
||||||
mut ctx := unsafe { &Context(user_data) }
|
|
||||||
ctx.frame++
|
ctx.frame++
|
||||||
if ctx.config.frame_fn == unsafe { nil } {
|
if ctx.config.frame_fn == unsafe { nil } {
|
||||||
return
|
return
|
||||||
|
@ -25,8 +25,8 @@ pub mut:
|
|||||||
}
|
}
|
||||||
|
|
||||||
// create_image creates an `Image` from `file`.
|
// create_image creates an `Image` from `file`.
|
||||||
// TODO return ?Image
|
// TODO return !Image
|
||||||
pub fn (mut ctx Context) create_image(file string) Image {
|
pub fn (ctx &Context) create_image(file string) Image {
|
||||||
// println('\ncreate_image("$file")')
|
// println('\ncreate_image("$file")')
|
||||||
if !os.exists(file) {
|
if !os.exists(file) {
|
||||||
return Image{}
|
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')
|
// println('created macos image: $img.path w=$img.width')
|
||||||
// C.printf('p = %p\n', img.data)
|
// C.printf('p = %p\n', img.data)
|
||||||
img.id = ctx.image_cache.len
|
img.id = ctx.image_cache.len
|
||||||
|
unsafe {
|
||||||
ctx.image_cache << img
|
ctx.image_cache << img
|
||||||
|
}
|
||||||
return img
|
return img
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -56,12 +58,16 @@ pub fn (mut ctx Context) create_image(file string) Image {
|
|||||||
path: file
|
path: file
|
||||||
id: ctx.image_cache.len
|
id: ctx.image_cache.len
|
||||||
}
|
}
|
||||||
|
unsafe {
|
||||||
ctx.image_cache << img
|
ctx.image_cache << img
|
||||||
|
}
|
||||||
return img
|
return img
|
||||||
}
|
}
|
||||||
mut img := create_image(file)
|
mut img := create_image(file)
|
||||||
img.id = ctx.image_cache.len
|
img.id = ctx.image_cache.len
|
||||||
|
unsafe {
|
||||||
ctx.image_cache << img
|
ctx.image_cache << img
|
||||||
|
}
|
||||||
return img
|
return img
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -31,7 +31,7 @@ struct C.PGResult {
|
|||||||
|
|
||||||
pub struct Config {
|
pub struct Config {
|
||||||
pub:
|
pub:
|
||||||
host string
|
host string = 'localhost'
|
||||||
port int = 5432
|
port int = 5432
|
||||||
user string
|
user string
|
||||||
password string
|
password string
|
||||||
|
Loading…
x
Reference in New Issue
Block a user