source: webkit/trunk/JavaScriptCore/runtime/StringObject.cpp@ 62677

Last change on this file since 62677 was 53170, checked in by [email protected], 15 years ago

2010-01-12 Kent Hansen <[email protected]>

Reviewed by Geoffrey Garen.

[ES5] Implement Object.getOwnPropertyNames
https://bugs.webkit.org/show_bug.cgi?id=32242

Add an extra argument to getPropertyNames() and getOwnPropertyNames()
(and all reimplementations thereof) that indicates whether non-enumerable
properties should be added.

  • API/JSCallbackObject.h:
  • API/JSCallbackObjectFunctions.h: (JSC::::getOwnPropertyNames):
  • JavaScriptCore.exp:
  • JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.def:
  • debugger/DebuggerActivation.cpp: (JSC::DebuggerActivation::getOwnPropertyNames):
  • debugger/DebuggerActivation.h:
  • runtime/Arguments.cpp: (JSC::Arguments::getOwnPropertyNames):
  • runtime/Arguments.h:
  • runtime/CommonIdentifiers.h:
  • runtime/JSArray.cpp: (JSC::JSArray::getOwnPropertyNames):
  • runtime/JSArray.h:
  • runtime/JSByteArray.cpp: (JSC::JSByteArray::getOwnPropertyNames):
  • runtime/JSByteArray.h:
  • runtime/JSFunction.cpp: (JSC::JSFunction::getOwnPropertyNames):
  • runtime/JSFunction.h:
  • runtime/JSNotAnObject.cpp: (JSC::JSNotAnObject::getOwnPropertyNames):
  • runtime/JSNotAnObject.h:
  • runtime/JSObject.cpp: (JSC::getClassPropertyNames): (JSC::JSObject::getPropertyNames): (JSC::JSObject::getOwnPropertyNames):
  • runtime/JSObject.h:
  • runtime/JSVariableObject.cpp: (JSC::JSVariableObject::getOwnPropertyNames):
  • runtime/JSVariableObject.h:
  • runtime/ObjectConstructor.cpp: (JSC::ObjectConstructor::ObjectConstructor): (JSC::objectConstructorGetOwnPropertyNames):
  • runtime/RegExpMatchesArray.h: (JSC::RegExpMatchesArray::getOwnPropertyNames):
  • runtime/StringObject.cpp: (JSC::StringObject::getOwnPropertyNames):
  • runtime/StringObject.h:
  • runtime/Structure.cpp: Rename getEnumerablePropertyNames() to getPropertyNames(), which takes an extra argument. (JSC::Structure::getPropertyNames):
  • runtime/Structure.h: (JSC::):

2010-01-12 Kent Hansen <[email protected]>

Reviewed by Geoffrey Garen.

[ES5] Implement Object.getOwnPropertyNames
https://bugs.webkit.org/show_bug.cgi?id=32242

Add new argument to the reimplementation of getOwnPropertyNames().

  • UserObjectImp.cpp: (UserObjectImp::getOwnPropertyNames):
  • UserObjectImp.h:

2010-01-12 Kent Hansen <[email protected]>

Reviewed by Geoffrey Garen.

[ES5] Implement Object.getOwnPropertyNames
https://bugs.webkit.org/show_bug.cgi?id=32242

Add tests for Object.getOwnPropertyNames(o), both standard usage and cross origin.

  • fast/js/Object-getOwnPropertyNames-expected.txt: Added.
  • fast/js/Object-getOwnPropertyNames.html: Added.
  • fast/js/script-tests/Object-getOwnPropertyNames.js: Added.
  • http/tests/security/cross-frame-access-enumeration-expected.txt:
  • http/tests/security/cross-frame-access-enumeration.html:

2010-01-12 Kent Hansen <[email protected]>

Reviewed by Geoffrey Garen.

[ES5] Implement Object.getOwnPropertyNames
https://bugs.webkit.org/show_bug.cgi?id=32242

Add new argument to reimplementations of getPropertyNames()
and getOwnPropertyNames(), and update the JS bindings generator.

Test: fast/js/Object-getOwnPropertyNames.html

  • bindings/js/JSDOMWindowCustom.cpp: (WebCore::JSDOMWindow::getPropertyNames): (WebCore::JSDOMWindow::getOwnPropertyNames):
  • bindings/js/JSDOMWindowShell.cpp: (WebCore::JSDOMWindowShell::getPropertyNames): (WebCore::JSDOMWindowShell::getOwnPropertyNames):
  • bindings/js/JSDOMWindowShell.h:
  • bindings/js/JSHistoryCustom.cpp: (WebCore::JSHistory::getOwnPropertyNames):
  • bindings/js/JSLocationCustom.cpp: (WebCore::JSLocation::getOwnPropertyNames):
  • bindings/js/JSQuarantinedObjectWrapper.cpp: (WebCore::JSQuarantinedObjectWrapper::getPropertyNames): (WebCore::JSQuarantinedObjectWrapper::getOwnPropertyNames):
  • bindings/js/JSQuarantinedObjectWrapper.h:
  • bindings/js/JSStorageCustom.cpp: (WebCore::JSStorage::getOwnPropertyNames):
  • bindings/scripts/CodeGeneratorJS.pm:
  • bridge/runtime_array.cpp: (JSC::RuntimeArray::getOwnPropertyNames):
  • bridge/runtime_array.h:
  • bridge/runtime_object.cpp: (JSC::RuntimeObjectImp::getPropertyNames): (JSC::RuntimeObjectImp::getOwnPropertyNames):
  • bridge/runtime_object.h:
  • Property svn:eol-style set to native
File size: 3.5 KB
Line 
1/*
2 * Copyright (C) 1999-2001 Harri Porten ([email protected])
3 * Copyright (C) 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved.
4 *
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser 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 * Lesser General Public License for more details.
14 *
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18 *
19 */
20
21#include "config.h"
22#include "StringObject.h"
23
24#include "PropertyNameArray.h"
25
26namespace JSC {
27
28ASSERT_CLASS_FITS_IN_CELL(StringObject);
29
30const ClassInfo StringObject::info = { "String", 0, 0, 0 };
31
32StringObject::StringObject(ExecState* exec, NonNullPassRefPtr<Structure> structure)
33 : JSWrapperObject(structure)
34{
35 setInternalValue(jsEmptyString(exec));
36}
37
38StringObject::StringObject(NonNullPassRefPtr<Structure> structure, JSString* string)
39 : JSWrapperObject(structure)
40{
41 setInternalValue(string);
42}
43
44StringObject::StringObject(ExecState* exec, NonNullPassRefPtr<Structure> structure, const UString& string)
45 : JSWrapperObject(structure)
46{
47 setInternalValue(jsString(exec, string));
48}
49
50bool StringObject::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot)
51{
52 if (internalValue()->getStringPropertySlot(exec, propertyName, slot))
53 return true;
54 return JSObject::getOwnPropertySlot(exec, propertyName, slot);
55}
56
57bool StringObject::getOwnPropertySlot(ExecState* exec, unsigned propertyName, PropertySlot& slot)
58{
59 if (internalValue()->getStringPropertySlot(exec, propertyName, slot))
60 return true;
61 return JSObject::getOwnPropertySlot(exec, Identifier::from(exec, propertyName), slot);
62}
63
64bool StringObject::getOwnPropertyDescriptor(ExecState* exec, const Identifier& propertyName, PropertyDescriptor& descriptor)
65{
66 if (internalValue()->getStringPropertyDescriptor(exec, propertyName, descriptor))
67 return true;
68 return JSObject::getOwnPropertyDescriptor(exec, propertyName, descriptor);
69}
70
71void StringObject::put(ExecState* exec, const Identifier& propertyName, JSValue value, PutPropertySlot& slot)
72{
73 if (propertyName == exec->propertyNames().length)
74 return;
75 JSObject::put(exec, propertyName, value, slot);
76}
77
78bool StringObject::deleteProperty(ExecState* exec, const Identifier& propertyName)
79{
80 if (propertyName == exec->propertyNames().length)
81 return false;
82 bool isStrictUInt32;
83 unsigned i = propertyName.toStrictUInt32(&isStrictUInt32);
84 if (isStrictUInt32 && internalValue()->canGetIndex(i))
85 return false;
86 return JSObject::deleteProperty(exec, propertyName);
87}
88
89void StringObject::getOwnPropertyNames(ExecState* exec, PropertyNameArray& propertyNames, EnumerationMode mode)
90{
91 int size = internalValue()->length();
92 for (int i = 0; i < size; ++i)
93 propertyNames.add(Identifier(exec, UString::from(i)));
94 if (mode == IncludeDontEnumProperties)
95 propertyNames.add(exec->propertyNames().length);
96 return JSObject::getOwnPropertyNames(exec, propertyNames, mode);
97}
98
99} // namespace JSC
Note: See TracBrowser for help on using the repository browser.