]>
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. | |
14957cd0 | 31 | class JSWrapperObject : public JSNonFinalObject { |
9dae56ea | 32 | public: |
6fe7ccc8 A |
33 | typedef JSNonFinalObject Base; |
34 | ||
14957cd0 A |
35 | JSValue internalValue() const; |
36 | void setInternalValue(JSGlobalData&, JSValue); | |
f9bf01c6 | 37 | |
6fe7ccc8 | 38 | static Structure* createStructure(JSGlobalData& globalData, JSGlobalObject* globalObject, JSValue prototype) |
f9bf01c6 | 39 | { |
6fe7ccc8 | 40 | return Structure::create(globalData, globalObject, prototype, TypeInfo(ObjectType, StructureFlags), &s_info); |
f9bf01c6 A |
41 | } |
42 | ||
43 | protected: | |
6fe7ccc8 | 44 | explicit JSWrapperObject(JSGlobalData&, Structure*); |
14957cd0 | 45 | static const unsigned StructureFlags = OverridesVisitChildren | JSNonFinalObject::StructureFlags; |
f9bf01c6 | 46 | |
6fe7ccc8 A |
47 | static void visitChildren(JSCell*, SlotVisitor&); |
48 | ||
9dae56ea | 49 | private: |
14957cd0 | 50 | WriteBarrier<Unknown> m_internalValue; |
9dae56ea | 51 | }; |
f9bf01c6 | 52 | |
14957cd0 A |
53 | inline JSWrapperObject::JSWrapperObject(JSGlobalData& globalData, Structure* structure) |
54 | : JSNonFinalObject(globalData, structure) | |
9dae56ea A |
55 | { |
56 | } | |
f9bf01c6 | 57 | |
14957cd0 A |
58 | inline JSValue JSWrapperObject::internalValue() const |
59 | { | |
60 | return m_internalValue.get(); | |
61 | } | |
62 | ||
63 | inline void JSWrapperObject::setInternalValue(JSGlobalData& globalData, JSValue value) | |
9dae56ea A |
64 | { |
65 | ASSERT(value); | |
66 | ASSERT(!value.isObject()); | |
14957cd0 | 67 | m_internalValue.set(globalData, this, value); |
9dae56ea A |
68 | } |
69 | ||
70 | } // namespace JSC | |
71 | ||
72 | #endif // JSWrapperObject_h |