Move func "sizes_init" to Rust

This commit is contained in:
Alex Kotov 2022-09-07 19:29:09 +04:00
parent 152a2f8e7f
commit 442f08ba9f
Signed by: kotovalexarian
GPG Key ID: 553C0EBBEB5D5F08
3 changed files with 31 additions and 6 deletions

View File

@ -36,12 +36,6 @@ struct WinGeom win_geom_create()
* Default init functions *
**************************/
void sizes_init(const Sizes sizes)
{
sizes->w = 0;
sizes->h = 0;
}
void basic_geom_init(const BasicGeom basic_geom)
{
position_init(&basic_geom->position);

View File

@ -6,12 +6,24 @@ pub struct Position {
y: c_int,
}
#[repr(C)]
pub struct Sizes {
width: c_int,
height: c_int,
}
impl Default for Position {
fn default() -> Self {
Self::new(0, 0)
}
}
impl Default for Sizes {
fn default() -> Self {
Self::new(0, 0)
}
}
impl Position {
fn new(x: c_int, y: c_int) -> Self {
Self { x, y }
@ -25,3 +37,17 @@ impl Position {
self.y
}
}
impl Sizes {
fn new(width: c_int, height: c_int) -> Self {
Self { width, height }
}
fn width(&self) -> c_int {
self.width
}
fn height(&self) -> c_int {
self.height
}
}

View File

@ -58,3 +58,8 @@ extern "C" fn constraints_snap_distance(snap_distance: c_uint) -> c_uint {
unsafe extern "C" fn position_init(position: *mut geom::Position) {
*position = Default::default();
}
#[no_mangle]
unsafe extern "C" fn sizes_init(sizes: &mut geom::Sizes) {
*sizes = Default::default();
}