Commit graph

1597 commits

Author SHA1 Message Date
Simon Hausmann
492af0f67c Rename the implementation of the Window item to WindowItem
If we were to add `sixtyfps:🪟:Window` to the re_exports, then
this clashes. We might rename the former, but this is a cleaner naming
in any case.

Relates to #333
2021-07-20 17:50:17 +02:00
Olivier Goffart
1360f1e26e Added icon property to the Window element 2021-07-20 16:34:19 +02:00
Olivier Goffart
f5de7e00a0 Make sure error messages don't end with '.'
As suggested in https://github.com/sixtyfpsui/sixtyfps/pull/275#issuecomment-881240725
2021-07-16 12:39:50 +02:00
Olivier Goffart
e633ee825d Fix error with struct that are only referenced by callbacks
We would have a compilation error in rust or C++ because the
collect_struct visitor would not visit these type and not produce
them correctly
2021-07-15 14:06:49 +02:00
Simon Hausmann
3aa959700c Revert "Attempt to fix a stack overflow in debug"
This reverts commit 51836a9457.

This is not needed anymore since PR #322
2021-07-15 12:20:01 +02:00
Simon Hausmann
42110263f6 Simplify field offset access workaround
As suggested by Olivier, we don't need the temporary variable. A ref followed
by immediate deref works just as well.
2021-07-15 12:19:20 +02:00
Simon Hausmann
aaf162d504 rust codegen: clarify comment about stack usage by referencing github issue 2021-07-15 12:19:20 +02:00
Simon Hausmann
30dbcdcaad rust generator: simplify field access code
There's no need for a separate access_self_field_offset function when
we can use format_ident directly.
2021-07-15 12:19:20 +02:00
Simon Hausmann
f7248a4863 Fix stack overflow with Rust generated code in debug builds on Windows
On Windows the default stack size is less than on Linux/macOS and
therefore an issues surfaces that is however operating system agnostic:

Due to inlining we generate quite big inner components with many fields.
Their field offsets are accumulated in the separate FIELD_OFFSETS
struct. The access pattern typically looks like this:

    Self::FIELD_OFFSETS.some_field.apply_pin(...)

This is destructed into at least two smaller operations, fetching
some_field and then calling apply_pin with that field as self parameter.

In Rust debug builds the first operation, unfortunately, ends up making
a full copy of Self::FIELD_OFFSETS into a temporary variable on the
stack. Unfortunately also that stack space isn't reused, so every access
results in a new stack allocation to hold all of the FIELD_OFFSETS
structure (~5kb in the printer demo).

With so many accesses to that in the generated code, we run out of stack
space already in the new() function, in item_tree() as well as in the
Drop impl that also accesses all field offsets.

This patch applies the following workaround that does the trick. The
above expression is replaced with

    {
        let field = &Self::FIELD_OFFSETS.some_field;
        *field
    }.apply_pin(...)

Fixes #133
2021-07-15 12:19:20 +02:00
Tobias Hunger
ca53abdbc7 Janitor: calls to push immediately after creation
This is clippy::vec_init_then_push.
2021-07-15 07:55:06 +02:00
Tobias Hunger
37619b8918 Janitor: OPTION.as_ref().map(String::as_str) == OPTION.as_deref()
This is clippy::option_as_ref_deref
2021-07-15 07:55:06 +02:00
Olivier Goffart
cc8249212d Fix name conflict when having two global with the same name in different files
Give globals an unique id so two global with the same name imported
from different file don't clash

Fixes #159
2021-07-13 14:36:38 +02:00
Olivier Goffart
cc7242c523 Add a selected callback to ComboBox 2021-07-13 11:42:31 +02:00
Olivier Goffart
7193cbeec1 Revert "C++ Fix struct with a field that has the same name as the struct itself"
This reverts commit 9e70e009a2.

This turns out to break CI

Changed the test not to use the same name for a field and the struct
2021-07-09 15:52:28 +02:00
Simon Hausmann
fcc71a3cce Fix image sizes not propagating into layouts when loading remotely
When images are loaded by the WASM-built interpreter, we do support
loading them asynchronously via the DOM. In that case we have a property
inside the HTMLImage in the GL backend that becomes dirty once loaded
and triggers re-evaluation of depending properties/layouts. However that
only works as long as uses of the image sizes are in property bindings.

BuiltinFunction::ImageSize however is marked as pure in the compiler, so
this may mean that something like this results in an initial assignment
instead of a binding:

    Image {
        source: ...
        height: source.height * 1px;
    }

For Rust, etc. that's fine, but when running in the WASM-built
interpreter the expression needs to remain in a binding. Therefore this
hack tries to narrow down this condition to wasm as target.
2021-07-09 14:56:02 +02:00
Olivier Goffart
9e70e009a2 C++ Fix struct with a field that has the same name as the struct itself 2021-07-09 14:37:42 +02:00
Olivier Goffart
6ed5044940 Fix rust compilation when using keywords in struct 2021-07-09 13:33:09 +02:00
Olivier Goffart
5c18e100b0 Fix unary operator + in rust 2021-07-09 12:52:18 +02:00
Tobias Hunger
08a6dc02fc Janitor: Find char, not a str 2021-07-08 20:43:38 +02:00
Tobias Hunger
bf48a6c65e Janitor: Remove some unnecessary returns 2021-07-08 20:43:38 +02:00
Tobias Hunger
63bc31aa44 Janitor: Remove unnecessary closure 2021-07-08 20:43:38 +02:00
Tobias Hunger
35dd3ed282 Janitor: Remove redundant clone() calls 2021-07-08 20:43:38 +02:00
Olivier Goffart
8e52b7d865 Fix bug that caused two way binding to sometimes disapear 2021-07-08 17:44:50 +02:00
Olivier Goffart
4604b70463 We need to collect the ressources in the root component 2021-07-07 19:45:50 +02:00
Olivier Goffart
a987b225b5 Collect all used components before inlining
And do some passes before inlining

We will need the list of components before inlining in order to generate
them if we disable inlining

So we can do some passes on each component before they are inlining

I tried to put the flickable pass in that list, but it did not work
if the Flickable itself is the root of a component
2021-07-07 17:58:43 +02:00
Olivier Goffart
920903ad19 Throw an error if there are duplicated id in a component 2021-07-07 12:31:40 +02:00
Olivier Goffart
c40a0bb5d6 passes: don't prefic the passes with passes::
the run function was moved to the passes module, so all passes are in scope
2021-07-07 11:49:42 +02:00
Olivier Goffart
f73a369786 cargo fmt 2021-07-07 11:04:50 +02:00
Olivier Goffart
8f75aadc70 Move the passes module to its own file
The main reason is that i don't like to edit files named lib.rs
because there are so many files with the same name
2021-07-07 10:48:28 +02:00
Tobias Hunger
e5bdeaa804 Janitor: Remove unnecessary & 2021-07-07 08:42:28 +02:00
Tobias Hunger
ac207428dc Janitor: CSpell fixes
Mark up some special words in documents (like C++ lingo in rust files).
2021-07-06 22:44:09 +02:00
Tobias Hunger
ac2d17e8e4 Janitor: Remove unnecessary format! 2021-07-06 22:34:21 +02:00
Tobias Hunger
c1c9e591f7 Janitor: Simplify if X.is_none() { return None } to X?; 2021-07-06 22:34:21 +02:00
Tobias Hunger
56885bd71d Janitor: Remove useless type conversion 2021-07-06 22:34:21 +02:00
Tobias Hunger
4d712b3f4f Janitor: Clippy suggests to collapse these ifs 2021-07-06 22:34:21 +02:00
Tobias Hunger
af0f193f1d Janitor: Fix clippy::if_same_then_else error
In this case this feels at controversial, but in general I find this
clippy lint pretty helpful: It has caught several copy-paste errors
before.

No behavior change is intended with this patch.
2021-07-06 21:28:36 +02:00
Olivier Goffart
67f0dc280f ptimized unused propery away
Currently, it is a bit limited in the amount of property that it removes
because it will not remove property that are used by properties being
removed, or will consider setting properties as an usage
2021-07-05 15:39:49 +02:00
Tobias Hunger
4be9ca7ffd Janitor: Remove useless () return types 2021-07-05 09:48:29 +02:00
Tobias Hunger
8b3eda8a49 Janitor: Remove some useless 'static that clippy does not like 2021-07-05 09:48:29 +02:00
Tobias Hunger
39984b27db Janitor: Fix spelling in comments 2021-07-03 15:49:43 +02:00
Simon Hausmann
3e55b0e8f8
Prospective cspell warning fix 2021-07-03 10:10:10 +02:00
Tobias Hunger
040c7735ec Dropping a reference does nothing
Is this what was actually intended here?
2021-07-03 09:43:07 +02:00
Olivier Goffart
13bd828b96 Update license date 2021-07-02 15:55:54 +02:00
Simon Hausmann
adeb192f6e C++ API: Make LinearGradientBrush and GradientStop private API 2021-07-02 15:34:16 +02:00
Olivier Goffart
c5312fd642 Ugly style: use a layout for the ComboBox
Then it is properly layed out and we can use the auto-wrap in the gallery example
2021-07-02 14:17:15 +02:00
Olivier Goffart
894a369737 C++: Fix warnings on windows
Unproperly escaped path with slashes
2021-07-01 13:50:27 +02:00
Olivier Goffart
35e20763a7 More replacement of &*std::begin with std::data
Complement the previous commit.
It is not ok to call *std::begin for an empty vector.

Also added a test for it.
2021-06-30 17:10:58 +02:00
Simon Hausmann
2662858a71 Fix assert with MSVC when deleting last item in C++ built printer demo
The generated code tries to compute the box layout info for an empty
repeater, where we end up calling `&*std::begin(cells)` and MSVC
asserts that this is dereferencing an invalid iterator. As Olivier spotted,
`std::data` comes to the assert-free rescue :-)
2021-06-30 17:03:28 +02:00
Olivier Goffart
ae114cf79d C++: don't re-export private symbol in the public API
Use the cbindgen_private namespace dirrectly from the generated code
2021-06-28 12:03:49 +02:00
Olivier Goffart
16ba23ae47 Move StateInfo to the private namespace 2021-06-28 11:23:44 +02:00