From 1099be693b1382b42864459b78a38282ae80b770 Mon Sep 17 00:00:00 2001 From: "scc%netscape.com" Date: Sat, 18 Mar 2000 05:17:46 +0000 Subject: [PATCH] Added the Bill Law trick to make |nsCOMPtr| break the build for everybody where it use to break it only for Solaris and a few others (the `tainting' problem). Added a haiku. r=danm --- xpcom/base/nsCOMPtr.h | 22 ++++++++++++++++++++-- xpcom/glue/nsCOMPtr.h | 22 ++++++++++++++++++++-- 2 files changed, 40 insertions(+), 4 deletions(-) diff --git a/xpcom/base/nsCOMPtr.h b/xpcom/base/nsCOMPtr.h index 15f35456b58..6792ec2772a 100644 --- a/xpcom/base/nsCOMPtr.h +++ b/xpcom/base/nsCOMPtr.h @@ -18,7 +18,7 @@ * Rights Reserved. * * Contributor(s): - * Scott Collins + * Scott Collins */ #ifndef nsCOMPtr_h___ @@ -29,6 +29,12 @@ See the User Manual at: + + + nsCOMPtr + better than a raw pointer + for owning objects + -- scc */ @@ -384,7 +390,7 @@ class nsCOMPtr_base We must, however, be careful only to |Release()| _after_ doing the assignment, in case the |Release()| leads to our _own_ destruction, which would, in turn, cause an incorrect second |Release()| of our old - pointer. Thank waterson@netscape.com for discovering this. + pointer. Thank for discovering this. */ nsISupports* oldPtr = mRawPtr; mRawPtr = newPtr; @@ -401,6 +407,18 @@ class nsCOMPtr : private nsCOMPtr_base #endif { + enum { _force_compliant_compilers_to_fail_ = sizeof(T) }; + /* + The declaration above exists specifically to make |nsCOMPtr| _not_ compile with only + a forward declaration of |T|. This should prevent Windows and Mac engineers from + breaking Solaris and other compilers that naturally have this behavior. Thank + for inventing this specific trick. + + Of course, if you're using |nsCOMPtr| outside the scope of wanting to compile on + Solaris and old GCC, you probably want to remove the enum so you can exploit forward + declarations. + */ + #ifdef NSCAP_FEATURE_DEBUG_PTR_TYPES private: void assign_with_AddRef( nsISupports* ); diff --git a/xpcom/glue/nsCOMPtr.h b/xpcom/glue/nsCOMPtr.h index 15f35456b58..6792ec2772a 100644 --- a/xpcom/glue/nsCOMPtr.h +++ b/xpcom/glue/nsCOMPtr.h @@ -18,7 +18,7 @@ * Rights Reserved. * * Contributor(s): - * Scott Collins + * Scott Collins */ #ifndef nsCOMPtr_h___ @@ -29,6 +29,12 @@ See the User Manual at: + + + nsCOMPtr + better than a raw pointer + for owning objects + -- scc */ @@ -384,7 +390,7 @@ class nsCOMPtr_base We must, however, be careful only to |Release()| _after_ doing the assignment, in case the |Release()| leads to our _own_ destruction, which would, in turn, cause an incorrect second |Release()| of our old - pointer. Thank waterson@netscape.com for discovering this. + pointer. Thank for discovering this. */ nsISupports* oldPtr = mRawPtr; mRawPtr = newPtr; @@ -401,6 +407,18 @@ class nsCOMPtr : private nsCOMPtr_base #endif { + enum { _force_compliant_compilers_to_fail_ = sizeof(T) }; + /* + The declaration above exists specifically to make |nsCOMPtr| _not_ compile with only + a forward declaration of |T|. This should prevent Windows and Mac engineers from + breaking Solaris and other compilers that naturally have this behavior. Thank + for inventing this specific trick. + + Of course, if you're using |nsCOMPtr| outside the scope of wanting to compile on + Solaris and old GCC, you probably want to remove the enum so you can exploit forward + declarations. + */ + #ifdef NSCAP_FEATURE_DEBUG_PTR_TYPES private: void assign_with_AddRef( nsISupports* );