Skip to content

Commit b88707d

Browse files
committed
Prefix style methods with TaffyStyle
1 parent 69c52f5 commit b88707d

File tree

1 file changed

+13
-11
lines changed

1 file changed

+13
-11
lines changed

src/ffi/style.rs

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use super::{GridPlacement, ReturnCode, StyleValue, StyleValueResult, StyleValueU
99
/// A wrapper around [`core::Style`] which allows the individual style properties to be accessed
1010
/// via FFI-friendly getter and setter functions
1111
#[repr(transparent)]
12-
pub struct Style {
12+
pub struct TaffyStyle {
1313
pub(crate) inner: core::Style,
1414
}
1515

@@ -28,7 +28,7 @@ macro_rules! assert_style_pointer_is_non_null {
2828
macro_rules! get_style {
2929
($raw_style_ptr:expr, $style_ident:ident, $block:expr) => {{
3030
assert_style_pointer_is_non_null!($raw_style_ptr);
31-
let style_box = unsafe { Box::from_raw($raw_style_ptr as *mut Style) };
31+
let style_box = unsafe { Box::from_raw($raw_style_ptr as *mut TaffyStyle) };
3232
let $style_ident = &style_box.inner;
3333

3434
let return_value = $block;
@@ -45,7 +45,7 @@ macro_rules! get_style {
4545
macro_rules! with_style_mut {
4646
($raw_style_ptr:expr, $style_ident:ident, $block:expr) => {{
4747
assert_style_pointer_is_non_null!($raw_style_ptr);
48-
let mut style_box = unsafe { Box::from_raw($raw_style_ptr as *mut Style) };
48+
let mut style_box = unsafe { Box::from_raw($raw_style_ptr as *mut TaffyStyle) };
4949
let $style_ident = &mut style_box.inner;
5050

5151
$block;
@@ -78,19 +78,19 @@ macro_rules! try_from_raw {
7878

7979
/// Function to get the margin_top value
8080
#[no_mangle]
81-
pub unsafe extern "C" fn Taffy_get_margin_top(raw_style: *const c_void) -> StyleValueResult {
81+
pub unsafe extern "C" fn TaffyStyle_get_margin_top(raw_style: *const c_void) -> StyleValueResult {
8282
get_style!(raw_style, style, style.margin.top)
8383
}
8484

8585
/// Function to set the margin_top value
8686
#[no_mangle]
87-
pub unsafe extern "C" fn Taffy_set_margin_top(raw_style: *mut c_void, value: StyleValue) -> ReturnCode {
87+
pub unsafe extern "C" fn TaffyStyle_set_margin_top(raw_style: *mut c_void, value: StyleValue) -> ReturnCode {
8888
with_style_mut!(raw_style, style, style.margin.top = try_from_value!(value))
8989
}
9090

9191
/// Function to set all the value of margin
9292
#[no_mangle]
93-
pub unsafe extern "C" fn Taffy_set_margin_trbl(
93+
pub unsafe extern "C" fn TaffyStyle_set_margin_trbl(
9494
raw_style: *mut c_void,
9595
top: StyleValue,
9696
right: StyleValue,
@@ -111,19 +111,19 @@ pub unsafe extern "C" fn Taffy_set_margin_trbl(
111111

112112
/// Function to get the margin_top value
113113
#[no_mangle]
114-
pub unsafe extern "C" fn Taffy_get_padding_top(raw_style: *const c_void) -> StyleValueResult {
114+
pub unsafe extern "C" fn TaffyStyle_get_padding_top(raw_style: *const c_void) -> StyleValueResult {
115115
get_style!(raw_style, style, style.padding.top)
116116
}
117117

118118
/// Function to set the padding_top value
119119
#[no_mangle]
120-
pub unsafe extern "C" fn Taffy_set_padding_top(raw_style: *mut c_void, value: f32, unit: StyleValueUnit) -> ReturnCode {
120+
pub unsafe extern "C" fn TaffyStyle_set_padding_top(raw_style: *mut c_void, value: f32, unit: StyleValueUnit) -> ReturnCode {
121121
with_style_mut!(raw_style, style, style.padding.top = try_from_raw!(unit, value))
122122
}
123123

124124
/// Function to set all the value of padding
125125
#[no_mangle]
126-
pub unsafe extern "C" fn Taffy_set_padding_trbl(
126+
pub unsafe extern "C" fn TaffyStyle_set_padding_trbl(
127127
raw_style: *mut c_void,
128128
top_value: f32,
129129
top_value_unit: StyleValueUnit,
@@ -147,11 +147,13 @@ pub unsafe extern "C" fn Taffy_set_padding_trbl(
147147
/* Grid APIs */
148148

149149
/// Get grid item's column placement
150-
pub fn style_get_grid_column(raw_style: *mut c_void) -> GridPlacementResult {
150+
#[no_mangle]
151+
pub unsafe extern "C" fn TaffyStyle_get_grid_column(raw_style: *mut c_void) -> GridPlacementResult {
151152
get_style!(raw_style, style, style.grid_column)
152153
}
153154

154155
/// Set grid item's column placement
155-
pub fn style_set_grid_column(raw_style: *mut c_void, placement: GridPlacement) -> ReturnCode {
156+
#[no_mangle]
157+
pub unsafe extern "C" fn TaffyStyle_set_grid_column(raw_style: *mut c_void, placement: GridPlacement) -> ReturnCode {
156158
with_style_mut!(raw_style, style, style.grid_column = placement.into())
157159
}

0 commit comments

Comments
 (0)