Changeset 16711 in webkit for trunk/JavaScriptCore/kjs


Ignore:
Timestamp:
Oct 2, 2006, 3:26:58 AM (19 years ago)
Author:
eseidel
Message:

2006-10-02 Nikolas Zimmermann <[email protected]>

Reviewed by eseidel & mjs. Landed by eseidel.

Fix Qt/Linux build with older gcc 3.3.4.
http://bugs.webkit.org/show_bug.cgi?id=11116

As discussed with Maciej, the GCC_ROOT_NS_HACK
can be completely removed, as well as the friendship
between cacheGlobalObject & the JS* objects.

  • bindings/scripts/CodeGeneratorJS.pm: Remove friendship.
  • platform/image-decoders/png/pnggccrd.c: Fix comments for gcc3. (png_read_filter_row_mmx_avg):
  • platform/image-decoders/png/pngvcrd.c: Ditto. (png_mmx_support): (png_read_filter_row_mmx_avg):
File:
1 edited

Legend:

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

    r15321 r16711  
    4242     * s is the key (e.g. a property name)
    4343     */
    44     const char *s;
     44    const char* s;
    4545
    4646    /**
     
    6060     * next is the pointer to the next entry for the same hash value
    6161     */
    62     const HashEntry *next;
     62    const HashEntry* next;
    6363  };
    6464
     
    8989     * Mind that some entries in the array are null (0,0,0,0).
    9090     */
    91     const HashEntry *entries;
     91    const HashEntry* entries;
    9292    /**
    9393     * the maximum value for the hash. Always smaller than size.
     
    104104     * Find an entry in the table, and return its value (i.e. the value field of HashEntry)
    105105     */
    106     static int find(const struct HashTable *table, const Identifier &s);
    107     static int find(const struct HashTable *table,
    108                     const UChar *c, unsigned int len);
     106    static int find(const struct HashTable*, const Identifier&);
     107    static int find(const struct HashTable*, const UChar*, unsigned int len);
    109108
    110109
     
    114113     * especially the attr field.
    115114     */
    116     static const HashEntry* findEntry(const struct HashTable *table,
    117                                       const Identifier &s);
     115    static const HashEntry* findEntry(const struct HashTable*, const Identifier&);
    118116
    119117  };
     
    126124   */
    127125  template <class FuncImp>
    128   inline JSValue *staticFunctionGetter(ExecState* exec, JSObject*, const Identifier& propertyName, const PropertySlot& slot)
     126  inline JSValue* staticFunctionGetter(ExecState* exec, JSObject*, const Identifier& propertyName, const PropertySlot& slot)
    129127  {
    130128      // Look for cached value in dynamic map of properties (in JSObject)
    131       JSObject *thisObj = slot.slotBase();
    132       JSValue *cachedVal = thisObj->getDirect(propertyName);
     129      JSObject* thisObj = slot.slotBase();
     130      JSValue* cachedVal = thisObj->getDirect(propertyName);
    133131      if (cachedVal)
    134132        return cachedVal;
    135133
    136       const HashEntry *entry = slot.staticEntry();
    137       JSValue *val = new FuncImp(exec, entry->value, entry->params, propertyName);
     134      const HashEntry* entry = slot.staticEntry();
     135      JSValue* val = new FuncImp(exec, entry->value, entry->params, propertyName);
    138136      thisObj->putDirect(propertyName, val, entry->attr);
    139137      return val;
     
    145143   */
    146144  template <class ThisImp>
    147   inline JSValue *staticValueGetter(ExecState* exec, JSObject*, const Identifier&, const PropertySlot& slot)
     145  inline JSValue* staticValueGetter(ExecState* exec, JSObject*, const Identifier&, const PropertySlot& slot)
    148146  {
    149147      ThisImp* thisObj = static_cast<ThisImp*>(slot.slotBase());
     
    173171   */
    174172  template <class FuncImp, class ThisImp, class ParentImp>
    175   inline bool getStaticPropertySlot(ExecState *exec, const HashTable* table,
     173  inline bool getStaticPropertySlot(ExecState* exec, const HashTable* table,
    176174                                    ThisImp* thisObj, const Identifier& propertyName, PropertySlot& slot)
    177175  {
     
    195193   */
    196194  template <class FuncImp, class ParentImp>
    197   inline bool getStaticFunctionSlot(ExecState *exec, const HashTable *table,
     195  inline bool getStaticFunctionSlot(ExecState* exec, const HashTable* table,
    198196                                    JSObject* thisObj, const Identifier& propertyName, PropertySlot& slot)
    199197  {
     
    201199
    202200    if (!entry) // not found, forward to parent
    203       return static_cast<ParentImp *>(thisObj)->ParentImp::getOwnPropertySlot(exec, propertyName, slot);
     201      return static_cast<ParentImp*>(thisObj)->ParentImp::getOwnPropertySlot(exec, propertyName, slot);
    204202
    205203    assert(entry->attr & Function);
     
    214212   */
    215213  template <class ThisImp, class ParentImp>
    216   inline bool getStaticValueSlot(ExecState *exec, const HashTable* table,
    217                                  ThisImp* thisObj, const Identifier &propertyName, PropertySlot& slot)
     214  inline bool getStaticValueSlot(ExecState* exec, const HashTable* table,
     215                                 ThisImp* thisObj, const Identifier& propertyName, PropertySlot& slot)
    218216  {
    219217    const HashEntry* entry = Lookup::findEntry(table, propertyName);
     
    234232   */
    235233  template <class ThisImp>
    236   inline bool lookupPut(ExecState* exec, const Identifier &propertyName,
     234  inline bool lookupPut(ExecState* exec, const Identifier& propertyName,
    237235                        JSValue* value, int attr,
    238236                        const HashTable* table, ThisImp* thisObj)
     
    264262   */
    265263  template <class ThisImp, class ParentImp>
    266   inline void lookupPut(ExecState* exec, const Identifier &propertyName,
     264  inline void lookupPut(ExecState* exec, const Identifier& propertyName,
    267265                        JSValue* value, int attr,
    268266                        const HashTable* table, ThisImp* thisObj)
     
    272270  }
    273271
     272  /**
     273   * This template method retrieves or create an object that is unique
     274   * (for a given interpreter) The first time this is called (for a given
     275   * property name), the Object will be constructed, and set as a property
     276   * of the interpreter's global object. Later calls will simply retrieve
     277   * that cached object. Note that the object constructor must take 1 argument, exec.
     278   */
     279  template <class ClassCtor>
     280  inline JSObject* cacheGlobalObject(ExecState* exec, const Identifier& propertyName)
     281  {
     282    JSObject* globalObject = static_cast<JSObject*>(exec->lexicalInterpreter()->globalObject());
     283    JSValue* obj = globalObject->getDirect(propertyName);
     284    if (obj) {
     285      assert(obj->isObject());
     286      return static_cast<JSObject* >(obj);
     287    }
     288    JSObject* newObject = new ClassCtor(exec);
     289    globalObject->put(exec, propertyName, newObject, Internal | DontEnum);
     290    return newObject;
     291  }
     292
    274293} // namespace
    275 
    276 /*
    277  * The template method below can't be in the KJS namespace because it's used in
    278  * KJS_DEFINE_PROPERTY which can be used outside of the KJS namespace. It can be moved back
    279  * when a gcc with http://gcc.gnu.org/bugzilla/show_bug.cgi?id=8355 is mainstream enough.
    280  */
    281  
    282 /**
    283  * This template method retrieves or create an object that is unique
    284  * (for a given interpreter) The first time this is called (for a given
    285  * property name), the Object will be constructed, and set as a property
    286  * of the interpreter's global object. Later calls will simply retrieve
    287  * that cached object. Note that the object constructor must take 1 argument, exec.
    288  */
    289 template <class ClassCtor>
    290 inline KJS::JSObject *cacheGlobalObject(KJS::ExecState *exec, const KJS::Identifier &propertyName)
    291 {
    292   KJS::JSObject *globalObject = static_cast<KJS::JSObject *>(exec->lexicalInterpreter()->globalObject());
    293   KJS::JSValue *obj = globalObject->getDirect(propertyName);
    294   if (obj) {
    295     assert(obj->isObject());
    296     return static_cast<KJS::JSObject *>(obj);
    297   }
    298   KJS::JSObject *newObject = new ClassCtor(exec);
    299   globalObject->put(exec, propertyName, newObject, KJS::Internal | KJS::DontEnum);
    300   return newObject;
    301 }
    302294
    303295/**
     
    318310 */
    319311
    320 // Work around a bug in GCC 4.1
    321 #if !COMPILER(GCC)
    322 #define KJS_GCC_ROOT_NS_HACK ::
    323 #else
    324 #define KJS_GCC_ROOT_NS_HACK
    325 #endif
    326 
    327312// These macros assume that a prototype's only properties are functions
    328313#define KJS_DEFINE_PROTOTYPE(ClassProto) \
    329314  class ClassProto : public KJS::JSObject { \
    330   friend KJS::JSObject *KJS_GCC_ROOT_NS_HACK cacheGlobalObject<ClassProto>(KJS::ExecState *exec, const KJS::Identifier &propertyName); \
    331315  public: \
    332     static KJS::JSObject *self(KJS::ExecState *exec); \
    333     virtual const KJS::ClassInfo *classInfo() const { return &info; } \
     316    static KJS::JSObject* self(KJS::ExecState* exec); \
     317    virtual const KJS::ClassInfo* classInfo() const { return &info; } \
    334318    static const KJS::ClassInfo info; \
    335     bool getOwnPropertySlot(KJS::ExecState *, const KJS::Identifier&, KJS::PropertySlot&); \
    336   protected: \
    337     ClassProto(KJS::ExecState *exec) \
     319    bool getOwnPropertySlot(KJS::ExecState* , const KJS::Identifier&, KJS::PropertySlot&); \
     320    ClassProto(KJS::ExecState* exec) \
    338321      : KJS::JSObject(exec->lexicalInterpreter()->builtinObjectPrototype()) { } \
    339322    \
     
    342325#define KJS_DEFINE_PROTOTYPE_WITH_PROTOTYPE(ClassProto, ClassProtoProto) \
    343326    class ClassProto : public KJS::JSObject { \
    344         friend KJS::JSObject* KJS_GCC_ROOT_NS_HACK cacheGlobalObject<ClassProto>(KJS::ExecState* exec, const KJS::Identifier& propertyName); \
    345327    public: \
    346328        static KJS::JSObject* self(KJS::ExecState* exec); \
     
    348330        static const KJS::ClassInfo info; \
    349331        bool getOwnPropertySlot(KJS::ExecState*, const KJS::Identifier&, KJS::PropertySlot&); \
    350     protected: \
    351332        ClassProto(KJS::ExecState* exec) \
    352333            : KJS::JSObject(ClassProtoProto::self(exec)) { } \
     
    356337#define KJS_IMPLEMENT_PROTOTYPE(ClassName, ClassProto, ClassFunc) \
    357338    const ClassInfo ClassProto::info = { ClassName, 0, &ClassProto##Table, 0 }; \
    358     JSObject *ClassProto::self(ExecState *exec) \
     339    JSObject* ClassProto::self(ExecState* exec) \
    359340    { \
    360         return ::cacheGlobalObject<ClassProto>(exec, "[[" ClassName ".prototype]]"); \
     341        return KJS::cacheGlobalObject<ClassProto>(exec, "[[" ClassName ".prototype]]"); \
    361342    } \
    362     bool ClassProto::getOwnPropertySlot(ExecState *exec, const Identifier& propertyName, PropertySlot& slot) \
     343    bool ClassProto::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot) \
    363344    { \
    364345      return getStaticFunctionSlot<ClassFunc, JSObject>(exec, &ClassProto##Table, this, propertyName, slot); \
     
    375356    } \
    376357    /* Macro user needs to implement the callAsFunction function. */ \
    377     virtual JSValue *callAsFunction(ExecState *exec, JSObject *thisObj, const List &args); \
     358    virtual JSValue* callAsFunction(ExecState* exec, JSObject* thisObj, const List& args); \
    378359  private: \
    379360    int id; \
    380361  };
    381362
    382 /*
    383  * List of things to do when porting an objectimp to the 'static hashtable' mechanism:
    384  * - write the hashtable source, between @begin and @end
    385  * - add a rule to build the .lut.h
    386  * - include the .lut.h
    387  * - mention the table in the classinfo (add a classinfo if necessary)
    388  * - write/update the class enum (for the tokens)
    389  * - turn get() into getValueProperty(), put() into putValueProperty(), using a switch and removing funcs
    390  * - write get() and/or put() using a template method
    391  * - cleanup old stuff (e.g. hasProperty)
    392  * - compile, test, commit ;)
    393  */
    394 
    395 
    396363#endif
Note: See TracChangeset for help on using the changeset viewer.