From: Lars Knoll Date: Tue, 11 Dec 2012 19:27:17 +0000 (+0100) Subject: Implement Object.defineProperties and fix Object.create X-Git-Tag: upstream/5.2.1~669^2~659^2~723 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=7dba11b7031c4be9338d98e38c80f0573acc47fd;p=platform%2Fupstream%2Fqtdeclarative.git Implement Object.defineProperties and fix Object.create Change-Id: I5a55b8d9b3c8e34018defcbe8ee97bde43a714c6 Reviewed-by: Simon Hausmann --- diff --git a/qv4ecmaobjects.cpp b/qv4ecmaobjects.cpp index b7d2e88..64c56bb 100644 --- a/qv4ecmaobjects.cpp +++ b/qv4ecmaobjects.cpp @@ -618,8 +618,10 @@ Value ObjectPrototype::method_create(ExecutionContext *ctx) newObject->prototype = O.objectValue(); Value objValue = Value::fromObject(newObject); - ctx->arguments[0] = objValue; - method_defineProperties(ctx); + if (ctx->argumentCount > 1) { + ctx->arguments[0] = objValue; + method_defineProperties(ctx); + } return objValue; } @@ -650,8 +652,22 @@ Value ObjectPrototype::method_defineProperties(ExecutionContext *ctx) if (!O.isObject()) ctx->throwTypeError(); - ctx->throwUnimplemented(QStringLiteral("Object.defineProperties")); - return Value::undefinedValue(); + Object *o = ctx->argument(1).toObject(ctx).objectValue(); + + if (o->members) { + PropertyTable::iterator it = o->members->begin(); + while (it != o->members->end()) { + if ((*it)->descriptor.isEnumerable()) { + String *name = (*it)->name; + PropertyDescriptor pd; + toPropertyDescriptor(ctx, o->__get__(ctx, name), &pd); + O.objectValue()->__defineOwnProperty__(ctx, name, &pd); + } + ++it; + } + } + + return O; } Value ObjectPrototype::method_seal(ExecutionContext *ctx)