Commit graph

463 commits

Author SHA1 Message Date
Tobias Hunger
a387c0f60f Janitor: Fix clippy::needless_borrow 2021-08-18 00:24:51 +02:00
Olivier Goffart
c25538c982 Normalize identifiers to - instead of _
As a result
 - The error messages will now show the error with `-` instead of `_`
 - The LSP will auto-complete with -
 - The interpreter's list of properties will list the property with '-'
   (but we made the change so that set_property, get_property, and so on
   work also if passed a '-')
2021-08-10 22:21:01 +02:00
Tobias Hunger
c3ce321429 Janitor: Fix clippy::ptr_arg 2021-08-09 13:19:34 +02:00
Tobias Hunger
24a2021226 Janitor: Fix clippy::needless_borrow 2021-08-04 22:50:35 +02:00
Olivier Goffart
1dab4c35d9 For embedded data, store the extension in the binary
This is usefull for the detection of SVG
2021-08-03 16:15:31 +02:00
Simon Hausmann
29f5853332 Provide sixtyfps::Window by reference in the Rust API
This also removes Clone from the Window again, to avoid having to face
the question: Does cloning a window duplicate it on the screen?
2021-08-03 10:32:04 +02:00
Simon Hausmann
66891a299c Start a new sixtyfps::Window API for Rust, C++, the interpreters and JS
The generated component now provides access to a Window type
via the window() accessor function.

This is part of #333
2021-08-03 10:32:04 +02:00
Simon Hausmann
ee80d2e1bb Fix Image::load_from_path calls in generated Rust code
* Call unwrap() on the Result() returned by `load_from_path` to avoid `error[E0605]: non-primitive cast: `Result<Image, LoadImageError>` as `Image``

Tested manually with resource embedding disabled and compiling the memory game.
2021-08-02 18:39:23 +02:00
Olivier Goffart
2a74603bfa Another fixup 2021-08-02 18:31:46 +02:00
Olivier Goffart
1146cd1ae2 Another fixup 2021-08-02 18:29:03 +02:00
Olivier Goffart
9a07102345 Fixup previous commit 2021-08-02 18:27:16 +02:00
Simon Hausmann
53757331c7 Fix compilation of generated Rust code when not embedding images
We must construct a Path for `load_from_path`, not a SharedString.
2021-08-02 16:52:39 +02:00
Simon Hausmann
a6f3d91778 cleanup: Fix wording in the comment in the Rust code generator regarding the special return handling
Co-authored-by: Olivier Goffart <ogoffart@sixtyfps.io>
2021-08-02 16:32:33 +02:00
Simon Hausmann
fbf3c5fbd0 Minor reduction in generated Rust code (llvm lines)
When setting a constant, we only need to use a closure for the
expression if it contains a return statement.

This saves about ~14000 llvm lines for a debug build of the printer
demo.
2021-08-02 16:32:33 +02:00
Simon Hausmann
52aee8d366 Another minor reduction in generated code
Further build on b3529d1b75 and move the
strong/weak reference dance into the API crate out of the generated
code.

Saves ~21k llvm lines on the printer demo (debug).

It's also possible to move the as_pin_ref() bit, but that didn't
really give any savings overall.
2021-08-01 09:34:36 +02:00
Tobias Hunger
f9f05c3c58 Janitor: Fix clippy::map_clone 2021-07-30 09:27:48 +02:00
Simon Hausmann
b3529d1b75 Rust: Speed up compilation times of generated code
The binding setup functions (set_binding, set_animated_binding, etc.)
are taking the binding basically as an `impl Fn() -> T`, which means
each call site creates a new copy. The bodies of these can be quite big.
Since most of our uses follow the pattern of just capturing the
samereduce the number of copies needed parameter, we can reduce the
number of copies needed by providing wrappers.

With rustc 1.54.0 on my mbp and debug, the build time of

    touch ../ui/printerdemo.60
    cargo rustc

goes from 1m:15s down to 42s, and total llvm lines goes from
2079842 down to 1134237.
2021-07-30 09:22:20 +02:00
Simon Hausmann
3f716ae558 Reduce clippy warnings in generated code even more
... by ignoring all style and complexity related lints, since humans don't typically consume the generated code.

Co-authored-by: Olivier Goffart <ogoffart@sixtyfps.io>
2021-07-30 09:20:01 +02:00
Simon Hausmann
3aa0b7bb8d clippy: ignore warning about ref-deref for field-offset access
As per commit f7248a4863 this *is* a necessary thing for us to do.
2021-07-30 09:20:01 +02:00
Simon Hausmann
a2e800abac clippy: ignore single binding in match warning in generated visit_dynamic
This is a harmless warning affecting only readability, so apply it
to the whole module.
2021-07-30 09:20:01 +02:00
Simon Hausmann
11bc09f153 clippy: don't covert self_rc into... the same type in the new() function of generated code 2021-07-30 09:20:01 +02:00
Olivier Goffart
f38ce3c090 Fix the tests 2021-07-29 18:25:23 +02:00
Olivier Goffart
01f11695a7 Properly merge the animation when inlining and removing aliases
Fix #193
Fix #345
2021-07-23 15:25:53 +02:00
Olivier Goffart
ba32777cab Refactoring: move the animation in the PropertyBinding struct
Since they always belong together.

This will help for issue #193
2021-07-23 15:25:53 +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
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
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
Olivier Goffart
13bd828b96 Update license date 2021-07-02 15:55:54 +02:00
Olivier Goffart
16ba23ae47 Move StateInfo to the private 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
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
d758102f26 Make the orientation a static parameter to BuiltinFunction::ImplicitLayoutInfo 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