remove unused declarations and reformat

Change-Id: I4e168fb62c275e02621c4b6e0c6000d0f006c327
This commit is contained in:
Mathias Agopian 2013-05-09 13:04:32 -07:00
parent a6cb0397da
commit 5d85d72a17
1 changed files with 46 additions and 49 deletions

View File

@ -26,9 +26,6 @@
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
namespace android { namespace android {
class TextOutput;
TextOutput& printStrongPointer(TextOutput& to, const void* val);
template<typename T> class wp; template<typename T> class wp;
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
@ -58,9 +55,8 @@ inline bool operator _op_ (const wp<U>& o) const { \
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
template <typename T> template<typename T>
class sp class sp {
{
public: public:
inline sp() : m_ptr(0) { } inline sp() : m_ptr(0) { }
@ -110,92 +106,93 @@ private:
#undef COMPARE #undef COMPARE
template <typename T>
TextOutput& operator<<(TextOutput& to, const sp<T>& val);
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
// No user serviceable parts below here. // No user serviceable parts below here.
template<typename T> template<typename T>
sp<T>::sp(T* other) sp<T>::sp(T* other)
: m_ptr(other) : m_ptr(other) {
{ if (other)
if (other) other->incStrong(this); other->incStrong(this);
} }
template<typename T> template<typename T>
sp<T>::sp(const sp<T>& other) sp<T>::sp(const sp<T>& other)
: m_ptr(other.m_ptr) : m_ptr(other.m_ptr) {
{ if (m_ptr)
if (m_ptr) m_ptr->incStrong(this); m_ptr->incStrong(this);
} }
template<typename T> template<typename U> template<typename T> template<typename U>
sp<T>::sp(U* other) : m_ptr(other) sp<T>::sp(U* other)
{ : m_ptr(other) {
if (other) ((T*)other)->incStrong(this); if (other)
((T*) other)->incStrong(this);
} }
template<typename T> template<typename U> template<typename T> template<typename U>
sp<T>::sp(const sp<U>& other) sp<T>::sp(const sp<U>& other)
: m_ptr(other.m_ptr) : m_ptr(other.m_ptr) {
{ if (m_ptr)
if (m_ptr) m_ptr->incStrong(this); m_ptr->incStrong(this);
}
template<typename T>
sp<T>::~sp()
{
if (m_ptr) m_ptr->decStrong(this);
} }
template<typename T> template<typename T>
sp<T>& sp<T>::operator = (const sp<T>& other) { sp<T>::~sp() {
if (m_ptr)
m_ptr->decStrong(this);
}
template<typename T>
sp<T>& sp<T>::operator =(const sp<T>& other) {
T* otherPtr(other.m_ptr); T* otherPtr(other.m_ptr);
if (otherPtr) otherPtr->incStrong(this); if (otherPtr)
if (m_ptr) m_ptr->decStrong(this); otherPtr->incStrong(this);
if (m_ptr)
m_ptr->decStrong(this);
m_ptr = otherPtr; m_ptr = otherPtr;
return *this; return *this;
} }
template<typename T> template<typename T>
sp<T>& sp<T>::operator = (T* other) sp<T>& sp<T>::operator =(T* other) {
{ if (other)
if (other) other->incStrong(this); other->incStrong(this);
if (m_ptr) m_ptr->decStrong(this); if (m_ptr)
m_ptr->decStrong(this);
m_ptr = other; m_ptr = other;
return *this; return *this;
} }
template<typename T> template<typename U> template<typename T> template<typename U>
sp<T>& sp<T>::operator = (const sp<U>& other) sp<T>& sp<T>::operator =(const sp<U>& other) {
{
T* otherPtr(other.m_ptr); T* otherPtr(other.m_ptr);
if (otherPtr) otherPtr->incStrong(this); if (otherPtr)
if (m_ptr) m_ptr->decStrong(this); otherPtr->incStrong(this);
if (m_ptr)
m_ptr->decStrong(this);
m_ptr = otherPtr; m_ptr = otherPtr;
return *this; return *this;
} }
template<typename T> template<typename U> template<typename T> template<typename U>
sp<T>& sp<T>::operator = (U* other) sp<T>& sp<T>::operator =(U* other) {
{ if (other)
if (other) ((T*)other)->incStrong(this); ((T*) other)->incStrong(this);
if (m_ptr) m_ptr->decStrong(this); if (m_ptr)
m_ptr->decStrong(this);
m_ptr = other; m_ptr = other;
return *this; return *this;
} }
template<typename T> template<typename T>
void sp<T>::force_set(T* other) void sp<T>::force_set(T* other) {
{
other->forceIncStrong(this); other->forceIncStrong(this);
m_ptr = other; m_ptr = other;
} }
template<typename T> template<typename T>
void sp<T>::clear() void sp<T>::clear() {
{
if (m_ptr) { if (m_ptr) {
m_ptr->decStrong(this); m_ptr->decStrong(this);
m_ptr = 0; m_ptr = 0;