source:
webkit/trunk/JavaScriptCore/runtime/StringObject.cpp@
43122
Last change on this file since 43122 was 43122, checked in by [email protected], 16 years ago | |
---|---|
2009-05-01 Geoffrey Garen <[email protected]>
JavaScriptGlue:
2009-05-01 Geoffrey Garen <[email protected]>
WebCore:
2009-05-01 Geoffrey Garen <[email protected]>
WebKit/mac:
2009-05-01 Geoffrey Garen <[email protected]>
WebKit/qt:
2009-05-01 Geoffrey Garen <[email protected]>
WebKit/win:
2009-05-01 Geoffrey Garen <[email protected]>
WebKit/wx:
2009-05-01 Geoffrey Garen <[email protected]>
|
|
|
|
File size: 3.1 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 | |
26 | namespace JSC { |
27 | |
28 | ASSERT_CLASS_FITS_IN_CELL(StringObject); |
29 | |
30 | const ClassInfo StringObject::info = { "String", 0, 0, 0 }; |
31 | |
32 | StringObject::StringObject(ExecState* exec, PassRefPtr<Structure> structure) |
33 | : JSWrapperObject(structure) |
34 | { |
35 | setInternalValue(jsEmptyString(exec)); |
36 | } |
37 | |
38 | StringObject::StringObject(PassRefPtr<Structure> structure, JSString* string) |
39 | : JSWrapperObject(structure) |
40 | { |
41 | setInternalValue(string); |
42 | } |
43 | |
44 | StringObject::StringObject(ExecState* exec, PassRefPtr<Structure> structure, const UString& string) |
45 | : JSWrapperObject(structure) |
46 | { |
47 | setInternalValue(jsString(exec, string)); |
48 | } |
49 | |
50 | bool 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 | |
57 | bool 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 | |
64 | void StringObject::put(ExecState* exec, const Identifier& propertyName, JSValue value, PutPropertySlot& slot) |
65 | { |
66 | if (propertyName == exec->propertyNames().length) |
67 | return; |
68 | JSObject::put(exec, propertyName, value, slot); |
69 | } |
70 | |
71 | bool StringObject::deleteProperty(ExecState* exec, const Identifier& propertyName) |
72 | { |
73 | if (propertyName == exec->propertyNames().length) |
74 | return false; |
75 | return JSObject::deleteProperty(exec, propertyName); |
76 | } |
77 | |
78 | void StringObject::getPropertyNames(ExecState* exec, PropertyNameArray& propertyNames) |
79 | { |
80 | int size = internalValue()->value().size(); |
81 | for (int i = 0; i < size; ++i) |
82 | propertyNames.add(Identifier(exec, UString::from(i))); |
83 | return JSObject::getPropertyNames(exec, propertyNames); |
84 | } |
85 | |
86 | UString StringObject::toString(ExecState*) const |
87 | { |
88 | return internalValue()->value(); |
89 | } |
90 | |
91 | UString StringObject::toThisString(ExecState*) const |
92 | { |
93 | return internalValue()->value(); |
94 | } |
95 | |
96 | JSString* StringObject::toThisJSString(ExecState*) |
97 | { |
98 | return internalValue(); |
99 | } |
100 | |
101 | } // namespace JSC |