Last change
on this file since 18837 was 15468, checked in by mjs, 19 years ago |
JavaScriptCore:
Reviewed by Darin.
- switch property lists to be vector+set of Identifiers instead of list of References
This has the following benefits:
- no duplicates in property lists
- simplifies API calls
- probably more efficient, since linked list is gone
- entirely removed Reference, ReferenceList and ProtectedReference types from the API
- kjs/PropertyNameArray.cpp: Added.
(KJS::PropertyNameArray::add): Check set, if not already there, add to
vector.
- kjs/PropertyNameArray.h: Added.
(KJS::PropertyNameArray::PropertyNameArray): Newly added type, combines
a set and a vector to make a unique but ordered list of identifiers.
(KJS::PropertyNameArray::begin): ditto
(KJS::PropertyNameArray::end): ditto
(KJS::PropertyNameArray::size): ditto
(KJS::PropertyNameArray::operator[]): ditto
- kjs/array_instance.h:
- kjs/array_object.cpp:
(ArrayInstance::getPropertyNames): renamed from getPropertyList, updated
for PropertyNameArray
(ArrayInstance::setLength): updated for PropertyNameArray
(ArrayInstance::pushUndefinedObjectsToEnd): ditto
- kjs/nodes.cpp:
(ForInNode::execute): updated for PropertyNameArray
- kjs/nodes.h:
- kjs/object.cpp:
(KJS::JSObject::getPropertyNames): renamed from getPropertyList, updated
for PropertyNameArray
- kjs/object.h:
- kjs/property_map.cpp:
(KJS::PropertyMap::getEnumerablePropertyNames): updated for PropertyNameArray
(KJS::PropertyMap::getSparseArrayPropertyNames): ditto
- kjs/property_map.h:
- kjs/protected_reference.h: Removed.
- kjs/reference.cpp: Removed.
- kjs/reference.h: Removed.
- kjs/reference_list.cpp: Removed.
- kjs/reference_list.h: Removed.
- kjs/scope_chain.cpp:
(KJS::ScopeChain::print): Use PropertyNamesArray instead of ReferenceList.
- kjs/string_object.cpp:
(StringInstance::getPropertyNames): Updated for new approach.
- kjs/string_object.h:
- kjs/ustring.h:
- API/APICast.h:
(toJS): Added overload for PropertyNameAccumulatorRef / PropertyNameArray*
(toRef): ditto
- API/JSBase.h:
- API/JSCallbackObject.cpp:
(KJS::JSCallbackObject::getPropertyNames): Fixed for new API.
- API/JSCallbackObject.h:
- API/JSObjectRef.cpp:
(JSPropertyNameArray::JSPropertyNameArray): Type used for a publicly vended
JSPropertyNameArrayRef.
(JSObjectCopyPropertyNames): New API call - renamed / refactored from
JSObjectCreatePropertyList
(JSPropertyNameArrayRetain): new retain call for JSPropertyNameArray.
(JSPropertyNameArrayRelease): new release call for - " -.
(JSPropertyNameArrayGetCount): Instead of having to use a stateful enumerator you
can now get the count and items in any order.
(JSPropertyNameArrayGetNameAtIndex): See above.
(JSPropertyNameAccumulatorAddName): What you add properties to is now an opaque
accumulator object.
- API/JSObjectRef.h: Prototyped new functions, removed old ones
- JavaScriptCore.exp: Updated exported symbols.
- JavaScriptCore.xcodeproj/project.pbxproj: Added new files, removed old.
- API/testapi.c:
(MyObject_getPropertyNames): Renamed / fixed callback to fit new paradigm.
(main): Updated for new API.
JavaScriptGlue:
Reviewed by Darin.
- switch property lists to be vector+set of Identifiers instead of list of References
- JSUtils.cpp:
(KJSValueToCFTypeInternal): updated for JSC SPI changes
- JSValueWrapper.cpp:
(JSValueWrapper::JSObjectCopyPropertyNames): ditto
- UserObjectImp.cpp:
(UserObjectImp::getPropertyNames): ditto
- UserObjectImp.h:
LayoutTests:
Reviewed by Darin.
- new test case and updated results for property list changes
- fast/js/for-in-avoid-duplicates-expected.txt: Added.
- fast/js/for-in-avoid-duplicates.html: Added.
- fast/js/kde/Array-expected.txt:
- fast/js/resources/for-in-avoid-duplicates.js: Added.
|
File size:
1.1 KB
|
Line | |
---|
1 | // -*- mode: c++; c-basic-offset: 4 -*-
|
---|
2 | /*
|
---|
3 | * Copyright (C) 2006 Apple Computer, Inc
|
---|
4 | *
|
---|
5 | * This library is free software; you can redistribute it and/or
|
---|
6 | * modify it under the terms of the GNU Library General Public
|
---|
7 | * License as published by the Free Software Foundation; either
|
---|
8 | * version 2 of the License, or (at your option) any later version.
|
---|
9 | *
|
---|
10 | * This library is distributed in the hope that it will be useful,
|
---|
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
---|
13 | * Library General Public License for more details.
|
---|
14 | *
|
---|
15 | * You should have received a copy of the GNU Library General Public License
|
---|
16 | * along with this library; see the file COPYING.LIB. If not, write to
|
---|
17 | * the Free Software Foundation, Inc., 51 Franklin Steet, Fifth Floor,
|
---|
18 | * Boston, MA 02110-1301, USA.
|
---|
19 | *
|
---|
20 | */
|
---|
21 |
|
---|
22 | #include "config.h"
|
---|
23 | #include "PropertyNameArray.h"
|
---|
24 |
|
---|
25 | namespace KJS {
|
---|
26 |
|
---|
27 | void PropertyNameArray::add(const Identifier& ident)
|
---|
28 | {
|
---|
29 | if (!m_set.add(ident.ustring().rep()).second)
|
---|
30 | return;
|
---|
31 |
|
---|
32 | m_vector.append(ident);
|
---|
33 | }
|
---|
34 |
|
---|
35 | } // namespace KJS
|
---|
36 |
|
---|
Note:
See
TracBrowser
for help on using the repository browser.