| 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::freeOwnedEflPtr):
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 +3 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
Lines 39-48 LIST(APPEND WTF_LIBRARIES a/Source/JavaScriptCore/wtf/CMakeListsEfl.txt_sec2
39
40
40
LIST(APPEND WTF_LINK_FLAGS
41
LIST(APPEND WTF_LINK_FLAGS
41
    ${ECORE_LDFLAGS}
42
    ${ECORE_LDFLAGS}
43
    ${EVAS_LDFLAGS}
42
)
44
)
43
45
44
LIST(APPEND WTF_INCLUDE_DIRECTORIES
46
LIST(APPEND WTF_INCLUDE_DIRECTORIES
45
    ${ECORE_INCLUDE_DIRS}
47
    ${ECORE_INCLUDE_DIRS}
48
    ${EVAS_INCLUDE_DIRS}
46
    ${ICU_INCLUDE_DIRS}
49
    ${ICU_INCLUDE_DIRS}
47
    ${JAVASCRIPTCORE_DIR}/wtf/unicode/
50
    ${JAVASCRIPTCORE_DIR}/wtf/unicode/
48
)
51
)
- 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 +139 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
// If we expand to using other data types, moving these typedefs to a
33
// separate file should be considered.
34
typedef struct _Evas_Object Evas_Object;
35
36
namespace WTF {
37
38
template <typename T> inline void freeOwnedEflPtr(T* ptr);
39
template <> void freeOwnedEflPtr<Evas_Object>(Evas_Object*);
40
41
template <typename T> class EflOwnPtr {
42
    WTF_MAKE_NONCOPYABLE(EflOwnPtr);
43
public:
44
    explicit EflOwnPtr(T* ptr = 0) : m_ptr(ptr) { }
45
    ~EflOwnPtr() { freeOwnedEflPtr(m_ptr); }
46
47
    T* get() const { return m_ptr; }
48
    T* release()
49
    {
50
        T* ptr = m_ptr;
51
        m_ptr = 0;
52
        return ptr;
53
    }
54
55
    T*& outPtr()
56
    {
57
        ASSERT(!m_ptr);
58
        return m_ptr;
59
    }
60
61
    void set(T* ptr)
62
    {
63
        ASSERT(!ptr || m_ptr != ptr);
64
        freeOwnedEflPtr(m_ptr);
65
        m_ptr = ptr;
66
    }
67
68
    void clear()
69
    {
70
        T* ptr = m_ptr;
71
        m_ptr = 0;
72
        freeOwnedEflPtr(ptr);
73
    }
74
75
    T& operator*() const
76
    {
77
        ASSERT(m_ptr);
78
        return *m_ptr;
79
    }
80
81
    T* operator->() const
82
    {
83
        ASSERT(m_ptr);
84
        return m_ptr;
85
    }
86
87
    bool operator!() const { return !m_ptr; }
88
89
    // This conversion operator allows implicit conversion to bool but not to other integer types.
90
    typedef T* EflOwnPtr::*UnspecifiedBoolType;
91
    operator UnspecifiedBoolType() const { return m_ptr ? &EflOwnPtr::m_ptr : 0; }
92
93
    void swap(EflOwnPtr& o) { std::swap(m_ptr, o.m_ptr); }
94
95
private:
96
    T* m_ptr;
97
};
98
99
template <typename T> inline void swap(EflOwnPtr<T>& a, EflOwnPtr<T>& b)
100
{
101
    a.swap(b);
102
}
103
104
template <typename T, typename U> inline bool operator==(const EflOwnPtr<T>& a, U* b)
105
{
106
    return a.get() == b;
107
}
108
109
template <typename T, typename U> inline bool operator==(T* a, const EflOwnPtr<U>& b)
110
{
111
    return a == b.get();
112
}
113
114
template <typename T, typename U> inline bool operator!=(const EflOwnPtr<T>& a, U* b)
115
{
116
    return a.get() != b;
117
}
118
119
template <typename T, typename U> inline bool operator!=(T* a, const EflOwnPtr<U>& b)
120
{
121
    return a != b.get();
122
}
123
124
template <typename T> inline typename EflOwnPtr<T>::PtrType getPtr(const EflOwnPtr<T>& p)
125
{
126
    return p.get();
127
}
128
129
template <typename T> inline void freeOwnedEflPtr(T* ptr)
130
{
131
    std::free(ptr);
132
}
133
134
} // namespace WTF
135
136
using WTF::EflOwnPtr;
137
138
#endif // EflOwnPtr_h
139

Return to Bug 62642