Fix build of generated C++ code when using transitions on int properties with esp-idf

The energy monitor declares a transition on an animated int property,
for which Property<int>::set_animated_binding_for_transition is called,
which in turn calls slint_property_set_animated_binding_helper. The
latter is overloaded for various property types, such as float, Color,
or Brush, and then calls specialized functions from ffi, such as

slint_property_set_animated_binding_(int|float|etc.).

slint_property_set_animated_binding_int uses i32 in Rust, which cbindgen
maps to int32_t, so the
slint_property_set_animated_binding_helper overload also uses int32_t.

Unfortunately, with esp-idf, int32_t is a distinct type from int, and
the overload resolution fails.

As remedy, this change uses c_int instead of i32 in the Rust ffi, which
maps to int.

This seems easier than changing Property<int> to Property<int32_t> :-)
This commit is contained in:
Simon Hausmann 2024-03-12 12:39:36 +01:00 committed by Simon Hausmann
parent ac23952927
commit b1f408f683
2 changed files with 2 additions and 2 deletions

View file

@ -17,7 +17,7 @@ namespace slint::private_api {
using cbindgen_private::StateInfo;
inline void slint_property_set_animated_binding_helper(
const cbindgen_private::PropertyHandleOpaque *handle, void (*binding)(void *, int32_t *),
const cbindgen_private::PropertyHandleOpaque *handle, void (*binding)(void *, int *),
void *user_data, void (*drop_user_data)(void *),
const cbindgen_private::PropertyAnimation *animation_data,
cbindgen_private::PropertyAnimation (*transition_data)(void *, uint64_t *))