Rename the sixtyfps-interpreter crate

This commit is contained in:
Simon Hausmann 2022-02-01 17:16:18 +01:00
parent cab22f8355
commit 2f73a27635
23 changed files with 83 additions and 83 deletions

View file

@ -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

View file

@ -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

View file

@ -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 }

View file

@ -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()
}

View file

@ -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" }

View file

@ -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();

View file

@ -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<sixtyfps_interpreter::ComponentDefinition>);
struct WrappedComponentRc(Option<sixtyfps_interpreter::ComponentInstance>);
struct WrappedComponentType(Option<slint_interpreter::ComponentDefinition>);
struct WrappedComponentRc(Option<slint_interpreter::ComponentInstance>);
struct WrappedWindow(Option<slint_core_internal::window::WindowRc>);
/// 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![],
};
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<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_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<sixtyfps_interpreter::Value> {
use sixtyfps_interpreter::Value;
) -> NeonResult<slint_interpreter::Value> {
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<Handle<'cx, JsValue>> {
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))

View file

@ -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

View file

@ -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" }

View file

@ -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 {

View file

@ -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;

View file

@ -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 <info@sixtyfps.io>"]
edition = "2021"

View file

@ -74,7 +74,7 @@ impl From<LangType> 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 <int> 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 <int> 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 := {

View file

@ -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 {

View file

@ -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"

View file

@ -3,15 +3,15 @@
#[cfg(test)]
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 =
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());
}
}

View file

@ -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"

View file

@ -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<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)
.map(std::path::PathBuf::from)
.collect::<Vec<_>>();
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<dyn Error>>
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() => {

View file

@ -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"] }

View file

@ -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<sixtyfps_interpreter::ComponentInstance>,
handle: Option<slint_interpreter::ComponentInstance>,
}
thread_local! {static PREVIEW_STATE: std::cell::RefCell<PreviewState> = 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<Message>,
) -> Option<()> {
let mut lsp_diags: HashMap<lsp_types::Url, Vec<lsp_types::Diagnostic>> = Default::default();

View file

@ -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,
}
}

View file

@ -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" }

View file

@ -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<serde_json::Value> {
fn to_json(val: slint_interpreter::Value) -> Option<serde_json::Value> {
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<Arc<Mutex<notify::RecommendedWatcher>>>,
) -> 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<Arc<Mutex<notify::RecommendedWatche
async fn reload(args: Cli, fswatcher: Arc<Mutex<notify::RecommendedWatcher>>) {
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::<SharedVector<Value>>(),
)),
),
)),
serde_json::Value::Object(obj) => obj
.iter()
.map(|(k, v)| (k.clone(), from_json(v)))
.collect::<sixtyfps_interpreter::Struct>()
.collect::<slint_interpreter::Struct>()
.into(),
}
}