Change names of identifiers used for accessing embedded resources in the compiler

Instead of using SFPS (Slint_Fast_Packing_System) use SLINT :-)
This commit is contained in:
Simon Hausmann 2022-02-14 15:32:16 +01:00 committed by Simon Hausmann
parent bc2ab0ce39
commit 29cbb9e181
2 changed files with 7 additions and 7 deletions

View file

@ -502,7 +502,7 @@ pub fn generate(doc: &Document) -> impl std::fmt::Display {
Declaration::Var(Var {
ty: "inline uint8_t".into(),
name: format!("sfps_embedded_resource_{}", er.id),
name: format!("slint_embedded_resource_{}", er.id),
array_size: Some(data.len()),
init: Some(init),
})
@ -1936,7 +1936,7 @@ fn compile_expression(expr: &llr::Expression, ctx: &EvaluationContext) -> String
crate::expression_tree::ImageReference::None => r#"slint::Image()"#.to_string(),
crate::expression_tree::ImageReference::AbsolutePath(path) => format!(r#"slint::Image::load_from_path(slint::SharedString(u8"{}"))"#, escape_string(path.as_str())),
crate::expression_tree::ImageReference::EmbeddedData { resource_id, extension } => {
let symbol = format!("sfps_embedded_resource_{}", resource_id);
let symbol = format!("slint_embedded_resource_{}", resource_id);
format!(
r#"slint::Image(slint::cbindgen_private::types::ImageInner::EmbeddedData(slint::cbindgen_private::Slice<uint8_t>{{std::data({}), std::size({})}}, slint::cbindgen_private::Slice<uint8_t>{{const_cast<uint8_t *>(reinterpret_cast<const uint8_t *>(u8"{}")), {}}}))"#,
symbol, symbol, escape_string(extension), extension.as_bytes().len()
@ -2180,7 +2180,7 @@ fn compile_builtin_function_call(
BuiltinFunction::RegisterCustomFontByMemory => {
if let [llr::Expression::NumberLiteral(resource_id)] = &arguments {
let resource_id: usize = *resource_id as _;
let symbol = format!("sfps_embedded_resource_{}", resource_id);
let symbol = format!("slint_embedded_resource_{}", resource_id);
format!(
"slint::private_api::register_font_from_data({}, std::size({}));",
symbol, symbol

View file

@ -141,7 +141,7 @@ pub fn generate(doc: &Document) -> TokenStream {
.borrow()
.iter()
.map(|(path, er)| {
let symbol = format_ident!("SFPS_EMBEDDED_RESOURCE_{}", er.id);
let symbol = format_ident!("SLINT_EMBEDDED_RESOURCE_{}", er.id);
match &er.kind {
crate::embedded_resources::EmbeddedResourcesKind::RawData => {
let data = embedded_file_tokens(path);
@ -1516,7 +1516,7 @@ fn compile_expression(expr: &Expression, ctx: &EvaluationContext) -> TokenStream
quote!(slint::re_exports::Image::load_from_path(::std::path::Path::new(#path)).unwrap())
}
crate::expression_tree::ImageReference::EmbeddedData { resource_id, extension } => {
let symbol = format_ident!("SFPS_EMBEDDED_RESOURCE_{}", resource_id);
let symbol = format_ident!("SLINT_EMBEDDED_RESOURCE_{}", resource_id);
let format = proc_macro2::Literal::byte_string(extension.as_bytes());
quote!(
slint::re_exports::Image::from(
@ -1525,7 +1525,7 @@ fn compile_expression(expr: &Expression, ctx: &EvaluationContext) -> TokenStream
)
}
crate::expression_tree::ImageReference::EmbeddedTexture { resource_id } => {
let symbol = format_ident!("SFPS_EMBEDDED_RESOURCE_{}", resource_id);
let symbol = format_ident!("SLINT_EMBEDDED_RESOURCE_{}", resource_id);
quote!(
slint::re_exports::Image::from(#symbol)
)
@ -1727,7 +1727,7 @@ fn compile_builtin_function_call(
BuiltinFunction::RegisterCustomFontByMemory => {
if let [Expression::NumberLiteral(resource_id)] = &arguments {
let resource_id: usize = *resource_id as _;
let symbol = format_ident!("SFPS_EMBEDDED_RESOURCE_{}", resource_id);
let symbol = format_ident!("SLINT_EMBEDDED_RESOURCE_{}", resource_id);
quote!(slint::register_font_from_memory(#symbol.into());)
} else {
panic!("internal error: invalid args to RegisterCustomFontByMemory {:?}", arguments)