Closed flxzt closed 2 years ago
There must be something wrong in the Rust bindings, as adding this:
const graphene_point_t points[] = {
GRAPHENE_POINT_INIT (250, 150),
GRAPHENE_POINT_INIT (150, 50),
GRAPHENE_POINT_INIT (50, 150),
GRAPHENE_POINT_INIT (150, 250),
};
const unsigned n_points = sizeof (points) / sizeof (points[0]);
graphene_rect_init (&r, 100, 100, 100, 100);
for (unsigned i = 0; i < n_points; i++)
{
mutest_expect ("a rectangle to not contain a point outside its boundaries",
mutest_bool_value (graphene_rect_contains_point (&r, &(points[i]))),
mutest_to_be, false,
NULL);
}
to the test suite still makes it pass.
It's an ABI mismatch. The problem here is that graphene uses bool
aka _Bool
(1 byte here) instead of gboolean
(int
) for the return type.
<return-value transfer-ownership="none">
<doc xml:space="preserve">`true` if the rectangle contains the point</doc>
<type name="gboolean" c:type="_Bool"/>
</return-value>
Lists the type name as gboolean
but also as C type _Bool
.
How exactly is this supposed to be handled by bindings, and do other non-libgirepository bindings actually handle this at all?
Okay, this is not really an issue in Graphene.
Well, it's an issue in graphene in the sense that it generates wrong introspection data (and maybe should've used proper gboolean
instead of C _Bool
but that's too late now) but I guess the actual bug here would be in gobject-introspection
Graphene is not a GLib library, so of course it can't use gboolean
. :-)
I guess gobject-introspection should treat _Bool
as a native type instead of coercing it into a gboolean
, but then again: _Bool
has no defined size and no GType
representation, so there's a ton more things that need to be done there.
Graphene is not a GLib library, so of course it can't use
gboolean
. :-)
Oh indeed, completely forgot about that :D Sorry
Experienced behavior
Rect::contains_point(&self, p: &Point) returns true for points which are above the rectangle.
Expected behavior
It should return false when they are not inside it.
Steps to reproduce
I experienced this bug while using the
graphene-rs
rust bindings for graphene, so this is rust code. This is the code that can reproduce the issue:Backtrace:
Operating system in use
Fedora 34, gtk4-rs on version
0.2