mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
vfmt: keep the source fn type alias names, instead of the expanded fn declarations
This commit is contained in:
parent
26c2654632
commit
d34c5b767b
@ -31,7 +31,8 @@ pub mut:
|
|||||||
pub fn new_builder(pref &pref.Preferences) Builder {
|
pub fn new_builder(pref &pref.Preferences) Builder {
|
||||||
rdir := os.real_path(pref.path)
|
rdir := os.real_path(pref.path)
|
||||||
compiled_dir := if os.is_dir(rdir) { rdir } else { os.dir(rdir) }
|
compiled_dir := if os.is_dir(rdir) { rdir } else { os.dir(rdir) }
|
||||||
table := table.new_table()
|
mut table := table.new_table()
|
||||||
|
table.is_fmt = false
|
||||||
if pref.use_color == .always {
|
if pref.use_color == .always {
|
||||||
util.emanager.set_support_color(true)
|
util.emanager.set_support_color(true)
|
||||||
}
|
}
|
||||||
|
65
vlib/v/fmt/tests/fntype_alias_keep.vv
Normal file
65
vlib/v/fmt/tests/fntype_alias_keep.vv
Normal file
@ -0,0 +1,65 @@
|
|||||||
|
module ui
|
||||||
|
|
||||||
|
import gg
|
||||||
|
import gx
|
||||||
|
import eventbus
|
||||||
|
|
||||||
|
pub type DrawFn = fn (ctx &gg.Context, state voidptr)
|
||||||
|
|
||||||
|
pub type ClickFn = fn (e MouseEvent, func voidptr)
|
||||||
|
|
||||||
|
pub type KeyFn = fn (e KeyEvent, func voidptr)
|
||||||
|
|
||||||
|
pub type ScrollFn = fn (e ScrollEvent, func voidptr)
|
||||||
|
|
||||||
|
pub type MouseMoveFn = fn (e MouseMoveEvent, func voidptr)
|
||||||
|
|
||||||
|
[ref_only]
|
||||||
|
pub struct Window {
|
||||||
|
pub mut:
|
||||||
|
ui &UI = voidptr(0)
|
||||||
|
children []Widget
|
||||||
|
child_window &Window = voidptr(0)
|
||||||
|
parent_window &Window = voidptr(0)
|
||||||
|
has_textbox bool // for initial focus
|
||||||
|
tab_index int
|
||||||
|
just_tabbed bool
|
||||||
|
state voidptr
|
||||||
|
draw_fn DrawFn
|
||||||
|
title string
|
||||||
|
mx f64
|
||||||
|
my f64
|
||||||
|
width int
|
||||||
|
height int
|
||||||
|
bg_color gx.Color
|
||||||
|
click_fn ClickFn
|
||||||
|
mouse_down_fn ClickFn
|
||||||
|
mouse_up_fn ClickFn
|
||||||
|
scroll_fn ScrollFn
|
||||||
|
key_down_fn KeyFn
|
||||||
|
char_fn KeyFn
|
||||||
|
mouse_move_fn MouseMoveFn
|
||||||
|
eventbus &eventbus.EventBus = eventbus.new()
|
||||||
|
}
|
||||||
|
|
||||||
|
pub struct WindowConfig {
|
||||||
|
pub:
|
||||||
|
width int
|
||||||
|
height int
|
||||||
|
resizable bool
|
||||||
|
title string
|
||||||
|
always_on_top bool
|
||||||
|
state voidptr
|
||||||
|
draw_fn DrawFn
|
||||||
|
bg_color gx.Color = default_window_color
|
||||||
|
on_click ClickFn
|
||||||
|
on_mouse_down ClickFn
|
||||||
|
on_mouse_up ClickFn
|
||||||
|
on_key_down KeyFn
|
||||||
|
on_scroll ScrollFn
|
||||||
|
on_mouse_move MouseMoveFn
|
||||||
|
children []Widget
|
||||||
|
font_path string
|
||||||
|
// pub mut:
|
||||||
|
// parent_window &Window
|
||||||
|
}
|
@ -839,10 +839,12 @@ pub fn (table &Table) type_to_str(t Type) string {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
.function {
|
.function {
|
||||||
info := sym.info as FnType
|
if !table.is_fmt {
|
||||||
res = table.fn_signature(info.func, {
|
info := sym.info as FnType
|
||||||
type_only: true
|
res = table.fn_signature(info.func, {
|
||||||
})
|
type_only: true
|
||||||
|
})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
.map {
|
.map {
|
||||||
if int(t) == map_type_idx {
|
if int(t) == map_type_idx {
|
||||||
|
@ -18,6 +18,7 @@ pub mut:
|
|||||||
redefined_fns []string
|
redefined_fns []string
|
||||||
fn_gen_types map[string][]Type // for generic functions
|
fn_gen_types map[string][]Type // for generic functions
|
||||||
cmod_prefix string // needed for table.type_to_str(Type) while vfmt; contains `os.`
|
cmod_prefix string // needed for table.type_to_str(Type) while vfmt; contains `os.`
|
||||||
|
is_fmt bool
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct Fn {
|
pub struct Fn {
|
||||||
@ -83,6 +84,7 @@ mut:
|
|||||||
pub fn new_table() &Table {
|
pub fn new_table() &Table {
|
||||||
mut t := &Table{}
|
mut t := &Table{}
|
||||||
t.register_builtin_type_symbols()
|
t.register_builtin_type_symbols()
|
||||||
|
t.is_fmt = true
|
||||||
return t
|
return t
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user