WebKit Bugzilla
New
Browse
Search+
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
[patch]
Patch
bug-62642-20110614132510.patch (text/plain), 7.33 KB, created by
Raphael Kubo da Costa (:rakuco)
on 2011-06-14 09:21:48 PDT
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Raphael Kubo da Costa (:rakuco)
Created:
2011-06-14 09:21:48 PDT
Size:
7.33 KB
patch
obsolete
>diff --git a/Source/JavaScriptCore/ChangeLog b/Source/JavaScriptCore/ChangeLog >index 6b2849c95981ac91c24087ee49c547905b870c9a..2e6ae61754f4dc4534a1382bd341d476c13c8568 100644 >--- a/Source/JavaScriptCore/ChangeLog >+++ b/Source/JavaScriptCore/ChangeLog >@@ -1,3 +1,38 @@ >+2011-06-14 Raphael Kubo da Costa <kubo@profusion.mobi> >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ [Efl] Add EflOwnPtr.h. >+ https://bugs.webkit.org/show_bug.cgi?id=62642 >+ >+ It works similarly to GOwnPtr and OwnPtr, but calls free() instead of >+ g_free() and delete to free memory. >+ >+ It can also be used to put Evas_Object's in smart pointer as well, >+ taking care of calling evas_object_del() when needed. >+ >+ * wtf/CMakeListsEfl.txt: >+ * wtf/efl/EflOwnPtr.cpp: Added. >+ (WTF::Evas_Object): >+ * wtf/efl/EflOwnPtr.h: Added. >+ (WTF::EflOwnPtr::EflOwnPtr): >+ (WTF::EflOwnPtr::~EflOwnPtr): >+ (WTF::EflOwnPtr::get): >+ (WTF::EflOwnPtr::release): >+ (WTF::EflOwnPtr::outPtr): >+ (WTF::EflOwnPtr::set): >+ (WTF::EflOwnPtr::clear): >+ (WTF::EflOwnPtr::operator*): >+ (WTF::EflOwnPtr::operator->): >+ (WTF::EflOwnPtr::operator!): >+ (WTF::EflOwnPtr::operator UnspecifiedBoolType): >+ (WTF::EflOwnPtr::swap): >+ (WTF::swap): >+ (WTF::operator==): >+ (WTF::operator!=): >+ (WTF::getPtr): >+ (WTF::freeOwned): >+ > 2011-05-31 Oliver Hunt <oliver@apple.com> > > Reviewed by Geoffrey Garen. >diff --git a/Source/JavaScriptCore/wtf/CMakeListsEfl.txt b/Source/JavaScriptCore/wtf/CMakeListsEfl.txt >index 56e678619c7f03d3f59ef7f3f0abb1cbc3f24f03..1cae09f0c2b7cdb36f8a93b895a56b0cc9fd12b7 100644 >--- a/Source/JavaScriptCore/wtf/CMakeListsEfl.txt >+++ b/Source/JavaScriptCore/wtf/CMakeListsEfl.txt >@@ -8,6 +8,7 @@ ENDIF() > > LIST(APPEND WTF_SOURCES > efl/MainThreadEfl.cpp >+ efl/EflOwnPtr.cpp > > OSAllocatorPosix.cpp > ThreadIdentifierDataPthreads.cpp >@@ -39,10 +40,12 @@ LIST(APPEND WTF_LIBRARIES > > LIST(APPEND WTF_LINK_FLAGS > ${ECORE_LDFLAGS} >+ ${EVAS_LDFLAGS} > ) > > LIST(APPEND WTF_INCLUDE_DIRECTORIES > ${ECORE_INCLUDE_DIRS} >+ ${EVAS_INCLUDE_DIRS} > ${ICU_INCLUDE_DIRS} > ${JAVASCRIPTCORE_DIR}/wtf/unicode/ > ) >diff --git a/Source/JavaScriptCore/wtf/efl/EflOwnPtr.cpp b/Source/JavaScriptCore/wtf/efl/EflOwnPtr.cpp >new file mode 100644 >index 0000000000000000000000000000000000000000..cb28de5a82a82fc02489a8b3674257d5852184f9 >--- /dev/null >+++ b/Source/JavaScriptCore/wtf/efl/EflOwnPtr.cpp >@@ -0,0 +1,34 @@ >+/* >+ * Copyright (C) 2011 ProFUSION embedded systems >+ * Copyright (C) 2011 Samsung Electronics >+ * >+ * This library is free software; you can redistribute it and/or >+ * modify it under the terms of the GNU Library General Public >+ * License as published by the Free Software Foundation; either >+ * version 2 of the License, or (at your option) any later version. >+ * >+ * This library is distributed in the hope that it will be useful, >+ * but WITHOUT ANY WARRANTY; without even the implied warranty of >+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU >+ * Library General Public License for more details. >+ * >+ * You should have received a copy of the GNU Library General Public License >+ * along with this library; see the file COPYING.LIB. If not, write to >+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, >+ * Boston, MA 02110-1301, USA. >+ * >+ */ >+ >+#include "config.h" >+#include "EflOwnPtr.h" >+ >+#include <Evas.h> >+ >+namespace WTF { >+ >+template <> void freeOwnedEflPtr<Evas_Object>(Evas_Object* ptr) >+{ >+ evas_object_del(ptr); >+} >+ >+} // namespace WTF >diff --git a/Source/JavaScriptCore/wtf/efl/EflOwnPtr.h b/Source/JavaScriptCore/wtf/efl/EflOwnPtr.h >new file mode 100644 >index 0000000000000000000000000000000000000000..bde4f4af093565d8332c4cb0e16ac4005317571a >--- /dev/null >+++ b/Source/JavaScriptCore/wtf/efl/EflOwnPtr.h >@@ -0,0 +1,139 @@ >+/* >+ * Copyright (C) 2006, 2007 Apple Inc. All rights reserved. >+ * Copyright (C) 2008 Collabora Ltd. >+ * Copyright (C) 2011 ProFUSION embedded systems >+ * Copyright (C) 2011 Samsung Electronics >+ * >+ * This library is free software; you can redistribute it and/or >+ * modify it under the terms of the GNU Library General Public >+ * License as published by the Free Software Foundation; either >+ * version 2 of the License, or (at your option) any later version. >+ * >+ * This library is distributed in the hope that it will be useful, >+ * but WITHOUT ANY WARRANTY; without even the implied warranty of >+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU >+ * Library General Public License for more details. >+ * >+ * You should have received a copy of the GNU Library General Public License >+ * along with this library; see the file COPYING.LIB. If not, write to >+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, >+ * Boston, MA 02110-1301, USA. >+ * >+ */ >+ >+#ifndef EflOwnPtr_h >+#define EflOwnPtr_h >+ >+#include <algorithm> >+#include <cstdlib> >+#include <wtf/Assertions.h> >+#include <wtf/Noncopyable.h> >+ >+// If we expand to using other data types, moving these typedefs to a >+// separate file should be considered. >+typedef struct _Evas_Object Evas_Object; >+ >+namespace WTF { >+ >+template <typename T> inline void freeOwnedEflPtr(T* ptr); >+template <> void freeOwnedEflPtr<Evas_Object>(Evas_Object*); >+ >+template <typename T> class EflOwnPtr { >+ WTF_MAKE_NONCOPYABLE(EflOwnPtr); >+public: >+ explicit EflOwnPtr(T* ptr = 0) : m_ptr(ptr) { } >+ ~EflOwnPtr() { freeOwnedEflPtr(m_ptr); } >+ >+ T* get() const { return m_ptr; } >+ T* release() >+ { >+ T* ptr = m_ptr; >+ m_ptr = 0; >+ return ptr; >+ } >+ >+ T*& outPtr() >+ { >+ ASSERT(!m_ptr); >+ return m_ptr; >+ } >+ >+ void set(T* ptr) >+ { >+ ASSERT(!ptr || m_ptr != ptr); >+ freeOwnedEflPtr(m_ptr); >+ m_ptr = ptr; >+ } >+ >+ void clear() >+ { >+ T* ptr = m_ptr; >+ m_ptr = 0; >+ freeOwnedEflPtr(ptr); >+ } >+ >+ T& operator*() const >+ { >+ ASSERT(m_ptr); >+ return *m_ptr; >+ } >+ >+ T* operator->() const >+ { >+ ASSERT(m_ptr); >+ return m_ptr; >+ } >+ >+ bool operator!() const { return !m_ptr; } >+ >+ // This conversion operator allows implicit conversion to bool but not to other integer types. >+ typedef T* EflOwnPtr::*UnspecifiedBoolType; >+ operator UnspecifiedBoolType() const { return m_ptr ? &EflOwnPtr::m_ptr : 0; } >+ >+ void swap(EflOwnPtr& o) { std::swap(m_ptr, o.m_ptr); } >+ >+private: >+ T* m_ptr; >+}; >+ >+template <typename T> inline void swap(EflOwnPtr<T>& a, EflOwnPtr<T>& b) >+{ >+ a.swap(b); >+} >+ >+template <typename T, typename U> inline bool operator==(const EflOwnPtr<T>& a, U* b) >+{ >+ return a.get() == b; >+} >+ >+template <typename T, typename U> inline bool operator==(T* a, const EflOwnPtr<U>& b) >+{ >+ return a == b.get(); >+} >+ >+template <typename T, typename U> inline bool operator!=(const EflOwnPtr<T>& a, U* b) >+{ >+ return a.get() != b; >+} >+ >+template <typename T, typename U> inline bool operator!=(T* a, const EflOwnPtr<U>& b) >+{ >+ return a != b.get(); >+} >+ >+template <typename T> inline typename EflOwnPtr<T>::PtrType getPtr(const EflOwnPtr<T>& p) >+{ >+ return p.get(); >+} >+ >+template <typename T> inline void freeOwned(T* ptr) >+{ >+ std::free(ptr); >+} >+ >+} // namespace WTF >+ >+using WTF::EflOwnPtr; >+ >+#endif // EflOwnPtr_h >+
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 62642
:
97127
|
97130
|
97131