@@ -991,12 +991,14 @@ fn embed_resource(
991
991
) ) ,
992
992
..Default :: default ( )
993
993
} ) ) ;
994
- let init = format ! ( "slint::cbindgen_private::types::StaticTextures {{
994
+ let init = format ! (
995
+ "slint::cbindgen_private::types::StaticTextures {{
995
996
.size = {{ {width}, {height} }},
996
997
.original_size = {{ {unscaled_width}, {unscaled_height} }},
997
- .data = slint::cbindgen_private::Slice<uint8_t>{{ {data_name} , {count} }},
998
- .textures = slint::cbindgen_private::Slice<slint::cbindgen_private::types::StaticTexture>{{ &{texture_name}, 1 }}
999
- }}" ) ;
998
+ .data = slint::private_api::make_slice({data_name} , {count} ),
999
+ .textures = slint::private_api::make_slice(&{texture_name}, 1)
1000
+ }}"
1001
+ ) ;
1000
1002
declarations. push ( Declaration :: Var ( Var {
1001
1003
ty : "const slint::cbindgen_private::types::StaticTextures" . into ( ) ,
1002
1004
name : format_smolstr ! ( "slint_embedded_resource_{}" , resource. id) ,
@@ -1078,7 +1080,7 @@ fn embed_resource(
1078
1080
name : format_smolstr ! ( "slint_embedded_resource_{}_glyphset_{}" , resource. id, glyphset_index) ,
1079
1081
array_size : Some ( glyphset. glyph_data . len ( ) ) ,
1080
1082
init : Some ( format ! ( "{{ {} }}" , glyphset. glyph_data. iter( ) . enumerate( ) . map( |( glyph_index, glyph) | {
1081
- format!( "{{ .x = {}, .y = {}, .width = {}, .height = {}, .x_advance = {}, .data = slint::cbindgen_private::Slice<uint8_t>{{ { }, {} }} }}" ,
1083
+ format!( "{{ .x = {}, .y = {}, .width = {}, .height = {}, .x_advance = {}, .data = slint::private_api::make_slice({ }, {}) }}" ,
1082
1084
glyph. x, glyph. y, glyph. width, glyph. height, glyph. x_advance,
1083
1085
format!( "slint_embedded_resource_{}_gs_{}_gd_{}" , resource. id, glyphset_index, glyph_index) ,
1084
1086
glyph. data. len( )
@@ -1101,10 +1103,7 @@ fn embed_resource(
1101
1103
. iter( )
1102
1104
. enumerate( )
1103
1105
. map( |( glyphset_index, glyphset) | format!(
1104
- "{{ .pixel_size = {}, .glyph_data = slint::cbindgen_private::Slice<slint::cbindgen_private::BitmapGlyph>{{
1105
- {}, {}
1106
- }}
1107
- }}" ,
1106
+ "{{ .pixel_size = {}, .glyph_data = slint::private_api::make_slice({}, {}) }}" ,
1108
1107
glyphset. pixel_size, format!( "slint_embedded_resource_{}_glyphset_{}" , resource. id, glyphset_index) , glyphset. glyph_data. len( )
1109
1108
) )
1110
1109
. join( ", \n " )
@@ -1114,14 +1113,14 @@ fn embed_resource(
1114
1113
1115
1114
let init = format ! (
1116
1115
"slint::cbindgen_private::BitmapFont {{
1117
- .family_name = slint::cbindgen_private::Slice<uint8_t>{{ { family_name_var} , {family_name_size} }} ,
1118
- .character_map = slint::cbindgen_private::Slice<slint::cbindgen_private::CharacterMapEntry>{{ { charmap_var}, {charmap_size} }} ,
1116
+ .family_name = slint::private_api::make_slice({ family_name_var} , {family_name_size}) ,
1117
+ .character_map = slint::private_api::make_slice({ charmap_var}, {charmap_size}) ,
1119
1118
.units_per_em = {units_per_em},
1120
1119
.ascent = {ascent},
1121
1120
.descent = {descent},
1122
1121
.x_height = {x_height},
1123
1122
.cap_height = {cap_height},
1124
- .glyphs = slint::cbindgen_private::Slice<slint::cbindgen_private::BitmapGlyphs>{{ { glyphsets_var}, {glyphsets_size} }} ,
1123
+ .glyphs = slint::private_api::make_slice({ glyphsets_var}, {glyphsets_size}) ,
1125
1124
.weight = {weight},
1126
1125
.italic = {italic},
1127
1126
.sdf = {sdf},
@@ -1584,13 +1583,13 @@ fn generate_item_tree(
1584
1583
Access :: Private ,
1585
1584
Declaration :: Function ( Function {
1586
1585
name : "item_tree" . into ( ) ,
1587
- signature : "() -> slint::cbindgen_private::Slice<slint::private_api::ItemTreeNode>" . into ( ) ,
1586
+ signature : "() -> slint::cbindgen_private::Slice<slint::private_api::ItemTreeNode>"
1587
+ . into ( ) ,
1588
1588
is_static : true ,
1589
1589
statements : Some ( vec ! [
1590
1590
"static const slint::private_api::ItemTreeNode children[] {" . to_owned( ) ,
1591
1591
format!( " {} }};" , item_tree_array. join( ", \n " ) ) ,
1592
- "return { const_cast<slint::private_api::ItemTreeNode*>(children), std::size(children) };"
1593
- . to_owned( ) ,
1592
+ "return slint::private_api::make_slice(std::span(children));" . to_owned( ) ,
1594
1593
] ) ,
1595
1594
..Default :: default ( )
1596
1595
} ) ,
@@ -1605,8 +1604,7 @@ fn generate_item_tree(
1605
1604
statements : Some ( vec ! [
1606
1605
"static const slint::private_api::ItemArrayEntry items[] {" . to_owned( ) ,
1607
1606
format!( " {} }};" , item_array. join( ", \n " ) ) ,
1608
- "return { const_cast<slint::private_api::ItemArrayEntry*>(items), std::size(items) };"
1609
- . to_owned( ) ,
1607
+ "return slint::private_api::make_slice(std::span(items));" . to_owned( ) ,
1610
1608
] ) ,
1611
1609
..Default :: default ( )
1612
1610
} ) ,
@@ -1803,7 +1801,7 @@ fn generate_item_tree(
1803
1801
. map( |l| format!( "slint::private_api::string_to_slice({l:?})" ) )
1804
1802
. join( ", " )
1805
1803
) ) ;
1806
- create_code. push ( format ! ( "slint::cbindgen_private::slint_translate_set_bundled_languages({{ languages.data(), {lang_len} }} );" ) ) ;
1804
+ create_code. push ( format ! ( "slint::cbindgen_private::slint_translate_set_bundled_languages(slint::private_api::make_slice(std::span(languages)) );" ) ) ;
1807
1805
}
1808
1806
1809
1807
create_code. push ( "self->globals = &self->m_globals;" . into ( ) ) ;
@@ -3397,7 +3395,7 @@ fn compile_expression(expr: &llr::Expression, ctx: &EvaluationContext) -> String
3397
3395
)
3398
3396
} else {
3399
3397
format ! (
3400
- "slint::cbindgen_private::Slice <{ty}>{{ std::array<{ty}, {count}>{{ {val} }}.data(), {count} }} " ,
3398
+ "slint::private_api::make_slice <{ty}>( std::array<{ty}, {count}>{{ {val} }}.data(), {count}) " ,
3401
3399
count = values. len( ) ,
3402
3400
ty = ty,
3403
3401
val = val. join( ", " )
@@ -3511,7 +3509,7 @@ fn compile_expression(expr: &llr::Expression, ctx: &EvaluationContext) -> String
3511
3509
} ;
3512
3510
format ! ( "slint::cbindgen_private::GridLayoutCellData {cv}_array [] = {{ {c} }};\
3513
3511
slint::cbindgen_private::slint_reorder_dialog_button_layout({cv}_array, {r});\
3514
- slint::cbindgen_private::Slice<slint::cbindgen_private::GridLayoutCellData> {cv} {{ std::data({cv}_array), std::size ({cv}_array) }} ",
3512
+ slint::cbindgen_private::Slice<slint::cbindgen_private::GridLayoutCellData> {cv} = slint::private_api::make_slice( std::span ({cv}_array)) ",
3515
3513
r = compile_expression( roles, ctx) ,
3516
3514
cv = cells_variable,
3517
3515
c = cells. join( ", " ) ,
@@ -4099,13 +4097,13 @@ fn box_layout_function(
4099
4097
let ri = repeated_indices. as_ref ( ) . map_or ( String :: new ( ) , |ri| {
4100
4098
write ! (
4101
4099
push_code,
4102
- "slint::cbindgen_private::Slice<int> {ri}{{ {ri}_array.data(), {ri}_array.size() }} ;"
4100
+ "slint::cbindgen_private::Slice<int> {ri} = slint::private_api::make_slice(std::span( {ri}_array)) ;"
4103
4101
)
4104
4102
. unwrap ( ) ;
4105
4103
format ! ( "std::array<int, {}> {}_array;" , 2 * repeater_idx, ri)
4106
4104
} ) ;
4107
4105
format ! (
4108
- "[&]{{ {} {} slint::cbindgen_private::Slice<slint::cbindgen_private::BoxLayoutCellData>{}{{cells_vector.data(), cells_vector.size()}} ; return {}; }}()" ,
4106
+ "[&]{{ {} {} slint::cbindgen_private::Slice<slint::cbindgen_private::BoxLayoutCellData>{} = slint::private_api::make_slice(std::span(cells_vector)) ; return {}; }}()" ,
4109
4107
ri,
4110
4108
push_code,
4111
4109
ident( cells_variable) ,
0 commit comments