Ignore:
Timestamp:
Apr 29, 2003, 11:26:29 AM (22 years ago)
Author:
darin
Message:

Reviewed by John.

  • fixed 2959353 -- eliminate globally initialized objects from JavaScriptCore
  • JavaScriptCore.pbproj/project.pbxproj: Added fpconst.cpp.
  • kjs/fpconst.cpp: Added. Defines KJS::NaN and KJS::Inf in a way that does not require a framework init routine.
  • kjs/identifier.h: Use a new KJS_IDENTIFIER_EACH_GLOBAL macro so we can do things to the entire set of identifiers easily. Also added an init function that sets up these globals in a way that does not require a framework init routine.
  • kjs/identifier.cpp: (Identifier::init): Initialize the property ane globals in a way that does not require a framework init routine.
  • kjs/internal.cpp: (InterpreterImp::initGlobalObject): Call Identifier::init.
  • kjs/ustring.h: Remove UChar::null and UString::null, and add UString::null(). We can't have a global object of a class that has a constructor if we want to avoid framework init routines, and luckily very little code relies on these.
  • kjs/ustring.cpp: (UCharReference::ref): Use our own global specific to this function rather than returning UChar::null when past the end of the string. This is dangerous because if the caller modifies it, that affects what all subsequent callers will see. (UString::Rep::create): Added assertions. (UString::UString): Got rid of code here that used to set up UString::null. (UString::null): Added. Returns a global null string, and can be used in some of the places where we used to use the UString::null global. (UString::operator[]): Fixed case where this used to return UChar::null to return '\0' instead.
  • kjs/regexp.cpp: (RegExp::match): Change uses of UString::null to UString::null().
File:
1 edited

Legend:

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

    r3745 r4206  
    3030        friend class PropertyMap;
    3131    public:
     32        static void init();
     33
    3234        Identifier() { }
    3335        Identifier(const char *s) : _ustring(add(s)) { }
     
    99101        { return Identifier::equal(a, b); }
    100102
    101     extern const Identifier argumentsPropertyName;
    102     extern const Identifier calleePropertyName;
    103     extern const Identifier constructorPropertyName;
    104     extern const Identifier lengthPropertyName;
    105     extern const Identifier messagePropertyName;
    106     extern const Identifier namePropertyName;
    107     extern const Identifier prototypePropertyName;
    108     extern const Identifier specialPrototypePropertyName;
    109     extern const Identifier toLocaleStringPropertyName;
    110     extern const Identifier toStringPropertyName;
    111     extern const Identifier valueOfPropertyName;
     103    // List of property names, passed to a macro so we can do set them up various
     104    // ways without repeating the list.
     105    #define KJS_IDENTIFIER_EACH_GLOBAL(macro) \
     106        macro(arguments) \
     107        macro(callee) \
     108        macro(constructor) \
     109        macro(length) \
     110        macro(message) \
     111        macro(name) \
     112        macro(prototype) \
     113        macro(toLocaleString) \
     114        macro(toString) \
     115        macro(valueOf)
     116
     117    // Define external global variables for all property names above (and one more).
     118#if !KJS_IDENTIFIER_HIDE_GLOBALS
     119    #define KJS_IDENTIFIER_DECLARE_GLOBAL(name) extern const Identifier name ## PropertyName;
     120    KJS_IDENTIFIER_EACH_GLOBAL(KJS_IDENTIFIER_DECLARE_GLOBAL)
     121    KJS_IDENTIFIER_DECLARE_GLOBAL(specialPrototype)
     122    #undef KJS_IDENTIFIER_DECLARE_GLOBAL
     123#endif
    112124
    113125}
Note: See TracChangeset for help on using the changeset viewer.