@@ -991,12 +991,14 @@ fn embed_resource(
991991 ) ) ,
992992 ..Default :: default ( )
993993 } ) ) ;
994- let init = format ! ( "slint::cbindgen_private::types::StaticTextures {{
994+ let init = format ! (
995+ "slint::cbindgen_private::types::StaticTextures {{
995996 .size = {{ {width}, {height} }},
996997 .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+ ) ;
10001002 declarations. push ( Declaration :: Var ( Var {
10011003 ty : "const slint::cbindgen_private::types::StaticTextures" . into ( ) ,
10021004 name : format_smolstr ! ( "slint_embedded_resource_{}" , resource. id) ,
@@ -1078,7 +1080,7 @@ fn embed_resource(
10781080 name : format_smolstr ! ( "slint_embedded_resource_{}_glyphset_{}" , resource. id, glyphset_index) ,
10791081 array_size : Some ( glyphset. glyph_data . len ( ) ) ,
10801082 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({ }, {}) }}" ,
10821084 glyph. x, glyph. y, glyph. width, glyph. height, glyph. x_advance,
10831085 format!( "slint_embedded_resource_{}_gs_{}_gd_{}" , resource. id, glyphset_index, glyph_index) ,
10841086 glyph. data. len( )
@@ -1101,10 +1103,7 @@ fn embed_resource(
11011103 . iter( )
11021104 . enumerate( )
11031105 . 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({}, {}) }}" ,
11081107 glyphset. pixel_size, format!( "slint_embedded_resource_{}_glyphset_{}" , resource. id, glyphset_index) , glyphset. glyph_data. len( )
11091108 ) )
11101109 . join( ", \n " )
@@ -1114,14 +1113,14 @@ fn embed_resource(
11141113
11151114 let init = format ! (
11161115 "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}) ,
11191118 .units_per_em = {units_per_em},
11201119 .ascent = {ascent},
11211120 .descent = {descent},
11221121 .x_height = {x_height},
11231122 .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}) ,
11251124 .weight = {weight},
11261125 .italic = {italic},
11271126 .sdf = {sdf},
@@ -1584,13 +1583,13 @@ fn generate_item_tree(
15841583 Access :: Private ,
15851584 Declaration :: Function ( Function {
15861585 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 ( ) ,
15881588 is_static : true ,
15891589 statements : Some ( vec ! [
15901590 "static const slint::private_api::ItemTreeNode children[] {" . to_owned( ) ,
15911591 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( ) ,
15941593 ] ) ,
15951594 ..Default :: default ( )
15961595 } ) ,
@@ -1605,8 +1604,7 @@ fn generate_item_tree(
16051604 statements : Some ( vec ! [
16061605 "static const slint::private_api::ItemArrayEntry items[] {" . to_owned( ) ,
16071606 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( ) ,
16101608 ] ) ,
16111609 ..Default :: default ( )
16121610 } ) ,
@@ -1803,7 +1801,7 @@ fn generate_item_tree(
18031801 . map( |l| format!( "slint::private_api::string_to_slice({l:?})" ) )
18041802 . join( ", " )
18051803 ) ) ;
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)) );" ) ) ;
18071805 }
18081806
18091807 create_code. push ( "self->globals = &self->m_globals;" . into ( ) ) ;
@@ -3397,7 +3395,7 @@ fn compile_expression(expr: &llr::Expression, ctx: &EvaluationContext) -> String
33973395 )
33983396 } else {
33993397 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}) " ,
34013399 count = values. len( ) ,
34023400 ty = ty,
34033401 val = val. join( ", " )
@@ -3511,7 +3509,7 @@ fn compile_expression(expr: &llr::Expression, ctx: &EvaluationContext) -> String
35113509 } ;
35123510 format ! ( "slint::cbindgen_private::GridLayoutCellData {cv}_array [] = {{ {c} }};\
35133511 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)) ",
35153513 r = compile_expression( roles, ctx) ,
35163514 cv = cells_variable,
35173515 c = cells. join( ", " ) ,
@@ -4099,13 +4097,13 @@ fn box_layout_function(
40994097 let ri = repeated_indices. as_ref ( ) . map_or ( String :: new ( ) , |ri| {
41004098 write ! (
41014099 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)) ;"
41034101 )
41044102 . unwrap ( ) ;
41054103 format ! ( "std::array<int, {}> {}_array;" , 2 * repeater_idx, ri)
41064104 } ) ;
41074105 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 {}; }}()" ,
41094107 ri,
41104108 push_code,
41114109 ident( cells_variable) ,
0 commit comments