| Differences between
and this patch
- a/Source/JavaScriptCore/ChangeLog +35 lines
Lines 1-3 a/Source/JavaScriptCore/ChangeLog_sec1
1
2011-06-14  Raphael Kubo da Costa  <kubo@profusion.mobi>
2
3
        Reviewed by NOBODY (OOPS!).
4
5
        [Efl] Add EflOwnPtr.h.
6
        https://bugs.webkit.org/show_bug.cgi?id=62642
7
8
        It works similarly to GOwnPtr and OwnPtr, but calls free() instead of
9
        g_free() and delete to free memory.
10
11
        It can also be used to put Evas_Object's in smart pointer as well,
12
        taking care of calling evas_object_del() when needed.
13
14
        * wtf/CMakeListsEfl.txt:
15
        * wtf/efl/EflOwnPtr.cpp: Added.
16
        (WTF::Evas_Object):
17
        * wtf/efl/EflOwnPtr.h: Added.
18
        (WTF::EflOwnPtr::EflOwnPtr):
19
        (WTF::EflOwnPtr::~EflOwnPtr):
20
        (WTF::EflOwnPtr::get):
21
        (WTF::EflOwnPtr::release):
22
        (WTF::EflOwnPtr::outPtr):
23
        (WTF::EflOwnPtr::set):
24
        (WTF::EflOwnPtr::clear):
25
        (WTF::EflOwnPtr::operator*):
26
        (WTF::EflOwnPtr::operator->):
27
        (WTF::EflOwnPtr::operator!):
28
        (WTF::EflOwnPtr::operator UnspecifiedBoolType):
29
        (WTF::EflOwnPtr::swap):
30
        (WTF::swap):
31
        (WTF::operator==):
32
        (WTF::operator!=):
33
        (WTF::getPtr):
34
        (WTF::freeOwned):
35
1
2011-05-31  Oliver Hunt  <oliver@apple.com>
36
2011-05-31  Oliver Hunt  <oliver@apple.com>
2
37
3
        Reviewed by Geoffrey Garen.
38
        Reviewed by Geoffrey Garen.
- a/Source/JavaScriptCore/wtf/CMakeListsEfl.txt +1 lines
Lines 8-13 ENDIF() a/Source/JavaScriptCore/wtf/CMakeListsEfl.txt_sec1
8
8
9
LIST(APPEND WTF_SOURCES
9
LIST(APPEND WTF_SOURCES
10
    efl/MainThreadEfl.cpp
10
    efl/MainThreadEfl.cpp
11
    efl/EflOwnPtr.cpp
11
12
12
    OSAllocatorPosix.cpp
13
    OSAllocatorPosix.cpp
13
    ThreadIdentifierDataPthreads.cpp
14
    ThreadIdentifierDataPthreads.cpp
- a/Source/JavaScriptCore/wtf/efl/EflOwnPtr.cpp +34 lines
Line 0 a/Source/JavaScriptCore/wtf/efl/EflOwnPtr.cpp_sec1
1
/*
2
 *  Copyright (C) 2011 ProFUSION embedded systems
3
 *  Copyright (C) 2011 Samsung Electronics
4
 *
5
 *  This library is free software; you can redistribute it and/or
6
 *  modify it under the terms of the GNU Library General Public
7
 *  License as published by the Free Software Foundation; either
8
 *  version 2 of the License, or (at your option) any later version.
9
 *
10
 *  This library is distributed in the hope that it will be useful,
11
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13
 *  Library General Public License for more details.
14
 *
15
 *  You should have received a copy of the GNU Library General Public License
16
 *  along with this library; see the file COPYING.LIB.  If not, write to
17
 *  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18
 *  Boston, MA 02110-1301, USA.
19
 *
20
 */
21
22
#include "config.h"
23
#include "EflOwnPtr.h"
24
25
#include <Evas.h>
26
27
namespace WTF {
28
29
template <> void freeOwnedEflPtr<Evas_Object>(Evas_Object* ptr)
30
{
31
    evas_object_del(ptr);
32
}
33
34
} // namespace WTF
- a/Source/JavaScriptCore/wtf/efl/EflOwnPtr.h +135 lines
Line 0 a/Source/JavaScriptCore/wtf/efl/EflOwnPtr.h_sec1
1
/*
2
 *  Copyright (C) 2006, 2007 Apple Inc. All rights reserved.
3
 *  Copyright (C) 2008 Collabora Ltd.
4
 *  Copyright (C) 2011 ProFUSION embedded systems
5
 *  Copyright (C) 2011 Samsung Electronics
6
 *
7
 *  This library is free software; you can redistribute it and/or
8
 *  modify it under the terms of the GNU Library General Public
9
 *  License as published by the Free Software Foundation; either
10
 *  version 2 of the License, or (at your option) any later version.
11
 *
12
 *  This library is distributed in the hope that it will be useful,
13
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
14
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15
 *  Library General Public License for more details.
16
 *
17
 *  You should have received a copy of the GNU Library General Public License
18
 *  along with this library; see the file COPYING.LIB.  If not, write to
19
 *  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
20
 *  Boston, MA 02110-1301, USA.
21
 *
22
 */
23
24
#ifndef EflOwnPtr_h
25
#define EflOwnPtr_h
26
27
#include <algorithm>
28
#include <cstdlib>
29
#include <wtf/Assertions.h>
30
#include <wtf/Noncopyable.h>
31
32
namespace WTF {
33
34
template <typename T> inline void freeOwnedEflPtr(T* ptr);
35
template <> void freeOwnedEflPtr<Evas_Object>(Evas_Object*);
36
37
template <typename T> class EflOwnPtr {
38
    WTF_MAKE_NONCOPYABLE(EflOwnPtr);
39
public:
40
    explicit EflOwnPtr(T* ptr = 0) : m_ptr(ptr) { }
41
    ~EflOwnPtr() { freeOwnedEflPtr(m_ptr); }
42
43
    T* get() const { return m_ptr; }
44
    T* release()
45
    {
46
        T* ptr = m_ptr;
47
        m_ptr = 0;
48
        return ptr;
49
    }
50
51
    T*& outPtr()
52
    {
53
        ASSERT(!m_ptr);
54
        return m_ptr;
55
    }
56
57
    void set(T* ptr)
58
    {
59
        ASSERT(!ptr || m_ptr != ptr);
60
        freeOwnedEflPtr(m_ptr);
61
        m_ptr = ptr;
62
    }
63
64
    void clear()
65
    {
66
        T* ptr = m_ptr;
67
        m_ptr = 0;
68
        freeOwnedEflPtr(ptr);
69
    }
70
71
    T& operator*() const
72
    {
73
        ASSERT(m_ptr);
74
        return *m_ptr;
75
    }
76
77
    T* operator->() const
78
    {
79
        ASSERT(m_ptr);
80
        return m_ptr;
81
    }
82
83
    bool operator!() const { return !m_ptr; }
84
85
    // This conversion operator allows implicit conversion to bool but not to other integer types.
86
    typedef T* EflOwnPtr::*UnspecifiedBoolType;
87
    operator UnspecifiedBoolType() const { return m_ptr ? &EflOwnPtr::m_ptr : 0; }
88
89
    void swap(EflOwnPtr& o) { std::swap(m_ptr, o.m_ptr); }
90
91
private:
92
    T* m_ptr;
93
};
94
95
template <typename T> inline void swap(EflOwnPtr<T>& a, EflOwnPtr<T>& b)
96
{
97
    a.swap(b);
98
}
99
100
template <typename T, typename U> inline bool operator==(const EflOwnPtr<T>& a, U* b)
101
{ 
102
    return a.get() == b; 
103
}
104
105
template <typename T, typename U> inline bool operator==(T* a, const EflOwnPtr<U>& b) 
106
{
107
    return a == b.get(); 
108
}
109
110
template <typename T, typename U> inline bool operator!=(const EflOwnPtr<T>& a, U* b)
111
{
112
    return a.get() != b; 
113
}
114
115
template <typename T, typename U> inline bool operator!=(T* a, const EflOwnPtr<U>& b)
116
{ 
117
    return a != b.get(); 
118
}
119
120
template <typename T> inline typename EflOwnPtr<T>::PtrType getPtr(const EflOwnPtr<T>& p)
121
{
122
    return p.get();
123
}
124
125
template <typename T> inline void freeOwned(T* ptr)
126
{
127
    std::free(ptr);
128
}
129
130
} // namespace WTF
131
132
using WTF::EflOwnPtr;
133
134
#endif // EflOwnPtr_h
135

Return to Bug 62642