source: webkit/trunk/JavaScriptCore/kjs/StringObject.cpp@ 35027

Last change on this file since 35027 was 35027, checked in by [email protected], 17 years ago

JavaScriptCore:

2008-07-06 Sam Weinig <[email protected]>

Reviewed by Cameron Zwarich.

Second step in broad cleanup effort.

[ File list elided ]

WebCore:

2008-07-06 Sam Weinig <[email protected]>

Reviewed by Cameron Zwarich.

Add #include for kjs/protect.h.

  • xml/XMLHttpRequest.cpp: (WebCore::XMLHttpRequest::loadRequestAsynchronously):
  • Property svn:eol-style set to native
File size: 3.0 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 KJS {
27
28const ClassInfo StringObject::info = { "String", 0, 0, 0 };
29
30StringObject::StringObject(ExecState* exec, JSObject* prototype)
31 : JSWrapperObject(prototype)
32{
33 setInternalValue(jsString(exec, ""));
34}
35
36StringObject::StringObject(JSObject* prototype, JSString* string)
37 : JSWrapperObject(prototype)
38{
39 setInternalValue(string);
40}
41
42StringObject::StringObject(ExecState* exec, JSObject* prototype, const UString& string)
43 : JSWrapperObject(prototype)
44{
45 setInternalValue(jsString(exec, string));
46}
47
48bool StringObject::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot)
49{
50 if (internalValue()->getStringPropertySlot(exec, propertyName, slot))
51 return true;
52 return JSObject::getOwnPropertySlot(exec, propertyName, slot);
53}
54
55bool StringObject::getOwnPropertySlot(ExecState* exec, unsigned propertyName, PropertySlot& slot)
56{
57 if (internalValue()->getStringPropertySlot(propertyName, slot))
58 return true;
59 return JSObject::getOwnPropertySlot(exec, Identifier::from(exec, propertyName), slot);
60}
61
62void StringObject::put(ExecState* exec, const Identifier& propertyName, JSValue* value)
63{
64 if (propertyName == exec->propertyNames().length)
65 return;
66 JSObject::put(exec, propertyName, value);
67}
68
69bool StringObject::deleteProperty(ExecState* exec, const Identifier& propertyName)
70{
71 if (propertyName == exec->propertyNames().length)
72 return false;
73 return JSObject::deleteProperty(exec, propertyName);
74}
75
76void StringObject::getPropertyNames(ExecState* exec, PropertyNameArray& propertyNames)
77{
78 int size = internalValue()->value().size();
79 for (int i = 0; i < size; ++i)
80 propertyNames.add(Identifier(exec, UString::from(i)));
81 return JSObject::getPropertyNames(exec, propertyNames);
82}
83
84UString StringObject::toString(ExecState*) const
85{
86 return internalValue()->value();
87}
88
89UString StringObject::toThisString(ExecState*) const
90{
91 return internalValue()->value();
92}
93
94JSString* StringObject::toThisJSString(ExecState*)
95{
96 return internalValue();
97}
98
99} // namespace KJS
Note: See TracBrowser for help on using the repository browser.