[webkit-changes] [47592] trunk/JavaScriptCore
Yong Li
yong.li at torchmobile.com
Thu Aug 20 14:04:14 PDT 2009
[47592] trunk/JavaScriptCoreIf derefIfNotNull() is not inline, it should be static. Otherwise, you can potentially get a build error like multiple bodies of "derefIfNotNull<foo>" are found. If this is not a problem to winscw compiler, ignore this mail.
----- Original Message -----
From: eric at webkit.org
To: webkit-changes at lists.webkit.org
Sent: Thursday, August 20, 2009 4:12 PM
Subject: [webkit-changes] [47592] trunk/JavaScriptCore
Revision 47592
Author eric at webkit.org
Date 2009-08-20 13:12:17 -0700 (Thu, 20 Aug 2009)
Log Message
2009-08-20 Yongjun Zhang <yongjun.zhang at nokia.com>
Reviewed by Eric Seidel.
https://bugs.webkit.org/show_bug.cgi?id=28054
Use a helper function to work around winscw compiler forward declaration bug
regarding templated classes.
Add parenthesis around (PassRefPtr::*UnspecifiedBoolType) to make winscw compiler
work with the default UnSpecifiedBoolType() operator, which removes the winscw
specific bool cast hack.
* wtf/PassRefPtr.h:
(WTF::derefIfNotNull):
(WTF::PassRefPtr::~PassRefPtr):Modified Paths
a.. trunk/JavaScriptCore/ChangeLog
b.. trunk/JavaScriptCore/wtf/PassRefPtr.h
Diff
Modified: trunk/JavaScriptCore/ChangeLog (47591 => 47592)
--- trunk/JavaScriptCore/ChangeLog 2009-08-20 19:56:05 UTC (rev 47591)
+++ trunk/JavaScriptCore/ChangeLog 2009-08-20 20:12:17 UTC (rev 47592)
@@ -1,3 +1,20 @@
+2009-08-20 Yongjun Zhang <yongjun.zhang at nokia.com>
+
+ Reviewed by Eric Seidel.
+
+ https://bugs.webkit.org/show_bug.cgi?id=28054
+
+ Use a helper function to work around winscw compiler forward declaration bug
+ regarding templated classes.
+
+ Add parenthesis around (PassRefPtr::*UnspecifiedBoolType) to make winscw compiler
+ work with the default UnSpecifiedBoolType() operator, which removes the winscw
+ specific bool cast hack.
+
+ * wtf/PassRefPtr.h:
+ (WTF::derefIfNotNull):
+ (WTF::PassRefPtr::~PassRefPtr):
+
2009-08-19 Yong Li <yong.li at torchmobile.com>
Reviewed by Gavin Barraclough.
Modified: trunk/JavaScriptCore/wtf/PassRefPtr.h (47591 => 47592)
--- trunk/JavaScriptCore/wtf/PassRefPtr.h 2009-08-20 19:56:05 UTC (rev 47591)
+++ trunk/JavaScriptCore/wtf/PassRefPtr.h 2009-08-20 20:12:17 UTC (rev 47592)
@@ -28,6 +28,19 @@
template<typename T> class RefPtr;
template<typename T> class PassRefPtr;
template <typename T> PassRefPtr<T> adoptRef(T*);
+
+ // Remove inline for winscw compiler to prevent the compiler agressively resolving
+ // T::deref(), which will fail compiling when PassRefPtr<T> is used as class member
+ // or function arguments before T is defined.
+ template<typename T>
+#if !COMPILER(WINSCW)
+ inline
+#endif
+ void derefIfNotNull(T* ptr)
+ {
+ if (UNLIKELY(ptr != 0))
+ ptr->deref();
+ }
template<typename T> class PassRefPtr {
public:
@@ -40,8 +53,8 @@
PassRefPtr(const PassRefPtr& o) : m_ptr(o.releaseRef()) {}
template <typename U> PassRefPtr(const PassRefPtr<U>& o) : m_ptr(o.releaseRef()) { }
- ALWAYS_INLINE ~PassRefPtr() { if (UNLIKELY(m_ptr != 0)) m_ptr->deref(); }
-
+ ALWAYS_INLINE ~PassRefPtr() { derefIfNotNull<T>(m_ptr); }
+
template <class U>
PassRefPtr(const RefPtr<U>& o) : m_ptr(o.get()) { if (T* ptr = m_ptr) ptr->ref(); }
@@ -56,12 +69,10 @@
bool operator!() const { return !m_ptr; }
// This conversion operator allows implicit conversion to bool but not to other integer types.
-#if COMPILER(WINSCW)
- operator bool() const { return m_ptr; }
-#else
- typedef T* PassRefPtr::*UnspecifiedBoolType;
+ // Parenthesis is needed for winscw compiler to resolve class qualifier in this case.
+ typedef T* (PassRefPtr::*UnspecifiedBoolType);
operator UnspecifiedBoolType() const { return m_ptr ? &PassRefPtr::m_ptr : 0; }
-#endif
+
PassRefPtr& operator=(T*);
PassRefPtr& operator=(const PassRefPtr&);
template <typename U> PassRefPtr& operator=(const PassRefPtr<U>&);
------------------------------------------------------------------------------
_______________________________________________
webkit-changes mailing list
webkit-changes at lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.webkit.org/pipermail/webkit-changes/attachments/20090820/bf0303bf/attachment-0001.html>
More information about the webkit-changes
mailing list