KJS

JSWrapperObject.h
1 /*
2  * Copyright (C) 2006 Maks Orlovich <[email protected]>
3  * Copyright (C) 2006 Apple Computer, Inc.
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 KJS_JSWrapperObject_h
23 #define KJS_JSWrapperObject_h
24 
25 #include "object.h"
26 
27 namespace KJS
28 {
29 
30 /**
31  This class is used as a base for classes such as String,
32  Number, Boolean and Date which which are wrappers for primitive
33  types. These classes stores the internal value, which is the
34  actual value represented by the wrapper objects.
35 */
36 class JSWrapperObject : public JSObject
37 {
38 public:
39  JSWrapperObject(JSValue *proto);
40 
41  /**
42  * Returns the internal value of the object. This is used for objects such
43  * as String and Boolean which are wrappers for native types. The internal
44  * value is the actual value represented by the wrapper objects.
45  *
46  * @see ECMA 8.6.2
47  * @return The internal value of the object
48  */
49  JSValue *internalValue() const;
50 
51  /**
52  * Sets the internal value of the object
53  *
54  * @see internalValue()
55  *
56  * @param v The new internal value
57  */
58  void setInternalValue(JSValue *v);
59 
60  void mark() override;
61 
62  /**
63  * Returns the prototype this object had during construction
64  */
65  JSValue *originalProto() const;
66 private:
67  JSValue *m_internalValue;
68  JSValue *m_originalProto;
69 };
70 
71 inline JSWrapperObject::JSWrapperObject(JSValue *proto)
72  : JSObject(proto)
73  , m_internalValue(nullptr)
74  , m_originalProto(proto)
75 {
76 }
77 
79 {
80  return m_internalValue;
81 }
82 
84 {
85  return m_originalProto;
86 }
87 
89 {
90  ASSERT(v);
91  m_internalValue = v;
92 }
93 
94 } // namespace KJS
95 
96 #endif // KJS_JSWrapperObject_h
JSValue is the base type for all primitives (Undefined, Null, Boolean, String, Number) and objects in...
Definition: value.h:58
JSValue * internalValue() const
Returns the internal value of the object.
void setInternalValue(JSValue *v)
Sets the internal value of the object.
This class is used as a base for classes such as String, Number, Boolean and Date which which are wra...
JSValue * originalProto() const
Returns the prototype this object had during construction.
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Sat Dec 2 2023 03:59:16 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.