зеркало из https://github.com/mozilla/pjs.git
Added closure argument to nsHashtable::Enumerate.
This commit is contained in:
Родитель
0a534a0c5d
Коммит
28969e9e90
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -1,56 +0,0 @@
|
|||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
#ifndef nsHashtable_h__
|
||||
#define nsHashtable_h__
|
||||
|
||||
#include "plhash.h"
|
||||
#include "nsCom.h"
|
||||
|
||||
class NS_COM nsHashKey {
|
||||
protected:
|
||||
nsHashKey(void);
|
||||
public:
|
||||
virtual ~nsHashKey(void);
|
||||
virtual PRUint32 HashValue(void) const = 0;
|
||||
virtual PRBool Equals(const nsHashKey *aKey) const = 0;
|
||||
virtual nsHashKey *Clone(void) const = 0;
|
||||
};
|
||||
|
||||
// Enumerator callback function. Use
|
||||
|
||||
typedef PRBool (*nsHashtableEnumFunc)(nsHashKey *aKey, void *aData);
|
||||
|
||||
class NS_COM nsHashtable {
|
||||
private:
|
||||
// members
|
||||
PLHashTable *hashtable;
|
||||
|
||||
public:
|
||||
nsHashtable(PRUint32 aSize = 256);
|
||||
~nsHashtable();
|
||||
|
||||
PRInt32 Count(void) { return hashtable->nentries; }
|
||||
void *Put(nsHashKey *aKey, void *aData);
|
||||
void *Get(nsHashKey *aKey);
|
||||
void *Remove(nsHashKey *aKey);
|
||||
nsHashtable *Clone();
|
||||
void Enumerate(nsHashtableEnumFunc aEnumFunc);
|
||||
};
|
||||
|
||||
#endif
|
Загрузка…
Ссылка в новой задаче