Commit 2abbd43a authored by weinig's avatar weinig

Reviewed by Darin

        Patch for http://bugs.webkit.org/show_bug.cgi?id=13855
        Port patch 666176 to JavaScriptCore

        - Renamed JSValue::downcast() to JSValue::asCell() which makes the
        function meaning cleaner. It's modeled after Harri Porten change in 
        KDE trunk.

        * kjs/collector.cpp:
        (KJS::Collector::protect):
        (KJS::Collector::unprotect):
        (KJS::Collector::collectOnMainThreadOnly):
        * kjs/object.h:
        (KJS::JSValue::isObject):
        * kjs/string_object.cpp:
        (KJS::StringProtoFunc::callAsFunction):
        * kjs/value.h:
        (KJS::JSValue::asCell):
        (KJS::JSValue::isNumber):
        (KJS::JSValue::isString):
        (KJS::JSValue::isObject):
        (KJS::JSValue::getNumber):
        (KJS::JSValue::getString):
        (KJS::JSValue::getObject):
        (KJS::JSValue::getUInt32):
        (KJS::JSValue::mark):
        (KJS::JSValue::marked):
        (KJS::JSValue::type):
        (KJS::JSValue::toPrimitive):
        (KJS::JSValue::toBoolean):
        (KJS::JSValue::toNumber):
        (KJS::JSValue::toString):
        (KJS::JSValue::toObject):



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@21736 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent ce6ad918
2007-05-24 Luciano Montanaro <mikelima@cirulla.net>
Reviewed by Darin
Patch for http://bugs.webkit.org/show_bug.cgi?id=13855
Port patch 666176 to JavaScriptCore
- Renamed JSValue::downcast() to JSValue::asCell() which makes the
function meaning cleaner. It's modeled after Harri Porten change in
KDE trunk.
* kjs/collector.cpp:
(KJS::Collector::protect):
(KJS::Collector::unprotect):
(KJS::Collector::collectOnMainThreadOnly):
* kjs/object.h:
(KJS::JSValue::isObject):
* kjs/string_object.cpp:
(KJS::StringProtoFunc::callAsFunction):
* kjs/value.h:
(KJS::JSValue::asCell):
(KJS::JSValue::isNumber):
(KJS::JSValue::isString):
(KJS::JSValue::isObject):
(KJS::JSValue::getNumber):
(KJS::JSValue::getString):
(KJS::JSValue::getObject):
(KJS::JSValue::getUInt32):
(KJS::JSValue::mark):
(KJS::JSValue::marked):
(KJS::JSValue::type):
(KJS::JSValue::toPrimitive):
(KJS::JSValue::toBoolean):
(KJS::JSValue::toNumber):
(KJS::JSValue::toString):
(KJS::JSValue::toObject):
2007-05-18 Holger Hans Peter Freyther <zecke@selfish.org>
Reviewed by Mark Rowe.
......
......@@ -630,7 +630,7 @@ void Collector::protect(JSValue *k)
if (JSImmediate::isImmediate(k))
return;
protectedValues().add(k->downcast());
protectedValues().add(k->asCell());
}
void Collector::unprotect(JSValue *k)
......@@ -642,7 +642,7 @@ void Collector::unprotect(JSValue *k)
if (JSImmediate::isImmediate(k))
return;
protectedValues().remove(k->downcast());
protectedValues().remove(k->asCell());
}
void Collector::collectOnMainThreadOnly(JSValue* value)
......@@ -654,7 +654,7 @@ void Collector::collectOnMainThreadOnly(JSValue* value)
if (JSImmediate::isImmediate(value))
return;
JSCell* cell = value->downcast();
JSCell* cell = value->asCell();
cellBlock(cell)->collectOnMainThreadOnly.set(cellOffset(cell));
++mainThreadOnlyObjectCount;
}
......
......@@ -542,7 +542,7 @@ inline bool JSCell::isObject(const ClassInfo *info) const
// this method is here to be after the inline declaration of JSCell::isObject
inline bool JSValue::isObject(const ClassInfo *c) const
{
return !JSImmediate::isImmediate(this) && downcast()->isObject(c);
return !JSImmediate::isImmediate(this) && asCell()->isObject(c);
}
// It may seem crazy to inline a function this large but it makes a big difference
......
......@@ -551,7 +551,7 @@ JSValue* StringProtoFunc::callAsFunction(ExecState* exec, JSObject* thisObj, con
// if there are no matches at all, it's important to return
// Null instead of an empty array, because this matches
// other browsers and because Null is a false value.
result = jsNull();
result = jsNull();
} else {
result = exec->lexicalInterpreter()->builtinArray()->construct(exec, list);
}
......
......@@ -56,7 +56,7 @@ struct ClassInfo;
*/
class JSValue {
friend class JSCell; // so it can derive from this class
friend class Collector; // so it can call downcast()
friend class Collector; // so it can call asCell()
private:
JSValue();
......@@ -108,8 +108,8 @@ public:
private:
// Implementation details.
JSCell *downcast();
const JSCell *downcast() const;
JSCell *asCell();
const JSCell *asCell() const;
// Give a compile time error if we try to copy one of these.
JSValue(const JSValue&);
......@@ -233,13 +233,13 @@ inline void JSCell::mark()
return Collector::markCell(this);
}
inline JSCell *JSValue::downcast()
inline JSCell *JSValue::asCell()
{
ASSERT(!JSImmediate::isImmediate(this));
return static_cast<JSCell *>(this);
}
inline const JSCell *JSValue::downcast() const
inline const JSCell *JSValue::asCell() const
{
ASSERT(!JSImmediate::isImmediate(this));
return static_cast<const JSCell *>(this);
......@@ -267,17 +267,17 @@ inline bool JSValue::isBoolean() const
inline bool JSValue::isNumber() const
{
return JSImmediate::isNumber(this) || !JSImmediate::isImmediate(this) && downcast()->isNumber();
return JSImmediate::isNumber(this) || !JSImmediate::isImmediate(this) && asCell()->isNumber();
}
inline bool JSValue::isString() const
{
return !JSImmediate::isImmediate(this) && downcast()->isString();
return !JSImmediate::isImmediate(this) && asCell()->isString();
}
inline bool JSValue::isObject() const
{
return !JSImmediate::isImmediate(this) && downcast()->isObject();
return !JSImmediate::isImmediate(this) && asCell()->isObject();
}
inline bool JSValue::getBoolean(bool& v) const
......@@ -301,32 +301,32 @@ inline bool JSValue::getNumber(double& v) const
v = JSImmediate::toDouble(this);
return true;
}
return downcast()->getNumber(v);
return asCell()->getNumber(v);
}
inline double JSValue::getNumber() const
{
return JSImmediate::isImmediate(this) ? JSImmediate::toDouble(this) : downcast()->getNumber();
return JSImmediate::isImmediate(this) ? JSImmediate::toDouble(this) : asCell()->getNumber();
}
inline bool JSValue::getString(UString& s) const
{
return !JSImmediate::isImmediate(this) && downcast()->getString(s);
return !JSImmediate::isImmediate(this) && asCell()->getString(s);
}
inline UString JSValue::getString() const
{
return JSImmediate::isImmediate(this) ? UString() : downcast()->getString();
return JSImmediate::isImmediate(this) ? UString() : asCell()->getString();
}
inline JSObject *JSValue::getObject()
{
return JSImmediate::isImmediate(this) ? 0 : downcast()->getObject();
return JSImmediate::isImmediate(this) ? 0 : asCell()->getObject();
}
inline const JSObject *JSValue::getObject() const
{
return JSImmediate::isImmediate(this) ? 0 : downcast()->getObject();
return JSImmediate::isImmediate(this) ? 0 : asCell()->getObject();
}
inline bool JSValue::getUInt32(uint32_t& v) const
......@@ -338,48 +338,48 @@ inline bool JSValue::getUInt32(uint32_t& v) const
v = static_cast<uint32_t>(d);
return JSImmediate::isNumber(this);
}
return downcast()->getUInt32(v);
return asCell()->getUInt32(v);
}
inline void JSValue::mark()
{
ASSERT(!JSImmediate::isImmediate(this)); // callers should check !marked() before calling mark()
downcast()->mark();
asCell()->mark();
}
inline bool JSValue::marked() const
{
return JSImmediate::isImmediate(this) || downcast()->marked();
return JSImmediate::isImmediate(this) || asCell()->marked();
}
inline JSType JSValue::type() const
{
return JSImmediate::isImmediate(this) ? JSImmediate::type(this) : downcast()->type();
return JSImmediate::isImmediate(this) ? JSImmediate::type(this) : asCell()->type();
}
inline JSValue *JSValue::toPrimitive(ExecState *exec, JSType preferredType) const
{
return JSImmediate::isImmediate(this) ? const_cast<JSValue *>(this) : downcast()->toPrimitive(exec, preferredType);
return JSImmediate::isImmediate(this) ? const_cast<JSValue *>(this) : asCell()->toPrimitive(exec, preferredType);
}
inline bool JSValue::toBoolean(ExecState *exec) const
{
return JSImmediate::isImmediate(this) ? JSImmediate::toBoolean(this) : downcast()->toBoolean(exec);
return JSImmediate::isImmediate(this) ? JSImmediate::toBoolean(this) : asCell()->toBoolean(exec);
}
inline double JSValue::toNumber(ExecState *exec) const
{
return JSImmediate::isImmediate(this) ? JSImmediate::toDouble(this) : downcast()->toNumber(exec);
return JSImmediate::isImmediate(this) ? JSImmediate::toDouble(this) : asCell()->toNumber(exec);
}
inline UString JSValue::toString(ExecState *exec) const
{
return JSImmediate::isImmediate(this) ? JSImmediate::toString(this) : downcast()->toString(exec);
return JSImmediate::isImmediate(this) ? JSImmediate::toString(this) : asCell()->toString(exec);
}
inline JSObject* JSValue::toObject(ExecState* exec) const
{
return JSImmediate::isImmediate(this) ? JSImmediate::toObject(this, exec) : downcast()->toObject(exec);
return JSImmediate::isImmediate(this) ? JSImmediate::toObject(this, exec) : asCell()->toObject(exec);
}
} // namespace
......
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