Commit graph

690 commits

Author SHA1 Message Date
Simon Hausmann
eddf176d49 llr cpp: Implement more of llr_compile_expression 2022-01-19 10:02:23 +01:00
Simon Hausmann
90e9829233 cpp llr: implement PropertyReference::Local 2022-01-19 10:02:23 +01:00
Simon Hausmann
62486ed41f Implement more of llr_compile_expression
* PropertyReference
 * BinaryExpression
 * Cast
2022-01-19 10:02:23 +01:00
Simon Hausmann
51d3376731 Begin generating basic property init expressions with the llr in C++ 2022-01-19 10:02:23 +01:00
Tobias Hunger
8150e5271d WIP: Make cpp.rs use LLR 2022-01-19 10:02:23 +01:00
Simon Hausmann
9f43b54fa6 Simplify llr::Expression::Condition
Remove the `Option` of the `false_expr` since it's always constructed as
`Some`.
2022-01-14 15:49:09 +01:00
Simon Hausmann
360a3c3b30 Re-evaluate bindings when data in models accessed via index expressions change
Call the new track_row_data_changes function in the model before
retrieving the data.
2022-01-14 13:38:25 +01:00
Olivier Goffart
d3a9437309 Support for writing in the model with the [] syntax 2022-01-14 13:38:25 +01:00
Simon Hausmann
f23b789a80 Fix Rust compilation of array indexing
Pass the array indexing through the llr.
2022-01-14 13:38:25 +01:00
James Blacklock
7ad1ba209d Add support for array index expressions
This is a squash of the changes in
https://github.com/sixtyfpsui/sixtyfps/pull/605
2022-01-14 13:38:25 +01:00
Simon Hausmann
5f97a3c39f Move EvaluationContext from the rust generator into the llr
For re-use in the C++ generator
2022-01-14 09:40:03 +01:00
Simon Hausmann
3692710b7b Fix CI and simplify Rust generator API
Return an empty token stream in case the document was empty.
2022-01-13 10:23:57 +01:00
Tobias Hunger
bf57f43157
rust: Do not check for empty file
This is already handled before calling rust::generate.
2022-01-12 19:11:02 +01:00
Olivier Goffart
f1ea2ccec4 Fix compilation in generated code when getting array lenght multiple times
We were moving a variable so it would cause an error in the rust generated code
2022-01-12 16:55:08 +01:00
Simon Hausmann
ab6c39f877 Remove unused diagnostics parameter from Rust generator 2022-01-12 16:22:35 +01:00
Olivier Goffart
bfa344415a LLR: Add back the index of first children in the runtime sub component
Using #component_id::item_tree for it does not work because the
public component id is not the right one, we need the one from
the current item tree which is not known at compile time
(could be several if the component is re-used accross item trees)

Also disable the code that sets the focus to the focued element for anything
but the window component: before, the setup code was only run for the
non-sub component, but now it is run for every sub component, and we
don't want to set the focus to anything that has a forward focus property
2022-01-12 16:22:35 +01:00
Olivier Goffart
eb50817185 LLR: rust generator for ShowPopup and cleanup 2022-01-12 16:22:35 +01:00
Simon Hausmann
c148dd076c Remove some old code from the rust generator that was commented out 2022-01-12 16:22:35 +01:00
Simon Hausmann
f843cb5c8f Fix crashes_issue_422_enclosing_component with rust/llr
Add support for `PropertyReference::InParent` in `access_item_rc`
2022-01-12 16:22:35 +01:00
Simon Hausmann
902f463f9f Simplify rust generated code slightly
Add a helper parent_index() function to ItemTreeNode to do the match in the
library crate instead of in the generated code.
2022-01-12 16:22:35 +01:00
Simon Hausmann
cc8ffe6497 Initial implementation of access_item_rc in the rust generator for llr
Otherwise this uses the trick of
InnnerCompo::item_tree()[self.tree_index] to retrieve the index of the
first children. This eliminates the tree_index_of_first_child member.

There are two test failures left:

One of them because accessing from within repeaters is not implemented
yet.

The second one because the self.tree_index of sub-components is not
calculated quite correctly yet when calling `init()`.
2022-01-12 16:22:35 +01:00
Olivier Goffart
c23d151d6d LLR: handle setup_code
Used to initialize the fonts and the initial focus
2022-01-12 16:22:35 +01:00
Olivier Goffart
1288951b9a LLR: set properties with animations 2022-01-12 16:22:35 +01:00
Olivier Goffart
242dfcf7cf Fix number to string conversion 2022-01-12 16:22:35 +01:00
Simon Hausmann
6e2f55e1b8 Fix calls to solve_path_layout
The function takes a reference to the `PathLayoutData` struct, which in
turn had a reference to the path data. The old rust generator had
special knowledge of calling solve_path_layout, so it knew to take a
reference of the path data.

In the llr there's no expression to take a reference. However since
PathData is cheap to move/copy (just holds SharedVector), we can pass it
by value (move) in the PathLayoutData.

This also means a copy in C++, which I *think* is safe, because the
constructor and destructor will be called on the C++ side, and the Rust
side still just operates on references or would try to move out a field
from the struct.
2022-01-12 16:22:35 +01:00
Olivier Goffart
0ea844a6dc LLR: Handle the Dialog properly
The cells needs to be stored in an intermediate mutable array
2022-01-12 16:22:35 +01:00
Olivier Goffart
1986cfe979 LLR: don't use a HashMap to store the component
because some keys can actually be duplicated in case of re-export with the same name
2022-01-12 16:22:35 +01:00
Simon Hausmann
44297bad24 Fix build of generated Rust code for path elements with the llr
* Move the C++ elements back into private_api (despite being generated), so that struct_name_to_tokens can generate the right name in re_exports
* When generating the llr_Expression::Struct for the path elements, make sure
  that all fields are filled out, to avoid an empty value expression in Expression::Struct
  in the Rust generator. Since we don't generate tuples but a named struct, we must provide all fields.
2022-01-12 16:22:35 +01:00
Simon Hausmann
31471fcf89 Complete path support in the llr / rust generator
This patch takes care of the lowering of events/coordinates arrays as
path data, which originates from a `commands: ...` string of SVG path
commands.

In order to minimize the path specific code in the generator, the
compile_paths now generates a Vec<Expression> for the events and
coordinates.
2022-01-12 16:22:35 +01:00
Olivier Goffart
6a8261366e llr: Fix compilation in the generated code 2022-01-12 16:22:35 +01:00
Olivier Goffart
8b15fc5ae4 LLR: Support for box layout with repeater 2022-01-12 16:22:35 +01:00
Olivier Goffart
07ea17fe71 LLR: Fix the repeater indices 2022-01-12 16:22:35 +01:00
Simon Hausmann
9e61d4168b Fix build of Paths with path elements with rust/llr
A `Path` with `MoveTo`/`LineTo`/etc. sub-elements now maps to an Expression::PathData of type
Type::PathData.

The llr lowering creates an Array of Type::PathElement, which is casted to PathData.

This only covers the element case. The compiled path events are still todo.
2022-01-12 16:22:35 +01:00
Olivier Goffart
50ff8304b0 WIP: start generating rust code from the LLR
WIP does not compile yet
most of the code is actually still commented out and needs to be ported
2022-01-12 16:22:35 +01:00
Tobias Hunger
4c331f1ac2
janitor: More clippy fixes
None of these should be controversial: It is all similar to quick fixes
I pushed before.
2022-01-09 14:50:58 +01:00
Tobias Hunger
79e2456ead Allow for bigger indices in VisitChildrenResult
The indexes stored in `VisitChildrenResult` are unsigned. We have 64
bits to store two values and we need to have one special value as a flag.

So accept any index `< u32::MAX` instead of `< i32::MAX`, which should
allow for more data to be visited;-)
2022-01-08 20:55:22 +01:00
Be
ab7403e57e allow FnMut as argument for on_callback 2022-01-08 03:09:28 +01:00
Jared Moulton
c5c139fbc9
Feat: Add math funcs Log10, Log2, Log and Exp (#813)
Implement Math.log and Math.pow
2022-01-07 12:07:58 +01:00
Tobias Hunger
3e448f75eb
janitor: Remove some unnecessary references
These are immediently dereferenced by the compiler according to clippy.

Remove some now unnecessary muts to make things build again.
2022-01-04 18:22:15 +01:00
Tobias Hunger
767704a88b
janitor: Remove some redundant closures 2022-01-04 18:21:07 +01:00
Tobias Hunger
d54e2a642a
Janitor: Change push_str of a one-char str to push 2022-01-04 09:39:41 +01:00
Tobias Hunger
e3eebfaa4a
janitor: Fix clippy error about duplicated branches in if 2022-01-03 14:37:49 +01:00
Tobias Hunger
bfca0e3573 Mass update copyright messages to be more REUSE compliant 2021-12-22 10:06:12 +01:00
Olivier Goffart
53775465dc
C++: add version macro
Fixes #705
2021-12-06 15:36:16 +01:00
Olivier Goffart
f27a2b8c74 Fix issues related to alias to globals
two problems
 - For the interpreter, properly handle the case of an alias to a global
 - For the rust generator, we can't return a reference to a property held
   in a global, so we must 'inline' the get_xx funciton on sub-components
2021-12-06 14:30:47 +01:00
Olivier Goffart
cd47ef1100 Mark properties that we know are never modified as constant,
so that we don't need to register dependencies when accessing them
2021-12-04 22:00:12 +01:00
Olivier Goffart
bc8d556799 Compiler: keep const-ness information of native property in the NativeClass 2021-12-04 22:00:12 +01:00
Olivier Goffart
a90013983b Add a way to debug the properties behind a configuration flag
I used a `#[cfg(..)]` instead of a feature flag because then it is enabled
for both the compiler and the lib at the same time, and since it is only a debug stuff
it does not need to be enabled within the project. So one must enable it with
`RUSTFLAGS='--cfg sixtyfps_debug_property'`
2021-12-04 22:00:12 +01:00
Olivier Goffart
0e174b6aba Start working on makeing the generated code no_std 2021-12-01 10:36:29 +01:00
Olivier Goffart
a201c31eaf Don't use Lazy to initialize the ITEM_TREE, use OnceBox instead
Lazy needs std
2021-12-01 10:36:29 +01:00