Some docs regarding the last model changes in the interpreter

This commit is contained in:
Olivier Goffart 2022-01-27 13:48:45 +01:00 committed by Olivier Goffart
parent 02bfdda0e3
commit 653e7d0c5d
5 changed files with 38 additions and 23 deletions

View file

@ -10,27 +10,7 @@ In version 0.2.0 we have increased the minimum version of C++. You need to have
If you are building SixtyFPS from source, you need to make sure that your Rust installation is up-to-date. If you have installed Rust using `rustup`, then you can upgrade to the latest Version of Rust by running `rustup update`.
### C++ Interpreter API
#### Callbacks
Callbacks declared in `.60` markup can be invoked from C++ using {cpp:func}`sixtyfps::interpreter::ComponentInstance::invoke_callback()` or {cpp:func}`sixtyfps::interpreter::ComponentInstance::invoke_global_callback()`. The arguments to the callback at invocation time used to require the use of `sixtyfps::Slice` type. This was changed to use the C++ 20 [`std::span`](https://en.cppreference.com/w/cpp/container/span) type, for easier passing.
Old code:
```cpp
sixtyfps::Value args[] = { SharedString("Hello"), 42. };
instance->invoke_callback("foo", sixtyfps::Slice{ args, 2 });
```
New code:
```cpp
sixtyfps::Value args[] = { SharedString("Hello"), 42. };
instance->invoke_callback("foo", args);
```
#### Models
### Models
`Model::row_data` returns now a `std::optional<ModelData>` and can thus be used with indices that are out of bounds.
@ -54,3 +34,28 @@ if (value.has_value()) {
// row index 2 is out of bounds
}
```
### C++ Interpreter API
#### Callbacks
Callbacks declared in `.60` markup can be invoked from C++ using {cpp:func}`sixtyfps::interpreter::ComponentInstance::invoke_callback()` or {cpp:func}`sixtyfps::interpreter::ComponentInstance::invoke_global_callback()`. The arguments to the callback at invocation time used to require the use of `sixtyfps::Slice` type. This was changed to use the C++ 20 [`std::span`](https://en.cppreference.com/w/cpp/container/span) type, for easier passing.
Old code:
```cpp
sixtyfps::Value args[] = { SharedString("Hello"), 42. };
instance->invoke_callback("foo", sixtyfps::Slice{ args, 2 });
```
New code:
```cpp
sixtyfps::Value args[] = { SharedString("Hello"), 42. };
instance->invoke_callback("foo", args);
```
#### Models
The `Value::Type::Array` has been replaced by `Value::Type::Model`