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

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

JavaScriptCore:

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

Rubber-stamped by Darin Adler.

Rename string_object.h/cpp to StringObject.h/cpp and split out StringObjectThatMasqueradesAsUndefined,
StringConstructor and StringPrototype.

  • DerivedSources.make:
  • GNUmakefile.am:
  • JavaScriptCore.pri:
  • JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.vcproj:
  • JavaScriptCore.xcodeproj/project.pbxproj:
  • JavaScriptCoreSources.bkl:
  • kjs/AllInOneFile.cpp:
  • kjs/JSGlobalObject.cpp:
  • kjs/StringConstructor.cpp: Copied from JavaScriptCore/kjs/string_object.cpp.
  • kjs/StringConstructor.h: Copied from JavaScriptCore/kjs/string_object.h.
  • kjs/StringObject.cpp: Copied from JavaScriptCore/kjs/string_object.cpp.
  • kjs/StringObject.h: Copied from JavaScriptCore/kjs/string_object.h.
  • kjs/StringObjectThatMasqueradesAsUndefined.h: Copied from JavaScriptCore/kjs/string_object.h.
  • kjs/StringPrototype.cpp: Copied from JavaScriptCore/kjs/string_object.cpp.
  • kjs/StringPrototype.h: Copied from JavaScriptCore/kjs/string_object.h.
  • kjs/internal.cpp:
  • kjs/string_object.cpp: Removed.
  • kjs/string_object.h: Removed.

WebCore:

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

Rubber-stamped by Darin Adler.

Update includes after remaming string_object.h to StringObject.h and
splitting out StringObjectThatMasqueradesAsUndefined, StringConstructor
and StringPrototype.

  • ForwardingHeaders/kjs/StringObject.h: Copied from WebCore/ForwardingHeaders/kjs/string_object.h.
  • ForwardingHeaders/kjs/StringObjectThatMasqueradesAsUndefined.h: Added.
  • ForwardingHeaders/kjs/StringPrototype.h: Added.
  • ForwardingHeaders/kjs/string_object.h: Removed.
  • bindings/js/JSCSSStyleDeclarationCustom.cpp:
  • 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* proto)
31 : JSWrapperObject(proto)
32{
33 setInternalValue(jsString(exec, ""));
34}
35
36StringObject::StringObject(JSObject* proto, JSString* string)
37 : JSWrapperObject(proto)
38{
39 setInternalValue(string);
40}
41
42StringObject::StringObject(ExecState* exec, JSObject* proto, const UString& string)
43 : JSWrapperObject(proto)
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.