Changeset 15468 in webkit for trunk/JavaScriptCore/API/JSObjectRef.cpp
- Timestamp:
- Jul 16, 2006, 2:06:28 PM (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
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 }
Note:
See TracChangeset
for help on using the changeset viewer.