Move func "sizes_init" to Rust
This commit is contained in:
parent
152a2f8e7f
commit
442f08ba9f
|
@ -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);
|
||||
|
|
26
src/geom.rs
26
src/geom.rs
|
@ -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
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue