Rename input and output property to in, out and in-out

This commit is contained in:
Olivier Goffart 2022-11-08 09:32:15 +01:00 committed by Olivier Goffart
parent ca616857b1
commit dd4c701307
8 changed files with 343 additions and 347 deletions

View file

@ -23,65 +23,65 @@
import { _ } from ""; // just to silence many errors in the LSP
Empty := _ {
input property <length> x;
input property <length> y;
input property <length> width;
input property <length> height;
in property <length> x;
in property <length> y;
in property <length> width;
in property <length> height;
//-default_size_binding:expands_to_parent_geometry
//-is_internal
}
Rectangle := Empty {
input property <brush> background;
input property <brush> color <=> background;
in property <brush> background;
in property <brush> color <=> background;
}
BorderRectangle := Rectangle {
input property <length> border-width;
input property <length> border-radius;
input property <brush> border-color;
in property <length> border-width;
in property <length> border-radius;
in property <brush> border-color;
//-default_size_binding:expands_to_parent_geometry
}
export { BorderRectangle as Rectangle }
ImageItem := Empty {
input property <image> source;
input property <ImageFit> image-fit;
input property <ImageRendering> image-rendering;
in property <image> source;
in property <ImageFit> image-fit;
in property <ImageRendering> image-rendering;
}
export ClippedImage := ImageItem {
input property <int> source-clip-x;
input property <int> source-clip-y;
input property <int> source-clip-width;
input property <int> source-clip-height;
input property <brush> colorize;
in property <int> source-clip-x;
in property <int> source-clip-y;
in property <int> source-clip-width;
in property <int> source-clip-height;
in property <brush> colorize;
//-default_size_binding:implicit_size
}
export { ClippedImage as Image }
export Rotate := Empty {
input property <angle> rotation-angle;
input property <length> rotation-origin-x;
input property <length> rotation-origin-y;
in property <angle> rotation-angle;
in property <length> rotation-origin-x;
in property <length> rotation-origin-y;
//-default_size_binding:expands_to_parent_geometry
//-is_internal
}
export Text := Empty {
input property <string> text;
input property <string> font-family;
input property <length> font-size;
input property <int> font-weight;
input property <brush> color; // StyleMetrics.default-text-color set in apply_default_properties_from_style
input property <TextHorizontalAlignment> horizontal-alignment;
input property <TextVerticalAlignment> vertical-alignment;
input property <TextOverflow> overflow;
input property <TextWrap> wrap;
input property <length> letter-spacing;
in property <string> text;
in property <string> font-family;
in property <length> font-size;
in property <int> font-weight;
in property <brush> color; // StyleMetrics.default-text-color set in apply_default_properties_from_style
in property <TextHorizontalAlignment> horizontal-alignment;
in property <TextVerticalAlignment> vertical-alignment;
in property <TextOverflow> overflow;
in property <TextWrap> wrap;
in property <length> letter-spacing;
//-default_size_binding:implicit_size
}
@ -93,18 +93,18 @@ export struct PointerEvent := {
}
export TouchArea := _ {
input property <length> x;
input property <length> y;
input property <length> width;
input property <length> height;
input property <bool> enabled: true;
output property <bool> pressed;
output property <bool> has_hover;
output property <length> mouse_x;
output property <length> mouse_y;
output property <length> pressed_x;
output property <length> pressed_y;
input property <MouseCursor> mouse-cursor;
in property <length> x;
in property <length> y;
in property <length> width;
in property <length> height;
in property <bool> enabled: true;
out property <bool> pressed;
out property <bool> has_hover;
out property <length> mouse_x;
out property <length> mouse_y;
out property <length> pressed_x;
out property <length> pressed_y;
in property <MouseCursor> mouse-cursor;
callback clicked;
callback moved;
callback pointer-event(PointerEvent);
@ -126,12 +126,12 @@ export struct KeyEvent := {
}
export FocusScope := _ {
input property <length> x;
input property <length> y;
input property <length> width;
input property <length> height;
input property <bool> enabled: true;
output property <bool> has-focus;
in property <length> x;
in property <length> y;
in property <length> width;
in property <length> height;
in property <bool> enabled: true;
out property <bool> has-focus;
callback key_pressed(KeyEvent) -> EventResult;
callback key_released(KeyEvent) -> EventResult;
//-default_size_binding:expands_to_parent_geometry
@ -141,35 +141,35 @@ export FocusScope := _ {
export Flickable := Empty {
// These properties are actually going to be forwarded to the viewport by the
// code generator
input property <length> viewport-height;
input property <length> viewport-width;
input output property <length> viewport-x;
input output property <length> viewport-y;
input property <bool> interactive: true;
in property <length> viewport-height;
in property <length> viewport-width;
in-out property <length> viewport-x;
in-out property <length> viewport-y;
in property <bool> interactive: true;
//-default_size_binding:expands_to_parent_geometry
}
WindowItem := _ {
input output property <length> width;
input output property <length> height;
input property <brush> background; // StyleMetrics.window_background set in apply_default_properties_from_style
input property <brush> color <=> background;
input property <string> title: "Slint Window";
input property <bool> no-frame;
input property <string> default-font-family;
input output property <length> default-font-size; // <=> StyleMetrics.default-font-size set in apply_default_properties_from_style
input property <int> default-font-weight;
input property <image> icon;
in-out property <length> width;
in-out property <length> height;
in property <brush> background; // StyleMetrics.window_background set in apply_default_properties_from_style
in property <brush> color <=> background;
in property <string> title: "Slint Window";
in property <bool> no-frame;
in property <string> default-font-family;
in-out property <length> default-font-size; // <=> StyleMetrics.default-font-size set in apply_default_properties_from_style
in property <int> default-font-weight;
in property <image> icon;
}
export Window := WindowItem {}
export BoxShadow := Empty {
input property <length> border_radius;
input property <length> offset_x;
input property <length> offset_y;
input property <color> color;
input property <length> blur;
in property <length> border_radius;
in property <length> offset_x;
in property <length> offset_y;
in property <color> color;
in property <length> blur;
//-default_size_binding:expands_to_parent_geometry
//-is_internal
}
@ -181,63 +181,63 @@ export struct Point := {
}
export TextInput := _ {
input output property <string> text;
input property <string> font-family;
input property <length> font-size;
input property <int> font-weight;
input property <brush> color; // StyleMetrics.default-text-color set in apply_default_properties_from_style
input property <color> selection-foreground-color: #000;
input property <color> selection-background-color: #808080;
input property <TextHorizontalAlignment> horizontal-alignment;
input property <TextVerticalAlignment> vertical-alignment;
input property <TextWrap> wrap;
input property <length> letter-spacing;
input property <length> x;
input property <length> y;
input property <length> width;
input property <length> height;
input property <length> text-cursor-width; // StyleMetrics.text-cursor-width set in apply_default_properties_from_style
input property <InputType> input-type;
in-out property <string> text;
in property <string> font-family;
in property <length> font-size;
in property <int> font-weight;
in property <brush> color; // StyleMetrics.default-text-color set in apply_default_properties_from_style
in property <color> selection-foreground-color: #000;
in property <color> selection-background-color: #808080;
in property <TextHorizontalAlignment> horizontal-alignment;
in property <TextVerticalAlignment> vertical-alignment;
in property <TextWrap> wrap;
in property <length> letter-spacing;
in property <length> x;
in property <length> y;
in property <length> width;
in property <length> height;
in property <length> text-cursor-width; // StyleMetrics.text-cursor-width set in apply_default_properties_from_style
in property <InputType> input-type;
// Internal, undocumented property, only exposed for tests.
output property <int> cursor-position_byte-offset;
out property <int> cursor-position_byte-offset;
// Internal, undocumented property, only exposed for tests.
output property <int> anchor-position-byte-offset;
output property <bool> has-focus;
out property <int> anchor-position-byte-offset;
out property <bool> has-focus;
callback accepted;
callback edited;
callback cursor_position_changed(Point);
input property <bool> enabled: true;
input property <bool> single-line: true;
input property <bool> read-only: false;
output property <string> preedit-text;
in property <bool> enabled: true;
in property <bool> single-line: true;
in property <bool> read-only: false;
out property <string> preedit-text;
//-default_size_binding:expands_to_parent_geometry
//-accepts_focus
}
export Clip := _ {
input property <length> x;
input property <length> y;
input property <length> width;
input property <length> height;
input property <length> border-radius;
input property <length> border-width;
input property <bool> clip;
in property <length> x;
in property <length> y;
in property <length> width;
in property <length> height;
in property <length> border-radius;
in property <length> border-width;
in property <bool> clip;
//-default_size_binding:expands_to_parent_geometry
//-is_internal
}
export Opacity := _ {
input property <length> x;
input property <length> y;
input property <length> width;
input property <length> height;
input property <float> opacity: 1;
in property <length> x;
in property <length> y;
in property <length> width;
in property <length> height;
in property <float> opacity: 1;
//-default_size_binding:expands_to_parent_geometry
//-is_internal
}
export Layer := Empty {
input property <bool> cache-rendering-hint;
in property <bool> cache-rendering-hint;
//-default_size_binding:expands_to_parent_geometry
//-is_internal
}
@ -248,25 +248,25 @@ Row := _ {
// Note: layouts are not NativeClass, but this is lowered in lower_layout
export GridLayout := _ {
input property <length> spacing;
in property <length> spacing;
// Additional accepted child
Row { }
}
export VerticalLayout := _ {
input property <length> spacing;
input property <LayoutAlignment> alignment;
in property <length> spacing;
in property <LayoutAlignment> alignment;
}
export HorizontalLayout := _ {
input property <length> spacing;
input property <LayoutAlignment> alignment;
in property <length> spacing;
in property <LayoutAlignment> alignment;
}
MoveTo := _ {
input property <float> x;
input property <float> y;
in property <float> x;
in property <float> y;
//-rust_type_constructor:slint::re_exports::PathElement::MoveTo(PathMoveTo{{}})
//-cpp_type:slint::private_api::PathMoveTo
@ -274,8 +274,8 @@ MoveTo := _ {
}
LineTo := _ {
input property <float> x;
input property <float> y;
in property <float> x;
in property <float> y;
//-rust_type_constructor:slint::re_exports::PathElement::LineTo(PathLineTo{{}})
//-cpp_type:slint::private_api::PathLineTo
@ -283,13 +283,13 @@ LineTo := _ {
}
ArcTo := _ {
input property <float> x;
input property <float> y;
input property <float> radius-x;
input property <float> radius-y;
input property <float> x-rotation;
input property <bool> large_arc;
input property <bool> sweep;
in property <float> x;
in property <float> y;
in property <float> radius-x;
in property <float> radius-y;
in property <float> x-rotation;
in property <bool> large_arc;
in property <bool> sweep;
//-rust_type_constructor:slint::re_exports::PathElement::ArcTo(PathArcTo{{}})
//-cpp_type:slint::private_api::PathArcTo
@ -297,12 +297,12 @@ ArcTo := _ {
}
CubicTo := _ {
input property <float> control-1-x;
input property <float> control-1-y;
input property <float> control-2-x;
input property <float> control-2-y;
input property <float> x;
input property <float> y;
in property <float> control-1-x;
in property <float> control-1-y;
in property <float> control-2-x;
in property <float> control-2-y;
in property <float> x;
in property <float> y;
//-rust_type_constructor:slint::re_exports::PathElement::CubicTo(PathCubicTo{{}})
//-cpp_type:slint::private_api::PathCubicTo
@ -310,10 +310,10 @@ CubicTo := _ {
}
QuadraticTo := _ {
input property <float> control-x;
input property <float> control-y;
input property <float> x;
input property <float> y;
in property <float> control-x;
in property <float> control-y;
in property <float> x;
in property <float> y;
//-rust_type_constructor:slint::re_exports::PathElement::QuadraticTo(PathQuadraticTo{{}})
//-cpp_type:slint::private_api::PathQuadraticTo
@ -328,20 +328,20 @@ Close := _ {
}
export Path := _ {
input property <length> x;
input property <length> y;
input property <length> width;
input property <length> height;
input property <brush> fill;
input property <FillRule> fill-rule;
input property <brush> stroke;
input property <length> stroke-width;
input property <string> commands;
input property <float> viewbox-x;
input property <float> viewbox-y;
input property <float> viewbox-width;
input property <float> viewbox-height;
input property <bool> clip;
in property <length> x;
in property <length> y;
in property <length> width;
in property <length> height;
in property <brush> fill;
in property <FillRule> fill-rule;
in property <brush> stroke;
in property <length> stroke-width;
in property <string> commands;
in property <float> viewbox-x;
in property <float> viewbox-y;
in property <float> viewbox-width;
in property <float> viewbox-height;
in property <bool> clip;
//-disallow_global_types_as_child_elements
MoveTo {}
@ -355,12 +355,12 @@ export Path := _ {
}
export PathLayout := _ {
input property <length> x;
input property <length> y;
input property <length> width;
input property <length> height;
input property <string> commands;
input property <float> offset;
in property <length> x;
in property <length> y;
in property <length> width;
in property <length> height;
in property <string> commands;
in property <float> offset;
MoveTo {}
LineTo {}
@ -371,18 +371,18 @@ export PathLayout := _ {
}
Tab := _ {
input property <string> title;
in property <string> title;
}
// Note: not a native class, handled in the lower_tabs pass
export TabWidget := _ {
input property <length> x;
input property <length> y;
input property <length> width;
input property <length> height;
in property <length> x;
in property <length> y;
in property <length> width;
in property <length> height;
input property <int> current-index;
input property <int> current-focused;
in property <int> current-index;
in property <int> current-focused;
//-disallow_global_types_as_child_elements
Tab {}
@ -394,22 +394,22 @@ export TabWidget := _ {
export PopupWindow := _ {
//property <length> x;
//property <length> y;
input property <length> width;
input property <length> height;
in property <length> width;
in property <length> height;
/*property <length> anchor_x;
input property <length> anchor_y;
input property <length> anchor_height;
input property <length> anchor_width;*/
in property <length> anchor_y;
in property <length> anchor_height;
in property <length> anchor_width;*/
//show() is hardcoded in typeregister.rs
}
export Dialog := WindowItem {}
PropertyAnimation := _ {
input property <duration> delay;
input property <duration> duration;
input property <easing> easing;
input property <float> iteration-count: 1.0;
in property <duration> delay;
in property <duration> duration;
in property <easing> easing;
in property <float> iteration-count: 1.0;
//-is_non_item_type
}
@ -427,206 +427,206 @@ export struct StateInfo := {
}
export NativeButton := _ {
input property <length> x;
input property <length> y;
input property <length> width;
input property <length> height;
input property <string> text;
input property <image> icon;
output property <bool> pressed;
input property <bool> checkable;
input output property <bool> checked;
output property <bool> has-focus;
in property <length> x;
in property <length> y;
in property <length> width;
in property <length> height;
in property <string> text;
in property <image> icon;
out property <bool> pressed;
in property <bool> checkable;
in-out property <bool> checked;
out property <bool> has-focus;
callback clicked;
input property <bool> enabled: true;
input property <StandardButtonKind> standard-button-kind;
input property <bool> is-standard-button;
in property <bool> enabled: true;
in property <StandardButtonKind> standard-button-kind;
in property <bool> is-standard-button;
//-is_internal
}
export NativeCheckBox := _ {
input property <length> x;
input property <length> y;
input property <length> width;
input property <length> height;
input property <bool> enabled: true;
input property <string> text;
input output property <bool> checked;
output property <bool> has-focus;
in property <length> x;
in property <length> y;
in property <length> width;
in property <length> height;
in property <bool> enabled: true;
in property <string> text;
in-out property <bool> checked;
out property <bool> has-focus;
callback toggled;
//-is_internal
}
export NativeSpinBox := _ {
input property <length> x;
input property <length> y;
input property <length> width;
input property <length> height;
input property <bool> enabled: true;
output property <bool> has-focus;
input output property <int> value;
input property <int> minimum;
input property <int> maximum: 100;
in property <length> x;
in property <length> y;
in property <length> width;
in property <length> height;
in property <bool> enabled: true;
out property <bool> has-focus;
in-out property <int> value;
in property <int> minimum;
in property <int> maximum: 100;
//-is_internal
}
export NativeSlider := _ {
input property <length> x;
input property <length> y;
input property <length> width;
input property <length> height;
input property <bool> enabled: true;
input output property <float> value;
input property <float> minimum;
input property <float> maximum: 100;
in property <length> x;
in property <length> y;
in property <length> width;
in property <length> height;
in property <bool> enabled: true;
in-out property <float> value;
in property <float> minimum;
in property <float> maximum: 100;
callback changed(float);
//-is_internal
}
export NativeGroupBox := _ {
input property <length> x;
input property <length> y;
input property <length> width;
input property <length> height;
input property <bool> enabled: true;
input property <string> title;
output property <length> native-padding-left;
output property <length> native-padding-right;
output property <length> native-padding-top;
output property <length> native-padding-bottom;
in property <length> x;
in property <length> y;
in property <length> width;
in property <length> height;
in property <bool> enabled: true;
in property <string> title;
out property <length> native-padding-left;
out property <length> native-padding-right;
out property <length> native-padding-top;
out property <length> native-padding-bottom;
//-default_size_binding:expands_to_parent_geometry
//-is_internal
}
export NativeLineEdit := _ {
input property <length> x;
input property <length> y;
input property <length> width;
input property <length> height;
output property <length> native-padding-left;
output property <length> native-padding-right;
output property <length> native-padding-top;
output property <length> native-padding-bottom;
input property <bool> has-focus;
input property <bool> enabled: true;
in property <length> x;
in property <length> y;
in property <length> width;
in property <length> height;
out property <length> native-padding-left;
out property <length> native-padding-right;
out property <length> native-padding-top;
out property <length> native-padding-bottom;
in property <bool> has-focus;
in property <bool> enabled: true;
//-is_internal
}
export NativeScrollView := _ {
input property <length> x;
input property <length> y;
input property <length> width;
input property <length> height;
input property <length> horizontal-max;
input property <length> horizontal-page-size;
input property <length> horizontal-value;
input property <length> vertical-max;
input property <length> vertical-page-size;
input output property <length> vertical-value;
output property <length> native-padding-left;
output property <length> native-padding-right;
output property <length> native-padding-top;
output property <length> native-padding-bottom;
input property <bool> has_focus;
input property <bool> enabled: true;
in property <length> x;
in property <length> y;
in property <length> width;
in property <length> height;
in property <length> horizontal-max;
in property <length> horizontal-page-size;
in property <length> horizontal-value;
in property <length> vertical-max;
in property <length> vertical-page-size;
in-out property <length> vertical-value;
out property <length> native-padding-left;
out property <length> native-padding-right;
out property <length> native-padding-top;
out property <length> native-padding-bottom;
in property <bool> has_focus;
in property <bool> enabled: true;
//-default_size_binding:expands_to_parent_geometry
//-is_internal
}
export NativeStandardListViewItem := _ {
input property <length> x;
input property <length> y;
input property <length> width;
input property <length> height;
input property <int> index;
input property <StandardListViewItem> item;
input output property <bool> is_selected;
input property <bool> has_hover;
in property <length> x;
in property <length> y;
in property <length> width;
in property <length> height;
in property <int> index;
in property <StandardListViewItem> item;
in-out property <bool> is_selected;
in property <bool> has_hover;
//-is_internal
}
export NativeComboBox := _ {
input property <length> x;
input property <length> y;
input property <length> width;
input property <length> height;
input property <string> current_value;
input output property <bool> is_open;
input property <bool> enabled: true;
in property <length> x;
in property <length> y;
in property <length> width;
in property <length> height;
in property <string> current_value;
in-out property <bool> is_open;
in property <bool> enabled: true;
callback open_popup;
//-is_internal
}
export NativeComboBoxPopup := _ {
input property <length> x;
input property <length> y;
input property <length> width;
input property <length> height;
in property <length> x;
in property <length> y;
in property <length> width;
in property <length> height;
//-is_internal
}
export NativeTabWidget := _ {
input property <length> x;
input property <length> y;
input property <length> width;
input property <length> height;
in property <length> x;
in property <length> y;
in property <length> width;
in property <length> height;
output property <length> content-x;
output property <length> content-y;
output property <length> content-height;
output property <length> content-width;
output property <length> tabbar-x;
output property <length> tabbar-y;
output property <length> tabbar-height;
output property <length> tabbar-width;
input property <length> tabbar-preferred-height;
input property <length> tabbar-preferred-width;
input property <length> content-min-height;
input property <length> content-min-width;
out property <length> content-x;
out property <length> content-y;
out property <length> content-height;
out property <length> content-width;
out property <length> tabbar-x;
out property <length> tabbar-y;
out property <length> tabbar-height;
out property <length> tabbar-width;
in property <length> tabbar-preferred-height;
in property <length> tabbar-preferred-width;
in property <length> content-min-height;
in property <length> content-min-width;
input property <int> current-index;
input property <int> current-focused;
in property <int> current-index;
in property <int> current-focused;
//-default_size_binding:expands_to_parent_geometry
//-is_internal
}
export NativeTab := _ {
input property <length> x;
input property <length> y;
input property <length> width;
input property <length> height;
in property <length> x;
in property <length> y;
in property <length> width;
in property <length> height;
input property<string> title;
input property<image> icon;
input property<bool> enabled : true;
output property<bool> pressed;
output property<int> current; // supposed to be a binding to the tab
input property<int> tab-index;
input property<int> current-focused;
input property<int> num-tabs;
in property<string> title;
in property<image> icon;
in property<bool> enabled : true;
out property<bool> pressed;
out property<int> current; // supposed to be a binding to the tab
in property<int> tab-index;
in property<int> current-focused;
in property<int> num-tabs;
//-is_internal
}
export global NativeStyleMetrics := {
output property <length> layout-spacing;
output property <length> layout-padding;
output property <length> text-cursor-width;
output property <color> window-background;
output property <color> default-text-color;
output property <length> default-font-size;
output property <color> textedit-background;
output property <color> textedit-text-color;
output property <color> textedit-background-disabled;
output property <color> textedit-text-color-disabled;
out property <length> layout-spacing;
out property <length> layout-padding;
out property <length> text-cursor-width;
out property <color> window-background;
out property <color> default-text-color;
out property <length> default-font-size;
out property <color> textedit-background;
out property <color> textedit-text-color;
out property <color> textedit-background-disabled;
out property <color> textedit-text-color-disabled;
output property <bool> dark-color-scheme;
out property <bool> dark-color-scheme;
// specific to the Native one
output property <color> placeholder-color;
output property <color> placeholder-color-disabled;
out property <color> placeholder-color;
out property <color> placeholder-color-disabled;
// Tab Bar metrics:
output property <LayoutAlignment> tab-bar-alignment;
out property <LayoutAlignment> tab-bar-alignment;
//-is_non_item_type
//-is_internal

View file

@ -91,14 +91,13 @@ pub fn load_builtins(register: &mut TypeRegister) {
continue;
}
match (token.as_token().unwrap().text(), info.property_visibility) {
("input", PropertyVisibility::Private) => {
("in", PropertyVisibility::Private) => {
info.property_visibility = PropertyVisibility::Input
}
("output", PropertyVisibility::Private) => {
("out", PropertyVisibility::Private) => {
info.property_visibility = PropertyVisibility::Output
}
("input", PropertyVisibility::Output)
| ("output", PropertyVisibility::Input) => {
("in-out", PropertyVisibility::Private) => {
info.property_visibility = PropertyVisibility::InOut
}
("property", _) => (),

View file

@ -745,16 +745,14 @@ impl Element {
continue;
}
match (token.as_token().unwrap().text(), visibility) {
("input", None) => visibility = Some(PropertyVisibility::Input),
("input", Some(PropertyVisibility::Output)) => {
visibility = Some(PropertyVisibility::InOut)
("in", None) => visibility = Some(PropertyVisibility::Input),
("in", Some(_)) => diag.push_error("Extra 'in' keyword".into(), &token),
("out", None) => visibility = Some(PropertyVisibility::Output),
("out", Some(_)) => diag.push_error("Extra 'out' keyword".into(), &token),
("in-out" | "in_out", None) => visibility = Some(PropertyVisibility::InOut),
("in-out" | "in_out", Some(_)) => {
diag.push_error("Extra 'in-out' keyword".into(), &token)
}
("input", Some(_)) => diag.push_error("Extra 'input' keyword".into(), &token),
("output", None) => visibility = Some(PropertyVisibility::Output),
("output", Some(PropertyVisibility::Input)) => {
visibility = Some(PropertyVisibility::InOut)
}
("output", Some(_)) => diag.push_error("Extra 'output' keyword".into(), &token),
("private", None) => visibility = Some(PropertyVisibility::Private),
("private", Some(_)) => {
diag.push_error("Extra 'private' keyword".into(), &token)
@ -1233,7 +1231,7 @@ impl Element {
&& lookup_result.property_visibility == PropertyVisibility::Output
{
diag.push_warning(
format!("Assigning to output property '{unresolved_name}' is deprecated"),
format!("Assigning to out property '{unresolved_name}' is deprecated"),
&name_token,
);
} else {

View file

@ -61,11 +61,15 @@ pub fn parse_element_content(p: &mut impl Parser) {
SyntaxKind::Identifier | SyntaxKind::Star if p.peek().as_str() == "animate" => {
parse_property_animation(&mut *p);
}
SyntaxKind::LAngle if p.peek().as_str() == "property" => {
SyntaxKind::LAngle | SyntaxKind::Identifier if p.peek().as_str() == "property" => {
parse_property_declaration(&mut *p);
}
SyntaxKind::Identifier
if matches!(p.peek().as_str(), "property" | "input" | "output" | "private") =>
if p.nth(1).as_str() == "property"
&& matches!(
p.peek().as_str(),
"in" | "out" | "in_out" | "in-out" | "private"
) =>
{
parse_property_declaration(&mut *p);
}
@ -324,7 +328,7 @@ fn parse_callback_declaration(p: &mut impl Parser) {
#[cfg_attr(test, parser_test)]
/// ```test,PropertyDeclaration
/// input property <int> xxx;
/// in property <int> xxx;
/// property<int> foobar;
/// property<string> text: "Something";
/// property<string> text <=> two.way;
@ -333,7 +337,7 @@ fn parse_callback_declaration(p: &mut impl Parser) {
fn parse_property_declaration(p: &mut impl Parser) {
let checkpoint = p.checkpoint();
let mut reported_experimental = false;
while matches!(p.peek().as_str(), "input" | "output" | "private") {
while matches!(p.peek().as_str(), "in" | "out" | "in-out" | "in_out" | "private") {
if !reported_experimental && !super::enable_experimental() {
p.error("the input/output keywords are experimental, set `SLINT_EXPERIMENTAL_SYNTAX` env variable to enable experimental syntax. See https://github.com/slint-ui/slint/issues/1750");
}

View file

@ -4,9 +4,9 @@
component Compo inherits Rectangle {
property <int> priv1: 42;
private property <int> priv2: priv1;
output property <int> output1: priv2;
input property <int> input1: output1;
input output property <int> inout1: input1;
out property <int> output1: priv2;
in property <int> input1: output1;
in-out property <int> inout1: input1;
TouchArea {
clicked => {
@ -40,9 +40,9 @@ component Compo inherits Rectangle {
OldCompo := Rectangle {
property <int> inout2: 42;
private property <int> priv2: inout2;
output property <int> output1: priv2;
input property <int> input1: output1;
input output property <int> inout1: input1;
out property <int> output1: priv2;
in property <int> input1: output1;
in-out property <int> inout1: input1;
TouchArea {
clicked => {
@ -98,10 +98,5 @@ component Foo inherits Rectangle {
}
]
output input output property <int> extra1;
// ^error{Extra 'output' keyword}
input input property <int> extra2;
// ^error{Extra 'input' keyword}
}

View file

@ -4,9 +4,9 @@
component Compo inherits Rectangle {
property <int> priv1: 42;
private property <int> priv2: priv1;
output property <int> output1: priv2;
input property <int> input1: output1;
output input property <int> inout1: input1;
out property <int> output1: priv2;
in property <int> input1: output1;
in-out property <int> inout1: input1;
TouchArea {
clicked => {
@ -27,9 +27,9 @@ component Compo inherits Rectangle {
OldCompo := Rectangle {
property <int> inout2: 42;
private property <int> priv2: inout2;
output property <int> output1: priv2;
input property <int> input1: output1;
input output property <int> inout1: input1;
out property <int> output1: priv2;
in property <int> input1: output1;
in-out property <int> inout1: input1;
TouchArea {
clicked => {
@ -45,7 +45,7 @@ OldCompo := Rectangle {
// ^warning{Self assignment on an output property is deprecated}
}
has-hover: true;
// ^warning{Assigning to output property 'has-hover' is deprecated}
// ^warning{Assigning to out property 'has-hover' is deprecated}
}
}
@ -56,7 +56,7 @@ component A inherits Compo {
component Foo inherits Rectangle {
input property <[int]> input_model;
in property <[int]> input_model;
c1 := OldCompo {

View file

@ -525,9 +525,9 @@ SomeRect := Rectangle {
r#"
component Base {
property <int> a: 1;
input property <int> b: 2;
output property <int> c: 3;
input output property <int> d: 4;
in property <int> b: 2;
out property <int> c: 3;
in-out property <int> d: 4;
}
component MyComp {

View file

@ -17,11 +17,11 @@ pub(crate) fn fold_node(
.and_then(|n| n.parent())
.map_or(false, |n| n.kind() == SyntaxKind::Component)
{
// check that the first identifier is "property" as opposed to an already converted "input output" token
// check that the first identifier is "property" as opposed to an already converted "in-out" token
if node.child_token(SyntaxKind::Identifier).map_or(false, |t| t.text() == "property") {
// Consider that all property are input output, because we don't do enough analysis in the syntax_updater to know
// Consider that all property are in-out, because we don't do enough analysis in the syntax_updater to know
// if they should be private
write!(file, "input output ")?;
write!(file, "in-out ")?;
}
}
Ok(false)