From 22973a932d35a691490890e6683ae15e34f7c52c Mon Sep 17 00:00:00 2001 From: "pinkerton%netscape.com" Date: Wed, 25 Aug 1999 22:04:02 +0000 Subject: [PATCH] fix QI lameness and use macros. git-svn-id: svn://10.0.0.236/trunk@44539 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/widget/src/gtk/nsClipboard.cpp | 26 ---------- mozilla/widget/src/gtk/nsClipboard.h | 3 -- mozilla/widget/src/gtk/nsDragService.cpp | 26 ---------- mozilla/widget/src/gtk/nsDragService.h | 4 -- mozilla/widget/src/mac/nsClipboard.cpp | 32 ------------ mozilla/widget/src/mac/nsClipboard.h | 3 -- mozilla/widget/src/mac/nsDragService.cpp | 16 ++---- mozilla/widget/src/mac/nsDragService.h | 4 +- mozilla/widget/src/windows/nsDragService.cpp | 52 +++---------------- mozilla/widget/src/windows/nsDragService.h | 4 -- .../widget/src/xpwidgets/nsBaseClipboard.cpp | 26 +--------- .../src/xpwidgets/nsBaseDragService.cpp | 28 +--------- .../widget/src/xpwidgets/nsTransferable.cpp | 3 +- .../src/xpwidgets/nsXIFFormatConverter.cpp | 3 +- 14 files changed, 20 insertions(+), 210 deletions(-) diff --git a/mozilla/widget/src/gtk/nsClipboard.cpp b/mozilla/widget/src/gtk/nsClipboard.cpp index d54b893bdb9..805cb076ff3 100644 --- a/mozilla/widget/src/gtk/nsClipboard.cpp +++ b/mozilla/widget/src/gtk/nsClipboard.cpp @@ -40,9 +40,6 @@ // The class statics: GtkWidget* nsClipboard::sWidget = 0; -NS_IMPL_ADDREF_INHERITED(nsClipboard, nsBaseClipboard) -NS_IMPL_RELEASE_INHERITED(nsClipboard, nsBaseClipboard) - #if defined(DEBUG_akkana) || defined(DEBUG_mcafee) || defined(DEBUG_pavlov) #define DEBUG_CLIPBOARD @@ -154,29 +151,6 @@ nsClipboard::~nsClipboard() } } -/** - * @param aIID The name of the class implementing the method - * @param _classiiddef The name of the #define symbol that defines the IID - * for the class (e.g. NS_ISUPPORTS_IID) - * -*/ -nsresult nsClipboard::QueryInterface(const nsIID& aIID, void** aInstancePtr) -{ - if (NULL == aInstancePtr) { - return NS_ERROR_NULL_POINTER; - } - - nsresult rv = NS_NOINTERFACE; - - if (aIID.Equals(nsIClipboard::GetIID())) { - *aInstancePtr = (void*) ((nsIClipboard*)this); - NS_ADDREF_THIS(); - return NS_OK; - } - - return rv; -} - // // GTK Weirdness! diff --git a/mozilla/widget/src/gtk/nsClipboard.h b/mozilla/widget/src/gtk/nsClipboard.h index aa448165a7e..937bceebd2b 100644 --- a/mozilla/widget/src/gtk/nsClipboard.h +++ b/mozilla/widget/src/gtk/nsClipboard.h @@ -38,9 +38,6 @@ public: nsClipboard(); virtual ~nsClipboard(); - //nsISupports - NS_DECL_ISUPPORTS_INHERITED - // nsIClipboard NS_IMETHOD ForceDataToClipboard(); diff --git a/mozilla/widget/src/gtk/nsDragService.cpp b/mozilla/widget/src/gtk/nsDragService.cpp index 2223cf19359..e7a469a3e19 100644 --- a/mozilla/widget/src/gtk/nsDragService.cpp +++ b/mozilla/widget/src/gtk/nsDragService.cpp @@ -28,9 +28,6 @@ static NS_DEFINE_CID(kCDragServiceCID, NS_DRAGSERVICE_CID); // The class statics: GtkWidget* nsDragService::sWidget = 0; -NS_IMPL_ADDREF_INHERITED(nsDragService, nsBaseDragService) -NS_IMPL_RELEASE_INHERITED(nsDragService, nsBaseDragService) - //------------------------------------------------------------------------- // static variables //------------------------------------------------------------------------- @@ -55,29 +52,6 @@ nsDragService::~nsDragService() { } -/** - * @param aIID The name of the class implementing the method - * @param _classiiddef The name of the #define symbol that defines the IID - * for the class (e.g. NS_ISUPPORTS_IID) - * -*/ -nsresult nsDragService::QueryInterface(const nsIID& aIID, void** aInstancePtr) -{ - - if (NULL == aInstancePtr) { - return NS_ERROR_NULL_POINTER; - } - - nsresult rv = NS_NOINTERFACE; - - if (aIID.Equals(nsIDragService::GetIID())) { - *aInstancePtr = (void*) ((nsIDragService*)this); - NS_ADDREF_THIS(); - return NS_OK; - } - - return rv; -} //--------------------------------------------------------- NS_IMETHODIMP nsDragService::StartDragSession (nsITransferable * aTransferable, PRUint32 aActionType) diff --git a/mozilla/widget/src/gtk/nsDragService.h b/mozilla/widget/src/gtk/nsDragService.h index 4ac4de08c6f..59c7f53777b 100644 --- a/mozilla/widget/src/gtk/nsDragService.h +++ b/mozilla/widget/src/gtk/nsDragService.h @@ -33,10 +33,6 @@ class nsDragService : public nsBaseDragService public: nsDragService(); virtual ~nsDragService(); - - //nsISupports - NS_DECL_ISUPPORTS_INHERITED - //nsIDragService NS_IMETHOD StartDragSession (nsITransferable * aTransferable, diff --git a/mozilla/widget/src/mac/nsClipboard.cpp b/mozilla/widget/src/mac/nsClipboard.cpp index 819631546ec..680b820a321 100644 --- a/mozilla/widget/src/mac/nsClipboard.cpp +++ b/mozilla/widget/src/mac/nsClipboard.cpp @@ -42,11 +42,6 @@ #include -NS_IMPL_ADDREF_INHERITED(nsClipboard, nsBaseClipboard) -NS_IMPL_RELEASE_INHERITED(nsClipboard, nsBaseClipboard) -//NS_IMPL_QUERY_INTERFACE1(nsClipboard, nsIClipboard) - - // // nsClipboard constructor // @@ -62,33 +57,6 @@ nsClipboard::~nsClipboard() } - -/** - * @param aIID The name of the class implementing the method - * @param _classiiddef The name of the #define symbol that defines the IID - * for the class (e.g. NS_ISUPPORTS_IID) - * -*/ -nsresult nsClipboard::QueryInterface(const nsIID& aIID, void** aInstancePtr) -{ - - if (NULL == aInstancePtr) { - return NS_ERROR_NULL_POINTER; - } - - nsresult rv = NS_NOINTERFACE; - - static NS_DEFINE_IID(kIClipboard, NS_ICLIPBOARD_IID); - if (aIID.Equals(kIClipboard)) { - *aInstancePtr = (void*) ((nsIClipboard*)this); - NS_ADDREF_THIS(); - return NS_OK; - } - - return rv; -} - - // // SetNativeClipboardData // diff --git a/mozilla/widget/src/mac/nsClipboard.h b/mozilla/widget/src/mac/nsClipboard.h index 6873454230e..e71597efcc0 100644 --- a/mozilla/widget/src/mac/nsClipboard.h +++ b/mozilla/widget/src/mac/nsClipboard.h @@ -39,9 +39,6 @@ public: nsClipboard(); virtual ~nsClipboard(); - //nsISupports - NS_DECL_ISUPPORTS_INHERITED - // nsIClipboard //NS_IMETHOD ForceDataToClipboard(); diff --git a/mozilla/widget/src/mac/nsDragService.cpp b/mozilla/widget/src/mac/nsDragService.cpp index a97f4ef79a7..9cd2293798a 100644 --- a/mozilla/widget/src/mac/nsDragService.cpp +++ b/mozilla/widget/src/mac/nsDragService.cpp @@ -39,6 +39,11 @@ DragSendDataUPP nsDragService::sDragSendDataUPP = NewDragSendDataProc(DragSendDataProc); +// we need our own stuff for MacOS because of nsIDragSessionMac. +NS_IMPL_ADDREF_INHERITED(nsDragService, nsBaseDragService) +NS_IMPL_RELEASE_INHERITED(nsDragService, nsBaseDragService) +NS_IMPL_QUERY_INTERFACE3(nsDragService, nsIDragService, nsIDragSession, nsIDragSessionMac) + // // DragService constructor @@ -57,17 +62,6 @@ nsDragService::~nsDragService() } -// -// AddRef -// Release -// QueryInterface -// -// handle the QI for nsIDragSessionMac and farm off anything else to the parent -// class. -// -NS_IMPL_ISUPPORTS_INHERITED(nsDragService,nsBaseDragService,nsIDragSessionMac); - - // // StartDragSession // diff --git a/mozilla/widget/src/mac/nsDragService.h b/mozilla/widget/src/mac/nsDragService.h index a1f3dd211e5..ee6eb3d5660 100644 --- a/mozilla/widget/src/mac/nsDragService.h +++ b/mozilla/widget/src/mac/nsDragService.h @@ -44,9 +44,9 @@ public: nsDragService(); virtual ~nsDragService(); - //nsISupports + //nsISupports - can't use inherited because of nsIDragSessionMac NS_DECL_ISUPPORTS_INHERITED - + //nsIDragService NS_IMETHOD InvokeDragSession (nsISupportsArray * anArrayTransferables, nsIRegion * aRegion, PRUint32 aActionType); diff --git a/mozilla/widget/src/windows/nsDragService.cpp b/mozilla/widget/src/windows/nsDragService.cpp index 3789731362c..c7eb3efe423 100644 --- a/mozilla/widget/src/windows/nsDragService.cpp +++ b/mozilla/widget/src/windows/nsDragService.cpp @@ -31,9 +31,6 @@ #include "OLEIDL.H" -NS_IMPL_ADDREF_INHERITED(nsDragService, nsBaseDragService) -NS_IMPL_RELEASE_INHERITED(nsDragService, nsBaseDragService) - //------------------------------------------------------------------------- // // DragService constructor @@ -60,40 +57,6 @@ nsDragService::~nsDragService() } -/** - * @param aIID The name of the class implementing the method - * @param _classiiddef The name of the #define symbol that defines the IID - * for the class (e.g. NS_ISUPPORTS_IID) - * -*/ -// clean me up! ;) -nsresult nsDragService::QueryInterface(const nsIID& aIID, void** aInstancePtr) -{ - - if (NULL == aInstancePtr) { - return NS_ERROR_NULL_POINTER; - } - - nsresult rv = nsBaseDragService::QueryInterface(aIID, aInstancePtr); - if (NS_OK == rv) { - return NS_OK; - } - - if (aIID.Equals(NS_GET_IID(nsIDragService))) { - *aInstancePtr = (void*) ((nsIDragService*)this); - NS_ADDREF_THIS(); - return NS_OK; - } - - if (aIID.Equals(NS_GET_IID(nsIDragSession))) { - *aInstancePtr = (void*) ((nsIDragSession*)this); - NS_ADDREF_THIS(); - return NS_OK; - } - - return rv; -} - //------------------------------------------------------------------------- NS_IMETHODIMP nsDragService::InvokeDragSession (nsISupportsArray * anArrayTransferables, nsIRegion * aRegion, PRUint32 aActionType) { @@ -236,6 +199,7 @@ NS_IMETHODIMP nsDragService::IsDataFlavorSupported(const char *aDataFlavor, PRBo return NS_ERROR_FAILURE; // First check to see if the mDataObject is is Collection of IDataObjects + *_retval = PR_FALSE; UINT format = nsClipboard::GetFormat(MULTI_MIME); FORMATETC fe; SET_FORMATETC(fe, format, 0, DVASPECT_CONTENT, -1, TYMED_HGLOBAL); @@ -246,11 +210,8 @@ NS_IMETHODIMP nsDragService::IsDataFlavorSupported(const char *aDataFlavor, PRBo format = nsClipboard::GetFormat(aDataFlavor); SET_FORMATETC(fe, format, 0, DVASPECT_CONTENT, -1, TYMED_HGLOBAL | TYMED_FILE | TYMED_GDI); - if (S_OK == mDataObject->QueryGetData(&fe)) { - return NS_OK; - } else { - return NS_ERROR_FAILURE; - } + if (S_OK == mDataObject->QueryGetData(&fe)) + *_retval = PR_TRUE;; } // Set it up for the data flavor @@ -264,12 +225,11 @@ NS_IMETHODIMP nsDragService::IsDataFlavorSupported(const char *aDataFlavor, PRBo PRUint32 cnt = dataObjCol->GetNumDataObjects(); for (i=0;iGetDataObjectAt(i); - if (S_OK == dataObj->QueryGetData(&fe)) { - return NS_OK; - } + if (S_OK == dataObj->QueryGetData(&fe)) + *_retval = PR_TRUE; } - return NS_ERROR_FAILURE; + return NS_OK; } //------------------------------------------------------------------------- diff --git a/mozilla/widget/src/windows/nsDragService.h b/mozilla/widget/src/windows/nsDragService.h index 16ea4787355..09b20592cce 100644 --- a/mozilla/widget/src/windows/nsDragService.h +++ b/mozilla/widget/src/windows/nsDragService.h @@ -35,10 +35,6 @@ class nsDragService : public nsBaseDragService public: nsDragService(); virtual ~nsDragService(); - - //nsISupports - NS_DECL_ISUPPORTS_INHERITED - // nsIDragService NS_IMETHOD InvokeDragSession (nsISupportsArray * anArrayTransferables, nsIRegion * aRegion, PRUint32 aActionType); diff --git a/mozilla/widget/src/xpwidgets/nsBaseClipboard.cpp b/mozilla/widget/src/xpwidgets/nsBaseClipboard.cpp index 47ec0175459..99b1a0ad11a 100644 --- a/mozilla/widget/src/xpwidgets/nsBaseClipboard.cpp +++ b/mozilla/widget/src/xpwidgets/nsBaseClipboard.cpp @@ -29,6 +29,8 @@ NS_IMPL_ADDREF(nsBaseClipboard) NS_IMPL_RELEASE(nsBaseClipboard) +NS_IMPL_QUERY_INTERFACE1(nsBaseClipboard, nsIClipboard); + //------------------------------------------------------------------------- // @@ -54,30 +56,6 @@ nsBaseClipboard::~nsBaseClipboard() EmptyClipboard(); } -/** - * @param aIID The name of the class implementing the method - * @param _classiiddef The name of the #define symbol that defines the IID - * for the class (e.g. NS_ISUPPORTS_IID) - * -*/ -nsresult nsBaseClipboard::QueryInterface(const nsIID& aIID, void** aInstancePtr) -{ - - if (NULL == aInstancePtr) { - return NS_ERROR_NULL_POINTER; - } - - nsresult rv = NS_NOINTERFACE; - - if (aIID.Equals(nsCOMTypeInfo::GetIID())) { - *aInstancePtr = (void*) ((nsIClipboard*)this); - NS_ADDREF_THIS(); - return NS_OK; - } - - return rv; -} - /** * Sets the transferable object diff --git a/mozilla/widget/src/xpwidgets/nsBaseDragService.cpp b/mozilla/widget/src/xpwidgets/nsBaseDragService.cpp index 6741ffac213..04f0b9e5948 100644 --- a/mozilla/widget/src/xpwidgets/nsBaseDragService.cpp +++ b/mozilla/widget/src/xpwidgets/nsBaseDragService.cpp @@ -30,6 +30,8 @@ NS_IMPL_ADDREF(nsBaseDragService) NS_IMPL_RELEASE(nsBaseDragService) +NS_IMPL_QUERY_INTERFACE2(nsBaseDragService, nsIDragService, nsIDragSession) + //------------------------------------------------------------------------- // @@ -56,32 +58,6 @@ nsBaseDragService::~nsBaseDragService() { } -/** - * @param aIID The name of the class implementing the method - * @param _classiiddef The name of the #define symbol that defines the IID - * for the class (e.g. NS_ISUPPORTS_IID) - * -*/ -nsresult nsBaseDragService::QueryInterface(const nsIID& aIID, void** aInstancePtr) -{ - if (NULL == aInstancePtr) - return NS_ERROR_NULL_POINTER; - - nsresult rv = NS_NOINTERFACE; - - if ( aIID.Equals(nsCOMTypeInfo::GetIID()) ) { - *aInstancePtr = NS_STATIC_CAST(nsIDragService*,this); - NS_ADDREF_THIS(); - return NS_OK; - } - else if (aIID.Equals(nsCOMTypeInfo::GetIID())) { - *aInstancePtr = NS_STATIC_CAST(nsIDragSession*,this); - NS_ADDREF_THIS(); - return NS_OK; - } - - return rv; -} //--------------------------------------------------------- NS_IMETHODIMP nsBaseDragService::SetCanDrop (PRBool aCanDrop) diff --git a/mozilla/widget/src/xpwidgets/nsTransferable.cpp b/mozilla/widget/src/xpwidgets/nsTransferable.cpp index 05ac7d7f20c..97484676dfb 100644 --- a/mozilla/widget/src/xpwidgets/nsTransferable.cpp +++ b/mozilla/widget/src/xpwidgets/nsTransferable.cpp @@ -44,8 +44,7 @@ Notes to self: NS_IMPL_ADDREF(nsTransferable) NS_IMPL_RELEASE(nsTransferable) -// NS_IMPL_QUERY_INTERFACE1(nsITransferable) -NS_IMPL_QUERY_INTERFACE(nsTransferable, NS_GET_IID(nsITransferable)) +NS_IMPL_QUERY_INTERFACE1(nsTransferable, nsITransferable) // million bytes diff --git a/mozilla/widget/src/xpwidgets/nsXIFFormatConverter.cpp b/mozilla/widget/src/xpwidgets/nsXIFFormatConverter.cpp index 646607a946d..a0e258b192b 100644 --- a/mozilla/widget/src/xpwidgets/nsXIFFormatConverter.cpp +++ b/mozilla/widget/src/xpwidgets/nsXIFFormatConverter.cpp @@ -50,7 +50,8 @@ static NS_DEFINE_IID(kCParserCID, NS_PARSER_IID); NS_IMPL_ADDREF(nsXIFFormatConverter) NS_IMPL_RELEASE(nsXIFFormatConverter) -NS_IMPL_QUERY_INTERFACE(nsXIFFormatConverter, NS_GET_IID(nsIFormatConverter)) +NS_IMPL_QUERY_INTERFACE1(nsXIFFormatConverter, nsIFormatConverter) + //------------------------------------------------------------------------- //