From fcc97e5267c39293eed92b07662a0c03358281a7 Mon Sep 17 00:00:00 2001 From: "philringnalda@gmail.com" Date: Sun, 18 Nov 2007 18:37:24 -0800 Subject: [PATCH] Bug 403592 - remove incredibly long-dead nsMdbPtr.h, r=bsmedberg, a=schrep --- toolkit/components/history/src/nsMdbPtr.h | 244 --------------------- xpfe/components/history/src/nsMdbPtr.h | 245 ---------------------- 2 files changed, 489 deletions(-) delete mode 100644 toolkit/components/history/src/nsMdbPtr.h delete mode 100644 xpfe/components/history/src/nsMdbPtr.h diff --git a/toolkit/components/history/src/nsMdbPtr.h b/toolkit/components/history/src/nsMdbPtr.h deleted file mode 100644 index 7465e3b38b1b..000000000000 --- a/toolkit/components/history/src/nsMdbPtr.h +++ /dev/null @@ -1,244 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is Mozilla Communicator client code. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -/* - - DO NOT USE THIS. IT IS INTENDED FOR TEMPORARY USE BY GLOBAL HISTORY, - PENDING CONVERSION OF THE MDB INTERFACES TO XPCOM. - -*/ - - -#ifndef nsMdbPtr_h__ -#define nsMdbPtr_h__ - -#include "mdb.h" - -template -class nsMdbDerivedSafe : public T -{ -private: - virtual mdb_err AddStrongRef(nsIMdbEnv* aEnv) { return 0; } // NOT TO BE IMPLEMENTED - virtual mdb_err CutStrongRef(nsIMdbEnv* aEnv) { return 0; } // NOT TO BE IMPLEMENTED - virtual nsMdbDerivedSafe& operator=(const T&) { return *this; } // NOT TO BE IMPLEMENTED - void operator delete(void*, size_t) {} // NOT TO BE IMPLEMENTED -}; - - -template -class nsMdbPtr -{ -private: - nsIMdbEnv* mEnv; - T* mRawPtr; - -public: - nsMdbPtr(nsIMdbEnv* aEnv) : mEnv(aEnv), mRawPtr(0) - { - NS_PRECONDITION(aEnv != 0, "null ptr"); - } - - nsMdbPtr(nsIMdbEnv* aEnv, T* aRawPtr) : mEnv(aEnv), mRawPtr(0) - { - NS_PRECONDITION(aEnv != 0, "null ptr"); - if (mEnv) { - if (aRawPtr) { - mRawPtr = aRawPtr; - mRawPtr->AddStrongRef(mEnv); - } - } - } - - nsMdbPtr(const nsMdbPtr& aSmartPtr) : mEnv(aSmartPtr.mEnv), mRawPtr(0) - { - if (mEnv) { - if (aSmartPtr) { - mRawPtr = aSmartPtr; - mRawPtr->AddStrongRef(mEnv); - } - } - } - - nsMdbPtr& - operator=(const nsMdbPtr& aSmartPtr) - { - if (mEnv) { - if (mRawPtr) { - mRawPtr->CutStrongRef(mEnv); - mRawPtr = 0; - } - } - mEnv = aSmartPtr.mEnv; - if (mEnv) { - mRawPtr = aSmartPtr.mRawPtr; - if (mRawPtr) - mRawPtr->AddStrongRef(mEnv); - } - - return *this; - } - - ~nsMdbPtr() - { - if (mEnv) { - if (mRawPtr) - mRawPtr->CutStrongRef(mEnv); - } - } - - nsMdbDerivedSafe* - get() const - { - return reinterpret_cast*>(mRawPtr); - } - - nsMdbDerivedSafe* - operator->() const - { - return get(); - } - - - nsMdbDerivedSafe& - operator*() const - { - return *get(); - } - - operator nsMdbDerivedSafe*() const - { - return get(); - } - - - T** - StartAssignment() - { - if (mRawPtr) { - mRawPtr->CutStrongRef(mEnv); - mRawPtr = 0; - } - return &mRawPtr; - } -}; - -template -inline -PRBool -operator==(const nsMdbPtr& lhs, const nsMdbPtr& rhs) -{ - return static_cast(lhs.get()) == static_cast(rhs.get()); -} - -template -inline -PRBool -operator==(const nsMdbPtr& lhs, const U* rhs) -{ - return static_cast(lhs.get()) == static_cast(rhs); -} - - -template -inline -PRBool -operator==(const U* lhs, const nsMdbPtr& rhs) -{ - return static_cast(lhs) == static_cast(rhs.get()); -} - - - - -template -inline -PRBool -operator!=(const nsMdbPtr& lhs, const nsMdbPtr& rhs) -{ - return static_cast(lhs.get()) != static_cast(rhs.get()); -} - -template -inline -PRBool -operator!=(const nsMdbPtr& lhs, const U* rhs) -{ - return static_cast(lhs.get()) != static_cast(rhs); -} - - -template -inline -PRBool -operator!=(const U* lhs, const nsMdbPtr& rhs) -{ - return static_cast(lhs) != static_cast(rhs.get()); -} - - - -template -class nsGetterAcquires -{ -private: - nsMdbPtr& mTargetSmartPtr; - -public: - explicit - nsGetterAcquires(nsMdbPtr& aSmartPtr) : mTargetSmartPtr(aSmartPtr) - { - // nothing else to do - } - - operator T**() - { - return mTargetSmartPtr.StartAssignment(); - } -}; - - -template -inline -nsGetterAcquires -getter_Acquires(nsMdbPtr& aSmartPtr) -{ - return nsGetterAcquires(aSmartPtr); -} - - -#endif // nsMdbPtr_h__ - diff --git a/xpfe/components/history/src/nsMdbPtr.h b/xpfe/components/history/src/nsMdbPtr.h deleted file mode 100644 index f2a5ed7055d2..000000000000 --- a/xpfe/components/history/src/nsMdbPtr.h +++ /dev/null @@ -1,245 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is Mozilla Communicator client code. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * Alec Flett - * - * Alternatively, the contents of this file may be used under the terms of - * either of the GNU General Public License Version 2 or later (the "GPL"), - * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -/* - - DO NOT USE THIS. IT IS INTENDED FOR TEMPORARY USE BY GLOBAL HISTORY, - PENDING CONVERSION OF THE MDB INTERFACES TO XPCOM. - -*/ - - -#ifndef nsMdbPtr_h__ -#define nsMdbPtr_h__ - -#include "mdb.h" - -template -class nsMdbDerivedSafe : public T -{ -private: - virtual mdb_err AddStrongRef(nsIMdbEnv* aEnv) { return 0; } // NOT TO BE IMPLEMENTED - virtual mdb_err CutStrongRef(nsIMdbEnv* aEnv) { return 0; } // NOT TO BE IMPLEMENTED - virtual nsMdbDerivedSafe& operator=(const T&) { return *this; } // NOT TO BE IMPLEMENTED - void operator delete(void*, size_t) {} // NOT TO BE IMPLEMENTED -}; - - -template -class nsMdbPtr -{ -private: - nsIMdbEnv* mEnv; - T* mRawPtr; - -public: - nsMdbPtr(nsIMdbEnv* aEnv) : mEnv(aEnv), mRawPtr(0) - { - NS_PRECONDITION(aEnv != 0, "null ptr"); - } - - nsMdbPtr(nsIMdbEnv* aEnv, T* aRawPtr) : mEnv(aEnv), mRawPtr(0) - { - NS_PRECONDITION(aEnv != 0, "null ptr"); - if (mEnv) { - if (aRawPtr) { - mRawPtr = aRawPtr; - mRawPtr->AddStrongRef(mEnv); - } - } - } - - nsMdbPtr(const nsMdbPtr& aSmartPtr) : mEnv(aSmartPtr.mEnv), mRawPtr(0) - { - if (mEnv) { - if (aSmartPtr) { - mRawPtr = aSmartPtr; - mRawPtr->AddStrongRef(mEnv); - } - } - } - - nsMdbPtr& - operator=(const nsMdbPtr& aSmartPtr) - { - if (mEnv) { - if (mRawPtr) { - mRawPtr->CutStrongRef(mEnv); - mRawPtr = 0; - } - } - mEnv = aSmartPtr.mEnv; - if (mEnv) { - mRawPtr = aSmartPtr.mRawPtr; - if (mRawPtr) - mRawPtr->AddStrongRef(mEnv); - } - - return *this; - } - - ~nsMdbPtr() - { - if (mEnv) { - if (mRawPtr) - mRawPtr->CutStrongRef(mEnv); - } - } - - nsMdbDerivedSafe* - get() const - { - return reinterpret_cast*>(mRawPtr); - } - - nsMdbDerivedSafe* - operator->() const - { - return get(); - } - - - nsMdbDerivedSafe& - operator*() const - { - return *get(); - } - - operator nsMdbDerivedSafe*() const - { - return get(); - } - - - T** - StartAssignment() - { - if (mRawPtr) { - mRawPtr->CutStrongRef(mEnv); - mRawPtr = 0; - } - return &mRawPtr; - } -}; - -template -inline -PRBool -operator==(const nsMdbPtr& lhs, const nsMdbPtr& rhs) -{ - return static_cast(lhs.get()) == static_cast(rhs.get()); -} - -template -inline -PRBool -operator==(const nsMdbPtr& lhs, const U* rhs) -{ - return static_cast(lhs.get()) == static_cast(rhs); -} - - -template -inline -PRBool -operator==(const U* lhs, const nsMdbPtr& rhs) -{ - return static_cast(lhs) == static_cast(rhs.get()); -} - - - - -template -inline -PRBool -operator!=(const nsMdbPtr& lhs, const nsMdbPtr& rhs) -{ - return static_cast(lhs.get()) != static_cast(rhs.get()); -} - -template -inline -PRBool -operator!=(const nsMdbPtr& lhs, const U* rhs) -{ - return static_cast(lhs.get()) != static_cast(rhs); -} - - -template -inline -PRBool -operator!=(const U* lhs, const nsMdbPtr& rhs) -{ - return static_cast(lhs) != static_cast(rhs.get()); -} - - - -template -class nsGetterAcquires -{ -private: - nsMdbPtr& mTargetSmartPtr; - -public: - explicit - nsGetterAcquires(nsMdbPtr& aSmartPtr) : mTargetSmartPtr(aSmartPtr) - { - // nothing else to do - } - - operator T**() - { - return mTargetSmartPtr.StartAssignment(); - } -}; - - -template -inline -nsGetterAcquires -getter_Acquires(nsMdbPtr& aSmartPtr) -{ - return nsGetterAcquires(aSmartPtr); -} - - -#endif // nsMdbPtr_h__ -