Rename C ffi functions

This commit is contained in:
Simon Hausmann 2022-02-02 11:02:03 +01:00
parent 7ee19cf7c0
commit c846633708
37 changed files with 391 additions and 407 deletions

View file

@ -137,14 +137,14 @@ fn gen_corelib(
"PathData",
"PathElement",
"Brush",
"sixtyfps_new_path_elements",
"sixtyfps_new_path_events",
"slint_new_path_elements",
"slint_new_path_events",
"Property",
"Slice",
"PropertyHandleOpaque",
"Callback",
"sixtyfps_property_listener_scope_evaluate",
"sixtyfps_property_listener_scope_is_dirty",
"slint_property_listener_scope_evaluate",
"slint_property_listener_scope_is_dirty",
"PropertyTrackerOpaque",
"CallbackOpaque",
"WindowRc",
@ -153,10 +153,10 @@ fn gen_corelib(
"PointerEventArg",
"PointArg",
"Point",
"sixtyfps_color_brighter",
"sixtyfps_color_darker",
"sixtyfps_image_size",
"sixtyfps_image_path",
"slint_color_brighter",
"slint_color_darker",
"slint_image_size",
"slint_image_path",
"TimerMode", // included in generated_public.h
"IntSize", // included in generated_public.h
]
@ -216,8 +216,8 @@ fn gen_corelib(
"ImageInner",
"Image",
"Size",
"sixtyfps_image_size",
"sixtyfps_image_path",
"slint_image_size",
"slint_image_path",
"SharedPixelBuffer",
"SharedImageBuffer",
],
@ -225,17 +225,12 @@ fn gen_corelib(
"sixtyfps_image_internal.h",
),
(
vec!["Color", "sixtyfps_color_brighter", "sixtyfps_color_darker"],
vec!["Color", "slint_color_brighter", "slint_color_darker"],
vec![],
"sixtyfps_color_internal.h",
),
(
vec![
"PathData",
"PathElement",
"sixtyfps_new_path_elements",
"sixtyfps_new_path_events",
],
vec!["PathData", "PathElement", "slint_new_path_elements", "slint_new_path_events"],
vec![],
"sixtyfps_pathdata_internal.h",
),
@ -250,23 +245,23 @@ fn gen_corelib(
let mut special_config = config.clone();
special_config.export.include = rust_types.iter().map(|s| s.to_string()).collect();
special_config.export.exclude = [
"sixtyfps_visit_item_tree",
"sixtyfps_windowrc_drop",
"sixtyfps_windowrc_clone",
"sixtyfps_windowrc_show",
"sixtyfps_windowrc_hide",
"sixtyfps_windowrc_get_scale_factor",
"sixtyfps_windowrc_set_scale_factor",
"sixtyfps_windowrc_free_graphics_resources",
"sixtyfps_windowrc_set_focus_item",
"sixtyfps_windowrc_set_component",
"sixtyfps_windowrc_show_popup",
"sixtyfps_new_path_elements",
"sixtyfps_new_path_events",
"sixtyfps_color_brighter",
"sixtyfps_color_darker",
"sixtyfps_image_size",
"sixtyfps_image_path",
"slint_visit_item_tree",
"slint_windowrc_drop",
"slint_windowrc_clone",
"slint_windowrc_show",
"slint_windowrc_hide",
"slint_windowrc_get_scale_factor",
"slint_windowrc_set_scale_factor",
"slint_windowrc_free_graphics_resources",
"slint_windowrc_set_focus_item",
"slint_windowrc_set_component",
"slint_windowrc_show_popup",
"slint_new_path_elements",
"slint_new_path_events",
"slint_color_brighter",
"slint_color_darker",
"slint_image_size",
"slint_image_path",
"IntSize",
]
.iter()

View file

@ -81,12 +81,12 @@ class WindowRc
{
public:
explicit WindowRc(cbindgen_private::WindowRcOpaque adopted_inner) : inner(adopted_inner) { }
WindowRc() { cbindgen_private::sixtyfps_windowrc_init(&inner); }
~WindowRc() { cbindgen_private::sixtyfps_windowrc_drop(&inner); }
WindowRc() { cbindgen_private::slint_windowrc_init(&inner); }
~WindowRc() { cbindgen_private::slint_windowrc_drop(&inner); }
WindowRc(const WindowRc &other)
{
assert_main_thread();
cbindgen_private::sixtyfps_windowrc_clone(&other.inner, &inner);
cbindgen_private::slint_windowrc_clone(&other.inner, &inner);
}
WindowRc(WindowRc &&) = delete;
WindowRc &operator=(WindowRc &&) = delete;
@ -94,35 +94,35 @@ public:
{
assert_main_thread();
if (this != &other) {
cbindgen_private::sixtyfps_windowrc_drop(&inner);
cbindgen_private::sixtyfps_windowrc_clone(&other.inner, &inner);
cbindgen_private::slint_windowrc_drop(&inner);
cbindgen_private::slint_windowrc_clone(&other.inner, &inner);
}
return *this;
}
void show() const { sixtyfps_windowrc_show(&inner); }
void hide() const { sixtyfps_windowrc_hide(&inner); }
void show() const { slint_windowrc_show(&inner); }
void hide() const { slint_windowrc_hide(&inner); }
float scale_factor() const { return sixtyfps_windowrc_get_scale_factor(&inner); }
void set_scale_factor(float value) const { sixtyfps_windowrc_set_scale_factor(&inner, value); }
float scale_factor() const { return slint_windowrc_get_scale_factor(&inner); }
void set_scale_factor(float value) const { slint_windowrc_set_scale_factor(&inner, value); }
template<typename Component, typename ItemTree>
void free_graphics_resources(Component *c, ItemTree items) const
{
cbindgen_private::sixtyfps_component_free_item_graphics_resources(
cbindgen_private::slint_component_free_item_graphics_resources(
vtable::VRef<ComponentVTable> { &Component::static_vtable, c }, items, &inner);
}
void set_focus_item(const ComponentRc &component_rc, uintptr_t item_index)
{
cbindgen_private::ItemRc item_rc { component_rc, item_index };
cbindgen_private::sixtyfps_windowrc_set_focus_item(&inner, &item_rc);
cbindgen_private::slint_windowrc_set_focus_item(&inner, &item_rc);
}
template<typename Component, typename ItemTree>
void init_items(Component *c, ItemTree items) const
{
cbindgen_private::sixtyfps_component_init_items(
cbindgen_private::slint_component_init_items(
vtable::VRef<ComponentVTable> { &Component::static_vtable, c }, items, &inner);
}
@ -130,7 +130,7 @@ public:
void set_component(const Component &c) const
{
auto self_rc = c.self_weak.lock().value().into_dyn();
sixtyfps_windowrc_set_component(&inner, &self_rc);
slint_windowrc_set_component(&inner, &self_rc);
}
template<typename Component, typename Parent>
@ -138,7 +138,7 @@ public:
cbindgen_private::ItemRc parent_item) const
{
auto popup = Component::create(parent_component).into_dyn();
cbindgen_private::sixtyfps_windowrc_show_popup(&inner, &popup, p, &parent_item);
cbindgen_private::slint_windowrc_show_popup(&inner, &popup, p, &parent_item);
}
private:
@ -160,7 +160,8 @@ constexpr inline ItemTreeNode make_dyn_node(std::uintptr_t offset, std::uint32_t
parent_index } };
}
inline ItemRef get_item_ref(ComponentRef component, cbindgen_private::Slice<ItemTreeNode> item_tree, int index)
inline ItemRef get_item_ref(ComponentRef component, cbindgen_private::Slice<ItemTreeNode> item_tree,
int index)
{
const auto &item = item_tree.ptr[index].item.item;
return ItemRef { item.vtable, reinterpret_cast<char *>(component.instance) + item.offset };
@ -338,7 +339,7 @@ struct Timer
/// `start(sixtyfps::TimerMode::Repeated, interval, callback);` on a default constructed Timer.
template<typename F>
Timer(std::chrono::milliseconds interval, F callback)
: id(cbindgen_private::sixtyfps_timer_start(
: id(cbindgen_private::slint_timer_start(
-1, TimerMode::Repeated, interval.count(),
[](void *data) { (*reinterpret_cast<F *>(data))(); }, new F(std::move(callback)),
[](void *data) { delete reinterpret_cast<F *>(data); }))
@ -346,7 +347,7 @@ struct Timer
}
Timer(const Timer &) = delete;
Timer &operator=(const Timer &) = delete;
~Timer() { cbindgen_private::sixtyfps_timer_destroy(id); }
~Timer() { cbindgen_private::slint_timer_destroy(id); }
/// Starts the timer with the given \a mode and \a interval, in order for the \a callback to
/// called when the timer fires. If the timer has been started previously and not fired yet,
@ -354,27 +355,27 @@ struct Timer
template<typename F>
void start(TimerMode mode, std::chrono::milliseconds interval, F callback)
{
id = cbindgen_private::sixtyfps_timer_start(
id = cbindgen_private::slint_timer_start(
id, mode, interval.count(), [](void *data) { (*reinterpret_cast<F *>(data))(); },
new F(std::move(callback)), [](void *data) { delete reinterpret_cast<F *>(data); });
}
/// Stops the previously started timer. Does nothing if the timer has never been started. A
/// stopped timer cannot be restarted with restart() -- instead you need to call start().
void stop() { cbindgen_private::sixtyfps_timer_stop(id); }
void stop() { cbindgen_private::slint_timer_stop(id); }
/// Restarts the timer. If the timer was previously started by calling [`Self::start()`]
/// with a duration and callback, then the time when the callback will be next invoked
/// is re-calculated to be in the specified duration relative to when this function is called.
///
/// Does nothing if the timer was never started.
void restart() { cbindgen_private::sixtyfps_timer_restart(id); }
void restart() { cbindgen_private::slint_timer_restart(id); }
/// Returns true if the timer is running; false otherwise.
bool running() const { return cbindgen_private::sixtyfps_timer_running(id); }
bool running() const { return cbindgen_private::slint_timer_running(id); }
/// Call the callback after the given duration.
template<typename F>
static void single_shot(std::chrono::milliseconds duration, F callback)
{
cbindgen_private::sixtyfps_timer_singleshot(
cbindgen_private::slint_timer_singleshot(
duration.count(), [](void *data) { (*reinterpret_cast<F *>(data))(); },
new F(std::move(callback)), [](void *data) { delete reinterpret_cast<F *>(data); });
}
@ -402,15 +403,16 @@ inline SharedVector<float> solve_box_layout(const cbindgen_private::BoxLayoutDat
cbindgen_private::Slice<int> repeater_indexes)
{
SharedVector<float> result;
cbindgen_private::Slice<uint32_t> ri { reinterpret_cast<uint32_t *>(repeater_indexes.ptr), repeater_indexes.len };
cbindgen_private::sixtyfps_solve_box_layout(&data, ri, &result);
cbindgen_private::Slice<uint32_t> ri { reinterpret_cast<uint32_t *>(repeater_indexes.ptr),
repeater_indexes.len };
cbindgen_private::slint_solve_box_layout(&data, ri, &result);
return result;
}
inline SharedVector<float> solve_grid_layout(const cbindgen_private::GridLayoutData &data)
{
SharedVector<float> result;
cbindgen_private::sixtyfps_solve_grid_layout(&data, &result);
cbindgen_private::slint_solve_grid_layout(&data, &result);
return result;
}
@ -418,7 +420,7 @@ inline cbindgen_private::LayoutInfo
grid_layout_info(cbindgen_private::Slice<cbindgen_private::GridLayoutCellData> cells, float spacing,
const cbindgen_private::Padding &padding)
{
return cbindgen_private::sixtyfps_grid_layout_info(cells, spacing, &padding);
return cbindgen_private::slint_grid_layout_info(cells, spacing, &padding);
}
inline cbindgen_private::LayoutInfo
@ -426,22 +428,23 @@ box_layout_info(cbindgen_private::Slice<cbindgen_private::BoxLayoutCellData> cel
const cbindgen_private::Padding &padding,
cbindgen_private::LayoutAlignment alignment)
{
return cbindgen_private::sixtyfps_box_layout_info(cells, spacing, &padding, alignment);
return cbindgen_private::slint_box_layout_info(cells, spacing, &padding, alignment);
}
inline cbindgen_private::LayoutInfo
box_layout_info_ortho(cbindgen_private::Slice<cbindgen_private::BoxLayoutCellData> cells,
const cbindgen_private::Padding &padding)
{
return cbindgen_private::sixtyfps_box_layout_info_ortho(cells, &padding);
return cbindgen_private::slint_box_layout_info_ortho(cells, &padding);
}
inline SharedVector<float> solve_path_layout(const cbindgen_private::PathLayoutData &data,
cbindgen_private::Slice<int> repeater_indexes)
{
SharedVector<float> result;
cbindgen_private::Slice<uint32_t> ri { reinterpret_cast<uint32_t *>(repeater_indexes.ptr), repeater_indexes.len };
cbindgen_private::sixtyfps_solve_path_layout(&data, ri, &result);
cbindgen_private::Slice<uint32_t> ri { reinterpret_cast<uint32_t *>(repeater_indexes.ptr),
repeater_indexes.len };
cbindgen_private::slint_solve_path_layout(&data, ri, &result);
return result;
}
@ -463,7 +466,8 @@ struct AbstractRepeaterView
using ModelPeer = std::weak_ptr<AbstractRepeaterView>;
template<typename M>
auto access_array_index(const M &model, int index) {
auto access_array_index(const M &model, int index)
{
model->track_row_data_changes(index);
if (const auto v = model->row_data(index)) {
return *v;
@ -823,21 +827,21 @@ public:
#if !defined(DOXYGEN)
cbindgen_private::Flickable::Flickable()
{
sixtyfps_flickable_data_init(&data);
slint_flickable_data_init(&data);
}
cbindgen_private::Flickable::~Flickable()
{
sixtyfps_flickable_data_free(&data);
slint_flickable_data_free(&data);
}
cbindgen_private::NativeStyleMetrics::NativeStyleMetrics()
{
sixtyfps_native_style_metrics_init(this);
slint_native_style_metrics_init(this);
}
cbindgen_private::NativeStyleMetrics::~NativeStyleMetrics()
{
sixtyfps_native_style_metrics_deinit(this);
slint_native_style_metrics_deinit(this);
}
#endif // !defined(DOXYGEN)
@ -858,7 +862,7 @@ struct VersionCheckHelper
inline void run_event_loop()
{
private_api::assert_main_thread();
cbindgen_private::sixtyfps_run_event_loop();
cbindgen_private::slint_run_event_loop();
}
/// Schedules the main event loop for termination. This function is meant
@ -867,7 +871,7 @@ inline void run_event_loop()
/// the initial call to sixtyfps::run_event_loop() will return.
inline void quit_event_loop()
{
cbindgen_private::sixtyfps_quit_event_loop();
cbindgen_private::slint_quit_event_loop();
}
/// Adds the specified functor to an internal queue, notifies the event loop to wake up.
@ -910,7 +914,7 @@ inline void quit_event_loop()
template<typename Functor>
void invoke_from_event_loop(Functor f)
{
cbindgen_private::sixtyfps_post_event(
cbindgen_private::slint_post_event(
[](void *data) { (*reinterpret_cast<Functor *>(data))(); }, new Functor(std::move(f)),
[](void *data) { delete reinterpret_cast<Functor *>(data); });
}
@ -993,7 +997,7 @@ namespace private_api {
inline std::optional<SharedString> register_font_from_path(const SharedString &path)
{
SharedString maybe_err;
cbindgen_private::sixtyfps_register_font_from_path(&path, &maybe_err);
cbindgen_private::slint_register_font_from_path(&path, &maybe_err);
if (!maybe_err.empty()) {
return maybe_err;
} else {
@ -1006,8 +1010,8 @@ inline std::optional<SharedString> register_font_from_path(const SharedString &p
inline std::optional<SharedString> register_font_from_data(const uint8_t *data, std::size_t len)
{
SharedString maybe_err;
cbindgen_private::sixtyfps_register_font_from_data({ const_cast<uint8_t *>(data), len },
&maybe_err);
cbindgen_private::slint_register_font_from_data({ const_cast<uint8_t *>(data), len },
&maybe_err);
if (!maybe_err.empty()) {
return maybe_err;
} else {

View file

@ -19,9 +19,9 @@ template<typename Ret, typename... Arg>
struct Callback<Ret(Arg...)>
{
/// Constructs an empty callback that contains no handler.
Callback() { cbindgen_private::sixtyfps_callback_init(&inner); }
Callback() { cbindgen_private::slint_callback_init(&inner); }
/// Destructs the callback.
~Callback() { cbindgen_private::sixtyfps_callback_drop(&inner); }
~Callback() { cbindgen_private::slint_callback_drop(&inner); }
Callback(const Callback &) = delete;
Callback(Callback &&) = delete;
Callback &operator=(const Callback &) = delete;
@ -30,7 +30,7 @@ struct Callback<Ret(Arg...)>
template<typename F>
void set_handler(F binding) const
{
cbindgen_private::sixtyfps_callback_set_handler(
cbindgen_private::slint_callback_set_handler(
&inner,
[](void *user_data, const void *arg, void *ret) {
*reinterpret_cast<Ret *>(ret) =
@ -47,7 +47,7 @@ struct Callback<Ret(Arg...)>
{
Ret r {};
Tuple tuple { arg... };
cbindgen_private::sixtyfps_callback_call(&inner, &tuple, &r);
cbindgen_private::slint_callback_call(&inner, &tuple, &r);
return r;
}
@ -63,9 +63,9 @@ template<typename... Arg>
struct Callback<void(Arg...)>
{
/// Constructs an empty callback that contains no handler.
Callback() { cbindgen_private::sixtyfps_callback_init(&inner); }
Callback() { cbindgen_private::slint_callback_init(&inner); }
/// Destructs the callback.
~Callback() { cbindgen_private::sixtyfps_callback_drop(&inner); }
~Callback() { cbindgen_private::slint_callback_drop(&inner); }
Callback(const Callback &) = delete;
Callback(Callback &&) = delete;
Callback &operator=(const Callback &) = delete;
@ -74,7 +74,7 @@ struct Callback<void(Arg...)>
template<typename F>
void set_handler(F binding) const
{
cbindgen_private::sixtyfps_callback_set_handler(
cbindgen_private::slint_callback_set_handler(
&inner,
[](void *user_data, const void *arg, void *) {
std::apply(*reinterpret_cast<F *>(user_data),
@ -88,7 +88,7 @@ struct Callback<void(Arg...)>
void call(const Arg &...arg) const
{
Tuple tuple { arg... };
cbindgen_private::sixtyfps_callback_call(&inner, &tuple, reinterpret_cast<void *>(0x1));
cbindgen_private::slint_callback_call(&inner, &tuple, reinterpret_cast<void *>(0x1));
}
private:

View file

@ -175,14 +175,14 @@ private:
inline Color Color::brighter(float factor) const
{
Color result;
cbindgen_private::types::sixtyfps_color_brighter(&inner, factor, &result.inner);
cbindgen_private::types::slint_color_brighter(&inner, factor, &result.inner);
return result;
}
inline Color Color::darker(float factor) const
{
Color result;
cbindgen_private::types::sixtyfps_color_darker(&inner, factor, &result.inner);
cbindgen_private::types::slint_color_darker(&inner, factor, &result.inner);
return result;
}
@ -223,8 +223,8 @@ inline void
Property<Color>::set_animated_value(const Color &new_value,
const cbindgen_private::PropertyAnimation &animation_data) const
{
cbindgen_private::sixtyfps_property_set_animated_value_color(&inner, value, new_value,
&animation_data);
cbindgen_private::slint_property_set_animated_value_color(&inner, value, new_value,
&animation_data);
}
} // namespace private_api

View file

@ -33,12 +33,12 @@ public:
*/
/// Returns the size of the Image in pixels.
IntSize size() const { return cbindgen_private::types::sixtyfps_image_size(&data); }
IntSize size() const { return cbindgen_private::types::slint_image_size(&data); }
/// Returns the path of the image on disk, if it was constructed via Image::load_from_path().
std::optional<sixtyfps::SharedString> path() const
{
if (auto *str = cbindgen_private::types::sixtyfps_image_path(&data)) {
if (auto *str = cbindgen_private::types::slint_image_path(&data)) {
return *str;
} else {
return {};

View file

@ -54,26 +54,26 @@ struct Struct
public:
/// Constructs a new empty struct. You can add fields with set_field() and
/// read them with get_field().
Struct() { cbindgen_private::sixtyfps_interpreter_struct_new(&inner); }
Struct() { cbindgen_private::slint_interpreter_struct_new(&inner); }
/// Creates a new Struct as a copy from \a other. All fields are copied as well.
Struct(const Struct &other)
{
cbindgen_private::sixtyfps_interpreter_struct_clone(&other.inner, &inner);
cbindgen_private::slint_interpreter_struct_clone(&other.inner, &inner);
}
/// Creates a new Struct by moving all fields from \a other into this struct.
Struct(Struct &&other)
{
inner = other.inner;
cbindgen_private::sixtyfps_interpreter_struct_new(&other.inner);
cbindgen_private::slint_interpreter_struct_new(&other.inner);
}
/// Assigns all the fields of \a other to this struct.
Struct &operator=(const Struct &other)
{
if (this == &other)
return *this;
cbindgen_private::sixtyfps_interpreter_struct_destructor(&inner);
sixtyfps_interpreter_struct_clone(&other.inner, &inner);
cbindgen_private::slint_interpreter_struct_destructor(&inner);
slint_interpreter_struct_clone(&other.inner, &inner);
return *this;
}
/// Moves all the fields of \a other to this struct.
@ -81,13 +81,13 @@ public:
{
if (this == &other)
return *this;
cbindgen_private::sixtyfps_interpreter_struct_destructor(&inner);
cbindgen_private::slint_interpreter_struct_destructor(&inner);
inner = other.inner;
cbindgen_private::sixtyfps_interpreter_struct_new(&other.inner);
cbindgen_private::slint_interpreter_struct_new(&other.inner);
return *this;
}
/// Destroys this struct.
~Struct() { cbindgen_private::sixtyfps_interpreter_struct_destructor(&inner); }
~Struct() { cbindgen_private::slint_interpreter_struct_destructor(&inner); }
/// Creates a new struct with the fields of the std::initializer_list given by args.
inline Struct(std::initializer_list<std::pair<std::string_view, Value>> args);
@ -159,11 +159,11 @@ public:
iterator() = default;
void next()
{
auto next = cbindgen_private::sixtyfps_interpreter_struct_iterator_next(&inner);
auto next = cbindgen_private::slint_interpreter_struct_iterator_next(&inner);
v = reinterpret_cast<const Value *>(next.v);
k = std::string_view(reinterpret_cast<char *>(next.k.ptr), next.k.len);
if (!v) {
cbindgen_private::sixtyfps_interpreter_struct_iterator_destructor(&inner);
cbindgen_private::slint_interpreter_struct_iterator_destructor(&inner);
}
}
@ -172,7 +172,7 @@ public:
~iterator()
{
if (v) {
cbindgen_private::sixtyfps_interpreter_struct_iterator_destructor(&inner);
cbindgen_private::slint_interpreter_struct_iterator_destructor(&inner);
}
}
// FIXME I believe iterators are supposed to be copy constructible
@ -201,7 +201,7 @@ public:
/// Returns an iterator over the fields of the struct.
iterator begin() const
{
return iterator(cbindgen_private::sixtyfps_interpreter_struct_make_iter(&inner));
return iterator(cbindgen_private::slint_interpreter_struct_make_iter(&inner));
}
/// Returns an iterator that when compared with an iterator returned by begin() can be
/// used to detect when all fields have been visited.
@ -218,7 +218,7 @@ public:
/// \private
Struct(const sixtyfps::cbindgen_private::StructOpaque &other)
{
cbindgen_private::sixtyfps_interpreter_struct_clone(&other, &inner);
cbindgen_private::slint_interpreter_struct_clone(&other, &inner);
}
private:
@ -237,8 +237,8 @@ private:
///
/// Note that models are only represented in one direction: You can create a sixtyfps::Model<Value>
/// in C++, store it in a std::shared_ptr and construct Value from it. Then you can set it on a
/// property in your .slint code that was declared to be either an array (`property <[sometype]> foo;`)
/// or an object literal (`property <{foo: string, bar: int}> my_prop;`). Such properties are
/// property in your .slint code that was declared to be either an array (`property <[sometype]>
/// foo;`) or an object literal (`property <{foo: string, bar: int}> my_prop;`). Such properties are
/// dynamic and accept models implemented in C++.
///
/// ```
@ -253,23 +253,23 @@ class Value
{
public:
/// Constructs a new value of type Value::Type::Void.
Value() { cbindgen_private::sixtyfps_interpreter_value_new(&inner); }
Value() { cbindgen_private::slint_interpreter_value_new(&inner); }
/// Constructs a new value by copying \a other.
Value(const Value &other) { sixtyfps_interpreter_value_clone(&other.inner, &inner); }
Value(const Value &other) { slint_interpreter_value_clone(&other.inner, &inner); }
/// Constructs a new value by moving \a other to this.
Value(Value &&other)
{
inner = other.inner;
cbindgen_private::sixtyfps_interpreter_value_new(&other.inner);
cbindgen_private::slint_interpreter_value_new(&other.inner);
}
/// Assigns the value \a other to this.
Value &operator=(const Value &other)
{
if (this == &other)
return *this;
cbindgen_private::sixtyfps_interpreter_value_destructor(&inner);
sixtyfps_interpreter_value_clone(&other.inner, &inner);
cbindgen_private::slint_interpreter_value_destructor(&inner);
slint_interpreter_value_clone(&other.inner, &inner);
return *this;
}
/// Moves the value \a other to this.
@ -277,13 +277,13 @@ public:
{
if (this == &other)
return *this;
cbindgen_private::sixtyfps_interpreter_value_destructor(&inner);
cbindgen_private::slint_interpreter_value_destructor(&inner);
inner = other.inner;
cbindgen_private::sixtyfps_interpreter_value_new(&other.inner);
cbindgen_private::slint_interpreter_value_new(&other.inner);
return *this;
}
/// Destroys the value.
~Value() { cbindgen_private::sixtyfps_interpreter_value_destructor(&inner); }
~Value() { cbindgen_private::slint_interpreter_value_destructor(&inner); }
/// A convenience alias for the value type enum.
using Type = ValueType;
@ -294,7 +294,7 @@ public:
/// Type::Double, otherwise an empty optional is returned.
std::optional<double> to_number() const
{
if (auto *number = cbindgen_private::sixtyfps_interpreter_value_to_number(&inner)) {
if (auto *number = cbindgen_private::slint_interpreter_value_to_number(&inner)) {
return *number;
} else {
return {};
@ -305,7 +305,7 @@ public:
/// Type::String, otherwise an empty optional is returned.
std::optional<sixtyfps::SharedString> to_string() const
{
if (auto *str = cbindgen_private::sixtyfps_interpreter_value_to_string(&inner)) {
if (auto *str = cbindgen_private::slint_interpreter_value_to_string(&inner)) {
return *str;
} else {
return {};
@ -316,7 +316,7 @@ public:
/// Type::Bool, otherwise an empty optional is returned.
std::optional<bool> to_bool() const
{
if (auto *b = cbindgen_private::sixtyfps_interpreter_value_to_bool(&inner)) {
if (auto *b = cbindgen_private::slint_interpreter_value_to_bool(&inner)) {
return *b;
} else {
return {};
@ -333,7 +333,7 @@ public:
/// Type::Brush, otherwise an empty optional is returned.
std::optional<sixtyfps::Brush> to_brush() const
{
if (auto *brush = cbindgen_private::sixtyfps_interpreter_value_to_brush(&inner)) {
if (auto *brush = cbindgen_private::slint_interpreter_value_to_brush(&inner)) {
return *brush;
} else {
return {};
@ -344,7 +344,7 @@ public:
/// Type::Struct, otherwise an empty optional is returned.
std::optional<Struct> to_struct() const
{
if (auto *opaque_struct = cbindgen_private::sixtyfps_interpreter_value_to_struct(&inner)) {
if (auto *opaque_struct = cbindgen_private::slint_interpreter_value_to_struct(&inner)) {
return Struct(*opaque_struct);
} else {
return {};
@ -355,7 +355,7 @@ public:
/// Type::Image, otherwise an empty optional is returned.
std::optional<Image> to_image() const
{
if (auto *img = cbindgen_private::sixtyfps_interpreter_value_to_image(&inner)) {
if (auto *img = cbindgen_private::slint_interpreter_value_to_image(&inner)) {
return *reinterpret_cast<const Image *>(img);
} else {
return {};
@ -365,14 +365,14 @@ public:
// template<typename T> std::optional<T> get() const;
/// Constructs a new Value that holds the double \a value.
Value(double value) { cbindgen_private::sixtyfps_interpreter_value_new_double(value, &inner); }
Value(double value) { cbindgen_private::slint_interpreter_value_new_double(value, &inner); }
/// Constructs a new Value that holds the string \a str.
Value(const SharedString &str)
{
cbindgen_private::sixtyfps_interpreter_value_new_string(&str, &inner);
cbindgen_private::slint_interpreter_value_new_string(&str, &inner);
}
/// Constructs a new Value that holds the boolean \a b.
Value(bool b) { cbindgen_private::sixtyfps_interpreter_value_new_bool(b, &inner); }
Value(bool b) { cbindgen_private::slint_interpreter_value_new_bool(b, &inner); }
/// Constructs a new Value that holds the value vector \a v as a model.
inline Value(const SharedVector<Value> &v);
/// Constructs a new Value that holds the value model \a m.
@ -380,27 +380,24 @@ public:
/// Constructs a new Value that holds the brush \a b.
Value(const sixtyfps::Brush &brush)
{
cbindgen_private::sixtyfps_interpreter_value_new_brush(&brush, &inner);
cbindgen_private::slint_interpreter_value_new_brush(&brush, &inner);
}
/// Constructs a new Value that holds the Struct \a struc.
Value(const Struct &struc)
{
cbindgen_private::sixtyfps_interpreter_value_new_struct(&struc.inner, &inner);
cbindgen_private::slint_interpreter_value_new_struct(&struc.inner, &inner);
}
/// Constructs a new Value that holds the Image \a img.
Value(const Image &img)
{
cbindgen_private::sixtyfps_interpreter_value_new_image(&img, &inner);
}
Value(const Image &img) { cbindgen_private::slint_interpreter_value_new_image(&img, &inner); }
/// Returns the type the variant holds.
Type type() const { return cbindgen_private::sixtyfps_interpreter_value_type(&inner); }
Type type() const { return cbindgen_private::slint_interpreter_value_type(&inner); }
/// Returns true if \a and \b hold values of the same type and the underlying vales are equal.
friend bool operator==(const Value &a, const Value &b)
{
return cbindgen_private::sixtyfps_interpreter_value_eq(&a.inner, &b.inner);
return cbindgen_private::slint_interpreter_value_eq(&a.inner, &b.inner);
}
private:
@ -415,14 +412,14 @@ private:
inline Value::Value(const sixtyfps::SharedVector<Value> &array)
{
cbindgen_private::sixtyfps_interpreter_value_new_array_model(
cbindgen_private::slint_interpreter_value_new_array_model(
&reinterpret_cast<const sixtyfps::SharedVector<ValueOpaque> &>(array), &inner);
}
inline std::optional<sixtyfps::SharedVector<Value>> Value::to_array() const
{
sixtyfps::SharedVector<Value> array;
if (cbindgen_private::sixtyfps_interpreter_value_to_array(
if (cbindgen_private::slint_interpreter_value_to_array(
&inner, &reinterpret_cast<sixtyfps::SharedVector<ValueOpaque> &>(array))) {
return array;
} else {
@ -440,26 +437,26 @@ inline Value::Value(const std::shared_ptr<sixtyfps::Model<Value>> &model)
// This kind of mean that the rust code has ownership of "this" until the drop function is
// called
std::shared_ptr<AbstractRepeaterView> self;
~ModelWrapper() { cbindgen_private::sixtyfps_interpreter_model_notify_destructor(&notify); }
~ModelWrapper() { cbindgen_private::slint_interpreter_model_notify_destructor(&notify); }
void row_added(int index, int count) override
{
cbindgen_private::sixtyfps_interpreter_model_notify_row_added(&notify, index, count);
cbindgen_private::slint_interpreter_model_notify_row_added(&notify, index, count);
}
void row_changed(int index) override
{
cbindgen_private::sixtyfps_interpreter_model_notify_row_changed(&notify, index);
cbindgen_private::slint_interpreter_model_notify_row_changed(&notify, index);
}
void row_removed(int index, int count) override
{
cbindgen_private::sixtyfps_interpreter_model_notify_row_removed(&notify, index, count);
cbindgen_private::slint_interpreter_model_notify_row_removed(&notify, index, count);
}
};
auto wrapper = std::make_shared<ModelWrapper>();
wrapper->model = model;
wrapper->self = wrapper;
cbindgen_private::sixtyfps_interpreter_model_notify_new(&wrapper->notify);
cbindgen_private::slint_interpreter_model_notify_new(&wrapper->notify);
model->attach_peer(wrapper);
auto row_count = [](VRef<ModelAdaptorVTable> self) -> uintptr_t {
@ -470,7 +467,7 @@ inline Value::Value(const std::shared_ptr<sixtyfps::Model<Value>> &model)
reinterpret_cast<ModelWrapper *>(self.instance)->model->row_data(int(row));
if (v.has_value()) {
*out = v->inner;
cbindgen_private::sixtyfps_interpreter_value_new(&v->inner);
cbindgen_private::slint_interpreter_value_new(&v->inner);
return true;
}
return false;
@ -489,7 +486,7 @@ inline Value::Value(const std::shared_ptr<sixtyfps::Model<Value>> &model)
static const ModelAdaptorVTable vt { row_count, row_data, set_row_data, get_notify, drop };
vtable::VBox<ModelAdaptorVTable> wrap { &vt, wrapper.get() };
cbindgen_private::sixtyfps_interpreter_value_new_model(wrap, &inner);
cbindgen_private::slint_interpreter_value_new_model(wrap, &inner);
}
inline Struct::Struct(std::initializer_list<std::pair<std::string_view, Value>> args)
@ -503,7 +500,7 @@ inline std::optional<Value> Struct::get_field(std::string_view name) const
const_cast<unsigned char *>(reinterpret_cast<const unsigned char *>(name.data())),
name.size()
};
if (auto *value = cbindgen_private::sixtyfps_interpreter_struct_get_field(&inner, name_view)) {
if (auto *value = cbindgen_private::slint_interpreter_struct_get_field(&inner, name_view)) {
return *reinterpret_cast<const Value *>(value);
} else {
return {};
@ -515,7 +512,7 @@ inline void Struct::set_field(std::string_view name, const Value &value)
const_cast<unsigned char *>(reinterpret_cast<const unsigned char *>(name.data())),
name.size()
};
cbindgen_private::sixtyfps_interpreter_struct_set_field(&inner, name_view, &value.inner);
cbindgen_private::slint_interpreter_struct_set_field(&inner, name_view, &value.inner);
}
/// The ComponentInstance represents a running instance of a component.
@ -547,13 +544,13 @@ public:
/// using sixtyfps::run_event_loop().
void show() const
{
cbindgen_private::sixtyfps_interpreter_component_instance_show(inner(), true);
cbindgen_private::slint_interpreter_component_instance_show(inner(), true);
}
/// Marks the window of this component to be hidden on the screen. This de-registers
/// the window from the windowing system and it will not receive any further events.
void hide() const
{
cbindgen_private::sixtyfps_interpreter_component_instance_show(inner(), false);
cbindgen_private::slint_interpreter_component_instance_show(inner(), false);
}
/// Returns the Window associated with this component. The window API can be used
/// to control different aspects of the integration into the windowing system,
@ -561,7 +558,7 @@ public:
const sixtyfps::Window &window()
{
const cbindgen_private::WindowRcOpaque *win_ptr = nullptr;
cbindgen_private::sixtyfps_interpreter_component_instance_window(inner(), &win_ptr);
cbindgen_private::slint_interpreter_component_instance_window(inner(), &win_ptr);
return *reinterpret_cast<const sixtyfps::Window *>(win_ptr);
}
/// This is a convenience function that first calls show(), followed by
@ -569,7 +566,7 @@ public:
void run() const
{
show();
cbindgen_private::sixtyfps_run_event_loop();
cbindgen_private::slint_run_event_loop();
hide();
}
#if defined(SIXTYFPS_QT_INTEGRATION) || defined(DOXYGEN)
@ -579,8 +576,8 @@ public:
QWidget *qwidget() const
{
const cbindgen_private::WindowRcOpaque *win_ptr = nullptr;
cbindgen_private::sixtyfps_interpreter_component_instance_window(inner(), &win_ptr);
auto wid = reinterpret_cast<QWidget *>(cbindgen_private::sixtyfps_qt_get_widget(
cbindgen_private::slint_interpreter_component_instance_window(inner(), &win_ptr);
auto wid = reinterpret_cast<QWidget *>(cbindgen_private::slint_qt_get_widget(
reinterpret_cast<const cbindgen_private::WindowRc *>(win_ptr)));
return wid;
}
@ -600,7 +597,7 @@ public:
bool set_property(std::string_view name, const Value &value) const
{
using namespace cbindgen_private;
return sixtyfps_interpreter_component_instance_set_property(
return slint_interpreter_component_instance_set_property(
inner(), sixtyfps::private_api::string_to_slice(name), &value.inner);
}
/// Returns the value behind a property declared in .slint.
@ -608,7 +605,7 @@ public:
{
using namespace cbindgen_private;
ValueOpaque out;
if (sixtyfps_interpreter_component_instance_get_property(
if (slint_interpreter_component_instance_get_property(
inner(), sixtyfps::private_api::string_to_slice(name), &out)) {
return Value(out);
} else {
@ -637,7 +634,7 @@ public:
reinterpret_cast<const ValueOpaque *>(args.data())),
args.size() };
ValueOpaque out;
if (sixtyfps_interpreter_component_instance_invoke_callback(
if (slint_interpreter_component_instance_invoke_callback(
inner(), sixtyfps::private_api::string_to_slice(name), args_view, &out)) {
return Value(out);
} else {
@ -676,7 +673,7 @@ public:
Value r = (*reinterpret_cast<F *>(data))(args_view);
new (ret) Value(std::move(r));
};
return cbindgen_private::sixtyfps_interpreter_component_instance_set_callback(
return cbindgen_private::slint_interpreter_component_instance_set_callback(
inner(), sixtyfps::private_api::string_to_slice(name), actual_cb,
new F(std::move(callback)), [](void *data) { delete reinterpret_cast<F *>(data); });
}
@ -696,7 +693,7 @@ public:
const Value &value) const
{
using namespace cbindgen_private;
return sixtyfps_interpreter_component_instance_set_global_property(
return slint_interpreter_component_instance_set_global_property(
inner(), sixtyfps::private_api::string_to_slice(global),
sixtyfps::private_api::string_to_slice(prop_name), &value.inner);
}
@ -706,7 +703,7 @@ public:
{
using namespace cbindgen_private;
ValueOpaque out;
if (sixtyfps_interpreter_component_instance_get_global_property(
if (slint_interpreter_component_instance_get_global_property(
inner(), sixtyfps::private_api::string_to_slice(global),
sixtyfps::private_api::string_to_slice(prop_name), &out)) {
return Value(out);
@ -741,7 +738,7 @@ public:
Value r = (*reinterpret_cast<F *>(data))(args_view);
new (ret) Value(std::move(r));
};
return cbindgen_private::sixtyfps_interpreter_component_instance_set_global_callback(
return cbindgen_private::slint_interpreter_component_instance_set_global_callback(
inner(), sixtyfps::private_api::string_to_slice(global),
sixtyfps::private_api::string_to_slice(name), actual_cb, new F(std::move(callback)),
[](void *data) { delete reinterpret_cast<F *>(data); });
@ -757,7 +754,7 @@ public:
reinterpret_cast<const ValueOpaque *>(args.data())),
args.size() };
ValueOpaque out;
if (sixtyfps_interpreter_component_instance_invoke_global_callback(
if (slint_interpreter_component_instance_invoke_global_callback(
inner(), sixtyfps::private_api::string_to_slice(global),
sixtyfps::private_api::string_to_slice(callback_name), args_view, &out)) {
return Value(out);
@ -790,7 +787,7 @@ public:
/// Constructs a new ComponentDefinition as a copy of \a other.
ComponentDefinition(const ComponentDefinition &other)
{
sixtyfps_interpreter_component_definition_clone(&other.inner, &inner);
slint_interpreter_component_definition_clone(&other.inner, &inner);
}
/// Assigns \a other to this ComponentDefinition.
ComponentDefinition &operator=(const ComponentDefinition &other)
@ -800,13 +797,13 @@ public:
if (this == &other)
return *this;
sixtyfps_interpreter_component_definition_destructor(&inner);
sixtyfps_interpreter_component_definition_clone(&other.inner, &inner);
slint_interpreter_component_definition_destructor(&inner);
slint_interpreter_component_definition_clone(&other.inner, &inner);
return *this;
}
/// Destroys this ComponentDefinition.
~ComponentDefinition() { sixtyfps_interpreter_component_definition_destructor(&inner); }
~ComponentDefinition() { slint_interpreter_component_definition_destructor(&inner); }
/// Creates a new instance of the component and returns a shared handle to it.
ComponentHandle<ComponentInstance> create() const
{
@ -816,7 +813,7 @@ public:
~CI() { result.~ComponentHandle(); }
CI() { }
} u;
cbindgen_private::sixtyfps_interpreter_component_instance_create(&inner, &u.i);
cbindgen_private::slint_interpreter_component_instance_create(&inner, &u.i);
return u.result;
}
@ -826,7 +823,7 @@ public:
sixtyfps::SharedVector<PropertyDescriptor> properties() const
{
sixtyfps::SharedVector<PropertyDescriptor> props;
cbindgen_private::sixtyfps_interpreter_component_definition_properties(&inner, &props);
cbindgen_private::slint_interpreter_component_definition_properties(&inner, &props);
return props;
}
@ -835,7 +832,7 @@ public:
sixtyfps::SharedVector<sixtyfps::SharedString> callbacks() const
{
sixtyfps::SharedVector<sixtyfps::SharedString> callbacks;
cbindgen_private::sixtyfps_interpreter_component_definition_callbacks(&inner, &callbacks);
cbindgen_private::slint_interpreter_component_definition_callbacks(&inner, &callbacks);
return callbacks;
}
@ -843,7 +840,7 @@ public:
sixtyfps::SharedString name() const
{
sixtyfps::SharedString name;
cbindgen_private::sixtyfps_interpreter_component_definition_name(&inner, &name);
cbindgen_private::slint_interpreter_component_definition_name(&inner, &name);
return name;
}
@ -851,7 +848,7 @@ public:
sixtyfps::SharedVector<sixtyfps::SharedString> globals() const
{
sixtyfps::SharedVector<sixtyfps::SharedString> names;
cbindgen_private::sixtyfps_interpreter_component_definition_globals(&inner, &names);
cbindgen_private::slint_interpreter_component_definition_globals(&inner, &names);
return names;
}
@ -862,7 +859,7 @@ public:
global_properties(std::string_view global_name) const
{
sixtyfps::SharedVector<PropertyDescriptor> properties;
if (cbindgen_private::sixtyfps_interpreter_component_definition_global_properties(
if (cbindgen_private::slint_interpreter_component_definition_global_properties(
&inner, sixtyfps::private_api::string_to_slice(global_name), &properties)) {
return properties;
}
@ -876,7 +873,7 @@ public:
global_callbacks(std::string_view global_name) const
{
sixtyfps::SharedVector<sixtyfps::SharedString> names;
if (cbindgen_private::sixtyfps_interpreter_component_definition_global_callbacks(
if (cbindgen_private::slint_interpreter_component_definition_global_callbacks(
&inner, sixtyfps::private_api::string_to_slice(global_name), &names)) {
return names;
}
@ -896,24 +893,25 @@ class ComponentCompiler
public:
/// Constructs a new ComponentCompiler instance.
ComponentCompiler() { cbindgen_private::sixtyfps_interpreter_component_compiler_new(&inner); }
ComponentCompiler() { cbindgen_private::slint_interpreter_component_compiler_new(&inner); }
/// Destroys this ComponentCompiler.
~ComponentCompiler()
{
cbindgen_private::sixtyfps_interpreter_component_compiler_destructor(&inner);
cbindgen_private::slint_interpreter_component_compiler_destructor(&inner);
}
/// Sets the include paths used for looking up `.slint` imports to the specified vector of paths.
/// Sets the include paths used for looking up `.slint` imports to the specified vector of
/// paths.
void set_include_paths(const sixtyfps::SharedVector<sixtyfps::SharedString> &paths)
{
cbindgen_private::sixtyfps_interpreter_component_compiler_set_include_paths(&inner, &paths);
cbindgen_private::slint_interpreter_component_compiler_set_include_paths(&inner, &paths);
}
/// Sets the style to be used for widgets.
void set_style(std::string_view style)
{
cbindgen_private::sixtyfps_interpreter_component_compiler_set_style(
cbindgen_private::slint_interpreter_component_compiler_set_style(
&inner, sixtyfps::private_api::string_to_slice(style));
}
@ -921,7 +919,7 @@ public:
sixtyfps::SharedString style() const
{
sixtyfps::SharedString s;
cbindgen_private::sixtyfps_interpreter_component_compiler_get_style(&inner, &s);
cbindgen_private::slint_interpreter_component_compiler_get_style(&inner, &s);
return s;
}
@ -929,7 +927,7 @@ public:
sixtyfps::SharedVector<sixtyfps::SharedString> include_paths() const
{
sixtyfps::SharedVector<sixtyfps::SharedString> paths;
cbindgen_private::sixtyfps_interpreter_component_compiler_get_include_paths(&inner, &paths);
cbindgen_private::slint_interpreter_component_compiler_get_include_paths(&inner, &paths);
return paths;
}
@ -938,7 +936,7 @@ public:
sixtyfps::SharedVector<Diagnostic> diagnostics() const
{
sixtyfps::SharedVector<Diagnostic> result;
cbindgen_private::sixtyfps_interpreter_component_compiler_get_diagnostics(&inner, &result);
cbindgen_private::slint_interpreter_component_compiler_get_diagnostics(&inner, &result);
return result;
}
@ -955,7 +953,7 @@ public:
std::string_view path)
{
cbindgen_private::ComponentDefinitionOpaque result;
if (cbindgen_private::sixtyfps_interpreter_component_compiler_build_from_source(
if (cbindgen_private::slint_interpreter_component_compiler_build_from_source(
&inner, sixtyfps::private_api::string_to_slice(source_code),
sixtyfps::private_api::string_to_slice(path), &result)) {
@ -978,7 +976,7 @@ public:
std::optional<ComponentDefinition> build_from_path(std::string_view path)
{
cbindgen_private::ComponentDefinitionOpaque result;
if (cbindgen_private::sixtyfps_interpreter_component_compiler_build_from_path(
if (cbindgen_private::slint_interpreter_component_compiler_build_from_path(
&inner, sixtyfps::private_api::string_to_slice(path), &result)) {
return ComponentDefinition(result);
@ -1000,7 +998,7 @@ inline void send_keyboard_string_sequence(const sixtyfps::interpreter::Component
KeyboardModifiers modifiers = {})
{
const cbindgen_private::WindowRcOpaque *win_ptr = nullptr;
cbindgen_private::sixtyfps_interpreter_component_instance_window(
cbindgen_private::slint_interpreter_component_instance_window(
reinterpret_cast<const cbindgen_private::ErasedComponentBox *>(component), &win_ptr);
cbindgen_private::send_keyboard_string_sequence(
&str, modifiers, reinterpret_cast<const cbindgen_private::WindowRc *>(win_ptr));

View file

@ -49,7 +49,7 @@ private:
size_t count)
{
SharedVector<PathElement> tmp;
sixtyfps_new_path_elements(&tmp, firstElement, count);
slint_new_path_elements(&tmp, firstElement, count);
return tmp;
}
@ -60,8 +60,8 @@ private:
{
SharedVector<PathEvent> events;
SharedVector<Point> coordinates;
sixtyfps_new_path_events(&events, &coordinates, firstEvent, event_count, firstCoordinate,
coordinate_count);
slint_new_path_events(&events, &coordinates, firstEvent, event_count, firstCoordinate,
coordinate_count);
return Data::Events(events, coordinates);
}

View file

@ -21,7 +21,7 @@ inline void sixtyfps_property_set_animated_binding_helper(
const cbindgen_private::PropertyAnimation *animation_data,
cbindgen_private::PropertyAnimation (*transition_data)(void *, uint64_t *))
{
cbindgen_private::sixtyfps_property_set_animated_binding_int(
cbindgen_private::slint_property_set_animated_binding_int(
handle, binding, user_data, drop_user_data, animation_data, transition_data);
}
@ -31,7 +31,7 @@ inline void sixtyfps_property_set_animated_binding_helper(
const cbindgen_private::PropertyAnimation *animation_data,
cbindgen_private::PropertyAnimation (*transition_data)(void *, uint64_t *))
{
cbindgen_private::sixtyfps_property_set_animated_binding_float(
cbindgen_private::slint_property_set_animated_binding_float(
handle, binding, user_data, drop_user_data, animation_data, transition_data);
}
@ -41,7 +41,7 @@ inline void sixtyfps_property_set_animated_binding_helper(
const cbindgen_private::PropertyAnimation *animation_data,
cbindgen_private::PropertyAnimation (*transition_data)(void *, uint64_t *))
{
cbindgen_private::sixtyfps_property_set_animated_binding_color(
cbindgen_private::slint_property_set_animated_binding_color(
handle, binding, user_data, drop_user_data, animation_data, transition_data);
}
@ -51,21 +51,21 @@ inline void sixtyfps_property_set_animated_binding_helper(
const cbindgen_private::PropertyAnimation *animation_data,
cbindgen_private::PropertyAnimation (*transition_data)(void *, uint64_t *))
{
cbindgen_private::sixtyfps_property_set_animated_binding_brush(
cbindgen_private::slint_property_set_animated_binding_brush(
handle, binding, user_data, drop_user_data, animation_data, transition_data);
}
template<typename T>
struct Property
{
Property() { cbindgen_private::sixtyfps_property_init(&inner); }
~Property() { cbindgen_private::sixtyfps_property_drop(&inner); }
Property() { cbindgen_private::slint_property_init(&inner); }
~Property() { cbindgen_private::slint_property_drop(&inner); }
Property(const Property &) = delete;
Property(Property &&) = delete;
Property &operator=(const Property &) = delete;
explicit Property(const T &value) : value(value)
{
cbindgen_private::sixtyfps_property_init(&inner);
cbindgen_private::slint_property_init(&inner);
}
/* Should it be implicit?
@ -77,20 +77,20 @@ struct Property
{
if (this->value != value) {
this->value = value;
cbindgen_private::sixtyfps_property_set_changed(&inner, &this->value);
cbindgen_private::slint_property_set_changed(&inner, &this->value);
}
}
const T &get() const
{
cbindgen_private::sixtyfps_property_update(&inner, &value);
cbindgen_private::slint_property_update(&inner, &value);
return value;
}
template<typename F>
void set_binding(F binding) const
{
cbindgen_private::sixtyfps_property_set_binding(
cbindgen_private::slint_property_set_binding(
&inner,
[](void *user_data, void *value) {
*reinterpret_cast<T *>(value) = (*reinterpret_cast<F *>(user_data))();
@ -135,8 +135,8 @@ struct Property
});
}
bool is_dirty() const { return cbindgen_private::sixtyfps_property_is_dirty(&inner); }
void mark_dirty() const { cbindgen_private::sixtyfps_property_mark_dirty(&inner); }
bool is_dirty() const { return cbindgen_private::slint_property_is_dirty(&inner); }
void mark_dirty() const { cbindgen_private::slint_property_mark_dirty(&inner); }
static void link_two_way(const Property<T> *p1, const Property<T> *p2)
{
@ -161,14 +161,14 @@ struct Property
return true;
};
auto intercept_binding_fn = [](void *user_data, void *value) {
cbindgen_private::sixtyfps_property_set_binding_internal(
cbindgen_private::slint_property_set_binding_internal(
&reinterpret_cast<TwoWayBinding *>(user_data)->common_property->inner, value);
return true;
};
cbindgen_private::sixtyfps_property_set_binding(&p1->inner, call_fn,
cbindgen_private::slint_property_set_binding(&p1->inner, call_fn,
new TwoWayBinding { common_property },
del_fn, intercept_fn, intercept_binding_fn);
cbindgen_private::sixtyfps_property_set_binding(&p2->inner, call_fn,
cbindgen_private::slint_property_set_binding(&p2->inner, call_fn,
new TwoWayBinding { common_property },
del_fn, intercept_fn, intercept_binding_fn);
}
@ -190,7 +190,7 @@ template<>
inline void Property<int32_t>::set_animated_value(
const int32_t &new_value, const cbindgen_private::PropertyAnimation &animation_data) const
{
cbindgen_private::sixtyfps_property_set_animated_value_int(&inner, value, new_value,
cbindgen_private::slint_property_set_animated_value_int(&inner, value, new_value,
&animation_data);
}
@ -199,14 +199,14 @@ inline void
Property<float>::set_animated_value(const float &new_value,
const cbindgen_private::PropertyAnimation &animation_data) const
{
cbindgen_private::sixtyfps_property_set_animated_value_float(&inner, value, new_value,
cbindgen_private::slint_property_set_animated_value_float(&inner, value, new_value,
&animation_data);
}
template<typename F>
void set_state_binding(const Property<StateInfo> &property, F binding)
{
cbindgen_private::sixtyfps_property_set_state_binding(
cbindgen_private::slint_property_set_state_binding(
&property.inner,
[](void *user_data) -> int32_t { return (*reinterpret_cast<F *>(user_data))(); },
new F(binding), [](void *user_data) { delete reinterpret_cast<F *>(user_data); });
@ -227,9 +227,9 @@ void set_state_binding(const Property<StateInfo> &property, F binding)
struct PropertyTracker
{
/// Constructs a new property tracker instance.
PropertyTracker() { cbindgen_private::sixtyfps_property_tracker_init(&inner); }
PropertyTracker() { cbindgen_private::slint_property_tracker_init(&inner); }
/// Destroys the property tracker.
~PropertyTracker() { cbindgen_private::sixtyfps_property_tracker_drop(&inner); }
~PropertyTracker() { cbindgen_private::slint_property_tracker_drop(&inner); }
/// The copy constructor is intentionally deleted, property trackers cannot be copied.
PropertyTracker(const PropertyTracker &) = delete;
/// The assignment operator is intentionally deleted, property trackers cannot be copied.
@ -237,14 +237,14 @@ struct PropertyTracker
/// Returns true if any properties accessed during the last evaluate() call have changed their
/// value since then.
bool is_dirty() const { return cbindgen_private::sixtyfps_property_tracker_is_dirty(&inner); }
bool is_dirty() const { return cbindgen_private::slint_property_tracker_is_dirty(&inner); }
/// Invokes the provided functor \a f and tracks accessed to any properties during that
/// invocation.
template<typename F>
auto evaluate(const F &f) const -> std::enable_if_t<std::is_same_v<decltype(f()), void>>
{
cbindgen_private::sixtyfps_property_tracker_evaluate(
cbindgen_private::slint_property_tracker_evaluate(
&inner, [](void *f) { (*reinterpret_cast<const F *>(f))(); }, const_cast<F *>(&f));
}
@ -269,7 +269,7 @@ struct PropertyTracker
auto evaluate_as_dependency_root(const F &f) const
-> std::enable_if_t<std::is_same_v<decltype(f()), void>>
{
cbindgen_private::sixtyfps_property_tracker_evaluate_as_dependency_root(
cbindgen_private::slint_property_tracker_evaluate_as_dependency_root(
&inner, [](void *f) { (*reinterpret_cast<const F *>(f))(); }, const_cast<F *>(&f));
}

View file

@ -18,7 +18,7 @@ struct SharedVector
/// Creates a new, empty vector.
SharedVector()
: inner(const_cast<SharedVectorHeader *>(reinterpret_cast<const SharedVectorHeader *>(
cbindgen_private::sixtyfps_shared_vector_empty())))
cbindgen_private::slint_shared_vector_empty())))
{
}
/// Creates a new vector that holds all the elements of the given std::initializer_list \a args.
@ -173,7 +173,7 @@ private:
for (auto it = b; it < e; ++it) {
it->~T();
}
cbindgen_private::sixtyfps_shared_vector_free(reinterpret_cast<uint8_t *>(inner),
cbindgen_private::slint_shared_vector_free(reinterpret_cast<uint8_t *>(inner),
sizeof(SharedVectorHeader)
+ inner->capacity * sizeof(T),
alignof(SharedVectorHeader));
@ -182,7 +182,7 @@ private:
static SharedVector with_capacity(std::size_t capacity)
{
auto mem = cbindgen_private::sixtyfps_shared_vector_allocate(
auto mem = cbindgen_private::slint_shared_vector_allocate(
sizeof(SharedVectorHeader) + capacity * sizeof(T), alignof(SharedVectorHeader));
return SharedVector(new (mem) SharedVectorHeader { { 1 }, 0, capacity });
}

View file

@ -23,12 +23,12 @@ namespace sixtyfps {
struct SharedString
{
/// Creates an empty default constructed string.
SharedString() { cbindgen_private::sixtyfps_shared_string_from_bytes(this, "", 0); }
SharedString() { cbindgen_private::slint_shared_string_from_bytes(this, "", 0); }
/// Creates a new SharedString from the string view \a s. The underlying string data
/// is copied.
SharedString(std::string_view s)
{
cbindgen_private::sixtyfps_shared_string_from_bytes(this, s.data(), s.size());
cbindgen_private::slint_shared_string_from_bytes(this, s.data(), s.size());
}
/// Creates a new SharedString from the null-terminated string pointer \a s. The underlying
/// string data is copied. It is assumed that the string is UTF-8 encoded.
@ -42,31 +42,31 @@ struct SharedString
/// Creates a new SharedString from the string view \a s. The underlying string data is copied.
SharedString(std::u8string_view s)
{
cbindgen_private::sixtyfps_shared_string_from_bytes(
cbindgen_private::slint_shared_string_from_bytes(
this, reinterpret_cast<const char*>(s.data()), s.size());
}
#endif
/// Creates a new SharedString from \a other.
SharedString(const SharedString &other)
{
cbindgen_private::sixtyfps_shared_string_clone(this, &other);
cbindgen_private::slint_shared_string_clone(this, &other);
}
/// Destroys this SharedString and frees the memory if this is the last instance
/// referencing it.
~SharedString() { cbindgen_private::sixtyfps_shared_string_drop(this); }
~SharedString() { cbindgen_private::slint_shared_string_drop(this); }
/// Assigns \a other to this string and returns a reference to this string.
SharedString &operator=(const SharedString &other)
{
cbindgen_private::sixtyfps_shared_string_drop(this);
cbindgen_private::sixtyfps_shared_string_clone(this, &other);
cbindgen_private::slint_shared_string_drop(this);
cbindgen_private::slint_shared_string_clone(this, &other);
return *this;
}
/// Assigns the string view \a s to this string and returns a reference to this string.
/// The underlying string data is copied. It is assumed that the string is UTF-8 encoded.
SharedString &operator=(std::string_view s)
{
cbindgen_private::sixtyfps_shared_string_drop(this);
cbindgen_private::sixtyfps_shared_string_from_bytes(this, s.data(), s.size());
cbindgen_private::slint_shared_string_drop(this);
cbindgen_private::slint_shared_string_from_bytes(this, s.data(), s.size());
return *this;
}
/// Assigns null-terminated string pointer \a s to this string and returns a reference
@ -85,13 +85,13 @@ struct SharedString
/// least this SharedString exists.
operator std::string_view() const
{
return cbindgen_private::sixtyfps_shared_string_bytes(this);
return cbindgen_private::slint_shared_string_bytes(this);
}
/// Provides a raw pointer to the string data. The returned pointer is only valid as long as at
/// least this SharedString exists.
auto data() const -> const char *
{
return cbindgen_private::sixtyfps_shared_string_bytes(this);
return cbindgen_private::slint_shared_string_bytes(this);
}
/// Returns a pointer to the first character. It is only safe to dereference the pointer if the
@ -185,7 +185,7 @@ struct SharedString
/// Appends \a other to this string and returns a reference to this.
SharedString &operator+=(std::string_view other)
{
cbindgen_private::sixtyfps_shared_string_append(this, other.data(), other.size());
cbindgen_private::slint_shared_string_append(this, other.data(), other.size());
return *this;
}
@ -193,7 +193,7 @@ private:
/// Use SharedString::from_number
explicit SharedString(double n)
{
cbindgen_private::sixtyfps_shared_string_from_number(this, n);
cbindgen_private::slint_shared_string_from_number(this, n);
}
void *inner; // opaque
};

View file

@ -9,18 +9,18 @@ namespace sixtyfps::testing {
inline void init()
{
cbindgen_private::sixtyfps_testing_init_backend();
cbindgen_private::slint_testing_init_backend();
}
inline void mock_elapsed_time(int64_t time_in_ms)
{
cbindgen_private::sixtyfps_mock_elapsed_time(time_in_ms);
cbindgen_private::slint_mock_elapsed_time(time_in_ms);
}
template<typename Component>
inline void send_mouse_click(const Component *component, float x, float y)
{
auto crc = *component->self_weak.into_dyn().lock();
cbindgen_private::sixtyfps_send_mouse_click(&crc, x, y, &component->m_window.window_handle());
cbindgen_private::slint_send_mouse_click(&crc, x, y, &component->m_window.window_handle());
}
template<typename Component>

View file

@ -18,13 +18,13 @@ pub fn use_modules() -> usize {
}
#[no_mangle]
pub unsafe extern "C" fn sixtyfps_windowrc_init(out: *mut WindowRcOpaque) {
pub unsafe extern "C" fn slint_windowrc_init(out: *mut WindowRcOpaque) {
assert_eq!(core::mem::size_of::<WindowRc>(), core::mem::size_of::<WindowRcOpaque>());
core::ptr::write(out as *mut WindowRc, crate::backend().create_window());
}
#[no_mangle]
pub unsafe extern "C" fn sixtyfps_run_event_loop() {
pub unsafe extern "C" fn slint_run_event_loop() {
crate::backend().run_event_loop(
slint_core_internal::backend::EventLoopQuitBehavior::QuitOnLastWindowClosed,
);
@ -32,7 +32,7 @@ pub unsafe extern "C" fn sixtyfps_run_event_loop() {
/// Will execute the given functor in the main thread
#[no_mangle]
pub unsafe extern "C" fn sixtyfps_post_event(
pub unsafe extern "C" fn slint_post_event(
event: extern "C" fn(user_data: *mut c_void),
user_data: *mut c_void,
drop_user_data: Option<extern "C" fn(*mut c_void)>,
@ -58,12 +58,12 @@ pub unsafe extern "C" fn sixtyfps_post_event(
}
#[no_mangle]
pub unsafe extern "C" fn sixtyfps_quit_event_loop() {
pub unsafe extern "C" fn slint_quit_event_loop() {
crate::backend().quit_event_loop();
}
#[no_mangle]
pub unsafe extern "C" fn sixtyfps_register_font_from_path(
pub unsafe extern "C" fn slint_register_font_from_path(
path: &slint_core_internal::SharedString,
error_str: *mut slint_core_internal::SharedString,
) {
@ -77,7 +77,7 @@ pub unsafe extern "C" fn sixtyfps_register_font_from_path(
}
#[no_mangle]
pub unsafe extern "C" fn sixtyfps_register_font_from_data(
pub unsafe extern "C" fn slint_register_font_from_data(
data: slint_core_internal::slice::Slice<'static, u8>,
error_str: *mut slint_core_internal::SharedString,
) {
@ -92,6 +92,6 @@ pub unsafe extern "C" fn sixtyfps_register_font_from_data(
#[cfg(feature = "testing")]
#[no_mangle]
pub unsafe extern "C" fn sixtyfps_testing_init_backend() {
pub unsafe extern "C" fn slint_testing_init_backend() {
slint_backend_testing_internal::init();
}