]> git.saurik.com Git - apple/javascriptcore.git/blame - runtime/StringObject.h
JavaScriptCore-7600.1.4.9.tar.gz
[apple/javascriptcore.git] / runtime / StringObject.h
CommitLineData
9dae56ea
A
1/*
2 * Copyright (C) 1999-2000 Harri Porten (porten@kde.org)
3 * Copyright (C) 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#ifndef StringObject_h
22#define StringObject_h
23
24#include "JSWrapperObject.h"
25#include "JSString.h"
26
27namespace JSC {
28
29 class StringObject : public JSWrapperObject {
30 public:
6fe7ccc8 31 typedef JSWrapperObject Base;
9dae56ea 32
81345200 33 static StringObject* create(VM& vm, Structure* structure)
6fe7ccc8 34 {
81345200
A
35 JSString* string = jsEmptyString(&vm);
36 StringObject* object = new (NotNull, allocateCell<StringObject>(vm.heap)) StringObject(vm, structure);
37 object->finishCreation(vm, string);
6fe7ccc8
A
38 return object;
39 }
81345200 40 static StringObject* create(VM& vm, Structure* structure, JSString* string)
6fe7ccc8 41 {
81345200
A
42 StringObject* object = new (NotNull, allocateCell<StringObject>(vm.heap)) StringObject(vm, structure);
43 object->finishCreation(vm, string);
6fe7ccc8
A
44 return object;
45 }
81345200 46 static StringObject* create(VM&, JSGlobalObject*, JSString*);
9dae56ea 47
81345200
A
48 static bool getOwnPropertySlot(JSObject*, ExecState*, PropertyName, PropertySlot&);
49 static bool getOwnPropertySlotByIndex(JSObject*, ExecState*, unsigned propertyName, PropertySlot&);
6fe7ccc8 50
93a37866
A
51 static void put(JSCell*, ExecState*, PropertyName, JSValue, PutPropertySlot&);
52 static void putByIndex(JSCell*, ExecState*, unsigned propertyName, JSValue, bool shouldThrow);
9dae56ea 53
93a37866
A
54 static bool deleteProperty(JSCell*, ExecState*, PropertyName);
55 static bool deletePropertyByIndex(JSCell*, ExecState*, unsigned propertyName);
6fe7ccc8 56 static void getOwnPropertyNames(JSObject*, ExecState*, PropertyNameArray&, EnumerationMode);
81345200 57 static bool defineOwnProperty(JSObject*, ExecState*, PropertyName, const PropertyDescriptor&, bool shouldThrow);
9dae56ea 58
81345200 59 DECLARE_EXPORT_INFO;
9dae56ea
A
60
61 JSString* internalValue() const { return asString(JSWrapperObject::internalValue());}
62
93a37866 63 static Structure* createStructure(VM& vm, JSGlobalObject* globalObject, JSValue prototype)
9dae56ea 64 {
81345200 65 return Structure::create(vm, globalObject, prototype, TypeInfo(ObjectType, StructureFlags), info());
9dae56ea
A
66 }
67
68 protected:
93a37866
A
69 JS_EXPORT_PRIVATE void finishCreation(VM&, JSString*);
70 static const unsigned StructureFlags = OverridesGetOwnPropertySlot | InterceptsGetOwnPropertySlotByIndexEvenWhenLengthIsNotZero | OverridesGetPropertyNames | JSWrapperObject::StructureFlags;
71 JS_EXPORT_PRIVATE StringObject(VM&, Structure*);
14957cd0 72 };
9dae56ea 73
ba379fdc 74 StringObject* asStringObject(JSValue);
9dae56ea 75
ba379fdc 76 inline StringObject* asStringObject(JSValue value)
9dae56ea 77 {
81345200 78 ASSERT(asObject(value)->inherits(StringObject::info()));
9dae56ea
A
79 return static_cast<StringObject*>(asObject(value));
80 }
81
81345200 82 JS_EXPORT_PRIVATE StringObject* constructString(VM&, JSGlobalObject*, JSValue);
93a37866 83
9dae56ea
A
84} // namespace JSC
85
86#endif // StringObject_h