]>
Commit | Line | Data |
---|---|---|
9dae56ea A |
1 | /* |
2 | * Copyright (C) 2006 Maks Orlovich | |
3 | * Copyright (C) 2006, 2007, 2008, 2009 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 Library 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 | * Library General Public License for more details. | |
14 | * | |
15 | * You should have received a copy of the GNU Library General Public License | |
16 | * along with this library; see the file COPYING.LIB. If not, write to | |
17 | * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | |
18 | * Boston, MA 02110-1301, USA. | |
19 | * | |
20 | */ | |
21 | ||
22 | #ifndef JSWrapperObject_h | |
23 | #define JSWrapperObject_h | |
24 | ||
25 | #include "JSObject.h" | |
26 | ||
27 | namespace JSC { | |
f9bf01c6 | 28 | |
9dae56ea A |
29 | // This class is used as a base for classes such as String, |
30 | // Number, Boolean and Date which are wrappers for primitive types. | |
31 | class JSWrapperObject : public JSObject { | |
32 | protected: | |
f9bf01c6 | 33 | explicit JSWrapperObject(NonNullPassRefPtr<Structure>); |
9dae56ea A |
34 | |
35 | public: | |
ba379fdc A |
36 | JSValue internalValue() const { return m_internalValue; } |
37 | void setInternalValue(JSValue); | |
f9bf01c6 A |
38 | |
39 | static PassRefPtr<Structure> createStructure(JSValue prototype) | |
40 | { | |
41 | return Structure::create(prototype, TypeInfo(ObjectType, StructureFlags), AnonymousSlotCount); | |
42 | } | |
43 | ||
44 | protected: | |
45 | static const unsigned AnonymousSlotCount = 1 + JSObject::AnonymousSlotCount; | |
46 | ||
9dae56ea | 47 | private: |
f9bf01c6 A |
48 | virtual void markChildren(MarkStack&); |
49 | ||
ba379fdc | 50 | JSValue m_internalValue; |
9dae56ea | 51 | }; |
f9bf01c6 A |
52 | |
53 | inline JSWrapperObject::JSWrapperObject(NonNullPassRefPtr<Structure> structure) | |
9dae56ea | 54 | : JSObject(structure) |
9dae56ea | 55 | { |
f9bf01c6 | 56 | putAnonymousValue(0, jsNull()); |
9dae56ea | 57 | } |
f9bf01c6 | 58 | |
ba379fdc | 59 | inline void JSWrapperObject::setInternalValue(JSValue value) |
9dae56ea A |
60 | { |
61 | ASSERT(value); | |
62 | ASSERT(!value.isObject()); | |
63 | m_internalValue = value; | |
f9bf01c6 | 64 | putAnonymousValue(0, value); |
9dae56ea A |
65 | } |
66 | ||
67 | } // namespace JSC | |
68 | ||
69 | #endif // JSWrapperObject_h |