Bug 1057914 (part 1) - Remove enumeration methods from nsICommandParams. r=ehsan.

--HG--
extra : rebase_source : 313bf18bd88f1fbdb9a308aecbab666b8ff87adf
This commit is contained in:
Nicholas Nethercote 2014-08-17 21:58:10 -07:00
parent c20d95b943
commit f47c6d907e
3 changed files with 9 additions and 115 deletions

View File

@ -28,8 +28,6 @@ const PLDHashTableOps nsCommandParams::sHashOps =
NS_IMPL_ISUPPORTS(nsCommandParams, nsICommandParams)
nsCommandParams::nsCommandParams()
: mCurEntry(0)
, mNumEntries(eNumEntriesUnknown)
{
// init the hash table later
}
@ -238,8 +236,6 @@ nsCommandParams::RemoveValue(const char * name)
// NS_OK unconditionally.
(void)PL_DHashTableOperate(&mValuesHash, (void *)name, PL_DHASH_REMOVE);
// inval the number of entries
mNumEntries = eNumEntriesUnknown;
return NS_OK;
}
@ -258,43 +254,6 @@ nsCommandParams::GetNamedEntry(const char * name)
return nullptr;
}
nsCommandParams::HashEntry*
nsCommandParams::GetIndexedEntry(int32_t index)
{
HashEntry* entry = reinterpret_cast<HashEntry*>(mValuesHash.entryStore);
HashEntry* limit = entry + PL_DHASH_TABLE_CAPACITY(&mValuesHash);
uint32_t entryCount = 0;
do {
if (!PL_DHASH_ENTRY_IS_LIVE(entry))
continue;
if ((int32_t)entryCount == index)
return entry;
entryCount ++;
} while (++entry < limit);
return nullptr;
}
uint32_t
nsCommandParams::GetNumEntries()
{
HashEntry* entry = reinterpret_cast<HashEntry*>(mValuesHash.entryStore);
HashEntry* limit = entry + PL_DHASH_TABLE_CAPACITY(&mValuesHash);
uint32_t entryCount = 0;
do {
if (PL_DHASH_ENTRY_IS_LIVE(entry))
entryCount ++;
} while (++entry < limit);
return entryCount;
}
nsCommandParams::HashEntry*
nsCommandParams::GetOrMakeEntry(const char * name, uint8_t entryType)
{
@ -357,36 +316,3 @@ nsCommandParams::HashClearEntry(PLDHashTable *table, PLDHashEntryHdr *entry)
#pragma mark -
#endif
/* boolean hasMoreElements (); */
NS_IMETHODIMP
nsCommandParams::HasMoreElements(bool *_retval)
{
NS_ENSURE_ARG_POINTER(_retval);
if (mNumEntries == eNumEntriesUnknown)
mNumEntries = GetNumEntries();
*_retval = mCurEntry < mNumEntries;
return NS_OK;
}
/* void first (); */
NS_IMETHODIMP
nsCommandParams::First()
{
mCurEntry = 0;
return NS_OK;
}
/* AString getNext (); */
NS_IMETHODIMP
nsCommandParams::GetNext(char **_retval)
{
HashEntry* thisEntry = GetIndexedEntry(mCurEntry);
if (!thisEntry)
return NS_ERROR_FAILURE;
*_retval = ToNewCString(thisEntry->mEntryName);
mCurEntry++;
return NS_OK;
}

View File

@ -104,9 +104,6 @@ protected:
HashEntry* GetNamedEntry(const char * name);
HashEntry* GetIndexedEntry(int32_t index);
uint32_t GetNumEntries();
HashEntry* GetOrMakeEntry(const char * name, uint8_t entryType);
protected:
@ -124,10 +121,6 @@ protected:
protected:
enum {
eNumEntriesUnknown = -1
};
// this is going to have to use a pldhash, because we need to
// be able to iterate through entries, passing names back
// to the caller, which means that we need to store the names
@ -135,10 +128,6 @@ protected:
PLDHashTable mValuesHash;
// enumerator data
int32_t mCurEntry;
int32_t mNumEntries; // number of entries at start of enumeration (-1 indicates not known)
static const PLDHashTableOps sHashOps;
};

View File

@ -11,10 +11,9 @@
*
*/
[scriptable, uuid(83f892cf-7ed3-490e-967a-62640f3158e1)]
[scriptable, uuid(b1fdf3c4-74e3-4f7d-a14d-2b76bcf53482)]
interface nsICommandParams : nsISupports
{
/*
* List of primitive types for parameter values.
*/
@ -28,18 +27,18 @@ interface nsICommandParams : nsISupports
/*
* getValueType
*
*
* Get the type of a specified parameter
*/
short getValueType(in string name);
/*
* get_Value
*
*
* Get the value of a specified parameter. Will return
* an error if the parameter does not exist, or if the value
* is of the wrong type (no coercion is performed for you).
*
*
* nsISupports values can contain any XPCOM interface,
* as documented for the command. It is permissible
* for it to contain nsICommandParams, but not *this*
@ -51,13 +50,13 @@ interface nsICommandParams : nsISupports
AString getStringValue(in string name);
string getCStringValue(in string name);
nsISupports getISupportsValue(in string name);
/*
* set_Value
*
*
* Set the value of a specified parameter (thus creating
* an entry for it).
*
*
* nsISupports values can contain any XPCOM interface,
* as documented for the command. It is permissible
* for it to contain nsICommandParams, but not *this*
@ -69,33 +68,13 @@ interface nsICommandParams : nsISupports
void setStringValue(in string name, in AString value);
void setCStringValue(in string name, in string value);
void setISupportsValue(in string name, in nsISupports value);
/*
* removeValue
*
*
* Remove the specified parameter from the list.
*/
void removeValue(in string name);
/*
* Enumeration methods
*
* Use these to enumerate over the contents of a parameter
* list. For each name that getNext() returns, use
* getValueType() and then getMumbleValue to get its
* value.
*/
boolean hasMoreElements();
void first();
/**
* GetNext()
*
* @return string pointer that will be allocated and is up
* to the caller to free
*/
string getNext();
};
// {f7fa4581-238e-11d5-a73c-ab64fb68f2bc}