@@ -79,11 +79,47 @@ i_slint_common::for_each_enums!(declare_enums);
79
79
80
80
pub struct BuiltinTypes {
81
81
pub enums : BuiltinEnums ,
82
+ pub noarg_callback_type : Type ,
83
+ pub strarg_callback_type : Type ,
84
+ pub logical_point_type : Type ,
85
+ pub font_metrics_type : Type ,
82
86
}
83
87
84
88
impl BuiltinTypes {
85
89
fn new ( ) -> Self {
86
- Self { enums : BuiltinEnums :: new ( ) }
90
+ Self {
91
+ enums : BuiltinEnums :: new ( ) ,
92
+ logical_point_type : Type :: Struct ( Rc :: new ( Struct {
93
+ fields : IntoIterator :: into_iter ( [
94
+ ( SmolStr :: new_static ( "x" ) , Type :: LogicalLength ) ,
95
+ ( SmolStr :: new_static ( "y" ) , Type :: LogicalLength ) ,
96
+ ] )
97
+ . collect ( ) ,
98
+ name : Some ( "slint::LogicalPosition" . into ( ) ) ,
99
+ node : None ,
100
+ rust_attributes : None ,
101
+ } ) ) ,
102
+ font_metrics_type : Type :: Struct ( Rc :: new ( Struct {
103
+ fields : IntoIterator :: into_iter ( [
104
+ ( SmolStr :: new_static ( "ascent" ) , Type :: LogicalLength ) ,
105
+ ( SmolStr :: new_static ( "descent" ) , Type :: LogicalLength ) ,
106
+ ( SmolStr :: new_static ( "x-height" ) , Type :: LogicalLength ) ,
107
+ ( SmolStr :: new_static ( "cap-height" ) , Type :: LogicalLength ) ,
108
+ ] )
109
+ . collect ( ) ,
110
+ name : Some ( "slint::private_api::FontMetrics" . into ( ) ) ,
111
+ node : None ,
112
+ rust_attributes : None ,
113
+ } ) ) ,
114
+ noarg_callback_type : Type :: Callback ( Rc :: new ( Callback {
115
+ return_type : None ,
116
+ args : vec ! [ ] ,
117
+ } ) ) ,
118
+ strarg_callback_type : Type :: Callback ( Rc :: new ( Callback {
119
+ return_type : None ,
120
+ args : vec ! [ Type :: String ] ,
121
+ } ) ) ,
122
+ }
87
123
}
88
124
}
89
125
@@ -112,19 +148,11 @@ pub const RESERVED_ROTATION_PROPERTIES: &[(&str, Type)] = &[
112
148
] ;
113
149
114
150
fn noarg_callback_type ( ) -> Type {
115
- thread_local ! {
116
- static TYPE : Type = Type :: Callback ( Rc :: new( Callback { return_type: None , args: vec![ ] } ) ) ;
117
- }
118
-
119
- TYPE . with ( |t| t. clone ( ) )
151
+ BUILTIN . with ( |types| types. noarg_callback_type . clone ( ) )
120
152
}
121
153
122
154
fn strarg_callback_type ( ) -> Type {
123
- thread_local ! {
124
- static TYPE : Type = Type :: Callback ( Rc :: new( Callback { return_type: None , args: vec![ Type :: String ] } ) ) ;
125
- }
126
-
127
- TYPE . with ( |t| t. clone ( ) )
155
+ BUILTIN . with ( |types| types. strarg_callback_type . clone ( ) )
128
156
}
129
157
130
158
pub fn reserved_accessibility_properties ( ) -> impl Iterator < Item = ( & ' static str , Type ) > {
@@ -599,35 +627,9 @@ impl TypeRegister {
599
627
}
600
628
601
629
pub fn logical_point_type ( ) -> Type {
602
- thread_local ! {
603
- static TYPE : Type = Type :: Struct ( Rc :: new( Struct {
604
- fields: IntoIterator :: into_iter( [
605
- ( SmolStr :: new_static( "x" ) , Type :: LogicalLength ) ,
606
- ( SmolStr :: new_static( "y" ) , Type :: LogicalLength ) ,
607
- ] )
608
- . collect( ) ,
609
- name: Some ( "slint::LogicalPosition" . into( ) ) ,
610
- node: None ,
611
- rust_attributes: None ,
612
- } ) ) ;
613
- }
614
- TYPE . with ( |t| t. clone ( ) )
630
+ BUILTIN . with ( |types| types. logical_point_type . clone ( ) )
615
631
}
616
632
617
633
pub fn font_metrics_type ( ) -> Type {
618
- thread_local ! {
619
- static TYPE : Type = Type :: Struct ( Rc :: new( Struct {
620
- fields: IntoIterator :: into_iter( [
621
- ( SmolStr :: new_static( "ascent" ) , Type :: LogicalLength ) ,
622
- ( SmolStr :: new_static( "descent" ) , Type :: LogicalLength ) ,
623
- ( SmolStr :: new_static( "x-height" ) , Type :: LogicalLength ) ,
624
- ( SmolStr :: new_static( "cap-height" ) , Type :: LogicalLength ) ,
625
- ] )
626
- . collect( ) ,
627
- name: Some ( "slint::private_api::FontMetrics" . into( ) ) ,
628
- node: None ,
629
- rust_attributes: None ,
630
- } ) ) ;
631
- }
632
- TYPE . with ( |t| t. clone ( ) )
634
+ BUILTIN . with ( |types| types. font_metrics_type . clone ( ) )
633
635
}
0 commit comments