Commit graph

1174 commits

Author SHA1 Message Date
Simon Hausmann
99644a741a Enable write access to models initialized from arrays in the interpreter
A model property such as

    property <[Foo]> model: [ ... ];

would create a VecModel in Rust and C++, which in turn can be written to
with an array index expression in .60. If the same .60 code was running
in the interpreter, a Value::Array would be created instead. We don't
support writing into Value::Array by index because we don't have
tracking in place for that, to update dependent bindings.

To fix this inconsistency, this patch changes the interpreter to
allocate a mutable VecModel as well.
2022-01-26 16:24:29 +01:00
Simon Hausmann
a6d4fa39a9 Fix support for round-tripping models in the node API
We can pass custom JS-written models into the interpreter, and with this patch we can also get the out again,
instead of causing a panic.
2022-01-26 16:24:29 +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
Olivier Goffart
e2ec76f9ef We don't need the resolver=2 with edition 2021 2022-01-25 11:40:11 +01:00
Olivier Goffart
a45dcc1f9a Update to edition 2021
The ffi function wrapper need to be changed because in the 2021 edition, when
the capture is moved into the closure, it moves the individual field instead
of the whole wrapper. But we need to move the whole wrapper because the Drop
of the wrapper will delete the C++ closure, and we don't want to call the
closure after it is deleted.
2022-01-25 11:40:11 +01:00
Simon Hausmann
670f9b5c50 Polish the C++ and Rust requirements intro paragraph a little 2022-01-24 19:51:05 +01:00
Simon Hausmann
249854c8f2 Start a migration guide for C++ API for 0.2.0
Once we have a Rust incompatible change we can change the sentencen in the ChangeLog to link to the Rust guide, too.
2022-01-24 19:51:05 +01:00
Olivier Goffart
319704d3fb C++: use default operator==
Since we now use C++20, we can simplify our code a bit
2022-01-24 17:16:55 +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
Olivier Goffart
973c5960b7 C++ interpreter: Use std::span instead of the internal Slice in the public API 2022-01-24 13:04:12 +01:00
Olivier Goffart
d0b3adeba9 Requires C++20 2022-01-24 13:04:12 +01:00
Olivier Goffart
6babb73136 Update the MSRV to 1.56, and test the generated code with edition 2021 2022-01-24 13:01:59 +01:00
ogoffart
42f1964e54 Bump version number to 0.2.0 2022-01-24 11:39:50 +01:00
Simon Hausmann
314b3bccb1 Fix version show in C++ docs 2022-01-21 11:03:55 +01:00
Olivier Goffart
c3f624d2fd Version updates 2022-01-21 09:33:16 +01:00
Olivier Goffart
6624a5da85 The generated code use VWeakMapped::default() which was added recently 2022-01-21 08:47:31 +01:00
Tobias Hunger
0063476aff Update license information
Use the reuse tool to get a better grip on licenses used in sixtyfps.
Fix a couple of licenses along the way.

* Uses creative commons for our own logo (commercial use!)
* Fixes some license information found in README files and documents
  them with proper .license files.
* Document Apache/MIT for helper_crates/const-field-offset which matches
  what its documentaion site says it uses.
* Add a list of licenses that apply to crates we publish and the tooling
  we have.

This patch only adds static information and does not contain any tooling
support.
2022-01-20 14:45:02 +01:00
Simon Hausmann
5248468c74 cpp docs: Remove red error message in online docs
Don't try to offer a preview for .60 markup that just shows struct syntax.
2022-01-20 11:29:10 +01:00
Simon Hausmann
5ae41f0b87 Fix links to C++ types in the C++ type mapping documentation
closes #852
2022-01-20 11:27:39 +01:00
Olivier Goffart
a91e298866 Update corrosion 2022-01-20 09:41:45 +01:00
Olivier Goffart
abdcc77650 Update corrosion 2022-01-20 07:52:19 +01:00
Tobias Hunger
68b4d4065b Keep LICENSE.md file but install LICENSES folder 2022-01-19 11:25:21 +01:00
Tobias Hunger
0fc176a408 Document some licenses in a REUSE compliant way 2022-01-19 11:25:21 +01:00
Tobias Hunger
2f6be7b31f Mass-add copyright headers into Cargo.toml files 2022-01-19 11:25:21 +01:00
Olivier Goffart
f9f90e1b4e C++: Do not expose private types in the sixtyfps namespace 2022-01-19 11:19:47 +01:00
Olivier Goffart
99adc25a81 llr-cpp: Fix for within layout 2022-01-19 10:02:23 +01:00
Olivier Goffart
d62b788829 C++: Do wrapper to the layout function
That returns and take their argument in a C++-like way instead of by pointer.
2022-01-19 10:02:23 +01:00
Simon Hausmann
6e3fcd1b08 Add row data tracking to C++ sixtyfps::Model
This works the same way as in the Rust model notify.
2022-01-14 13:38:25 +01:00
Simon Hausmann
43830ccd78 Add insert to C++ VecModel 2022-01-14 13:38:25 +01:00
Olivier Goffart
3e264fc7f6 C++: Add new generated files to the list of installed headers 2022-01-13 14:05:23 +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
Simon Hausmann
ab6c39f877 Remove unused diagnostics parameter from Rust generator 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
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
Tobias Hunger
7bba5c4e31 janitor: Fix warning when building C++ tooling
Replace `std::array::IntoIter::new(...)` with
`IntoIterator::into_iter(...)` as suggested by the compiler.
2022-01-12 12:31:15 +01:00
Simon Hausmann
6acfa53f3e Link to the sixtyfps interpreter crate from the Rust API crate
Our web site and READMEs direct to our Rust API crate, which makes sense as it provides
fundamental traits and types. However as pointed out in
#811 we should advertise the existence of the interpreter API.

Ideally we'd link to the crate documentation that

    (1) perfect matches the version number
    (2) uses sixtyfps.io for our built docs and docs.rs for the published crates

I could not find a way to do this (not without making the crate a dependency and adding features), so
this patch is a compromise that I've seen used in other
crates.
2022-01-11 11:24:18 +01:00
Tobias Hunger
ac8f7b4957 janitor: Sprinkle #[must_use] over the codebase 2022-01-09 13:46:33 +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
Olivier Goffart
a751d000db Add a bunch of categories and keywords in some of our Cargo.toml 2022-01-07 17:14:07 +01:00
Simon Hausmann
aadb755fd7 Join separated documentation for some interpreter C++ API types
The docs were living in the public header file while the enums/structs were defined in Rust.
With the infrastructure of the parent commits we can join them together.
2022-01-05 16:32:55 +01:00
Simon Hausmann
dc387553ba Centralize the C++ sixtyfps version macros in the generated public header file 2022-01-05 16:32:55 +01:00
Simon Hausmann
174fd2659f Remove some duplication in the documentation of API that's shared between Rust and C++
This change makes the start of sharing the docs for the `TimerMode` enum
between Rust and C++. The reference to Timer::start in there works as
both doxygen and rustdoc find the right reference, but this needs
careful editing in the future and double-checking!

Another "caveat" is that the docs for the TimerMode enum say that the
enum is defined in the file "sixtyfps_generated_public.h", which is
correct as-is but not as pretty as "sixtyfps.h". I tried various ways
with \file and \includedoc, but couldn't get it working differently.

To implement this, the cppdocs steps now also runs cbindgen and cbindgen
generates a new sixtyfps_generated_public.h file that contains types we
do want to have in the public sixtyfps namespace.
2022-01-05 16:32:55 +01:00
Simon Hausmann
083ae5692b Fix the Rust/C++ Timer API to be more convenient to use
Allow calling restart() on a repeated timer if it has been previously stopped.
2022-01-05 13:26:28 +01:00
Simon Hausmann
f557a27556 Complete the C++ Timer API
With this patch it matches the Rust API, with start(), restart(), running() and
a default constructor.
2022-01-05 12:10:29 +01:00
Tobias Hunger
2b222457ef
janitor: Remove some unnecessary to_string() calls 2022-01-04 18:23:02 +01:00
Tobias Hunger
6d69c343dc
Revert "Deduplicate use of ptr_eq for Models"
This was not intended to get uploaded without review!

This reverts commit d678f4b1da.
2022-01-03 17:10:27 +01:00
Tobias Hunger
d678f4b1da
Deduplicate use of ptr_eq for Models 2022-01-03 16:22:32 +01:00
Simon Hausmann
eb88e77ee9 Some polish to the Rust crate docs
* Improve headings and linkage
* Replace "you can use XXX to YYY" with "Use XXX to YYY"
* In the limitation about exported components, link to the tracking
issue.
2022-01-02 20:19:29 +01:00
Tobias Hunger
597467fae9 Manually update license information in Cargo.toml files
... that are not published or private or not processed by xtask for
other reasons.
2021-12-22 10:06:12 +01:00