delete members;
}
-void Object::setProperty(Context *ctx, const QString &name, const Value &value)
+void Object::__put__(Context *ctx, const QString &name, const Value &value)
{
- setProperty(ctx, ctx->engine->identifier(name), value);
+ __put__(ctx, ctx->engine->identifier(name), value);
}
-void Object::setProperty(Context *ctx, const QString &name, void (*code)(Context *), int count)
+void Object::__put__(Context *ctx, const QString &name, void (*code)(Context *), int count)
{
Q_UNUSED(count);
- setProperty(ctx, name, Value::fromObject(ctx->engine->newNativeFunction(ctx, code)));
-}
-
-Value Object::getProperty(Context *ctx, String *name)
-{
- if (name->isEqualTo(ctx->engine->id___proto__))
- return Value::fromObject(prototype);
-
- PropertyDescriptor tmp;
- if (PropertyDescriptor *p = getPropertyDescriptor(ctx, name, &tmp)) {
- if (p->isData())
- return p->value;
- if (!p->get)
- return Value::undefinedValue();
- FunctionObject *f = p->get->asFunctionObject();
- if (f) {
- f->call(ctx);
- return ctx->result;
- }
- }
- return Value::undefinedValue();
+ __put__(ctx, name, Value::fromObject(ctx->engine->newNativeFunction(ctx, code)));
}
// Section 8.12.1
-PropertyDescriptor *Object::getOwnProperty(Context *, String *name)
+PropertyDescriptor *Object::__getOwnProperty__(Context *, String *name)
{
if (members)
return members->find(name);
return 0;
}
-PropertyDescriptor *Object::getPropertyDescriptor(Context *ctx, String *name, PropertyDescriptor *to_fill)
+// Section 8.12.2
+PropertyDescriptor *Object::__getPropertyDescriptor__(Context *ctx, String *name, PropertyDescriptor *to_fill)
{
- if (PropertyDescriptor *p = getOwnProperty(ctx, name))
+ if (PropertyDescriptor *p = __getOwnProperty__(ctx, name))
return p;
if (prototype)
- return prototype->getPropertyDescriptor(ctx, name, to_fill);
+ return prototype->__getPropertyDescriptor__(ctx, name, to_fill);
return 0;
}
-// Section 8.12.5
-void Object::setProperty(Context *ctx, String *name, const Value &value, bool throwException)
+// Section 8.12.3
+Value Object::__get__(Context *ctx, String *name)
{
- if (!canSetProperty(ctx, name)) {
- if (throwException)
- __qmljs_throw_type_error(ctx);
- return;
- }
-
- if (!members)
- members = new PropertyTable();
+ if (name->isEqualTo(ctx->engine->id___proto__))
+ return Value::fromObject(prototype);
- PropertyDescriptor *pd = getOwnProperty(ctx, name);
- if (pd) {
- if (pd->isData()) {
- pd->value = value;
- return;
+ PropertyDescriptor tmp;
+ if (PropertyDescriptor *p = __getPropertyDescriptor__(ctx, name, &tmp)) {
+ if (p->isData())
+ return p->value;
+ if (!p->get)
+ return Value::undefinedValue();
+ FunctionObject *f = p->get->asFunctionObject();
+ if (f) {
+ f->call(ctx);
+ return ctx->result;
}
}
- PropertyDescriptor *p = members->insert(name);
- *p = PropertyDescriptor::fromValue(value);
+ return Value::undefinedValue();
}
// Section 8.12.4
-bool Object::canSetProperty(Context *ctx, String *name)
+bool Object::__canPut__(Context *ctx, String *name)
{
- if (PropertyDescriptor *p = getOwnProperty(ctx, name)) {
+ if (PropertyDescriptor *p = __getOwnProperty__(ctx, name)) {
if (p->isAccessor())
return p->get != 0;
return p->isWritable();
return extensible;
PropertyDescriptor tmp;
- if (PropertyDescriptor *p = prototype->getPropertyDescriptor(ctx, name, &tmp)) {
+ if (PropertyDescriptor *p = prototype->__getPropertyDescriptor__(ctx, name, &tmp)) {
if (p->isAccessor())
return p->get != 0;
if (!extensible)
return true;
}
-bool Object::hasProperty(Context *ctx, String *name) const
+// Section 8.12.5
+void Object::__put__(Context *ctx, String *name, const Value &value, bool throwException)
{
- if (members)
- return members->find(name) != 0;
+ // clause 1
+ if (!__canPut__(ctx, name))
+ goto reject;
- return prototype ? prototype->hasProperty(ctx, name) : false;
+ if (!members)
+ members = new PropertyTable();
+
+ {
+ // Clause 2
+ PropertyDescriptor *pd = __getOwnProperty__(ctx, name);
+ // Clause 3
+ if (pd && pd->isData()) {
+ // spec says to call [[DefineOwnProperty]] with { [[Value]]: value }
+
+ // ### to simplify and speed up we should expand the relevant parts here (clauses 6,7,9,10,12,13)
+ PropertyDescriptor desc = PropertyDescriptor::fromValue(value);
+ desc.configurable = PropertyDescriptor::Undefined;
+ desc.enumberable = PropertyDescriptor::Undefined;
+ desc.writable = PropertyDescriptor::Undefined;
+ __defineOwnProperty__(ctx, name, &desc, throwException);
+ return;
+ }
+
+ // clause 4
+ PropertyDescriptor tmp;
+ if (prototype)
+ pd = prototype->__getPropertyDescriptor__(ctx, name, &tmp);
+
+ // Clause 5
+ if (pd && pd->isAccessor()) {
+ assert(pd->set != 0);
+ FunctionObject *func = pd->set->asFunctionObject();
+ assert(func);
+
+ // ### unify with callFunction method
+ Context k;
+ Context *c = func->needsActivation ? ctx->engine->newContext() : &k;
+ Value that = Value::fromObject(this);
+ Value args[1];
+ args[0] = value;
+ c->initCallContext(ctx, &that, func, args, 1);
+ func->call(c);
+ c->leaveCallContext();
+ return;
+ }
+
+ PropertyDescriptor *p = members->insert(name);
+ *p = PropertyDescriptor::fromValue(value);
+ }
+
+ reject:
+ if (throwException)
+ __qmljs_throw_type_error(ctx);
}
-bool Object::deleteProperty(Context *, String *name, bool flag)
+// Section 8.12.6
+bool Object::__hasProperty__(Context *ctx, String *name) const
{
- Q_UNUSED(flag);
-
if (members)
- return members->remove(name);
+ return members->find(name) != 0;
- return false;
+ return prototype ? prototype->__hasProperty__(ctx, name) : false;
}
-bool Object::defineOwnProperty(Context *ctx, String *name, const Value &getter, const Value &setter, bool flag)
+// Section 8.12.7
+bool Object::__delete__(Context *ctx, String *name, bool throwException)
+{
+ if (members) {
+ if (PropertyTableEntry *entry = members->findEntry(name)) {
+ if (entry->descriptor.isConfigurable()) {
+ members->remove(entry);
+ return true;
+ }
+ if (throwException)
+ __qmljs_throw_type_error(ctx);
+ return false;
+ }
+ }
+ return true;
+}
+
+// Section 8.12.9
+bool Object::__defineOwnProperty__(Context *ctx, String *name, PropertyDescriptor *desc, bool throwException)
{
if (!members)
members = new PropertyTable();
- PropertyDescriptor *p = getOwnProperty(ctx, name);
- if (!p) {
+ // Clause 1
+ PropertyDescriptor *current = __getOwnProperty__(ctx, name);
+ if (!current) {
+ // clause 3
if (!extensible)
goto reject;
+ // clause 4
+ *current = *desc;
+ current->fullyPopulated();
+ return true;
+ }
+
+ // clause 5
+ if (desc->isEmpty())
+ return true;
+
+ // clause 6
+ if (desc->isSubset(current))
+ return true;
+
+ // clause 7
+ if (!current->isConfigurable()) {
+ if (desc->isConfigurable())
+ goto reject;
+ if (desc->enumberable != PropertyDescriptor::Unset && desc->enumberable != current->enumberable)
+ goto reject;
}
+ // clause 8
+ if (desc->isGeneric())
+ goto accept;
+
+ // clause 9
+ if (current->isData() != desc->isData()) {
+ // 9a
+ if (!current->isConfigurable())
+ goto reject;
+ if (current->isData()) {
+ // 9b
+ current->type = PropertyDescriptor::Accessor;
+ current->writable = PropertyDescriptor::Undefined;
+ current->get = 0;
+ current->set = 0;
+ } else {
+ // 9c
+ current->type = PropertyDescriptor::Data;
+ current->writable = PropertyDescriptor::Unset;
+ current->value = Value::undefinedValue();
+ }
+ } else if (current->isData() && desc->isData()) { // clause 10
+ if (!current->isConfigurable() && !current->isWritable()) {
+ if (desc->isWritable() || !current->value.sameValue(desc->value))
+ goto reject;
+ }
+ } else { // clause 10
+ assert(current->isAccessor() && desc->isAccessor());
+ if (!current->isConfigurable()) {
+ if (current->get != desc->get || current->set != desc->set)
+ goto reject;
+ }
+ }
+
+ accept:
+
+ *current += *desc;
+ return true;
reject:
- if (flag)
+ if (throwException)
__qmljs_throw_type_error(ctx);
return false;
}
}
}
-Value ArrayObject::getProperty(Context *ctx, String *name)
+Value ArrayObject::__get__(Context *ctx, String *name)
{
if (name->isEqualTo(ctx->engine->id_length))
return Value::fromDouble(value.size());
- return Object::getProperty(ctx, name);
+ return Object::__get__(ctx, name);
}
bool FunctionObject::hasInstance(Context *ctx, const Value &value)
return false;
}
- Value o = getProperty(ctx, ctx->engine->id_prototype);
+ Value o = __get__(ctx, ctx->engine->id_prototype);
if (! o.isObject()) {
ctx->throwTypeError();
return false;
function->code(ctx, function->codeData);
}
-Value RegExpObject::getProperty(Context *ctx, String *name)
+Value RegExpObject::__get__(Context *ctx, String *name)
{
QString n = name->toQString();
if (n == QLatin1String("source"))
return Value::fromBoolean(value.patternOptions() & QRegularExpression::MultilineOption);
else if (n == QLatin1String("lastIndex"))
return lastIndex;
- return Object::getProperty(ctx, name);
+ return Object::__get__(ctx, name);
}
void ScriptFunction::construct(VM::Context *ctx)
{
Object *obj = ctx->engine->newObject();
- Value proto = getProperty(ctx, ctx->engine->id_prototype);
+ Value proto = __get__(ctx, ctx->engine->id_prototype);
if (proto.isObject())
obj->prototype = proto.objectValue();
ctx->thisObject = Value::fromObject(obj);
function->code(ctx, function->codeData);
}
-PropertyDescriptor *ActivationObject::getPropertyDescriptor(Context *ctx, String *name, PropertyDescriptor *to_fill)
+PropertyDescriptor *ActivationObject::__getPropertyDescriptor__(Context *ctx, String *name, PropertyDescriptor *to_fill)
{
if (context) {
for (unsigned int i = 0; i < context->varCount; ++i) {
}
}
- return Object::getPropertyDescriptor(ctx, name, to_fill);
+ return Object::__getPropertyDescriptor__(ctx, name, to_fill);
}
-Value ArgumentsObject::getProperty(Context *ctx, String *name)
+Value ArgumentsObject::__get__(Context *ctx, String *name)
{
if (name->isEqualTo(ctx->engine->id_length))
return Value::fromDouble(context->argumentCount);
- return Object::getProperty(ctx, name);
+ return Object::__get__(ctx, name);
}
-PropertyDescriptor *ArgumentsObject::getPropertyDescriptor(Context *ctx, String *name, PropertyDescriptor *to_fill)
+PropertyDescriptor *ArgumentsObject::__getPropertyDescriptor__(Context *ctx, String *name, PropertyDescriptor *to_fill)
{
if (context) {
const quint32 i = Value::fromString(name).toUInt32(ctx);
}
}
- return Object::getPropertyDescriptor(ctx, name, to_fill);
+ return Object::__getPropertyDescriptor__(ctx, name, to_fill);
}
ExecutionEngine::ExecutionEngine()
globalObject = Value::fromObject(glo);
rootContext->activation = Value::fromObject(glo);
- glo->setProperty(rootContext, identifier(QStringLiteral("Object")), objectCtor);
- glo->setProperty(rootContext, identifier(QStringLiteral("String")), stringCtor);
- glo->setProperty(rootContext, identifier(QStringLiteral("Number")), numberCtor);
- glo->setProperty(rootContext, identifier(QStringLiteral("Boolean")), booleanCtor);
- glo->setProperty(rootContext, identifier(QStringLiteral("Array")), arrayCtor);
- glo->setProperty(rootContext, identifier(QStringLiteral("Function")), functionCtor);
- glo->setProperty(rootContext, identifier(QStringLiteral("Date")), dateCtor);
- glo->setProperty(rootContext, identifier(QStringLiteral("RegExp")), regExpCtor);
- glo->setProperty(rootContext, identifier(QStringLiteral("Math")), Value::fromObject(newMathObject(rootContext)));
+ 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("Math")), Value::fromObject(newMathObject(rootContext)));
}
Context *ExecutionEngine::newContext()
{
ScriptFunction *f = new ScriptFunction(scope, function);
Object *proto = scope->engine->newObject();
- proto->setProperty(scope, scope->engine->id_constructor, Value::fromObject(f));
- f->setProperty(scope, scope->engine->id_prototype, Value::fromObject(proto));
+ proto->__put__(scope, scope->engine->id_constructor, Value::fromObject(f));
+ f->__put__(scope, scope->engine->id_prototype, Value::fromObject(proto));
f->prototype = scope->engine->functionPrototype;
return f;
}
Value Value::property(Context *ctx, String *name) const
{
- return isObject() ? objectValue()->getProperty(ctx, name) : undefinedValue();
+ return isObject() ? objectValue()->__get__(ctx, name) : undefinedValue();
}
void Context::init(ExecutionEngine *eng)
for (Context *ctx = this; ctx; ctx = ctx->parent) {
if (ctx->activation.isObject()) {
PropertyDescriptor tmp;
- if (PropertyDescriptor *pd = ctx->activation.objectValue()->getPropertyDescriptor(this, name, &tmp)) {
+ if (PropertyDescriptor *pd = ctx->activation.objectValue()->__getPropertyDescriptor__(this, name, &tmp)) {
return &pd->value;
}
}
assert(thisObject.isObject());
result = thisObject;
- Value proto = f->getProperty(this, engine->id_prototype);
+ Value proto = f->__get__(this, engine->id_prototype);
thisObject.objectValue()->prototype = proto.objectValue();
if (! thisObject.isObject())
thisObject.objectValue()->prototype = engine->objectPrototype;
Value __qmljs_delete_member(Context *ctx, Value base, String *name)
{
Value obj = base.toObject(ctx);
- return Value::fromBoolean(obj.objectValue()->deleteProperty(ctx, name, true));
+ return Value::fromBoolean(obj.objectValue()->__delete__(ctx, name, true));
}
Value __qmljs_delete_property(Context *ctx, String *name)
Value obj = ctx->activation;
if (! obj.isObject())
obj = ctx->engine->globalObject;
- return Value::fromBoolean(obj.objectValue()->deleteProperty(ctx, name, true));
+ return Value::fromBoolean(obj.objectValue()->__delete__(ctx, name, true));
}
Value __qmljs_delete_value(Context *ctx, Value value)
{
if (right.isObject()) {
Value s = __qmljs_to_string(left, ctx);
- bool r = right.objectValue()->hasProperty(ctx, s.stringValue());
+ bool r = right.objectValue()->__hasProperty__(ctx, s.stringValue());
return Value::fromBoolean(r);
} else {
return __qmljs_throw_type_error(ctx);
void __qmljs_inplace_bit_and_member(Value value, Value base, String *name, Context *ctx)
{
Object *o = base.objectValue();
- Value prop = o->getProperty(ctx, name);
+ Value prop = o->__get__(ctx, name);
prop = __qmljs_bit_and(prop, value, ctx);
- o->setProperty(ctx, name, prop);
+ o->__put__(ctx, name, prop);
}
void __qmljs_inplace_bit_or_member(Value value, Value base, String *name, Context *ctx)
{
Object *o = base.objectValue();
- Value prop = o->getProperty(ctx, name);
+ Value prop = o->__get__(ctx, name);
prop = __qmljs_bit_or(prop, value, ctx);
- o->setProperty(ctx, name, prop);
+ o->__put__(ctx, name, prop);
}
void __qmljs_inplace_bit_xor_member(Value value, Value base, String *name, Context *ctx)
{
Object *o = base.objectValue();
- Value prop = o->getProperty(ctx, name);
+ Value prop = o->__get__(ctx, name);
prop = __qmljs_bit_xor(prop, value, ctx);
- o->setProperty(ctx, name, prop);
+ o->__put__(ctx, name, prop);
}
void __qmljs_inplace_add_member(Value value, Value base, String *name, Context *ctx)
{
Object *o = base.objectValue();
- Value prop = o->getProperty(ctx, name);
+ Value prop = o->__get__(ctx, name);
prop = __qmljs_add(prop, value, ctx);
- o->setProperty(ctx, name, prop);
+ o->__put__(ctx, name, prop);
}
void __qmljs_inplace_sub_member(Value value, Value base, String *name, Context *ctx)
{
Object *o = base.objectValue();
- Value prop = o->getProperty(ctx, name);
+ Value prop = o->__get__(ctx, name);
prop = __qmljs_sub(prop, value, ctx);
- o->setProperty(ctx, name, prop);
+ o->__put__(ctx, name, prop);
}
void __qmljs_inplace_mul_member(Value value, Value base, String *name, Context *ctx)
{
Object *o = base.objectValue();
- Value prop = o->getProperty(ctx, name);
+ Value prop = o->__get__(ctx, name);
prop = __qmljs_mul(prop, value, ctx);
- o->setProperty(ctx, name, prop);
+ o->__put__(ctx, name, prop);
}
void __qmljs_inplace_div_member(Value value, Value base, String *name, Context *ctx)
{
Object *o = base.objectValue();
- Value prop = o->getProperty(ctx, name);
+ Value prop = o->__get__(ctx, name);
prop = __qmljs_div(prop, value, ctx);
- o->setProperty(ctx, name, prop);
+ o->__put__(ctx, name, prop);
}
void __qmljs_inplace_mod_member(Value value, Value base, String *name, Context *ctx)
{
Object *o = base.objectValue();
- Value prop = o->getProperty(ctx, name);
+ Value prop = o->__get__(ctx, name);
prop = __qmljs_mod(prop, value, ctx);
- o->setProperty(ctx, name, prop);
+ o->__put__(ctx, name, prop);
}
void __qmljs_inplace_shl_member(Value value, Value base, String *name, Context *ctx)
{
Object *o = base.objectValue();
- Value prop = o->getProperty(ctx, name);
+ Value prop = o->__get__(ctx, name);
prop = __qmljs_shl(prop, value, ctx);
- o->setProperty(ctx, name, prop);
+ o->__put__(ctx, name, prop);
}
void __qmljs_inplace_shr_member(Value value, Value base, String *name, Context *ctx)
{
Object *o = base.objectValue();
- Value prop = o->getProperty(ctx, name);
+ Value prop = o->__get__(ctx, name);
prop = __qmljs_shr(prop, value, ctx);
- o->setProperty(ctx, name, prop);
+ o->__put__(ctx, name, prop);
}
void __qmljs_inplace_ushr_member(Value value, Value base, String *name, Context *ctx)
{
Object *o = base.objectValue();
- Value prop = o->getProperty(ctx, name);
+ Value prop = o->__get__(ctx, name);
prop = __qmljs_ushr(prop, value, ctx);
- o->setProperty(ctx, name, prop);
+ o->__put__(ctx, name, prop);
}
String *__qmljs_string_from_utf8(Context *ctx, const char *s)
assert(object.isObject());
Object *oo = object.objectValue();
- Value conv = oo->getProperty(ctx, meth1);
+ Value conv = oo->__get__(ctx, meth1);
if (FunctionObject *f = conv.asFunctionObject()) {
Value r = callFunction(ctx, object, f, 0, 0);
if (r.isPrimitive())
return r;
}
- conv = oo->getProperty(ctx, meth2);
+ conv = oo->__get__(ctx, meth2);
if (FunctionObject *f = conv.asFunctionObject()) {
Value r = callFunction(ctx, object, f, 0, 0);
if (r.isPrimitive())
void __qmljs_set_property(Context *ctx, Value object, String *name, Value value)
{
- object.objectValue()->setProperty(ctx, name, value, /*flags*/ 0);
+ object.objectValue()->__put__(ctx, name, value, /*flags*/ 0);
}
void __qmljs_set_property_boolean(Context *ctx, Value *object, String *name, bool b)
{
Value value = Value::fromBoolean(b);
- object->objectValue()->setProperty(ctx, name, value, /*flag*/ 0);
+ object->objectValue()->__put__(ctx, name, value, /*flag*/ 0);
}
void __qmljs_set_property_number(Context *ctx, Value *object, String *name, double number)
{
Q_UNUSED(ctx);
Value value = Value::fromDouble(number);
- object->objectValue()->setProperty(ctx, name, value, /*flag*/ 0);
+ object->objectValue()->__put__(ctx, name, value, /*flag*/ 0);
}
void __qmljs_set_property_string(Context *ctx, Value *object, String *name, String *s)
{
Q_UNUSED(ctx);
Value value = Value::fromString(s);
- object->objectValue()->setProperty(ctx, name, value, /*flag*/ 0);
+ object->objectValue()->__put__(ctx, name, value, /*flag*/ 0);
}
void __qmljs_set_property_closure(Context *ctx, Value *object, String *name, IR::Function *function)
{
Value value = __qmljs_init_closure(function, ctx);
- object->objectValue()->setProperty(ctx, name, value, /*flag*/ 0);
+ object->objectValue()->__put__(ctx, name, value, /*flag*/ 0);
}
Value __qmljs_get_element(Context *ctx, Value object, Value index)
if (! object.isObject())
object = __qmljs_to_object(object, ctx);
- return object.objectValue()->getProperty(ctx, name);
+ return object.objectValue()->__get__(ctx, name);
}
void __qmljs_set_element(Context *ctx, Value object, Value index, Value value)
if (! object.isObject())
object = __qmljs_to_object(object, ctx);
- object.objectValue()->setProperty(ctx, name, value, /*flags*/ 0);
+ object.objectValue()->__put__(ctx, name, value, /*flags*/ 0);
}
Value __qmljs_foreach_iterator_object(Value in, Context *ctx)
if (Value *prop = ctx->lookupPropertyDescriptor(name))
*prop = value;
else
- ctx->engine->globalObject.objectValue()->setProperty(ctx, name, value);
+ ctx->engine->globalObject.objectValue()->__put__(ctx, name, value);
}
void __qmljs_set_activation_property_boolean(Context *ctx, String *name, bool b)
Value __qmljs_get_property(Context *ctx, Value object, String *name)
{
if (object.isObject()) {
- return object.objectValue()->getProperty(ctx, name);
+ return object.objectValue()->__get__(ctx, name);
} else if (object.isString() && name->isEqualTo(ctx->engine->id_length)) {
return Value::fromInt32(object.stringValue()->toQString().length());
} else {
object = __qmljs_to_object(object, ctx);
if (object.isObject()) {
- return object.objectValue()->getProperty(ctx, name);
+ return object.objectValue()->__get__(ctx, name);
} else {
ctx->throwTypeError();
return Value::undefinedValue();
if (!thisObject.isObject())
thisObject = __qmljs_to_object(base, context);
- Value func = thisObject.objectValue()->getProperty(context, name);
+ Value func = thisObject.objectValue()->__get__(context, name);
if (FunctionObject *f = func.asFunctionObject()) {
Context k;
Context *ctx = f->needsActivation ? context->engine->newContext() : &k;
ctx->result = Value::fromObject(ctx->engine->newObject());
}
-Value ObjectCtor::getProperty(Context *ctx, String *name)
+Value ObjectCtor::__get__(Context *ctx, String *name)
{
if (name == ctx->engine->id_length)
return Value::fromDouble(1);
- return Object::getProperty(ctx, name);
+ return Object::__get__(ctx, name);
}
void ObjectPrototype::init(Context *ctx, const Value &ctor)
{
- ctor.objectValue()->setProperty(ctx, ctx->engine->id_prototype, Value::fromObject(this));
- ctor.objectValue()->setProperty(ctx, QStringLiteral("getPrototypeOf"), method_getPrototypeOf, 0);
- ctor.objectValue()->setProperty(ctx, QStringLiteral("getOwnPropertyDescriptor"), method_getOwnPropertyDescriptor, 0);
- ctor.objectValue()->setProperty(ctx, QStringLiteral("getOwnPropertyNames"), method_getOwnPropertyNames, 0);
- ctor.objectValue()->setProperty(ctx, QStringLiteral("create"), method_create, 0);
- ctor.objectValue()->setProperty(ctx, QStringLiteral("defineProperty"), method_defineProperty, 0);
- ctor.objectValue()->setProperty(ctx, QStringLiteral("defineProperties"), method_defineProperties, 0);
- ctor.objectValue()->setProperty(ctx, QStringLiteral("seal"), method_seal, 0);
- ctor.objectValue()->setProperty(ctx, QStringLiteral("freeze"), method_freeze, 0);
- ctor.objectValue()->setProperty(ctx, QStringLiteral("preventExtensions"), method_preventExtensions, 0);
- ctor.objectValue()->setProperty(ctx, QStringLiteral("isSealed"), method_isSealed, 0);
- ctor.objectValue()->setProperty(ctx, QStringLiteral("isFrozen"), method_isFrozen, 0);
- ctor.objectValue()->setProperty(ctx, QStringLiteral("isExtensible"), method_isExtensible, 0);
- ctor.objectValue()->setProperty(ctx, QStringLiteral("keys"), method_keys, 0);
-
- setProperty(ctx, QStringLiteral("constructor"), ctor);
- setProperty(ctx, QStringLiteral("toString"), method_toString, 0);
- setProperty(ctx, QStringLiteral("toLocaleString"), method_toLocaleString, 0);
- setProperty(ctx, QStringLiteral("valueOf"), method_valueOf, 0);
- setProperty(ctx, QStringLiteral("hasOwnProperty"), method_hasOwnProperty, 0);
- setProperty(ctx, QStringLiteral("isPrototypeOf"), method_isPrototypeOf, 0);
- setProperty(ctx, QStringLiteral("propertyIsEnumerable"), method_propertyIsEnumerable, 0);
+ ctor.objectValue()->__put__(ctx, ctx->engine->id_prototype, Value::fromObject(this));
+ ctor.objectValue()->__put__(ctx, QStringLiteral("getPrototypeOf"), method_getPrototypeOf, 0);
+ ctor.objectValue()->__put__(ctx, QStringLiteral("getOwnPropertyDescriptor"), method_getOwnPropertyDescriptor, 0);
+ ctor.objectValue()->__put__(ctx, QStringLiteral("getOwnPropertyNames"), method_getOwnPropertyNames, 0);
+ ctor.objectValue()->__put__(ctx, QStringLiteral("create"), method_create, 0);
+ ctor.objectValue()->__put__(ctx, QStringLiteral("defineProperty"), method_defineProperty, 0);
+ ctor.objectValue()->__put__(ctx, QStringLiteral("defineProperties"), method_defineProperties, 0);
+ ctor.objectValue()->__put__(ctx, QStringLiteral("seal"), method_seal, 0);
+ ctor.objectValue()->__put__(ctx, QStringLiteral("freeze"), method_freeze, 0);
+ ctor.objectValue()->__put__(ctx, QStringLiteral("preventExtensions"), method_preventExtensions, 0);
+ ctor.objectValue()->__put__(ctx, QStringLiteral("isSealed"), method_isSealed, 0);
+ ctor.objectValue()->__put__(ctx, QStringLiteral("isFrozen"), method_isFrozen, 0);
+ ctor.objectValue()->__put__(ctx, QStringLiteral("isExtensible"), method_isExtensible, 0);
+ ctor.objectValue()->__put__(ctx, QStringLiteral("keys"), method_keys, 0);
+
+ __put__(ctx, QStringLiteral("constructor"), ctor);
+ __put__(ctx, QStringLiteral("toString"), method_toString, 0);
+ __put__(ctx, QStringLiteral("toLocaleString"), method_toLocaleString, 0);
+ __put__(ctx, QStringLiteral("valueOf"), method_valueOf, 0);
+ __put__(ctx, QStringLiteral("hasOwnProperty"), method_hasOwnProperty, 0);
+ __put__(ctx, QStringLiteral("isPrototypeOf"), method_isPrototypeOf, 0);
+ __put__(ctx, QStringLiteral("propertyIsEnumerable"), method_propertyIsEnumerable, 0);
}
void ObjectPrototype::method_getPrototypeOf(Context *ctx)
{
String *P = ctx->argument(0).toString(ctx);
Value O = ctx->thisObject.toObject(ctx);
- bool r = O.objectValue()->getOwnProperty(ctx, P) != 0;
+ bool r = O.objectValue()->__getOwnProperty__(ctx, P) != 0;
ctx->result = Value::fromBoolean(r);
}
void StringPrototype::init(Context *ctx, const Value &ctor)
{
- ctor.objectValue()->setProperty(ctx, ctx->engine->id_prototype, Value::fromObject(this));
- ctor.objectValue()->setProperty(ctx, QStringLiteral("fromCharCode"), method_fromCharCode);
-
- setProperty(ctx, QStringLiteral("constructor"), ctor);
- setProperty(ctx, QStringLiteral("toString"), method_toString);
- setProperty(ctx, QStringLiteral("valueOf"), method_valueOf);
- setProperty(ctx, QStringLiteral("charAt"), method_charAt);
- setProperty(ctx, QStringLiteral("charCodeAt"), method_charCodeAt);
- setProperty(ctx, QStringLiteral("concat"), method_concat);
- setProperty(ctx, QStringLiteral("indexOf"), method_indexOf);
- setProperty(ctx, QStringLiteral("lastIndexOf"), method_lastIndexOf);
- setProperty(ctx, QStringLiteral("localeCompare"), method_localeCompare);
- setProperty(ctx, QStringLiteral("match"), method_match);
- setProperty(ctx, QStringLiteral("replace"), method_replace);
- setProperty(ctx, QStringLiteral("search"), method_search);
- setProperty(ctx, QStringLiteral("slice"), method_slice);
- setProperty(ctx, QStringLiteral("split"), method_split);
- setProperty(ctx, QStringLiteral("substr"), method_substr);
- setProperty(ctx, QStringLiteral("substring"), method_substring);
- setProperty(ctx, QStringLiteral("toLowerCase"), method_toLowerCase);
- setProperty(ctx, QStringLiteral("toLocaleLowerCase"), method_toLocaleLowerCase);
- setProperty(ctx, QStringLiteral("toUpperCase"), method_toUpperCase);
- setProperty(ctx, QStringLiteral("toLocaleUpperCase"), method_toLocaleUpperCase);
+ ctor.objectValue()->__put__(ctx, ctx->engine->id_prototype, Value::fromObject(this));
+ ctor.objectValue()->__put__(ctx, QStringLiteral("fromCharCode"), method_fromCharCode);
+
+ __put__(ctx, QStringLiteral("constructor"), ctor);
+ __put__(ctx, QStringLiteral("toString"), method_toString);
+ __put__(ctx, QStringLiteral("valueOf"), method_valueOf);
+ __put__(ctx, QStringLiteral("charAt"), method_charAt);
+ __put__(ctx, QStringLiteral("charCodeAt"), method_charCodeAt);
+ __put__(ctx, QStringLiteral("concat"), method_concat);
+ __put__(ctx, QStringLiteral("indexOf"), method_indexOf);
+ __put__(ctx, QStringLiteral("lastIndexOf"), method_lastIndexOf);
+ __put__(ctx, QStringLiteral("localeCompare"), method_localeCompare);
+ __put__(ctx, QStringLiteral("match"), method_match);
+ __put__(ctx, QStringLiteral("replace"), method_replace);
+ __put__(ctx, QStringLiteral("search"), method_search);
+ __put__(ctx, QStringLiteral("slice"), method_slice);
+ __put__(ctx, QStringLiteral("split"), method_split);
+ __put__(ctx, QStringLiteral("substr"), method_substr);
+ __put__(ctx, QStringLiteral("substring"), method_substring);
+ __put__(ctx, QStringLiteral("toLowerCase"), method_toLowerCase);
+ __put__(ctx, QStringLiteral("toLocaleLowerCase"), method_toLocaleLowerCase);
+ __put__(ctx, QStringLiteral("toUpperCase"), method_toUpperCase);
+ __put__(ctx, QStringLiteral("toLocaleUpperCase"), method_toLocaleUpperCase);
}
QString StringPrototype::getThisString(Context *ctx)
void NumberPrototype::init(Context *ctx, const Value &ctor)
{
- ctor.objectValue()->setProperty(ctx, ctx->engine->id_prototype, Value::fromObject(this));
- ctor.objectValue()->setProperty(ctx, QStringLiteral("NaN"), Value::fromDouble(qSNaN()));
- ctor.objectValue()->setProperty(ctx, QStringLiteral("NEGATIVE_INFINITY"), Value::fromDouble(-qInf()));
- ctor.objectValue()->setProperty(ctx, QStringLiteral("POSITIVE_INFINITY"), Value::fromDouble(qInf()));
- ctor.objectValue()->setProperty(ctx, QStringLiteral("MAX_VALUE"), Value::fromDouble(1.7976931348623158e+308));
+ ctor.objectValue()->__put__(ctx, ctx->engine->id_prototype, Value::fromObject(this));
+ ctor.objectValue()->__put__(ctx, QStringLiteral("NaN"), Value::fromDouble(qSNaN()));
+ ctor.objectValue()->__put__(ctx, QStringLiteral("NEGATIVE_INFINITY"), Value::fromDouble(-qInf()));
+ ctor.objectValue()->__put__(ctx, QStringLiteral("POSITIVE_INFINITY"), Value::fromDouble(qInf()));
+ ctor.objectValue()->__put__(ctx, QStringLiteral("MAX_VALUE"), Value::fromDouble(1.7976931348623158e+308));
#ifdef __INTEL_COMPILER
# pragma warning( push )
# pragma warning(disable: 239)
#endif
- ctor.objectValue()->setProperty(ctx, QStringLiteral("MIN_VALUE"), Value::fromDouble(5e-324));
+ ctor.objectValue()->__put__(ctx, QStringLiteral("MIN_VALUE"), Value::fromDouble(5e-324));
#ifdef __INTEL_COMPILER
# pragma warning( pop )
#endif
- setProperty(ctx, QStringLiteral("constructor"), ctor);
- setProperty(ctx, QStringLiteral("toString"), method_toString);
- setProperty(ctx, QStringLiteral("toLocalString"), method_toLocaleString);
- setProperty(ctx, QStringLiteral("valueOf"), method_valueOf);
- setProperty(ctx, QStringLiteral("toFixed"), method_toFixed);
- setProperty(ctx, QStringLiteral("toExponential"), method_toExponential);
- setProperty(ctx, QStringLiteral("toPrecision"), method_toPrecision);
+ __put__(ctx, QStringLiteral("constructor"), ctor);
+ __put__(ctx, QStringLiteral("toString"), method_toString);
+ __put__(ctx, QStringLiteral("toLocalString"), method_toLocaleString);
+ __put__(ctx, QStringLiteral("valueOf"), method_valueOf);
+ __put__(ctx, QStringLiteral("toFixed"), method_toFixed);
+ __put__(ctx, QStringLiteral("toExponential"), method_toExponential);
+ __put__(ctx, QStringLiteral("toPrecision"), method_toPrecision);
}
void NumberPrototype::method_toString(Context *ctx)
void BooleanPrototype::init(Context *ctx, const Value &ctor)
{
- ctor.objectValue()->setProperty(ctx, ctx->engine->id_prototype, Value::fromObject(this));
- setProperty(ctx, QStringLiteral("constructor"), ctor);
- setProperty(ctx, QStringLiteral("toString"), method_toString);
- setProperty(ctx, QStringLiteral("valueOf"), method_valueOf);
+ ctor.objectValue()->__put__(ctx, ctx->engine->id_prototype, Value::fromObject(this));
+ __put__(ctx, QStringLiteral("constructor"), ctor);
+ __put__(ctx, QStringLiteral("toString"), method_toString);
+ __put__(ctx, QStringLiteral("valueOf"), method_valueOf);
}
void BooleanPrototype::method_toString(Context *ctx)
void ArrayPrototype::init(Context *ctx, const Value &ctor)
{
- ctor.objectValue()->setProperty(ctx, ctx->engine->id_prototype, Value::fromObject(this));
- setProperty(ctx, QStringLiteral("constructor"), ctor);
- setProperty(ctx, QStringLiteral("toString"), method_toString, 0);
- setProperty(ctx, QStringLiteral("toLocalString"), method_toLocaleString, 0);
- setProperty(ctx, QStringLiteral("concat"), method_concat, 1);
- setProperty(ctx, QStringLiteral("join"), method_join, 1);
- setProperty(ctx, QStringLiteral("pop"), method_pop, 0);
- setProperty(ctx, QStringLiteral("push"), method_push, 1);
- setProperty(ctx, QStringLiteral("reverse"), method_reverse, 0);
- setProperty(ctx, QStringLiteral("shift"), method_shift, 0);
- setProperty(ctx, QStringLiteral("slice"), method_slice, 2);
- setProperty(ctx, QStringLiteral("sort"), method_sort, 1);
- setProperty(ctx, QStringLiteral("splice"), method_splice, 2);
- setProperty(ctx, QStringLiteral("unshift"), method_unshift, 1);
- setProperty(ctx, QStringLiteral("indexOf"), method_indexOf, 0);
- setProperty(ctx, QStringLiteral("lastIndexOf"), method_lastIndexOf, 0);
- setProperty(ctx, QStringLiteral("every"), method_every, 0);
- setProperty(ctx, QStringLiteral("some"), method_some, 0);
- setProperty(ctx, QStringLiteral("forEach"), method_forEach, 0);
- setProperty(ctx, QStringLiteral("map"), method_map, 0);
- setProperty(ctx, QStringLiteral("filter"), method_filter, 0);
- setProperty(ctx, QStringLiteral("reduce"), method_reduce, 0);
- setProperty(ctx, QStringLiteral("reduceRight"), method_reduceRight, 0);
+ ctor.objectValue()->__put__(ctx, ctx->engine->id_prototype, Value::fromObject(this));
+ __put__(ctx, QStringLiteral("constructor"), ctor);
+ __put__(ctx, QStringLiteral("toString"), method_toString, 0);
+ __put__(ctx, QStringLiteral("toLocalString"), method_toLocaleString, 0);
+ __put__(ctx, QStringLiteral("concat"), method_concat, 1);
+ __put__(ctx, QStringLiteral("join"), method_join, 1);
+ __put__(ctx, QStringLiteral("pop"), method_pop, 0);
+ __put__(ctx, QStringLiteral("push"), method_push, 1);
+ __put__(ctx, QStringLiteral("reverse"), method_reverse, 0);
+ __put__(ctx, QStringLiteral("shift"), method_shift, 0);
+ __put__(ctx, QStringLiteral("slice"), method_slice, 2);
+ __put__(ctx, QStringLiteral("sort"), method_sort, 1);
+ __put__(ctx, QStringLiteral("splice"), method_splice, 2);
+ __put__(ctx, QStringLiteral("unshift"), method_unshift, 1);
+ __put__(ctx, QStringLiteral("indexOf"), method_indexOf, 0);
+ __put__(ctx, QStringLiteral("lastIndexOf"), method_lastIndexOf, 0);
+ __put__(ctx, QStringLiteral("every"), method_every, 0);
+ __put__(ctx, QStringLiteral("some"), method_some, 0);
+ __put__(ctx, QStringLiteral("forEach"), method_forEach, 0);
+ __put__(ctx, QStringLiteral("map"), method_map, 0);
+ __put__(ctx, QStringLiteral("filter"), method_filter, 0);
+ __put__(ctx, QStringLiteral("reduce"), method_reduce, 0);
+ __put__(ctx, QStringLiteral("reduceRight"), method_reduceRight, 0);
}
void ArrayPrototype::method_toString(Context *ctx)
Value r1 = self.property(ctx, ctx->engine->id_length);
quint32 r2 = !r1.isUndefined() ? r1.toUInt32(ctx) : 0;
if (! r2) {
- self.objectValue()->setProperty(ctx, ctx->engine->id_length, Value::fromDouble(0));
+ self.objectValue()->__put__(ctx, ctx->engine->id_length, Value::fromDouble(0));
} else {
String *r6 = Value::fromDouble(r2 - 1).toString(ctx);
Value r7 = self.property(ctx, r6);
- self.objectValue()->deleteProperty(ctx, r6, 0);
- self.objectValue()->setProperty(ctx, ctx->engine->id_length, Value::fromDouble(2 - 1));
+ self.objectValue()->__delete__(ctx, r6, 0);
+ self.objectValue()->__put__(ctx, ctx->engine->id_length, Value::fromDouble(2 - 1));
ctx->result = r7;
}
}
for (unsigned int index = 0; index < ctx->argumentCount; ++index, ++n) {
Value r3 = ctx->argument(index);
String *name = Value::fromDouble(n).toString(ctx);
- self.objectValue()->setProperty(ctx, name, r3);
+ self.objectValue()->__put__(ctx, name, r3);
}
Value r = Value::fromDouble(n);
- self.objectValue()->setProperty(ctx, ctx->engine->id_length, r);
+ self.objectValue()->__put__(ctx, ctx->engine->id_length, r);
ctx->result = r;
}
}
void FunctionPrototype::init(Context *ctx, const Value &ctor)
{
- ctor.objectValue()->setProperty(ctx, ctx->engine->id_prototype, Value::fromObject(this));
- setProperty(ctx, QStringLiteral("constructor"), ctor);
- setProperty(ctx, QStringLiteral("toString"), method_toString, 0);
- setProperty(ctx, QStringLiteral("apply"), method_apply, 0);
- setProperty(ctx, QStringLiteral("call"), method_call, 0);
- setProperty(ctx, QStringLiteral("bind"), method_bind, 0);
+ ctor.objectValue()->__put__(ctx, ctx->engine->id_prototype, Value::fromObject(this));
+ __put__(ctx, QStringLiteral("constructor"), ctor);
+ __put__(ctx, QStringLiteral("toString"), method_toString, 0);
+ __put__(ctx, QStringLiteral("apply"), method_apply, 0);
+ __put__(ctx, QStringLiteral("call"), method_call, 0);
+ __put__(ctx, QStringLiteral("bind"), method_bind, 0);
}
void FunctionPrototype::method_toString(Context *ctx)
void DatePrototype::init(Context *ctx, const Value &ctor)
{
- ctor.objectValue()->setProperty(ctx, ctx->engine->id_prototype, Value::fromObject(this));
+ ctor.objectValue()->__put__(ctx, ctx->engine->id_prototype, Value::fromObject(this));
LocalTZA = getLocalTZA();
- ctor.objectValue()->setProperty(ctx, QStringLiteral("parse"), method_parse, 1);
- ctor.objectValue()->setProperty(ctx, QStringLiteral("UTC"), method_UTC, 7);
-
- setProperty(ctx, QStringLiteral("constructor"), ctor);
- setProperty(ctx, QStringLiteral("toString"), method_toString, 0);
- setProperty(ctx, QStringLiteral("toDateString"), method_toDateString, 0);
- setProperty(ctx, QStringLiteral("toTimeString"), method_toTimeString, 0);
- setProperty(ctx, QStringLiteral("toLocaleString"), method_toLocaleString, 0);
- setProperty(ctx, QStringLiteral("toLocaleDateString"), method_toLocaleDateString, 0);
- setProperty(ctx, QStringLiteral("toLocaleTimeString"), method_toLocaleTimeString, 0);
- setProperty(ctx, QStringLiteral("valueOf"), method_valueOf, 0);
- setProperty(ctx, QStringLiteral("getTime"), method_getTime, 0);
- setProperty(ctx, QStringLiteral("getYear"), method_getYear, 0);
- setProperty(ctx, QStringLiteral("getFullYear"), method_getFullYear, 0);
- setProperty(ctx, QStringLiteral("getUTCFullYear"), method_getUTCFullYear, 0);
- setProperty(ctx, QStringLiteral("getMonth"), method_getMonth, 0);
- setProperty(ctx, QStringLiteral("getUTCMonth"), method_getUTCMonth, 0);
- setProperty(ctx, QStringLiteral("getDate"), method_getDate, 0);
- setProperty(ctx, QStringLiteral("getUTCDate"), method_getUTCDate, 0);
- setProperty(ctx, QStringLiteral("getDay"), method_getDay, 0);
- setProperty(ctx, QStringLiteral("getUTCDay"), method_getUTCDay, 0);
- setProperty(ctx, QStringLiteral("getHours"), method_getHours, 0);
- setProperty(ctx, QStringLiteral("getUTCHours"), method_getUTCHours, 0);
- setProperty(ctx, QStringLiteral("getMinutes"), method_getMinutes, 0);
- setProperty(ctx, QStringLiteral("getUTCMinutes"), method_getUTCMinutes, 0);
- setProperty(ctx, QStringLiteral("getSeconds"), method_getSeconds, 0);
- setProperty(ctx, QStringLiteral("getUTCSeconds"), method_getUTCSeconds, 0);
- setProperty(ctx, QStringLiteral("getMilliseconds"), method_getMilliseconds, 0);
- setProperty(ctx, QStringLiteral("getUTCMilliseconds"), method_getUTCMilliseconds, 0);
- setProperty(ctx, QStringLiteral("getTimezoneOffset"), method_getTimezoneOffset, 0);
- setProperty(ctx, QStringLiteral("setTime"), method_setTime, 1);
- setProperty(ctx, QStringLiteral("setMilliseconds"), method_setMilliseconds, 1);
- setProperty(ctx, QStringLiteral("setUTCMilliseconds"), method_setUTCMilliseconds, 1);
- setProperty(ctx, QStringLiteral("setSeconds"), method_setSeconds, 2);
- setProperty(ctx, QStringLiteral("setUTCSeconds"), method_setUTCSeconds, 2);
- setProperty(ctx, QStringLiteral("setMinutes"), method_setMinutes, 3);
- setProperty(ctx, QStringLiteral("setUTCMinutes"), method_setUTCMinutes, 3);
- setProperty(ctx, QStringLiteral("setHours"), method_setHours, 4);
- setProperty(ctx, QStringLiteral("setUTCHours"), method_setUTCHours, 4);
- setProperty(ctx, QStringLiteral("setDate"), method_setDate, 1);
- setProperty(ctx, QStringLiteral("setUTCDate"), method_setUTCDate, 1);
- setProperty(ctx, QStringLiteral("setMonth"), method_setMonth, 2);
- setProperty(ctx, QStringLiteral("setUTCMonth"), method_setUTCMonth, 2);
- setProperty(ctx, QStringLiteral("setYear"), method_setYear, 1);
- setProperty(ctx, QStringLiteral("setFullYear"), method_setFullYear, 3);
- setProperty(ctx, QStringLiteral("setUTCFullYear"), method_setUTCFullYear, 3);
- setProperty(ctx, QStringLiteral("toUTCString"), method_toUTCString, 0);
- setProperty(ctx, QStringLiteral("toGMTString"), method_toUTCString, 0);
+ ctor.objectValue()->__put__(ctx, QStringLiteral("parse"), method_parse, 1);
+ ctor.objectValue()->__put__(ctx, QStringLiteral("UTC"), method_UTC, 7);
+
+ __put__(ctx, QStringLiteral("constructor"), ctor);
+ __put__(ctx, QStringLiteral("toString"), method_toString, 0);
+ __put__(ctx, QStringLiteral("toDateString"), method_toDateString, 0);
+ __put__(ctx, QStringLiteral("toTimeString"), method_toTimeString, 0);
+ __put__(ctx, QStringLiteral("toLocaleString"), method_toLocaleString, 0);
+ __put__(ctx, QStringLiteral("toLocaleDateString"), method_toLocaleDateString, 0);
+ __put__(ctx, QStringLiteral("toLocaleTimeString"), method_toLocaleTimeString, 0);
+ __put__(ctx, QStringLiteral("valueOf"), method_valueOf, 0);
+ __put__(ctx, QStringLiteral("getTime"), method_getTime, 0);
+ __put__(ctx, QStringLiteral("getYear"), method_getYear, 0);
+ __put__(ctx, QStringLiteral("getFullYear"), method_getFullYear, 0);
+ __put__(ctx, QStringLiteral("getUTCFullYear"), method_getUTCFullYear, 0);
+ __put__(ctx, QStringLiteral("getMonth"), method_getMonth, 0);
+ __put__(ctx, QStringLiteral("getUTCMonth"), method_getUTCMonth, 0);
+ __put__(ctx, QStringLiteral("getDate"), method_getDate, 0);
+ __put__(ctx, QStringLiteral("getUTCDate"), method_getUTCDate, 0);
+ __put__(ctx, QStringLiteral("getDay"), method_getDay, 0);
+ __put__(ctx, QStringLiteral("getUTCDay"), method_getUTCDay, 0);
+ __put__(ctx, QStringLiteral("getHours"), method_getHours, 0);
+ __put__(ctx, QStringLiteral("getUTCHours"), method_getUTCHours, 0);
+ __put__(ctx, QStringLiteral("getMinutes"), method_getMinutes, 0);
+ __put__(ctx, QStringLiteral("getUTCMinutes"), method_getUTCMinutes, 0);
+ __put__(ctx, QStringLiteral("getSeconds"), method_getSeconds, 0);
+ __put__(ctx, QStringLiteral("getUTCSeconds"), method_getUTCSeconds, 0);
+ __put__(ctx, QStringLiteral("getMilliseconds"), method_getMilliseconds, 0);
+ __put__(ctx, QStringLiteral("getUTCMilliseconds"), method_getUTCMilliseconds, 0);
+ __put__(ctx, QStringLiteral("getTimezoneOffset"), method_getTimezoneOffset, 0);
+ __put__(ctx, QStringLiteral("setTime"), method_setTime, 1);
+ __put__(ctx, QStringLiteral("setMilliseconds"), method_setMilliseconds, 1);
+ __put__(ctx, QStringLiteral("setUTCMilliseconds"), method_setUTCMilliseconds, 1);
+ __put__(ctx, QStringLiteral("setSeconds"), method_setSeconds, 2);
+ __put__(ctx, QStringLiteral("setUTCSeconds"), method_setUTCSeconds, 2);
+ __put__(ctx, QStringLiteral("setMinutes"), method_setMinutes, 3);
+ __put__(ctx, QStringLiteral("setUTCMinutes"), method_setUTCMinutes, 3);
+ __put__(ctx, QStringLiteral("setHours"), method_setHours, 4);
+ __put__(ctx, QStringLiteral("setUTCHours"), method_setUTCHours, 4);
+ __put__(ctx, QStringLiteral("setDate"), method_setDate, 1);
+ __put__(ctx, QStringLiteral("setUTCDate"), method_setUTCDate, 1);
+ __put__(ctx, QStringLiteral("setMonth"), method_setMonth, 2);
+ __put__(ctx, QStringLiteral("setUTCMonth"), method_setUTCMonth, 2);
+ __put__(ctx, QStringLiteral("setYear"), method_setYear, 1);
+ __put__(ctx, QStringLiteral("setFullYear"), method_setFullYear, 3);
+ __put__(ctx, QStringLiteral("setUTCFullYear"), method_setUTCFullYear, 3);
+ __put__(ctx, QStringLiteral("toUTCString"), method_toUTCString, 0);
+ __put__(ctx, QStringLiteral("toGMTString"), method_toUTCString, 0);
}
double DatePrototype::getThisDate(Context *ctx)
void RegExpPrototype::init(Context *ctx, const Value &ctor)
{
- ctor.objectValue()->setProperty(ctx, ctx->engine->id_prototype, Value::fromObject(this));
- setProperty(ctx, QStringLiteral("constructor"), ctor);
- setProperty(ctx, QStringLiteral("exec"), method_exec, 0);
- setProperty(ctx, QStringLiteral("test"), method_test, 0);
- setProperty(ctx, QStringLiteral("toString"), method_toString, 0);
+ ctor.objectValue()->__put__(ctx, ctx->engine->id_prototype, Value::fromObject(this));
+ __put__(ctx, QStringLiteral("constructor"), ctor);
+ __put__(ctx, QStringLiteral("exec"), method_exec, 0);
+ __put__(ctx, QStringLiteral("test"), method_test, 0);
+ __put__(ctx, QStringLiteral("toString"), method_toString, 0);
}
void RegExpPrototype::method_exec(Context *ctx)
for (int i = 0; i <= captured; ++i)
array->value.push(Value::fromString(ctx, match.captured(i)));
- array->setProperty(ctx, QLatin1String("index"), Value::fromInt32(match.capturedStart(0)));
- array->setProperty(ctx, QLatin1String("input"), arg);
+ array->__put__(ctx, QLatin1String("index"), Value::fromInt32(match.capturedStart(0)));
+ array->__put__(ctx, QLatin1String("input"), arg);
if (r->global)
r->lastIndex = Value::fromInt32(match.capturedEnd(0));
//
MathObject::MathObject(Context *ctx)
{
- setProperty(ctx, QStringLiteral("E"), Value::fromDouble(::exp(1.0)));
- setProperty(ctx, QStringLiteral("LN2"), Value::fromDouble(::log(2.0)));
- setProperty(ctx, QStringLiteral("LN10"), Value::fromDouble(::log(10.0)));
- setProperty(ctx, QStringLiteral("LOG2E"), Value::fromDouble(1.0/::log(2.0)));
- setProperty(ctx, QStringLiteral("LOG10E"), Value::fromDouble(1.0/::log(10.0)));
- setProperty(ctx, QStringLiteral("PI"), Value::fromDouble(qt_PI));
- setProperty(ctx, QStringLiteral("SQRT1_2"), Value::fromDouble(::sqrt(0.5)));
- setProperty(ctx, QStringLiteral("SQRT2"), Value::fromDouble(::sqrt(2.0)));
-
- setProperty(ctx, QStringLiteral("abs"), method_abs, 1);
- setProperty(ctx, QStringLiteral("acos"), method_acos, 1);
- setProperty(ctx, QStringLiteral("asin"), method_asin, 0);
- setProperty(ctx, QStringLiteral("atan"), method_atan, 1);
- setProperty(ctx, QStringLiteral("atan2"), method_atan2, 2);
- setProperty(ctx, QStringLiteral("ceil"), method_ceil, 1);
- setProperty(ctx, QStringLiteral("cos"), method_cos, 1);
- setProperty(ctx, QStringLiteral("exp"), method_exp, 1);
- setProperty(ctx, QStringLiteral("floor"), method_floor, 1);
- setProperty(ctx, QStringLiteral("log"), method_log, 1);
- setProperty(ctx, QStringLiteral("max"), method_max, 2);
- setProperty(ctx, QStringLiteral("min"), method_min, 2);
- setProperty(ctx, QStringLiteral("pow"), method_pow, 2);
- setProperty(ctx, QStringLiteral("random"), method_random, 0);
- setProperty(ctx, QStringLiteral("round"), method_round, 1);
- setProperty(ctx, QStringLiteral("sin"), method_sin, 1);
- setProperty(ctx, QStringLiteral("sqrt"), method_sqrt, 1);
- setProperty(ctx, QStringLiteral("tan"), method_tan, 1);
+ __put__(ctx, QStringLiteral("E"), Value::fromDouble(::exp(1.0)));
+ __put__(ctx, QStringLiteral("LN2"), Value::fromDouble(::log(2.0)));
+ __put__(ctx, QStringLiteral("LN10"), Value::fromDouble(::log(10.0)));
+ __put__(ctx, QStringLiteral("LOG2E"), Value::fromDouble(1.0/::log(2.0)));
+ __put__(ctx, QStringLiteral("LOG10E"), Value::fromDouble(1.0/::log(10.0)));
+ __put__(ctx, QStringLiteral("PI"), Value::fromDouble(qt_PI));
+ __put__(ctx, QStringLiteral("SQRT1_2"), Value::fromDouble(::sqrt(0.5)));
+ __put__(ctx, QStringLiteral("SQRT2"), Value::fromDouble(::sqrt(2.0)));
+
+ __put__(ctx, QStringLiteral("abs"), method_abs, 1);
+ __put__(ctx, QStringLiteral("acos"), method_acos, 1);
+ __put__(ctx, QStringLiteral("asin"), method_asin, 0);
+ __put__(ctx, QStringLiteral("atan"), method_atan, 1);
+ __put__(ctx, QStringLiteral("atan2"), method_atan2, 2);
+ __put__(ctx, QStringLiteral("ceil"), method_ceil, 1);
+ __put__(ctx, QStringLiteral("cos"), method_cos, 1);
+ __put__(ctx, QStringLiteral("exp"), method_exp, 1);
+ __put__(ctx, QStringLiteral("floor"), method_floor, 1);
+ __put__(ctx, QStringLiteral("log"), method_log, 1);
+ __put__(ctx, QStringLiteral("max"), method_max, 2);
+ __put__(ctx, QStringLiteral("min"), method_min, 2);
+ __put__(ctx, QStringLiteral("pow"), method_pow, 2);
+ __put__(ctx, QStringLiteral("random"), method_random, 0);
+ __put__(ctx, QStringLiteral("round"), method_round, 1);
+ __put__(ctx, QStringLiteral("sin"), method_sin, 1);
+ __put__(ctx, QStringLiteral("sqrt"), method_sqrt, 1);
+ __put__(ctx, QStringLiteral("tan"), method_tan, 1);
}
/* copies the sign from y to x and returns the result */