Commit 220f6b43 authored by Roberto Raggi's avatar Roberto Raggi
Browse files

Register the `Qt' and the `console' object.

parent caedef35
......@@ -1410,6 +1410,7 @@ Engine::Engine()
_regexpCtor(0),
_globalObject(0),
_mathObject(0),
_qtObject(0),
#ifndef NO_DECLARATIVE_BACKEND
_qmlKeysObject(0),
#endif
......@@ -1566,6 +1567,11 @@ const ObjectValue *Engine::mathObject() const
return _mathObject;
}
const ObjectValue *Engine::qtObject() const
{
return _qtObject;
}
void Engine::registerValue(Value *value)
{
_registeredValues.append(value);
......@@ -1856,6 +1862,40 @@ void Engine::initializePrototypes()
_globalObject->setProperty("Number", numberCtor());
_globalObject->setProperty("Date", dateCtor());
_globalObject->setProperty("RegExp", regexpCtor());
//types
_qtObject = newObject(/*prototype */ 0);
addFunction(_qtObject, QLatin1String("rgba"), 4);
addFunction(_qtObject, QLatin1String("hsla"), 4);
addFunction(_qtObject, QLatin1String("rect"), 4);
addFunction(_qtObject, QLatin1String("point"), 2);
addFunction(_qtObject, QLatin1String("size"), 2);
addFunction(_qtObject, QLatin1String("vector3d"), 3);
//color helpers
addFunction(_qtObject, QLatin1String("lighter"), 1);
addFunction(_qtObject, QLatin1String("darker"), 1);
addFunction(_qtObject, QLatin1String("tint"), 2);
//misc methods
addFunction(_qtObject, QLatin1String("closestAngle"), 2);
addFunction(_qtObject, QLatin1String("playSound"), 1);
addFunction(_qtObject, QLatin1String("openUrlExternally"), 1);
addFunction(_qtObject, QLatin1String("md5"), 1);
addFunction(_qtObject, QLatin1String("btoa"), 1);
addFunction(_qtObject, QLatin1String("atob"), 1);
addFunction(_qtObject, QLatin1String("quit"), 0);
addFunction(_qtObject, QLatin1String("resolvedUrl"), 1);
//firebug/webkit compat
ObjectValue *consoleObject = newObject(/*prototype */ 0);
addFunction(consoleObject, QLatin1String("log"), 1);
addFunction(consoleObject, QLatin1String("debug"), 1);
_globalObject->setProperty(QLatin1String("console"), consoleObject);
_globalObject->setProperty(QLatin1String("Qt"), _qtObject);
}
const ObjectValue *Engine::qmlKeysObject()
......
......@@ -547,6 +547,7 @@ public:
// global object
ObjectValue *globalObject() const;
const ObjectValue *mathObject() const;
const ObjectValue *qtObject() const;
// prototypes
ObjectValue *objectPrototype() const;
......@@ -608,6 +609,7 @@ private:
ObjectValue *_globalObject;
ObjectValue *_mathObject;
ObjectValue *_qtObject;
#ifndef NO_DECLARATIVE_BACKEND
ObjectValue *_qmlKeysObject;
#endif
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment