Skip to content

Commit

Permalink
Rename the sixtyfps-compilerlib crate
Browse files Browse the repository at this point in the history
  • Loading branch information
tronical committed Feb 1, 2022
1 parent 9494068 commit cab22f8
Show file tree
Hide file tree
Showing 36 changed files with 169 additions and 158 deletions.
2 changes: 1 addition & 1 deletion api/node/native/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ crate-type = ["cdylib"]
name = "sixtyfps_node_native"

[dependencies]
sixtyfps-compilerlib = { 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" }
sixtyfps-interpreter = { version = "=0.2.0", path="../../../internal/interpreter", features = ["display-diagnostics"] }

Expand Down
2 changes: 1 addition & 1 deletion api/node/native/js_model.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 neon::prelude::*;
use sixtyfps_compilerlib::langtype::Type;
use slint_compiler_internal::langtype::Type;
use slint_core_internal::model::Model;
use std::cell::Cell;
use std::rc::{Rc, Weak};
Expand Down
4 changes: 2 additions & 2 deletions api/node/native/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
use core::cell::RefCell;
use neon::prelude::*;
use rand::RngCore;
use sixtyfps_compilerlib::langtype::Type;
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};
Expand Down Expand Up @@ -154,7 +154,7 @@ fn create<'cx>(

fn to_eval_value<'cx>(
val: Handle<'cx, JsValue>,
ty: sixtyfps_compilerlib::langtype::Type,
ty: slint_compiler_internal::langtype::Type,
cx: &mut impl Context<'cx>,
persistent_context: &persistent_context::PersistentContext<'cx>,
) -> NeonResult<sixtyfps_interpreter::Value> {
Expand Down
2 changes: 1 addition & 1 deletion api/rs/build/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ path = "lib.rs"
default = []

[dependencies]
sixtyfps-compilerlib = { version = "=0.2.0", path = "../../../internal/compiler", features = ["rust", "display-diagnostics"] }
slint-compiler-internal = { version = "=0.2.0", path = "../../../internal/compiler", features = ["rust", "display-diagnostics"] }

spin_on = "0.1"
thiserror = "1"
14 changes: 7 additions & 7 deletions api/rs/build/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,18 +54,18 @@ use std::env;
use std::io::Write;
use std::path::Path;

use sixtyfps_compilerlib::diagnostics::BuildDiagnostics;
use slint_compiler_internal::diagnostics::BuildDiagnostics;

/// The structure for configuring aspects of the compilation of `.60` markup files to Rust.
pub struct CompilerConfiguration {
config: sixtyfps_compilerlib::CompilerConfiguration,
config: slint_compiler_internal::CompilerConfiguration,
}

impl Default for CompilerConfiguration {
fn default() -> Self {
Self {
config: sixtyfps_compilerlib::CompilerConfiguration::new(
sixtyfps_compilerlib::generator::OutputFormat::Rust,
config: slint_compiler_internal::CompilerConfiguration::new(
slint_compiler_internal::generator::OutputFormat::Rust,
),
}
}
Expand Down Expand Up @@ -189,7 +189,7 @@ pub fn compile_with_config(
.join(path.as_ref());

let mut diag = BuildDiagnostics::default();
let syntax_node = sixtyfps_compilerlib::parser::parse_file(&path, &mut diag);
let syntax_node = slint_compiler_internal::parser::parse_file(&path, &mut diag);

if diag.has_error() {
let vec = diag.to_string_vec();
Expand Down Expand Up @@ -222,7 +222,7 @@ pub fn compile_with_config(
let syntax_node = syntax_node.expect("diags contained no compilation errors");

// 'spin_on' is ok here because the compiler in single threaded and does not block if there is no blocking future
let (doc, diag) = spin_on::spin_on(sixtyfps_compilerlib::compile_syntax_node(
let (doc, diag) = spin_on::spin_on(slint_compiler_internal::compile_syntax_node(
syntax_node,
diag,
compiler_config,
Expand All @@ -244,7 +244,7 @@ pub fn compile_with_config(

let file = std::fs::File::create(&output_file_path).map_err(CompileError::SaveError)?;
let mut code_formatter = CodeFormatter { indentation: 0, in_string: false, sink: file };
let generated = sixtyfps_compilerlib::generator::rust::generate(&doc);
let generated = slint_compiler_internal::generator::rust::generate(&doc);

for x in &diag.all_loaded_files {
if x.is_absolute() {
Expand Down
2 changes: 1 addition & 1 deletion api/rs/macros/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ proc-macro = true
path = "lib.rs"

[dependencies]
sixtyfps-compilerlib = { version = "=0.2.0", path = "../../../internal/compiler", features = ["proc_macro_span", "rust", "display-diagnostics"] }
slint-compiler-internal = { version = "=0.2.0", path = "../../../internal/compiler", features = ["proc_macro_span", "rust", "display-diagnostics"] }

proc-macro2 = "1.0.17"
quote = "1.0"
Expand Down
8 changes: 4 additions & 4 deletions api/rs/macros/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ use std::path::Path;

use proc_macro::{Spacing, TokenStream, TokenTree};
use quote::quote;
use sixtyfps_compilerlib::diagnostics::BuildDiagnostics;
use sixtyfps_compilerlib::parser::SyntaxKind;
use sixtyfps_compilerlib::*;
use slint_compiler_internal::diagnostics::BuildDiagnostics;
use slint_compiler_internal::parser::SyntaxKind;
use slint_compiler_internal::*;

/// Returns true if the two token are touching. For example the two token `foo`and `-` are touching if
/// it was written like so in the source code: `foo-` but not when written like so `foo -`
Expand Down Expand Up @@ -337,7 +337,7 @@ pub fn sixtyfps(stream: TokenStream) -> TokenStream {

//println!("{:#?}", syntax_node);
let mut compiler_config =
CompilerConfiguration::new(sixtyfps_compilerlib::generator::OutputFormat::Rust);
CompilerConfiguration::new(slint_compiler_internal::generator::OutputFormat::Rust);

if std::env::var_os("SIXTYFPS_STYLE").is_none() {
// This file is written by the slint-backend-selector-internal's built script.
Expand Down
2 changes: 1 addition & 1 deletion internal/compiler/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-compilerlib"
name = "slint-compiler-internal"
version = "0.2.0"
authors = ["SixtyFPS <info@sixtyfps.io>"]
edition = "2021"
Expand Down
20 changes: 10 additions & 10 deletions internal/compiler/tests/syntax_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ fn process_file(path: &std::path::Path) -> std::io::Result<bool> {
}

fn process_diagnostics(
compile_diagnostics: &sixtyfps_compilerlib::diagnostics::BuildDiagnostics,
compile_diagnostics: &slint_compiler_internal::diagnostics::BuildDiagnostics,
path: &Path,
source: &str,
silent: bool,
Expand Down Expand Up @@ -108,8 +108,8 @@ fn process_diagnostics(
} + column;

let expected_diag_level = match warning_or_error {
"warning" => sixtyfps_compilerlib::diagnostics::DiagnosticLevel::Warning,
"error" => sixtyfps_compilerlib::diagnostics::DiagnosticLevel::Error,
"warning" => slint_compiler_internal::diagnostics::DiagnosticLevel::Warning,
"error" => slint_compiler_internal::diagnostics::DiagnosticLevel::Error,
_ => panic!("Unsupported diagnostic level {}", warning_or_error),
};

Expand All @@ -135,7 +135,7 @@ fn process_diagnostics(

#[cfg(feature = "display-diagnostics")]
if !silent {
let mut to_report = sixtyfps_compilerlib::diagnostics::BuildDiagnostics::default();
let mut to_report = slint_compiler_internal::diagnostics::BuildDiagnostics::default();
for d in diags {
to_report.push_compiler_error(d.clone());
}
Expand All @@ -156,16 +156,16 @@ fn process_file_source(
source: String,
silent: bool,
) -> std::io::Result<bool> {
let mut parse_diagnostics = sixtyfps_compilerlib::diagnostics::BuildDiagnostics::default();
let mut parse_diagnostics = slint_compiler_internal::diagnostics::BuildDiagnostics::default();
let syntax_node =
sixtyfps_compilerlib::parser::parse(source.clone(), Some(path), &mut parse_diagnostics);
slint_compiler_internal::parser::parse(source.clone(), Some(path), &mut parse_diagnostics);
let has_parse_error = parse_diagnostics.has_error();
let mut compiler_config = sixtyfps_compilerlib::CompilerConfiguration::new(
sixtyfps_compilerlib::generator::OutputFormat::Interpreter,
let mut compiler_config = slint_compiler_internal::CompilerConfiguration::new(
slint_compiler_internal::generator::OutputFormat::Interpreter,
);
compiler_config.style = Some("fluent".into());
let compile_diagnostics = if !parse_diagnostics.has_error() {
let (_, build_diags) = spin_on::spin_on(sixtyfps_compilerlib::compile_syntax_node(
let (_, build_diags) = spin_on::spin_on(slint_compiler_internal::compile_syntax_node(
syntax_node.clone(),
parse_diagnostics,
compiler_config.clone(),
Expand All @@ -190,7 +190,7 @@ fn process_file_source(

if has_parse_error {
// Still try to compile to make sure it doesn't panic
spin_on::spin_on(sixtyfps_compilerlib::compile_syntax_node(
spin_on::spin_on(slint_compiler_internal::compile_syntax_node(
syntax_node,
compile_diagnostics,
compiler_config,
Expand Down
4 changes: 2 additions & 2 deletions internal/interpreter/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ default = ["std", "backend-gl", "x11", "backend-qt", "compat-0-2-0"]
compat-0-2-0 = []

## enable the [`print_diagnostics`] function to show diagnostic in the console output
display-diagnostics = ["sixtyfps-compilerlib/display-diagnostics"]
display-diagnostics = ["slint-compiler-internal/display-diagnostics"]

# (internal) export C++ FFI functions
ffi = ["spin_on", "slint-core-internal/ffi"]
Expand All @@ -53,7 +53,7 @@ x11 = ["slint-backend-selector-internal/x11", "backend-gl"]
wayland = ["slint-backend-selector-internal/wayland", "backend-gl"]

[dependencies]
sixtyfps-compilerlib = { version = "=0.2.0", path = "../compiler" }
slint-compiler-internal = { version = "=0.2.0", path = "../compiler" }
slint-core-internal = { version = "=0.2.0", path = "../core", features = ["rtti"] }
slint-backend-selector-internal = { version = "=0.2.0", path = "../../internal/backends/selector" }

Expand Down
16 changes: 8 additions & 8 deletions internal/interpreter/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)

use core::convert::TryInto;
use sixtyfps_compilerlib::langtype::Type as LangType;
use slint_compiler_internal::langtype::Type as LangType;
use slint_core_internal::graphics::Image;
use slint_core_internal::model::{Model, ModelRc};
use slint_core_internal::{Brush, PathData, SharedString, SharedVector};
Expand All @@ -13,7 +13,7 @@ use std::path::{Path, PathBuf};
use std::rc::Rc;

#[doc(inline)]
pub use sixtyfps_compilerlib::diagnostics::{Diagnostic, DiagnosticLevel};
pub use slint_compiler_internal::diagnostics::{Diagnostic, DiagnosticLevel};

pub use slint_core_internal::api::*;

Expand Down Expand Up @@ -429,15 +429,15 @@ impl FromIterator<(String, Value)> for Struct {
/// ComponentCompiler is the entry point to the SixtyFPS interpreter that can be used
/// to load .60 files or compile them on-the-fly from a string.
pub struct ComponentCompiler {
config: sixtyfps_compilerlib::CompilerConfiguration,
config: slint_compiler_internal::CompilerConfiguration,
diagnostics: Vec<Diagnostic>,
}

impl Default for ComponentCompiler {
fn default() -> Self {
Self {
config: sixtyfps_compilerlib::CompilerConfiguration::new(
sixtyfps_compilerlib::generator::OutputFormat::Interpreter,
config: slint_compiler_internal::CompilerConfiguration::new(
slint_compiler_internal::generator::OutputFormat::Interpreter,
),
diagnostics: vec![],
}
Expand Down Expand Up @@ -516,7 +516,7 @@ impl ComponentCompiler {
path: P,
) -> Option<ComponentDefinition> {
let path = path.as_ref();
let source = match sixtyfps_compilerlib::diagnostics::load_from_path(path) {
let source = match slint_compiler_internal::diagnostics::load_from_path(path) {
Ok(s) => s,
Err(d) => {
self.diagnostics = vec![d];
Expand Down Expand Up @@ -612,7 +612,7 @@ impl ComponentDefinition {
#[doc(hidden)]
pub fn properties_and_callbacks(
&self,
) -> impl Iterator<Item = (String, sixtyfps_compilerlib::langtype::Type)> + '_ {
) -> impl Iterator<Item = (String, slint_compiler_internal::langtype::Type)> + '_ {
// We create here a 'static guard, because unfortunately the returned type would be restricted to the guard lifetime
// which is not required, but this is safe because there is only one instance of the unerased type
let guard = unsafe { generativity::Guard::new(generativity::Id::new()) };
Expand Down Expand Up @@ -706,7 +706,7 @@ impl ComponentDefinition {
/// This function is available when the `display-diagnostics` is enabled.
#[cfg(feature = "display-diagnostics")]
pub fn print_diagnostics(diagnostics: &[Diagnostic]) {
let mut build_diagnostics = sixtyfps_compilerlib::diagnostics::BuildDiagnostics::default();
let mut build_diagnostics = slint_compiler_internal::diagnostics::BuildDiagnostics::default();
for d in diagnostics {
build_diagnostics.push_compiler_error(d.clone())
}
Expand Down
28 changes: 15 additions & 13 deletions internal/interpreter/dynamic_component.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ use crate::{api::Value, dynamic_type, eval};
use core::convert::TryInto;
use core::ptr::NonNull;
use dynamic_type::{Instance, InstanceBox};
use sixtyfps_compilerlib::expression_tree::{Expression, NamedReference};
use sixtyfps_compilerlib::langtype::Type;
use sixtyfps_compilerlib::object_tree::ElementRc;
use sixtyfps_compilerlib::*;
use sixtyfps_compilerlib::{diagnostics::BuildDiagnostics, object_tree::PropertyDeclaration};
use slint_compiler_internal::expression_tree::{Expression, NamedReference};
use slint_compiler_internal::langtype::Type;
use slint_compiler_internal::object_tree::ElementRc;
use slint_compiler_internal::*;
use slint_compiler_internal::{diagnostics::BuildDiagnostics, object_tree::PropertyDeclaration};
use slint_core_internal::api::Window;
use slint_core_internal::component::{Component, ComponentRef, ComponentRefPin, ComponentVTable};
use slint_core_internal::item_tree::{
Expand Down Expand Up @@ -293,7 +293,7 @@ pub struct ComponentDescription<'id> {

fn internal_properties_to_public<'a>(
prop_iter: impl Iterator<Item = (&'a String, &'a PropertyDeclaration)> + 'a,
) -> impl Iterator<Item = (String, sixtyfps_compilerlib::langtype::Type)> + 'a {
) -> impl Iterator<Item = (String, slint_compiler_internal::langtype::Type)> + 'a {
prop_iter.filter(|(_, v)| v.expose_in_public_api).map(|(s, v)| {
let name = v
.node
Expand All @@ -320,7 +320,7 @@ impl<'id> ComponentDescription<'id> {
/// We try to preserve the dashes and underscore as written in the property declaration
pub fn properties(
&self,
) -> impl Iterator<Item = (String, sixtyfps_compilerlib::langtype::Type)> + '_ {
) -> impl Iterator<Item = (String, slint_compiler_internal::langtype::Type)> + '_ {
internal_properties_to_public(self.public_properties.iter())
}

Expand All @@ -335,7 +335,7 @@ impl<'id> ComponentDescription<'id> {
pub fn global_properties(
&self,
name: &str,
) -> Option<impl Iterator<Item = (String, sixtyfps_compilerlib::langtype::Type)> + '_> {
) -> Option<impl Iterator<Item = (String, slint_compiler_internal::langtype::Type)> + '_> {
self.exported_globals_by_name
.get(crate::normalize_identifier(name).as_ref())
.and_then(|global_idx| self.compiled_globals.get(*global_idx))
Expand Down Expand Up @@ -684,8 +684,10 @@ pub async fn load(
path: std::path::PathBuf,
mut compiler_config: CompilerConfiguration,
guard: generativity::Guard<'_>,
) -> (Result<Rc<ComponentDescription<'_>>, ()>, sixtyfps_compilerlib::diagnostics::BuildDiagnostics)
{
) -> (
Result<Rc<ComponentDescription<'_>>, ()>,
slint_compiler_internal::diagnostics::BuildDiagnostics,
) {
if compiler_config.style.is_none() && std::env::var("SIXTYFPS_STYLE").is_err() {
// Defaults to native if it exists:
compiler_config.style = Some(if slint_backend_selector_internal::HAS_NATIVE_STYLE {
Expand Down Expand Up @@ -1053,16 +1055,16 @@ pub(crate) fn generate_component<'id>(

pub fn animation_for_property(
component: InstanceRef,
animation: &Option<sixtyfps_compilerlib::object_tree::PropertyAnimation>,
animation: &Option<slint_compiler_internal::object_tree::PropertyAnimation>,
) -> AnimatedBindingKind {
match animation {
Some(sixtyfps_compilerlib::object_tree::PropertyAnimation::Static(anim_elem)) => {
Some(slint_compiler_internal::object_tree::PropertyAnimation::Static(anim_elem)) => {
AnimatedBindingKind::Animation(eval::new_struct_with_bindings(
&anim_elem.borrow().bindings,
&mut eval::EvalLocalContext::from_component_instance(component),
))
}
Some(sixtyfps_compilerlib::object_tree::PropertyAnimation::Transition {
Some(slint_compiler_internal::object_tree::PropertyAnimation::Transition {
animations,
state_ref,
}) => {
Expand Down
Loading

0 comments on commit cab22f8

Please sign in to comment.