File indexing completed on 2024-05-12 15:43:25
0001 /* 0002 * Copyright (C) 2006 Maks Orlovich <maksim@kde.org> 0003 * Copyright (C) 2006 Apple Computer, Inc. 0004 * 0005 * This library is free software; you can redistribute it and/or 0006 * modify it under the terms of the GNU Library General Public 0007 * License as published by the Free Software Foundation; either 0008 * version 2 of the License, or (at your option) any later version. 0009 * 0010 * This library is distributed in the hope that it will be useful, 0011 * but WITHOUT ANY WARRANTY; without even the implied warranty of 0012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 0013 * Library General Public License for more details. 0014 * 0015 * You should have received a copy of the GNU Library General Public License 0016 * along with this library; see the file COPYING.LIB. If not, write to 0017 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 0018 * Boston, MA 02110-1301, USA. 0019 * 0020 */ 0021 0022 #ifndef KJS_JSWrapperObject_h 0023 #define KJS_JSWrapperObject_h 0024 0025 #include "object.h" 0026 0027 namespace KJS 0028 { 0029 0030 /** 0031 This class is used as a base for classes such as String, 0032 Number, Boolean and Date which which are wrappers for primitive 0033 types. These classes stores the internal value, which is the 0034 actual value represented by the wrapper objects. 0035 */ 0036 class JSWrapperObject : public JSObject 0037 { 0038 public: 0039 JSWrapperObject(JSValue *proto); 0040 0041 /** 0042 * Returns the internal value of the object. This is used for objects such 0043 * as String and Boolean which are wrappers for native types. The internal 0044 * value is the actual value represented by the wrapper objects. 0045 * 0046 * @see ECMA 8.6.2 0047 * @return The internal value of the object 0048 */ 0049 JSValue *internalValue() const; 0050 0051 /** 0052 * Sets the internal value of the object 0053 * 0054 * @see internalValue() 0055 * 0056 * @param v The new internal value 0057 */ 0058 void setInternalValue(JSValue *v); 0059 0060 void mark() override; 0061 0062 /** 0063 * Returns the prototype this object had during construction 0064 */ 0065 JSValue *originalProto() const; 0066 private: 0067 JSValue *m_internalValue; 0068 JSValue *m_originalProto; 0069 }; 0070 0071 inline JSWrapperObject::JSWrapperObject(JSValue *proto) 0072 : JSObject(proto) 0073 , m_internalValue(nullptr) 0074 , m_originalProto(proto) 0075 { 0076 } 0077 0078 inline JSValue *JSWrapperObject::internalValue() const 0079 { 0080 return m_internalValue; 0081 } 0082 0083 inline JSValue *JSWrapperObject::originalProto() const 0084 { 0085 return m_originalProto; 0086 } 0087 0088 inline void JSWrapperObject::setInternalValue(JSValue *v) 0089 { 0090 ASSERT(v); 0091 m_internalValue = v; 0092 } 0093 0094 } // namespace KJS 0095 0096 #endif // KJS_JSWrapperObject_h