From: dglazkov@chromium.org Date: Fri, 30 Jan 2009 22:02:04 +0000 (+0000) Subject: 2009-01-30 David Levin X-Git-Url: https://git.webkit.org/?p=WebKit-https.git;a=commitdiff_plain;h=2f61d396d920c02fcd7340388c31f14b2eb899ec 2009-01-30 David Levin Reviewed by Darin Adler. https://bugs.webkit.org/show_bug.cgi?id=23618 Templated worker tasks should be more error proof to use. Fix Chromium build. * wtf/TypeTraits.h: (WTF::IsConvertibleToInteger::IsConvertibleToDouble): Avoid "possible loss of data" warning when using Microsoft's C++ compiler by avoiding an implicit conversion of int types to doubles. git-svn-id: https://svn.webkit.org/repository/webkit/trunk@40418 268f45cc-cd09-0410-ab3c-d52691b4dbfc --- diff --git a/JavaScriptCore/ChangeLog b/JavaScriptCore/ChangeLog index 9fe3ca3cbf1a..ce633c2a0995 100644 --- a/JavaScriptCore/ChangeLog +++ b/JavaScriptCore/ChangeLog @@ -1,3 +1,16 @@ +2009-01-30 David Levin + + Reviewed by Darin Adler. + + https://bugs.webkit.org/show_bug.cgi?id=23618 + Templated worker tasks should be more error proof to use. + Fix Chromium build. + + * wtf/TypeTraits.h: + (WTF::IsConvertibleToInteger::IsConvertibleToDouble): + Avoid "possible loss of data" warning when using Microsoft's C++ compiler + by avoiding an implicit conversion of int types to doubles. + 2009-01-30 Laszlo Gombos Reviewed by Simon Hausmann. diff --git a/JavaScriptCore/wtf/TypeTraits.h b/JavaScriptCore/wtf/TypeTraits.h index c4ccf6fcf684..6b7a975336bc 100644 --- a/JavaScriptCore/wtf/TypeTraits.h +++ b/JavaScriptCore/wtf/TypeTraits.h @@ -110,21 +110,34 @@ namespace WTF { COMPILE_ASSERT(IsPod::value, WTF_IsPod_float_true); COMPILE_ASSERT(!IsPod >::value, WTF_IsPod_struct_false); - template struct IsConvertibleToInteger { - private: - typedef char YesType; - struct NoType { - char padding[8]; + template class IsConvertibleToInteger { + // Avoid "possible loss of data" warning when using Microsoft's C++ compiler + // by not converting int's to doubles. + template class IsConvertibleToDouble; + template class IsConvertibleToDouble { + public: + static const bool value = false; }; - static YesType integerCheck(int); - static NoType integerCheck(...); - static T& t; + template class IsConvertibleToDouble { + typedef char YesType; + struct NoType { + char padding[8]; + }; + + static YesType floatCheck(long double); + static NoType floatCheck(...); + static T& t; + public: + static const bool value = sizeof(floatCheck(t)) == sizeof(YesType); + }; public: - static const bool value = sizeof(integerCheck(t)) == sizeof(YesType); + static const bool value = IsInteger::value || IsConvertibleToDouble::value, T>::value; }; + enum IsConvertibleToIntegerCheck { }; + COMPILE_ASSERT(IsConvertibleToInteger::value, WTF_IsConvertibleToInteger_enum_true); COMPILE_ASSERT(IsConvertibleToInteger::value, WTF_IsConvertibleToInteger_bool_true); COMPILE_ASSERT(IsConvertibleToInteger::value, WTF_IsConvertibleToInteger_char_true); COMPILE_ASSERT(IsConvertibleToInteger::value, WTF_IsConvertibleToInteger_signed_char_true);