Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

set nil as the initial value of the struct reference type fields #558

Merged
merged 1 commit into from
Nov 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion component/accordion.v
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import gx
@[heap]
pub struct AccordionComponent {
pub mut:
layout &ui.Stack // required
layout &ui.Stack = unsafe { nil } // required
titles map[string]string
selected map[string]bool
views map[string]int
Expand Down
8 changes: 4 additions & 4 deletions component/alpha.v
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ pub struct AlphaComponent {
pub mut:
id string
alpha int
layout &ui.Stack
slider &ui.Slider
textbox &ui.TextBox
on_changed AlphaFn = AlphaFn(0)
layout &ui.Stack = unsafe { nil }
slider &ui.Slider = unsafe { nil }
textbox &ui.TextBox = unsafe { nil }
on_changed AlphaFn = AlphaFn(0)
}

@[params]
Expand Down
22 changes: 11 additions & 11 deletions component/colorbox.v
Original file line number Diff line number Diff line change
Expand Up @@ -47,17 +47,17 @@ mut:
hsl bool // use hsl instead of hsv
drag bool // drag mode for canvas on h
pub mut:
layout &ui.Stack // required
cv_h &ui.CanvasLayout
cv_sv &ui.CanvasLayout
r_rgb_cur &ui.Rectangle
cv_hsv_sel &ui.CanvasLayout
tb_r &ui.TextBox
tb_g &ui.TextBox
tb_b &ui.TextBox
lb_r &ui.Label
lb_g &ui.Label
lb_b &ui.Label
layout &ui.Stack = unsafe { nil } // required
cv_h &ui.CanvasLayout = unsafe { nil }
cv_sv &ui.CanvasLayout = unsafe { nil }
r_rgb_cur &ui.Rectangle = unsafe { nil }
cv_hsv_sel &ui.CanvasLayout = unsafe { nil }
tb_r &ui.TextBox = unsafe { nil }
tb_g &ui.TextBox = unsafe { nil }
tb_b &ui.TextBox = unsafe { nil }
lb_r &ui.Label = unsafe { nil }
lb_g &ui.Label = unsafe { nil }
lb_b &ui.Label = unsafe { nil }
}

@[params]
Expand Down
4 changes: 2 additions & 2 deletions component/colorbutton.v
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ type ColorButtonFn = fn (b &ColorButtonComponent)
@[heap]
pub struct ColorButtonComponent {
pub mut:
widget &ui.Button
bg_color gx.Color = gx.white
widget &ui.Button = unsafe { nil }
bg_color gx.Color = gx.white
alpha int
on_click ColorButtonFn = ColorButtonFn(0)
on_changed ColorButtonFn = ColorButtonFn(0)
Expand Down
4 changes: 2 additions & 2 deletions component/colorpalette.v
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import math
pub struct ColorPaletteComponent {
pub mut:
id string
layout &ui.Stack // required
colbtn &ui.Button // current
layout &ui.Stack = unsafe { nil } // required
colbtn &ui.Button = unsafe { nil } // current
ncolors int
alpha &AlphaComponent = unsafe { nil }
color &gx.Color = unsafe { nil }
Expand Down
2 changes: 1 addition & 1 deletion component/colorsliders.v
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ type ColorSlidersFn = fn (cs &ColorSlidersComponent)
pub struct ColorSlidersComponent {
id string
pub mut:
layout &ui.Stack // required
layout &ui.Stack = unsafe { nil } // required
orientation ui.Orientation
r_slider &ui.Slider = unsafe { nil }
r_textbox &ui.TextBox = unsafe { nil }
Expand Down
12 changes: 6 additions & 6 deletions component/double_listbox.v
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ import ui
@[heap]
pub struct DoubleListBoxComponent {
pub mut:
layout &ui.Stack // required
lb_left &ui.ListBox
lb_right &ui.ListBox
btn_left &ui.Button
btn_right &ui.Button
btn_clear &ui.Button
layout &ui.Stack = unsafe { nil } // required
lb_left &ui.ListBox = unsafe { nil }
lb_right &ui.ListBox = unsafe { nil }
btn_left &ui.Button = unsafe { nil }
btn_right &ui.Button = unsafe { nil }
btn_clear &ui.Button = unsafe { nil }
}

@[params]
Expand Down
6 changes: 3 additions & 3 deletions component/filebrowser.v
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ import os
@[heap]
pub struct FileBrowserComponent {
pub mut:
layout &ui.Stack
btn_cancel &ui.Button
btn_ok &ui.Button
layout &ui.Stack = unsafe { nil }
btn_cancel &ui.Button = unsafe { nil }
btn_ok &ui.Button = unsafe { nil }
tv &TreeViewComponent = unsafe { nil }
dir string
}
Expand Down
2 changes: 1 addition & 1 deletion component/fontbutton.v
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import gx
@[heap]
pub struct FontButtonComponent {
pub mut:
btn &ui.Button
btn &ui.Button = unsafe { nil }
dtw ui.DrawTextWidget
}

Expand Down
2 changes: 1 addition & 1 deletion component/fontchooser.v
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const (
@[heap]
pub struct FontChooserComponent {
pub mut:
layout &ui.Stack // required
layout &ui.Stack = unsafe { nil } // required
dtw ui.DrawTextWidget
}

Expand Down
2 changes: 1 addition & 1 deletion component/grid.v
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ type GridData = Factor | []bool | []f64 | []int | []string
pub struct GridComponent {
pub mut:
id string
layout &ui.CanvasLayout
layout &ui.CanvasLayout = unsafe { nil }
vars []GridVar
types []GridType
formula_mngr GridFormulaMngr
Expand Down
6 changes: 3 additions & 3 deletions component/hideable.v
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import gx
pub struct HideableComponent {
pub mut:
id string
layout &ui.Stack
layout &ui.Stack = unsafe { nil }
child_layout_id string
window &ui.Window = &ui.Window(unsafe { nil })
z_index map[string]int
Expand All @@ -20,8 +20,8 @@ pub mut:
pub struct HideableParams {
id string
bg_color gx.Color
layout &ui.Stack
hidden bool = true
layout &ui.Stack = unsafe { nil }
hidden bool = true
shortcut string
open bool = true
}
Expand Down
2 changes: 1 addition & 1 deletion component/menufile.v
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ pub type MenuFileFn = fn (&MenuFileComponent)
pub struct MenuFileComponent {
pub mut:
id string
layout &ui.Stack
layout &ui.Stack = unsafe { nil }
hidden_files bool
file string
folder_to_open string
Expand Down
6 changes: 3 additions & 3 deletions component/messagebox.v
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ type MessageBoxFn = fn (&MessageBoxComponent)
@[heap]
pub struct MessageBoxComponent {
id string
layout &ui.Stack
tb &ui.TextBox
btn &ui.Button
layout &ui.Stack = unsafe { nil }
tb &ui.TextBox = unsafe { nil }
btn &ui.Button = unsafe { nil }
text string
on_click MessageBoxFn = MessageBoxFn(0)
}
Expand Down
4 changes: 2 additions & 2 deletions component/rasterview.v
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ type RasterViewFn = fn (rv &RasterViewComponent)
pub struct RasterViewComponent {
pub mut:
id string
layout &ui.CanvasLayout
r &libvg.Raster
layout &ui.CanvasLayout = unsafe { nil }
r &libvg.Raster = unsafe { nil }
// width int
// height int
// channels int = 4
Expand Down
8 changes: 4 additions & 4 deletions component/settings.v
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ pub struct SettingFont {
param string
lb_text string
mut:
layout &ui.Stack
lb_param &ui.Label
lb_font &ui.Label
btn_font &ui.Button
layout &ui.Stack = unsafe { nil }
lb_param &ui.Label = unsafe { nil }
lb_font &ui.Label = unsafe { nil }
btn_font &ui.Button = unsafe { nil }
}

@[params]
Expand Down
10 changes: 5 additions & 5 deletions component/splitpanel.v
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ const splitpanel_btn_size = 6
pub struct SplitPanelComponent {
pub mut:
id string
layout &ui.Stack
child1 &ui.Widget
child2 &ui.Widget
layout &ui.Stack = unsafe { nil }
child1 &ui.Widget = unsafe { nil }
child2 &ui.Widget = unsafe { nil }
direction ui.Direction
active bool
weight f32
Expand All @@ -21,8 +21,8 @@ pub mut:
@[params]
pub struct SplitPanelParams {
id string
child1 &ui.Widget
child2 &ui.Widget
child1 &ui.Widget = unsafe { nil }
child2 &ui.Widget = unsafe { nil }
direction ui.Direction = .row
weight f64 = 50.0
btn_size int = component.splitpanel_btn_size
Expand Down
4 changes: 2 additions & 2 deletions component/tabs.v
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ enum TabsMode {
pub struct TabsComponent {
pub mut:
id string
layout &ui.Stack // required
layout &ui.Stack = unsafe { nil } // required
active string
prev_active string
tab_bar &ui.Stack
tab_bar &ui.Stack = unsafe { nil }
pages map[string]ui.Widget
z_index map[string]int
mode TabsMode
Expand Down
2 changes: 1 addition & 1 deletion component/treeview.v
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ type TreeViewClickFn = fn (c &ui.CanvasLayout, mut tv TreeViewComponent)
pub struct TreeViewComponent {
pub mut:
id string
layout &ui.Stack // required
layout &ui.Stack = unsafe { nil } // required
trees []Tree
icon_paths map[string]string
text_color gx.Color
Expand Down