Commit graph

470 commits

Author SHA1 Message Date
Tobias Hunger
e6b24bceec [reorg]: Set up and populate the internal directory
Move "internal" crates into the `internal` directory. This first batch
includes most of sixtyfps_runtime but leaves the rendering backends
alone for now.

pre-commit applied some cleanups to the moved files:
 - Consistent newline at end of file policy
 - trimming trailing whitespace
 - Formatting Cargo.toml files.
2022-01-31 16:00:50 +01:00
Olivier Goffart
929166f06c Change what is accepted by ModelRc::new and ModelRc::from
- ModelRc::new constructs a ModelRc from a impl Model
 - ModelRc::form constructs a ModelRc from a `Rc<dyn Model>` or `Rc<impl Model>`
2022-01-31 14:44:35 +01:00
Tobias Hunger
018c1a6666 Rename ModelHandle to SharedModel
This patch is mostly a rename now, but also contains a few small
cleanups.

SharedModel implements the Model trait itself and gracefully falls back
to an empty model is no Model was provided. This allows for some small
simplifications.

Also make sure to use the same comparision for SharedModels everywhere.
This fixes the last remaining clippy errors we had.
2022-01-30 01:26:35 +01:00
Olivier Goffart
2e10b41b64 Janitor: Fix warning about non-existing lint 2022-01-28 15:33:12 +01:00
Tobias Hunger
9e03d9b718
clippy: Silence clippy errors in generated code
Silence `erasing_op` and `clippy::approx_constant`.

Properly fixing the first would require more branches in the code
generator -- which seems useless.

The latter can be caused by input .60 code, so there is nothing we can
do to fix that!
2022-01-28 08:24:39 +01:00
Tobias Hunger
e3c4209b1f
Change Model::row_data to return an Option<T> (#873)
Change Model::row_data to return an Option<T> (rust) or std::optional<T> (c++)

Co-authored-by: Olivier Goffart <olivier@woboq.com>
Co-authored-by: Simon Hausmann <hausmann@gmail.com>
2022-01-26 13:55:38 +01:00
Simon Hausmann
36e07b8801 Make it possible to use a string binding for Path commands
This was requested a few days ago in the chat and might also present an alternative for #754
2022-01-24 15:59:49 +01:00
Simon Hausmann
1bacaee68b Fix stack usage on Windows with Rust debug builds
Re-apply commit f7248a4863 to the updated code generator.

This fixes running the gallery on Windows in debug builds with the fluent style.
2022-01-19 16:22:03 +01:00
Tobias Hunger
fb3d5ef263 LLR-C++: Implement ShowPopupWindow 2022-01-19 10:02:23 +01:00
Tobias Hunger
638326cb39 Remove useless comment 2022-01-19 10:02:23 +01:00
Simon Hausmann
f691d91c06 Fix failing rust test
The Close{} element now has a C++ type name, but in the Rust generator we're
not interesting in using that
since PathElement::Close is without fields.
2022-01-19 10:02:23 +01:00
Olivier Goffart
0259c0dc9b Give a return type to llr::Expression::ExtraBuiltinFunctionCall
Some code in the C++ generator needs the type of such expressions
2022-01-19 10:02:23 +01:00
Olivier Goffart
b36de552e5 Pass the Padding by value in the layout data struct
It can simply be a Copy type anyway.
So there is no more special code needed in the rust (and also in C++) generator for it
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
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
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
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
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