adding ns prefix to private classes namespace

git-svn-id: svn://10.0.0.236/trunk@19430 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
dp%netscape.com 1999-02-03 15:39:13 +00:00
parent 6c2994b241
commit d5470d4135
12 changed files with 138 additions and 132 deletions

View File

@ -31,9 +31,12 @@
#include "plstr.h"
#include "prlink.h"
#include "nsRepository.h"
#ifdef USE_NSREG
#if !defined(XP_BEGIN_PROTOS)
#define XP_BEGIN_PROTOS extern "C" {
#define XP_END_PROTOS };
#endif
#include "NSReg.h"
#endif
@ -51,7 +54,7 @@
nsHashtable *nsRepository::factories = NULL;
PRMonitor *nsRepository::monitor = NULL;
DllStore *nsRepository::dllStore = NULL;
nsDllStore *nsRepository::dllStore = NULL;
static PRLogModuleInfo *logmodule = NULL;
@ -65,13 +68,13 @@ public:
// DO NOT DELETE THIS. Many FactoryEntry(s) could be sharing the same Dll.
// This gets deleted from the dllStore going away.
Dll *dll;
nsDll *dll;
FactoryEntry(const nsCID &aClass, nsIFactory *aFactory,
const char *aLibrary)
: cid(aClass), factory(aFactory), library(NULL), dll(NULL)
{
DllStore *dllCollection = nsRepository::dllStore;
nsDllStore *dllCollection = nsRepository::dllStore;
if (aLibrary == NULL)
{
@ -86,14 +89,17 @@ public:
}
// If dll not already in dllCollection, add it.
// PR_EnterMonitor(nsRepository::monitor);
dll = dllCollection->Get(library);
// PR_ExitMonitor(nsRepository::monitor);
if (dll == NULL)
{
// Add a new Dll into the DllStore
dll = new Dll(library);
// Add a new Dll into the nsDllStore
dll = new nsDll(library);
if (dll->GetStatus() != DLL_OK)
{
// Cant create a DllInfo. Backoff.
// Cant create a nsDll. Backoff.
delete dll;
dll = NULL;
PL_strfree(library);
@ -101,7 +107,9 @@ public:
}
else
{
// PR_EnterMonitor(nsRepository::monitor);
dllCollection->Put(library, dll);
// PR_ExitMonitor(nsRepository::monitor);
}
}
}
@ -114,30 +122,25 @@ public:
if (factory != NULL) {
factory->Release();
}
// DO NOT DELETE Dll *dll;
// DO NOT DELETE nsDll *dll;
}
};
class IDKey: public nsHashKey {
private:
nsID id;
nsID id;
public:
IDKey(const nsID &aID) {
id = aID;
}
PRUint32 HashValue(void) const {
return id.m0;
}
PRBool Equals(const nsHashKey *aKey) const {
return (id.Equals(((const IDKey *) aKey)->id));
}
nsHashKey *Clone(void) const {
return new IDKey(id);
}
IDKey(const nsID &aID) { id = aID; }
PRUint32 HashValue(void) const { return id.m0; }
PRBool Equals(const nsHashKey *aKey) const
{
return (id.Equals(((const IDKey *) aKey)->id));
}
nsHashKey *Clone(void) const { return new IDKey(id); }
};
#ifdef USE_NSREG
@ -380,7 +383,7 @@ nsresult nsRepository::Initialize(void)
logmodule = PR_NewLogModule("nsRepository");
}
if (dllStore == NULL) {
dllStore = new DllStore();
dllStore = new nsDllStore();
}
PR_LOG(logmodule, PR_LOG_ALWAYS,
@ -663,4 +666,3 @@ nsresult nsRepository::FreeLibraries(void)
return NS_OK;
}

View File

@ -67,7 +67,7 @@ typedef nsresult (*nsUnregisterProc)(const char *path);
*/
class FactoryEntry;
class DllStore;
class nsDllStore;
/*
* nsRepository class
@ -80,9 +80,9 @@ private:
static nsresult checkInitialized(void);
static nsresult loadFactory(FactoryEntry *aEntry, nsIFactory **aFactory);
public:
static DllStore *dllStore;
static nsDllStore *dllStore;
static nsresult Initialize(void);
// Finds a factory for a specific class ID
@ -123,6 +123,7 @@ public:
// Unload dynamically loaded factories that are not in use
static nsresult FreeLibraries(void);
};
#endif

View File

@ -16,7 +16,7 @@
* Reserved.
*/
/* Dll
/* nsDll
*
* Abstraction of a Dll. Stores modifiedTime and size for easy detection of
* change in dll.
@ -27,7 +27,7 @@
#include "xcDll.h"
#include "plstr.h" // strdup and strfree
Dll::Dll(const char *libFullPath) : m_instance(NULL), m_status(DLL_OK),
nsDll::nsDll(const char *libFullPath) : m_instance(NULL), m_status(DLL_OK),
m_fullpath(NULL)
{
// XXX No initializer for PRTime's
@ -67,7 +67,7 @@ Dll::Dll(const char *libFullPath) : m_instance(NULL), m_status(DLL_OK),
m_status = DLL_OK;
}
Dll::~Dll(void)
nsDll::~nsDll(void)
{
if (m_instance != NULL)
Unload();
@ -75,7 +75,7 @@ Dll::~Dll(void)
m_fullpath = NULL;
}
PRBool Dll::Load(void)
PRBool nsDll::Load(void)
{
if (m_status != DLL_OK)
{
@ -91,7 +91,7 @@ PRBool Dll::Load(void)
}
PRBool Dll::Unload(void)
PRBool nsDll::Unload(void)
{
if (m_status != DLL_OK || m_instance == NULL)
return (PR_FALSE);
@ -105,7 +105,7 @@ PRBool Dll::Unload(void)
return (PR_FALSE);
}
void * Dll::FindSymbol(const char *symbol)
void * nsDll::FindSymbol(const char *symbol)
{
if (symbol == NULL)
return (NULL);

View File

@ -27,32 +27,31 @@
#include "prio.h"
#include "prlink.h"
typedef enum DllStatus
typedef enum nsDllStatus
{
DLL_OK = 0,
DLL_NO_MEM = 1,
DLL_STAT_ERROR = 2,
DLL_NOT_FILE = 3,
DLL_INVALID_PARAM = 4
} DllStatus;
} nsDllStatus;
class Dll
class nsDll
{
private:
char *m_fullpath; // system format full filename of dll
PRTime m_lastModTime; // last modified time
PRUint64 m_size; // size of the dynamic library
PRLibrary *m_instance; // Load instance
DllStatus m_status; // holds current status
nsDllStatus m_status; // holds current status
public:
Dll(const char *libFullPath);
//DllEntry(const char *library, PRTime modTime, PR_Uint32 size);
~Dll(void);
nsDll(const char *libFullPath);
~nsDll(void);
// Status checking on oprations
DllStatus GetStatus(void) { return (m_status); }
// Status checking on operations completed
nsDllStatus GetStatus(void) { return (m_status); }
// Dll Loading
PRBool Load(void);
@ -63,6 +62,7 @@ public:
}
void *FindSymbol(const char *symbol);
const char *GetFullPath(void) { return (m_fullpath); }
PRTime GetLastModifiedTime(void) { return(m_lastModTime); }
PRUint64 GetSize(void) { return(m_size); }
PRLibrary *GetInstance(void) { return (m_instance); }

View File

@ -17,7 +17,7 @@
*/
/* DllStore
/* nsDllStore
*
* Stores dll and their accociated info in a hash keyed on the system format
* full dll path name e.g C:\Program Files\Netscape\Program\raptor.dll
@ -29,11 +29,11 @@
static PR_CALLBACK PRIntn _deleteDllInfo(PLHashEntry *he, PRIntn i, void *arg)
{
delete (Dll *)he->value;
delete (nsDll *)he->value;
return (HT_ENUMERATE_NEXT);
}
DllStore::DllStore(void) : m_dllHashTable(NULL)
nsDllStore::nsDllStore(void) : m_dllHashTable(NULL)
{
PRUint32 initSize = 128;
@ -42,11 +42,11 @@ DllStore::DllStore(void) : m_dllHashTable(NULL)
}
DllStore::~DllStore(void)
nsDllStore::~nsDllStore(void)
{
if (m_dllHashTable)
{
// Delete each of the Dll stored before deleting the Hash Table
// Delete each of the nsDll stored before deleting the Hash Table
PL_HashTableEnumerateEntries(m_dllHashTable, _deleteDllInfo, NULL);
PL_HashTableDestroy(m_dllHashTable);
}
@ -54,29 +54,29 @@ DllStore::~DllStore(void)
}
Dll* DllStore::Get(const char *dll)
nsDll* nsDllStore::Get(const char *dll)
{
Dll *dllInfo = NULL;
nsDll *dllInfo = NULL;
if (m_dllHashTable)
{
dllInfo = (Dll *)PL_HashTableLookup(m_dllHashTable, dll);
dllInfo = (nsDll *)PL_HashTableLookup(m_dllHashTable, dll);
}
return (dllInfo);
}
Dll* DllStore::Remove(const char *dll)
nsDll* nsDllStore::Remove(const char *dll)
{
if (m_dllHashTable == NULL)
{
return (NULL);
}
Dll *dllInfo = Get(dll);
nsDll *dllInfo = Get(dll);
PL_HashTableRemove(m_dllHashTable, dll);
return (dllInfo);
}
PRBool DllStore::Put(const char *dll, Dll *dllInfo)
PRBool nsDllStore::Put(const char *dll, nsDll *dllInfo)
{
if (m_dllHashTable == NULL)
return(PR_FALSE);

View File

@ -17,7 +17,7 @@
*/
/* DllStore
/* nsDllStore
*
* Stores dll and their accociated info in a hash keyed on the system format
* full dll path name e.g C:\Program Files\Netscape\Program\raptor.dll
@ -28,22 +28,22 @@
#include "plhash.h"
#include "xcDll.h"
class DllStore
class nsDllStore
{
private:
PLHashTable *m_dllHashTable;
public:
// Constructor
DllStore(void);
~DllStore(void);
nsDllStore(void);
~nsDllStore(void);
// Caller is not expected to delete Dll returned
// The Dll returned in NOT removed from the hash
Dll* Get(const char *filename);
PRBool Put(const char *filename, Dll *dllInfo);
// Caller is not expected to delete nsDll returned
// The nsDll returned in NOT removed from the hash
nsDll* Get(const char *filename);
PRBool Put(const char *filename, nsDll *dllInfo);
// The Dll returned is removed from the hash
// Caller is expected to delete the returned Dll
Dll* Remove(const char *filename);
// The nsDll returned is removed from the hash
// Caller is expected to delete the returned nsDll
nsDll* Remove(const char *filename);
};

View File

@ -67,7 +67,7 @@ typedef nsresult (*nsUnregisterProc)(const char *path);
*/
class FactoryEntry;
class DllStore;
class nsDllStore;
/*
* nsRepository class
@ -80,9 +80,9 @@ private:
static nsresult checkInitialized(void);
static nsresult loadFactory(FactoryEntry *aEntry, nsIFactory **aFactory);
public:
static DllStore *dllStore;
static nsDllStore *dllStore;
static nsresult Initialize(void);
// Finds a factory for a specific class ID
@ -123,6 +123,7 @@ public:
// Unload dynamically loaded factories that are not in use
static nsresult FreeLibraries(void);
};
#endif

View File

@ -31,9 +31,12 @@
#include "plstr.h"
#include "prlink.h"
#include "nsRepository.h"
#ifdef USE_NSREG
#if !defined(XP_BEGIN_PROTOS)
#define XP_BEGIN_PROTOS extern "C" {
#define XP_END_PROTOS };
#endif
#include "NSReg.h"
#endif
@ -51,7 +54,7 @@
nsHashtable *nsRepository::factories = NULL;
PRMonitor *nsRepository::monitor = NULL;
DllStore *nsRepository::dllStore = NULL;
nsDllStore *nsRepository::dllStore = NULL;
static PRLogModuleInfo *logmodule = NULL;
@ -65,13 +68,13 @@ public:
// DO NOT DELETE THIS. Many FactoryEntry(s) could be sharing the same Dll.
// This gets deleted from the dllStore going away.
Dll *dll;
nsDll *dll;
FactoryEntry(const nsCID &aClass, nsIFactory *aFactory,
const char *aLibrary)
: cid(aClass), factory(aFactory), library(NULL), dll(NULL)
{
DllStore *dllCollection = nsRepository::dllStore;
nsDllStore *dllCollection = nsRepository::dllStore;
if (aLibrary == NULL)
{
@ -86,14 +89,17 @@ public:
}
// If dll not already in dllCollection, add it.
// PR_EnterMonitor(nsRepository::monitor);
dll = dllCollection->Get(library);
// PR_ExitMonitor(nsRepository::monitor);
if (dll == NULL)
{
// Add a new Dll into the DllStore
dll = new Dll(library);
// Add a new Dll into the nsDllStore
dll = new nsDll(library);
if (dll->GetStatus() != DLL_OK)
{
// Cant create a DllInfo. Backoff.
// Cant create a nsDll. Backoff.
delete dll;
dll = NULL;
PL_strfree(library);
@ -101,7 +107,9 @@ public:
}
else
{
// PR_EnterMonitor(nsRepository::monitor);
dllCollection->Put(library, dll);
// PR_ExitMonitor(nsRepository::monitor);
}
}
}
@ -114,30 +122,25 @@ public:
if (factory != NULL) {
factory->Release();
}
// DO NOT DELETE Dll *dll;
// DO NOT DELETE nsDll *dll;
}
};
class IDKey: public nsHashKey {
private:
nsID id;
nsID id;
public:
IDKey(const nsID &aID) {
id = aID;
}
PRUint32 HashValue(void) const {
return id.m0;
}
PRBool Equals(const nsHashKey *aKey) const {
return (id.Equals(((const IDKey *) aKey)->id));
}
nsHashKey *Clone(void) const {
return new IDKey(id);
}
IDKey(const nsID &aID) { id = aID; }
PRUint32 HashValue(void) const { return id.m0; }
PRBool Equals(const nsHashKey *aKey) const
{
return (id.Equals(((const IDKey *) aKey)->id));
}
nsHashKey *Clone(void) const { return new IDKey(id); }
};
#ifdef USE_NSREG
@ -380,7 +383,7 @@ nsresult nsRepository::Initialize(void)
logmodule = PR_NewLogModule("nsRepository");
}
if (dllStore == NULL) {
dllStore = new DllStore();
dllStore = new nsDllStore();
}
PR_LOG(logmodule, PR_LOG_ALWAYS,
@ -663,4 +666,3 @@ nsresult nsRepository::FreeLibraries(void)
return NS_OK;
}

View File

@ -16,7 +16,7 @@
* Reserved.
*/
/* Dll
/* nsDll
*
* Abstraction of a Dll. Stores modifiedTime and size for easy detection of
* change in dll.
@ -27,7 +27,7 @@
#include "xcDll.h"
#include "plstr.h" // strdup and strfree
Dll::Dll(const char *libFullPath) : m_instance(NULL), m_status(DLL_OK),
nsDll::nsDll(const char *libFullPath) : m_instance(NULL), m_status(DLL_OK),
m_fullpath(NULL)
{
// XXX No initializer for PRTime's
@ -67,7 +67,7 @@ Dll::Dll(const char *libFullPath) : m_instance(NULL), m_status(DLL_OK),
m_status = DLL_OK;
}
Dll::~Dll(void)
nsDll::~nsDll(void)
{
if (m_instance != NULL)
Unload();
@ -75,7 +75,7 @@ Dll::~Dll(void)
m_fullpath = NULL;
}
PRBool Dll::Load(void)
PRBool nsDll::Load(void)
{
if (m_status != DLL_OK)
{
@ -91,7 +91,7 @@ PRBool Dll::Load(void)
}
PRBool Dll::Unload(void)
PRBool nsDll::Unload(void)
{
if (m_status != DLL_OK || m_instance == NULL)
return (PR_FALSE);
@ -105,7 +105,7 @@ PRBool Dll::Unload(void)
return (PR_FALSE);
}
void * Dll::FindSymbol(const char *symbol)
void * nsDll::FindSymbol(const char *symbol)
{
if (symbol == NULL)
return (NULL);

View File

@ -27,32 +27,31 @@
#include "prio.h"
#include "prlink.h"
typedef enum DllStatus
typedef enum nsDllStatus
{
DLL_OK = 0,
DLL_NO_MEM = 1,
DLL_STAT_ERROR = 2,
DLL_NOT_FILE = 3,
DLL_INVALID_PARAM = 4
} DllStatus;
} nsDllStatus;
class Dll
class nsDll
{
private:
char *m_fullpath; // system format full filename of dll
PRTime m_lastModTime; // last modified time
PRUint64 m_size; // size of the dynamic library
PRLibrary *m_instance; // Load instance
DllStatus m_status; // holds current status
nsDllStatus m_status; // holds current status
public:
Dll(const char *libFullPath);
//DllEntry(const char *library, PRTime modTime, PR_Uint32 size);
~Dll(void);
nsDll(const char *libFullPath);
~nsDll(void);
// Status checking on oprations
DllStatus GetStatus(void) { return (m_status); }
// Status checking on operations completed
nsDllStatus GetStatus(void) { return (m_status); }
// Dll Loading
PRBool Load(void);
@ -63,6 +62,7 @@ public:
}
void *FindSymbol(const char *symbol);
const char *GetFullPath(void) { return (m_fullpath); }
PRTime GetLastModifiedTime(void) { return(m_lastModTime); }
PRUint64 GetSize(void) { return(m_size); }
PRLibrary *GetInstance(void) { return (m_instance); }

View File

@ -17,7 +17,7 @@
*/
/* DllStore
/* nsDllStore
*
* Stores dll and their accociated info in a hash keyed on the system format
* full dll path name e.g C:\Program Files\Netscape\Program\raptor.dll
@ -29,11 +29,11 @@
static PR_CALLBACK PRIntn _deleteDllInfo(PLHashEntry *he, PRIntn i, void *arg)
{
delete (Dll *)he->value;
delete (nsDll *)he->value;
return (HT_ENUMERATE_NEXT);
}
DllStore::DllStore(void) : m_dllHashTable(NULL)
nsDllStore::nsDllStore(void) : m_dllHashTable(NULL)
{
PRUint32 initSize = 128;
@ -42,11 +42,11 @@ DllStore::DllStore(void) : m_dllHashTable(NULL)
}
DllStore::~DllStore(void)
nsDllStore::~nsDllStore(void)
{
if (m_dllHashTable)
{
// Delete each of the Dll stored before deleting the Hash Table
// Delete each of the nsDll stored before deleting the Hash Table
PL_HashTableEnumerateEntries(m_dllHashTable, _deleteDllInfo, NULL);
PL_HashTableDestroy(m_dllHashTable);
}
@ -54,29 +54,29 @@ DllStore::~DllStore(void)
}
Dll* DllStore::Get(const char *dll)
nsDll* nsDllStore::Get(const char *dll)
{
Dll *dllInfo = NULL;
nsDll *dllInfo = NULL;
if (m_dllHashTable)
{
dllInfo = (Dll *)PL_HashTableLookup(m_dllHashTable, dll);
dllInfo = (nsDll *)PL_HashTableLookup(m_dllHashTable, dll);
}
return (dllInfo);
}
Dll* DllStore::Remove(const char *dll)
nsDll* nsDllStore::Remove(const char *dll)
{
if (m_dllHashTable == NULL)
{
return (NULL);
}
Dll *dllInfo = Get(dll);
nsDll *dllInfo = Get(dll);
PL_HashTableRemove(m_dllHashTable, dll);
return (dllInfo);
}
PRBool DllStore::Put(const char *dll, Dll *dllInfo)
PRBool nsDllStore::Put(const char *dll, nsDll *dllInfo)
{
if (m_dllHashTable == NULL)
return(PR_FALSE);

View File

@ -17,7 +17,7 @@
*/
/* DllStore
/* nsDllStore
*
* Stores dll and their accociated info in a hash keyed on the system format
* full dll path name e.g C:\Program Files\Netscape\Program\raptor.dll
@ -28,22 +28,22 @@
#include "plhash.h"
#include "xcDll.h"
class DllStore
class nsDllStore
{
private:
PLHashTable *m_dllHashTable;
public:
// Constructor
DllStore(void);
~DllStore(void);
nsDllStore(void);
~nsDllStore(void);
// Caller is not expected to delete Dll returned
// The Dll returned in NOT removed from the hash
Dll* Get(const char *filename);
PRBool Put(const char *filename, Dll *dllInfo);
// Caller is not expected to delete nsDll returned
// The nsDll returned in NOT removed from the hash
nsDll* Get(const char *filename);
PRBool Put(const char *filename, nsDll *dllInfo);
// The Dll returned is removed from the hash
// Caller is expected to delete the returned Dll
Dll* Remove(const char *filename);
// The nsDll returned is removed from the hash
// Caller is expected to delete the returned nsDll
nsDll* Remove(const char *filename);
};