mirror of
https://github.com/slint-ui/slint.git
synced 2025-10-01 06:11:16 +00:00
enable scripts to access the length of arrays
This commit is contained in:
parent
9f3d02c319
commit
ab665ba7b6
6 changed files with 40 additions and 0 deletions
|
@ -45,6 +45,7 @@ pub enum BuiltinFunction {
|
|||
ColorBrighter,
|
||||
ColorDarker,
|
||||
ImageSize,
|
||||
ArrayLength,
|
||||
Rgb,
|
||||
ImplicitLayoutInfo(Orientation),
|
||||
RegisterCustomFontByPath,
|
||||
|
@ -125,6 +126,10 @@ impl BuiltinFunction {
|
|||
}),
|
||||
args: vec![Type::Image],
|
||||
},
|
||||
BuiltinFunction::ArrayLength => Type::Function {
|
||||
return_type: Box::new(Type::Int32),
|
||||
args: vec![Type::Array(Box::new(Type::InferredGenericType))],
|
||||
},
|
||||
BuiltinFunction::Rgb => Type::Function {
|
||||
return_type: Box::new(Type::Color),
|
||||
args: vec![Type::Int32, Type::Int32, Type::Int32, Type::Float32],
|
||||
|
@ -168,6 +173,7 @@ impl BuiltinFunction {
|
|||
BuiltinFunction::ImageSize => true,
|
||||
#[cfg(target_arch = "wasm32")]
|
||||
BuiltinFunction::ImageSize => false,
|
||||
BuiltinFunction::ArrayLength => true,
|
||||
BuiltinFunction::Rgb => true,
|
||||
BuiltinFunction::ImplicitLayoutInfo(_) => false,
|
||||
BuiltinFunction::RegisterCustomFontByPath
|
||||
|
@ -985,6 +991,7 @@ impl Expression {
|
|||
pub fn default_value_for_type(ty: &Type) -> Expression {
|
||||
match ty {
|
||||
Type::Invalid
|
||||
| Type::InferredGenericType
|
||||
| Type::Component(_)
|
||||
| Type::Builtin(_)
|
||||
| Type::Native(_)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue