Changeset 155407 in webkit
- Timestamp:
- Sep 9, 2013, 5:43:51 PM (13 years ago)
- Location:
- trunk/Source/WTF
- Files:
-
- 11 edited
-
ChangeLog (modified) (1 diff)
-
wtf/FilePrintStream.cpp (modified) (1 diff)
-
wtf/FilePrintStream.h (modified) (2 diffs)
-
wtf/HashTable.h (modified) (2 diffs)
-
wtf/ListHashSet.h (modified) (2 diffs)
-
wtf/OwnPtr.h (modified) (3 diffs)
-
wtf/Threading.cpp (modified) (2 diffs)
-
wtf/ThreadingPthreads.cpp (modified) (2 diffs)
-
wtf/unicode/Collator.h (modified) (2 diffs)
-
wtf/unicode/CollatorDefault.cpp (modified) (1 diff)
-
wtf/unicode/icu/CollatorICU.cpp (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WTF/ChangeLog
r155402 r155407 1 2013-09-09 Anders Carlsson <andersca@apple.com> 2 3 Introduce WTF::createOwned 4 https://bugs.webkit.org/show_bug.cgi?id=121059 5 6 Reviewed by Andreas Kling. 7 8 WTF::createOwned is a function template that does adoptPtr + new in a single function call, 9 with all the arguments being perfectly forwarded thanks to C++11. 10 11 Being forward-looking, createOwned returns an OwnPtr rather than a PassOwnPtr since the plan is 12 to get rid of PassOwnPtr and just use std::move instead. 13 14 * wtf/FilePrintStream.cpp: 15 * wtf/FilePrintStream.h: 16 * wtf/HashTable.h: 17 * wtf/ListHashSet.h: 18 * wtf/OwnPtr.h: 19 (WTF::OwnPtr::OwnPtr): 20 (WTF::createOwned): 21 (WTF::createThread): 22 (WTF::establishIdentifierForPthreadHandle): 23 (WTF::createThreadInternal): 24 (WTF::Collator::userDefault): 25 (WTF::Collator::userDefault): 26 1 27 2013-09-09 Anders Carlsson <andersca@apple.com> 2 28 -
trunk/Source/WTF/wtf/FilePrintStream.cpp
r136601 r155407 42 42 } 43 43 44 PassOwnPtr<FilePrintStream> FilePrintStream::open(const char* filename, const char* mode)44 OwnPtr<FilePrintStream> FilePrintStream::open(const char* filename, const char* mode) 45 45 { 46 46 FILE* file = fopen(filename, mode); 47 47 if (!file) 48 return PassOwnPtr<FilePrintStream>();49 50 return adoptPtr(new FilePrintStream(file));48 return nullptr; 49 50 return createOwned<FilePrintStream>(file); 51 51 } 52 52 -
trunk/Source/WTF/wtf/FilePrintStream.h
r150995 r155407 28 28 29 29 #include <stdio.h> 30 #include <wtf/PassOwnPtr.h>31 30 #include <wtf/PrintStream.h> 31 #include <wtf/OwnPtr.h> 32 32 33 33 namespace WTF { … … 43 43 virtual ~FilePrintStream(); 44 44 45 WTF_EXPORT_PRIVATE static PassOwnPtr<FilePrintStream> open(const char* filename, const char* mode);45 WTF_EXPORT_PRIVATE static OwnPtr<FilePrintStream> open(const char* filename, const char* mode); 46 46 47 47 FILE* file() { return m_file; } -
trunk/Source/WTF/wtf/HashTable.h
r155251 r155407 556 556 #if CHECK_HASHTABLE_ITERATORS 557 557 , m_iterators(0) 558 , m_mutex( adoptPtr(new Mutex))559 #endif 560 #if DUMP_HASHTABLE_STATS_PER_TABLE 561 , m_stats( adoptPtr(new Stats))558 , m_mutex(createOwned<Mutex>()) 559 #endif 560 #if DUMP_HASHTABLE_STATS_PER_TABLE 561 , m_stats(createOwned<Stats>()) 562 562 #endif 563 563 { … … 1167 1167 #if CHECK_HASHTABLE_ITERATORS 1168 1168 , m_iterators(0) 1169 , m_mutex( adoptPtr(new Mutex))1170 #endif 1171 #if DUMP_HASHTABLE_STATS_PER_TABLE 1172 , m_stats( adoptPtr(new Stats(*other.m_stats)))1169 , m_mutex(createOwned<Mutex>()) 1170 #endif 1171 #if DUMP_HASHTABLE_STATS_PER_TABLE 1172 , m_stats(createOwned<Stats>(*other.m_stats)) 1173 1173 #endif 1174 1174 { -
trunk/Source/WTF/wtf/ListHashSet.h
r154967 r155407 512 512 : m_head(0) 513 513 , m_tail(0) 514 , m_allocator( adoptPtr(new NodeAllocator))514 , m_allocator(createOwned<NodeAllocator>()) 515 515 { 516 516 } … … 520 520 : m_head(0) 521 521 , m_tail(0) 522 , m_allocator( adoptPtr(new NodeAllocator))522 , m_allocator(createOwned<NodeAllocator>()) 523 523 { 524 524 const_iterator end = other.end(); -
trunk/Source/WTF/wtf/OwnPtr.h
r155357 r155407 37 37 38 38 template<typename T> class OwnPtr { 39 #if COMPILER_SUPPORTS(CXX_RVALUE_REFERENCES)40 // If rvalue references are not supported, the copy constructor is41 // public so OwnPtr cannot be marked noncopyable. See note below.42 WTF_MAKE_NONCOPYABLE(OwnPtr);43 #endif44 39 public: 45 40 typedef typename std::remove_pointer<T>::type ValueType; … … 92 87 93 88 private: 89 explicit OwnPtr(PtrType ptr) : m_ptr(ptr) { } 90 91 template<typename U> friend OwnPtr<U> createOwned(); 92 template<typename U, typename A1> friend OwnPtr<U> createOwned(A1&&); 93 template<typename U, typename A1, typename A2> friend OwnPtr<U> createOwned(A1&&, A2&&); 94 94 95 #if !COMPILER_SUPPORTS(CXX_RVALUE_REFERENCES) 95 96 // If rvalue references are supported, noncopyable takes care of this. … … 213 214 } 214 215 216 template<typename T> 217 inline OwnPtr<T> createOwned() 218 { 219 return OwnPtr<T>(new T); 220 } 221 222 template<typename T, typename A1> 223 inline OwnPtr<T> createOwned(A1&& a1) 224 { 225 return OwnPtr<T>(new T(std::forward<A1>(a1))); 226 } 227 228 template<typename T, typename A1, typename A2> 229 inline OwnPtr<T> createOwned(A1&& a1, A2&& a2) 230 { 231 return OwnPtr<T>(new T(std::forward<A1>(a1), std::forward<A2>(a2))); 232 } 233 215 234 } // namespace WTF 216 235 217 236 using WTF::OwnPtr; 237 using WTF::createOwned; 218 238 219 239 #endif // WTF_OwnPtr_h -
trunk/Source/WTF/wtf/Threading.cpp
r148166 r155407 117 117 ThreadIdentifier createThread(ThreadFunctionWithReturnValue entryPoint, void* data, const char* name) 118 118 { 119 OwnPtr<ThreadFunctionWithReturnValueInvocation> invocation = adoptPtr(new ThreadFunctionWithReturnValueInvocation(entryPoint, data));119 auto invocation = createOwned<ThreadFunctionWithReturnValueInvocation>(entryPoint, data); 120 120 121 121 // Balanced by adoptPtr() in compatEntryPoint. … … 137 137 ThreadIdentifier createThread(ThreadFunctionWithReturnValue entryPoint, void* data) 138 138 { 139 OwnPtr<ThreadFunctionWithReturnValueInvocation> invocation = adoptPtr(new ThreadFunctionWithReturnValueInvocation(entryPoint, data));139 auto invocation = createOwned<ThreadFunctionWithReturnValueInvocation>(entryPoint, data); 140 140 141 141 // Balanced by adoptPtr() in compatEntryPoint. -
trunk/Source/WTF/wtf/ThreadingPthreads.cpp
r149980 r155407 180 180 MutexLocker locker(threadMapMutex()); 181 181 static ThreadIdentifier identifierCount = 1; 182 threadMap().add(identifierCount, adoptPtr(new PthreadState(pthreadHandle)));182 threadMap().add(identifierCount, createOwned<PthreadState>(pthreadHandle).release()); 183 183 return identifierCount++; 184 184 } … … 199 199 ThreadIdentifier createThreadInternal(ThreadFunction entryPoint, void* data, const char*) 200 200 { 201 OwnPtr<ThreadFunctionInvocation> invocation = adoptPtr(new ThreadFunctionInvocation(entryPoint, data));201 auto invocation = WTF::createOwned<ThreadFunctionInvocation>(entryPoint, data); 202 202 pthread_t threadHandle; 203 203 if (pthread_create(&threadHandle, 0, wtfThreadEntryPoint, invocation.get())) { -
trunk/Source/WTF/wtf/unicode/Collator.h
r155251 r155407 31 31 32 32 #include <wtf/Noncopyable.h> 33 #include <wtf/ PassOwnPtr.h>33 #include <wtf/OwnPtr.h> 34 34 #include <wtf/unicode/Unicode.h> 35 35 … … 49 49 WTF_EXPORT_PRIVATE void setOrderLowerFirst(bool); 50 50 51 WTF_EXPORT_PRIVATE static PassOwnPtr<Collator> userDefault();51 WTF_EXPORT_PRIVATE static OwnPtr<Collator> userDefault(); 52 52 53 53 WTF_EXPORT_PRIVATE Result collate(const ::UChar*, size_t, const ::UChar*, size_t) const; -
trunk/Source/WTF/wtf/unicode/CollatorDefault.cpp
r111778 r155407 46 46 } 47 47 48 PassOwnPtr<Collator> Collator::userDefault()48 OwnPtr<Collator> Collator::userDefault() 49 49 { 50 return adoptPtr(new Collator(0));50 return createOwned<Collator>(0); 51 51 } 52 52 -
trunk/Source/WTF/wtf/unicode/icu/CollatorICU.cpp
r149255 r155407 59 59 } 60 60 61 PassOwnPtr<Collator> Collator::userDefault()61 OwnPtr<Collator> Collator::userDefault() 62 62 { 63 63 #if OS(DARWIN) && USE(CF) … … 72 72 char buf[256]; 73 73 if (!collationOrder) 74 return adoptPtr(new Collator(""));74 return createOwned<Collator>(""); 75 75 CFStringGetCString(collationOrder, buf, sizeof(buf), kCFStringEncodingASCII); 76 return adoptPtr(new Collator(buf));76 return createOwned<Collator>(buf); 77 77 #else 78 return adoptPtr(new Collator(0));78 return createOwned<Collator>(static_cast<const char*>(0)); 79 79 #endif 80 80 }
Note:
See TracChangeset
for help on using the changeset viewer.