Changeset 15468 in webkit
- Timestamp:
- Jul 16, 2006 2:06:28 PM (18 years ago)
- Location:
- trunk
- Files:
-
- 5 added
- 5 deleted
- 31 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/API/APICast.h
r15437 r15468 35 35 class JSValue; 36 36 class JSObject; 37 class ReferenceList;37 class PropertyNameArray; 38 38 } 39 39 … … 65 65 } 66 66 67 inline KJS:: ReferenceList* toJS(JSPropertyListRef l)67 inline KJS::PropertyNameArray* toJS(JSPropertyNameAccumulatorRef a) 68 68 { 69 return reinterpret_cast<KJS:: ReferenceList*>(l);69 return reinterpret_cast<KJS::PropertyNameArray*>(a); 70 70 } 71 71 … … 95 95 } 96 96 97 inline JSPropertyListRef toRef(KJS::ReferenceList* l)98 {99 return reinterpret_cast<JSPropertyListRef>(l);100 }101 102 97 inline JSContextRef toRef(KJS::ExecState* e) 103 98 { … … 105 100 } 106 101 102 inline JSPropertyNameAccumulatorRef toRef(KJS::PropertyNameArray* l) 103 { 104 return reinterpret_cast<JSPropertyNameAccumulatorRef>(l); 105 } 106 107 107 #endif // APICast_h -
trunk/JavaScriptCore/API/JSBase.h
r15437 r15468 44 44 typedef struct __JSClass* JSClassRef; 45 45 46 /*! @typedef JSProperty ListRef A JavaScript property list. Used for listing the properties in an object so they can be enumerated. */47 typedef struct __JSProperty List* JSPropertyListRef;46 /*! @typedef JSPropertyNameArrayRef An array of JavaScript property names. */ 47 typedef struct __JSPropertyNameArray* JSPropertyNameArrayRef; 48 48 49 /*! @typedef JSProperty EnumeratorRef A JavaScript property enumerator. Used for enumerating the properties in an object. */50 typedef struct __JSProperty Enumerator* JSPropertyEnumeratorRef;49 /*! @typedef JSPropertyNameAccumulatorRef A data type used to collect a JavaScript object's property names. */ 50 typedef struct __JSPropertyNameAccumulator* JSPropertyNameAccumulatorRef; 51 51 52 52 -
trunk/JavaScriptCore/API/JSCallbackObject.cpp
r15462 r15468 31 31 #include "JSObjectRef.h" 32 32 #include "internal.h" 33 #include "reference.h" 34 #include "reference_list.h" 33 #include "PropertyNameArray.h" 35 34 36 35 namespace KJS { … … 291 290 } 292 291 293 void JSCallbackObject::getPropertyList(ReferenceList& propertyList, bool recursive) 294 { 295 JSObjectRef thisRef = toRef(this); 296 297 for (JSClassRef jsClass = m_class; jsClass; jsClass = jsClass->parentClass) { 298 if (JSObjectAddPropertiesToListCallback addPropertiesToList = jsClass->addPropertiesToList) 299 addPropertiesToList(thisRef, toRef(&propertyList)); 292 void JSCallbackObject::getPropertyNames(ExecState* exec, PropertyNameArray& propertyNames) 293 { 294 JSContextRef execRef = toRef(exec); 295 JSObjectRef thisRef = toRef(this); 296 297 for (JSClassRef jsClass = m_class; jsClass; jsClass = jsClass->parentClass) { 298 if (JSObjectGetPropertyNamesCallback getPropertyNames = jsClass->getPropertyNames) 299 getPropertyNames(execRef, thisRef, toRef(&propertyNames)); 300 300 301 301 if (__JSClass::StaticValuesTable* staticValues = jsClass->staticValues) { … … 306 306 StaticValueEntry* entry = it->second; 307 307 if (entry->getProperty && !(entry->attributes & kJSPropertyAttributeDontEnum)) 308 property List.append(Reference(this, Identifier(name)));308 propertyNames.add(Identifier(name)); 309 309 } 310 310 } … … 317 317 StaticFunctionEntry* entry = it->second; 318 318 if (!(entry->attributes & kJSPropertyAttributeDontEnum)) 319 property List.append(Reference(this, Identifier(name)));320 } 321 } 322 } 323 324 JSObject::getProperty List(propertyList, recursive);319 propertyNames.add(Identifier(name)); 320 } 321 } 322 } 323 324 JSObject::getPropertyNames(exec, propertyNames); 325 325 } 326 326 -
trunk/JavaScriptCore/API/JSCallbackObject.h
r15443 r15468 61 61 virtual JSValue* callAsFunction(ExecState*, JSObject* thisObj, const List &args); 62 62 63 virtual void getProperty List(ReferenceList& propertyList, bool recursive);63 virtual void getPropertyNames(ExecState*, PropertyNameArray&); 64 64 65 65 virtual double toNumber(ExecState*) const; -
trunk/JavaScriptCore/API/JSClassRef.cpp
r15462 r15468 45 45 , setProperty(definition->setProperty) 46 46 , deleteProperty(definition->deleteProperty) 47 , addPropertiesToList(definition->addPropertiesToList)47 , getPropertyNames(definition->getPropertyNames) 48 48 , callAsFunction(definition->callAsFunction) 49 49 , callAsConstructor(definition->callAsConstructor) -
trunk/JavaScriptCore/API/JSClassRef.h
r15462 r15468 74 74 JSObjectSetPropertyCallback setProperty; 75 75 JSObjectDeletePropertyCallback deleteProperty; 76 JSObject AddPropertiesToListCallback addPropertiesToList;76 JSObjectGetPropertyNamesCallback getPropertyNames; 77 77 JSObjectCallAsFunctionCallback callAsFunction; 78 78 JSObjectCallAsConstructorCallback callAsConstructor; -
trunk/JavaScriptCore/API/JSObjectRef.cpp
r15465 r15468 38 38 #include "internal.h" 39 39 #include "object.h" 40 #include " reference_list.h"40 #include "PropertyNameArray.h" 41 41 42 42 using namespace KJS; … … 307 307 } 308 308 309 struct __JSProperty Enumerator310 { 311 __JSProperty Enumerator() : refCount(0), iterator(list.end())309 struct __JSPropertyNameArray 310 { 311 __JSPropertyNameArray() : refCount(0) 312 312 { 313 313 } 314 314 315 315 unsigned refCount; 316 ReferenceList list; 317 ReferenceListIterator iterator; 316 PropertyNameArray array; 318 317 }; 319 318 320 JSPropertyEnumeratorRef JSObjectCreatePropertyEnumerator(JSObjectRef object) 321 { 322 JSLock lock; 323 JSObject* jsObject = toJS(object); 324 325 JSPropertyEnumeratorRef enumerator = new __JSPropertyEnumerator(); 326 jsObject->getPropertyList(enumerator->list); 327 enumerator->iterator = enumerator->list.begin(); 328 329 return JSPropertyEnumeratorRetain(enumerator); 330 } 331 332 JSStringRef JSPropertyEnumeratorGetNextName(JSPropertyEnumeratorRef enumerator) 333 { 334 ReferenceListIterator& iterator = enumerator->iterator; 335 if (iterator != enumerator->list.end()) { 336 JSStringRef result = toRef(iterator->getPropertyName().ustring().rep()); 337 iterator++; 338 return result; 339 } 340 return 0; 341 } 342 343 JSPropertyEnumeratorRef JSPropertyEnumeratorRetain(JSPropertyEnumeratorRef enumerator) 344 { 345 ++enumerator->refCount; 346 return enumerator; 347 } 348 349 void JSPropertyEnumeratorRelease(JSPropertyEnumeratorRef enumerator) 350 { 351 if (--enumerator->refCount == 0) 352 delete enumerator; 353 } 354 355 void JSPropertyListAdd(JSPropertyListRef propertyList, JSObjectRef thisObject, JSStringRef propertyName) 356 { 357 JSLock lock; 358 ReferenceList* jsPropertyList = toJS(propertyList); 359 JSObject* jsObject = toJS(thisObject); 319 JSPropertyNameArrayRef JSObjectCopyPropertyNames(JSContextRef context, JSObjectRef object) 320 { 321 JSLock lock; 322 JSObject* jsObject = toJS(object); 323 ExecState* exec = toJS(context); 324 325 JSPropertyNameArrayRef propertyNames = new __JSPropertyNameArray(); 326 jsObject->getPropertyNames(exec, propertyNames->array); 327 328 return JSPropertyNameArrayRetain(propertyNames); 329 } 330 331 JSPropertyNameArrayRef JSPropertyNameArrayRetain(JSPropertyNameArrayRef array) 332 { 333 ++array->refCount; 334 return array; 335 } 336 337 void JSPropertyNameArrayRelease(JSPropertyNameArrayRef array) 338 { 339 if (--array->refCount == 0) 340 delete array; 341 } 342 343 size_t JSPropertyNameArrayGetCount(JSPropertyNameArrayRef array) 344 { 345 return array->array.size(); 346 } 347 348 JSStringRef JSPropertyNameArrayGetNameAtIndex(JSPropertyNameArrayRef array, size_t index) 349 { 350 return toRef(array->array[index].ustring().rep()); 351 } 352 353 void JSPropertyNameAccumulatorAddName(JSPropertyNameAccumulatorRef array, JSStringRef propertyName) 354 { 355 JSLock lock; 356 PropertyNameArray* propertyNames = toJS(array); 360 357 UString::Rep* rep = toJS(propertyName); 361 358 362 jsPropertyList->append(Reference(jsObject, Identifier(rep)));363 } 359 propertyNames->add(Identifier(rep)); 360 } -
trunk/JavaScriptCore/API/JSObjectRef.h
r15464 r15468 155 155 156 156 /*! 157 @typedef JSObjectAddPropertiesToListCallback 158 @abstract The callback invoked when adding an object's properties to a property list. 159 @param object The JSObject whose properties need to be added to propertyList. 160 @param propertyList A JavaScript property list that will be used to enumerate object's properties. 161 @discussion If you named your function GetPropertyList, you would declare it like this: 162 163 void AddPropertiesToList(JSObjectRef object, JSPropertyListRef propertyList); 164 165 Use JSPropertyListAdd to add properties to propertyList. 166 167 Property lists are used by JSPropertyEnumerators and JavaScript for...in loops. 157 @typedef JSObjectGetPropertyNamesCallback 158 @abstract The callback invoked to get the names of an object's properties. 159 @param context The current execution context. 160 @param object The JSObject whose property names need to be appended to propertyNames. 161 @param accumulator A JavaScript property name accumulator, to which the object should add the names of its properties. 162 @discussion If you named your function GetPropertyNames, you would declare it like this: 163 164 void GetPropertyNames(JSContextRef context, JSObjectRef object, JSPropertyNameAccumulatorRef accumulator); 165 166 Use JSPropertyNameAccumulatorAddName to add property names to accumulator. 167 168 Property lists are used by JSPropertyEnumerators and JavaScript for...in loops. 169 170 It's only necessary to add names of properties that you handle 171 specially in your own get / set callbacks. Static property names, 172 names of standard JS properties, and properties from the prototype 173 will be added automatically. 168 174 */ 169 175 typedef void 170 (*JSObject AddPropertiesToListCallback) (JSObjectRef object, JSPropertyListRef propertyList);176 (*JSObjectGetPropertyNamesCallback) (JSContextRef context, JSObjectRef object, JSPropertyNameAccumulatorRef propertyNames); 171 177 172 178 /*! … … 327 333 JSObjectSetPropertyCallback setProperty; 328 334 JSObjectDeletePropertyCallback deleteProperty; 329 JSObject AddPropertiesToListCallback addPropertiesToList;335 JSObjectGetPropertyNamesCallback getPropertyNames; 330 336 JSObjectCallAsFunctionCallback callAsFunction; 331 337 JSObjectCallAsConstructorCallback callAsConstructor; … … 486 492 @param propertyIndex The property's name as a number 487 493 @param value A JSValue to use as the property's value. 488 @param attributes A logically ORed set of JSPropertyAttributes to give to the property.489 494 @discussion This is equivalent to setting a property by a string name containing the number, but allows faster access to JS arrays. 490 495 */ 491 void JSObjectSetPropertyAtIndex(JSContextRef context, JSObjectRef object, unsigned propertyIndex, JSValueRef value , JSPropertyAttributes attributes);496 void JSObjectSetPropertyAtIndex(JSContextRef context, JSObjectRef object, unsigned propertyIndex, JSValueRef value); 492 497 493 498 /*! … … 550 555 /*! 551 556 @function 552 @abstract Creates an enumerator for an object's properties. 553 @param object The object whose properties you want to enumerate. 554 @result A JSPropertyEnumerator with a list of object's properties. Ownership follows the Create Rule. 555 */ 556 JSPropertyEnumeratorRef JSObjectCreatePropertyEnumerator(JSObjectRef object); 557 /*! 558 @function 559 @abstract Retains a property enumerator. 560 @param enumerator The JSPropertyEnumerator to retain. 561 @result A JSPropertyEnumerator that is the same as enumerator. 562 */ 563 JSPropertyEnumeratorRef JSPropertyEnumeratorRetain(JSPropertyEnumeratorRef enumerator); 564 /*! 565 @function 566 @abstract Releases a property enumerator. 567 @param enumerator The JSPropertyEnumerator to release. 568 */ 569 void JSPropertyEnumeratorRelease(JSPropertyEnumeratorRef enumerator); 570 /*! 571 @function 572 @abstract Gets a property enumerator's next property. 573 @param enumerator The JSPropertyEnumerator whose next property you want to get. 574 @result A JSString containing the property's name, or NULL if all properties have been enumerated. 575 */ 576 JSStringRef JSPropertyEnumeratorGetNextName(JSPropertyEnumeratorRef enumerator); 577 578 /*! 579 @function 580 @abstract Adds a property to a property list. 581 @discussion Use this method inside a JSObjectAddPropertiesToListCallback to add a property to an object's property list. 582 @param propertyList The JSPropertyList to which you want to add a property. 583 @param thisObject The JSObject to which the property belongs. 584 @param propertyName A JSString specifying the property's name. 585 */ 586 void JSPropertyListAdd(JSPropertyListRef propertyList, JSObjectRef thisObject, JSStringRef propertyName); 557 @abstract Get the names of all enumerable properties of an object. 558 @param context The execution context to use. 559 @param object The object from which to get property names. 560 @result A JSPropertyNameArray containing the names of all the object's enumerable properties. 561 */ 562 JSPropertyNameArrayRef JSObjectCopyPropertyNames(JSContextRef context, JSObjectRef object); 563 564 /*! 565 @function 566 @abstract Retains a JavaScript property name array. 567 @param array The JSPropertyNameArray to retain. 568 @result A JSPropertyNameArray that is the same as array. 569 */ 570 JSPropertyNameArrayRef JSPropertyNameArrayRetain(JSPropertyNameArrayRef array); 571 572 /*! 573 @function 574 @abstract Releases a JavaScript property name array. 575 @param array The JSPropetyNameArray to release. 576 */ 577 void JSPropertyNameArrayRelease(JSPropertyNameArrayRef array); 578 579 /*! 580 @function 581 @abstract Get the number of items in a JavaScript property name array. 582 @param array The array from which to retrieve the count. 583 @result The count of items in the array. 584 */ 585 size_t JSPropertyNameArrayGetCount(JSPropertyNameArrayRef array); 586 587 /*! 588 @function 589 @abstract Get a single item from a JavaScript property name array. 590 @param array The array from which to retrieve a property name. 591 @param index The index of the property name to retrieve. 592 @result A JSStringRef containing the name of the property. 593 */ 594 JSStringRef JSPropertyNameArrayGetNameAtIndex(JSPropertyNameArrayRef array, size_t index); 595 596 /*! 597 @function 598 @abstract Add a property name - useful while getting the property names for an object. 599 @param accumulator The accumulator object to which to add the property. 600 @param propertyName The new property to add. 601 */ 602 void JSPropertyNameAccumulatorAddName(JSPropertyNameAccumulatorRef accumulator, JSStringRef propertyName); 587 603 588 604 #ifdef __cplusplus -
trunk/JavaScriptCore/API/testapi.c
r15465 r15468 170 170 } 171 171 172 static void MyObject_ addPropertiesToList(JSObjectRef object, JSPropertyListRef propertyList)172 static void MyObject_getPropertyNames(JSContextRef context, JSObjectRef object, JSPropertyNameAccumulatorRef propertyNames) 173 173 { 174 174 UNUSED_PARAM(context); … … 177 177 178 178 propertyName = JSStringCreateWithUTF8CString("alwaysOne"); 179 JSProperty ListAdd(propertyList, object, propertyName);179 JSPropertyNameAccumulatorAddName(propertyNames, propertyName); 180 180 JSStringRelease(propertyName); 181 181 182 182 propertyName = JSStringCreateWithUTF8CString("myPropertyName"); 183 JSProperty ListAdd(propertyList, object, propertyName);183 JSPropertyNameAccumulatorAddName(propertyNames, propertyName); 184 184 JSStringRelease(propertyName); 185 185 } … … 258 258 MyObject_setProperty, 259 259 MyObject_deleteProperty, 260 MyObject_ addPropertiesToList,260 MyObject_getPropertyNames, 261 261 MyObject_callAsFunction, 262 262 MyObject_callAsConstructor, … … 589 589 JSObjectSetProperty(context, o, jsOneIString, JSValueMakeNumber(1), kJSPropertyAttributeNone, NULL); 590 590 JSObjectSetProperty(context, o, jsCFIString, JSValueMakeNumber(1), kJSPropertyAttributeDontEnum, NULL); 591 JSPropertyEnumeratorRef enumerator = JSObjectCreatePropertyEnumerator(o); 592 int count = 0; 593 while (JSPropertyEnumeratorGetNextName(enumerator)) 594 ++count; 595 JSPropertyEnumeratorRelease(enumerator); 591 JSPropertyNameArrayRef nameArray = JSObjectCopyPropertyNames(context, o); 592 size_t expectedCount = JSPropertyNameArrayGetCount(nameArray); 593 size_t count; 594 for (count = 0; count < expectedCount; ++count) 595 JSPropertyNameArrayGetNameAtIndex(nameArray, count); 596 JSPropertyNameArrayRelease(nameArray); 596 597 assert(count == 1); // jsCFString should not be enumerated 597 598 -
trunk/JavaScriptCore/ChangeLog
r15465 r15468 1 2006-07-15 Maciej Stachowiak <mjs@apple.com> 2 3 Reviewed by Darin. 4 5 - switch property lists to be vector+set of Identifiers instead of list of References 6 7 This has the following benefits: 8 9 - no duplicates in property lists 10 - simplifies API calls 11 - probably more efficient, since linked list is gone 12 - entirely removed Reference, ReferenceList and ProtectedReference types from the API 13 14 * kjs/PropertyNameArray.cpp: Added. 15 (KJS::PropertyNameArray::add): Check set, if not already there, add to 16 vector. 17 * kjs/PropertyNameArray.h: Added. 18 (KJS::PropertyNameArray::PropertyNameArray): Newly added type, combines 19 a set and a vector to make a unique but ordered list of identifiers. 20 (KJS::PropertyNameArray::begin): ditto 21 (KJS::PropertyNameArray::end): ditto 22 (KJS::PropertyNameArray::size): ditto 23 (KJS::PropertyNameArray::operator[]): ditto 24 * kjs/array_instance.h: 25 * kjs/array_object.cpp: 26 (ArrayInstance::getPropertyNames): renamed from getPropertyList, updated 27 for PropertyNameArray 28 (ArrayInstance::setLength): updated for PropertyNameArray 29 (ArrayInstance::pushUndefinedObjectsToEnd): ditto 30 * kjs/nodes.cpp: 31 (ForInNode::execute): updated for PropertyNameArray 32 * kjs/nodes.h: 33 * kjs/object.cpp: 34 (KJS::JSObject::getPropertyNames): renamed from getPropertyList, updated 35 for PropertyNameArray 36 * kjs/object.h: 37 * kjs/property_map.cpp: 38 (KJS::PropertyMap::getEnumerablePropertyNames): updated for PropertyNameArray 39 (KJS::PropertyMap::getSparseArrayPropertyNames): ditto 40 * kjs/property_map.h: 41 * kjs/protected_reference.h: Removed. 42 * kjs/reference.cpp: Removed. 43 * kjs/reference.h: Removed. 44 * kjs/reference_list.cpp: Removed. 45 * kjs/reference_list.h: Removed. 46 * kjs/scope_chain.cpp: 47 (KJS::ScopeChain::print): Use PropertyNamesArray instead of ReferenceList. 48 * kjs/string_object.cpp: 49 (StringInstance::getPropertyNames): Updated for new approach. 50 * kjs/string_object.h: 51 * kjs/ustring.h: 52 * API/APICast.h: 53 (toJS): Added overload for PropertyNameAccumulatorRef / PropertyNameArray* 54 (toRef): ditto 55 * API/JSBase.h: 56 * API/JSCallbackObject.cpp: 57 (KJS::JSCallbackObject::getPropertyNames): Fixed for new API. 58 * API/JSCallbackObject.h: 59 * API/JSObjectRef.cpp: 60 (__JSPropertyNameArray::__JSPropertyNameArray): Type used for a publicly vended 61 JSPropertyNameArrayRef. 62 (JSObjectCopyPropertyNames): New API call - renamed / refactored from 63 JSObjectCreatePropertyList 64 (JSPropertyNameArrayRetain): new retain call for JSPropertyNameArray. 65 (JSPropertyNameArrayRelease): new release call for - " -. 66 (JSPropertyNameArrayGetCount): Instead of having to use a stateful enumerator you 67 can now get the count and items in any order. 68 (JSPropertyNameArrayGetNameAtIndex): See above. 69 (JSPropertyNameAccumulatorAddName): What you add properties to is now an opaque 70 accumulator object. 71 * API/JSObjectRef.h: Prototyped new functions, removed old ones 72 * JavaScriptCore.exp: Updated exported symbols. 73 * JavaScriptCore.xcodeproj/project.pbxproj: Added new files, removed old. 74 * API/testapi.c: 75 (MyObject_getPropertyNames): Renamed / fixed callback to fit new paradigm. 76 (main): Updated for new API. 77 1 78 2006-07-15 Darin Adler <darin@apple.com> 2 79 -
trunk/JavaScriptCore/JavaScriptCore.exp
r15462 r15468 14 14 _JSObjectCallAsConstructor 15 15 _JSObjectCallAsFunction 16 _JSObjectC reatePropertyEnumerator16 _JSObjectCopyPropertyNames 17 17 _JSObjectDeleteProperty 18 18 _JSObjectGetPrivate 19 19 _JSObjectGetProperty 20 _JSObjectGetPropertyAtIndex 20 21 _JSObjectGetPrototype 21 22 _JSObjectHasProperty … … 28 29 _JSObjectSetPrivate 29 30 _JSObjectSetProperty 31 _JSObjectSetPropertyAtIndex 30 32 _JSObjectSetPrototype 31 _JSPropertyEnumeratorGetNextName 32 _JSPropertyEnumeratorRelease 33 _JSPropertyEnumeratorRetain 34 _JSPropertyListAdd 33 _JSPropertyNameAccumulatorAddName 34 _JSPropertyNameArrayGetCount 35 _JSPropertyNameArrayGetNameAtIndex 36 _JSPropertyNameArrayRelease 37 _JSPropertyNameArrayRetain 35 38 _JSStringCopyCFString 36 39 _JSStringCreateWithCFString … … 139 142 __ZN3KJS12PropertySlot15undefinedGetterEPNS_9ExecStateEPNS_8JSObjectERKNS_10IdentifierERKS0_ 140 143 __ZN3KJS12jsNumberCellEd 141 __ZN3KJS13ReferenceList6appendERKNS_9ReferenceE142 __ZN3KJS13ReferenceListC1Ev143 __ZN3KJS13ReferenceListD1Ev144 144 __ZN3KJS13SavedBuiltinsC1Ev 145 145 __ZN3KJS13SavedBuiltinsD1Ev … … 147 147 __ZN3KJS15SavedPropertiesD1Ev 148 148 __ZN3KJS16RuntimeObjectImpC1EPNS_8Bindings8InstanceE 149 __ZN3KJS17PropertyNameArray3addERKNS_10IdentifierE 149 150 __ZN3KJS18lengthPropertyNameE 150 151 __ZN3KJS19InternalFunctionImp11hasInstanceEPNS_9ExecStateEPNS_7JSValueE … … 152 153 __ZN3KJS19InternalFunctionImpC2EPNS_17FunctionPrototypeERKNS_10IdentifierE 153 154 __ZN3KJS19messagePropertyNameE 154 __ZN3KJS21ReferenceListIteratorppEi155 155 __ZN3KJS21prototypePropertyNameE 156 156 __ZN3KJS4List6appendEPNS_7JSValueE … … 187 187 __ZN3KJS8JSObject14deletePropertyEPNS_9ExecStateERKNS_10IdentifierE 188 188 __ZN3KJS8JSObject14deletePropertyEPNS_9ExecStateEj 189 __ZN3KJS8JSObject1 5getPropertyListERNS_13ReferenceListEb189 __ZN3KJS8JSObject16getPropertyNamesEPNS_9ExecStateERNS_17PropertyNameArrayE 190 190 __ZN3KJS8JSObject18getOwnPropertySlotEPNS_9ExecStateEjRNS_12PropertySlotE 191 191 __ZN3KJS8JSObject22fillGetterPropertySlotERNS_12PropertySlotEPPNS_7JSValueE … … 207 207 __ZN3KJS9Collector7protectEPNS_7JSValueE 208 208 __ZN3KJS9Collector9unprotectEPNS_7JSValueE 209 __ZN3KJS9ReferenceC1EPNS_8JSObjectERKNS_10IdentifierE210 209 __ZN3KJSeqERKNS_7UStringEPKc 211 210 __ZN3WTF10fastCallocEmm … … 222 221 __ZNK3KJS11PropertyMap4saveERNS_15SavedPropertiesE 223 222 __ZNK3KJS12DateInstance7getTimeERdRi 224 __ZNK3KJS13ReferenceList3endEv225 __ZNK3KJS13ReferenceList5beginEv226 223 __ZNK3KJS19InternalFunctionImp14implementsCallEv 227 224 __ZNK3KJS19InternalFunctionImp21implementsHasInstanceEv 228 __ZNK3KJS21ReferenceListIteratorneERKS0_229 __ZNK3KJS21ReferenceListIteratorptEv230 225 __ZNK3KJS4List2atEi 231 226 __ZNK3KJS4List8copyTailEv … … 258 253 __ZNK3KJS8JSObject9toBooleanEPNS_9ExecStateE 259 254 __ZNK3KJS9ExecState18lexicalInterpreterEv 260 __ZNK3KJS9Reference15getPropertyNameEv261 255 __ZTVN3KJS19InternalFunctionImpE 262 256 __ZTVN3KJS8JSObjectE -
trunk/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj
r15428 r15468 78 78 14F137590A3A727E00F26F90 /* Context.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 14F137580A3A727E00F26F90 /* Context.cpp */; }; 79 79 14F137830A3A765B00F26F90 /* context.h in Headers */ = {isa = PBXBuildFile; fileRef = 14F137820A3A765B00F26F90 /* context.h */; settings = {ATTRIBUTES = (Private, ); }; }; 80 652C107F08DA7B1E0020887D /* protected_reference.h in Headers */ = {isa = PBXBuildFile; fileRef = 652C107E08DA7B1E0020887D /* protected_reference.h */; }; 80 65400C110A69BAF200509887 /* PropertyNameArray.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 65400C0F0A69BAF200509887 /* PropertyNameArray.cpp */; }; 81 65400C120A69BAF200509887 /* PropertyNameArray.h in Headers */ = {isa = PBXBuildFile; fileRef = 65400C100A69BAF200509887 /* PropertyNameArray.h */; settings = {ATTRIBUTES = (Private, ); }; }; 81 82 6541BD7208E80A17002CBEE7 /* TCPageMap.h in Headers */ = {isa = PBXBuildFile; fileRef = 6541BD6E08E80A17002CBEE7 /* TCPageMap.h */; }; 82 83 6541BD7308E80A17002CBEE7 /* TCSpinLock.h in Headers */ = {isa = PBXBuildFile; fileRef = 6541BD6F08E80A17002CBEE7 /* TCSpinLock.h */; }; … … 146 147 932F5B600822A1C700736975 /* config.h in Headers */ = {isa = PBXBuildFile; fileRef = F68EBB8C0255D4C601FF60F7 /* config.h */; settings = {ATTRIBUTES = (Private, ); }; }; 147 148 932F5B610822A1C700736975 /* JavaScriptCorePrefix.h in Headers */ = {isa = PBXBuildFile; fileRef = F5C290E60284F98E018635CA /* JavaScriptCorePrefix.h */; }; 148 932F5B630822A1C700736975 /* reference_list.h in Headers */ = {isa = PBXBuildFile; fileRef = F54F0800030CD22001B5C2EB /* reference_list.h */; settings = {ATTRIBUTES = (Private, ); }; };149 932F5B640822A1C700736975 /* reference.h in Headers */ = {isa = PBXBuildFile; fileRef = F5341391030CEEB1018BE7F3 /* reference.h */; settings = {ATTRIBUTES = (Private, ); }; };150 149 932F5B650822A1C700736975 /* completion.h in Headers */ = {isa = PBXBuildFile; fileRef = F5BB2BC5030F772101FCFE1D /* completion.h */; settings = {ATTRIBUTES = (Private, ); }; }; 151 150 932F5B660822A1C700736975 /* identifier.h in Headers */ = {isa = PBXBuildFile; fileRef = 933A349A038AE7C6008635CE /* identifier.h */; settings = {ATTRIBUTES = (Private, ); }; }; … … 209 208 932F5BA90822A1C700736975 /* value.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F692A8870255597D01FF60F7 /* value.cpp */; }; 210 209 932F5BAB0822A1C700736975 /* nodes2string.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F5FFE656026B47A6018635CA /* nodes2string.cpp */; }; 211 932F5BAC0822A1C700736975 /* reference.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F5341390030CEEB1018BE7F3 /* reference.cpp */; settings = {ATTRIBUTES = (Private, ); }; };212 932F5BAD0822A1C700736975 /* reference_list.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F5341394030CF5F8018BE7F3 /* reference_list.cpp */; settings = {ATTRIBUTES = (Private, ); }; };213 210 932F5BAE0822A1C700736975 /* identifier.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 933A349D038AE80F008635CE /* identifier.cpp */; }; 214 211 932F5BAF0822A1C700736975 /* scope_chain.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9374D3A8038D9D74008635CE /* scope_chain.cpp */; }; … … 426 423 651F6412039D5B5F0078395C /* dtoa.cpp */ = {isa = PBXFileReference; fileEncoding = 30; indentWidth = 4; lastKnownFileType = sourcecode.cpp.cpp; path = dtoa.cpp; sourceTree = "<group>"; tabWidth = 8; }; 427 424 651F6413039D5B5F0078395C /* dtoa.h */ = {isa = PBXFileReference; fileEncoding = 30; indentWidth = 4; lastKnownFileType = sourcecode.c.h; path = dtoa.h; sourceTree = "<group>"; tabWidth = 8; }; 428 652C107E08DA7B1E0020887D /* protected_reference.h */ = {isa = PBXFileReference; fileEncoding = 30; indentWidth = 4; lastKnownFileType = sourcecode.c.h; path = protected_reference.h; sourceTree = "<group>"; tabWidth = 8; }; 425 65400C0F0A69BAF200509887 /* PropertyNameArray.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = PropertyNameArray.cpp; sourceTree = "<group>"; }; 426 65400C100A69BAF200509887 /* PropertyNameArray.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = PropertyNameArray.h; sourceTree = "<group>"; }; 429 427 6541720E039E08B90058BFEB /* dftables.c */ = {isa = PBXFileReference; fileEncoding = 30; indentWidth = 4; lastKnownFileType = sourcecode.c.c; name = dftables.c; path = pcre/dftables.c; sourceTree = "<group>"; tabWidth = 8; }; 430 428 6541720F039E08B90058BFEB /* pcre.h */ = {isa = PBXFileReference; fileEncoding = 30; indentWidth = 4; lastKnownFileType = sourcecode.c.h; name = pcre.h; path = pcre/pcre.h; sourceTree = "<group>"; tabWidth = 8; }; … … 519 517 E195679409E7CF1200B89D13 /* Unicode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Unicode.h; sourceTree = "<group>"; }; 520 518 E195679509E7CF1200B89D13 /* UnicodeCategory.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UnicodeCategory.h; sourceTree = "<group>"; }; 521 F5341390030CEEB1018BE7F3 /* reference.cpp */ = {isa = PBXFileReference; fileEncoding = 30; indentWidth = 4; lastKnownFileType = sourcecode.cpp.cpp; path = reference.cpp; sourceTree = "<group>"; tabWidth = 8; };522 F5341391030CEEB1018BE7F3 /* reference.h */ = {isa = PBXFileReference; fileEncoding = 30; indentWidth = 4; lastKnownFileType = sourcecode.c.h; path = reference.h; sourceTree = "<group>"; tabWidth = 8; };523 F5341394030CF5F8018BE7F3 /* reference_list.cpp */ = {isa = PBXFileReference; fileEncoding = 30; indentWidth = 4; lastKnownFileType = sourcecode.cpp.cpp; path = reference_list.cpp; sourceTree = "<group>"; tabWidth = 8; };524 F54F0800030CD22001B5C2EB /* reference_list.h */ = {isa = PBXFileReference; fileEncoding = 30; indentWidth = 4; lastKnownFileType = sourcecode.c.h; path = reference_list.h; sourceTree = "<group>"; tabWidth = 8; };525 519 F5BB2BC5030F772101FCFE1D /* completion.h */ = {isa = PBXFileReference; fileEncoding = 30; indentWidth = 4; lastKnownFileType = sourcecode.c.h; path = completion.h; sourceTree = "<group>"; tabWidth = 8; }; 526 520 F5C290E60284F98E018635CA /* JavaScriptCorePrefix.h */ = {isa = PBXFileReference; fileEncoding = 30; indentWidth = 4; lastKnownFileType = sourcecode.c.h; name = JavaScriptCorePrefix.h; path = ../JavaScriptCorePrefix.h; sourceTree = "<group>"; tabWidth = 8; }; … … 838 832 isa = PBXGroup; 839 833 children = ( 834 65400C0F0A69BAF200509887 /* PropertyNameArray.cpp */, 835 65400C100A69BAF200509887 /* PropertyNameArray.h */, 840 836 938772E5038BFE19008635CE /* array_instance.h */, 841 837 F692A84D0255597D01FF60F7 /* array_object.cpp */, … … 903 899 65621E6C089E859700760F35 /* property_slot.h */, 904 900 65C02FBB0637462A003E7EE6 /* protect.h */, 905 652C107E08DA7B1E0020887D /* protected_reference.h */,906 F5341390030CEEB1018BE7F3 /* reference.cpp */,907 F5341391030CEEB1018BE7F3 /* reference.h */,908 F5341394030CF5F8018BE7F3 /* reference_list.cpp */,909 F54F0800030CD22001B5C2EB /* reference_list.h */,910 901 F692A87D0255597D01FF60F7 /* regexp.cpp */, 911 902 F692A87E0255597D01FF60F7 /* regexp.h */, … … 1030 1021 932F5B600822A1C700736975 /* config.h in Headers */, 1031 1022 932F5B610822A1C700736975 /* JavaScriptCorePrefix.h in Headers */, 1032 932F5B630822A1C700736975 /* reference_list.h in Headers */,1033 932F5B640822A1C700736975 /* reference.h in Headers */,1034 1023 932F5B650822A1C700736975 /* completion.h in Headers */, 1035 1024 932F5B660822A1C700736975 /* identifier.h in Headers */, … … 1074 1063 93E26BFE08B151D400F85226 /* ucpinternal.h in Headers */, 1075 1064 93E26C1308B1523D00F85226 /* ucptable.c in Headers */, 1076 652C107F08DA7B1E0020887D /* protected_reference.h in Headers */,1077 1065 65E217BD08E7EECC0023E5F6 /* Assertions.h in Headers */, 1078 1066 65E217C008E7EECC0023E5F6 /* FastMalloc.h in Headers */, … … 1130 1118 1440F8AE0A508D200005F061 /* JSCallbackConstructor.h in Headers */, 1131 1119 1440FCE30A51E46B0005F061 /* JSClassRef.h in Headers */, 1120 65400C120A69BAF200509887 /* PropertyNameArray.h in Headers */, 1132 1121 ); 1133 1122 runOnlyForDeploymentPostprocessing = 0; … … 1357 1346 932F5BA90822A1C700736975 /* value.cpp in Sources */, 1358 1347 932F5BAB0822A1C700736975 /* nodes2string.cpp in Sources */, 1359 932F5BAC0822A1C700736975 /* reference.cpp in Sources */,1360 932F5BAD0822A1C700736975 /* reference_list.cpp in Sources */,1361 1348 932F5BAE0822A1C700736975 /* identifier.cpp in Sources */, 1362 1349 932F5BAF0822A1C700736975 /* scope_chain.cpp in Sources */, … … 1417 1404 1440FCE40A51E46B0005F061 /* JSClassRef.cpp in Sources */, 1418 1405 1421359B0A677F4F00A8195E /* JSBase.cpp in Sources */, 1406 65400C110A69BAF200509887 /* PropertyNameArray.cpp in Sources */, 1419 1407 ); 1420 1408 runOnlyForDeploymentPostprocessing = 0; -
trunk/JavaScriptCore/kjs/array_instance.h
r15385 r15468 40 40 virtual bool deleteProperty(ExecState *exec, const Identifier &propertyName); 41 41 virtual bool deleteProperty(ExecState *exec, unsigned propertyName); 42 virtual void getProperty List(ReferenceList& propertyList, bool recursive);42 virtual void getPropertyNames(ExecState*, PropertyNameArray&); 43 43 44 44 virtual void mark(); -
trunk/JavaScriptCore/kjs/array_object.cpp
r15385 r15468 29 29 #include "lookup.h" 30 30 #include "operations.h" 31 #include " reference_list.h"31 #include "PropertyNameArray.h" 32 32 #include <wtf/HashSet.h> 33 33 #include <stdio.h> … … 200 200 } 201 201 202 void ArrayInstance::getProperty List(ReferenceList& propertyList, bool recursive)202 void ArrayInstance::getPropertyNames(ExecState* exec, PropertyNameArray& propertyNames) 203 203 { 204 204 // avoid fetching this every time through the loop 205 JSValue *undefined = jsUndefined(); 206 207 //### FIXME: should avoid duplicates with prototype 205 JSValue* undefined = jsUndefined(); 206 208 207 for (unsigned i = 0; i < storageLength; ++i) { 209 JSValue *imp= storage[i];210 if ( imp && imp != undefined) {211 property List.append(Reference(this,i));212 213 }214 return JSObject::getPropertyList(propertyList, recursive);208 JSValue* value = storage[i]; 209 if (value && value != undefined) 210 propertyNames.add(Identifier::from(i)); 211 } 212 213 JSObject::getPropertyNames(exec, propertyNames); 215 214 } 216 215 … … 244 243 245 244 if (newLength < length) { 246 ReferenceList sparseProperties; 247 248 _prop.addSparseArrayPropertiesToReferenceList(sparseProperties, this); 249 250 ReferenceListIterator it = sparseProperties.begin(); 251 while (it != sparseProperties.end()) { 252 Reference ref = it++; 245 PropertyNameArray sparseProperties; 246 247 _prop.getSparseArrayPropertyNames(sparseProperties); 248 249 PropertyNameArrayIterator end = sparseProperties.end(); 250 251 for (PropertyNameArrayIterator it = sparseProperties.begin(); it != end; ++it) { 252 Identifier name = *it; 253 253 bool ok; 254 unsigned index = ref.getPropertyName().toArrayIndex(&ok); 255 if (ok && index > newLength) { 256 ref.deleteValue(exec); 257 } 254 unsigned index = name.toArrayIndex(&ok); 255 if (ok && index > newLength) 256 deleteProperty(exec, name); 258 257 } 259 258 } … … 361 360 } 362 361 } 363 364 ReferenceList sparseProperties; 365 _prop.addSparseArrayPropertiesToReferenceList(sparseProperties, this); 366 unsigned newLength = o + sparseProperties.length(); 367 368 if (newLength > storageLength) { 369 resizeStorage(newLength); 370 } 371 372 ReferenceListIterator it = sparseProperties.begin(); 373 while (it != sparseProperties.end()) { 374 Reference ref = it++; 375 storage[o] = ref.getValue(exec); 376 JSObject::deleteProperty(exec, ref.getPropertyName()); 377 o++; 362 363 PropertyNameArray sparseProperties; 364 _prop.getSparseArrayPropertyNames(sparseProperties); 365 unsigned newLength = o + sparseProperties.size(); 366 367 if (newLength > storageLength) 368 resizeStorage(newLength); 369 370 PropertyNameArrayIterator end = sparseProperties.end(); 371 for (PropertyNameArrayIterator it = sparseProperties.begin(); it != end; ++it) { 372 Identifier name = *it; 373 storage[o] = get(exec, name); 374 JSObject::deleteProperty(exec, name); 375 o++; 378 376 } 379 377 -
trunk/JavaScriptCore/kjs/nodes.cpp
r15385 r15468 36 36 #include "lexer.h" 37 37 #include "operations.h" 38 #include " reference_list.h"38 #include "PropertyNameArray.h" 39 39 #include <wtf/HashSet.h> 40 40 #include <wtf/HashCountedSet.h> … … 1860 1860 JSObject *v; 1861 1861 Completion c; 1862 ReferenceList propertyList;1862 PropertyNameArray propertyNames; 1863 1863 1864 1864 if (varDecl) { … … 1879 1879 KJS_CHECKEXCEPTION 1880 1880 v = e->toObject(exec); 1881 v->getPropertyList(propertyList); 1882 1883 ReferenceListIterator propIt = propertyList.begin(); 1884 1885 while (propIt != propertyList.end()) { 1886 Identifier name = propIt->getPropertyName(); 1887 if (!v->hasProperty(exec, name)) { 1888 propIt++; 1889 continue; 1890 } 1891 1892 JSValue *str = jsString(name.ustring()); 1893 1894 if (lexpr->isResolveNode()) { 1881 v->getPropertyNames(exec, propertyNames); 1882 1883 PropertyNameArrayIterator end = propertyNames.end(); 1884 for (PropertyNameArrayIterator it = propertyNames.begin(); it != end; ++it) { 1885 const Identifier &name = *it; 1886 if (!v->hasProperty(exec, name)) 1887 continue; 1888 1889 JSValue *str = jsString(name.ustring()); 1890 1891 if (lexpr->isResolveNode()) { 1895 1892 const Identifier &ident = static_cast<ResolveNode *>(lexpr.get())->identifier(); 1896 1893 … … 1951 1948 } 1952 1949 } 1953 1954 propIt++;1955 1950 } 1956 1951 -
trunk/JavaScriptCore/kjs/nodes.h
r14502 r15468 35 35 class PropertyNameNode; 36 36 class PropertyListNode; 37 class Reference;38 37 class RegExp; 39 38 class SourceElementsNode; -
trunk/JavaScriptCore/kjs/object.cpp
r15385 r15468 30 30 #include "nodes.h" 31 31 #include "operations.h" 32 #include " reference_list.h"32 #include "PropertyNameArray.h" 33 33 #include <math.h> 34 34 … … 476 476 } 477 477 478 void JSObject::getProperty List(ReferenceList& propertyList, bool recursive)479 { 480 _prop.addEnumerablesToReferenceList(propertyList, this);478 void JSObject::getPropertyNames(ExecState* exec, PropertyNameArray& propertyNames) 479 { 480 _prop.getEnumerablePropertyNames(propertyNames); 481 481 482 482 // Add properties from the static hashtable of properties … … 487 487 const HashEntry *e = info->propHashTable->entries; 488 488 for (int i = 0; i < size; ++i, ++e) { 489 if ( e->s && !(e->attr & DontEnum))490 property List.append(Reference(this, e->s)); /// ######### check for duplicates with the propertymap489 if (e->s && !(e->attr & DontEnum)) 490 propertyNames.add(e->s); 491 491 } 492 492 } 493 493 info = info->parentClass; 494 494 } 495 if (_proto->isObject() && recursive)496 static_cast<JSObject*>(_proto)->getPropertyList(propertyList, recursive);495 if (_proto->isObject()) 496 static_cast<JSObject*>(_proto)->getPropertyNames(exec, propertyNames); 497 497 } 498 498 -
trunk/JavaScriptCore/kjs/object.h
r15385 r15468 39 39 class ListImp; 40 40 class InternalFunctionImp; 41 class PropertyNameArray; 41 42 42 43 // ECMA 262-3 8.6.1 … … 441 442 void setScope(const ScopeChain &s) { _scope = s; } 442 443 443 /** 444 * Returns a List of References to all the properties of the object. Used 445 * in "for x in y" statements. The list is created new, so it can be freely 446 * modified without affecting the object's properties. It should be deleted 447 * by the caller. 448 * 449 * Subclasses can override this method in ObjectImpl to provide the 450 * appearance of 451 * having extra properties other than those set specifically with put(). 452 * 453 * @param exec The current execution state 454 * @param recursive Whether or not properties in the object's prototype 455 * chain should be 456 * included in the list. 457 * @return A List of References to properties of the object. 458 **/ 459 virtual void getPropertyList(ReferenceList& propertyList, bool recursive = true); 444 virtual void getPropertyNames(ExecState*, PropertyNameArray&); 460 445 461 446 /** -
trunk/JavaScriptCore/kjs/property_map.cpp
r14951 r15468 25 25 #include "object.h" 26 26 #include "protect.h" 27 #include " reference_list.h"27 #include "PropertyNameArray.h" 28 28 #include <algorithm> 29 29 #include <wtf/FastMalloc.h> … … 75 75 76 76 // lastIndexUsed is an ever-increasing index used to identify the order items 77 // were inserted into the property map. It's vital that addEnumerablesToReferenceList77 // were inserted into the property map. It's vital that getEnumerablePropertyNames 78 78 // return the properties in the order they were added for compatibility with other 79 79 // browsers' JavaScript implementations. … … 584 584 } 585 585 586 void PropertyMap:: addEnumerablesToReferenceList(ReferenceList &list, JSObject *base) const586 void PropertyMap::getEnumerablePropertyNames(PropertyNameArray& propertyNames) const 587 587 { 588 588 if (!_table) { … … 590 590 UString::Rep *key = _singleEntry.key; 591 591 if (key && !(_singleEntry.attributes & DontEnum)) 592 list.append(Reference(base, Identifier(key)));592 propertyNames.add(Identifier(key)); 593 593 #endif 594 594 return; … … 611 611 qsort(sortedEnumerables.data(), p - sortedEnumerables.data(), sizeof(Entry*), comparePropertyMapEntryIndices); 612 612 613 // Put the keys of the sorted entries into the referencelist.613 // Put the keys of the sorted entries into the list. 614 614 for (Entry** q = sortedEnumerables.data(); q != p; ++q) 615 list.append(Reference(base, Identifier((*q)->key)));616 } 617 618 void PropertyMap:: addSparseArrayPropertiesToReferenceList(ReferenceList &list, JSObject *base) const615 propertyNames.add(Identifier(q[0]->key)); 616 } 617 618 void PropertyMap::getSparseArrayPropertyNames(PropertyNameArray& propertyNames) const 619 619 { 620 620 if (!_table) { … … 626 626 k.toUInt32(&fitsInUInt32); 627 627 if (fitsInUInt32) 628 list.append(Reference(base, Identifier(key)));628 propertyNames.add(Identifier(key)); 629 629 } 630 630 #endif … … 641 641 k.toUInt32(&fitsInUInt32); 642 642 if (fitsInUInt32) 643 list.append(Reference(base, Identifier(key)));643 propertyNames.add(Identifier(key)); 644 644 } 645 645 } -
trunk/JavaScriptCore/kjs/property_map.h
r14951 r15468 29 29 namespace KJS { 30 30 31 class PropertyNameArray; 31 32 class JSObject; 32 class ReferenceList;33 33 class JSValue; 34 34 … … 81 81 82 82 void mark() const; 83 void addEnumerablesToReferenceList(ReferenceList &, JSObject *) const;84 void addSparseArrayPropertiesToReferenceList(ReferenceList &, JSObject *) const;83 void getEnumerablePropertyNames(PropertyNameArray&) const; 84 void getSparseArrayPropertyNames(PropertyNameArray&) const; 85 85 86 86 void save(SavedProperties &) const; -
trunk/JavaScriptCore/kjs/scope_chain.cpp
r15385 r15468 22 22 #include "config.h" 23 23 #include "scope_chain.h" 24 #include "reference_list.h" 24 #include "PropertyNameArray.h" 25 #include "object.h" 25 26 26 27 namespace KJS { … … 43 44 for (ScopeChainIterator scopeIter = begin(); scopeIter != scopeEnd; ++scopeIter) { 44 45 JSObject* o = *scopeIter; 45 ReferenceList propertyList; 46 o->getPropertyList(propertyList, false); 47 ReferenceListIterator propEnd = propertyList.end(); 46 PropertyNameArray propertyNames; 47 // FIXME: should pass ExecState here! 48 o->getPropertyNames(0, propertyNames); 49 PropertyNameArrayIterator propEnd = propertyNames.end(); 48 50 49 51 fprintf(stderr, "----- [scope %p] -----\n", o); 50 for ( ReferenceListIterator propIter = propertyList.begin(); propIter != propEnd; propIter++) {51 Identifier name = propIter->getPropertyName();52 for (PropertyNameArrayIterator propIter = propertyNames.begin(); propIter != propEnd; propIter++) { 53 Identifier name = *propIter; 52 54 fprintf(stderr, "%s, ", name.ascii()); 53 55 } -
trunk/JavaScriptCore/kjs/string_object.cpp
r15385 r15468 27 27 #include "error_object.h" 28 28 #include "operations.h" 29 #include " reference_list.h"29 #include "PropertyNameArray.h" 30 30 #include "regexp_object.h" 31 31 #include <wtf/unicode/Unicode.h> … … 95 95 } 96 96 97 void StringInstance::getPropertyList(ReferenceList& propertyList, bool recursive) 98 { 99 //### FIXME: should avoid duplicates with prototype 97 void StringInstance::getPropertyNames(ExecState* exec, PropertyNameArray& propertyNames) 98 { 100 99 int size = internalValue()->getString().size(); 101 100 for (int i = 0; i < size; i++) 102 property List.append(Reference(this, i));103 return JSObject::getProperty List(propertyList, recursive);101 propertyNames.add(Identifier(UString(i))); 102 return JSObject::getPropertyNames(exec, propertyNames); 104 103 } 105 104 -
trunk/JavaScriptCore/kjs/string_object.h
r15385 r15468 32 32 StringInstance(JSObject *proto, const UString &string); 33 33 34 virtual bool getOwnPropertySlot(ExecState 35 virtual void put(ExecState *exec, const Identifier &propertyName, JSValue *value, int attr = None);36 virtual bool deleteProperty(ExecState *exec, const Identifier &propertyName);37 virtual void getProperty List(ReferenceList& propertyList, bool recursive);34 virtual bool getOwnPropertySlot(ExecState*, const Identifier&, PropertySlot&); 35 virtual void put(ExecState* exec, const Identifier& propertyName, JSValue* value, int attr = None); 36 virtual bool deleteProperty(ExecState* exec, const Identifier& propertyName); 37 virtual void getPropertyNames(ExecState*, PropertyNameArray&); 38 38 39 39 virtual const ClassInfo *classInfo() const { return &info; } -
trunk/JavaScriptCore/kjs/ustring.h
r14951 r15468 133 133 */ 134 134 unsigned char high() const { return ref().uc >> 8; } 135 135 136 private: 136 137 // not implemented, can only be constructed from UString … … 216 217 217 218 public: 219 218 220 /** 219 221 * Constructs a null string. -
trunk/JavaScriptGlue/ChangeLog
r15440 r15468 1 2006-07-15 Maciej Stachowiak <mjs@apple.com> 2 3 Reviewed by Darin. 4 5 - switch property lists to be vector+set of Identifiers instead of list of References 6 7 * JSUtils.cpp: 8 (KJSValueToCFTypeInternal): updated for JSC SPI changes 9 * JSValueWrapper.cpp: 10 (JSValueWrapper::JSObjectCopyPropertyNames): ditto 11 * UserObjectImp.cpp: 12 (UserObjectImp::getPropertyNames): ditto 13 * UserObjectImp.h: 14 1 15 === Safari-521.17 === 2 16 -
trunk/JavaScriptGlue/JSUtils.cpp
r15386 r15468 35 35 #include "JSValueWrapper.h" 36 36 #include "JSObject.h" 37 #include <JavaScriptCore/ reference_list.h>37 #include <JavaScriptCore/PropertyNameArray.h> 38 38 39 39 struct ObjectImpList { … … 295 295 JSInterpreter* intrepreter = (JSInterpreter*)exec->dynamicInterpreter(); 296 296 if (intrepreter && (intrepreter->Flags() & kJSFlagConvertAssociativeArray)) { 297 ReferenceList propList;298 object->getProperty List(propList);299 ReferenceListIterator iter = propList.begin();300 ReferenceListIterator end = propList.end();297 PropertyNameArray propNames; 298 object->getPropertyNames(exec, propNames); 299 PropertyNameArrayIterator iter = propNames.begin(); 300 PropertyNameArrayIterator end = propNames.end(); 301 301 while(iter != end && isArray) 302 302 { 303 Identifier propName = iter->getPropertyName();303 Identifier propName = *iter; 304 304 UString ustr = propName.ustring(); 305 305 const UniChar* uniChars = (const UniChar*)ustr.data(); … … 334 334 { 335 335 // Not an array, just treat it like a dictionary which contains (property name, property value) pairs 336 ReferenceList propList;337 object->getProperty List(propList);336 PropertyNameArray propNames; 337 object->getPropertyNames(exec, propNames); 338 338 { 339 339 result = CFDictionaryCreateMutable(0, … … 343 343 if (result) 344 344 { 345 ReferenceListIterator iter = propList.begin();346 ReferenceListIterator end = propList.end();345 PropertyNameArrayIterator iter = propNames.begin(); 346 PropertyNameArrayIterator end = propNames.end(); 347 347 while(iter != end) 348 348 { 349 Identifier propName = iter->getPropertyName();349 Identifier propName = *iter; 350 350 if (object->hasProperty(exec, propName)) 351 351 { -
trunk/JavaScriptGlue/JSValueWrapper.cpp
r15437 r15468 29 29 #include "config.h" 30 30 #include "JSValueWrapper.h" 31 #include "JavaScriptCore/reference_list.h"31 #include <JavaScriptCore/PropertyNameArray.h> 32 32 #include <pthread.h> 33 33 … … 119 119 ExecState* exec = getThreadGlobalExecState(); 120 120 JSObject *object = ptr->GetValue()->toObject(exec); 121 ReferenceList propList;122 object->getProperty List(propList);123 ReferenceListIterator iterator = propList.begin();124 125 while (iterator != prop List.end()) {126 Identifier name = iterator->getPropertyName();121 PropertyNameArray propNames; 122 object->getPropertyNames(exec, propNames); 123 PropertyNameArrayIterator iterator = propNames.begin(); 124 125 while (iterator != propNames.end()) { 126 Identifier name = *iterator; 127 127 CFStringRef nameStr = IdentifierToCFString(name); 128 128 -
trunk/JavaScriptGlue/UserObjectImp.cpp
r15386 r15468 29 29 #include "config.h" 30 30 #include "UserObjectImp.h" 31 #include <JavaScriptCore/ reference_list.h>31 #include <JavaScriptCore/PropertyNameArray.h> 32 32 33 33 const ClassInfo UserObjectImp::info = {"UserObject", 0, 0, 0}; … … 123 123 124 124 125 void UserObjectImp::getProperty List(ExecState *exec, ReferenceList& propertyList, bool recursive)125 void UserObjectImp::getPropertyNames(ExecState *exec, PropertyNameArray& propertyNames) 126 126 { 127 127 JSUserObject* ptr = GetJSUserObject(); … … 133 133 for (i = 0; i < count; i++) { 134 134 CFStringRef propertyName = (CFStringRef)CFArrayGetValueAtIndex(cfPropertyNames, i); 135 property List.append(Reference(this, CFStringToIdentifier(propertyName)));135 propertyNames.add(CFStringToIdentifier(propertyName)); 136 136 } 137 137 CFRelease(cfPropertyNames); 138 138 } 139 139 } 140 JSObject::getProperty List(propertyList, recursive);140 JSObject::getPropertyNames(exec, propertyNames); 141 141 } 142 142 -
trunk/JavaScriptGlue/UserObjectImp.h
r14951 r15468 45 45 virtual bool implementsCall() const; 46 46 47 virtual void getProperty List(ExecState *exec, ReferenceList& propertyList, bool recursive = true);47 virtual void getPropertyNames(ExecState*, PropertyNameArray&); 48 48 49 49 virtual JSValue *callAsFunction(ExecState *exec, JSObject *thisObj, const List &args); -
trunk/LayoutTests/ChangeLog
r15459 r15468 1 2006-07-16 Maciej Stachowiak <mjs@apple.com> 2 3 Reviewed by Darin. 4 5 - new test case and updated results for property list changes 6 7 * fast/js/for-in-avoid-duplicates-expected.txt: Added. 8 * fast/js/for-in-avoid-duplicates.html: Added. 9 * fast/js/kde/Array-expected.txt: 10 * fast/js/resources/for-in-avoid-duplicates.js: Added. 11 1 12 2006-07-15 Darin Adler <darin@apple.com> 2 13 -
trunk/LayoutTests/fast/js/kde/Array-expected.txt
r13294 r15468 66 66 PASS arr.length is maxint 67 67 PASS arr[maxint-1] is "test2" 68 FAIL propnames.length should be 3 (of type number). Was 4 (of type number). 68 PASS propnames.length is 3 69 69 PASS propnames[0] is '0' 70 70 PASS propnames[1] is '1' 71 FAIL propnames[2] should be 2 (of type string). Was 1 (of type string). 71 PASS propnames[2] is '2' 72 72 PASS successfullyParsed is true 73 73
Note: See TracChangeset
for help on using the changeset viewer.