Skip to content

Commit

Permalink
Rename the sixtyfps-interpreter crate
Browse files Browse the repository at this point in the history
  • Loading branch information
tronical committed Feb 1, 2022
1 parent cab22f8 commit 2f73a27
Show file tree
Hide file tree
Showing 23 changed files with 83 additions and 83 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build_docs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
4 changes: 2 additions & 2 deletions api/cpp/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
Expand All @@ -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 }

Expand Down
4 changes: 2 additions & 2 deletions api/cpp/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}
Expand Down
2 changes: 1 addition & 1 deletion api/node/native/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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" }

Expand Down
4 changes: 2 additions & 2 deletions api/node/native/js_model.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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();
Expand Down
28 changes: 14 additions & 14 deletions api/node/native/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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") };

Expand All @@ -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| {
Expand All @@ -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);
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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),
Expand Down Expand Up @@ -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))
Expand All @@ -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))
Expand Down
2 changes: 1 addition & 1 deletion api/sixtyfps-rs/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion api/wasm-interpreter/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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" }

Expand Down
8 changes: 4 additions & 4 deletions api/wasm-interpreter/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down Expand Up @@ -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)
}
Expand Down Expand Up @@ -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");
}
Expand All @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion internal/core/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion internal/interpreter/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
12 changes: 6 additions & 6 deletions internal/interpreter/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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())]
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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 := {
Expand Down
6 changes: 3 additions & 3 deletions internal/interpreter/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion tests/doctests/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
6 changes: 3 additions & 3 deletions tests/doctests/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}
}
Expand Down
2 changes: 1 addition & 1 deletion tests/driver/interpreter/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
6 changes: 3 additions & 3 deletions tests/driver/interpreter/interpreter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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>> {
Expand All @@ -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

Expand All @@ -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() => {
Expand Down
Loading

0 comments on commit 2f73a27

Please sign in to comment.