aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/qml/qqmlpropertybinding_p.h
diff options
context:
space:
mode:
authorFabian Kosmale <fabian.kosmale@qt.io>2020-10-17 14:23:35 +0200
committerFabian Kosmale <fabian.kosmale@qt.io>2020-11-04 13:49:39 +0000
commit4b9249dabf002e204298cfc3cd0e64e607905d54 (patch)
tree4c1d310ed9fac0de38db6b8672f98923878a96a0 /src/qml/qml/qqmlpropertybinding_p.h
parentf9feaa20a8b8a875f9da5c8b561aca8bafd446ca (diff)
Adjust to QPropertyBindingPrivate not using std::function anymore
Change-Id: Id197f3d4bf8ab60256040e0a177d5596ce78a0a8 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Diffstat (limited to 'src/qml/qml/qqmlpropertybinding_p.h')
-rw-r--r--src/qml/qml/qqmlpropertybinding_p.h39
1 files changed, 37 insertions, 2 deletions
diff --git a/src/qml/qml/qqmlpropertybinding_p.h b/src/qml/qml/qqmlpropertybinding_p.h
index c3c684a753..1ea82b26be 100644
--- a/src/qml/qml/qqmlpropertybinding_p.h
+++ b/src/qml/qml/qqmlpropertybinding_p.h
@@ -63,19 +63,54 @@ QT_BEGIN_NAMESPACE
class QQmlPropertyBinding : public QQmlJavaScriptExpression,
public QPropertyBindingPrivate
+
{
public:
+ static constexpr auto propertyBindingOffset() {
+ QT_WARNING_PUSH QT_WARNING_DISABLE_INVALID_OFFSETOF
+ return offsetof(QQmlPropertyBinding, ref);
+ QT_WARNING_POP
+ }
+
static QUntypedPropertyBinding create(const QQmlPropertyData *pd, QV4::Function *function,
QObject *obj, const QQmlRefPointer<QQmlContextData> &ctxt,
QV4::ExecutionContext *scope);
void expressionChanged() override;
+
+ static bool doEvaluate(QMetaType metaType, QUntypedPropertyData *dataPtr, void *f) {
+ auto address = static_cast<std::byte*>(f);
+ address -= sizeof (QPropertyBindingPrivate); // f now points to QPropertyBindingPrivate suboject
+ address -= QQmlPropertyBinding::propertyBindingOffset(); // f now points to QQmlPropertyBinding
+ return reinterpret_cast<QQmlPropertyBinding *>(address)->evaluate(metaType, dataPtr);
+ }
+
private:
- QQmlPropertyBinding(const QMetaType &metaType);
+ QQmlPropertyBinding(QMetaType metaType);
+
+ bool evaluate(QMetaType metaType, void *dataPtr);
+
+
+};
+
+template <auto I>
+struct Print {};
- bool evaluate(const QMetaType &metaType, void *dataPtr);
+namespace QtPrivate {
+template<>
+inline constexpr BindingFunctionVTable bindingFunctionVTable<QQmlPropertyBinding> = {
+ &QQmlPropertyBinding::doEvaluate,
+ [](void *qpropertyBinding){
+ auto address = static_cast<std::byte*>(qpropertyBinding);
+ address -= QQmlPropertyBinding::propertyBindingOffset(); // f now points to QQmlPropertyBinding
+ reinterpret_cast<QQmlPropertyBinding *>(address)->~QQmlPropertyBinding();
+ delete[] address;
+ },
+ [](void *, void *){},
+ 0
};
+}
class QQmlTranslationPropertyBinding
{