diff options
author | Lars Knoll <lars.knoll@digia.com> | 2012-12-13 00:53:04 +0100 |
---|---|---|
committer | Simon Hausmann <simon.hausmann@digia.com> | 2012-12-12 16:07:18 +0100 |
commit | c28f8c7b409fdd7214bb721c4192374786ec682f (patch) | |
tree | 7df99ac24c439f6349593d2723af5e40ace6ba0a /qmljs_engine.cpp | |
parent | 949303cd7da0edcab235bc19d5fad7d4af7eaed3 (diff) |
Fix access rights for builtin properties
According to the spec all builtin properties have
writable: true, enumerable: false and configurable:true
by default. This is what is now being used. Some constants
have all attributes set to false, and there is an extra
method for setting these readonly properties.
Change-Id: If5ba875bcc9f1644aa8a07a2d9b37716bf228e12
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
Diffstat (limited to 'qmljs_engine.cpp')
-rw-r--r-- | qmljs_engine.cpp | 57 |
1 files changed, 24 insertions, 33 deletions
diff --git a/qmljs_engine.cpp b/qmljs_engine.cpp index 6e837e21ba..45db9fcb2b 100644 --- a/qmljs_engine.cpp +++ b/qmljs_engine.cpp @@ -179,42 +179,33 @@ ExecutionEngine::ExecutionEngine(MemoryManager *memoryManager, EvalISelFactory * rootContext->activation = glo; rootContext->thisObject = Value::fromObject(glo); - glo->__put__(rootContext, identifier(QStringLiteral("Object")), objectCtor); - glo->__put__(rootContext, identifier(QStringLiteral("String")), stringCtor); - glo->__put__(rootContext, identifier(QStringLiteral("Number")), numberCtor); - glo->__put__(rootContext, identifier(QStringLiteral("Boolean")), booleanCtor); - glo->__put__(rootContext, identifier(QStringLiteral("Array")), arrayCtor); - glo->__put__(rootContext, identifier(QStringLiteral("Function")), functionCtor); - glo->__put__(rootContext, identifier(QStringLiteral("Date")), dateCtor); - glo->__put__(rootContext, identifier(QStringLiteral("RegExp")), regExpCtor); - glo->__put__(rootContext, identifier(QStringLiteral("Error")), errorCtor); - glo->__put__(rootContext, identifier(QStringLiteral("EvalError")), evalErrorCtor); - glo->__put__(rootContext, identifier(QStringLiteral("RangeError")), rangeErrorCtor); - glo->__put__(rootContext, identifier(QStringLiteral("ReferenceError")), referenceErrorCtor); - glo->__put__(rootContext, identifier(QStringLiteral("SyntaxError")), syntaxErrorCtor); - glo->__put__(rootContext, identifier(QStringLiteral("TypeError")), typeErrorCtor); - glo->__put__(rootContext, identifier(QStringLiteral("URIError")), uRIErrorCtor); - glo->__put__(rootContext, identifier(QStringLiteral("Math")), Value::fromObject(newMathObject(rootContext))); - - PropertyDescriptor pd; - pd.type = PropertyDescriptor::Data; - pd.writable = PropertyDescriptor::Unset; - pd.enumberable = PropertyDescriptor::Unset; - pd.configurable = PropertyDescriptor::Unset; - - pd.value = Value::undefinedValue(); - glo->__defineOwnProperty__(rootContext, identifier(QStringLiteral("undefined")), &pd); - pd.value = Value::fromDouble(nan("")); - glo->__defineOwnProperty__(rootContext, identifier(QStringLiteral("NaN")), &pd); - pd.value = Value::fromDouble(INFINITY); - glo->__defineOwnProperty__(rootContext, identifier(QStringLiteral("Infinity")), &pd); - - glo->__put__(rootContext, identifier(QStringLiteral("eval")), Value::fromObject(new (memoryManager) EvalFunction(rootContext))); + glo->defineDefaultProperty(rootContext, QStringLiteral("Object"), objectCtor); + glo->defineDefaultProperty(rootContext, QStringLiteral("String"), stringCtor); + glo->defineDefaultProperty(rootContext, QStringLiteral("Number"), numberCtor); + glo->defineDefaultProperty(rootContext, QStringLiteral("Boolean"), booleanCtor); + glo->defineDefaultProperty(rootContext, QStringLiteral("Array"), arrayCtor); + glo->defineDefaultProperty(rootContext, QStringLiteral("Function"), functionCtor); + glo->defineDefaultProperty(rootContext, QStringLiteral("Date"), dateCtor); + glo->defineDefaultProperty(rootContext, QStringLiteral("RegExp"), regExpCtor); + glo->defineDefaultProperty(rootContext, QStringLiteral("Error"), errorCtor); + glo->defineDefaultProperty(rootContext, QStringLiteral("EvalError"), evalErrorCtor); + glo->defineDefaultProperty(rootContext, QStringLiteral("RangeError"), rangeErrorCtor); + glo->defineDefaultProperty(rootContext, QStringLiteral("ReferenceError"), referenceErrorCtor); + glo->defineDefaultProperty(rootContext, QStringLiteral("SyntaxError"), syntaxErrorCtor); + glo->defineDefaultProperty(rootContext, QStringLiteral("TypeError"), typeErrorCtor); + glo->defineDefaultProperty(rootContext, QStringLiteral("URIError"), uRIErrorCtor); + glo->defineDefaultProperty(rootContext, QStringLiteral("Math"), Value::fromObject(newMathObject(rootContext))); + + glo->defineReadonlyProperty(this, QStringLiteral("undefined"), Value::undefinedValue()); + glo->defineReadonlyProperty(this, QStringLiteral("NaN"), Value::fromDouble(nan(""))); + glo->defineReadonlyProperty(this, QStringLiteral("Infinity"), Value::fromDouble(INFINITY)); + + glo->defineDefaultProperty(rootContext, QStringLiteral("eval"), Value::fromObject(new (memoryManager) EvalFunction(rootContext))); // TODO: parseInt [15.1.2.2] // TODO: parseFloat [15.1.2.3] - glo->__put__(rootContext, identifier(QStringLiteral("isNaN")), Value::fromObject(new (memoryManager) IsNaNFunction(rootContext))); // isNaN [15.1.2.4] - glo->__put__(rootContext, identifier(QStringLiteral("isFinite")), Value::fromObject(new (memoryManager) IsFiniteFunction(rootContext))); // isFinite [15.1.2.5] + glo->defineDefaultProperty(rootContext, QStringLiteral("isNaN"), Value::fromObject(new (memoryManager) IsNaNFunction(rootContext))); + glo->defineDefaultProperty(rootContext, QStringLiteral("isFinite"), Value::fromObject(new (memoryManager) IsFiniteFunction(rootContext))); } ExecutionEngine::~ExecutionEngine() |