Diff
Modified: trunk/Source/WTF/ChangeLog (215449 => 215450)
--- trunk/Source/WTF/ChangeLog 2017-04-18 04:55:40 UTC (rev 215449)
+++ trunk/Source/WTF/ChangeLog 2017-04-18 05:37:45 UTC (rev 215450)
@@ -1,3 +1,19 @@
+2017-04-17 Alex Christensen <[email protected]>
+
+ Allow Variants of RetainPtrs
+ https://bugs.webkit.org/show_bug.cgi?id=170923
+
+ Reviewed by Tim Horton and Sam Weinig.
+
+ * wtf/RetainPtr.h:
+ (WTF::RetainPtr::operator&): Deleted.
+ Operator& was causing a compile error when making Variant<RetainPtr<T>, ...>
+ and because it is strange and only used once, let's just remove it.
+ * wtf/Variant.h:
+ (WTF::get):
+ (WTF::get_if):
+ Use std::addressof instead of operator& which could be overloaded to return any type with any meaning.
+
2017-04-17 Youenn Fablet <[email protected]>
Disable outdated WritableStream API
Modified: trunk/Source/WTF/wtf/RetainPtr.h (215449 => 215450)
--- trunk/Source/WTF/wtf/RetainPtr.h 2017-04-18 04:55:40 UTC (rev 215449)
+++ trunk/Source/WTF/wtf/RetainPtr.h 2017-04-18 05:37:45 UTC (rev 215450)
@@ -88,18 +88,6 @@
bool operator!() const { return !m_ptr; }
-#if !(defined (__OBJC__) && __has_feature(objc_arc))
- // This function is useful for passing RetainPtrs to functions that return
- // CF types as out parameters.
- PtrType* operator&()
- {
- // Require that the pointer is null, to prevent leaks.
- ASSERT(!m_ptr);
-
- return (PtrType*)&m_ptr;
- }
-#endif
-
// This conversion operator allows implicit conversion to bool but not to other integer types.
typedef StorageType RetainPtr::*UnspecifiedBoolType;
operator UnspecifiedBoolType() const { return m_ptr ? &RetainPtr::m_ptr : nullptr; }
Modified: trunk/Source/WTF/wtf/Variant.h (215449 => 215450)
--- trunk/Source/WTF/wtf/Variant.h 2017-04-18 04:55:40 UTC (rev 215449)
+++ trunk/Source/WTF/wtf/Variant.h 2017-04-18 05:37:45 UTC (rev 215450)
@@ -1788,8 +1788,8 @@
constexpr typename __indexed_type<_Index,_Types...>::__type const& get(Variant<_Types...> const& __v){
return *(
(_Index!=__v.index())
- ? &__throw_bad_variant_access<typename __indexed_type<_Index,_Types...>::__type const&>("Bad Variant index in get")
- : &__variant_accessor<_Index,_Types...>::get(__v)
+ ? std::addressof(__throw_bad_variant_access<typename __indexed_type<_Index,_Types...>::__type const&>("Bad Variant index in get"))
+ : std::addressof(__variant_accessor<_Index,_Types...>::get(__v))
);
}
@@ -1797,8 +1797,8 @@
constexpr typename __indexed_type<_Index,_Types...>::__type& get(Variant<_Types...>& __v){
return *(
(_Index!=__v.index())
- ? &__throw_bad_variant_access<typename __indexed_type<_Index,_Types...>::__type&>("Bad Variant index in get")
- : &__variant_accessor<_Index,_Types...>::get(__v)
+ ? std::addressof(__throw_bad_variant_access<typename __indexed_type<_Index,_Types...>::__type&>("Bad Variant index in get"))
+ : std::addressof(__variant_accessor<_Index,_Types...>::get(__v))
);
}
@@ -1818,18 +1818,18 @@
template<typename _Type,typename ... _Types>
constexpr std::add_pointer_t<_Type> get_if(Variant<_Types...>& __v){
- return (__type_index<_Type,_Types...>::__value!=__v.index())?nullptr:&get<_Type>(__v);
+ return (__type_index<_Type,_Types...>::__value!=__v.index())?nullptr:std::addressof(get<_Type>(__v));
}
template<typename _Type,typename ... _Types>
constexpr std::add_pointer_t<_Type const> get_if(Variant<_Types...> const& __v){
- return (__type_index<_Type,_Types...>::__value!=__v.index())?nullptr:&get<_Type>(__v);
+ return (__type_index<_Type,_Types...>::__value!=__v.index())?nullptr:std::addressof(get<_Type>(__v));
}
template<ptrdiff_t _Index,typename ... _Types>
constexpr std::add_pointer_t<typename __indexed_type<_Index,_Types...>::__type> get_if(Variant<_Types...>& __v){
return ((_Index!=__v.index())?nullptr:
- &__variant_accessor<_Index,_Types...>::get(__v));
+ std::addressof(__variant_accessor<_Index,_Types...>::get(__v)));
}
template<ptrdiff_t _Index,typename ... _Types>
@@ -1836,7 +1836,7 @@
constexpr std::add_pointer_t<typename __indexed_type<_Index,_Types...>::__type const> get_if(
Variant<_Types...> const& __v){
return ((_Index!=__v.index())?nullptr:
- &__variant_accessor<_Index,_Types...>::get(__v));
+ std::addressof(__variant_accessor<_Index,_Types...>::get(__v)));
}
template<typename _Type,typename ... _Types>
Modified: trunk/Source/WebCore/ChangeLog (215449 => 215450)
--- trunk/Source/WebCore/ChangeLog 2017-04-18 04:55:40 UTC (rev 215449)
+++ trunk/Source/WebCore/ChangeLog 2017-04-18 05:37:45 UTC (rev 215450)
@@ -1,3 +1,16 @@
+2017-04-17 Alex Christensen <[email protected]>
+
+ Allow Variants of RetainPtrs
+ https://bugs.webkit.org/show_bug.cgi?id=170923
+
+ Reviewed by Tim Horton and Sam Weinig.
+
+ No change in behavior. Just updated the one class that used RetainPtr::operator& to cleanly initialize
+ RetainPtrs instead of taking the address of a smart pointer and forcing a value inside of it.
+
+ * platform/mac/SSLKeyGeneratorMac.mm:
+ (WebCore::signedPublicKeyAndChallengeString):
+
2017-04-17 Fujii Hironori <[email protected]>
[WinCairo] 'WebCore::GraphicsLayerTextureMapper::flushCompositingStated': method with override specifier 'override' did not override any base class methods
Modified: trunk/Source/WebCore/platform/mac/SSLKeyGeneratorMac.mm (215449 => 215450)
--- trunk/Source/WebCore/platform/mac/SSLKeyGeneratorMac.mm 2017-04-18 04:55:40 UTC (rev 215449)
+++ trunk/Source/WebCore/platform/mac/SSLKeyGeneratorMac.mm 2017-04-18 05:37:45 UTC (rev 215450)
@@ -128,20 +128,23 @@
SignedPublicKeyAndChallenge signedPublicKeyAndChallenge { };
- RetainPtr<SecAccessRef> access;
- if (SecAccessCreate(keyDescription.createCFString().get(), nullptr, &access) != noErr)
+ SecAccessRef accessRef { nullptr };
+ if (SecAccessCreate(keyDescription.createCFString().get(), nullptr, &accessRef) != noErr)
return String();
+ RetainPtr<SecAccessRef> access = adoptCF(accessRef);
- RetainPtr<CFArrayRef> acls;
- if (SecAccessCopySelectedACLList(access.get(), CSSM_ACL_AUTHORIZATION_DECRYPT, &acls) != noErr)
+ CFArrayRef aclsRef { nullptr };
+ if (SecAccessCopySelectedACLList(access.get(), CSSM_ACL_AUTHORIZATION_DECRYPT, &aclsRef) != noErr)
return String();
+ RetainPtr<CFArrayRef> acls = adoptCF(aclsRef);
SecACLRef acl = (SecACLRef)(CFArrayGetValueAtIndex(acls.get(), 0));
// Passing nullptr to SecTrustedApplicationCreateFromPath tells that function to assume the application bundle.
- RetainPtr<SecTrustedApplicationRef> trustedApp;
- if (SecTrustedApplicationCreateFromPath(nullptr, &trustedApp) != noErr)
+ SecTrustedApplicationRef trustedAppRef { nullptr };
+ if (SecTrustedApplicationCreateFromPath(nullptr, &trustedAppRef) != noErr)
return String();
+ RetainPtr<SecTrustedApplicationRef> trustedApp = adoptCF(trustedAppRef);
const CSSM_ACL_KEYCHAIN_PROMPT_SELECTOR defaultSelector = {
CSSM_ACL_KEYCHAIN_PROMPT_CURRENT_VERSION, 0
@@ -149,10 +152,12 @@
if (SecACLSetSimpleContents(acl, (__bridge CFArrayRef)@[ (__bridge id)trustedApp.get() ], keyDescription.createCFString().get(), &defaultSelector) != noErr)
return String();
- RetainPtr<SecKeyRef> publicKey;
- RetainPtr<SecKeyRef> privateKey;
- if (SecKeyCreatePair(nullptr, CSSM_ALGID_RSA, keySize, 0, CSSM_KEYUSE_ANY, CSSM_KEYATTR_PERMANENT | CSSM_KEYATTR_EXTRACTABLE | CSSM_KEYATTR_RETURN_REF, CSSM_KEYUSE_ANY, CSSM_KEYATTR_SENSITIVE | CSSM_KEYATTR_RETURN_REF | CSSM_KEYATTR_PERMANENT | CSSM_KEYATTR_EXTRACTABLE, access.get(), &publicKey, &privateKey) != noErr)
+ SecKeyRef publicKeyRef { nullptr };
+ SecKeyRef privateKeyRef { nullptr };
+ if (SecKeyCreatePair(nullptr, CSSM_ALGID_RSA, keySize, 0, CSSM_KEYUSE_ANY, CSSM_KEYATTR_PERMANENT | CSSM_KEYATTR_EXTRACTABLE | CSSM_KEYATTR_RETURN_REF, CSSM_KEYUSE_ANY, CSSM_KEYATTR_SENSITIVE | CSSM_KEYATTR_RETURN_REF | CSSM_KEYATTR_PERMANENT | CSSM_KEYATTR_EXTRACTABLE, access.get(), &publicKeyRef, &privateKeyRef) != noErr)
return String();
+ RetainPtr<SecKeyRef> publicKey = adoptCF(publicKeyRef);
+ RetainPtr<SecKeyRef> privateKey = adoptCF(privateKeyRef);
CSSM_CSP_HANDLE cspHandle;
if (SecKeyGetCSPHandle(privateKey.get(), &cspHandle) != noErr)
Modified: trunk/Tools/ChangeLog (215449 => 215450)
--- trunk/Tools/ChangeLog 2017-04-18 04:55:40 UTC (rev 215449)
+++ trunk/Tools/ChangeLog 2017-04-18 05:37:45 UTC (rev 215450)
@@ -1,3 +1,15 @@
+2017-04-17 Alex Christensen <[email protected]>
+
+ Allow Variants of RetainPtrs
+ https://bugs.webkit.org/show_bug.cgi?id=170923
+
+ Reviewed by Tim Horton and Sam Weinig.
+
+ * TestWebKitAPI/Tests/WTF/Variant.cpp:
+ (TestWebKitAPI::TEST):
+ Add tests for RetainPtr and for another class with overloaded operator& to verify such classes can
+ work in Variants.
+
2017-04-17 Brady Eidson <[email protected]>
Make WKHTTPCookieStore public.
Modified: trunk/Tools/TestWebKitAPI/Tests/WTF/Variant.cpp (215449 => 215450)
--- trunk/Tools/TestWebKitAPI/Tests/WTF/Variant.cpp 2017-04-18 04:55:40 UTC (rev 215449)
+++ trunk/Tools/TestWebKitAPI/Tests/WTF/Variant.cpp 2017-04-18 05:37:45 UTC (rev 215450)
@@ -109,6 +109,34 @@
EXPECT_TRUE(Type::String == type);
}
+#if USE(CF)
+TEST(WTF_Variant, RetainPtr)
+{
+ enum class Type {
+ None,
+ RefPtr,
+ RetainPtr,
+ };
+
+ Type type = Type::None;
+
+ auto visitor = WTF::makeVisitor(
+ [&](const RefPtr<RefLogger>&) { type = Type::RefPtr; },
+ [&](const RetainPtr<CFDataRef>&) { type = Type::RetainPtr; }
+ );
+
+ RefPtr<RefLogger> refPtr;
+ RetainPtr<CFDataRef> retainPtr;
+ Variant<RefPtr<RefLogger>, RetainPtr<CFDataRef>> variant(WTFMove(refPtr));
+ WTF::visit(visitor, variant);
+ EXPECT_TRUE(Type::RefPtr == type);
+
+ variant = WTFMove(retainPtr);
+ WTF::visit(visitor, variant);
+ EXPECT_TRUE(Type::RetainPtr == type);
+}
+#endif
+
TEST(WTF_Variant, VisitorUsingMakeVisitor)
{
enum class Type {
@@ -225,4 +253,23 @@
ASSERT_STREQ("ref(a) deref(a) ", takeLogStr().c_str());
}
+template<class T>
+class Holder {
+public:
+ T data;
+
+ Holder(T data) : data(data) { }
+
+ T* operator&() { return &data; }
+};
+
+TEST(WTF_Variant, OperatorAmpersand)
+{
+ Variant<Holder<int>, int> v = Holder<int>(10);
+ EXPECT_TRUE(WTF::get<Holder<int>>(v).data == 10);
+
+ v = 20;
+ EXPECT_TRUE(WTF::get<int>(v) == 20);
}
+
+}