Commit graph

488 commits

Author SHA1 Message Date
Tobias Hunger
bf7b170044 Janitor: Fix clippy::comparison_to_empty 2021-07-22 14:10:46 +02:00
Simon Hausmann
3146fb7764 internal cleanup: Remove the sixtyfps::testing::HasWindow trait
and replace it with the internal, re-exported WindowHandleAccess
one.

Strictly speaking, this is a breaking change. In practice the
returned type of this trait was in `sixtyfps::re_exports`, so any
public use is questionable :)
2021-07-21 20:33:02 +02:00
Simon Hausmann
eaddbe664e internal cleanup: Rename ComponentWindow to WindowRc
That's all it is nowadays, it's a wrapper around Rc<Window>. It's not an
alias because we need to also "wrap" it to C++ via cbindgen, but that's
about it.
2021-07-21 20:33:02 +02:00
Simon Hausmann
ef184f7f1a internal cleanup: Remove the rest of the ComponentWindow API
Now it just remains a wrapper around the Rc, and it can soon be moved to
the API crate hopefully.
2021-07-21 17:41:12 +02:00
Simon Hausmann
77ea5b7a15 API cleanup: hide the rest of the ComponentWindow "internals" 2021-07-21 17:41:12 +02:00
Simon Hausmann
4c1d9dc03e internal cleanup: Remove the poup functions from ComponentWindow
Use WindowHandleAccess instead. Also the clone()
isn't needed anymore since the function take a self reference instead of an Rc<Self> by value.
2021-07-21 17:41:12 +02:00
Simon Hausmann
e005058285 internal cleanup: remove free_graphics_resource from the public ComponentWindow API
Use the WindowHandleAccess backdoor instead.
2021-07-21 17:41:12 +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
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
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
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
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
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
39984b27db Janitor: Fix spelling in comments 2021-07-03 15:49:43 +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
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
Olivier Goffart
daff9e8e65 Move Callback and internal Models to the private_api namespace 2021-06-28 11:23:44 +02:00
Tobias Hunger
13d7f5e7bd Janitor: Fix typos in comments and user-facing strings
Also adapt tests for error messages containing the fixed strings.

No behavior change is intended!
2021-06-28 08:32:25 +02:00
Tobias Hunger
87460c4ac8 Janitor: Fix typo in struct field name
No behavior change is intended here!
2021-06-28 08:32:00 +02:00
Tobias Hunger
1e30bea812 Janitor: Fix typo in thread-local variable name
No behavior change is intended here!
2021-06-28 08:32:00 +02:00
Simon Hausmann
66299437f0 Fix C++ build
The path types are now all in the private_api namespace
2021-06-21 15:50:58 +02:00
Simon Hausmann
fe59fb3ec3 C++: Hide sixtyfps::PathData from the public API 2021-06-21 15:50:58 +02:00
Simon Hausmann
51bc21c9a5 C++: Hide AbstractRepeaterView, Repeater and ModelPeer
These are not public API.
2021-06-21 15:50:58 +02:00
Simon Hausmann
7f8f1b3105 Hide Property<T> and PropertyTracker<T> from the public C++ API
Move those two classes into the private_api namespace, which is excluded
from the API reference documentation.

For generate code the explicit qualification of Property<T> is changed,
for the cbindgen generated item types the private_api namespace is
pulled into the cbindgen_private namespace.
2021-06-21 15:50:58 +02:00
Olivier Goffart
99c140ae08 Allow accessing the width and height of the image in .60
Closes #208
2021-06-21 11:22:50 +02:00
Olivier Goffart
a97bcd5ae1 Use BTreeMap unstead of HashMap to store the bindings
Because the order is important to keep deterministic error and output
2021-06-18 21:47:00 +02:00
Olivier Goffart
d758102f26 Make the orientation a static parameter to BuiltinFunction::ImplicitLayoutInfo 2021-06-16 15:14:07 +02:00
Olivier Goffart
cfc04bb4ab C++: adapt to the layout horizontal/vertical split 2021-06-16 15:14:07 +02:00
Olivier Goffart
7aba0f2a0b Layout split of horizontal/vertical
Rust part
2021-06-16 15:14:07 +02:00
Olivier Goffart
2483425d57 Add abs() 2021-06-11 14:17:47 +02:00
Olivier Goffart
ce34ff87d0 Finish support for callback aliases
cc #111
2021-06-07 20:40:36 +02:00
Olivier Goffart
142a8dc185 Rename ImageReference to ImageInner and make Immage.0 private 2021-05-28 17:05:16 +02:00
Olivier Goffart
0b3fecf300 WIP: API to expose image loading from C++ and Rust 2021-05-28 17:05:16 +02:00
Olivier Goffart
a1880bd943 Report an error when trying to convert from logical to physical coordinate in a global 2021-05-20 18:11:58 +02:00
Olivier Goffart
a79a4351b5 Be smarter at detecting the constant property and at not generating bindings
this implies that we need to make sure the property are initialized in
order so that constant properties that depends on other constant properties
are correctly computed
2021-05-20 13:40:51 +02:00
Olivier Goffart
ba1aff84d0 Layout refactoring: C++ part 2021-05-11 14:59:57 +02:00
Olivier Goffart
539a78e807 Rust: implement enough of PathLayout so that the tests passes
(does not implement the repeater case)
2021-05-11 14:59:57 +02:00