Changeset 268543 in webkit


Ignore:
Timestamp:
Oct 15, 2020 12:12:02 PM (4 years ago)
Author:
ddkilzer@apple.com
Message:

WeakObjCPtr.h is not safe to include in C++ source files
<https://webkit.org/b/217712>
<rdar://problem/70250667>

Reviewed by Darin Adler.

  • wtf/WeakObjCPtr.h:

(WTF::WeakObjCPtr::get const):

  • Move implementation outside of the class and wrap it in #ifdef OBJC/#endif. This makes the header safe to compile with other C++ sources, but will fail if get() is used in a C++ source file.
Location:
trunk/Source/WTF
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WTF/ChangeLog

    r268503 r268543  
     12020-10-15  David Kilzer  <ddkilzer@apple.com>
     2
     3        WeakObjCPtr.h is not safe to include in C++ source files
     4        <https://webkit.org/b/217712>
     5        <rdar://problem/70250667>
     6
     7        Reviewed by Darin Adler.
     8
     9        * wtf/WeakObjCPtr.h:
     10        (WTF::WeakObjCPtr::get const):
     11        - Move implementation outside of the class and wrap it in
     12          #ifdef __OBJC__/#endif.  This makes the header safe to compile
     13          with other C++ sources, but will fail if get() is used in a
     14          C++ source file.
     15
    1162020-10-14  Ryosuke Niwa  <rniwa@webkit.org>
    217
  • trunk/Source/WTF/wtf/WeakObjCPtr.h

    r234685 r268543  
    11/*
    2  * Copyright (C) 2013-2018 Apple Inc. All rights reserved.
     2 * Copyright (C) 2013-2020 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    8282    }
    8383
    84     RetainPtr<ValueType> get() const
    85     {
    86 #if __has_feature(objc_arc)
    87         return static_cast<ValueType *>(m_weakReference);
    88 #else
    89         return adoptNS(objc_loadWeakRetained(&m_weakReference));
    90 #endif
    91     }
     84    RetainPtr<ValueType> get() const;
    9285
    9386    ValueType *getAutoreleased() const
     
    111104};
    112105
     106#ifdef __OBJC__
     107template<typename T>
     108RetainPtr<typename WeakObjCPtr<T>::ValueType> WeakObjCPtr<T>::get() const
     109{
     110#if __has_feature(objc_arc)
     111    return static_cast<typename WeakObjCPtr<T>::ValueType *>(m_weakReference);
     112#else
     113    return adoptNS(objc_loadWeakRetained(&m_weakReference));
     114#endif
     115}
     116#endif
     117
    113118} // namespace WTF
    114119
Note: See TracChangeset for help on using the changeset viewer.