Changeset 4206 in webkit for trunk/JavaScriptCore/kjs/ustring.cpp


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/ustring.cpp

    r3736 r4206  
    117117}
    118118
    119 UChar UChar::null((char)0);
    120119UString::Rep UString::Rep::null = { 0, 0, 0, 1, 1 };
    121120UString::Rep UString::Rep::empty = { 0, 0, 0, 1, 1 };
    122 UString UString::null;
    123121const int normalStatBufferSize = 4096;
    124122static char *statBuffer = 0;
     
    155153  if (offset < str->rep->len)
    156154    return *(str->rep->dat + offset);
    157   else
    158     return UChar::null;
     155  else {
     156    static UChar callerBetterNotModifyThis('\0');
     157    return callerBetterNotModifyThis;
     158  }
    159159}
    160160
     
    253253UString::UString()
    254254{
    255   null.rep = &Rep::null;
    256255  attach(&Rep::null);
    257256}
     
    320319  memcpy(d + aSize, b.data(), bSize * sizeof(UChar));
    321320  rep = Rep::create(d, length);
     321}
     322
     323const UString &UString::null()
     324{
     325    static UString n;
     326    return n;
    322327}
    323328
     
    551556{
    552557  if (pos >= size())
    553     return UChar::null;
    554 
    555   return ((UChar *)data())[pos];
     558    return '\0';
     559  return data()[pos];
    556560}
    557561
Note: See TracChangeset for help on using the changeset viewer.