mirror of
https://github.com/slint-ui/slint.git
synced 2025-10-01 14:21:16 +00:00
Move all cbindgen generated code into
sixtyfps::cbindgen_private Having private in the name makes it clear that this is ... private, and cbindgen helps remember that it's generated.
This commit is contained in:
parent
2fa953ce8a
commit
14fe897086
12 changed files with 108 additions and 108 deletions
|
@ -12,7 +12,7 @@ LICENSE END */
|
|||
#include <string_view>
|
||||
|
||||
namespace sixtyfps {
|
||||
namespace internal {
|
||||
namespace cbindgen_private {
|
||||
struct PropertyAnimation;
|
||||
}
|
||||
}
|
||||
|
@ -24,13 +24,13 @@ namespace sixtyfps {
|
|||
template<typename T>
|
||||
struct Property
|
||||
{
|
||||
Property() { internal::sixtyfps_property_init(&inner); }
|
||||
~Property() { internal::sixtyfps_property_drop(&inner); }
|
||||
Property() { cbindgen_private::sixtyfps_property_init(&inner); }
|
||||
~Property() { cbindgen_private::sixtyfps_property_drop(&inner); }
|
||||
Property(const Property &) = delete;
|
||||
Property(Property &&) = delete;
|
||||
Property &operator=(const Property &) = delete;
|
||||
explicit Property(const T &value) : value(value) {
|
||||
internal::sixtyfps_property_init(&inner);
|
||||
cbindgen_private::sixtyfps_property_init(&inner);
|
||||
}
|
||||
|
||||
/* Should it be implicit?
|
||||
|
@ -41,19 +41,19 @@ struct Property
|
|||
void set(const T &value) const
|
||||
{
|
||||
this->value = value;
|
||||
internal::sixtyfps_property_set_changed(&inner);
|
||||
cbindgen_private::sixtyfps_property_set_changed(&inner);
|
||||
}
|
||||
|
||||
const T &get() const
|
||||
{
|
||||
internal::sixtyfps_property_update(&inner, &value);
|
||||
cbindgen_private::sixtyfps_property_update(&inner, &value);
|
||||
return value;
|
||||
}
|
||||
|
||||
template<typename F>
|
||||
void set_binding(F binding) const
|
||||
{
|
||||
internal::sixtyfps_property_set_binding(
|
||||
cbindgen_private::sixtyfps_property_set_binding(
|
||||
&inner,
|
||||
[](void *user_data, void *value) {
|
||||
*reinterpret_cast<T *>(value) = (*reinterpret_cast<F *>(user_data))();
|
||||
|
@ -62,35 +62,35 @@ struct Property
|
|||
}
|
||||
|
||||
inline void set_animated_value(const T &value,
|
||||
const internal::PropertyAnimation &animation_data);
|
||||
const cbindgen_private::PropertyAnimation &animation_data);
|
||||
template<typename F>
|
||||
inline void set_animated_binding(F binding, const internal::PropertyAnimation &animation_data);
|
||||
inline void set_animated_binding(F binding, const cbindgen_private::PropertyAnimation &animation_data);
|
||||
|
||||
private:
|
||||
internal::PropertyHandleOpaque inner;
|
||||
cbindgen_private::PropertyHandleOpaque inner;
|
||||
mutable T value{};
|
||||
};
|
||||
|
||||
template<>
|
||||
void Property<int32_t>::set_animated_value(const int32_t &new_value,
|
||||
const internal::PropertyAnimation &animation_data)
|
||||
const cbindgen_private::PropertyAnimation &animation_data)
|
||||
{
|
||||
internal::sixtyfps_property_set_animated_value_int(&inner, value, new_value, &animation_data);
|
||||
cbindgen_private::sixtyfps_property_set_animated_value_int(&inner, value, new_value, &animation_data);
|
||||
}
|
||||
|
||||
template<>
|
||||
void Property<float>::set_animated_value(const float &new_value,
|
||||
const internal::PropertyAnimation &animation_data)
|
||||
const cbindgen_private::PropertyAnimation &animation_data)
|
||||
{
|
||||
internal::sixtyfps_property_set_animated_value_float(&inner, value, new_value, &animation_data);
|
||||
cbindgen_private::sixtyfps_property_set_animated_value_float(&inner, value, new_value, &animation_data);
|
||||
}
|
||||
|
||||
template<>
|
||||
template<typename F>
|
||||
void Property<int32_t>::set_animated_binding(F binding,
|
||||
const internal::PropertyAnimation &animation_data)
|
||||
const cbindgen_private::PropertyAnimation &animation_data)
|
||||
{
|
||||
internal::sixtyfps_property_set_animated_binding_int(
|
||||
cbindgen_private::sixtyfps_property_set_animated_binding_int(
|
||||
&inner,
|
||||
[](void *user_data, int32_t *value) {
|
||||
*reinterpret_cast<int32_t *>(value) = (*reinterpret_cast<F *>(user_data))();
|
||||
|
@ -102,9 +102,9 @@ void Property<int32_t>::set_animated_binding(F binding,
|
|||
template<>
|
||||
template<typename F>
|
||||
void Property<float>::set_animated_binding(F binding,
|
||||
const internal::PropertyAnimation &animation_data)
|
||||
const cbindgen_private::PropertyAnimation &animation_data)
|
||||
{
|
||||
internal::sixtyfps_property_set_animated_binding_float(
|
||||
cbindgen_private::sixtyfps_property_set_animated_binding_float(
|
||||
&inner,
|
||||
[](void *user_data, float *value) {
|
||||
*reinterpret_cast<float *>(value) = (*reinterpret_cast<F *>(user_data))();
|
||||
|
@ -115,18 +115,18 @@ void Property<float>::set_animated_binding(F binding,
|
|||
|
||||
struct PropertyTracker
|
||||
{
|
||||
PropertyTracker() { internal::sixtyfps_property_tracker_init(&inner); }
|
||||
~PropertyTracker() { internal::sixtyfps_property_tracker_drop(&inner); }
|
||||
PropertyTracker() { cbindgen_private::sixtyfps_property_tracker_init(&inner); }
|
||||
~PropertyTracker() { cbindgen_private::sixtyfps_property_tracker_drop(&inner); }
|
||||
PropertyTracker(const PropertyTracker &) = delete;
|
||||
PropertyTracker &operator=(const PropertyTracker &) = delete;
|
||||
|
||||
bool is_dirty() const {
|
||||
return internal::sixtyfps_property_tracker_is_dirty(&inner);
|
||||
return cbindgen_private::sixtyfps_property_tracker_is_dirty(&inner);
|
||||
}
|
||||
|
||||
template<typename F>
|
||||
void evaluate(const F &f) const {
|
||||
internal::sixtyfps_property_tracker_evaluate(
|
||||
cbindgen_private::sixtyfps_property_tracker_evaluate(
|
||||
&inner,
|
||||
[](void *f){ (*reinterpret_cast<const F*>(f))(); },
|
||||
const_cast<F*>(&f)
|
||||
|
@ -134,7 +134,7 @@ struct PropertyTracker
|
|||
}
|
||||
|
||||
private:
|
||||
internal::PropertyTrackerOpaque inner;
|
||||
cbindgen_private::PropertyTrackerOpaque inner;
|
||||
};
|
||||
|
||||
} // namespace sixtyfps
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue