mirror of
https://github.com/slint-ui/slint.git
synced 2025-11-03 13:23:00 +00:00
Rename the sixtyfps-interpreter crate
This commit is contained in:
parent
cab22f8355
commit
2f73a27635
23 changed files with 83 additions and 83 deletions
2
.github/workflows/build_docs.yaml
vendored
2
.github/workflows/build_docs.yaml
vendored
|
|
@ -77,7 +77,7 @@ jobs:
|
||||||
with:
|
with:
|
||||||
command: doc
|
command: doc
|
||||||
toolchain: nightly
|
toolchain: nightly
|
||||||
args: -p sixtyfps -p sixtyfps-build -p sixtyfps-interpreter --no-deps --all-features
|
args: -p sixtyfps -p sixtyfps-build -p slint-interpreter --no-deps --all-features
|
||||||
- name: "Rust Tutorial Docs"
|
- name: "Rust Tutorial Docs"
|
||||||
run: mdbook build
|
run: mdbook build
|
||||||
working-directory: docs/tutorial/rust
|
working-directory: docs/tutorial/rust
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@ All notable changes to this project will be documented in this file.
|
||||||
|
|
||||||
This version changes some APIs in incompatible ways. For details how to migrate your application code, see the [C++ migration guide](api/cpp/docs/cpp_migration.md)
|
This version changes some APIs in incompatible ways. For details how to migrate your application code, see the [C++ migration guide](api/cpp/docs/cpp_migration.md)
|
||||||
as well as the [Rust migration guide for the `sixtyfps` crate](api/sixtyfps-rs/migration.md) and for the
|
as well as the [Rust migration guide for the `sixtyfps` crate](api/sixtyfps-rs/migration.md) and for the
|
||||||
[`sixtyfps-interpreter` crate](internal/interpreter/migration.rs).
|
[`slint-interpreter` crate](internal/interpreter/migration.rs).
|
||||||
|
|
||||||
### Changed
|
### Changed
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,7 @@ crate-type = ["lib", "cdylib"]
|
||||||
[features]
|
[features]
|
||||||
backend-gl = ["slint-backend-selector-internal/slint-backend-gl-internal"]
|
backend-gl = ["slint-backend-selector-internal/slint-backend-gl-internal"]
|
||||||
backend-qt = ["slint-backend-selector-internal/slint-backend-qt-internal"]
|
backend-qt = ["slint-backend-selector-internal/slint-backend-qt-internal"]
|
||||||
interpreter = ["sixtyfps-interpreter"]
|
interpreter = ["slint-interpreter"]
|
||||||
testing = ["slint-backend-testing-internal"] # Enable some function used by the integration tests
|
testing = ["slint-backend-testing-internal"] # Enable some function used by the integration tests
|
||||||
wayland = ["slint-backend-selector-internal/wayland"]
|
wayland = ["slint-backend-selector-internal/wayland"]
|
||||||
x11 = ["slint-backend-selector-internal/x11"]
|
x11 = ["slint-backend-selector-internal/x11"]
|
||||||
|
|
@ -33,7 +33,7 @@ default = ["backend-gl", "x11", "backend-qt"]
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
slint-core-internal = { version = "=0.2.0", path="../../internal/core", features = ["ffi"] }
|
slint-core-internal = { version = "=0.2.0", path="../../internal/core", features = ["ffi"] }
|
||||||
sixtyfps-interpreter = { version = "=0.2.0", path="../../internal/interpreter", default-features = false, features = ["ffi", "compat-0-2-0"], optional = true }
|
slint-interpreter = { version = "=0.2.0", path="../../internal/interpreter", default-features = false, features = ["ffi", "compat-0-2-0"], optional = true }
|
||||||
slint-backend-selector-internal = { version = "=0.2.0", path="../../internal/backends/selector" }
|
slint-backend-selector-internal = { version = "=0.2.0", path="../../internal/backends/selector" }
|
||||||
slint-backend-testing-internal = { version = "=0.2.0", path="../../internal/backends/testing", optional = true }
|
slint-backend-testing-internal = { version = "=0.2.0", path="../../internal/backends/testing", optional = true }
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -11,8 +11,8 @@ use slint_core_internal::window::WindowRc;
|
||||||
#[doc(hidden)]
|
#[doc(hidden)]
|
||||||
#[cold]
|
#[cold]
|
||||||
pub fn use_modules() -> usize {
|
pub fn use_modules() -> usize {
|
||||||
#[cfg(feature = "sixtyfps-interpreter")]
|
#[cfg(feature = "slint-interpreter")]
|
||||||
sixtyfps_interpreter::use_modules();
|
slint_interpreter::use_modules();
|
||||||
slint_backend_selector_internal::use_modules();
|
slint_backend_selector_internal::use_modules();
|
||||||
slint_core_internal::use_modules()
|
slint_core_internal::use_modules()
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,7 @@ name = "sixtyfps_node_native"
|
||||||
[dependencies]
|
[dependencies]
|
||||||
slint-compiler-internal = { version = "=0.2.0", path="../../../internal/compiler" }
|
slint-compiler-internal = { version = "=0.2.0", path="../../../internal/compiler" }
|
||||||
slint-core-internal = { version = "=0.2.0", path="../../../internal/core" }
|
slint-core-internal = { version = "=0.2.0", path="../../../internal/core" }
|
||||||
sixtyfps-interpreter = { version = "=0.2.0", path="../../../internal/interpreter", features = ["display-diagnostics"] }
|
slint-interpreter = { version = "=0.2.0", path="../../../internal/interpreter", features = ["display-diagnostics"] }
|
||||||
|
|
||||||
vtable = { version = "0.1.1", path="../../../helper_crates/vtable" }
|
vtable = { version = "0.1.1", path="../../../helper_crates/vtable" }
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -47,7 +47,7 @@ impl JsModel {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Model for JsModel {
|
impl Model for JsModel {
|
||||||
type Data = sixtyfps_interpreter::Value;
|
type Data = slint_interpreter::Value;
|
||||||
|
|
||||||
fn row_count(&self) -> usize {
|
fn row_count(&self) -> usize {
|
||||||
let r = Cell::new(0usize);
|
let r = Cell::new(0usize);
|
||||||
|
|
@ -68,7 +68,7 @@ impl Model for JsModel {
|
||||||
if row >= self.row_count() {
|
if row >= self.row_count() {
|
||||||
None
|
None
|
||||||
} else {
|
} else {
|
||||||
let r = Cell::new(sixtyfps_interpreter::Value::default());
|
let r = Cell::new(slint_interpreter::Value::default());
|
||||||
crate::run_with_global_context(&|cx, persistent_context| {
|
crate::run_with_global_context(&|cx, persistent_context| {
|
||||||
let row = JsNumber::new(cx, row as f64);
|
let row = JsNumber::new(cx, row as f64);
|
||||||
let obj = self.get_object(cx, persistent_context).unwrap();
|
let obj = self.get_object(cx, persistent_context).unwrap();
|
||||||
|
|
|
||||||
|
|
@ -4,17 +4,17 @@
|
||||||
use core::cell::RefCell;
|
use core::cell::RefCell;
|
||||||
use neon::prelude::*;
|
use neon::prelude::*;
|
||||||
use rand::RngCore;
|
use rand::RngCore;
|
||||||
use sixtyfps_interpreter::ComponentHandle;
|
|
||||||
use slint_compiler_internal::langtype::Type;
|
use slint_compiler_internal::langtype::Type;
|
||||||
use slint_core_internal::model::{Model, ModelRc};
|
use slint_core_internal::model::{Model, ModelRc};
|
||||||
use slint_core_internal::window::WindowHandleAccess;
|
use slint_core_internal::window::WindowHandleAccess;
|
||||||
use slint_core_internal::{ImageInner, SharedVector};
|
use slint_core_internal::{ImageInner, SharedVector};
|
||||||
|
use slint_interpreter::ComponentHandle;
|
||||||
|
|
||||||
mod js_model;
|
mod js_model;
|
||||||
mod persistent_context;
|
mod persistent_context;
|
||||||
|
|
||||||
struct WrappedComponentType(Option<sixtyfps_interpreter::ComponentDefinition>);
|
struct WrappedComponentType(Option<slint_interpreter::ComponentDefinition>);
|
||||||
struct WrappedComponentRc(Option<sixtyfps_interpreter::ComponentInstance>);
|
struct WrappedComponentRc(Option<slint_interpreter::ComponentInstance>);
|
||||||
struct WrappedWindow(Option<slint_core_internal::window::WindowRc>);
|
struct WrappedWindow(Option<slint_core_internal::window::WindowRc>);
|
||||||
|
|
||||||
/// We need to do some gymnastic with closures to pass the ExecuteContext with the right lifetime
|
/// We need to do some gymnastic with closures to pass the ExecuteContext with the right lifetime
|
||||||
|
|
@ -59,11 +59,11 @@ fn load(mut cx: FunctionContext) -> JsResult<JsValue> {
|
||||||
}
|
}
|
||||||
None => vec![],
|
None => vec![],
|
||||||
};
|
};
|
||||||
let mut compiler = sixtyfps_interpreter::ComponentCompiler::default();
|
let mut compiler = slint_interpreter::ComponentCompiler::default();
|
||||||
compiler.set_include_paths(include_paths);
|
compiler.set_include_paths(include_paths);
|
||||||
let c = spin_on::spin_on(compiler.build_from_path(path));
|
let c = spin_on::spin_on(compiler.build_from_path(path));
|
||||||
|
|
||||||
sixtyfps_interpreter::print_diagnostics(compiler.diagnostics());
|
slint_interpreter::print_diagnostics(compiler.diagnostics());
|
||||||
|
|
||||||
let c = if let Some(c) = c { c } else { return cx.throw_error("Compilation error") };
|
let c = if let Some(c) = c { c } else { return cx.throw_error("Compilation error") };
|
||||||
|
|
||||||
|
|
@ -77,12 +77,12 @@ fn make_callback_handler<'cx>(
|
||||||
persistent_context: &persistent_context::PersistentContext<'cx>,
|
persistent_context: &persistent_context::PersistentContext<'cx>,
|
||||||
fun: Handle<'cx, JsFunction>,
|
fun: Handle<'cx, JsFunction>,
|
||||||
return_type: Option<Box<Type>>,
|
return_type: Option<Box<Type>>,
|
||||||
) -> Box<dyn Fn(&[sixtyfps_interpreter::Value]) -> sixtyfps_interpreter::Value> {
|
) -> Box<dyn Fn(&[slint_interpreter::Value]) -> slint_interpreter::Value> {
|
||||||
let fun_value = fun.as_value(cx);
|
let fun_value = fun.as_value(cx);
|
||||||
let fun_idx = persistent_context.allocate(cx, fun_value);
|
let fun_idx = persistent_context.allocate(cx, fun_value);
|
||||||
Box::new(move |args| {
|
Box::new(move |args| {
|
||||||
let args = args.to_vec();
|
let args = args.to_vec();
|
||||||
let ret = core::cell::Cell::new(sixtyfps_interpreter::Value::Void);
|
let ret = core::cell::Cell::new(slint_interpreter::Value::Void);
|
||||||
let borrow_ret = &ret;
|
let borrow_ret = &ret;
|
||||||
let return_type = &return_type;
|
let return_type = &return_type;
|
||||||
run_with_global_context(&move |cx, persistent_context| {
|
run_with_global_context(&move |cx, persistent_context| {
|
||||||
|
|
@ -109,7 +109,7 @@ fn make_callback_handler<'cx>(
|
||||||
|
|
||||||
fn create<'cx>(
|
fn create<'cx>(
|
||||||
cx: &mut CallContext<'cx, impl neon::object::This>,
|
cx: &mut CallContext<'cx, impl neon::object::This>,
|
||||||
component_type: sixtyfps_interpreter::ComponentDefinition,
|
component_type: slint_interpreter::ComponentDefinition,
|
||||||
) -> JsResult<'cx, JsValue> {
|
) -> JsResult<'cx, JsValue> {
|
||||||
let component = component_type.create();
|
let component = component_type.create();
|
||||||
let persistent_context = persistent_context::PersistentContext::new(cx);
|
let persistent_context = persistent_context::PersistentContext::new(cx);
|
||||||
|
|
@ -157,8 +157,8 @@ fn to_eval_value<'cx>(
|
||||||
ty: slint_compiler_internal::langtype::Type,
|
ty: slint_compiler_internal::langtype::Type,
|
||||||
cx: &mut impl Context<'cx>,
|
cx: &mut impl Context<'cx>,
|
||||||
persistent_context: &persistent_context::PersistentContext<'cx>,
|
persistent_context: &persistent_context::PersistentContext<'cx>,
|
||||||
) -> NeonResult<sixtyfps_interpreter::Value> {
|
) -> NeonResult<slint_interpreter::Value> {
|
||||||
use sixtyfps_interpreter::Value;
|
use slint_interpreter::Value;
|
||||||
match ty {
|
match ty {
|
||||||
Type::Float32
|
Type::Float32
|
||||||
| Type::Int32
|
| Type::Int32
|
||||||
|
|
@ -242,11 +242,11 @@ fn to_eval_value<'cx>(
|
||||||
}
|
}
|
||||||
|
|
||||||
fn to_js_value<'cx>(
|
fn to_js_value<'cx>(
|
||||||
val: sixtyfps_interpreter::Value,
|
val: slint_interpreter::Value,
|
||||||
cx: &mut impl Context<'cx>,
|
cx: &mut impl Context<'cx>,
|
||||||
persistent_context: &persistent_context::PersistentContext<'cx>,
|
persistent_context: &persistent_context::PersistentContext<'cx>,
|
||||||
) -> NeonResult<Handle<'cx, JsValue>> {
|
) -> NeonResult<Handle<'cx, JsValue>> {
|
||||||
use sixtyfps_interpreter::Value;
|
use slint_interpreter::Value;
|
||||||
Ok(match val {
|
Ok(match val {
|
||||||
Value::Void => JsUndefined::new().as_value(cx),
|
Value::Void => JsUndefined::new().as_value(cx),
|
||||||
Value::Number(n) => JsNumber::new(cx, n).as_value(cx),
|
Value::Number(n) => JsNumber::new(cx, n).as_value(cx),
|
||||||
|
|
@ -466,7 +466,7 @@ declare_types! {
|
||||||
let component = cx.borrow(&this, |x| x.0.as_ref().map(|c| c.clone_strong()));
|
let component = cx.borrow(&this, |x| x.0.as_ref().map(|c| c.clone_strong()));
|
||||||
let component = component.ok_or(()).or_else(|()| cx.throw_error("Invalid type"))?;
|
let component = component.ok_or(()).or_else(|()| cx.throw_error("Invalid type"))?;
|
||||||
run_scoped(&mut cx,this.downcast().unwrap(), || {
|
run_scoped(&mut cx,this.downcast().unwrap(), || {
|
||||||
sixtyfps_interpreter::testing::send_mouse_click(&component, x, y);
|
slint_interpreter::testing::send_mouse_click(&component, x, y);
|
||||||
Ok(())
|
Ok(())
|
||||||
})?;
|
})?;
|
||||||
Ok(JsUndefined::new().as_value(&mut cx))
|
Ok(JsUndefined::new().as_value(&mut cx))
|
||||||
|
|
@ -478,7 +478,7 @@ declare_types! {
|
||||||
let component = cx.borrow(&this, |x| x.0.as_ref().map(|c| c.clone_strong()));
|
let component = cx.borrow(&this, |x| x.0.as_ref().map(|c| c.clone_strong()));
|
||||||
let component = component.ok_or(()).or_else(|()| cx.throw_error("Invalid type"))?;
|
let component = component.ok_or(()).or_else(|()| cx.throw_error("Invalid type"))?;
|
||||||
run_scoped(&mut cx,this.downcast().unwrap(), || {
|
run_scoped(&mut cx,this.downcast().unwrap(), || {
|
||||||
sixtyfps_interpreter::testing::send_keyboard_string_sequence(&component, sequence.into());
|
slint_interpreter::testing::send_keyboard_string_sequence(&component, sequence.into());
|
||||||
Ok(())
|
Ok(())
|
||||||
})?;
|
})?;
|
||||||
Ok(JsUndefined::new().as_value(&mut cx))
|
Ok(JsUndefined::new().as_value(&mut cx))
|
||||||
|
|
|
||||||
|
|
@ -26,7 +26,7 @@ of including them in Rust:
|
||||||
|
|
||||||
- The `.60` code is [inline in a macro](#the-60-code-in-a-macro).
|
- The `.60` code is [inline in a macro](#the-60-code-in-a-macro).
|
||||||
- The `.60` code in [external files compiled with `build.rs`](#the-60-code-in-external-files-is-compiled-with-buildrs)
|
- The `.60` code in [external files compiled with `build.rs`](#the-60-code-in-external-files-is-compiled-with-buildrs)
|
||||||
- The `.60` code is loaded dynamically at run-time from the file system, by using the [interpreter API](https://docs.rs/sixtyfps-interpreter/latest/sixtyfps_interpreter/).
|
- The `.60` code is loaded dynamically at run-time from the file system, by using the [interpreter API](https://docs.rs/slint-interpreter/latest/slint_interpreter/).
|
||||||
|
|
||||||
With the first two methods, the markup code is translated to Rust code and each component is turned into a Rust
|
With the first two methods, the markup code is translated to Rust code and each component is turned into a Rust
|
||||||
struct with functions. Use these functions to instantiate and show the component, and
|
struct with functions. Use these functions to instantiate and show the component, and
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,7 @@ homepage = "https://sixtyfps.io"
|
||||||
crate-type = ["cdylib"]
|
crate-type = ["cdylib"]
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
sixtyfps-interpreter = { path = "../../internal/interpreter" }
|
slint-interpreter = { path = "../../internal/interpreter" }
|
||||||
|
|
||||||
vtable = { version = "0.1.1", path="../../helper_crates/vtable" }
|
vtable = { version = "0.1.1", path="../../helper_crates/vtable" }
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@
|
||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
use wasm_bindgen::prelude::*;
|
use wasm_bindgen::prelude::*;
|
||||||
|
|
||||||
use sixtyfps_interpreter::ComponentHandle;
|
use slint_interpreter::ComponentHandle;
|
||||||
|
|
||||||
#[cfg(feature = "wee_alloc")]
|
#[cfg(feature = "wee_alloc")]
|
||||||
#[global_allocator]
|
#[global_allocator]
|
||||||
|
|
@ -60,7 +60,7 @@ pub async fn compile_from_string_with_style(
|
||||||
#[cfg(feature = "console_error_panic_hook")]
|
#[cfg(feature = "console_error_panic_hook")]
|
||||||
console_error_panic_hook::set_once();
|
console_error_panic_hook::set_once();
|
||||||
|
|
||||||
let mut compiler = sixtyfps_interpreter::ComponentCompiler::default();
|
let mut compiler = slint_interpreter::ComponentCompiler::default();
|
||||||
if !style.is_empty() {
|
if !style.is_empty() {
|
||||||
compiler.set_style(style)
|
compiler.set_style(style)
|
||||||
}
|
}
|
||||||
|
|
@ -105,7 +105,7 @@ pub async fn compile_from_string_with_style(
|
||||||
let filename_js = JsValue::from_str(&filename);
|
let filename_js = JsValue::from_str(&filename);
|
||||||
let (line, column) = d.line_column();
|
let (line, column) = d.line_column();
|
||||||
|
|
||||||
if d.level() == sixtyfps_interpreter::DiagnosticLevel::Error {
|
if d.level() == slint_interpreter::DiagnosticLevel::Error {
|
||||||
if !error_as_string.is_empty() {
|
if !error_as_string.is_empty() {
|
||||||
error_as_string.push_str("\n");
|
error_as_string.push_str("\n");
|
||||||
}
|
}
|
||||||
|
|
@ -132,7 +132,7 @@ pub async fn compile_from_string_with_style(
|
||||||
|
|
||||||
#[wasm_bindgen]
|
#[wasm_bindgen]
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
pub struct WrappedCompiledComp(sixtyfps_interpreter::ComponentDefinition);
|
pub struct WrappedCompiledComp(slint_interpreter::ComponentDefinition);
|
||||||
|
|
||||||
#[wasm_bindgen]
|
#[wasm_bindgen]
|
||||||
impl WrappedCompiledComp {
|
impl WrappedCompiledComp {
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
// SPDX-License-Identifier: (GPL-3.0-only OR LicenseRef-SixtyFPS-commercial)
|
// SPDX-License-Identifier: (GPL-3.0-only OR LicenseRef-SixtyFPS-commercial)
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
This module contains types that are public and re-exported in the sixtyfps-rs as well as the sixtyfps-interpreter crate as public API.
|
This module contains types that are public and re-exported in the sixtyfps-rs as well as the slint-interpreter crate as public API.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
use std::rc::Rc;
|
use std::rc::Rc;
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
# SPDX-License-Identifier: (GPL-3.0-only OR LicenseRef-SixtyFPS-commercial)
|
# SPDX-License-Identifier: (GPL-3.0-only OR LicenseRef-SixtyFPS-commercial)
|
||||||
|
|
||||||
[package]
|
[package]
|
||||||
name = "sixtyfps-interpreter"
|
name = "slint-interpreter"
|
||||||
version = "0.2.0"
|
version = "0.2.0"
|
||||||
authors = ["SixtyFPS <info@sixtyfps.io>"]
|
authors = ["SixtyFPS <info@sixtyfps.io>"]
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
|
|
|
||||||
|
|
@ -74,7 +74,7 @@ impl From<LangType> for ValueType {
|
||||||
/// [`From`] or [`TryInto`] traits to access the value.
|
/// [`From`] or [`TryInto`] traits to access the value.
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
/// # use sixtyfps_interpreter::*;
|
/// # use slint_interpreter::*;
|
||||||
/// use core::convert::TryInto;
|
/// use core::convert::TryInto;
|
||||||
/// // create a value containing an integer
|
/// // create a value containing an integer
|
||||||
/// let v = Value::from(100u32);
|
/// let v = Value::from(100u32);
|
||||||
|
|
@ -384,7 +384,7 @@ pub(crate) fn normalize_identifier(ident: &str) -> Cow<'_, str> {
|
||||||
///
|
///
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
/// # use sixtyfps_interpreter::*;
|
/// # use slint_interpreter::*;
|
||||||
/// use core::convert::TryInto;
|
/// use core::convert::TryInto;
|
||||||
/// // Construct a value from a key/value iterator
|
/// // Construct a value from a key/value iterator
|
||||||
/// let value : Value = [("foo".into(), 45u32.into()), ("bar".into(), true.into())]
|
/// let value : Value = [("foo".into(), 45u32.into()), ("bar".into(), true.into())]
|
||||||
|
|
@ -740,7 +740,7 @@ impl ComponentInstance {
|
||||||
/// ## Examples
|
/// ## Examples
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
/// use sixtyfps_interpreter::{ComponentDefinition, ComponentCompiler, Value, SharedString};
|
/// use slint_interpreter::{ComponentDefinition, ComponentCompiler, Value, SharedString};
|
||||||
/// let code = r#"
|
/// let code = r#"
|
||||||
/// MyWin := Window {
|
/// MyWin := Window {
|
||||||
/// property <int> my_property: 42;
|
/// property <int> my_property: 42;
|
||||||
|
|
@ -778,7 +778,7 @@ impl ComponentInstance {
|
||||||
/// ## Examples
|
/// ## Examples
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
/// use sixtyfps_interpreter::{ComponentDefinition, ComponentCompiler, Value, SharedString, ComponentHandle};
|
/// use slint_interpreter::{ComponentDefinition, ComponentCompiler, Value, SharedString, ComponentHandle};
|
||||||
/// use core::convert::TryInto;
|
/// use core::convert::TryInto;
|
||||||
/// let code = r#"
|
/// let code = r#"
|
||||||
/// MyWin := Window {
|
/// MyWin := Window {
|
||||||
|
|
@ -837,7 +837,7 @@ impl ComponentInstance {
|
||||||
/// ## Examples
|
/// ## Examples
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
/// use sixtyfps_interpreter::{ComponentDefinition, ComponentCompiler, Value, SharedString};
|
/// use slint_interpreter::{ComponentDefinition, ComponentCompiler, Value, SharedString};
|
||||||
/// let code = r#"
|
/// let code = r#"
|
||||||
/// global Glob := {
|
/// global Glob := {
|
||||||
/// property <int> my_property: 42;
|
/// property <int> my_property: 42;
|
||||||
|
|
@ -891,7 +891,7 @@ impl ComponentInstance {
|
||||||
/// ## Examples
|
/// ## Examples
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
/// use sixtyfps_interpreter::{ComponentDefinition, ComponentCompiler, Value, SharedString};
|
/// use slint_interpreter::{ComponentDefinition, ComponentCompiler, Value, SharedString};
|
||||||
/// use core::convert::TryInto;
|
/// use core::convert::TryInto;
|
||||||
/// let code = r#"
|
/// let code = r#"
|
||||||
/// export global Logic := {
|
/// export global Logic := {
|
||||||
|
|
|
||||||
|
|
@ -24,13 +24,13 @@ executor, such as the one provided by the `spin_on` crate
|
||||||
This example loads a `.60` dynamically from a path and show errors if any:
|
This example loads a `.60` dynamically from a path and show errors if any:
|
||||||
|
|
||||||
```rust
|
```rust
|
||||||
use sixtyfps_interpreter::{ComponentDefinition, ComponentCompiler, ComponentHandle};
|
use slint_interpreter::{ComponentDefinition, ComponentCompiler, ComponentHandle};
|
||||||
|
|
||||||
let mut compiler = ComponentCompiler::default();
|
let mut compiler = ComponentCompiler::default();
|
||||||
let definition =
|
let definition =
|
||||||
spin_on::spin_on(compiler.build_from_path("hello.60"));
|
spin_on::spin_on(compiler.build_from_path("hello.60"));
|
||||||
# #[cfg(feature="print_diagnostics")]
|
# #[cfg(feature="print_diagnostics")]
|
||||||
sixtyfps_interpreter::print_diagnostics(&compiler.diagnostics());
|
slint_interpreter::print_diagnostics(&compiler.diagnostics());
|
||||||
if let Some(definition) = definition {
|
if let Some(definition) = definition {
|
||||||
let instance = definition.create();
|
let instance = definition.create();
|
||||||
instance.run();
|
instance.run();
|
||||||
|
|
@ -40,7 +40,7 @@ if let Some(definition) = definition {
|
||||||
This example load a `.60` from a string and set some properties:
|
This example load a `.60` from a string and set some properties:
|
||||||
|
|
||||||
```rust
|
```rust
|
||||||
use sixtyfps_interpreter::{ComponentDefinition, ComponentCompiler, Value, SharedString, ComponentHandle};
|
use slint_interpreter::{ComponentDefinition, ComponentCompiler, Value, SharedString, ComponentHandle};
|
||||||
|
|
||||||
let code = r#"
|
let code = r#"
|
||||||
MyWin := Window {
|
MyWin := Window {
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,7 @@ name = "doctests"
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
slint-compiler-internal = { path = "../../internal/compiler", features = ["display-diagnostics"] }
|
slint-compiler-internal = { path = "../../internal/compiler", features = ["display-diagnostics"] }
|
||||||
sixtyfps-interpreter = { path = "../../internal/interpreter" }
|
slint-interpreter = { path = "../../internal/interpreter" }
|
||||||
sixtyfps = { path = "../../api/sixtyfps-rs" }
|
sixtyfps = { path = "../../api/sixtyfps-rs" }
|
||||||
|
|
||||||
lazy_static = "1.4.0"
|
lazy_static = "1.4.0"
|
||||||
|
|
|
||||||
|
|
@ -3,15 +3,15 @@
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
fn do_test(snippet: &str) -> Result<(), Box<dyn std::error::Error>> {
|
fn do_test(snippet: &str) -> Result<(), Box<dyn std::error::Error>> {
|
||||||
let mut compiler = sixtyfps_interpreter::ComponentCompiler::default();
|
let mut compiler = slint_interpreter::ComponentCompiler::default();
|
||||||
let component =
|
let component =
|
||||||
spin_on::spin_on(compiler.build_from_source(snippet.into(), Default::default()));
|
spin_on::spin_on(compiler.build_from_source(snippet.into(), Default::default()));
|
||||||
|
|
||||||
#[cfg(feature = "display-diagnostics")]
|
#[cfg(feature = "display-diagnostics")]
|
||||||
sixtyfps_interpreter::print_diagnostics(&compiler.diagnostics());
|
slint_interpreter::print_diagnostics(&compiler.diagnostics());
|
||||||
|
|
||||||
for d in compiler.diagnostics() {
|
for d in compiler.diagnostics() {
|
||||||
if d.level() == sixtyfps_interpreter::DiagnosticLevel::Error {
|
if d.level() == slint_interpreter::DiagnosticLevel::Error {
|
||||||
return Err(d.message().to_owned().into());
|
return Err(d.message().to_owned().into());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@ path = "main.rs"
|
||||||
name = "test-driver-interpreter"
|
name = "test-driver-interpreter"
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
sixtyfps-interpreter = { path = "../../../internal/interpreter", default-features = false, features = ["display-diagnostics", "compat-0-2-0"] }
|
slint-interpreter = { path = "../../../internal/interpreter", default-features = false, features = ["display-diagnostics", "compat-0-2-0"] }
|
||||||
slint-backend-testing-internal = { path = "../../../internal/backends/testing" }
|
slint-backend-testing-internal = { path = "../../../internal/backends/testing" }
|
||||||
|
|
||||||
itertools = "0.10"
|
itertools = "0.10"
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
// SPDX-License-Identifier: (GPL-3.0-only OR LicenseRef-SixtyFPS-commercial)
|
// SPDX-License-Identifier: (GPL-3.0-only OR LicenseRef-SixtyFPS-commercial)
|
||||||
|
|
||||||
use itertools::Itertools;
|
use itertools::Itertools;
|
||||||
use sixtyfps_interpreter::{DiagnosticLevel, Value, ValueType};
|
use slint_interpreter::{DiagnosticLevel, Value, ValueType};
|
||||||
use std::error::Error;
|
use std::error::Error;
|
||||||
|
|
||||||
pub fn test(testcase: &test_driver_lib::TestCase) -> Result<(), Box<dyn Error>> {
|
pub fn test(testcase: &test_driver_lib::TestCase) -> Result<(), Box<dyn Error>> {
|
||||||
|
|
@ -12,7 +12,7 @@ pub fn test(testcase: &test_driver_lib::TestCase) -> Result<(), Box<dyn Error>>
|
||||||
let include_paths = test_driver_lib::extract_include_paths(&source)
|
let include_paths = test_driver_lib::extract_include_paths(&source)
|
||||||
.map(std::path::PathBuf::from)
|
.map(std::path::PathBuf::from)
|
||||||
.collect::<Vec<_>>();
|
.collect::<Vec<_>>();
|
||||||
let mut compiler = sixtyfps_interpreter::ComponentCompiler::default();
|
let mut compiler = slint_interpreter::ComponentCompiler::default();
|
||||||
compiler.set_include_paths(include_paths);
|
compiler.set_include_paths(include_paths);
|
||||||
compiler.set_style(String::from("fluent")); // force to fluent style as Qt does not like multi-threaded test execution
|
compiler.set_style(String::from("fluent")); // force to fluent style as Qt does not like multi-threaded test execution
|
||||||
|
|
||||||
|
|
@ -21,7 +21,7 @@ pub fn test(testcase: &test_driver_lib::TestCase) -> Result<(), Box<dyn Error>>
|
||||||
|
|
||||||
let component = match component {
|
let component = match component {
|
||||||
None => {
|
None => {
|
||||||
sixtyfps_interpreter::print_diagnostics(&compiler.diagnostics());
|
slint_interpreter::print_diagnostics(&compiler.diagnostics());
|
||||||
|
|
||||||
match std::env::var("SIXTYFPS_INTERPRETER_ERROR_WHITELIST") {
|
match std::env::var("SIXTYFPS_INTERPRETER_ERROR_WHITELIST") {
|
||||||
Ok(wl) if !wl.is_empty() => {
|
Ok(wl) if !wl.is_empty() => {
|
||||||
|
|
|
||||||
|
|
@ -22,17 +22,17 @@ name = "sixtyfps-lsp"
|
||||||
path = "main.rs"
|
path = "main.rs"
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
sixtyfps-backend-gl = ["sixtyfps-interpreter/backend-gl"]
|
sixtyfps-backend-gl = ["slint-interpreter/backend-gl"]
|
||||||
sixtyfps-backend-qt = ["sixtyfps-interpreter/backend-qt"]
|
sixtyfps-backend-qt = ["slint-interpreter/backend-qt"]
|
||||||
wayland = ["sixtyfps-interpreter/wayland"]
|
wayland = ["slint-interpreter/wayland"]
|
||||||
x11 = ["sixtyfps-interpreter/x11"]
|
x11 = ["slint-interpreter/x11"]
|
||||||
|
|
||||||
default = ["sixtyfps-backend-qt", "sixtyfps-backend-gl", "x11"]
|
default = ["sixtyfps-backend-qt", "sixtyfps-backend-gl", "x11"]
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
slint-compiler-internal = { version = "=0.2.0", path = "../../internal/compiler"}
|
slint-compiler-internal = { version = "=0.2.0", path = "../../internal/compiler"}
|
||||||
slint-core-internal = { version = "=0.2.0", path = "../../internal/core"}
|
slint-core-internal = { version = "=0.2.0", path = "../../internal/core"}
|
||||||
sixtyfps-interpreter = { version = "=0.2.0", path = "../../internal/interpreter", default-features = false, features = ["compat-0-2-0"] }
|
slint-interpreter = { version = "=0.2.0", path = "../../internal/interpreter", default-features = false, features = ["compat-0-2-0"] }
|
||||||
slint-backend-selector-internal = { version = "=0.2.0", path="../../internal/backends/selector" }
|
slint-backend-selector-internal = { version = "=0.2.0", path="../../internal/backends/selector" }
|
||||||
|
|
||||||
clap = { version = "3.0.5", features=["derive", "wrap_help"] }
|
clap = { version = "3.0.5", features=["derive", "wrap_help"] }
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,7 @@ use clap::Parser;
|
||||||
|
|
||||||
use crate::lsp_ext::{Health, ServerStatusNotification, ServerStatusParams};
|
use crate::lsp_ext::{Health, ServerStatusNotification, ServerStatusParams};
|
||||||
|
|
||||||
use sixtyfps_interpreter::ComponentHandle;
|
use slint_interpreter::ComponentHandle;
|
||||||
|
|
||||||
#[derive(PartialEq)]
|
#[derive(PartialEq)]
|
||||||
enum RequestedGuiEventLoopState {
|
enum RequestedGuiEventLoopState {
|
||||||
|
|
@ -202,7 +202,7 @@ async fn reload_preview(
|
||||||
cache.current = preview_component.clone();
|
cache.current = preview_component.clone();
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut builder = sixtyfps_interpreter::ComponentCompiler::default();
|
let mut builder = slint_interpreter::ComponentCompiler::default();
|
||||||
let cli_args = super::Cli::parse();
|
let cli_args = super::Cli::parse();
|
||||||
if !cli_args.style.is_empty() {
|
if !cli_args.style.is_empty() {
|
||||||
builder.set_style(cli_args.style)
|
builder.set_style(cli_args.style)
|
||||||
|
|
@ -229,7 +229,7 @@ async fn reload_preview(
|
||||||
if let Some(compiled) = compiled {
|
if let Some(compiled) = compiled {
|
||||||
#[derive(Default)]
|
#[derive(Default)]
|
||||||
struct PreviewState {
|
struct PreviewState {
|
||||||
handle: Option<sixtyfps_interpreter::ComponentInstance>,
|
handle: Option<slint_interpreter::ComponentInstance>,
|
||||||
}
|
}
|
||||||
thread_local! {static PREVIEW_STATE: std::cell::RefCell<PreviewState> = Default::default();}
|
thread_local! {static PREVIEW_STATE: std::cell::RefCell<PreviewState> = Default::default();}
|
||||||
PREVIEW_STATE.with(|preview_state| {
|
PREVIEW_STATE.with(|preview_state| {
|
||||||
|
|
@ -256,7 +256,7 @@ async fn reload_preview(
|
||||||
}
|
}
|
||||||
|
|
||||||
fn notify_diagnostics(
|
fn notify_diagnostics(
|
||||||
diagnostics: &[sixtyfps_interpreter::Diagnostic],
|
diagnostics: &[slint_interpreter::Diagnostic],
|
||||||
sender: &crossbeam_channel::Sender<Message>,
|
sender: &crossbeam_channel::Sender<Message>,
|
||||||
) -> Option<()> {
|
) -> Option<()> {
|
||||||
let mut lsp_diags: HashMap<lsp_types::Url, Vec<lsp_types::Diagnostic>> = Default::default();
|
let mut lsp_diags: HashMap<lsp_types::Url, Vec<lsp_types::Diagnostic>> = Default::default();
|
||||||
|
|
|
||||||
|
|
@ -152,8 +152,8 @@ fn to_lsp_diag_level(
|
||||||
level: slint_compiler_internal::diagnostics::DiagnosticLevel,
|
level: slint_compiler_internal::diagnostics::DiagnosticLevel,
|
||||||
) -> lsp_types::DiagnosticSeverity {
|
) -> lsp_types::DiagnosticSeverity {
|
||||||
match level {
|
match level {
|
||||||
sixtyfps_interpreter::DiagnosticLevel::Error => lsp_types::DiagnosticSeverity::ERROR,
|
slint_interpreter::DiagnosticLevel::Error => lsp_types::DiagnosticSeverity::ERROR,
|
||||||
sixtyfps_interpreter::DiagnosticLevel::Warning => lsp_types::DiagnosticSeverity::WARNING,
|
slint_interpreter::DiagnosticLevel::Warning => lsp_types::DiagnosticSeverity::WARNING,
|
||||||
_ => lsp_types::DiagnosticSeverity::INFORMATION,
|
_ => lsp_types::DiagnosticSeverity::INFORMATION,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -14,16 +14,16 @@ categories = ["gui", "development-tools"]
|
||||||
keywords = ["viewer", "gui", "ui", "toolkit"]
|
keywords = ["viewer", "gui", "ui", "toolkit"]
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
sixtyfps-backend-gl = ["sixtyfps-interpreter/backend-gl"]
|
sixtyfps-backend-gl = ["slint-interpreter/backend-gl"]
|
||||||
sixtyfps-backend-qt = ["sixtyfps-interpreter/backend-qt"]
|
sixtyfps-backend-qt = ["slint-interpreter/backend-qt"]
|
||||||
wayland = ["sixtyfps-interpreter/wayland"]
|
wayland = ["slint-interpreter/wayland"]
|
||||||
x11 = ["sixtyfps-interpreter/x11"]
|
x11 = ["slint-interpreter/x11"]
|
||||||
|
|
||||||
default = ["sixtyfps-backend-qt", "sixtyfps-backend-gl", "x11"]
|
default = ["sixtyfps-backend-qt", "sixtyfps-backend-gl", "x11"]
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
slint-core-internal = { version = "=0.2.0", path="../../internal/core" }
|
slint-core-internal = { version = "=0.2.0", path="../../internal/core" }
|
||||||
sixtyfps-interpreter = { version = "=0.2.0", path = "../../internal/interpreter", default-features = false, features = ["display-diagnostics", "compat-0-2-0"] }
|
slint-interpreter = { version = "=0.2.0", path = "../../internal/interpreter", default-features = false, features = ["display-diagnostics", "compat-0-2-0"] }
|
||||||
slint-backend-selector-internal = { version = "=0.2.0", path="../../internal/backends/selector" }
|
slint-backend-selector-internal = { version = "=0.2.0", path="../../internal/backends/selector" }
|
||||||
|
|
||||||
vtable = { version = "0.1", path="../../helper_crates/vtable" }
|
vtable = { version = "0.1", path="../../helper_crates/vtable" }
|
||||||
|
|
|
||||||
|
|
@ -3,9 +3,9 @@
|
||||||
|
|
||||||
#![doc = include_str!("README.md")]
|
#![doc = include_str!("README.md")]
|
||||||
|
|
||||||
use sixtyfps_interpreter::{ComponentHandle, ComponentInstance, SharedString, Value};
|
|
||||||
use slint_core_internal::model::{Model, ModelRc};
|
use slint_core_internal::model::{Model, ModelRc};
|
||||||
use slint_core_internal::SharedVector;
|
use slint_core_internal::SharedVector;
|
||||||
|
use slint_interpreter::{ComponentHandle, ComponentInstance, SharedString, Value};
|
||||||
use std::future::Future;
|
use std::future::Future;
|
||||||
use std::pin::Pin;
|
use std::pin::Pin;
|
||||||
use std::sync::atomic::{AtomicU32, Ordering};
|
use std::sync::atomic::{AtomicU32, Ordering};
|
||||||
|
|
@ -78,7 +78,7 @@ fn main() -> Result<()> {
|
||||||
let mut compiler = init_compiler(&args, fswatcher);
|
let mut compiler = init_compiler(&args, fswatcher);
|
||||||
|
|
||||||
let c = spin_on::spin_on(compiler.build_from_path(args.path));
|
let c = spin_on::spin_on(compiler.build_from_path(args.path));
|
||||||
sixtyfps_interpreter::print_diagnostics(compiler.diagnostics());
|
slint_interpreter::print_diagnostics(compiler.diagnostics());
|
||||||
|
|
||||||
let c = match c {
|
let c = match c {
|
||||||
Some(c) => c,
|
Some(c) => c,
|
||||||
|
|
@ -102,19 +102,19 @@ fn main() -> Result<()> {
|
||||||
if let Some(data_path) = args.save_data {
|
if let Some(data_path) = args.save_data {
|
||||||
let mut obj = serde_json::Map::new();
|
let mut obj = serde_json::Map::new();
|
||||||
for (name, _) in c.properties() {
|
for (name, _) in c.properties() {
|
||||||
fn to_json(val: sixtyfps_interpreter::Value) -> Option<serde_json::Value> {
|
fn to_json(val: slint_interpreter::Value) -> Option<serde_json::Value> {
|
||||||
match val {
|
match val {
|
||||||
sixtyfps_interpreter::Value::Number(x) => Some(x.into()),
|
slint_interpreter::Value::Number(x) => Some(x.into()),
|
||||||
sixtyfps_interpreter::Value::String(x) => Some(x.as_str().into()),
|
slint_interpreter::Value::String(x) => Some(x.as_str().into()),
|
||||||
sixtyfps_interpreter::Value::Bool(x) => Some(x.into()),
|
slint_interpreter::Value::Bool(x) => Some(x.into()),
|
||||||
sixtyfps_interpreter::Value::Model(model) => {
|
slint_interpreter::Value::Model(model) => {
|
||||||
let mut res = Vec::with_capacity(model.row_count());
|
let mut res = Vec::with_capacity(model.row_count());
|
||||||
for i in 0..model.row_count() {
|
for i in 0..model.row_count() {
|
||||||
res.push(to_json(model.row_data(i).unwrap())?);
|
res.push(to_json(model.row_data(i).unwrap())?);
|
||||||
}
|
}
|
||||||
Some(serde_json::Value::Array(res))
|
Some(serde_json::Value::Array(res))
|
||||||
}
|
}
|
||||||
sixtyfps_interpreter::Value::Struct(st) => {
|
slint_interpreter::Value::Struct(st) => {
|
||||||
let mut obj = serde_json::Map::new();
|
let mut obj = serde_json::Map::new();
|
||||||
for (k, v) in st.iter() {
|
for (k, v) in st.iter() {
|
||||||
obj.insert(k.into(), to_json(v.clone())?);
|
obj.insert(k.into(), to_json(v.clone())?);
|
||||||
|
|
@ -141,8 +141,8 @@ fn main() -> Result<()> {
|
||||||
fn init_compiler(
|
fn init_compiler(
|
||||||
args: &Cli,
|
args: &Cli,
|
||||||
fswatcher: Option<Arc<Mutex<notify::RecommendedWatcher>>>,
|
fswatcher: Option<Arc<Mutex<notify::RecommendedWatcher>>>,
|
||||||
) -> sixtyfps_interpreter::ComponentCompiler {
|
) -> slint_interpreter::ComponentCompiler {
|
||||||
let mut compiler = sixtyfps_interpreter::ComponentCompiler::default();
|
let mut compiler = slint_interpreter::ComponentCompiler::default();
|
||||||
compiler.set_include_paths(args.include_paths.clone());
|
compiler.set_include_paths(args.include_paths.clone());
|
||||||
if let Some(style) = &args.style {
|
if let Some(style) = &args.style {
|
||||||
compiler.set_style(style.clone());
|
compiler.set_style(style.clone());
|
||||||
|
|
@ -223,7 +223,7 @@ fn start_fswatch_thread(args: Cli) -> Result<Arc<Mutex<notify::RecommendedWatche
|
||||||
async fn reload(args: Cli, fswatcher: Arc<Mutex<notify::RecommendedWatcher>>) {
|
async fn reload(args: Cli, fswatcher: Arc<Mutex<notify::RecommendedWatcher>>) {
|
||||||
let mut compiler = init_compiler(&args, Some(fswatcher));
|
let mut compiler = init_compiler(&args, Some(fswatcher));
|
||||||
let c = compiler.build_from_path(&args.path).await;
|
let c = compiler.build_from_path(&args.path).await;
|
||||||
sixtyfps_interpreter::print_diagnostics(compiler.diagnostics());
|
slint_interpreter::print_diagnostics(compiler.diagnostics());
|
||||||
|
|
||||||
if let Some(c) = c {
|
if let Some(c) = c {
|
||||||
CURRENT_INSTANCE.with(|current| {
|
CURRENT_INSTANCE.with(|current| {
|
||||||
|
|
@ -258,23 +258,23 @@ fn load_data(instance: &ComponentInstance, data_path: &std::path::Path) -> Resul
|
||||||
|
|
||||||
let obj = json.as_object().ok_or("The data is not a JSON object")?;
|
let obj = json.as_object().ok_or("The data is not a JSON object")?;
|
||||||
for (name, v) in obj {
|
for (name, v) in obj {
|
||||||
fn from_json(v: &serde_json::Value) -> sixtyfps_interpreter::Value {
|
fn from_json(v: &serde_json::Value) -> slint_interpreter::Value {
|
||||||
match v {
|
match v {
|
||||||
serde_json::Value::Null => sixtyfps_interpreter::Value::Void,
|
serde_json::Value::Null => slint_interpreter::Value::Void,
|
||||||
serde_json::Value::Bool(b) => (*b).into(),
|
serde_json::Value::Bool(b) => (*b).into(),
|
||||||
serde_json::Value::Number(n) => {
|
serde_json::Value::Number(n) => {
|
||||||
sixtyfps_interpreter::Value::Number(n.as_f64().unwrap_or(f64::NAN))
|
slint_interpreter::Value::Number(n.as_f64().unwrap_or(f64::NAN))
|
||||||
}
|
}
|
||||||
serde_json::Value::String(s) => SharedString::from(s.as_str()).into(),
|
serde_json::Value::String(s) => SharedString::from(s.as_str()).into(),
|
||||||
serde_json::Value::Array(array) => sixtyfps_interpreter::Value::Model(
|
serde_json::Value::Array(array) => slint_interpreter::Value::Model(ModelRc::new(
|
||||||
ModelRc::new(slint_core_internal::model::SharedVectorModel::from(
|
slint_core_internal::model::SharedVectorModel::from(
|
||||||
array.iter().map(from_json).collect::<SharedVector<Value>>(),
|
array.iter().map(from_json).collect::<SharedVector<Value>>(),
|
||||||
)),
|
|
||||||
),
|
),
|
||||||
|
)),
|
||||||
serde_json::Value::Object(obj) => obj
|
serde_json::Value::Object(obj) => obj
|
||||||
.iter()
|
.iter()
|
||||||
.map(|(k, v)| (k.clone(), from_json(v)))
|
.map(|(k, v)| (k.clone(), from_json(v)))
|
||||||
.collect::<sixtyfps_interpreter::Struct>()
|
.collect::<slint_interpreter::Struct>()
|
||||||
.into(),
|
.into(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue