Cleanup
authorLars Knoll <lars.knoll@digia.com>
Thu, 18 Oct 2012 06:52:40 +0000 (08:52 +0200)
committerSimon Hausmann <simon.hausmann@digia.com>
Thu, 18 Oct 2012 08:33:34 +0000 (10:33 +0200)
Remove __qmljs_init_object and replace it with
Value::fromObject

Change-Id: Ibc8bd9e7ecd56c6713dc08add72e5cd35ffea78e
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
main.cpp
qmljs_objects.cpp
qmljs_runtime.cpp
qmljs_runtime.h
qv4ecmaobjects.cpp

index 5110e48..becd301 100644 (file)
--- a/main.cpp
+++ b/main.cpp
@@ -287,7 +287,7 @@ static void evaluate(QQmlJS::VM::Context *ctx, const QString &fileName, const QS
 
     ctx->hasUncaughtException = false;
     if (! ctx->activation.isObject())
-        ctx->activation = __qmljs_init_object(new QQmlJS::VM::Object());
+        ctx->activation = VM::Value::fromObject(new QQmlJS::VM::Object());
 
     foreach (const QString *local, globalCode->locals) {
         ctx->activation.objectValue()->setProperty(ctx, *local, QQmlJS::VM::Value::undefinedValue());
index 34e223a..285f164 100644 (file)
@@ -190,7 +190,7 @@ void FunctionObject::call(Context *ctx)
 
 void FunctionObject::construct(Context *ctx)
 {
-    ctx->thisObject = __qmljs_init_object(ctx->engine->newObject());
+    ctx->thisObject = Value::fromObject(ctx->engine->newObject());
     call(ctx);
 }
 
@@ -235,7 +235,7 @@ void ScriptFunction::construct(VM::Context *ctx)
     Value proto = getProperty(ctx, ctx->engine->id_prototype);
     if (proto.isObject())
         obj->prototype = proto.objectValue();
-    ctx->thisObject = __qmljs_init_object(obj);
+    ctx->thisObject = Value::fromObject(obj);
     function->code(ctx, function->codeData);
 }
 
@@ -347,8 +347,8 @@ ExecutionEngine::ExecutionEngine()
     // set up the global object
     //
     VM::Object *glo = newObject(/*rootContext*/);
-    globalObject = __qmljs_init_object(glo);
-    rootContext->activation = __qmljs_init_object(glo);
+    globalObject = Value::fromObject(glo);
+    rootContext->activation = Value::fromObject(glo);
 
     glo->setProperty(rootContext, identifier(QStringLiteral("Object")), objectCtor);
     glo->setProperty(rootContext, identifier(QStringLiteral("String")), stringCtor);
index 3c9ca10..6cbc8f6 100644 (file)
@@ -327,7 +327,7 @@ void Context::initCallContext(ExecutionEngine *e, const Value *object, FunctionO
     result = Value::undefinedValue();
 
     if (f->needsActivation)
-        activation = __qmljs_init_object(engine->newActivationObject(this));
+        activation = Value::fromObject(engine->newActivationObject(this));
     else
         activation = Value::nullValue();
 
@@ -387,12 +387,12 @@ extern "C" {
 
 Value __qmljs_init_closure(IR::Function *clos, Context *ctx)
 {
-    return __qmljs_init_object(ctx->engine->newScriptFunction(ctx, clos));
+    return Value::fromObject(ctx->engine->newScriptFunction(ctx, clos));
 }
 
 Value __qmljs_init_native_function(void (*code)(Context *), Context *ctx)
 {
-    return __qmljs_init_object(ctx->engine->newNativeFunction(ctx, code));
+    return Value::fromObject(ctx->engine->newNativeFunction(ctx, code));
 }
 
 Value __qmljs_string_literal_undefined(Context *ctx)
@@ -952,25 +952,25 @@ Value __qmljs_throw_type_error(Context *ctx)
 
 Value __qmljs_new_object(Context *ctx)
 {
-    return __qmljs_init_object(ctx->engine->newObject());
+    return Value::fromObject(ctx->engine->newObject());
 }
 
 Value __qmljs_new_boolean_object(Context *ctx, bool boolean)
 {
     Value value = Value::fromBoolean(boolean);
-    return __qmljs_init_object(ctx->engine->newBooleanObject(value));
+    return Value::fromObject(ctx->engine->newBooleanObject(value));
 }
 
 Value __qmljs_new_number_object(Context *ctx, double number)
 {
     Value value = Value::fromDouble(number);
-    return __qmljs_init_object(ctx->engine->newNumberObject(value));
+    return Value::fromObject(ctx->engine->newNumberObject(value));
 }
 
 Value __qmljs_new_string_object(Context *ctx, String *string)
 {
     Value value = Value::fromString(string);
-    return __qmljs_init_object(ctx->engine->newStringObject(value));
+    return Value::fromObject(ctx->engine->newStringObject(value));
 }
 
 void __qmljs_set_property(Context *ctx, Value object, String *name, Value value)
index 4f4d7a1..d49a217 100644 (file)
@@ -104,7 +104,6 @@ void __qmljs_builtin_throw(Value val, Context *context);
 Value __qmljs_builtin_rethrow(Context *context);
 
 // constructors
-Value __qmljs_init_object(Object *object);
 Value __qmljs_init_closure(IR::Function *clos, Context *ctx);
 Value __qmljs_init_native_function(void (*code)(Context *), Context *ctx);
 
@@ -688,13 +687,6 @@ struct Context {
 
 extern "C" {
 
-// constructors
-
-inline Value __qmljs_init_object(Object *object)
-{
-    return Value::fromObject(object);
-}
-
 // type conversion and testing
 inline Value __qmljs_to_primitive(Value value, Context *ctx, int typeHint)
 {
index c2f349b..f081f06 100644 (file)
@@ -521,12 +521,12 @@ ObjectCtor::ObjectCtor(Context *scope)
 
 void ObjectCtor::construct(Context *ctx)
 {
-    ctx->thisObject = __qmljs_init_object(ctx->engine->newObject());
+    ctx->thisObject = Value::fromObject(ctx->engine->newObject());
 }
 
 void ObjectCtor::call(Context *ctx)
 {
-    ctx->result = __qmljs_init_object(ctx->engine->newObject());
+    ctx->result = Value::fromObject(ctx->engine->newObject());
 }
 
 Value ObjectCtor::getProperty(Context *ctx, String *name, PropertyAttributes *attributes)
@@ -705,7 +705,7 @@ void StringCtor::construct(Context *ctx)
         value = Value::fromString(ctx->argument(0).toString(ctx));
     else
         value = Value::fromString(ctx, QString());
-    ctx->thisObject = __qmljs_init_object(ctx->engine->newStringObject(value));
+    ctx->thisObject = Value::fromObject(ctx->engine->newStringObject(value));
 }
 
 void StringCtor::call(Context *ctx)
@@ -1015,7 +1015,7 @@ NumberCtor::NumberCtor(Context *scope)
 void NumberCtor::construct(Context *ctx)
 {
     const double n = ctx->argument(0).toNumber(ctx);
-    ctx->thisObject = __qmljs_init_object(ctx->engine->newNumberObject(Value::fromDouble(n)));
+    ctx->thisObject = Value::fromObject(ctx->engine->newNumberObject(Value::fromDouble(n)));
 }
 
 void NumberCtor::call(Context *ctx)
@@ -1194,7 +1194,7 @@ BooleanCtor::BooleanCtor(Context *scope)
 void BooleanCtor::construct(Context *ctx)
 {
     const double n = ctx->argument(0).toBoolean(ctx);
-    ctx->thisObject = __qmljs_init_object(ctx->engine->newBooleanObject(Value::fromBoolean(n)));
+    ctx->thisObject = Value::fromObject(ctx->engine->newBooleanObject(Value::fromBoolean(n)));
 }
 
 void BooleanCtor::call(Context *ctx)
@@ -2428,12 +2428,12 @@ RegExpCtor::RegExpCtor(Context *scope)
 
 void RegExpCtor::construct(Context *ctx)
 {
-    ctx->thisObject = __qmljs_init_object(ctx->engine->newStringObject(Value::undefinedValue()));
+    ctx->thisObject = Value::fromObject(ctx->engine->newStringObject(Value::undefinedValue()));
 }
 
 void RegExpCtor::call(Context *ctx)
 {
-    ctx->result = __qmljs_init_object(ctx->engine->newRegExpObject(Value::undefinedValue()));
+    ctx->result = Value::fromObject(ctx->engine->newRegExpObject(Value::undefinedValue()));
 }
 
 void RegExpPrototype::init(Context *ctx, const Value &ctor)