Changeset 35022 in webkit for trunk/JavaScriptCore/kjs/JSArray.h


Ignore:
Timestamp:
Jul 5, 2008, 10:26:58 PM (17 years ago)
Author:
[email protected]
Message:

2008-07-05 Sam Weinig <[email protected]>

Reviewed by Cameron Zwarich.

First step in broad cleanup effort.

[ File list elided ]

File:
1 edited

Legend:

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

    r34964 r35022  
    2727namespace KJS {
    2828
    29   typedef HashMap<unsigned, JSValue*> SparseArrayValueMap;
     29    typedef HashMap<unsigned, JSValue*> SparseArrayValueMap;
    3030
    31   struct ArrayStorage {
    32       unsigned m_vectorLength;
    33       unsigned m_numValuesInVector;
    34       SparseArrayValueMap* m_sparseValueMap;
    35       void* lazyCreationData; // A JSArray subclass can use this to fill the vector lazily.
    36       JSValue* m_vector[1];
    37   };
     31    struct ArrayStorage {
     32        unsigned m_vectorLength;
     33        unsigned m_numValuesInVector;
     34        SparseArrayValueMap* m_sparseValueMap;
     35        void* lazyCreationData; // A JSArray subclass can use this to fill the vector lazily.
     36        JSValue* m_vector[1];
     37    };
    3838
    39   class JSArray : public JSObject {
    40   public:
    41     JSArray(JSValue* prototype, unsigned initialLength);
    42     JSArray(JSObject* prototype, const ArgList& initialValues);
    43     virtual ~JSArray();
     39    class JSArray : public JSObject {
     40    public:
     41        JSArray(JSValue* prototype, unsigned initialLength);
     42        JSArray(JSObject* prototype, const ArgList& initialValues);
     43        virtual ~JSArray();
    4444
    45     virtual bool getOwnPropertySlot(ExecState*, const Identifier& propertyName, PropertySlot&);
    46     virtual bool getOwnPropertySlot(ExecState*, unsigned propertyName, PropertySlot&);
    47     virtual void put(ExecState*, unsigned propertyName, JSValue*); // FIXME: Make protected and add setItem.
     45        virtual bool getOwnPropertySlot(ExecState*, const Identifier& propertyName, PropertySlot&);
     46        virtual bool getOwnPropertySlot(ExecState*, unsigned propertyName, PropertySlot&);
     47        virtual void put(ExecState*, unsigned propertyName, JSValue*); // FIXME: Make protected and add setItem.
    4848
    49     static const ClassInfo info;
     49        static const ClassInfo info;
    5050
    51     unsigned getLength() const { return m_length; }
    52     void setLength(unsigned); // OK to use on new arrays, but not if it might be a RegExpMatchArray.
     51        unsigned getLength() const { return m_length; }
     52        void setLength(unsigned); // OK to use on new arrays, but not if it might be a RegExpMatchArray.
    5353
    54     void sort(ExecState*);
    55     void sort(ExecState*, JSValue* compareFunction, CallType, const CallData&);
     54        void sort(ExecState*);
     55        void sort(ExecState*, JSValue* compareFunction, CallType, const CallData&);
    5656
    57     bool canGetIndex(unsigned i) { return i < m_fastAccessCutoff; }
    58     JSValue* getIndex(unsigned i)
    59     {
    60         ASSERT(canGetIndex(i));
    61         return m_storage->m_vector[i];
    62     }
     57        bool canGetIndex(unsigned i) { return i < m_fastAccessCutoff; }
     58        JSValue* getIndex(unsigned i)
     59        {
     60            ASSERT(canGetIndex(i));
     61            return m_storage->m_vector[i];
     62        }
    6363
    64     bool canSetIndex(unsigned i) { return i < m_fastAccessCutoff; }
    65     JSValue* setIndex(unsigned i, JSValue* v)
    66     {
    67         ASSERT(canSetIndex(i));
    68         return m_storage->m_vector[i] = v;
    69     }
     64        bool canSetIndex(unsigned i) { return i < m_fastAccessCutoff; }
     65        JSValue* setIndex(unsigned i, JSValue* v)
     66        {
     67            ASSERT(canSetIndex(i));
     68            return m_storage->m_vector[i] = v;
     69        }
    7070
    71   protected:
    72     virtual void put(ExecState*, const Identifier& propertyName, JSValue*);
    73     virtual bool deleteProperty(ExecState*, const Identifier& propertyName);
    74     virtual bool deleteProperty(ExecState*, unsigned propertyName);
    75     virtual void getPropertyNames(ExecState*, PropertyNameArray&);
    76     virtual void mark();
     71    protected:
     72        virtual void put(ExecState*, const Identifier& propertyName, JSValue*);
     73        virtual bool deleteProperty(ExecState*, const Identifier& propertyName);
     74        virtual bool deleteProperty(ExecState*, unsigned propertyName);
     75        virtual void getPropertyNames(ExecState*, PropertyNameArray&);
     76        virtual void mark();
    7777
    78     void* lazyCreationData();
    79     void setLazyCreationData(void*);
     78        void* lazyCreationData();
     79        void setLazyCreationData(void*);
    8080
    81   private:
    82     virtual const ClassInfo* classInfo() const { return &info; }
     81    private:
     82        virtual const ClassInfo* classInfo() const { return &info; }
    8383
    84     static JSValue* lengthGetter(ExecState*, const Identifier&, const PropertySlot&);
     84        static JSValue* lengthGetter(ExecState*, const Identifier&, const PropertySlot&);
    8585
    86     bool getOwnPropertySlotSlowCase(ExecState*, unsigned propertyName, PropertySlot&);
    87     void putSlowCase(ExecState*, unsigned propertyName, JSValue*);
     86        bool getOwnPropertySlotSlowCase(ExecState*, unsigned propertyName, PropertySlot&);
     87        void putSlowCase(ExecState*, unsigned propertyName, JSValue*);
    8888
    89     bool increaseVectorLength(unsigned newLength);
    90    
    91     unsigned compactForSorting();
     89        bool increaseVectorLength(unsigned newLength);
     90       
     91        unsigned compactForSorting();
    9292
    93     enum ConsistencyCheckType { NormalConsistencyCheck, DestructorConsistencyCheck, SortConsistencyCheck };
    94     void checkConsistency(ConsistencyCheckType = NormalConsistencyCheck);
     93        enum ConsistencyCheckType { NormalConsistencyCheck, DestructorConsistencyCheck, SortConsistencyCheck };
     94        void checkConsistency(ConsistencyCheckType = NormalConsistencyCheck);
    9595
    96     unsigned m_length;
    97     unsigned m_fastAccessCutoff;
    98     ArrayStorage* m_storage;
    99   };
     96        unsigned m_length;
     97        unsigned m_fastAccessCutoff;
     98        ArrayStorage* m_storage;
     99    };
    100100
    101   JSArray* constructEmptyArray(ExecState*);
    102   JSArray* constructEmptyArray(ExecState*, unsigned initialLength);
    103   JSArray* constructArray(ExecState*, JSValue* singleItemValue);
    104   JSArray* constructArray(ExecState*, const ArgList& values);
     101    JSArray* constructEmptyArray(ExecState*);
     102    JSArray* constructEmptyArray(ExecState*, unsigned initialLength);
     103    JSArray* constructArray(ExecState*, JSValue* singleItemValue);
     104    JSArray* constructArray(ExecState*, const ArgList& values);
    105105
    106106} // namespace KJS
    107107
    108 #endif
     108#endif // JSArray_h
Note: See TracChangeset for help on using the changeset viewer.