mirror of
https://github.com/slint-ui/slint.git
synced 2025-07-13 08:05:19 +00:00

We currently forward declare classes as we use them in functions. But this breaks if classes with the same name were declared in the parent namespace. As shown with this example ```C++ // Uncomment that line to make the code break //struct SharedGlobals; namespace ns { // Is that a forward declaration in `ns`? // Depends if it was declared before in the parent namespace void foo(struct SharedGlobals *x) {} // Actualy define ns::SharedGlobal struct SharedGlobals { int x; }; int xyz() { SharedGlobals globals; foo(&globals); } } ``` So make sure we forward-declare the classes properly to be more robust and be able to include generated file with namespace after a file without namespace CC #2909
29 lines
691 B
Text
29 lines
691 B
Text
// Copyright © SixtyFPS GmbH <info@slint.dev>
|
|
// SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-Slint-Royalty-free-2.0 OR LicenseRef-Slint-Software-3.0
|
|
|
|
import {Button, AboutSlint} from "std-widgets.slint";
|
|
|
|
export global Logic {
|
|
callback decrement(int) -> int;
|
|
}
|
|
|
|
export struct FooBar {
|
|
qrs: int, tuv: string
|
|
}
|
|
|
|
|
|
export component AnotherWindow inherits Window {
|
|
preferred-width: 800px;
|
|
preferred-height: 600px;
|
|
property <int> count: 100;
|
|
in property<FooBar> xxx;
|
|
|
|
VerticalLayout {
|
|
AboutSlint { }
|
|
Button {
|
|
text: "Hello";
|
|
clicked => { count = Logic.decrement(count); }
|
|
}
|
|
Text { text: count; }
|
|
}
|
|
}
|