Re-run clang-format with version 18

This commit is contained in:
Simon Hausmann 2024-06-10 11:17:08 +02:00 committed by Simon Hausmann
parent 355a8ab62b
commit 650f19a33c
10 changed files with 70 additions and 135 deletions

View file

@ -192,10 +192,7 @@ public:
} }
/// Returns an iterator that when compared with an iterator returned by begin() can be /// Returns an iterator that when compared with an iterator returned by begin() can be
/// used to detect when all fields have been visited. /// used to detect when all fields have been visited.
iterator end() const iterator end() const { return iterator(); }
{
return iterator();
}
/// Returns the value of the field with the given \a name; Returns an std::optional without /// Returns the value of the field with the given \a name; Returns an std::optional without
/// value if the field does not exist. /// value if the field does not exist.
@ -699,10 +696,11 @@ public:
// clang-format on // clang-format on
{ {
using namespace cbindgen_private; using namespace cbindgen_private;
auto actual_cb = [](void *data, auto actual_cb =
cbindgen_private::Slice<cbindgen_private::Box<cbindgen_private::Value>> [](void *data,
arg) { cbindgen_private::Slice<cbindgen_private::Box<cbindgen_private::Value>> arg) {
std::span<const Value> args_view { reinterpret_cast<const Value *>(arg.ptr), arg.len }; std::span<const Value> args_view { reinterpret_cast<const Value *>(arg.ptr),
arg.len };
Value r = (*reinterpret_cast<F *>(data))(args_view); Value r = (*reinterpret_cast<F *>(data))(args_view);
auto inner = r.inner; auto inner = r.inner;
r.inner = cbindgen_private::slint_interpreter_value_new(); r.inner = cbindgen_private::slint_interpreter_value_new();
@ -773,10 +771,11 @@ public:
bool set_global_callback(std::string_view global, std::string_view name, F callback) const bool set_global_callback(std::string_view global, std::string_view name, F callback) const
{ {
using namespace cbindgen_private; using namespace cbindgen_private;
auto actual_cb = [](void *data, auto actual_cb =
cbindgen_private::Slice<cbindgen_private::Box<cbindgen_private::Value>> [](void *data,
arg) { cbindgen_private::Slice<cbindgen_private::Box<cbindgen_private::Value>> arg) {
std::span<const Value> args_view { reinterpret_cast<const Value *>(arg.ptr), arg.len }; std::span<const Value> args_view { reinterpret_cast<const Value *>(arg.ptr),
arg.len };
Value r = (*reinterpret_cast<F *>(data))(args_view); Value r = (*reinterpret_cast<F *>(data))(args_view);
auto inner = r.inner; auto inner = r.inner;
r.inner = cbindgen_private::slint_interpreter_value_new(); r.inner = cbindgen_private::slint_interpreter_value_new();

View file

@ -392,10 +392,7 @@ public:
/// Returns a copy of text stored in the system clipboard, if any. /// Returns a copy of text stored in the system clipboard, if any.
/// ///
/// If the platform doesn't support the specified clipboard, the function should return nullopt /// If the platform doesn't support the specified clipboard, the function should return nullopt
virtual std::optional<SharedString> clipboard_text(Clipboard) virtual std::optional<SharedString> clipboard_text(Clipboard) { return {}; }
{
return {};
}
/// Spins an event loop and renders the visible windows. /// Spins an event loop and renders the visible windows.
virtual void run_event_loop() { } virtual void run_event_loop() { }
@ -698,8 +695,7 @@ public:
/// to fill it with pixels. After the line buffer is filled with pixels, your implementation is /// to fill it with pixels. After the line buffer is filled with pixels, your implementation is
/// free to flush that line to the screen for display. /// free to flush that line to the screen for display.
template<typename Callback> template<typename Callback>
requires requires(Callback callback) requires requires(Callback callback) {
{
callback(size_t(0), size_t(0), size_t(0), [&callback](std::span<Rgb565Pixel>) {}); callback(size_t(0), size_t(0), size_t(0), [&callback](std::span<Rgb565Pixel>) {});
} }
PhysicalRegion render_by_line(Callback process_line_callback) const PhysicalRegion render_by_line(Callback process_line_callback) const

View file

@ -345,18 +345,12 @@ public:
/// \private /// \private
/// Internal function called by the view to register itself /// Internal function called by the view to register itself
void attach_peer(private_api::ModelPeer p) void attach_peer(private_api::ModelPeer p) { peers.push_back(std::move(p)); }
{
peers.push_back(std::move(p));
}
/// \private /// \private
/// Internal function called from within bindings to register with the currently /// Internal function called from within bindings to register with the currently
/// evaluating dependency and get notified when this model's row count changes. /// evaluating dependency and get notified when this model's row count changes.
void track_row_count_changes() const void track_row_count_changes() const { model_row_count_dirty_property.get(); }
{
model_row_count_dirty_property.get();
}
/// \private /// \private
/// Internal function called from within bindings to register with the currently /// Internal function called from within bindings to register with the currently

View file

@ -211,10 +211,7 @@ public:
#if !defined(DOXYGEN) #if !defined(DOXYGEN)
// FIXME: we need this to create GradientStop // FIXME: we need this to create GradientStop
operator const cbindgen_private::types::Color &() const operator const cbindgen_private::types::Color &() const { return inner; }
{
return inner;
}
#endif #endif
private: private:

View file

@ -195,10 +195,7 @@ public:
} }
/// Returns the size of the Image in pixels. /// Returns the size of the Image in pixels.
Size<uint32_t> size() const Size<uint32_t> size() const { return cbindgen_private::types::slint_image_size(&data); }
{
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(). /// Returns the path of the image on disk, if it was constructed via Image::load_from_path().
std::optional<slint::SharedString> path() const std::optional<slint::SharedString> path() const
@ -227,10 +224,7 @@ public:
return cbindgen_private::types::slint_image_compare_equal(&a.data, &b.data); return cbindgen_private::types::slint_image_compare_equal(&a.data, &b.data);
} }
/// Returns false if \a a refers to the same image as \a b; true otherwise. /// Returns false if \a a refers to the same image as \a b; true otherwise.
friend bool operator!=(const Image &a, const Image &b) friend bool operator!=(const Image &a, const Image &b) { return !(a == b); }
{
return !(a == b);
}
/// \private /// \private
explicit Image(cbindgen_private::types::Image inner) : data(inner) { } explicit Image(cbindgen_private::types::Image inner) : data(inner) { }

View file

@ -49,10 +49,7 @@ struct SharedString
} }
/// Destroys this SharedString and frees the memory if this is the last instance /// Destroys this SharedString and frees the memory if this is the last instance
/// referencing it. /// referencing it.
~SharedString() ~SharedString() { cbindgen_private::slint_shared_string_drop(this); }
{
cbindgen_private::slint_shared_string_drop(this);
}
/// Assigns \a other to this string and returns a reference to this string. /// Assigns \a other to this string and returns a reference to this string.
SharedString &operator=(const SharedString &other) SharedString &operator=(const SharedString &other)
{ {
@ -71,10 +68,7 @@ struct SharedString
/// Assigns null-terminated string pointer \a s to this string and returns a reference /// Assigns null-terminated string pointer \a s to this string and returns a reference
/// to this string. The underlying string data is copied. It is assumed that the string /// to this string. The underlying string data is copied. It is assumed that the string
/// is UTF-8 encoded. /// is UTF-8 encoded.
SharedString &operator=(const char *s) SharedString &operator=(const char *s) { return *this = std::string_view(s); }
{
return *this = std::string_view(s);
}
/// Move-assigns \a other to this SharedString instance. /// Move-assigns \a other to this SharedString instance.
SharedString &operator=(SharedString &&other) SharedString &operator=(SharedString &&other)
@ -85,23 +79,14 @@ struct SharedString
/// Provides a view to the string data. The returned view is only valid as long as at /// Provides a view to the string data. The returned view is only valid as long as at
/// least this SharedString exists. /// least this SharedString exists.
operator std::string_view() const operator std::string_view() const { return cbindgen_private::slint_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 /// Provides a raw pointer to the string data. The returned pointer is only valid as long as at
/// least this SharedString exists. /// least this SharedString exists.
auto data() const -> const char * auto data() const -> const char * { return cbindgen_private::slint_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 /// Returns a pointer to the first character. It is only safe to dereference the pointer if the
/// string contains at least one character. /// string contains at least one character.
const char *begin() const const char *begin() const { return data(); }
{
return data();
}
/// Returns a point past the last character of the string. It is not safe to dereference the /// Returns a point past the last character of the string. It is not safe to dereference the
/// pointer, but it is suitable for comparison. /// pointer, but it is suitable for comparison.
const char *end() const const char *end() const
@ -111,10 +96,7 @@ struct SharedString
} }
/// \return true if the string contains no characters; false otherwise. /// \return true if the string contains no characters; false otherwise.
bool empty() const bool empty() const { return std::string_view(*this).empty(); }
{
return std::string_view(*this).empty();
}
/// \return true if the string starts with the specified prefix string; false otherwise /// \return true if the string starts with the specified prefix string; false otherwise
bool starts_with(std::string_view prefix) const bool starts_with(std::string_view prefix) const
@ -141,10 +123,7 @@ struct SharedString
/// auto str = slint::SharedString::from_number(42); // creates "42" /// auto str = slint::SharedString::from_number(42); // creates "42"
/// auto str2 = slint::SharedString::from_number(100.5) // creates "100.5" /// auto str2 = slint::SharedString::from_number(100.5) // creates "100.5"
/// \endcode /// \endcode
static SharedString from_number(double n) static SharedString from_number(double n) { return SharedString(n); }
{
return SharedString(n);
}
/// Returns true if \a a is equal to \a b; otherwise returns false. /// Returns true if \a a is equal to \a b; otherwise returns false.
friend bool operator==(const SharedString &a, const SharedString &b) friend bool operator==(const SharedString &a, const SharedString &b)
@ -206,10 +185,7 @@ struct SharedString
private: private:
/// Use SharedString::from_number /// Use SharedString::from_number
explicit SharedString(double n) explicit SharedString(double n) { cbindgen_private::slint_shared_string_from_number(this, n); }
{
cbindgen_private::slint_shared_string_from_number(this, n);
}
void *inner; // opaque void *inner; // opaque
}; };

View file

@ -134,45 +134,21 @@ public:
return VRc(inner); return VRc(inner);
} }
const X *operator->() const const X *operator->() const { return &inner->data; }
{ const X &operator*() const { return inner->data; }
return &inner->data; X *operator->() { return &inner->data; }
} X &operator*() { return inner->data; }
const X &operator*() const
{
return inner->data;
}
X *operator->()
{
return &inner->data;
}
X &operator*()
{
return inner->data;
}
const VRc<VTable, Dyn> &into_dyn() const const VRc<VTable, Dyn> &into_dyn() const
{ {
return *reinterpret_cast<const VRc<VTable, Dyn> *>(this); return *reinterpret_cast<const VRc<VTable, Dyn> *>(this);
} }
VRef<VTable> borrow() const VRef<VTable> borrow() const { return { inner->vtable, inner->data_ptr() }; }
{
return { inner->vtable, inner->data_ptr() };
}
friend bool operator==(const VRc &a, const VRc &b) friend bool operator==(const VRc &a, const VRc &b) { return a.inner == b.inner; }
{ friend bool operator!=(const VRc &a, const VRc &b) { return a.inner != b.inner; }
return a.inner == b.inner; const VTable *vtable() const { return inner->vtable; }
}
friend bool operator!=(const VRc &a, const VRc &b)
{
return a.inner != b.inner;
}
const VTable *vtable() const
{
return inner->vtable;
}
}; };
template<typename VTable, typename X = Dyn> template<typename VTable, typename X = Dyn>

View file

@ -53,7 +53,10 @@ static GLint compile_shader(GLuint program, GLuint shader_type, const GLchar *co
glGetIntegerv(ParamName, (GLint *)&saved_value); \ glGetIntegerv(ParamName, (GLint *)&saved_value); \
BindingFn(TargetName, new_value); \ BindingFn(TargetName, new_value); \
} \ } \
~StructName() { BindingFn(TargetName, saved_value); } \ ~StructName() \
{ \
BindingFn(TargetName, saved_value); \
} \
} }
DEFINE_SCOPED_BINDING(ScopedTextureBinding, GL_TEXTURE_BINDING_2D, glBindTexture, GL_TEXTURE_2D); DEFINE_SCOPED_BINDING(ScopedTextureBinding, GL_TEXTURE_BINDING_2D, glBindTexture, GL_TEXTURE_2D);