From 3bd70bbd4ea4bc39adb3f0a45be6f9868d243d43 Mon Sep 17 00:00:00 2001 From: "bryner%brianryner.com" Date: Sat, 9 Aug 2003 10:08:00 +0000 Subject: [PATCH] Convert nsIAutoCompleteResultTypes.h to an IDL file, which makes QI'ing to those interfaces work as expected. --- .../autocomplete/public/Makefile.in | 3 +- ...Types.h => nsIAutoCompleteResultTypes.idl} | 67 +++++++++++-------- .../src/nsAutoCompleteMdbResult.cpp | 22 ++++-- .../src/nsAutoCompleteMdbResult.h | 21 ++---- .../components/satchel/src/nsFormHistory.cpp | 1 + 5 files changed, 61 insertions(+), 53 deletions(-) rename toolkit/components/autocomplete/public/{nsIAutoCompleteResultTypes.h => nsIAutoCompleteResultTypes.idl} (58%) mode change 100644 => 100755 diff --git a/toolkit/components/autocomplete/public/Makefile.in b/toolkit/components/autocomplete/public/Makefile.in index db911d444978..b2acfad14b54 100644 --- a/toolkit/components/autocomplete/public/Makefile.in +++ b/toolkit/components/autocomplete/public/Makefile.in @@ -33,8 +33,7 @@ XPIDLSRCS = nsIAutoCompleteController.idl \ nsIAutoCompletePopup.idl \ nsIAutoCompleteSearch.idl \ nsIAutoCompleteResult.idl \ + nsIAutoCompleteResultTypes.idl \ $(NULL) -EXPORTS = nsIAutoCompleteResultTypes.h - include $(topsrcdir)/config/rules.mk diff --git a/toolkit/components/autocomplete/public/nsIAutoCompleteResultTypes.h b/toolkit/components/autocomplete/public/nsIAutoCompleteResultTypes.idl old mode 100644 new mode 100755 similarity index 58% rename from toolkit/components/autocomplete/public/nsIAutoCompleteResultTypes.h rename to toolkit/components/autocomplete/public/nsIAutoCompleteResultTypes.idl index da593075c8f4..04141f0ecf4c --- a/toolkit/components/autocomplete/public/nsIAutoCompleteResultTypes.h +++ b/toolkit/components/autocomplete/public/nsIAutoCompleteResultTypes.idl @@ -35,40 +35,51 @@ * * ***** END LICENSE BLOCK ***** */ -#ifndef __nsIAutoCompleteResultTypes__ -#define __nsIAutoCompleteResultTypes__ +#include "nsIAutoCompleteResult.idl" -#include "nsIAutoCompleteResult.h" -#include "nsString.h" -#include "nsVoidArray.h" +interface nsIMdbTable; +interface nsIMdbEnv; +interface nsIMdbRow; + +%{ C++ #include "mdb.h" +%} -class nsIAutoCompleteBaseResult : public nsIAutoCompleteResult +native mdb_scope(mdb_scope); +native mdb_column(mdb_column); + +/* noscript */ +[uuid(c5257f44-b4d0-41aa-a50b-5b7bcefcc235)] +interface nsIAutoCompleteBaseResult : nsIAutoCompleteResult { -public: - NS_IMETHOD SetSearchString(const nsAString &aSearchString) = 0; - NS_IMETHOD SetErrorDescription(const nsAString &aErrorDescription) = 0; - NS_IMETHOD SetDefaultIndex(PRInt32 aDefaultIndex) = 0; - NS_IMETHOD SetSearchResult(PRUint32 aSearchResult) = 0; + void setSearchString(in AString searchString); + void setErrorDescription(in AString errorDescription); + void setDefaultIndex(in long defaultIndex); + void setSearchResult(in unsigned long searchResult); }; -class nsIAutoCompleteMdbResult : public nsIAutoCompleteBaseResult +/* noscript */ +[uuid(f7e7b341-2d5c-4d04-9f51-496cb2ce178c)] +interface nsIAutoCompleteMdbResult : nsIAutoCompleteBaseResult { -public: - enum eDataType { - kUnicharType, - kCharType, - kIntType - }; + const short kUnicharType = 0; + const short kCharType = 1; + const short kIntType = 2; - NS_IMETHOD Init(nsIMdbEnv *aEnv, nsIMdbTable *aTable) = 0; - NS_IMETHOD SetTokens(mdb_scope aValueToken, eDataType aValueType, mdb_scope aCommentToken, eDataType aCommentType) = 0; - NS_IMETHOD AddRow(nsIMdbRow *aRow) = 0; - NS_IMETHOD RemoveRowAt(PRUint32 aRowIndex) = 0; - NS_IMETHOD GetRowAt(PRUint32 aRowIndex, nsIMdbRow **aRow) = 0; - NS_IMETHOD GetRowValue(nsIMdbRow *aRow, mdb_column aCol, nsAString &aValue) = 0; - NS_IMETHOD GetRowValue(nsIMdbRow *aRow, mdb_column aCol, nsACString &aValue) = 0; - NS_IMETHOD GetRowValue(nsIMdbRow *aRow, mdb_column aCol, PRInt32 *aValue) = 0; + void init(in nsIMdbEnv env, in nsIMdbTable table); + + void setTokens(in mdb_scope valueToken, in short valueType, + in mdb_scope commentToken, in short commentType); + + void addRow(in nsIMdbRow row); + + void removeRowAt(in unsigned long rowIndex); + + nsIMdbRow getRowAt(in unsigned long rowIndex); + + AString getRowValue(in nsIMdbRow row, in mdb_column col); + + AUTF8String getUTF8RowValue(in nsIMdbRow row, in mdb_column col); + + long getIntRowValue(in nsIMdbRow row, in mdb_column col); }; - -#endif // __nsIAutoCompleteResultTypes__ diff --git a/toolkit/components/autocomplete/src/nsAutoCompleteMdbResult.cpp b/toolkit/components/autocomplete/src/nsAutoCompleteMdbResult.cpp index 846bd1156a7e..a768074e2619 100644 --- a/toolkit/components/autocomplete/src/nsAutoCompleteMdbResult.cpp +++ b/toolkit/components/autocomplete/src/nsAutoCompleteMdbResult.cpp @@ -39,7 +39,15 @@ #include "nsCOMPtr.h" #include "nsCRT.h" -NS_IMPL_ISUPPORTS1(nsAutoCompleteMdbResult, nsIAutoCompleteResult) +NS_INTERFACE_MAP_BEGIN(nsAutoCompleteMdbResult) + NS_INTERFACE_MAP_ENTRY(nsIAutoCompleteResult) + NS_INTERFACE_MAP_ENTRY(nsIAutoCompleteBaseResult) + NS_INTERFACE_MAP_ENTRY(nsIAutoCompleteMdbResult) + NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIAutoCompleteResult) +NS_INTERFACE_MAP_END + +NS_IMPL_ADDREF(nsAutoCompleteMdbResult) +NS_IMPL_RELEASE(nsAutoCompleteMdbResult) nsAutoCompleteMdbResult::nsAutoCompleteMdbResult() : mDefaultIndex(-1), @@ -102,7 +110,7 @@ nsAutoCompleteMdbResult::GetValueAt(PRInt32 aIndex, nsAString & _retval) GetRowValue(row, mValueToken, _retval); } else if (mValueType == kCharType) { nsCAutoString value; - GetRowValue(row, mValueToken, value); + GetUTF8RowValue(row, mValueToken, value); _retval = NS_ConvertUTF8toUCS2(value); } @@ -129,7 +137,7 @@ nsAutoCompleteMdbResult::GetCommentAt(PRInt32 aIndex, nsAString & _retval) GetRowValue(row, mCommentToken, _retval); } else if (mCommentType == kCharType) { nsCAutoString value; - GetRowValue(row, mCommentToken, value); + GetUTF8RowValue(row, mCommentToken, value); _retval = NS_ConvertUTF8toUCS2(value); } @@ -185,7 +193,7 @@ nsAutoCompleteMdbResult::Init(nsIMdbEnv *aEnv, nsIMdbTable *aTable) } NS_IMETHODIMP -nsAutoCompleteMdbResult::SetTokens(mdb_scope aValueToken, eDataType aValueType, mdb_scope aCommentToken, eDataType aCommentType) +nsAutoCompleteMdbResult::SetTokens(mdb_scope aValueToken, PRInt16 aValueType, mdb_scope aCommentToken, PRInt16 aCommentType) { mValueToken = aValueToken; mValueType = aValueType; @@ -243,7 +251,8 @@ nsAutoCompleteMdbResult::GetRowValue(nsIMdbRow *aRow, mdb_column aCol, nsAString nsresult -nsAutoCompleteMdbResult::GetRowValue(nsIMdbRow *aRow, mdb_column aCol, nsACString& aValue) +nsAutoCompleteMdbResult::GetUTF8RowValue(nsIMdbRow *aRow, mdb_column aCol, + nsACString& aValue) { mdb_err err; @@ -261,7 +270,8 @@ nsAutoCompleteMdbResult::GetRowValue(nsIMdbRow *aRow, mdb_column aCol, nsACStrin } nsresult -nsAutoCompleteMdbResult::GetRowValue(nsIMdbRow *aRow, mdb_column aCol, PRInt32 *aValue) +nsAutoCompleteMdbResult::GetIntRowValue(nsIMdbRow *aRow, mdb_column aCol, + PRInt32 *aValue) { mdb_err err; diff --git a/toolkit/components/autocomplete/src/nsAutoCompleteMdbResult.h b/toolkit/components/autocomplete/src/nsAutoCompleteMdbResult.h index b06ccdf754ba..fb085bb5c7f5 100644 --- a/toolkit/components/autocomplete/src/nsAutoCompleteMdbResult.h +++ b/toolkit/components/autocomplete/src/nsAutoCompleteMdbResult.h @@ -53,22 +53,9 @@ public: nsAutoCompleteMdbResult(); virtual ~nsAutoCompleteMdbResult(); - // nsIAutoCompleteBaseResult - NS_IMETHOD SetSearchString(const nsAString &aSearchString); - NS_IMETHOD SetErrorDescription(const nsAString &aErrorDescription); - NS_IMETHOD SetDefaultIndex(PRInt32 aDefaultIndex); - NS_IMETHOD SetSearchResult(PRUint32 aSearchResult); + NS_DECL_NSIAUTOCOMPLETEBASERESULT + NS_DECL_NSIAUTOCOMPLETEMDBRESULT - // nsIAutoCompleteMdbResult - NS_IMETHOD Init(nsIMdbEnv *aEnv, nsIMdbTable *aTable); - NS_IMETHOD SetTokens(mdb_scope aValueToken, eDataType aValueType, mdb_scope aCommentToken, eDataType aCommentType); - NS_IMETHOD AddRow(nsIMdbRow *aRow); - NS_IMETHOD RemoveRowAt(PRUint32 aRowIndex); - NS_IMETHOD GetRowAt(PRUint32 aRowIndex, nsIMdbRow **aRow); - NS_IMETHOD GetRowValue(nsIMdbRow *aRow, mdb_column aCol, nsAString &aValue); - NS_IMETHOD GetRowValue(nsIMdbRow *aRow, mdb_column aCol, nsACString &aValue); - NS_IMETHOD GetRowValue(nsIMdbRow *aRow, mdb_column aCol, PRInt32 *aValue); - protected: nsAutoVoidArray mResults; @@ -81,9 +68,9 @@ protected: nsIMdbTable *mTable; mdb_scope mValueToken; - eDataType mValueType; + PRInt16 mValueType; mdb_scope mCommentToken; - eDataType mCommentType; + PRInt16 mCommentType; }; #endif // __nsAutoCompleteResultBase__ diff --git a/toolkit/components/satchel/src/nsFormHistory.cpp b/toolkit/components/satchel/src/nsFormHistory.cpp index 45f5ba31f6bb..bede14400fb9 100644 --- a/toolkit/components/satchel/src/nsFormHistory.cpp +++ b/toolkit/components/satchel/src/nsFormHistory.cpp @@ -54,6 +54,7 @@ #include "nsIDOMHTMLFormElement.h" #include "nsIDOMHTMLInputElement.h" #include "nsIDOMHTMLCollection.h" +#include "nsVoidArray.h" static const char *kFormHistoryFileName = "formhistory.dat";