diff --git a/.github/workflows/build_docs.yaml b/.github/workflows/build_docs.yaml index 1ee28869fd4..0b29a097bfc 100644 --- a/.github/workflows/build_docs.yaml +++ b/.github/workflows/build_docs.yaml @@ -77,7 +77,7 @@ jobs: with: command: doc 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" run: mdbook build working-directory: docs/tutorial/rust diff --git a/CHANGELOG.md b/CHANGELOG.md index 28f38341241..7840029f251 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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) 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 diff --git a/api/cpp/Cargo.toml b/api/cpp/Cargo.toml index bc7fd5f8771..093ecf7423c 100644 --- a/api/cpp/Cargo.toml +++ b/api/cpp/Cargo.toml @@ -24,7 +24,7 @@ crate-type = ["lib", "cdylib"] [features] backend-gl = ["slint-backend-selector-internal/slint-backend-gl-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 wayland = ["slint-backend-selector-internal/wayland"] x11 = ["slint-backend-selector-internal/x11"] @@ -33,7 +33,7 @@ default = ["backend-gl", "x11", "backend-qt"] [dependencies] 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-testing-internal = { version = "=0.2.0", path="../../internal/backends/testing", optional = true } diff --git a/api/cpp/lib.rs b/api/cpp/lib.rs index b84f7f9b5d9..d77f0635ae8 100644 --- a/api/cpp/lib.rs +++ b/api/cpp/lib.rs @@ -11,8 +11,8 @@ use slint_core_internal::window::WindowRc; #[doc(hidden)] #[cold] pub fn use_modules() -> usize { - #[cfg(feature = "sixtyfps-interpreter")] - sixtyfps_interpreter::use_modules(); + #[cfg(feature = "slint-interpreter")] + slint_interpreter::use_modules(); slint_backend_selector_internal::use_modules(); slint_core_internal::use_modules() } diff --git a/api/node/native/Cargo.toml b/api/node/native/Cargo.toml index aff802a6eb7..454bf68d47c 100644 --- a/api/node/native/Cargo.toml +++ b/api/node/native/Cargo.toml @@ -22,7 +22,7 @@ name = "sixtyfps_node_native" [dependencies] slint-compiler-internal = { version = "=0.2.0", path="../../../internal/compiler" } 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" } diff --git a/api/node/native/js_model.rs b/api/node/native/js_model.rs index cdbecd4b5be..54ef354052a 100644 --- a/api/node/native/js_model.rs +++ b/api/node/native/js_model.rs @@ -47,7 +47,7 @@ impl JsModel { } impl Model for JsModel { - type Data = sixtyfps_interpreter::Value; + type Data = slint_interpreter::Value; fn row_count(&self) -> usize { let r = Cell::new(0usize); @@ -68,7 +68,7 @@ impl Model for JsModel { if row >= self.row_count() { None } 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| { let row = JsNumber::new(cx, row as f64); let obj = self.get_object(cx, persistent_context).unwrap(); diff --git a/api/node/native/lib.rs b/api/node/native/lib.rs index db458e2e9d1..0d59a29ef14 100644 --- a/api/node/native/lib.rs +++ b/api/node/native/lib.rs @@ -4,17 +4,17 @@ use core::cell::RefCell; use neon::prelude::*; use rand::RngCore; -use sixtyfps_interpreter::ComponentHandle; use slint_compiler_internal::langtype::Type; use slint_core_internal::model::{Model, ModelRc}; use slint_core_internal::window::WindowHandleAccess; use slint_core_internal::{ImageInner, SharedVector}; +use slint_interpreter::ComponentHandle; mod js_model; mod persistent_context; -struct WrappedComponentType(Option); -struct WrappedComponentRc(Option); +struct WrappedComponentType(Option); +struct WrappedComponentRc(Option); struct WrappedWindow(Option); /// 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 { } None => vec![], }; - let mut compiler = sixtyfps_interpreter::ComponentCompiler::default(); + let mut compiler = slint_interpreter::ComponentCompiler::default(); compiler.set_include_paths(include_paths); 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") }; @@ -77,12 +77,12 @@ fn make_callback_handler<'cx>( persistent_context: &persistent_context::PersistentContext<'cx>, fun: Handle<'cx, JsFunction>, return_type: Option>, -) -> Box sixtyfps_interpreter::Value> { +) -> Box slint_interpreter::Value> { let fun_value = fun.as_value(cx); let fun_idx = persistent_context.allocate(cx, fun_value); Box::new(move |args| { 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 return_type = &return_type; run_with_global_context(&move |cx, persistent_context| { @@ -109,7 +109,7 @@ fn make_callback_handler<'cx>( fn create<'cx>( cx: &mut CallContext<'cx, impl neon::object::This>, - component_type: sixtyfps_interpreter::ComponentDefinition, + component_type: slint_interpreter::ComponentDefinition, ) -> JsResult<'cx, JsValue> { let component = component_type.create(); let persistent_context = persistent_context::PersistentContext::new(cx); @@ -157,8 +157,8 @@ fn to_eval_value<'cx>( ty: slint_compiler_internal::langtype::Type, cx: &mut impl Context<'cx>, persistent_context: &persistent_context::PersistentContext<'cx>, -) -> NeonResult { - use sixtyfps_interpreter::Value; +) -> NeonResult { + use slint_interpreter::Value; match ty { Type::Float32 | Type::Int32 @@ -242,11 +242,11 @@ fn to_eval_value<'cx>( } fn to_js_value<'cx>( - val: sixtyfps_interpreter::Value, + val: slint_interpreter::Value, cx: &mut impl Context<'cx>, persistent_context: &persistent_context::PersistentContext<'cx>, ) -> NeonResult> { - use sixtyfps_interpreter::Value; + use slint_interpreter::Value; Ok(match val { Value::Void => JsUndefined::new().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 = component.ok_or(()).or_else(|()| cx.throw_error("Invalid type"))?; 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(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 = component.ok_or(()).or_else(|()| cx.throw_error("Invalid type"))?; 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(JsUndefined::new().as_value(&mut cx)) diff --git a/api/sixtyfps-rs/lib.rs b/api/sixtyfps-rs/lib.rs index 56d1447ab4a..dab7b560d27 100644 --- a/api/sixtyfps-rs/lib.rs +++ b/api/sixtyfps-rs/lib.rs @@ -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 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 struct with functions. Use these functions to instantiate and show the component, and diff --git a/api/wasm-interpreter/Cargo.toml b/api/wasm-interpreter/Cargo.toml index 4b6d9adbf04..a078a79cfcc 100644 --- a/api/wasm-interpreter/Cargo.toml +++ b/api/wasm-interpreter/Cargo.toml @@ -16,7 +16,7 @@ homepage = "https://sixtyfps.io" crate-type = ["cdylib"] [dependencies] -sixtyfps-interpreter = { path = "../../internal/interpreter" } +slint-interpreter = { path = "../../internal/interpreter" } vtable = { version = "0.1.1", path="../../helper_crates/vtable" } diff --git a/api/wasm-interpreter/src/lib.rs b/api/wasm-interpreter/src/lib.rs index a805e6eea7a..44510a3d601 100644 --- a/api/wasm-interpreter/src/lib.rs +++ b/api/wasm-interpreter/src/lib.rs @@ -7,7 +7,7 @@ use std::path::Path; use wasm_bindgen::prelude::*; -use sixtyfps_interpreter::ComponentHandle; +use slint_interpreter::ComponentHandle; #[cfg(feature = "wee_alloc")] #[global_allocator] @@ -60,7 +60,7 @@ pub async fn compile_from_string_with_style( #[cfg(feature = "console_error_panic_hook")] console_error_panic_hook::set_once(); - let mut compiler = sixtyfps_interpreter::ComponentCompiler::default(); + let mut compiler = slint_interpreter::ComponentCompiler::default(); if !style.is_empty() { compiler.set_style(style) } @@ -105,7 +105,7 @@ pub async fn compile_from_string_with_style( let filename_js = JsValue::from_str(&filename); 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() { error_as_string.push_str("\n"); } @@ -132,7 +132,7 @@ pub async fn compile_from_string_with_style( #[wasm_bindgen] #[derive(Clone)] -pub struct WrappedCompiledComp(sixtyfps_interpreter::ComponentDefinition); +pub struct WrappedCompiledComp(slint_interpreter::ComponentDefinition); #[wasm_bindgen] impl WrappedCompiledComp { diff --git a/internal/core/api.rs b/internal/core/api.rs index 05547e5a1cd..0a6991689dc 100644 --- a/internal/core/api.rs +++ b/internal/core/api.rs @@ -2,7 +2,7 @@ // 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; diff --git a/internal/interpreter/Cargo.toml b/internal/interpreter/Cargo.toml index bde3a9aad74..a057a9ebcdb 100644 --- a/internal/interpreter/Cargo.toml +++ b/internal/interpreter/Cargo.toml @@ -2,7 +2,7 @@ # SPDX-License-Identifier: (GPL-3.0-only OR LicenseRef-SixtyFPS-commercial) [package] -name = "sixtyfps-interpreter" +name = "slint-interpreter" version = "0.2.0" authors = ["SixtyFPS "] edition = "2021" diff --git a/internal/interpreter/api.rs b/internal/interpreter/api.rs index 4f8123950bf..779a2aa1905 100644 --- a/internal/interpreter/api.rs +++ b/internal/interpreter/api.rs @@ -74,7 +74,7 @@ impl From for ValueType { /// [`From`] or [`TryInto`] traits to access the value. /// /// ``` -/// # use sixtyfps_interpreter::*; +/// # use slint_interpreter::*; /// use core::convert::TryInto; /// // create a value containing an integer /// 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; /// // Construct a value from a key/value iterator /// let value : Value = [("foo".into(), 45u32.into()), ("bar".into(), true.into())] @@ -740,7 +740,7 @@ impl ComponentInstance { /// ## Examples /// /// ``` - /// use sixtyfps_interpreter::{ComponentDefinition, ComponentCompiler, Value, SharedString}; + /// use slint_interpreter::{ComponentDefinition, ComponentCompiler, Value, SharedString}; /// let code = r#" /// MyWin := Window { /// property my_property: 42; @@ -778,7 +778,7 @@ impl ComponentInstance { /// ## Examples /// /// ``` - /// use sixtyfps_interpreter::{ComponentDefinition, ComponentCompiler, Value, SharedString, ComponentHandle}; + /// use slint_interpreter::{ComponentDefinition, ComponentCompiler, Value, SharedString, ComponentHandle}; /// use core::convert::TryInto; /// let code = r#" /// MyWin := Window { @@ -837,7 +837,7 @@ impl ComponentInstance { /// ## Examples /// /// ``` - /// use sixtyfps_interpreter::{ComponentDefinition, ComponentCompiler, Value, SharedString}; + /// use slint_interpreter::{ComponentDefinition, ComponentCompiler, Value, SharedString}; /// let code = r#" /// global Glob := { /// property my_property: 42; @@ -891,7 +891,7 @@ impl ComponentInstance { /// ## Examples /// /// ``` - /// use sixtyfps_interpreter::{ComponentDefinition, ComponentCompiler, Value, SharedString}; + /// use slint_interpreter::{ComponentDefinition, ComponentCompiler, Value, SharedString}; /// use core::convert::TryInto; /// let code = r#" /// export global Logic := { diff --git a/internal/interpreter/lib.rs b/internal/interpreter/lib.rs index 68ef81736e0..57e594c6d5e 100644 --- a/internal/interpreter/lib.rs +++ b/internal/interpreter/lib.rs @@ -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: ```rust -use sixtyfps_interpreter::{ComponentDefinition, ComponentCompiler, ComponentHandle}; +use slint_interpreter::{ComponentDefinition, ComponentCompiler, ComponentHandle}; let mut compiler = ComponentCompiler::default(); let definition = spin_on::spin_on(compiler.build_from_path("hello.60")); # #[cfg(feature="print_diagnostics")] -sixtyfps_interpreter::print_diagnostics(&compiler.diagnostics()); +slint_interpreter::print_diagnostics(&compiler.diagnostics()); if let Some(definition) = definition { let instance = definition.create(); instance.run(); @@ -40,7 +40,7 @@ if let Some(definition) = definition { This example load a `.60` from a string and set some properties: ```rust -use sixtyfps_interpreter::{ComponentDefinition, ComponentCompiler, Value, SharedString, ComponentHandle}; +use slint_interpreter::{ComponentDefinition, ComponentCompiler, Value, SharedString, ComponentHandle}; let code = r#" MyWin := Window { diff --git a/tests/doctests/Cargo.toml b/tests/doctests/Cargo.toml index 50b557e5463..d224f003481 100644 --- a/tests/doctests/Cargo.toml +++ b/tests/doctests/Cargo.toml @@ -15,7 +15,7 @@ name = "doctests" [dev-dependencies] slint-compiler-internal = { path = "../../internal/compiler", features = ["display-diagnostics"] } -sixtyfps-interpreter = { path = "../../internal/interpreter" } +slint-interpreter = { path = "../../internal/interpreter" } sixtyfps = { path = "../../api/sixtyfps-rs" } lazy_static = "1.4.0" diff --git a/tests/doctests/main.rs b/tests/doctests/main.rs index 0cf8c3afc1d..45722060ffc 100644 --- a/tests/doctests/main.rs +++ b/tests/doctests/main.rs @@ -3,15 +3,15 @@ #[cfg(test)] fn do_test(snippet: &str) -> Result<(), Box> { - let mut compiler = sixtyfps_interpreter::ComponentCompiler::default(); + let mut compiler = slint_interpreter::ComponentCompiler::default(); let component = spin_on::spin_on(compiler.build_from_source(snippet.into(), Default::default())); #[cfg(feature = "display-diagnostics")] - sixtyfps_interpreter::print_diagnostics(&compiler.diagnostics()); + slint_interpreter::print_diagnostics(&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()); } } diff --git a/tests/driver/interpreter/Cargo.toml b/tests/driver/interpreter/Cargo.toml index 7f352bca8c4..aa2c817b251 100644 --- a/tests/driver/interpreter/Cargo.toml +++ b/tests/driver/interpreter/Cargo.toml @@ -14,7 +14,7 @@ path = "main.rs" name = "test-driver-interpreter" [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" } itertools = "0.10" diff --git a/tests/driver/interpreter/interpreter.rs b/tests/driver/interpreter/interpreter.rs index 99e6a330816..eb676ea4099 100644 --- a/tests/driver/interpreter/interpreter.rs +++ b/tests/driver/interpreter/interpreter.rs @@ -2,7 +2,7 @@ // SPDX-License-Identifier: (GPL-3.0-only OR LicenseRef-SixtyFPS-commercial) use itertools::Itertools; -use sixtyfps_interpreter::{DiagnosticLevel, Value, ValueType}; +use slint_interpreter::{DiagnosticLevel, Value, ValueType}; use std::error::Error; pub fn test(testcase: &test_driver_lib::TestCase) -> Result<(), Box> { @@ -12,7 +12,7 @@ pub fn test(testcase: &test_driver_lib::TestCase) -> Result<(), Box> let include_paths = test_driver_lib::extract_include_paths(&source) .map(std::path::PathBuf::from) .collect::>(); - let mut compiler = sixtyfps_interpreter::ComponentCompiler::default(); + let mut compiler = slint_interpreter::ComponentCompiler::default(); 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 @@ -21,7 +21,7 @@ pub fn test(testcase: &test_driver_lib::TestCase) -> Result<(), Box> let component = match component { None => { - sixtyfps_interpreter::print_diagnostics(&compiler.diagnostics()); + slint_interpreter::print_diagnostics(&compiler.diagnostics()); match std::env::var("SIXTYFPS_INTERPRETER_ERROR_WHITELIST") { Ok(wl) if !wl.is_empty() => { diff --git a/tools/lsp/Cargo.toml b/tools/lsp/Cargo.toml index 4dc738a9bd4..65a3d8fdc8b 100644 --- a/tools/lsp/Cargo.toml +++ b/tools/lsp/Cargo.toml @@ -22,17 +22,17 @@ name = "sixtyfps-lsp" path = "main.rs" [features] -sixtyfps-backend-gl = ["sixtyfps-interpreter/backend-gl"] -sixtyfps-backend-qt = ["sixtyfps-interpreter/backend-qt"] -wayland = ["sixtyfps-interpreter/wayland"] -x11 = ["sixtyfps-interpreter/x11"] +sixtyfps-backend-gl = ["slint-interpreter/backend-gl"] +sixtyfps-backend-qt = ["slint-interpreter/backend-qt"] +wayland = ["slint-interpreter/wayland"] +x11 = ["slint-interpreter/x11"] default = ["sixtyfps-backend-qt", "sixtyfps-backend-gl", "x11"] [dependencies] slint-compiler-internal = { version = "=0.2.0", path = "../../internal/compiler"} 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" } clap = { version = "3.0.5", features=["derive", "wrap_help"] } diff --git a/tools/lsp/preview.rs b/tools/lsp/preview.rs index 0ba5457b1b3..69eb5291209 100644 --- a/tools/lsp/preview.rs +++ b/tools/lsp/preview.rs @@ -16,7 +16,7 @@ use clap::Parser; use crate::lsp_ext::{Health, ServerStatusNotification, ServerStatusParams}; -use sixtyfps_interpreter::ComponentHandle; +use slint_interpreter::ComponentHandle; #[derive(PartialEq)] enum RequestedGuiEventLoopState { @@ -202,7 +202,7 @@ async fn reload_preview( 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(); if !cli_args.style.is_empty() { builder.set_style(cli_args.style) @@ -229,7 +229,7 @@ async fn reload_preview( if let Some(compiled) = compiled { #[derive(Default)] struct PreviewState { - handle: Option, + handle: Option, } thread_local! {static PREVIEW_STATE: std::cell::RefCell = Default::default();} PREVIEW_STATE.with(|preview_state| { @@ -256,7 +256,7 @@ async fn reload_preview( } fn notify_diagnostics( - diagnostics: &[sixtyfps_interpreter::Diagnostic], + diagnostics: &[slint_interpreter::Diagnostic], sender: &crossbeam_channel::Sender, ) -> Option<()> { let mut lsp_diags: HashMap> = Default::default(); diff --git a/tools/lsp/util.rs b/tools/lsp/util.rs index acbc7c02a53..aeefcb4aadf 100644 --- a/tools/lsp/util.rs +++ b/tools/lsp/util.rs @@ -152,8 +152,8 @@ fn to_lsp_diag_level( level: slint_compiler_internal::diagnostics::DiagnosticLevel, ) -> lsp_types::DiagnosticSeverity { match level { - sixtyfps_interpreter::DiagnosticLevel::Error => lsp_types::DiagnosticSeverity::ERROR, - sixtyfps_interpreter::DiagnosticLevel::Warning => lsp_types::DiagnosticSeverity::WARNING, + slint_interpreter::DiagnosticLevel::Error => lsp_types::DiagnosticSeverity::ERROR, + slint_interpreter::DiagnosticLevel::Warning => lsp_types::DiagnosticSeverity::WARNING, _ => lsp_types::DiagnosticSeverity::INFORMATION, } } diff --git a/tools/viewer/Cargo.toml b/tools/viewer/Cargo.toml index ffcede28653..87222eae9ef 100644 --- a/tools/viewer/Cargo.toml +++ b/tools/viewer/Cargo.toml @@ -14,16 +14,16 @@ categories = ["gui", "development-tools"] keywords = ["viewer", "gui", "ui", "toolkit"] [features] -sixtyfps-backend-gl = ["sixtyfps-interpreter/backend-gl"] -sixtyfps-backend-qt = ["sixtyfps-interpreter/backend-qt"] -wayland = ["sixtyfps-interpreter/wayland"] -x11 = ["sixtyfps-interpreter/x11"] +sixtyfps-backend-gl = ["slint-interpreter/backend-gl"] +sixtyfps-backend-qt = ["slint-interpreter/backend-qt"] +wayland = ["slint-interpreter/wayland"] +x11 = ["slint-interpreter/x11"] default = ["sixtyfps-backend-qt", "sixtyfps-backend-gl", "x11"] [dependencies] 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" } vtable = { version = "0.1", path="../../helper_crates/vtable" } diff --git a/tools/viewer/main.rs b/tools/viewer/main.rs index f6fb7cc1611..4fa35ea77e3 100644 --- a/tools/viewer/main.rs +++ b/tools/viewer/main.rs @@ -3,9 +3,9 @@ #![doc = include_str!("README.md")] -use sixtyfps_interpreter::{ComponentHandle, ComponentInstance, SharedString, Value}; use slint_core_internal::model::{Model, ModelRc}; use slint_core_internal::SharedVector; +use slint_interpreter::{ComponentHandle, ComponentInstance, SharedString, Value}; use std::future::Future; use std::pin::Pin; use std::sync::atomic::{AtomicU32, Ordering}; @@ -78,7 +78,7 @@ fn main() -> Result<()> { let mut compiler = init_compiler(&args, fswatcher); 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 { Some(c) => c, @@ -102,19 +102,19 @@ fn main() -> Result<()> { if let Some(data_path) = args.save_data { let mut obj = serde_json::Map::new(); for (name, _) in c.properties() { - fn to_json(val: sixtyfps_interpreter::Value) -> Option { + fn to_json(val: slint_interpreter::Value) -> Option { match val { - sixtyfps_interpreter::Value::Number(x) => Some(x.into()), - sixtyfps_interpreter::Value::String(x) => Some(x.as_str().into()), - sixtyfps_interpreter::Value::Bool(x) => Some(x.into()), - sixtyfps_interpreter::Value::Model(model) => { + slint_interpreter::Value::Number(x) => Some(x.into()), + slint_interpreter::Value::String(x) => Some(x.as_str().into()), + slint_interpreter::Value::Bool(x) => Some(x.into()), + slint_interpreter::Value::Model(model) => { let mut res = Vec::with_capacity(model.row_count()); for i in 0..model.row_count() { res.push(to_json(model.row_data(i).unwrap())?); } Some(serde_json::Value::Array(res)) } - sixtyfps_interpreter::Value::Struct(st) => { + slint_interpreter::Value::Struct(st) => { let mut obj = serde_json::Map::new(); for (k, v) in st.iter() { obj.insert(k.into(), to_json(v.clone())?); @@ -141,8 +141,8 @@ fn main() -> Result<()> { fn init_compiler( args: &Cli, fswatcher: Option>>, -) -> sixtyfps_interpreter::ComponentCompiler { - let mut compiler = sixtyfps_interpreter::ComponentCompiler::default(); +) -> slint_interpreter::ComponentCompiler { + let mut compiler = slint_interpreter::ComponentCompiler::default(); compiler.set_include_paths(args.include_paths.clone()); if let Some(style) = &args.style { compiler.set_style(style.clone()); @@ -223,7 +223,7 @@ fn start_fswatch_thread(args: Cli) -> Result>) { let mut compiler = init_compiler(&args, Some(fswatcher)); 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 { 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")?; 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 { - 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::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::Array(array) => sixtyfps_interpreter::Value::Model( - ModelRc::new(slint_core_internal::model::SharedVectorModel::from( + serde_json::Value::Array(array) => slint_interpreter::Value::Model(ModelRc::new( + slint_core_internal::model::SharedVectorModel::from( array.iter().map(from_json).collect::>(), - )), - ), + ), + )), serde_json::Value::Object(obj) => obj .iter() .map(|(k, v)| (k.clone(), from_json(v))) - .collect::() + .collect::() .into(), } }