File indexing completed on 2024-05-12 15:43:16
0001 /* 0002 * Copyright (C) 2003,2007 Apple Computer, Inc 0003 * 0004 * This library is free software; you can redistribute it and/or 0005 * modify it under the terms of the GNU Library General Public 0006 * License as published by the Free Software Foundation; either 0007 * version 2 of the License, or (at your option) any later version. 0008 * 0009 * This library is distributed in the hope that it will be useful, 0010 * but WITHOUT ANY WARRANTY; without even the implied warranty of 0011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 0012 * Library General Public License for more details. 0013 * 0014 * You should have received a copy of the GNU Library General Public License 0015 * along with this library; see the file COPYING.LIB. If not, write to 0016 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 0017 * Boston, MA 02110-1301, USA. 0018 * 0019 */ 0020 0021 #ifndef KJS_COMMON_IDENTIFIERS_H 0022 #define KJS_COMMON_IDENTIFIERS_H 0023 0024 #include "identifier.h" 0025 #include <wtf/Noncopyable.h> 0026 0027 // List of property names, passed to a macro so we can do set them up various 0028 // ways without repeating the list. 0029 #define KJS_COMMON_IDENTIFIERS_EACH_PROPERTY_NAME(macro) \ 0030 macro(arguments) \ 0031 macro(callee) \ 0032 macro(caller) \ 0033 macro(constructor) \ 0034 macro(fromCharCode) \ 0035 macro(global) \ 0036 macro(ignoreCase) \ 0037 macro(index) \ 0038 macro(input) \ 0039 macro(lastIndex) \ 0040 macro(length) \ 0041 macro(message) \ 0042 macro(multiline) \ 0043 macro(name) \ 0044 macro(prototype) \ 0045 macro(source) \ 0046 macro(toExponential) \ 0047 macro(toFixed) \ 0048 macro(toLocaleString) \ 0049 macro(toPrecision) \ 0050 macro(toString) \ 0051 macro(valueOf) \ 0052 macro(toJSON) \ 0053 macro(configurable) \ 0054 macro(value) \ 0055 macro(writable) \ 0056 macro(enumerable) \ 0057 macro(get) \ 0058 macro(set) \ 0059 macro(toISOString) 0060 0061 namespace KJS 0062 { 0063 0064 class KJS_EXPORT CommonIdentifiers : Noncopyable 0065 { 0066 0067 private: 0068 CommonIdentifiers(); 0069 0070 public: 0071 static CommonIdentifiers *shared(); 0072 0073 const Identifier nullIdentifier; 0074 const Identifier underscoreProto; 0075 0076 #define KJS_IDENTIFIER_DECLARE_PROPERTY_NAME_GLOBAL(name) const Identifier name; 0077 KJS_COMMON_IDENTIFIERS_EACH_PROPERTY_NAME(KJS_IDENTIFIER_DECLARE_PROPERTY_NAME_GLOBAL) 0078 #undef KJS_IDENTIFIER_DECLARE_PROPERTY_NAME_GLOBAL 0079 }; 0080 } // namespace KJS 0081 0082 // ### better place in identifier.h. only here because of the shared null 0083 namespace WTF 0084 { 0085 // Provide hashing of Identifiers --- using the rep ptr 0086 struct IdentHash { 0087 static unsigned hash(const KJS::Identifier &key) 0088 { 0089 return PtrHash<KJS::UString::Rep *>::hash(key.ustring().rep()); 0090 } 0091 static bool equal(const KJS::Identifier &a, const KJS::Identifier &b) 0092 { 0093 return a == b; 0094 } 0095 static const bool safeToCompareToEmptyOrDeleted = false; 0096 }; 0097 0098 template<> struct DefaultHash<KJS::Identifier> { 0099 typedef IdentHash Hash; 0100 }; 0101 0102 template<> struct HashTraits<KJS::Identifier> : GenericHashTraits<KJS::Identifier> { 0103 static const bool emptyValueIsZero = false; 0104 static const bool needsDestruction = true; 0105 static void constructDeletedValue(KJS::Identifier *slot) 0106 { 0107 new(slot) KJS::Identifier(); 0108 } 0109 static bool isDeletedValue(const KJS::Identifier &value) 0110 { 0111 return value.isNull(); 0112 } 0113 }; 0114 0115 } // namespace WTF 0116 0117 #endif // KJS_COMMON_IDENTIFIERS_H 0118