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

    r11525 r11527  
    3737using namespace KJS;
    3838
    39 // ------------------------------ StringInstanceImp ----------------------------
    40 
    41 const ClassInfo StringInstanceImp::info = {"String", 0, 0, 0};
    42 
    43 StringInstanceImp::StringInstanceImp(ObjectImp *proto)
    44   : ObjectImp(proto)
     39// ------------------------------ StringInstance ----------------------------
     40
     41const ClassInfo StringInstance::info = {"String", 0, 0, 0};
     42
     43StringInstance::StringInstance(JSObject *proto)
     44  : JSObject(proto)
    4545{
    4646  setInternalValue(jsString(""));
    4747}
    4848
    49 StringInstanceImp::StringInstanceImp(ObjectImp *proto, const UString &string)
    50   : ObjectImp(proto)
     49StringInstance::StringInstance(JSObject *proto, const UString &string)
     50  : JSObject(proto)
    5151{
    5252  setInternalValue(jsString(string));
    5353}
    5454
    55 ValueImp *StringInstanceImp::lengthGetter(ExecState *exec, const Identifier& propertyName, const PropertySlot &slot)
    56 {
    57     return jsNumber(static_cast<StringInstanceImp *>(slot.slotBase())->internalValue()->toString(exec).size());
    58 }
    59 
    60 ValueImp *StringInstanceImp::indexGetter(ExecState *exec, const Identifier& propertyName, const PropertySlot &slot)
    61 {
    62     const UChar c = static_cast<StringInstanceImp *>(slot.slotBase())->internalValue()->toString(exec)[slot.index()];
     55JSValue *StringInstance::lengthGetter(ExecState *exec, const Identifier& propertyName, const PropertySlot &slot)
     56{
     57    return jsNumber(static_cast<StringInstance *>(slot.slotBase())->internalValue()->toString(exec).size());
     58}
     59
     60JSValue *StringInstance::indexGetter(ExecState *exec, const Identifier& propertyName, const PropertySlot &slot)
     61{
     62    const UChar c = static_cast<StringInstance *>(slot.slotBase())->internalValue()->toString(exec)[slot.index()];
    6363    return jsString(UString(&c, 1));
    6464}
    6565
    66 bool StringInstanceImp::getOwnPropertySlot(ExecState *exec, const Identifier& propertyName, PropertySlot &slot)
     66bool StringInstance::getOwnPropertySlot(ExecState *exec, const Identifier& propertyName, PropertySlot &slot)
    6767{
    6868  if (propertyName == lengthPropertyName) {
     
    8282  }
    8383
    84   return ObjectImp::getOwnPropertySlot(exec, propertyName, slot);
    85 }
    86 
    87 void StringInstanceImp::put(ExecState *exec, const Identifier &propertyName, ValueImp *value, int attr)
     84  return JSObject::getOwnPropertySlot(exec, propertyName, slot);
     85}
     86
     87void StringInstance::put(ExecState *exec, const Identifier &propertyName, JSValue *value, int attr)
    8888{
    8989  if (propertyName == lengthPropertyName)
    9090    return;
    91   ObjectImp::put(exec, propertyName, value, attr);
    92 }
    93 
    94 bool StringInstanceImp::deleteProperty(ExecState *exec, const Identifier &propertyName)
     91  JSObject::put(exec, propertyName, value, attr);
     92}
     93
     94bool StringInstance::deleteProperty(ExecState *exec, const Identifier &propertyName)
    9595{
    9696  if (propertyName == lengthPropertyName)
    9797    return false;
    98   return ObjectImp::deleteProperty(exec, propertyName);
    99 }
    100 
    101 // ------------------------------ StringPrototypeImp ---------------------------
    102 const ClassInfo StringPrototypeImp::info = {"String", &StringInstanceImp::info, &stringTable, 0};
     98  return JSObject::deleteProperty(exec, propertyName);
     99}
     100
     101// ------------------------------ StringPrototype ---------------------------
     102const ClassInfo StringPrototype::info = {"String", &StringInstance::info, &stringTable, 0};
    103103/* Source for string_object.lut.h
    104104@begin stringTable 26
    105   toString              StringProtoFuncImp::ToString    DontEnum|Function       0
    106   valueOf               StringProtoFuncImp::ValueOf     DontEnum|Function       0
    107   charAt                StringProtoFuncImp::CharAt      DontEnum|Function       1
    108   charCodeAt            StringProtoFuncImp::CharCodeAt  DontEnum|Function       1
    109   concat                StringProtoFuncImp::Concat      DontEnum|Function       1
    110   indexOf               StringProtoFuncImp::IndexOf     DontEnum|Function       1
    111   lastIndexOf           StringProtoFuncImp::LastIndexOf DontEnum|Function       1
    112   match                 StringProtoFuncImp::Match       DontEnum|Function       1
    113   replace               StringProtoFuncImp::Replace     DontEnum|Function       2
    114   search                StringProtoFuncImp::Search      DontEnum|Function       1
    115   slice                 StringProtoFuncImp::Slice       DontEnum|Function       2
    116   split                 StringProtoFuncImp::Split       DontEnum|Function       2
    117   substr                StringProtoFuncImp::Substr      DontEnum|Function       2
    118   substring             StringProtoFuncImp::Substring   DontEnum|Function       2
    119   toLowerCase           StringProtoFuncImp::ToLowerCase DontEnum|Function       0
    120   toUpperCase           StringProtoFuncImp::ToUpperCase DontEnum|Function       0
    121   toLocaleLowerCase     StringProtoFuncImp::ToLocaleLowerCase DontEnum|Function 0
    122   toLocaleUpperCase     StringProtoFuncImp::ToLocaleUpperCase DontEnum|Function 0
     105  toString              StringProtoFunc::ToString       DontEnum|Function       0
     106  valueOf               StringProtoFunc::ValueOf        DontEnum|Function       0
     107  charAt                StringProtoFunc::CharAt DontEnum|Function       1
     108  charCodeAt            StringProtoFunc::CharCodeAt     DontEnum|Function       1
     109  concat                StringProtoFunc::Concat DontEnum|Function       1
     110  indexOf               StringProtoFunc::IndexOf        DontEnum|Function       1
     111  lastIndexOf           StringProtoFunc::LastIndexOf    DontEnum|Function       1
     112  match                 StringProtoFunc::Match  DontEnum|Function       1
     113  replace               StringProtoFunc::Replace        DontEnum|Function       2
     114  search                StringProtoFunc::Search DontEnum|Function       1
     115  slice                 StringProtoFunc::Slice  DontEnum|Function       2
     116  split                 StringProtoFunc::Split  DontEnum|Function       2
     117  substr                StringProtoFunc::Substr DontEnum|Function       2
     118  substring             StringProtoFunc::Substring      DontEnum|Function       2
     119  toLowerCase           StringProtoFunc::ToLowerCase    DontEnum|Function       0
     120  toUpperCase           StringProtoFunc::ToUpperCase    DontEnum|Function       0
     121  toLocaleLowerCase     StringProtoFunc::ToLocaleLowerCase DontEnum|Function    0
     122  toLocaleUpperCase     StringProtoFunc::ToLocaleUpperCase DontEnum|Function    0
    123123#
    124124# Under here: html extension, should only exist if KJS_PURE_ECMA is not defined
    125125# I guess we need to generate two hashtables in the .lut.h file, and use #ifdef
    126126# to select the right one... TODO. #####
    127   big                   StringProtoFuncImp::Big         DontEnum|Function       0
    128   small                 StringProtoFuncImp::Small       DontEnum|Function       0
    129   blink                 StringProtoFuncImp::Blink       DontEnum|Function       0
    130   bold                  StringProtoFuncImp::Bold        DontEnum|Function       0
    131   fixed                 StringProtoFuncImp::Fixed       DontEnum|Function       0
    132   italics               StringProtoFuncImp::Italics     DontEnum|Function       0
    133   strike                StringProtoFuncImp::Strike      DontEnum|Function       0
    134   sub                   StringProtoFuncImp::Sub         DontEnum|Function       0
    135   sup                   StringProtoFuncImp::Sup         DontEnum|Function       0
    136   fontcolor             StringProtoFuncImp::Fontcolor   DontEnum|Function       1
    137   fontsize              StringProtoFuncImp::Fontsize    DontEnum|Function       1
    138   anchor                StringProtoFuncImp::Anchor      DontEnum|Function       1
    139   link                  StringProtoFuncImp::Link        DontEnum|Function       1
     127  big                   StringProtoFunc::Big            DontEnum|Function       0
     128  small                 StringProtoFunc::Small  DontEnum|Function       0
     129  blink                 StringProtoFunc::Blink  DontEnum|Function       0
     130  bold                  StringProtoFunc::Bold   DontEnum|Function       0
     131  fixed                 StringProtoFunc::Fixed  DontEnum|Function       0
     132  italics               StringProtoFunc::Italics        DontEnum|Function       0
     133  strike                StringProtoFunc::Strike DontEnum|Function       0
     134  sub                   StringProtoFunc::Sub            DontEnum|Function       0
     135  sup                   StringProtoFunc::Sup            DontEnum|Function       0
     136  fontcolor             StringProtoFunc::Fontcolor      DontEnum|Function       1
     137  fontsize              StringProtoFunc::Fontsize       DontEnum|Function       1
     138  anchor                StringProtoFunc::Anchor DontEnum|Function       1
     139  link                  StringProtoFunc::Link   DontEnum|Function       1
    140140@end
    141141*/
    142142// ECMA 15.5.4
    143 StringPrototypeImp::StringPrototypeImp(ExecState *exec,
    144                                        ObjectPrototypeImp *objProto)
    145   : StringInstanceImp(objProto)
     143StringPrototype::StringPrototype(ExecState *exec,
     144                                       ObjectPrototype *objProto)
     145  : StringInstance(objProto)
    146146{
    147147  // The constructor will be added later, after StringObjectImp has been built
     
    149149}
    150150
    151 bool StringPrototypeImp::getOwnPropertySlot(ExecState *exec, const Identifier& propertyName, PropertySlot &slot)
    152 {
    153   return getStaticFunctionSlot<StringProtoFuncImp, StringInstanceImp>(exec, &stringTable, this, propertyName, slot);
    154 }
    155 
    156 // ------------------------------ StringProtoFuncImp ---------------------------
    157 
    158 StringProtoFuncImp::StringProtoFuncImp(ExecState *exec, int i, int len)
     151bool StringPrototype::getOwnPropertySlot(ExecState *exec, const Identifier& propertyName, PropertySlot &slot)
     152{
     153  return getStaticFunctionSlot<StringProtoFunc, StringInstance>(exec, &stringTable, this, propertyName, slot);
     154}
     155
     156// ------------------------------ StringProtoFunc ---------------------------
     157
     158StringProtoFunc::StringProtoFunc(ExecState *exec, int i, int len)
    159159  : InternalFunctionImp(
    160     static_cast<FunctionPrototypeImp*>(exec->lexicalInterpreter()->builtinFunctionPrototype())
     160    static_cast<FunctionPrototype*>(exec->lexicalInterpreter()->builtinFunctionPrototype())
    161161    ), id(i)
    162162{
     
    164164}
    165165
    166 bool StringProtoFuncImp::implementsCall() const
     166bool StringProtoFunc::implementsCall() const
    167167{
    168168  return true;
     
    171171static inline bool regExpIsGlobal(RegExpImp *regExp, ExecState *exec)
    172172{
    173     ValueImp *globalProperty = regExp->get(exec,"global");
     173    JSValue *globalProperty = regExp->get(exec,"global");
    174174    return !globalProperty->isUndefined() && globalProperty->toBoolean(exec);
    175175}
     
    259259}
    260260
    261 static ValueImp *replace(ExecState *exec, const UString &source, ValueImp *pattern, ValueImp *replacement)
    262 {
    263   ObjectImp *replacementFunction = 0;
     261static JSValue *replace(ExecState *exec, const UString &source, JSValue *pattern, JSValue *replacement)
     262{
     263  JSObject *replacementFunction = 0;
    264264  UString replacementString;
    265265
     
    365365
    366366// ECMA 15.5.4.2 - 15.5.4.20
    367 ValueImp *StringProtoFuncImp::callAsFunction(ExecState *exec, ObjectImp *thisObj, const List &args)
    368 {
    369   ValueImp *result = NULL;
     367JSValue *StringProtoFunc::callAsFunction(ExecState *exec, JSObject *thisObj, const List &args)
     368{
     369  JSValue *result = NULL;
    370370
    371371  // toString and valueOf are no generic function.
    372372  if (id == ToString || id == ValueOf) {
    373     if (!thisObj || !thisObj->inherits(&StringInstanceImp::info))
     373    if (!thisObj || !thisObj->inherits(&StringInstance::info))
    374374      return throwError(exec, TypeError);
    375375
     
    385385
    386386  int len = s.size();
    387   ValueImp *a0 = args[0];
    388   ValueImp *a1 = args[1];
     387  JSValue *a0 = args[0];
     388  JSValue *a1 = args[1];
    389389
    390390  switch (id) {
     
    528528    }
    529529    case Split: {
    530     ObjectImp *constructor = exec->lexicalInterpreter()->builtinArray();
    531     ObjectImp *res = static_cast<ObjectImp *>(constructor->construct(exec,List::empty()));
     530    JSObject *constructor = exec->lexicalInterpreter()->builtinArray();
     531    JSObject *res = static_cast<JSObject *>(constructor->construct(exec,List::empty()));
    532532    result = res;
    533533    u = s;
    534534    i = p0 = 0;
    535535    uint32_t limit = a1->isUndefined() ? 0xFFFFFFFFU : a1->toUInt32(exec);
    536     if (a0->isObject() && static_cast<ObjectImp *>(a0)->inherits(&RegExpImp::info)) {
    537       ObjectImp *obj0 = static_cast<ObjectImp *>(a0);
     536    if (a0->isObject() && static_cast<JSObject *>(a0)->inherits(&RegExpImp::info)) {
     537      JSObject *obj0 = static_cast<JSObject *>(a0);
    538538      RegExp reg(obj0->get(exec,"source")->toString(exec));
    539539      if (u.isEmpty() && !reg.match(u, 0).isNull()) {
     
    690690
    691691StringObjectImp::StringObjectImp(ExecState *exec,
    692                                  FunctionPrototypeImp *funcProto,
    693                                  StringPrototypeImp *stringProto)
     692                                 FunctionPrototype *funcProto,
     693                                 StringPrototype *stringProto)
    694694  : InternalFunctionImp(funcProto)
    695695{
     
    710710
    711711// ECMA 15.5.2
    712 ObjectImp *StringObjectImp::construct(ExecState *exec, const List &args)
    713 {
    714   ObjectImp *proto = exec->lexicalInterpreter()->builtinStringPrototype();
     712JSObject *StringObjectImp::construct(ExecState *exec, const List &args)
     713{
     714  JSObject *proto = exec->lexicalInterpreter()->builtinStringPrototype();
    715715  if (args.size() == 0)
    716     return new StringInstanceImp(proto);
    717   return new StringInstanceImp(proto, args.begin()->toString(exec));
     716    return new StringInstance(proto);
     717  return new StringInstance(proto, args.begin()->toString(exec));
    718718}
    719719
     
    724724
    725725// ECMA 15.5.1
    726 ValueImp *StringObjectImp::callAsFunction(ExecState *exec, ObjectImp */*thisObj*/, const List &args)
     726JSValue *StringObjectImp::callAsFunction(ExecState *exec, JSObject */*thisObj*/, const List &args)
    727727{
    728728  if (args.isEmpty())
    729729    return jsString("");
    730730  else {
    731     ValueImp *v = args[0];
     731    JSValue *v = args[0];
    732732    return jsString(v->toString(exec));
    733733  }
     
    737737
    738738// ECMA 15.5.3.2 fromCharCode()
    739 StringObjectFuncImp::StringObjectFuncImp(ExecState *exec, FunctionPrototypeImp *funcProto)
     739StringObjectFuncImp::StringObjectFuncImp(ExecState *exec, FunctionPrototype *funcProto)
    740740  : InternalFunctionImp(funcProto)
    741741{
     
    748748}
    749749
    750 ValueImp *StringObjectFuncImp::callAsFunction(ExecState *exec, ObjectImp */*thisObj*/, const List &args)
     750JSValue *StringObjectFuncImp::callAsFunction(ExecState *exec, JSObject */*thisObj*/, const List &args)
    751751{
    752752  UString s;
Note: See TracChangeset for help on using the changeset viewer.