#include <private/qqmlengine_p.h>
#include <qv4codegen_p.h>
#include "private/qlocale_tools_p.h"
+#include "private/qqmlbuiltinfunctions_p.h"
#include <QtCore/qmath.h>
#include <QtCore/QDebug>
return scope->d()->engine->memoryManager->alloc<SimpleScriptFunction>(scope, function, createProto);
}
+bool FunctionObject::isBinding() const
+{
+ return d()->internalClass->vtable == QQmlBindingFunction::staticVTable();
+}
+
DEFINE_OBJECT_VTABLE(FunctionCtor);
Heap::FunctionCtor::FunctionCtor(QV4::ExecutionContext *scope)
bool needsActivation() const { return d()->needsActivation; }
bool strictMode() const { return d()->function ? d()->function->isStrict() : false; }
- bool bindingKeyFlag() const { return d()->bindingKeyFlag; }
+ bool isBinding() const;
static void markObjects(Heap::Base *that, ExecutionEngine *e);
};
QV4::Scope scope(ctx);
QV4::ScopedFunctionObject f(scope, value);
if (f) {
- if (!f->bindingKeyFlag()) {
+ if (!f->isBinding()) {
if (!property->isVarProperty() && property->propType != qMetaTypeId<QJSValue>()) {
// assigning a JS function to a non var or QJSValue property or is not allowed.
QString error = QLatin1String("Cannot assign JavaScript function to ");
uchar extensible : 1; // used by Object
uchar needsActivation : 1; // used by FunctionObject
uchar _strictMode : 1; // used by FunctionObject
- uchar bindingKeyFlag : 1;
+ uchar _bindingKeyFlag : 1;
uchar hasAccessorProperty : 1;
uchar _unused : 1;
mutable uchar subtype;
QV4::Scope scope(ep->v4engine());
QV4::ScopedFunctionObject f(scope, v4function.value());
Q_ASSERT(f);
- if (f->bindingKeyFlag()) {
+ if (f->isBinding()) {
Q_ASSERT(f->as<QV4::QQmlBindingFunction>());
QQmlSourceLocation loc = static_cast<QV4::Heap::QQmlBindingFunction *>(f->d())->bindingLocation;
url = loc.sourceFile;
return false;
} else if (isVarProperty) {
QV4::FunctionObject *f = result->asFunctionObject();
- if (f && f->bindingKeyFlag()) {
+ if (f && f->isBinding()) {
// we explicitly disallow this case to avoid confusion. Users can still store one
// in an array in a var property if they need to, but the common case is user error.
expression->delayedError()->setErrorDescription(QLatin1String("Invalid use of Qt.binding() in a binding declaration."));
writeValueProperty(object, core, QVariant(), context, flags);
} else if (type == qMetaTypeId<QJSValue>()) {
QV4::FunctionObject *f = result->asFunctionObject();
- if (f && f->bindingKeyFlag()) {
+ if (f && f->isBinding()) {
expression->delayedError()->setErrorDescription(QLatin1String("Invalid use of Qt.binding() in a binding declaration."));
expression->delayedError()->setErrorObject(object);
return false;
expression->delayedError()->setErrorObject(object);
return false;
} else if (QV4::FunctionObject *f = result->asFunctionObject()) {
- if (f->bindingKeyFlag())
+ if (f->isBinding())
expression->delayedError()->setErrorDescription(QLatin1String("Invalid use of Qt.binding() in a binding declaration."));
else
expression->delayedError()->setErrorDescription(QLatin1String("Unable to assign a function to a property of any type other than var."));
QV4::ScopedFunctionObject f(scope, value);
if (reference && f) {
- if (!f->bindingKeyFlag()) {
+ if (!f->isBinding()) {
// assigning a JS function to a non-var-property is not allowed.
QString error = QStringLiteral("Cannot assign JavaScript function to value-type property");
ScopedString e(scope, v4->newString(error));
, originalFunction(originalFunction->d())
{
setVTable(QV4::QQmlBindingFunction::staticVTable());
- bindingKeyFlag = true;
}
void QQmlBindingFunction::initBindingLocation()