Added closure argument to nsHashtable::Enumerate.
git-svn-id: svn://10.0.0.236/trunk@8910 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
parent
6f46cc2695
commit
24b7d5e489
@ -51,7 +51,7 @@ char *gSession;
|
||||
char *gDenied;
|
||||
nsPrivilegeTable *gPrivilegeTable;
|
||||
|
||||
static PRBool getPrincipalString(nsHashKey *aKey, void *aData);
|
||||
static PRBool getPrincipalString(nsHashKey *aKey, void *aData, void* closure);
|
||||
|
||||
static nsPrincipal *RDF_getPrincipal(JSec_Principal jsec_pr);
|
||||
static PRBool RDF_RemovePrincipal(nsPrincipal *prin);
|
||||
@ -765,7 +765,7 @@ PRBool nsPrivilegeManager::checkMatchPrincipal(void* context, nsPrincipal *prin,
|
||||
return (comparePrincipalArray(prinArray, classPrinArray) != nsSetComparisonType_NoSubset) ? PR_TRUE : PR_FALSE;
|
||||
}
|
||||
|
||||
static PRBool getPrincipalString(nsHashKey *aKey, void *aData)
|
||||
static PRBool getPrincipalString(nsHashKey *aKey, void *aData, void* closure)
|
||||
{
|
||||
/* Admin UI */
|
||||
/* XXX: Ignore empty strings */
|
||||
@ -813,7 +813,7 @@ nsPrincipal * nsPrivilegeManager::getPrincipalFromString(char *prinName)
|
||||
return prin;
|
||||
}
|
||||
|
||||
static PRBool getPermissionsString(nsHashKey *aKey, void *aData)
|
||||
static PRBool getPermissionsString(nsHashKey *aKey, void *aData, void* closure)
|
||||
{
|
||||
/* Admin UI */
|
||||
TargetKey *targetKey = (TargetKey *) aKey;
|
||||
@ -895,7 +895,7 @@ PRBool nsPrivilegeManager::removePrincipalsPrivilege(char *prinName,
|
||||
return PR_TRUE;
|
||||
}
|
||||
|
||||
static PRBool updatePrivileges(nsHashKey *aKey, void *aData)
|
||||
static PRBool updatePrivileges(nsHashKey *aKey, void *aData, void* closure)
|
||||
{
|
||||
/* Admin UI */
|
||||
TargetKey *targetKey = (TargetKey *) aKey;
|
||||
|
||||
@ -227,7 +227,7 @@ static nsHashtable *theTargetRegistry = new nsHashtable();
|
||||
static nsHashtable *theSystemTargetRegistry = new nsHashtable();
|
||||
static nsHashtable *theDescToTargetRegistry = new nsHashtable();
|
||||
|
||||
static PRBool addToTargetArray(nsHashKey *aKey, void *aData);
|
||||
static PRBool addToTargetArray(nsHashKey *aKey, void *aData, void* closure);
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
@ -1323,7 +1323,7 @@ void nsTarget::getFlattenedTargets(nsHashtable *targHash,
|
||||
}
|
||||
}
|
||||
|
||||
static PRBool addToTargetArray(nsHashKey *aKey, void *aData)
|
||||
static PRBool addToTargetArray(nsHashKey *aKey, void *aData, void* closure)
|
||||
{
|
||||
TargetKey *targetKey = (TargetKey *) aKey;
|
||||
nsTarget *target = targetKey->itsTarget;
|
||||
|
||||
@ -250,7 +250,7 @@ StyleSetImpl::StyleSetImpl()
|
||||
NS_INIT_REFCNT();
|
||||
}
|
||||
|
||||
PRBool ReleaseContext(nsHashKey *aKey, void *aData)
|
||||
PRBool ReleaseContext(nsHashKey *aKey, void *aData, void* closure)
|
||||
{
|
||||
((nsIStyleContext*)aData)->Release();
|
||||
return PR_TRUE;
|
||||
@ -726,7 +726,7 @@ static ContextNode* FindNode(nsIStyleContext* aContext, ContextNode* aStart)
|
||||
return nsnull;
|
||||
}
|
||||
|
||||
PRBool GatherContexts(nsHashKey *aKey, void *aData)
|
||||
PRBool GatherContexts(nsHashKey *aKey, void *aData, void* closure)
|
||||
{
|
||||
PRBool result = PR_TRUE;
|
||||
|
||||
|
||||
@ -144,7 +144,7 @@ RuleHash::RuleHash(void)
|
||||
{
|
||||
}
|
||||
|
||||
static PRBool DeleteValue(nsHashKey* aKey, void* aValue)
|
||||
static PRBool DeleteValue(nsHashKey* aKey, void* aValue, void* closure)
|
||||
{
|
||||
delete ((RuleValue*)aValue);
|
||||
return PR_TRUE;
|
||||
|
||||
@ -250,7 +250,7 @@ StyleSetImpl::StyleSetImpl()
|
||||
NS_INIT_REFCNT();
|
||||
}
|
||||
|
||||
PRBool ReleaseContext(nsHashKey *aKey, void *aData)
|
||||
PRBool ReleaseContext(nsHashKey *aKey, void *aData, void* closure)
|
||||
{
|
||||
((nsIStyleContext*)aData)->Release();
|
||||
return PR_TRUE;
|
||||
@ -726,7 +726,7 @@ static ContextNode* FindNode(nsIStyleContext* aContext, ContextNode* aStart)
|
||||
return nsnull;
|
||||
}
|
||||
|
||||
PRBool GatherContexts(nsHashKey *aKey, void *aData)
|
||||
PRBool GatherContexts(nsHashKey *aKey, void *aData, void* closure)
|
||||
{
|
||||
PRBool result = PR_TRUE;
|
||||
|
||||
|
||||
@ -144,7 +144,7 @@ RuleHash::RuleHash(void)
|
||||
{
|
||||
}
|
||||
|
||||
static PRBool DeleteValue(nsHashKey* aKey, void* aValue)
|
||||
static PRBool DeleteValue(nsHashKey* aKey, void* aValue, void* closure)
|
||||
{
|
||||
delete ((RuleValue*)aValue);
|
||||
return PR_TRUE;
|
||||
|
||||
@ -144,7 +144,7 @@ RuleHash::RuleHash(void)
|
||||
{
|
||||
}
|
||||
|
||||
static PRBool DeleteValue(nsHashKey* aKey, void* aValue)
|
||||
static PRBool DeleteValue(nsHashKey* aKey, void* aValue, void* closure)
|
||||
{
|
||||
delete ((RuleValue*)aValue);
|
||||
return PR_TRUE;
|
||||
|
||||
@ -250,7 +250,7 @@ StyleSetImpl::StyleSetImpl()
|
||||
NS_INIT_REFCNT();
|
||||
}
|
||||
|
||||
PRBool ReleaseContext(nsHashKey *aKey, void *aData)
|
||||
PRBool ReleaseContext(nsHashKey *aKey, void *aData, void* closure)
|
||||
{
|
||||
((nsIStyleContext*)aData)->Release();
|
||||
return PR_TRUE;
|
||||
@ -726,7 +726,7 @@ static ContextNode* FindNode(nsIStyleContext* aContext, ContextNode* aStart)
|
||||
return nsnull;
|
||||
}
|
||||
|
||||
PRBool GatherContexts(nsHashKey *aKey, void *aData)
|
||||
PRBool GatherContexts(nsHashKey *aKey, void *aData, void* closure)
|
||||
{
|
||||
PRBool result = PR_TRUE;
|
||||
|
||||
|
||||
@ -71,11 +71,17 @@ static PLHashAllocOps _hashAllocOps = {
|
||||
// Enumerator callback
|
||||
//
|
||||
|
||||
struct _HashEnumerateArgs {
|
||||
nsHashtableEnumFunc fn;
|
||||
void* arg;
|
||||
};
|
||||
|
||||
static PR_CALLBACK PRIntn _hashEnumerate(PLHashEntry *he, PRIntn i, void *arg)
|
||||
{
|
||||
return ((nsHashtableEnumFunc) arg)((nsHashKey *) he->key, he->value) ?
|
||||
HT_ENUMERATE_NEXT :
|
||||
HT_ENUMERATE_STOP;
|
||||
_HashEnumerateArgs* thunk = (_HashEnumerateArgs*)arg;
|
||||
return thunk->fn((nsHashKey *) he->key, he->value, thunk->arg)
|
||||
? HT_ENUMERATE_NEXT
|
||||
: HT_ENUMERATE_STOP;
|
||||
}
|
||||
|
||||
//
|
||||
@ -151,6 +157,9 @@ nsHashtable * nsHashtable::Clone() {
|
||||
return newHashTable;
|
||||
}
|
||||
|
||||
void nsHashtable::Enumerate(nsHashtableEnumFunc aEnumFunc) {
|
||||
PL_HashTableEnumerateEntries(hashtable, _hashEnumerate, aEnumFunc);
|
||||
void nsHashtable::Enumerate(nsHashtableEnumFunc aEnumFunc, void* closure) {
|
||||
_HashEnumerateArgs thunk;
|
||||
thunk.fn = aEnumFunc;
|
||||
thunk.arg = closure;
|
||||
PL_HashTableEnumerateEntries(hashtable, _hashEnumerate, &thunk);
|
||||
}
|
||||
|
||||
@ -71,11 +71,17 @@ static PLHashAllocOps _hashAllocOps = {
|
||||
// Enumerator callback
|
||||
//
|
||||
|
||||
struct _HashEnumerateArgs {
|
||||
nsHashtableEnumFunc fn;
|
||||
void* arg;
|
||||
};
|
||||
|
||||
static PR_CALLBACK PRIntn _hashEnumerate(PLHashEntry *he, PRIntn i, void *arg)
|
||||
{
|
||||
return ((nsHashtableEnumFunc) arg)((nsHashKey *) he->key, he->value) ?
|
||||
HT_ENUMERATE_NEXT :
|
||||
HT_ENUMERATE_STOP;
|
||||
_HashEnumerateArgs* thunk = (_HashEnumerateArgs*)arg;
|
||||
return thunk->fn((nsHashKey *) he->key, he->value, thunk->arg)
|
||||
? HT_ENUMERATE_NEXT
|
||||
: HT_ENUMERATE_STOP;
|
||||
}
|
||||
|
||||
//
|
||||
@ -151,6 +157,9 @@ nsHashtable * nsHashtable::Clone() {
|
||||
return newHashTable;
|
||||
}
|
||||
|
||||
void nsHashtable::Enumerate(nsHashtableEnumFunc aEnumFunc) {
|
||||
PL_HashTableEnumerateEntries(hashtable, _hashEnumerate, aEnumFunc);
|
||||
void nsHashtable::Enumerate(nsHashtableEnumFunc aEnumFunc, void* closure) {
|
||||
_HashEnumerateArgs thunk;
|
||||
thunk.fn = aEnumFunc;
|
||||
thunk.arg = closure;
|
||||
PL_HashTableEnumerateEntries(hashtable, _hashEnumerate, &thunk);
|
||||
}
|
||||
|
||||
@ -34,7 +34,7 @@ public:
|
||||
|
||||
// Enumerator callback function. Use
|
||||
|
||||
typedef PRBool (*nsHashtableEnumFunc)(nsHashKey *aKey, void *aData);
|
||||
typedef PRBool (*nsHashtableEnumFunc)(nsHashKey *aKey, void *aData, void* closure);
|
||||
|
||||
class NS_COM nsHashtable {
|
||||
private:
|
||||
@ -50,7 +50,7 @@ public:
|
||||
void *Get(nsHashKey *aKey);
|
||||
void *Remove(nsHashKey *aKey);
|
||||
nsHashtable *Clone();
|
||||
void Enumerate(nsHashtableEnumFunc aEnumFunc);
|
||||
void Enumerate(nsHashtableEnumFunc aEnumFunc, void* closure = NULL);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user