@@ -8,9 +8,6 @@ use super::{
8
8
use std:: ffi:: c_void;
9
9
use taffy:: prelude as core;
10
10
11
- pub struct TaffyStyle ;
12
- pub type TaffyStyleRef = * mut TaffyStyle ;
13
-
14
11
/// Return [`ReturnCode::NullStylePointer`] if the passed pointer is null
15
12
macro_rules! assert_style_pointer_is_non_null {
16
13
( $raw_style_ptr: expr) => { {
@@ -72,7 +69,7 @@ macro_rules! try_from_raw {
72
69
macro_rules! enum_prop_getter {
73
70
( $func_name: ident; $( $props: ident) .+) => {
74
71
#[ no_mangle]
75
- pub unsafe extern "C" fn $func_name( raw_style: * const TaffyStyle ) -> IntResult {
72
+ pub unsafe extern "C" fn $func_name( raw_style: TaffyStyleConstRef ) -> IntResult {
76
73
get_style!( raw_style, style, style. $( $props) .* as i32 )
77
74
}
78
75
} ;
@@ -81,7 +78,7 @@ macro_rules! enum_prop_getter {
81
78
macro_rules! option_enum_prop_getter {
82
79
( $func_name: ident; $( $props: ident) .+) => {
83
80
#[ no_mangle]
84
- pub unsafe extern "C" fn $func_name( raw_style: * const TaffyStyle ) -> IntResult {
81
+ pub unsafe extern "C" fn $func_name( raw_style: TaffyStyleConstRef ) -> IntResult {
85
82
get_style!( raw_style, style, style. $( $props) .* . map( |v| v as i32 ) . unwrap_or( 0 ) )
86
83
}
87
84
} ;
@@ -91,7 +88,7 @@ macro_rules! option_enum_prop_getter {
91
88
macro_rules! enum_prop_setter {
92
89
( $func_name: ident; $( $props: ident) .+; $enum: ident) => {
93
90
#[ no_mangle]
94
- pub unsafe extern "C" fn $func_name( raw_style: * mut TaffyStyle , value: $enum) -> ReturnCode {
91
+ pub unsafe extern "C" fn $func_name( raw_style: TaffyStyleMutRef , value: $enum) -> ReturnCode {
95
92
with_style_mut!( raw_style, style, style. $( $props) .* = value. into( ) )
96
93
}
97
94
} ;
@@ -141,7 +138,7 @@ enum_prop_setter!(TaffyStyle_SetGridAutoFlow; grid_auto_flow; TaffyGridAutoFlow)
141
138
macro_rules! style_value_prop_getter {
142
139
( $func_name: ident; $( $props: ident) .+) => {
143
140
#[ no_mangle]
144
- pub unsafe extern "C" fn $func_name( raw_style: * const TaffyStyle ) -> StyleValueResult {
141
+ pub unsafe extern "C" fn $func_name( raw_style: TaffyStyleConstRef ) -> StyleValueResult {
145
142
get_style!( raw_style, style, style. $( $props) .* )
146
143
}
147
144
} ;
@@ -151,7 +148,7 @@ macro_rules! style_value_prop_getter {
151
148
macro_rules! style_value_prop_setter {
152
149
( $func_name: ident; $( $props: ident) .+) => {
153
150
#[ no_mangle]
154
- pub unsafe extern "C" fn $func_name( raw_style: * mut TaffyStyle , value: f32 , unit: StyleValueUnit ) -> ReturnCode {
151
+ pub unsafe extern "C" fn $func_name( raw_style: TaffyStyleMutRef , value: f32 , unit: StyleValueUnit ) -> ReturnCode {
155
152
with_style_mut!( raw_style, style, style. $( $props) .* = try_from_raw!( unit, value) )
156
153
}
157
154
} ;
@@ -223,11 +220,11 @@ style_value_prop_setter!(TaffyStyle_SetRowGap; gap.height);
223
220
224
221
// Aspect ratio
225
222
#[ no_mangle]
226
- pub unsafe extern "C" fn TaffyStyle_GetAspectRatio ( raw_style : * const TaffyStyle ) -> FloatResult {
223
+ pub unsafe extern "C" fn TaffyStyle_GetAspectRatio ( raw_style : TaffyStyleConstRef ) -> FloatResult {
227
224
get_style ! ( raw_style, style, style. aspect_ratio. unwrap_or( f32 :: NAN ) )
228
225
}
229
226
#[ no_mangle]
230
- pub unsafe extern "C" fn TaffyStyle_SetAspectRatio ( raw_style : * mut TaffyStyle , value : f32 ) -> ReturnCode {
227
+ pub unsafe extern "C" fn TaffyStyle_SetAspectRatio ( raw_style : TaffyStyleMutRef , value : f32 ) -> ReturnCode {
231
228
with_style_mut ! ( raw_style, style, {
232
229
if value. is_finite( ) && value > 0.0 {
233
230
style. aspect_ratio = Some ( value)
@@ -241,7 +238,7 @@ pub unsafe extern "C" fn TaffyStyle_SetAspectRatio(raw_style: *mut TaffyStyle, v
241
238
macro_rules! float_prop_getter {
242
239
( $func_name: ident; $( $props: ident) .+) => {
243
240
#[ no_mangle]
244
- pub unsafe extern "C" fn $func_name( raw_style: * const TaffyStyle ) -> FloatResult {
241
+ pub unsafe extern "C" fn $func_name( raw_style: TaffyStyleConstRef ) -> FloatResult {
245
242
get_style!( raw_style, style, style. $( $props) .* )
246
243
}
247
244
} ;
@@ -251,7 +248,7 @@ macro_rules! float_prop_getter {
251
248
macro_rules! float_prop_setter {
252
249
( $func_name: ident; $( $props: ident) .+) => {
253
250
#[ no_mangle]
254
- pub unsafe extern "C" fn $func_name( raw_style: * mut TaffyStyle , value: f32 ) -> ReturnCode {
251
+ pub unsafe extern "C" fn $func_name( raw_style: TaffyStyleMutRef , value: f32 ) -> ReturnCode {
255
252
with_style_mut!( raw_style, style, style. $( $props) .* = value)
256
253
}
257
254
} ;
@@ -272,7 +269,7 @@ float_prop_setter!(TaffyStyle_SetFlexShrink; flex_shrink);
272
269
/// Function to set all the value of margin
273
270
#[ no_mangle]
274
271
pub unsafe extern "C" fn TaffyStyle_SetMargin (
275
- raw_style : * mut TaffyStyle ,
272
+ raw_style : TaffyStyleMutRef ,
276
273
edge : TaffyEdge ,
277
274
value : StyleValue ,
278
275
) -> ReturnCode {
@@ -305,12 +302,12 @@ pub unsafe extern "C" fn TaffyStyle_SetMargin(
305
302
306
303
/// Get grid item's column placement
307
304
#[ no_mangle]
308
- pub unsafe extern "C" fn TaffyStyleGetGridColumn ( raw_style : * mut TaffyStyle ) -> GridPlacementResult {
305
+ pub unsafe extern "C" fn TaffyStyleGetGridColumn ( raw_style : TaffyStyleMutRef ) -> GridPlacementResult {
309
306
get_style ! ( raw_style, style, style. grid_column)
310
307
}
311
308
312
309
/// Set grid item's column placement
313
310
#[ no_mangle]
314
- pub unsafe extern "C" fn TaffyStyleSetGridColumn ( raw_style : * mut TaffyStyle , placement : GridPlacement ) -> ReturnCode {
311
+ pub unsafe extern "C" fn TaffyStyleSetGridColumn ( raw_style : TaffyStyleMutRef , placement : GridPlacement ) -> ReturnCode {
315
312
with_style_mut ! ( raw_style, style, style. grid_column = placement. into( ) )
316
313
}
0 commit comments