mirror of
https://github.com/slint-ui/slint.git
synced 2025-09-27 20:42:25 +00:00
Run clang-format over C++ files
This commit is contained in:
parent
1884497308
commit
ca6dfc0cb5
12 changed files with 141 additions and 107 deletions
|
@ -213,8 +213,8 @@ public:
|
||||||
inline std::optional<SharedString> register_font_from_data(const uint8_t *data, std::size_t len)
|
inline std::optional<SharedString> register_font_from_data(const uint8_t *data, std::size_t len)
|
||||||
{
|
{
|
||||||
SharedString maybe_err;
|
SharedString maybe_err;
|
||||||
cbindgen_private::slint_register_font_from_data(&inner, { const_cast<uint8_t *>(data), len },
|
cbindgen_private::slint_register_font_from_data(
|
||||||
&maybe_err);
|
&inner, { const_cast<uint8_t *>(data), len }, &maybe_err);
|
||||||
if (!maybe_err.empty()) {
|
if (!maybe_err.empty()) {
|
||||||
return maybe_err;
|
return maybe_err;
|
||||||
} else {
|
} else {
|
||||||
|
@ -222,8 +222,6 @@ public:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
cbindgen_private::WindowRcOpaque inner;
|
cbindgen_private::WindowRcOpaque inner;
|
||||||
};
|
};
|
||||||
|
|
|
@ -98,7 +98,6 @@ private:
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Brush is used to declare how to fill or outline shapes, such as rectangles, paths or text. A
|
/// Brush is used to declare how to fill or outline shapes, such as rectangles, paths or text. A
|
||||||
|
|
|
@ -163,7 +163,10 @@ 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 { return inner; }
|
operator const cbindgen_private::types::Color &() const
|
||||||
|
{
|
||||||
|
return inner;
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
|
@ -61,12 +61,19 @@ private:
|
||||||
};
|
};
|
||||||
|
|
||||||
namespace private_api {
|
namespace private_api {
|
||||||
inline Image load_image_from_embedded_data(std::span<const uint8_t> data, std::string_view extension) {
|
inline Image load_image_from_embedded_data(std::span<const uint8_t> data,
|
||||||
|
std::string_view extension)
|
||||||
|
{
|
||||||
cbindgen_private::types::Image img(cbindgen_private::types::Image::ImageInner_None());
|
cbindgen_private::types::Image img(cbindgen_private::types::Image::ImageInner_None());
|
||||||
cbindgen_private::types::slint_image_load_from_embedded_data(
|
cbindgen_private::types::slint_image_load_from_embedded_data(
|
||||||
slint::cbindgen_private::Slice<uint8_t>{const_cast<uint8_t *>(data.data()), data.size()}, slint::cbindgen_private::Slice<uint8_t>{const_cast<uint8_t *>(reinterpret_cast<const uint8_t *>(extension.data())), extension.size()}, &img);
|
slint::cbindgen_private::Slice<uint8_t> { const_cast<uint8_t *>(data.data()),
|
||||||
|
data.size() },
|
||||||
|
slint::cbindgen_private::Slice<uint8_t> {
|
||||||
|
const_cast<uint8_t *>(reinterpret_cast<const uint8_t *>(extension.data())),
|
||||||
|
extension.size() },
|
||||||
|
&img);
|
||||||
return Image(img);
|
return Image(img);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -205,7 +205,10 @@ 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 { return iterator(); }
|
iterator end() const
|
||||||
|
{
|
||||||
|
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.
|
||||||
|
@ -454,10 +457,7 @@ inline Value::Value(const std::shared_ptr<slint::Model<Value>> &model)
|
||||||
{
|
{
|
||||||
cbindgen_private::slint_interpreter_model_notify_row_removed(¬ify, index, count);
|
cbindgen_private::slint_interpreter_model_notify_row_removed(¬ify, index, count);
|
||||||
}
|
}
|
||||||
void reset() override
|
void reset() override { cbindgen_private::slint_interpreter_model_notify_reset(¬ify); }
|
||||||
{
|
|
||||||
cbindgen_private::slint_interpreter_model_notify_reset(¬ify);
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
auto wrapper = std::make_shared<ModelWrapper>();
|
auto wrapper = std::make_shared<ModelWrapper>();
|
||||||
|
@ -492,7 +492,8 @@ inline Value::Value(const std::shared_ptr<slint::Model<Value>> &model)
|
||||||
};
|
};
|
||||||
|
|
||||||
static const ModelAdaptorVTable vt { row_count, row_data, set_row_data, get_notify, drop };
|
static const ModelAdaptorVTable vt { row_count, row_data, set_row_data, get_notify, drop };
|
||||||
cbindgen_private::slint_interpreter_value_new_model(reinterpret_cast<uint8_t *>(wrapper.get()), &vt, &inner);
|
cbindgen_private::slint_interpreter_value_new_model(reinterpret_cast<uint8_t *>(wrapper.get()),
|
||||||
|
&vt, &inner);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline Struct::Struct(std::initializer_list<std::pair<std::string_view, Value>> args)
|
inline Struct::Struct(std::initializer_list<std::pair<std::string_view, Value>> args)
|
||||||
|
|
|
@ -7,6 +7,7 @@
|
||||||
#include "slint_pathdata_internal.h"
|
#include "slint_pathdata_internal.h"
|
||||||
|
|
||||||
namespace slint::private_api {
|
namespace slint::private_api {
|
||||||
|
using cbindgen_private::PathEvent;
|
||||||
using cbindgen_private::types::PathArcTo;
|
using cbindgen_private::types::PathArcTo;
|
||||||
using cbindgen_private::types::PathCubicTo;
|
using cbindgen_private::types::PathCubicTo;
|
||||||
using cbindgen_private::types::PathElement;
|
using cbindgen_private::types::PathElement;
|
||||||
|
@ -14,7 +15,6 @@ using cbindgen_private::types::PathLineTo;
|
||||||
using cbindgen_private::types::PathMoveTo;
|
using cbindgen_private::types::PathMoveTo;
|
||||||
using cbindgen_private::types::PathQuadraticTo;
|
using cbindgen_private::types::PathQuadraticTo;
|
||||||
using cbindgen_private::types::Point;
|
using cbindgen_private::types::Point;
|
||||||
using cbindgen_private::PathEvent;
|
|
||||||
|
|
||||||
struct PathData
|
struct PathData
|
||||||
{
|
{
|
||||||
|
|
|
@ -3,13 +3,13 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
|
||||||
namespace slint {
|
namespace slint {
|
||||||
|
|
||||||
/// The Size structure is used to represent a two-dimensional size
|
/// The Size structure is used to represent a two-dimensional size
|
||||||
/// with width and height.
|
/// with width and height.
|
||||||
template <typename T>
|
template<typename T>
|
||||||
struct Size {
|
struct Size
|
||||||
|
{
|
||||||
/// The width of the size
|
/// The width of the size
|
||||||
T width;
|
T width;
|
||||||
/// The height of the size
|
/// The height of the size
|
||||||
|
@ -20,10 +20,10 @@ struct Size {
|
||||||
};
|
};
|
||||||
|
|
||||||
namespace cbindgen_private {
|
namespace cbindgen_private {
|
||||||
// The Size types are expanded to the Size2D<...> type from the euclid crate which
|
// The Size types are expanded to the Size2D<...> type from the euclid crate which
|
||||||
// is binary compatible with Size<T>
|
// is binary compatible with Size<T>
|
||||||
template <typename T> using Size2D = Size<T>;
|
template<typename T>
|
||||||
|
using Size2D = Size<T>;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -53,7 +53,10 @@ 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() { cbindgen_private::slint_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.
|
/// Assigns \a other to this string and returns a reference to this string.
|
||||||
SharedString &operator=(const SharedString &other)
|
SharedString &operator=(const SharedString &other)
|
||||||
{
|
{
|
||||||
|
@ -72,7 +75,10 @@ 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) { return *this = std::string_view(s); }
|
SharedString &operator=(const char *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)
|
||||||
|
@ -83,20 +89,35 @@ 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 { return cbindgen_private::slint_shared_string_bytes(this); }
|
operator std::string_view() const
|
||||||
|
{
|
||||||
|
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 * { return cbindgen_private::slint_shared_string_bytes(this); }
|
auto data() const -> const char *
|
||||||
|
{
|
||||||
|
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 { return data(); }
|
const char *begin() const
|
||||||
|
{
|
||||||
|
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 { return &*std::string_view(*this).end(); }
|
const char *end() const
|
||||||
|
{
|
||||||
|
return &*std::string_view(*this).end();
|
||||||
|
}
|
||||||
|
|
||||||
/// \return true if the string contains no characters; false otherwise.
|
/// \return true if the string contains no characters; false otherwise.
|
||||||
bool empty() const { return std::string_view(*this).empty(); }
|
bool empty() const
|
||||||
|
{
|
||||||
|
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
|
||||||
|
@ -123,7 +144,10 @@ 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) { return SharedString(n); }
|
static SharedString from_number(double 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)
|
||||||
|
@ -185,7 +209,10 @@ struct SharedString
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/// Use SharedString::from_number
|
/// Use SharedString::from_number
|
||||||
explicit SharedString(double n) { cbindgen_private::slint_shared_string_from_number(this, n); }
|
explicit SharedString(double n)
|
||||||
|
{
|
||||||
|
cbindgen_private::slint_shared_string_from_number(this, n);
|
||||||
|
}
|
||||||
void *inner; // opaque
|
void *inner; // opaque
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -18,7 +18,8 @@ struct VRefMut
|
||||||
void *instance;
|
void *instance;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct Layout {
|
struct Layout
|
||||||
|
{
|
||||||
std::size_t size;
|
std::size_t size;
|
||||||
std::size_t align;
|
std::size_t align;
|
||||||
};
|
};
|
||||||
|
@ -31,15 +32,17 @@ template<typename T>
|
||||||
using Pin = T;
|
using Pin = T;
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
struct VBox {
|
struct VBox
|
||||||
|
{
|
||||||
const T *vtable = nullptr;
|
const T *vtable = nullptr;
|
||||||
void *instance = nullptr;
|
void *instance = nullptr;
|
||||||
VBox(const VBox&) = delete;
|
VBox(const VBox &) = delete;
|
||||||
VBox() = default;
|
VBox() = default;
|
||||||
VBox&operator=(const VBox&) = delete;
|
VBox &operator=(const VBox &) = delete;
|
||||||
~VBox() {
|
~VBox()
|
||||||
|
{
|
||||||
if (vtable && instance) {
|
if (vtable && instance) {
|
||||||
vtable->drop({vtable, instance});
|
vtable->drop({ vtable, instance });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -54,11 +57,15 @@ struct VOffset
|
||||||
};
|
};
|
||||||
|
|
||||||
template<typename VTable, typename X>
|
template<typename VTable, typename X>
|
||||||
struct VRcInner {
|
struct VRcInner
|
||||||
template<typename VTable_, typename X_> friend class VRc;
|
{
|
||||||
template<typename VTable_, typename X_> friend class VWeak;
|
template<typename VTable_, typename X_>
|
||||||
|
friend class VRc;
|
||||||
|
template<typename VTable_, typename X_>
|
||||||
|
friend class VWeak;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
VRcInner() : layout {} {}
|
VRcInner() : layout {} { }
|
||||||
const VTable *vtable = &X::static_vtable;
|
const VTable *vtable = &X::static_vtable;
|
||||||
std::atomic<int> strong_ref = 1;
|
std::atomic<int> strong_ref = 1;
|
||||||
std::atomic<int> weak_ref = 1;
|
std::atomic<int> weak_ref = 1;
|
||||||
|
@ -72,113 +79,108 @@ private:
|
||||||
~VRcInner() = delete;
|
~VRcInner() = delete;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct Dyn {};
|
struct Dyn
|
||||||
|
{
|
||||||
|
};
|
||||||
|
|
||||||
template<typename VTable, typename X = Dyn>
|
template<typename VTable, typename X = Dyn>
|
||||||
class VRc {
|
class VRc
|
||||||
|
{
|
||||||
VRcInner<VTable, X> *inner;
|
VRcInner<VTable, X> *inner;
|
||||||
VRc(VRcInner<VTable, X> *inner) : inner(inner) {}
|
VRc(VRcInner<VTable, X> *inner) : inner(inner) { }
|
||||||
template<typename VTable_, typename X_> friend class VWeak;
|
template<typename VTable_, typename X_>
|
||||||
|
friend class VWeak;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
~VRc() {
|
~VRc()
|
||||||
|
{
|
||||||
if (!--inner->strong_ref) {
|
if (!--inner->strong_ref) {
|
||||||
Layout layout = inner->vtable->drop_in_place({inner->vtable, &inner->data});
|
Layout layout = inner->vtable->drop_in_place({ inner->vtable, &inner->data });
|
||||||
layout.size += inner->data_offset;
|
layout.size += inner->data_offset;
|
||||||
layout.align = std::max<size_t>(layout.align, alignof(VRcInner<VTable, Dyn>));
|
layout.align = std::max<size_t>(layout.align, alignof(VRcInner<VTable, Dyn>));
|
||||||
inner->layout = layout;
|
inner->layout = layout;
|
||||||
if (!--inner->weak_ref) {
|
if (!--inner->weak_ref) {
|
||||||
inner->vtable->dealloc(inner->vtable, reinterpret_cast<uint8_t*>(inner), layout);
|
inner->vtable->dealloc(inner->vtable, reinterpret_cast<uint8_t *>(inner), layout);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
VRc(const VRc &other): inner(other.inner) {
|
VRc(const VRc &other) : inner(other.inner) { inner->strong_ref++; }
|
||||||
inner->strong_ref++;
|
VRc &operator=(const VRc &other)
|
||||||
}
|
{
|
||||||
VRc &operator=(const VRc &other) {
|
|
||||||
if (inner == other.inner)
|
if (inner == other.inner)
|
||||||
return *this;
|
return *this;
|
||||||
this->~VRc();
|
this->~VRc();
|
||||||
new(this) VRc(other);
|
new (this) VRc(other);
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
/// Construct a new VRc holding an X.
|
/// Construct a new VRc holding an X.
|
||||||
///
|
///
|
||||||
/// The type X must have a static member `static_vtable` of type VTable
|
/// The type X must have a static member `static_vtable` of type VTable
|
||||||
template<typename ...Args> static VRc make(Args... args) {
|
template<typename... Args>
|
||||||
auto mem = ::operator new(sizeof(VRcInner<VTable, X>), static_cast<std::align_val_t>(alignof(VRcInner<VTable, X>)));
|
static VRc make(Args... args)
|
||||||
|
{
|
||||||
|
auto mem = ::operator new(sizeof(VRcInner<VTable, X>),
|
||||||
|
static_cast<std::align_val_t>(alignof(VRcInner<VTable, X>)));
|
||||||
auto inner = new (mem) VRcInner<VTable, X>;
|
auto inner = new (mem) VRcInner<VTable, X>;
|
||||||
new (&inner->data) X(args...);
|
new (&inner->data) X(args...);
|
||||||
return VRc(inner);
|
return VRc(inner);
|
||||||
}
|
}
|
||||||
|
|
||||||
const X* operator->() const {
|
const X *operator->() const { return &inner->data; }
|
||||||
return &inner->data;
|
const X &operator*() const { return inner->data; }
|
||||||
}
|
X *operator->() { return &inner->data; }
|
||||||
const X& operator*() const {
|
X &operator*() { return inner->data; }
|
||||||
return inner->data;
|
|
||||||
}
|
|
||||||
X* operator->() {
|
|
||||||
return &inner->data;
|
|
||||||
}
|
|
||||||
X& operator*() {
|
|
||||||
return inner->data;
|
|
||||||
}
|
|
||||||
|
|
||||||
VRc<VTable, Dyn> into_dyn() const { return *reinterpret_cast<const VRc<VTable, Dyn> *>(this); }
|
VRc<VTable, Dyn> into_dyn() const { return *reinterpret_cast<const VRc<VTable, Dyn> *>(this); }
|
||||||
|
|
||||||
VRef<VTable> borrow() const { return { inner->vtable, inner->data_ptr() }; }
|
VRef<VTable> borrow() const { 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; }
|
||||||
return a.inner == b.inner;
|
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;
|
|
||||||
}
|
|
||||||
const VTable *vtable() const { return inner->vtable; }
|
const VTable *vtable() const { return inner->vtable; }
|
||||||
};
|
};
|
||||||
|
|
||||||
template<typename VTable, typename X = Dyn>
|
template<typename VTable, typename X = Dyn>
|
||||||
class VWeak {
|
class VWeak
|
||||||
|
{
|
||||||
VRcInner<VTable, X> *inner = nullptr;
|
VRcInner<VTable, X> *inner = nullptr;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
VWeak() = default;
|
VWeak() = default;
|
||||||
~VWeak() {
|
~VWeak()
|
||||||
|
{
|
||||||
if (inner && !--inner->weak_ref) {
|
if (inner && !--inner->weak_ref) {
|
||||||
inner->vtable->dealloc(inner->vtable, reinterpret_cast<uint8_t*>(inner), inner->layout);
|
inner->vtable->dealloc(inner->vtable, reinterpret_cast<uint8_t *>(inner),
|
||||||
|
inner->layout);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
VWeak(const VWeak &other): inner(other.inner) {
|
VWeak(const VWeak &other) : inner(other.inner) { inner && inner->weak_ref++; }
|
||||||
inner && inner->weak_ref++;
|
VWeak(const VRc<VTable, X> &other) : inner(other.inner) { inner && inner->weak_ref++; }
|
||||||
}
|
VWeak &operator=(const VWeak &other)
|
||||||
VWeak(const VRc<VTable, X> &other): inner(other.inner) {
|
{
|
||||||
inner && inner->weak_ref++;
|
|
||||||
}
|
|
||||||
VWeak &operator=(const VWeak &other) {
|
|
||||||
if (inner == other.inner)
|
if (inner == other.inner)
|
||||||
return *this;
|
return *this;
|
||||||
this->~VWeak();
|
this->~VWeak();
|
||||||
new(this) VWeak(other);
|
new (this) VWeak(other);
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::optional<VRc<VTable, X>> lock() const {
|
std::optional<VRc<VTable, X>> lock() const
|
||||||
|
{
|
||||||
if (!inner || inner->strong_ref == 0)
|
if (!inner || inner->strong_ref == 0)
|
||||||
return {};
|
return {};
|
||||||
inner->strong_ref++;
|
inner->strong_ref++;
|
||||||
return { VRc<VTable, X>(inner) };
|
return { VRc<VTable, X>(inner) };
|
||||||
}
|
}
|
||||||
|
|
||||||
VWeak<VTable, Dyn> into_dyn() const { return *reinterpret_cast<const VWeak<VTable, Dyn> *>(this); }
|
VWeak<VTable, Dyn> into_dyn() const
|
||||||
|
{
|
||||||
|
return *reinterpret_cast<const VWeak<VTable, Dyn> *>(this);
|
||||||
|
}
|
||||||
|
|
||||||
friend bool operator==(const VWeak &a, const VWeak &b) {
|
friend bool operator==(const VWeak &a, const VWeak &b) { return a.inner == b.inner; }
|
||||||
return a.inner == b.inner;
|
friend bool operator!=(const VWeak &a, const VWeak &b) { return a.inner != b.inner; }
|
||||||
}
|
|
||||||
friend bool operator!=(const VWeak &a, const VWeak &b) {
|
|
||||||
return a.inner != b.inner;
|
|
||||||
}
|
|
||||||
const VTable *vtable() const { return inner ? inner->vtable : nullptr; }
|
const VTable *vtable() const { return inner ? inner->vtable : nullptr; }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
} // namespace vtable
|
||||||
|
|
||||||
} //namespace vtable
|
|
||||||
|
|
|
@ -24,7 +24,6 @@ SCENARIO("Basic usage")
|
||||||
REQUIRE(prop2.get() == 42 + 4);
|
REQUIRE(prop2.get() == 42 + 4);
|
||||||
prop.set(55);
|
prop.set(55);
|
||||||
REQUIRE(prop2.get() == 55 + 4);
|
REQUIRE(prop2.get() == 55 + 4);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
REQUIRE(prop.get() == 55);
|
REQUIRE(prop.get() == 55);
|
||||||
|
@ -32,7 +31,6 @@ SCENARIO("Basic usage")
|
||||||
REQUIRE(prop.get() == 33);
|
REQUIRE(prop.get() == 33);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
SCENARIO("Set after binding")
|
SCENARIO("Set after binding")
|
||||||
{
|
{
|
||||||
Property<int> prop;
|
Property<int> prop;
|
||||||
|
|
|
@ -58,10 +58,9 @@ int main(int argc, char **argv)
|
||||||
auto instance = def->create();
|
auto instance = def->create();
|
||||||
QWidget *wid = instance->qwidget();
|
QWidget *wid = instance->qwidget();
|
||||||
if (!wid) {
|
if (!wid) {
|
||||||
QMessageBox::critical(
|
QMessageBox::critical(&main, QApplication::translate("qt_viewer", "No Qt backend"),
|
||||||
&main, QApplication::translate("qt_viewer", "No Qt backend"),
|
QApplication::translate(
|
||||||
QApplication::translate("qt_viewer",
|
"qt_viewer", "Slint is not running with the Qt backend."),
|
||||||
"Slint is not running with the Qt backend."),
|
|
||||||
QMessageBox::StandardButton::Ok);
|
QMessageBox::StandardButton::Ok);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue