From 9d8652d710dc39b796a9d576bc97928589841fed Mon Sep 17 00:00:00 2001 From: "scc%netscape.com" Date: Sat, 21 Aug 1999 20:07:27 +0000 Subject: [PATCH] added license, fixed tabs --- xpcom/base/nsWeakPtr.h | 22 ++++++ xpcom/base/nsWeakReference.cpp | 136 +++++++++++++++++++-------------- xpcom/base/nsWeakReference.h | 132 +++++++++++++++++++------------- xpcom/glue/nsWeakReference.cpp | 136 +++++++++++++++++++-------------- xpcom/glue/nsWeakReference.h | 132 +++++++++++++++++++------------- 5 files changed, 334 insertions(+), 224 deletions(-) diff --git a/xpcom/base/nsWeakPtr.h b/xpcom/base/nsWeakPtr.h index b5bc75619b9..5bae039619c 100644 --- a/xpcom/base/nsWeakPtr.h +++ b/xpcom/base/nsWeakPtr.h @@ -1,3 +1,25 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * 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 the Mozilla browser. + * + * The Initial Developer of the Original Code is Netscape + * Communications, Inc. Portions created by Netscape are + * Copyright (C) 1999, Mozilla. All Rights Reserved. + * + * Contributor(s): + * Scott Collins + */ + #ifndef nsWeakPtr_h__ #define nsWeakPtr_h__ diff --git a/xpcom/base/nsWeakReference.cpp b/xpcom/base/nsWeakReference.cpp index 4f29bad5b25..5af1f7c6f52 100644 --- a/xpcom/base/nsWeakReference.cpp +++ b/xpcom/base/nsWeakReference.cpp @@ -1,3 +1,25 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * 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 the Mozilla browser. + * + * The Initial Developer of the Original Code is Netscape + * Communications, Inc. Portions created by Netscape are + * Copyright (C) 1999, Mozilla. All Rights Reserved. + * + * Contributor(s): + * Scott Collins + */ + // nsWeakReference.cpp #include "nsWeakReference.h" @@ -5,83 +27,83 @@ NS_COM nsIWeakReference * NS_GetWeakReference( nsISupports* aInstance, nsresult* aResult ) - { - nsresult status; - if ( !aResult ) - aResult = &status; + { + nsresult status; + if ( !aResult ) + aResult = &status; - nsCOMPtr factoryP = do_QueryInterface(aInstance, aResult); + nsCOMPtr factoryP = do_QueryInterface(aInstance, aResult); - nsIWeakReference* weakP = 0; - if ( factoryP ) - status = factoryP->GetWeakReference(&weakP); - return weakP; - } + nsIWeakReference* weakP = 0; + if ( factoryP ) + status = factoryP->GetWeakReference(&weakP); + return weakP; + } NS_IMETHODIMP nsSupportsWeakReference::GetWeakReference( nsIWeakReference** aInstancePtr ) - { - if ( !aInstancePtr ) - return NS_ERROR_NULL_POINTER; + { + if ( !aInstancePtr ) + return NS_ERROR_NULL_POINTER; - if ( !mProxy ) - mProxy = new nsWeakReference(this); - *aInstancePtr = mProxy; + if ( !mProxy ) + mProxy = new nsWeakReference(this); + *aInstancePtr = mProxy; - nsresult status; - if ( !*aInstancePtr ) - status = NS_NOINTERFACE; - else - { - NS_ADDREF(*aInstancePtr); - status = NS_OK; - } + nsresult status; + if ( !*aInstancePtr ) + status = NS_NOINTERFACE; + else + { + NS_ADDREF(*aInstancePtr); + status = NS_OK; + } - return status; - } + return status; + } NS_IMETHODIMP_(nsrefcnt) nsWeakReference::AddRef() - { - return ++mRefCount; - } + { + return ++mRefCount; + } NS_IMETHODIMP_(nsrefcnt) nsWeakReference::Release() - { - nsrefcnt temp = --mRefCount; - if ( !mRefCount ) - delete this; - return temp; - } + { + nsrefcnt temp = --mRefCount; + if ( !mRefCount ) + delete this; + return temp; + } NS_IMETHODIMP nsWeakReference::QueryInterface( const nsIID& aIID, void** aInstancePtr ) - { - if ( !aInstancePtr ) - return NS_ERROR_NULL_POINTER; + { + if ( !aInstancePtr ) + return NS_ERROR_NULL_POINTER; - if ( aIID.Equals(nsCOMTypeInfo::GetIID()) ) - *aInstancePtr = NS_STATIC_CAST(nsIWeakReference*, this); - else if ( aIID.Equals(nsCOMTypeInfo::GetIID()) ) - *aInstancePtr = NS_STATIC_CAST(nsISupports*, this); - else - *aInstancePtr = 0; + if ( aIID.Equals(nsCOMTypeInfo::GetIID()) ) + *aInstancePtr = NS_STATIC_CAST(nsIWeakReference*, this); + else if ( aIID.Equals(nsCOMTypeInfo::GetIID()) ) + *aInstancePtr = NS_STATIC_CAST(nsISupports*, this); + else + *aInstancePtr = 0; - nsresult status; - if ( !*aInstancePtr ) - status = NS_NOINTERFACE; - else - { - NS_ADDREF( NS_REINTERPRET_CAST(nsISupports*, *aInstancePtr) ); - status = NS_OK; - } + nsresult status; + if ( !*aInstancePtr ) + status = NS_NOINTERFACE; + else + { + NS_ADDREF( NS_REINTERPRET_CAST(nsISupports*, *aInstancePtr) ); + status = NS_OK; + } - return status; - } + return status; + } NS_IMETHODIMP nsWeakReference::QueryReferent( const nsIID& aIID, void** aInstancePtr ) - { - return mReferent ? mReferent->QueryInterface(aIID, aInstancePtr) : NS_ERROR_NULL_POINTER; - } + { + return mReferent ? mReferent->QueryInterface(aIID, aInstancePtr) : NS_ERROR_NULL_POINTER; + } diff --git a/xpcom/base/nsWeakReference.h b/xpcom/base/nsWeakReference.h index 98e7e0243b3..9e2265e47dc 100644 --- a/xpcom/base/nsWeakReference.h +++ b/xpcom/base/nsWeakReference.h @@ -1,3 +1,25 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * 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 the Mozilla browser. + * + * The Initial Developer of the Original Code is Netscape + * Communications, Inc. Portions created by Netscape are + * Copyright (C) 1999, Mozilla. All Rights Reserved. + * + * Contributor(s): + * Scott Collins + */ + #ifndef nsWeakReference_h__ #define nsWeakReference_h__ @@ -6,76 +28,76 @@ #include "nsIWeakReference.h" class NS_COM nsSupportsWeakReference : public nsISupportsWeakReference - { - public: - nsSupportsWeakReference() - : mProxy(0) - { - // nothing else to do here - } + { + public: + nsSupportsWeakReference() + : mProxy(0) + { + // nothing else to do here + } - inline virtual ~nsSupportsWeakReference(); + inline virtual ~nsSupportsWeakReference(); - NS_IMETHOD GetWeakReference( nsIWeakReference** ); + NS_IMETHOD GetWeakReference( nsIWeakReference** ); - private: - friend class nsWeakReference; + private: + friend class nsWeakReference; - void - NoticeProxyDestruction() - // ...called (only) by an |nsWeakReference| from _its_ dtor. - { - mProxy = 0; - } + void + NoticeProxyDestruction() + // ...called (only) by an |nsWeakReference| from _its_ dtor. + { + mProxy = 0; + } - nsWeakReference* mProxy; - }; + nsWeakReference* mProxy; + }; class NS_COM nsWeakReference : public nsIWeakReference - { - public: - // nsISupports... - NS_IMETHOD_(nsrefcnt) AddRef(); - NS_IMETHOD_(nsrefcnt) Release(); - NS_IMETHOD QueryInterface( const nsIID&, void** ); + { + public: + // nsISupports... + NS_IMETHOD_(nsrefcnt) AddRef(); + NS_IMETHOD_(nsrefcnt) Release(); + NS_IMETHOD QueryInterface( const nsIID&, void** ); - // nsIWeakReference... - NS_IMETHOD QueryReferent( const nsIID&, void** ); + // nsIWeakReference... + NS_IMETHOD QueryReferent( const nsIID&, void** ); - private: - friend class nsSupportsWeakReference; + private: + friend class nsSupportsWeakReference; - nsWeakReference( nsSupportsWeakReference* referent ) - : mRefCount(0), - mReferent(referent) - // ...I can only be constructed by an |nsSupportsWeakReference| - { - // nothing else to do here - } + nsWeakReference( nsSupportsWeakReference* referent ) + : mRefCount(0), + mReferent(referent) + // ...I can only be constructed by an |nsSupportsWeakReference| + { + // nothing else to do here + } - virtual ~nsWeakReference() - // ...I will only be destroyed by calling |delete| myself. - { - if ( mReferent ) - mReferent->NoticeProxyDestruction(); - } + virtual ~nsWeakReference() + // ...I will only be destroyed by calling |delete| myself. + { + if ( mReferent ) + mReferent->NoticeProxyDestruction(); + } - void - NoticeReferentDestruction() - // ...called (only) by an |nsSupportsWeakReference| from _its_ dtor. - { - mReferent = 0; - } + void + NoticeReferentDestruction() + // ...called (only) by an |nsSupportsWeakReference| from _its_ dtor. + { + mReferent = 0; + } - nsrefcnt mRefCount; - nsSupportsWeakReference* mReferent; - }; + nsrefcnt mRefCount; + nsSupportsWeakReference* mReferent; + }; inline nsSupportsWeakReference::~nsSupportsWeakReference() - { - if ( mProxy ) - mProxy->NoticeReferentDestruction(); - } + { + if ( mProxy ) + mProxy->NoticeReferentDestruction(); + } #endif diff --git a/xpcom/glue/nsWeakReference.cpp b/xpcom/glue/nsWeakReference.cpp index 4f29bad5b25..5af1f7c6f52 100644 --- a/xpcom/glue/nsWeakReference.cpp +++ b/xpcom/glue/nsWeakReference.cpp @@ -1,3 +1,25 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * 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 the Mozilla browser. + * + * The Initial Developer of the Original Code is Netscape + * Communications, Inc. Portions created by Netscape are + * Copyright (C) 1999, Mozilla. All Rights Reserved. + * + * Contributor(s): + * Scott Collins + */ + // nsWeakReference.cpp #include "nsWeakReference.h" @@ -5,83 +27,83 @@ NS_COM nsIWeakReference * NS_GetWeakReference( nsISupports* aInstance, nsresult* aResult ) - { - nsresult status; - if ( !aResult ) - aResult = &status; + { + nsresult status; + if ( !aResult ) + aResult = &status; - nsCOMPtr factoryP = do_QueryInterface(aInstance, aResult); + nsCOMPtr factoryP = do_QueryInterface(aInstance, aResult); - nsIWeakReference* weakP = 0; - if ( factoryP ) - status = factoryP->GetWeakReference(&weakP); - return weakP; - } + nsIWeakReference* weakP = 0; + if ( factoryP ) + status = factoryP->GetWeakReference(&weakP); + return weakP; + } NS_IMETHODIMP nsSupportsWeakReference::GetWeakReference( nsIWeakReference** aInstancePtr ) - { - if ( !aInstancePtr ) - return NS_ERROR_NULL_POINTER; + { + if ( !aInstancePtr ) + return NS_ERROR_NULL_POINTER; - if ( !mProxy ) - mProxy = new nsWeakReference(this); - *aInstancePtr = mProxy; + if ( !mProxy ) + mProxy = new nsWeakReference(this); + *aInstancePtr = mProxy; - nsresult status; - if ( !*aInstancePtr ) - status = NS_NOINTERFACE; - else - { - NS_ADDREF(*aInstancePtr); - status = NS_OK; - } + nsresult status; + if ( !*aInstancePtr ) + status = NS_NOINTERFACE; + else + { + NS_ADDREF(*aInstancePtr); + status = NS_OK; + } - return status; - } + return status; + } NS_IMETHODIMP_(nsrefcnt) nsWeakReference::AddRef() - { - return ++mRefCount; - } + { + return ++mRefCount; + } NS_IMETHODIMP_(nsrefcnt) nsWeakReference::Release() - { - nsrefcnt temp = --mRefCount; - if ( !mRefCount ) - delete this; - return temp; - } + { + nsrefcnt temp = --mRefCount; + if ( !mRefCount ) + delete this; + return temp; + } NS_IMETHODIMP nsWeakReference::QueryInterface( const nsIID& aIID, void** aInstancePtr ) - { - if ( !aInstancePtr ) - return NS_ERROR_NULL_POINTER; + { + if ( !aInstancePtr ) + return NS_ERROR_NULL_POINTER; - if ( aIID.Equals(nsCOMTypeInfo::GetIID()) ) - *aInstancePtr = NS_STATIC_CAST(nsIWeakReference*, this); - else if ( aIID.Equals(nsCOMTypeInfo::GetIID()) ) - *aInstancePtr = NS_STATIC_CAST(nsISupports*, this); - else - *aInstancePtr = 0; + if ( aIID.Equals(nsCOMTypeInfo::GetIID()) ) + *aInstancePtr = NS_STATIC_CAST(nsIWeakReference*, this); + else if ( aIID.Equals(nsCOMTypeInfo::GetIID()) ) + *aInstancePtr = NS_STATIC_CAST(nsISupports*, this); + else + *aInstancePtr = 0; - nsresult status; - if ( !*aInstancePtr ) - status = NS_NOINTERFACE; - else - { - NS_ADDREF( NS_REINTERPRET_CAST(nsISupports*, *aInstancePtr) ); - status = NS_OK; - } + nsresult status; + if ( !*aInstancePtr ) + status = NS_NOINTERFACE; + else + { + NS_ADDREF( NS_REINTERPRET_CAST(nsISupports*, *aInstancePtr) ); + status = NS_OK; + } - return status; - } + return status; + } NS_IMETHODIMP nsWeakReference::QueryReferent( const nsIID& aIID, void** aInstancePtr ) - { - return mReferent ? mReferent->QueryInterface(aIID, aInstancePtr) : NS_ERROR_NULL_POINTER; - } + { + return mReferent ? mReferent->QueryInterface(aIID, aInstancePtr) : NS_ERROR_NULL_POINTER; + } diff --git a/xpcom/glue/nsWeakReference.h b/xpcom/glue/nsWeakReference.h index 98e7e0243b3..9e2265e47dc 100644 --- a/xpcom/glue/nsWeakReference.h +++ b/xpcom/glue/nsWeakReference.h @@ -1,3 +1,25 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * 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 the Mozilla browser. + * + * The Initial Developer of the Original Code is Netscape + * Communications, Inc. Portions created by Netscape are + * Copyright (C) 1999, Mozilla. All Rights Reserved. + * + * Contributor(s): + * Scott Collins + */ + #ifndef nsWeakReference_h__ #define nsWeakReference_h__ @@ -6,76 +28,76 @@ #include "nsIWeakReference.h" class NS_COM nsSupportsWeakReference : public nsISupportsWeakReference - { - public: - nsSupportsWeakReference() - : mProxy(0) - { - // nothing else to do here - } + { + public: + nsSupportsWeakReference() + : mProxy(0) + { + // nothing else to do here + } - inline virtual ~nsSupportsWeakReference(); + inline virtual ~nsSupportsWeakReference(); - NS_IMETHOD GetWeakReference( nsIWeakReference** ); + NS_IMETHOD GetWeakReference( nsIWeakReference** ); - private: - friend class nsWeakReference; + private: + friend class nsWeakReference; - void - NoticeProxyDestruction() - // ...called (only) by an |nsWeakReference| from _its_ dtor. - { - mProxy = 0; - } + void + NoticeProxyDestruction() + // ...called (only) by an |nsWeakReference| from _its_ dtor. + { + mProxy = 0; + } - nsWeakReference* mProxy; - }; + nsWeakReference* mProxy; + }; class NS_COM nsWeakReference : public nsIWeakReference - { - public: - // nsISupports... - NS_IMETHOD_(nsrefcnt) AddRef(); - NS_IMETHOD_(nsrefcnt) Release(); - NS_IMETHOD QueryInterface( const nsIID&, void** ); + { + public: + // nsISupports... + NS_IMETHOD_(nsrefcnt) AddRef(); + NS_IMETHOD_(nsrefcnt) Release(); + NS_IMETHOD QueryInterface( const nsIID&, void** ); - // nsIWeakReference... - NS_IMETHOD QueryReferent( const nsIID&, void** ); + // nsIWeakReference... + NS_IMETHOD QueryReferent( const nsIID&, void** ); - private: - friend class nsSupportsWeakReference; + private: + friend class nsSupportsWeakReference; - nsWeakReference( nsSupportsWeakReference* referent ) - : mRefCount(0), - mReferent(referent) - // ...I can only be constructed by an |nsSupportsWeakReference| - { - // nothing else to do here - } + nsWeakReference( nsSupportsWeakReference* referent ) + : mRefCount(0), + mReferent(referent) + // ...I can only be constructed by an |nsSupportsWeakReference| + { + // nothing else to do here + } - virtual ~nsWeakReference() - // ...I will only be destroyed by calling |delete| myself. - { - if ( mReferent ) - mReferent->NoticeProxyDestruction(); - } + virtual ~nsWeakReference() + // ...I will only be destroyed by calling |delete| myself. + { + if ( mReferent ) + mReferent->NoticeProxyDestruction(); + } - void - NoticeReferentDestruction() - // ...called (only) by an |nsSupportsWeakReference| from _its_ dtor. - { - mReferent = 0; - } + void + NoticeReferentDestruction() + // ...called (only) by an |nsSupportsWeakReference| from _its_ dtor. + { + mReferent = 0; + } - nsrefcnt mRefCount; - nsSupportsWeakReference* mReferent; - }; + nsrefcnt mRefCount; + nsSupportsWeakReference* mReferent; + }; inline nsSupportsWeakReference::~nsSupportsWeakReference() - { - if ( mProxy ) - mProxy->NoticeReferentDestruction(); - } + { + if ( mProxy ) + mProxy->NoticeReferentDestruction(); + } #endif