Changeset 11719 in webkit for trunk/JavaScriptCore
- Timestamp:
- Dec 21, 2005, 4:55:34 PM (19 years ago)
- Location:
- trunk/JavaScriptCore
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/ChangeLog
r11690 r11719 1 2005-12-21 Geoffrey Garen <[email protected]> 2 3 Reviewed by Darin. 4 5 Removed evil hack for determining if a type is an integer, replaced 6 with template metaprogramming. 7 8 * JavaScriptCore.xcodeproj/project.pbxproj: Set tab size to 2 for 9 testkjs.cpp 10 * kjs/testkjs.cpp: 11 (main): Inserted asserts to test IsInteger. FIXME: Move these to 12 KXMLCore unit tests directory when we create one. 13 * kxmlcore/HashTraits.h: 14 (KXMLCore::): Added IsInteger class for querying types. 15 1 16 2005-12-20 Maciej Stachowiak <[email protected]> 2 17 -
trunk/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj
r11667 r11719 278 278 279 279 /* Begin PBXFileReference section */ 280 45E12D8806A49B0F00E9DF84 /* testkjs.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = testkjs.cpp; sourceTree = "<group>"; };280 45E12D8806A49B0F00E9DF84 /* testkjs.cpp */ = {isa = PBXFileReference; fileEncoding = 30; indentWidth = 2; lastKnownFileType = sourcecode.cpp.cpp; path = testkjs.cpp; sourceTree = "<group>"; }; 281 281 5114F47B05E4426200D1BBBD /* runtime_root.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; name = runtime_root.cpp; path = bindings/runtime_root.cpp; sourceTree = "<group>"; }; 282 282 5114F47C05E4426200D1BBBD /* runtime_root.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = runtime_root.h; path = bindings/runtime_root.h; sourceTree = "<group>"; }; -
trunk/JavaScriptCore/kjs/testkjs.cpp
r11527 r11719 27 27 #include <string.h> 28 28 29 #include "HashTraits.h" 29 30 #include "value.h" 30 31 #include "object.h" … … 35 36 36 37 using namespace KJS; 38 using namespace KXMLCore; 37 39 38 40 class TestFunctionImp : public JSObject { … … 106 108 { 107 109 JSLock lock; 108 110 111 // Unit tests for KXMLCore::IsInteger. Don't have a better place for them now. 112 // FIXME: move these once we create a unit test directory for KXMLCore. 113 assert(IsInteger<bool>::value); 114 assert(IsInteger<char>::value); 115 assert(IsInteger<signed char>::value); 116 assert(IsInteger<unsigned char>::value); 117 assert(IsInteger<short>::value); 118 assert(IsInteger<unsigned short>::value); 119 assert(IsInteger<int>::value); 120 assert(IsInteger<unsigned int>::value); 121 assert(IsInteger<long>::value); 122 assert(IsInteger<unsigned long>::value); 123 assert(IsInteger<long long>::value); 124 assert(IsInteger<unsigned long long>::value); 125 126 assert(!IsInteger<char *>::value); 127 assert(!IsInteger<const char *>::value); 128 assert(!IsInteger<volatile char *>::value); 129 assert(!IsInteger<double>::value); 130 assert(!IsInteger<float>::value); 131 assert(!IsInteger<GlobalImp>::value); 132 109 133 JSObject *global(new GlobalImp()); 110 134 -
trunk/JavaScriptCore/kxmlcore/HashTraits.h
r11628 r11719 25 25 26 26 #include <utility> 27 #ifndef WIN3228 #include <bits/cpp_type_traits.h>29 #endif30 27 31 28 namespace KXMLCore { 32 29 33 30 using std::pair; 34 35 // FIXME: stop using this evil hack, use something supported or else specialize 36 // for all numerit cypes by hand 31 32 template <typename T> struct IsInteger { static const bool value = false; }; 33 template <> struct IsInteger<bool> { static const bool value = true; }; 34 template <> struct IsInteger<char> { static const bool value = true; }; 35 template <> struct IsInteger<signed char> { static const bool value = true; }; 36 template <> struct IsInteger<unsigned char> { static const bool value = true; }; 37 template <> struct IsInteger<short> { static const bool value = true; }; 38 template <> struct IsInteger<unsigned short> { static const bool value = true; }; 39 template <> struct IsInteger<int> { static const bool value = true; }; 40 template <> struct IsInteger<unsigned int> { static const bool value = true; }; 41 template <> struct IsInteger<long> { static const bool value = true; }; 42 template <> struct IsInteger<unsigned long> { static const bool value = true; }; 43 template <> struct IsInteger<long long> { static const bool value = true; }; 44 template <> struct IsInteger<unsigned long long> { static const bool value = true; }; 45 37 46 template<typename T> 38 47 struct HashTraits { 39 48 typedef T traitType; 40 #ifdef __GLIBCXX__ // gcc 3.4 and greater: 41 static const bool emptyValueIsZero = std::__is_integer<T>::__value; 42 #else 43 static const bool emptyValueIsZero = std::__is_integer<T>::_M_type; 44 #endif 49 static const bool emptyValueIsZero = IsInteger<T>::value; 45 50 46 51 static traitType emptyValue() {
Note:
See TracChangeset
for help on using the changeset viewer.