mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 765436 - Remove WrappedNative2WrapperMap; r=mrbkap
It is completely unused. --HG-- extra : rebase_source : c267f58324d2b9ff8b7558253c23e2aa01c681ec
This commit is contained in:
parent
20c87fa332
commit
d7c945f469
@ -47,7 +47,6 @@ class NativeSetMap;
|
||||
class IID2ThisTranslatorMap;
|
||||
class XPCNativeScriptableSharedMap;
|
||||
class XPCWrappedNativeProtoMap;
|
||||
class WrappedNative2WrapperMap;
|
||||
class JSObject2JSObjectMap;
|
||||
|
||||
class nsXPCComponents;
|
||||
|
@ -649,132 +649,3 @@ XPCWrappedNativeProtoMap::~XPCWrappedNativeProtoMap()
|
||||
}
|
||||
|
||||
/***************************************************************************/
|
||||
// implement WrappedNative2WrapperMap...
|
||||
|
||||
struct JSDHashTableOps
|
||||
WrappedNative2WrapperMap::sOps = {
|
||||
JS_DHashAllocTable,
|
||||
JS_DHashFreeTable,
|
||||
JS_DHashVoidPtrKeyStub,
|
||||
JS_DHashMatchEntryStub,
|
||||
MoveLink,
|
||||
ClearLink,
|
||||
JS_DHashFinalizeStub,
|
||||
nsnull
|
||||
};
|
||||
|
||||
// static
|
||||
void
|
||||
WrappedNative2WrapperMap::ClearLink(JSDHashTable* table,
|
||||
JSDHashEntryHdr* entry)
|
||||
{
|
||||
Entry* e = static_cast<Entry*>(entry);
|
||||
e->key = nsnull;
|
||||
PR_REMOVE_LINK(&e->value);
|
||||
memset(e, 0, sizeof(*e));
|
||||
}
|
||||
|
||||
// static
|
||||
void
|
||||
WrappedNative2WrapperMap::MoveLink(JSDHashTable* table,
|
||||
const JSDHashEntryHdr* from,
|
||||
JSDHashEntryHdr* to)
|
||||
{
|
||||
const Entry* oldEntry = static_cast<const Entry*>(from);
|
||||
Entry* newEntry = static_cast<Entry*>(to);
|
||||
|
||||
newEntry->key = oldEntry->key;
|
||||
|
||||
// Now update the list.
|
||||
if (PR_CLIST_IS_EMPTY(&oldEntry->value)) {
|
||||
PR_INIT_CLIST(&newEntry->value);
|
||||
newEntry->value.obj = oldEntry->value.obj;
|
||||
} else {
|
||||
newEntry->value = oldEntry->value;
|
||||
newEntry->value.next->prev = &newEntry->value;
|
||||
newEntry->value.prev->next = &newEntry->value;
|
||||
}
|
||||
}
|
||||
|
||||
// static
|
||||
WrappedNative2WrapperMap*
|
||||
WrappedNative2WrapperMap::newMap(int size)
|
||||
{
|
||||
WrappedNative2WrapperMap* map = new WrappedNative2WrapperMap(size);
|
||||
if (map && map->mTable)
|
||||
return map;
|
||||
delete map;
|
||||
return nsnull;
|
||||
}
|
||||
|
||||
WrappedNative2WrapperMap::WrappedNative2WrapperMap(int size)
|
||||
{
|
||||
mTable = JS_NewDHashTable(&sOps, nsnull, sizeof(Entry), size);
|
||||
}
|
||||
|
||||
WrappedNative2WrapperMap::~WrappedNative2WrapperMap()
|
||||
{
|
||||
if (mTable)
|
||||
JS_DHashTableDestroy(mTable);
|
||||
}
|
||||
|
||||
JSObject*
|
||||
WrappedNative2WrapperMap::Add(WrappedNative2WrapperMap* head,
|
||||
JSObject* wrappedObject,
|
||||
JSObject* wrapper)
|
||||
{
|
||||
NS_PRECONDITION(wrappedObject,"bad param");
|
||||
Entry* entry = (Entry*)
|
||||
JS_DHashTableOperate(mTable, wrappedObject, JS_DHASH_ADD);
|
||||
if (!entry)
|
||||
return nsnull;
|
||||
NS_ASSERTION(!entry->key || this == head, "dangling pointer?");
|
||||
entry->key = wrappedObject;
|
||||
Link* l = &entry->value;
|
||||
|
||||
NS_ASSERTION(!l->obj, "Uh, how'd this happen?");
|
||||
|
||||
if (!l->next) {
|
||||
// Initialize the circular list. This case only happens when
|
||||
// this == head.
|
||||
PR_INIT_CLIST(l);
|
||||
}
|
||||
|
||||
l->obj = wrapper;
|
||||
|
||||
if (this != head) {
|
||||
Link* headLink = head->FindLink(wrappedObject);
|
||||
if (!headLink) {
|
||||
Entry* dummy = (Entry*)
|
||||
JS_DHashTableOperate(head->mTable, wrappedObject, JS_DHASH_ADD);
|
||||
dummy->key = wrappedObject;
|
||||
headLink = &dummy->value;
|
||||
PR_INIT_CLIST(headLink);
|
||||
headLink->obj = nsnull;
|
||||
}
|
||||
|
||||
PR_INSERT_BEFORE(l, headLink);
|
||||
}
|
||||
|
||||
return wrapper;
|
||||
}
|
||||
|
||||
bool
|
||||
WrappedNative2WrapperMap::AddLink(JSObject* wrappedObject, Link* oldLink)
|
||||
{
|
||||
Entry* entry = (Entry*)
|
||||
JS_DHashTableOperate(mTable, wrappedObject, JS_DHASH_ADD);
|
||||
if (!entry)
|
||||
return false;
|
||||
NS_ASSERTION(!entry->key, "Eh? What's happening?");
|
||||
entry->key = wrappedObject;
|
||||
Link* newLink = &entry->value;
|
||||
|
||||
PR_INSERT_LINK(newLink, oldLink);
|
||||
PR_REMOVE_AND_INIT_LINK(oldLink);
|
||||
newLink->obj = oldLink->obj;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/***************************************************************************/
|
||||
|
@ -601,78 +601,7 @@ private:
|
||||
JSDHashTable *mTable;
|
||||
};
|
||||
|
||||
class WrappedNative2WrapperMap
|
||||
{
|
||||
static struct JSDHashTableOps sOps;
|
||||
|
||||
static void ClearLink(JSDHashTable* table, JSDHashEntryHdr* entry);
|
||||
static void MoveLink(JSDHashTable* table, const JSDHashEntryHdr* from,
|
||||
JSDHashEntryHdr* to);
|
||||
|
||||
public:
|
||||
struct Link : public PRCList
|
||||
{
|
||||
JSObject *obj;
|
||||
};
|
||||
|
||||
struct Entry : public JSDHashEntryHdr
|
||||
{
|
||||
// Note: key must be the flat JSObject for a wrapped native.
|
||||
JSObject* key;
|
||||
Link value;
|
||||
};
|
||||
|
||||
static WrappedNative2WrapperMap* newMap(int size);
|
||||
|
||||
inline JSObject* Find(JSObject* wrapper)
|
||||
{
|
||||
NS_PRECONDITION(wrapper, "bad param");
|
||||
Entry* entry = (Entry*)
|
||||
JS_DHashTableOperate(mTable, wrapper, JS_DHASH_LOOKUP);
|
||||
if (JS_DHASH_ENTRY_IS_FREE(entry))
|
||||
return nsnull;
|
||||
return entry->value.obj;
|
||||
}
|
||||
|
||||
// Note: If the entry already exists, then this will overwrite the
|
||||
// existing entry, returning the old value.
|
||||
JSObject* Add(WrappedNative2WrapperMap* head,
|
||||
JSObject* wrappedObject,
|
||||
JSObject* wrapper);
|
||||
|
||||
// Function to find a link.
|
||||
Link* FindLink(JSObject* wrappedObject)
|
||||
{
|
||||
Entry* entry = (Entry*)
|
||||
JS_DHashTableOperate(mTable, wrappedObject, JS_DHASH_LOOKUP);
|
||||
if (JS_DHASH_ENTRY_IS_BUSY(entry))
|
||||
return &entry->value;
|
||||
return nsnull;
|
||||
}
|
||||
|
||||
// "Internal" function to add an empty link without doing unnecessary
|
||||
// work.
|
||||
bool AddLink(JSObject* wrappedObject, Link* oldLink);
|
||||
|
||||
inline void Remove(JSObject* wrapper)
|
||||
{
|
||||
NS_PRECONDITION(wrapper,"bad param");
|
||||
JS_DHashTableOperate(mTable, wrapper, JS_DHASH_REMOVE);
|
||||
}
|
||||
|
||||
inline uint32_t Count() {return mTable->entryCount;}
|
||||
inline uint32_t Enumerate(JSDHashEnumerator f, void *arg)
|
||||
{return JS_DHashTableEnumerate(mTable, f, arg);}
|
||||
|
||||
~WrappedNative2WrapperMap();
|
||||
|
||||
private:
|
||||
WrappedNative2WrapperMap(); // no implementation
|
||||
WrappedNative2WrapperMap(int size);
|
||||
|
||||
private:
|
||||
JSDHashTable *mTable;
|
||||
};
|
||||
/***************************************************************************/
|
||||
|
||||
class JSObject2JSObjectMap
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user