Skip to content

Commit 58acbae

Browse files
gsk: Manually implement Path.foreach_intersection
1 parent e8b5a62 commit 58acbae

File tree

3 files changed

+46
-44
lines changed

3 files changed

+46
-44
lines changed

gsk4/Gir.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,9 @@ status = "generate"
173173
[[object.function]]
174174
name = "foreach"
175175
manual = true # tries to call from_glib_borrow on an enum
176+
[[object.function]]
177+
name = "foreach_intersection"
178+
manual = true # tries to call from_glib_borrow on an enum
176179

177180
[[object]]
178181
name = "Gsk.PathBuilder"

gsk4/src/auto/path.rs

Lines changed: 0 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,6 @@
22
// from gir-files (https://github.com/gtk-rs/gir-files)
33
// DO NOT EDIT
44

5-
#[cfg(feature = "v4_20")]
6-
#[cfg_attr(docsrs, doc(cfg(feature = "v4_20")))]
7-
use crate::PathIntersection;
85
use crate::{ffi, FillRule, PathPoint, Stroke};
96
use glib::translate::*;
107

@@ -20,47 +17,6 @@ glib::wrapper! {
2017
}
2118

2219
impl Path {
23-
#[cfg(feature = "v4_20")]
24-
#[cfg_attr(docsrs, doc(cfg(feature = "v4_20")))]
25-
#[doc(alias = "gsk_path_foreach_intersection")]
26-
pub fn foreach_intersection<
27-
P: FnMut(&Path, &PathPoint, &Path, &PathPoint, &PathIntersection) -> bool,
28-
>(
29-
&self,
30-
path2: Option<&Path>,
31-
func: P,
32-
) -> bool {
33-
let mut func_data: P = func;
34-
unsafe extern "C" fn func_func<
35-
P: FnMut(&Path, &PathPoint, &Path, &PathPoint, &PathIntersection) -> bool,
36-
>(
37-
path1: *mut ffi::GskPath,
38-
point1: *const ffi::GskPathPoint,
39-
path2: *mut ffi::GskPath,
40-
point2: *const ffi::GskPathPoint,
41-
kind: ffi::GskPathIntersection,
42-
user_data: glib::ffi::gpointer,
43-
) -> glib::ffi::gboolean {
44-
let path1 = from_glib_borrow(path1);
45-
let point1 = from_glib_borrow(point1);
46-
let path2 = from_glib_borrow(path2);
47-
let point2 = from_glib_borrow(point2);
48-
let kind = from_glib_borrow(kind);
49-
let callback = user_data as *mut P;
50-
(*callback)(&path1, &point1, &path2, &point2, &kind).into_glib()
51-
}
52-
let func = Some(func_func::<P> as _);
53-
let super_callback0: &mut P = &mut func_data;
54-
unsafe {
55-
from_glib(ffi::gsk_path_foreach_intersection(
56-
self.to_glib_none().0,
57-
path2.to_glib_none().0,
58-
func,
59-
super_callback0 as *mut _ as *mut _,
60-
))
61-
}
62-
}
63-
6420
#[doc(alias = "gsk_path_get_bounds")]
6521
#[doc(alias = "get_bounds")]
6622
pub fn bounds(&self) -> Option<graphene::Rect> {

gsk4/src/path.rs

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
use glib::translate::*;
44

55
use crate::{ffi, Path, PathForeachFlags, PathOperation};
6+
#[cfg(feature = "v4_20")]
7+
use crate::{PathIntersection, PathPoint};
68

79
impl Path {
810
#[doc(alias = "gsk_path_foreach")]
@@ -37,6 +39,47 @@ impl Path {
3739
))
3840
}
3941
}
42+
43+
#[cfg(feature = "v4_20")]
44+
#[cfg_attr(docsrs, doc(cfg(feature = "v4_20")))]
45+
#[doc(alias = "gsk_path_foreach_intersection")]
46+
pub fn foreach_intersection<
47+
P: FnMut(&Path, &PathPoint, &Path, &PathPoint, PathIntersection) -> bool,
48+
>(
49+
&self,
50+
path2: Option<&Path>,
51+
func: P,
52+
) -> bool {
53+
let mut func_data: P = func;
54+
unsafe extern "C" fn func_func<
55+
P: FnMut(&Path, &PathPoint, &Path, &PathPoint, PathIntersection) -> bool,
56+
>(
57+
path1: *mut ffi::GskPath,
58+
point1: *const ffi::GskPathPoint,
59+
path2: *mut ffi::GskPath,
60+
point2: *const ffi::GskPathPoint,
61+
kind: ffi::GskPathIntersection,
62+
user_data: glib::ffi::gpointer,
63+
) -> glib::ffi::gboolean {
64+
let path1 = from_glib_borrow(path1);
65+
let point1 = from_glib_borrow(point1);
66+
let path2 = from_glib_borrow(path2);
67+
let point2 = from_glib_borrow(point2);
68+
let kind = from_glib(kind);
69+
let callback = user_data as *mut P;
70+
(*callback)(&path1, &point1, &path2, &point2, kind).into_glib()
71+
}
72+
let func = Some(func_func::<P> as _);
73+
let super_callback0: &mut P = &mut func_data;
74+
unsafe {
75+
from_glib(ffi::gsk_path_foreach_intersection(
76+
self.to_glib_none().0,
77+
path2.to_glib_none().0,
78+
func,
79+
super_callback0 as *mut _ as *mut _,
80+
))
81+
}
82+
}
4083
}
4184

4285
impl std::str::FromStr for Path {

0 commit comments

Comments
 (0)