Changeset 11527 in webkit for trunk/JavaScriptCore/kjs/value.h


Ignore:
Timestamp:
Dec 10, 2005, 6:06:17 PM (19 years ago)
Author:
darin
Message:

JavaScriptCore:

Rubber stamped by Maciej.

  • did long-promised KJS renaming:

ValueImp -> JSValue
ObjectImp -> JSObject
AllocatedValueImp -> JSCell

A renaming to get a class out of the way

KJS::Bindings::JSObject -> JavaJSObject

and some other "imp-reduction" renaming

*InstanceImp -> *Instance
*ProtoFuncImp -> *ProtoFunc
*PrototypeImp -> *Prototype
ArgumentsImp -> Arguments
RuntimeArrayImp -> RuntimeArray
RuntimeMethodImp -> RuntimeMethod

  • most files and functions

WebCore:

Rubber stamped by Maciej.

  • updated for KJS class renaming
  • many files and functions
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/kjs/value.h

    r11525 r11527  
    4343class ClassInfo;
    4444class ExecState;
    45 class ObjectImp;
     45class JSObject;
    4646
    4747/**
     
    5959
    6060/**
    61  * ValueImp is the base type for all primitives (Undefined, Null, Boolean,
     61 * JSValue is the base type for all primitives (Undefined, Null, Boolean,
    6262 * String, Number) and objects in ECMAScript.
    6363 *
    64  * Note: you should never inherit from ValueImp as it is for primitive types
     64 * Note: you should never inherit from JSValue as it is for primitive types
    6565 * only (all of which are provided internally by KJS). Instead, inherit from
    66  * ObjectImp.
     66 * JSObject.
    6767 */
    68 class ValueImp {
    69     friend class AllocatedValueImp; // so it can derive from this class
     68class JSValue {
     69    friend class JSCell; // so it can derive from this class
    7070    friend class ProtectedValues; // so it can call downcast()
    7171
    7272private:
    73     ValueImp();
    74     virtual ~ValueImp();
     73    JSValue();
     74    virtual ~JSValue();
    7575
    7676public:
     
    9292    bool getString(UString&) const;
    9393    UString getString() const; // null string if not a string
    94     ObjectImp *getObject(); // NULL if not an object
    95     const ObjectImp *getObject() const; // NULL if not an object
     94    JSObject *getObject(); // NULL if not an object
     95    const JSObject *getObject() const; // NULL if not an object
    9696
    9797    // Extracting integer values.
     
    9999
    100100    // Basic conversions.
    101     ValueImp *toPrimitive(ExecState *exec, Type preferredType = UnspecifiedType) const;
     101    JSValue *toPrimitive(ExecState *exec, Type preferredType = UnspecifiedType) const;
    102102    bool toBoolean(ExecState *exec) const;
    103103    double toNumber(ExecState *exec) const;
    104104    UString toString(ExecState *exec) const;
    105     ObjectImp *toObject(ExecState *exec) const;
     105    JSObject *toObject(ExecState *exec) const;
    106106
    107107    // Integer conversions.
     
    117117private:
    118118    // Implementation details.
    119     AllocatedValueImp *downcast();
    120     const AllocatedValueImp *downcast() const;
     119    JSCell *downcast();
     120    const JSCell *downcast() const;
    121121
    122122    // Give a compile time error if we try to copy one of these.
    123     ValueImp(const ValueImp&);
    124     ValueImp& operator=(const ValueImp&);
     123    JSValue(const JSValue&);
     124    JSValue& operator=(const JSValue&);
    125125};
    126126
    127 class AllocatedValueImp : public ValueImp {
     127class JSCell : public JSValue {
    128128    friend class Collector;
    129129    friend class UndefinedImp;
     
    132132    friend class NumberImp;
    133133    friend class StringImp;
    134     friend class ObjectImp;
     134    friend class JSObject;
    135135private:
    136     AllocatedValueImp();
    137     virtual ~AllocatedValueImp();
     136    JSCell();
     137    virtual ~JSCell();
    138138public:
    139139    // Querying the type.
     
    151151    bool getString(UString&) const;
    152152    UString getString() const; // null string if not a string
    153     ObjectImp *getObject(); // NULL if not an object
    154     const ObjectImp *getObject() const; // NULL if not an object
     153    JSObject *getObject(); // NULL if not an object
     154    const JSObject *getObject() const; // NULL if not an object
    155155
    156156    // Extracting integer values.
     
    158158
    159159    // Basic conversions.
    160     virtual ValueImp *toPrimitive(ExecState *exec, Type preferredType = UnspecifiedType) const = 0;
     160    virtual JSValue *toPrimitive(ExecState *exec, Type preferredType = UnspecifiedType) const = 0;
    161161    virtual bool toBoolean(ExecState *exec) const = 0;
    162162    virtual double toNumber(ExecState *exec) const = 0;
    163163    virtual UString toString(ExecState *exec) const = 0;
    164     virtual ObjectImp *toObject(ExecState *exec) const = 0;
     164    virtual JSObject *toObject(ExecState *exec) const = 0;
    165165
    166166    // Garbage collection.
     
    173173};
    174174
    175 AllocatedValueImp *jsUndefined();
    176 AllocatedValueImp *jsNull();
    177 
    178 AllocatedValueImp *jsBoolean(bool);
    179 
    180 ValueImp *jsNumber(double);
    181 ValueImp *jsNaN();
    182 
    183 AllocatedValueImp *jsString(const UString &); // returns empty string if passed null string
    184 AllocatedValueImp *jsString(const char * = ""); // returns empty string if passed 0
     175JSCell *jsUndefined();
     176JSCell *jsNull();
     177
     178JSCell *jsBoolean(bool);
     179
     180JSValue *jsNumber(double);
     181JSValue *jsNaN();
     182
     183JSCell *jsString(const UString &); // returns empty string if passed null string
     184JSCell *jsString(const char * = ""); // returns empty string if passed 0
    185185
    186186extern const double NaN;
     
    189189class ConstantValues {
    190190public:
    191     static AllocatedValueImp *undefined;
    192     static AllocatedValueImp *null;
    193     static AllocatedValueImp *jsFalse;
    194     static AllocatedValueImp *jsTrue;
     191    static JSCell *undefined;
     192    static JSCell *null;
     193    static JSCell *jsFalse;
     194    static JSCell *jsTrue;
    195195
    196196    static void initIfNeeded();
     
    198198};
    199199
    200 inline AllocatedValueImp *jsUndefined()
     200inline JSCell *jsUndefined()
    201201{
    202202    return ConstantValues::undefined;
    203203}
    204204
    205 inline AllocatedValueImp *jsNull()
     205inline JSCell *jsNull()
    206206{
    207207    return ConstantValues::null;
    208208}
    209209
    210 inline AllocatedValueImp *jsBoolean(bool b)
     210inline JSCell *jsBoolean(bool b)
    211211{
    212212    return b ? ConstantValues::jsTrue : ConstantValues::jsFalse;
    213213}
    214214
    215 inline ValueImp *jsNaN()
     215inline JSValue *jsNaN()
    216216{
    217217    return SimpleNumber::make(NaN);
    218218}
    219219
    220 inline ValueImp::ValueImp()
    221 {
    222 }
    223 
    224 inline ValueImp::~ValueImp()
    225 {
    226 }
    227 
    228 inline AllocatedValueImp::AllocatedValueImp()
     220inline JSValue::JSValue()
     221{
     222}
     223
     224inline JSValue::~JSValue()
     225{
     226}
     227
     228inline JSCell::JSCell()
    229229    : m_marked(false)
    230230{
    231231}
    232232
    233 inline AllocatedValueImp::~AllocatedValueImp()
    234 {
    235 }
    236 
    237 inline bool AllocatedValueImp::isBoolean() const
     233inline JSCell::~JSCell()
     234{
     235}
     236
     237inline bool JSCell::isBoolean() const
    238238{
    239239    return type() == BooleanType;
    240240}
    241241
    242 inline bool AllocatedValueImp::isNumber() const
     242inline bool JSCell::isNumber() const
    243243{
    244244    return type() == NumberType;
    245245}
    246246
    247 inline bool AllocatedValueImp::isString() const
     247inline bool JSCell::isString() const
    248248{
    249249    return type() == StringType;
    250250}
    251251
    252 inline bool AllocatedValueImp::isObject() const
     252inline bool JSCell::isObject() const
    253253{
    254254    return type() == ObjectType;
    255255}
    256256
    257 inline bool AllocatedValueImp::marked() const
     257inline bool JSCell::marked() const
    258258{
    259259    return m_marked;
    260260}
    261261
    262 inline void AllocatedValueImp::mark()
     262inline void JSCell::mark()
    263263{
    264264    m_marked = true;
    265265}
    266266
    267 inline AllocatedValueImp *ValueImp::downcast()
     267inline JSCell *JSValue::downcast()
    268268{
    269269    assert(!SimpleNumber::is(this));
    270     return static_cast<AllocatedValueImp *>(this);
    271 }
    272 
    273 inline const AllocatedValueImp *ValueImp::downcast() const
     270    return static_cast<JSCell *>(this);
     271}
     272
     273inline const JSCell *JSValue::downcast() const
    274274{
    275275    assert(!SimpleNumber::is(this));
    276     return static_cast<const AllocatedValueImp *>(this);
    277 }
    278 
    279 inline bool ValueImp::isUndefined() const
     276    return static_cast<const JSCell *>(this);
     277}
     278
     279inline bool JSValue::isUndefined() const
    280280{
    281281    return this == jsUndefined();
    282282}
    283283
    284 inline bool ValueImp::isNull() const
     284inline bool JSValue::isNull() const
    285285{
    286286    return this == jsNull();
    287287}
    288288
    289 inline bool ValueImp::isUndefinedOrNull() const
     289inline bool JSValue::isUndefinedOrNull() const
    290290{
    291291    return this == jsUndefined() || this == jsNull();
    292292}
    293293
    294 inline bool ValueImp::isBoolean() const
     294inline bool JSValue::isBoolean() const
    295295{
    296296    return !SimpleNumber::is(this) && downcast()->isBoolean();
    297297}
    298298
    299 inline bool ValueImp::isNumber() const
     299inline bool JSValue::isNumber() const
    300300{
    301301    return SimpleNumber::is(this) || downcast()->isNumber();
    302302}
    303303
    304 inline bool ValueImp::isString() const
     304inline bool JSValue::isString() const
    305305{
    306306    return !SimpleNumber::is(this) && downcast()->isString();
    307307}
    308308
    309 inline bool ValueImp::isObject() const
     309inline bool JSValue::isObject() const
    310310{
    311311    return !SimpleNumber::is(this) && downcast()->isObject();
    312312}
    313313
    314 inline bool ValueImp::isObject(const ClassInfo *c) const
     314inline bool JSValue::isObject(const ClassInfo *c) const
    315315{
    316316    return !SimpleNumber::is(this) && downcast()->isObject(c);
    317317}
    318318
    319 inline bool ValueImp::getBoolean(bool& v) const
     319inline bool JSValue::getBoolean(bool& v) const
    320320{
    321321    return !SimpleNumber::is(this) && downcast()->getBoolean(v);
    322322}
    323323
    324 inline bool ValueImp::getNumber(double& v) const
     324inline bool JSValue::getNumber(double& v) const
    325325{
    326326    if (SimpleNumber::is(this)) {
     
    331331}
    332332
    333 inline double ValueImp::getNumber() const
     333inline double JSValue::getNumber() const
    334334{
    335335    return SimpleNumber::is(this) ? SimpleNumber::value(this) : downcast()->getNumber();
    336336}
    337337
    338 inline bool ValueImp::getString(UString& s) const
     338inline bool JSValue::getString(UString& s) const
    339339{
    340340    return !SimpleNumber::is(this) && downcast()->getString(s);
    341341}
    342342
    343 inline UString ValueImp::getString() const
     343inline UString JSValue::getString() const
    344344{
    345345    return SimpleNumber::is(this) ? UString() : downcast()->getString();
    346346}
    347347
    348 inline ObjectImp *ValueImp::getObject()
     348inline JSObject *JSValue::getObject()
    349349{
    350350    return SimpleNumber::is(this) ? 0 : downcast()->getObject();
    351351}
    352352
    353 inline const ObjectImp *ValueImp::getObject() const
     353inline const JSObject *JSValue::getObject() const
    354354{
    355355    return SimpleNumber::is(this) ? 0 : downcast()->getObject();
    356356}
    357357
    358 inline bool ValueImp::getUInt32(uint32_t& v) const
     358inline bool JSValue::getUInt32(uint32_t& v) const
    359359{
    360360    if (SimpleNumber::is(this)) {
     
    368368}
    369369
    370 inline void ValueImp::mark()
     370inline void JSValue::mark()
    371371{
    372372    if (!SimpleNumber::is(this))
     
    374374}
    375375
    376 inline bool ValueImp::marked() const
     376inline bool JSValue::marked() const
    377377{
    378378    return SimpleNumber::is(this) || downcast()->marked();
    379379}
    380380
    381 inline Type ValueImp::type() const
     381inline Type JSValue::type() const
    382382{
    383383    return SimpleNumber::is(this) ? NumberType : downcast()->type();
    384384}
    385385
    386 inline ValueImp *ValueImp::toPrimitive(ExecState *exec, Type preferredType) const
    387 {
    388     return SimpleNumber::is(this) ? const_cast<ValueImp *>(this) : downcast()->toPrimitive(exec, preferredType);
    389 }
    390 
    391 inline bool ValueImp::toBoolean(ExecState *exec) const
     386inline JSValue *JSValue::toPrimitive(ExecState *exec, Type preferredType) const
     387{
     388    return SimpleNumber::is(this) ? const_cast<JSValue *>(this) : downcast()->toPrimitive(exec, preferredType);
     389}
     390
     391inline bool JSValue::toBoolean(ExecState *exec) const
    392392{
    393393    if (SimpleNumber::is(this)) {
     
    399399}
    400400
    401 inline double ValueImp::toNumber(ExecState *exec) const
     401inline double JSValue::toNumber(ExecState *exec) const
    402402{
    403403    return SimpleNumber::is(this) ? SimpleNumber::value(this) : downcast()->toNumber(exec);
    404404}
    405405
    406 inline UString ValueImp::toString(ExecState *exec) const
     406inline UString JSValue::toString(ExecState *exec) const
    407407{
    408408    if (SimpleNumber::is(this)) {
Note: See TracChangeset for help on using the changeset viewer.