Changes to make xpcom20 build. Missing timer stuff though.

git-svn-id: svn://10.0.0.236/branches/XPCOM20_BRANCH@32085 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
warren%netscape.com
1999-05-18 21:36:42 +00:00
parent 0976bdde57
commit 65db6ee0dd
65 changed files with 723 additions and 809 deletions

View File

@@ -829,8 +829,8 @@ nsString2& nsString2::Append(const char* aCString,PRInt32 aCount) {
nsStr temp;
Initialize(temp,eOneByte);
temp.mStr=(char*)aCString;
if(-1==aCount) aCount= nsCRT::strlen(aCString);
temp.mLength = aCount;
temp.mLength=nsCRT::strlen(aCString);
if(-1==aCount) aCount=temp.mLength;
nsStr::Append(*this,temp,0,aCount,mAgent);
}
return *this;
@@ -848,8 +848,8 @@ nsString2& nsString2::Append(const PRUnichar* aString,PRInt32 aCount) {
nsStr temp;
Initialize(temp,eTwoByte);
temp.mUStr=(PRUnichar*)aString;
if(-1==aCount) aCount= nsCRT::strlen(aString);
temp.mLength = aCount;
temp.mLength=nsCRT::strlen(aString);
if(-1==aCount) aCount=temp.mLength;
nsStr::Append(*this,temp,0,aCount,mAgent);
}
return *this;

View File

@@ -38,6 +38,8 @@ EXPORTS = \
nscore.h \
$(NULL)
XPILD_MODULE = xpcom_base
XPIDLSRCS = \
.\nsrootidl.idl \
.\nsISupports.idl \

View File

@@ -24,9 +24,6 @@
#include "nsIServiceManager.h"
#include <string.h> /* for memcpy */
static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
static NS_DEFINE_IID(kIAllocatorIID, NS_IALLOCATOR_IID);
nsAllocatorImpl::nsAllocatorImpl(nsISupports* outer)
{
NS_INIT_AGGREGATED(outer);
@@ -44,8 +41,8 @@ nsAllocatorImpl::AggregatedQueryInterface(const nsIID& aIID, void** aInstancePtr
if (NULL == aInstancePtr) {
return NS_ERROR_NULL_POINTER;
}
if (aIID.Equals(kIAllocatorIID) ||
aIID.Equals(kISupportsIID)) {
if (aIID.Equals(nsIAllocator::GetIID()) ||
aIID.Equals(nsISupports::GetIID())) {
*aInstancePtr = (void*) this;
AddRef();
return NS_OK;
@@ -56,13 +53,13 @@ nsAllocatorImpl::AggregatedQueryInterface(const nsIID& aIID, void** aInstancePtr
NS_METHOD
nsAllocatorImpl::Create(nsISupports* outer, const nsIID& aIID, void* *aInstancePtr)
{
if (outer && !aIID.Equals(kISupportsIID))
if (outer && !aIID.Equals(nsISupports::GetIID()))
return NS_NOINTERFACE; // XXX right error?
nsAllocatorImpl* mm = new nsAllocatorImpl(outer);
if (mm == NULL)
return NS_ERROR_OUT_OF_MEMORY;
mm->AddRef();
if (aIID.Equals(kISupportsIID))
if (aIID.Equals(nsISupports::GetIID()))
*aInstancePtr = mm->GetInner();
else
*aInstancePtr = mm;
@@ -102,7 +99,7 @@ nsAllocatorImpl::HeapMinimize(void)
}
////////////////////////////////////////////////////////////////////////////////
#if 0
nsAllocatorFactory::nsAllocatorFactory(void)
{
NS_INIT_REFCNT();
@@ -128,6 +125,7 @@ nsAllocatorFactory::LockFactory(PRBool aLock)
{
return NS_OK; // XXX what?
}
#endif
////////////////////////////////////////////////////////////////////////////////
@@ -175,10 +173,7 @@ nsIAllocator* nsAllocator::mAllocator = NULL;
PRBool nsAllocator::FetchAllocator()
{
NS_DEFINE_IID(kAllocatorCID, NS_ALLOCATOR_CID);
NS_DEFINE_IID(kIAllocatorIID, NS_IALLOCATOR_IID);
nsServiceManager::GetService(kAllocatorCID, kIAllocatorIID,
(nsISupports **)&mAllocator);
nsAllocatorImpl::Create(NULL, nsIAllocator::GetIID(), (void**)&mAllocator);
NS_ASSERTION(mAllocator, "failed to get Allocator!");
return (PRBool) mAllocator;
}

View File

@@ -73,7 +73,7 @@ public:
};
////////////////////////////////////////////////////////////////////////////////
#if 0
class nsAllocatorFactory : public nsIFactory {
public:
NS_IMETHOD CreateInstance(nsISupports *aOuter,
@@ -87,6 +87,6 @@ public:
NS_DECL_ISUPPORTS
};
#endif
////////////////////////////////////////////////////////////////////////////////
#endif // nsAllocator_h__

View File

@@ -19,15 +19,9 @@
#ifndef nsID_h__
#define nsID_h__
#include <string.h>
#ifndef prtypes_h___
#include "prtypes.h"
#endif
#ifndef nsCom_h__
#include "string.h"
#include "nsCom.h"
#endif
/**
* A "unique identifier". This is modeled after OSF DCE UUIDs.

View File

@@ -19,9 +19,7 @@
#ifndef __nsIID_h
#define __nsIID_h
#ifndef nsID_h__
#include "nsID.h"
#endif
/**
* An "interface id" which can be used to uniquely identify a given

View File

@@ -703,7 +703,7 @@ nsComponentManagerImpl::PlatformFind(const nsCID &aCID, nsFactoryEntry* *result)
//
// HashProgID
//
nsresult
nsresult
nsComponentManagerImpl::HashProgID(const char *aProgID, const nsCID &aClass)
{
if(!aProgID)
@@ -1817,21 +1817,22 @@ nsComponentManagerImpl::SelfRegisterDll(nsDll *dll)
if (dll->Load() == PR_FALSE)
{
#ifdef NS_DEBUG
// Cannot load. Probably not a dll.
char errorMsg[1024] = "Cannot get error from nspr. Not enough memory.";
if (PR_GetErrorTextLength() < (int) sizeof(errorMsg))
PR_GetErrorText(errorMsg);
#ifdef NS_DEBUG
PR_LOG(nsComponentManagerLog, PR_LOG_ALWAYS,
("nsComponentManager: SelfRegisterDll(%s) Load FAILED with error:%s", dll->GetFullPath(), errorMsg));
#endif /* NS_DEBUG */
// Put the error message on the screen.
// For now this message is also for optimized builds. Hence no ifdef DEBUG
printf("**************************************************\n"
"nsComponentManager: Load(%s) FAILED with error: %s\n"
"**************************************************\n",
dll->GetFullPath(), errorMsg);
#endif /* NS_DEBUG */
return(NS_ERROR_FAILURE);
}

View File

@@ -35,11 +35,11 @@ NS_METHOD nsGenericFactory::QueryInterface(const nsIID& aIID, void** aInstancePt
if (NULL == aInstancePtr) {
return NS_ERROR_NULL_POINTER;
}
if (aIID.Equals(nsIFactory::GetIID()) ||
aIID.Equals(nsIGenericFactory::GetIID()) ||
aIID.Equals(nsISupports::GetIID())) {
*aInstancePtr = (void*) this;
AddRef();
if (aIID.Equals(nsIGenericFactory::GetIID()) ||
aIID.Equals(nsIFactory::GetIID()) ||
aIID.Equals(nsISupports::GetIID())) {
*aInstancePtr = (nsIGenericFactory*) this;
NS_ADDREF_THIS();
return NS_OK;
}
return NS_NOINTERFACE;
@@ -86,3 +86,25 @@ NS_METHOD nsGenericFactory::Create(nsISupports* outer, const nsIID& aIID, void*
}
return res;
}
extern nsresult
NS_NewGenericFactory(nsIGenericFactory* *result,
nsIGenericFactory::ConstructorProcPtr constructor,
nsIGenericFactory::DestructorProcPtr destructor)
{
nsresult rv;
nsIGenericFactory* fact;
rv = nsGenericFactory::Create(NULL, nsIGenericFactory::GetIID(), (void**)&fact);
if (NS_FAILED(rv)) return rv;
rv = fact->SetConstructor(constructor);
if (NS_FAILED(rv)) goto error;
rv = fact->SetDestructor(destructor);
if (NS_FAILED(rv)) goto error;
*result = fact;
return rv;
error:
NS_RELEASE(fact);
return rv;
}

View File

@@ -54,4 +54,40 @@ public:
NS_IMETHOD SetDestructor(DestructorProcPtr destructor) = 0;
};
extern nsresult
NS_NewGenericFactory(nsIGenericFactory* *result,
nsIGenericFactory::ConstructorProcPtr constructor,
nsIGenericFactory::DestructorProcPtr destructor = NULL);
#define NS_GENERIC_FACTORY_CONSTRUCTOR(_InstanceClass) \
static nsresult \
_InstanceClass##Constructor(nsISupports *aOuter, REFNSIID aIID, void **aResult) \
{ \
nsresult rv; \
\
_InstanceClass * inst; \
\
if (NULL == aResult) { \
rv = NS_ERROR_NULL_POINTER; \
goto done; \
} \
*aResult = NULL; \
if (NULL != aOuter) { \
rv = NS_ERROR_NO_AGGREGATION; \
goto done; \
} \
\
NS_NEWXPCOM(inst, _InstanceClass); \
if (NULL == inst) { \
rv = NS_ERROR_OUT_OF_MEMORY; \
goto done; \
} \
NS_ADDREF(inst); \
rv = inst->QueryInterface(aIID, aResult); \
NS_RELEASE(inst); \
\
done: \
return rv; \
}
#endif /* nsIGenericFactory_h___ */

View File

@@ -30,6 +30,11 @@
// {5316C380-B2F8-11d2-A374-0080C6F80E4B}
#define NS_IREGISTRYVALUE_IID { 0x5316c380, 0xb2f8, 0x11d2, { 0xa3, 0x74, 0x0, 0x80, 0xc6, 0xf8, 0xe, 0x4b } }
/* be761f00-a3b0-11d2-996c-0080c7cb1081 */
#define NS_REGISTRY_CID \
{ 0xbe761f00, 0xa3b0, 0x11d2, \
{0x99, 0x6c, 0x00, 0x80, 0xc7, 0xcb, 0x10, 0x81} }
class nsIEnumerator;

View File

@@ -516,98 +516,3 @@ nsServiceManager::UnregisterService(const char* aProgID)
}
////////////////////////////////////////////////////////////////////////////////
// XPCOM initialization
//
// To Control the order of initialization of these key components I am putting
// this function.
//
// - nsServiceManager
// - nsComponentManager
// - nsRegistry
//
// Here are key points to remember:
// - A global of all these need to exist. nsServiceManager is an independent object.
// nsComponentManager uses both the globalServiceManager and its own registry.
//
// - A static object of both the nsComponentManager and nsServiceManager
// are in use. Hence InitXPCOM() gets triggered from both
// NS_GetGlobale{Service/Component}Manager() calls.
//
// - There exists no global Registry. Registry can be created from the component manager.
//
#include "nsComponentManager.h"
#include "nsIRegistry.h"
#include "nsXPComCIID.h"
#include "nsAllocator.h"
extern "C" NS_EXPORT nsresult
NS_RegistryGetFactory(nsISupports* servMgr, nsIFactory** aFactory);
nsIServiceManager* nsServiceManager::mGlobalServiceManager = NULL;
nsComponentManagerImpl* nsComponentManagerImpl::gComponentManager = NULL;
nsresult NS_InitXPCOM(nsIServiceManager* *result)
{
nsresult rv = NS_OK;
// 1. Create the Global Service Manager
nsIServiceManager* servMgr = NULL;
if (nsServiceManager::mGlobalServiceManager == NULL)
{
rv = NS_NewServiceManager(&servMgr);
if (NS_FAILED(rv)) return rv;
nsServiceManager::mGlobalServiceManager = servMgr;
NS_ADDREF(servMgr);
if (result) *result = servMgr;
}
// 2. Create the Component Manager and register with global service manager
// It is understood that the component manager can use the global service manager.
nsComponentManagerImpl *compMgr = NULL;
if (nsComponentManagerImpl::gComponentManager == NULL)
{
compMgr = new nsComponentManagerImpl();
if (compMgr == NULL)
return NS_ERROR_OUT_OF_MEMORY;
NS_ADDREF(compMgr);
nsresult rv = compMgr->Init();
if (NS_FAILED(rv))
{
NS_RELEASE(compMgr);
return rv;
}
nsComponentManagerImpl::gComponentManager = compMgr;
}
rv = servMgr->RegisterService(kComponentManagerCID, compMgr);
if (NS_FAILED(rv)) return rv;
// 3. Register the RegistryFactory with the component manager so that
// clients can create new registry objects.
nsIFactory *registryFactory = NULL;
rv = NS_RegistryGetFactory(servMgr, &registryFactory);
if (NS_FAILED(rv)) return rv;
NS_DEFINE_CID(kRegistryCID, NS_REGISTRY_CID);
rv = compMgr->RegisterFactory(kRegistryCID, NS_REGISTRY_CLASSNAME,
NS_REGISTRY_PROGID, registryFactory,
PR_TRUE);
NS_RELEASE(registryFactory);
if (NS_FAILED(rv)) return rv;
// Register nsAllocator
nsAllocatorFactory* alloc = new nsAllocatorFactory();
if (alloc == NULL)
return NS_ERROR_OUT_OF_MEMORY;
NS_ADDREF(alloc);
static NS_DEFINE_CID(kAllocatorCID, NS_ALLOCATOR_CID);
rv = compMgr->RegisterFactory(kAllocatorCID, "Malloc/Free Allocator",
NULL, alloc, PR_TRUE);
NS_RELEASE(alloc);
if (NS_FAILED(rv)) return rv;
return rv;
}

View File

@@ -58,6 +58,8 @@ EXPORTS = \
plvector.h \
$(NULL)
XPILD_MODULE = xpcom_ds
XPIDLSRCS = \
.\nsICollection.idl \
.\nsIEnumerator.idl \
@@ -92,7 +94,6 @@ CPP_OBJS = \
.\$(OBJDIR)\nsObserverList.obj \
.\$(OBJDIR)\nsObserverService.obj \
.\$(OBJDIR)\nsPageMgr.obj \
.\$(OBJDIR)\nsPipe.obj \
.\$(OBJDIR)\nsProperties.obj \
.\$(OBJDIR)\nsQuickSort.obj \
.\$(OBJDIR)\nsRBTree.obj \

View File

@@ -15,51 +15,33 @@
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
#include "nsIArena.h"
#include "nsArena.h"
#include "nsCRT.h"
#define PL_ARENA_CONST_ALIGN_MASK 7
#include "plarena.h"
static NS_DEFINE_IID(kArenaIID, NS_IARENA_IID);
// Simple arena implementation layered on plarena
class ArenaImpl : public nsIArena {
public:
ArenaImpl(PRInt32 aBlockSize);
NS_DECL_ISUPPORTS
virtual void* Alloc(PRInt32 aSize);
protected:
virtual ~ArenaImpl();
PLArenaPool mPool;
PRInt32 mBlockSize;
};
ArenaImpl::ArenaImpl(PRInt32 aBlockSize)
NS_IMETHODIMP
ArenaImpl::Init(PRUint32 aBlockSize)
{
NS_INIT_REFCNT();
if (aBlockSize < NS_MIN_ARENA_BLOCK_SIZE) {
aBlockSize = NS_DEFAULT_ARENA_BLOCK_SIZE;
}
PL_INIT_ARENA_POOL(&mPool, "nsIArena", aBlockSize);
mBlockSize = aBlockSize;
return NS_OK;
}
NS_IMPL_ISUPPORTS(ArenaImpl,kArenaIID)
NS_IMPL_ISUPPORTS(ArenaImpl, nsIArena::GetIID())
ArenaImpl::~ArenaImpl()
{
PL_FinishArenaPool(&mPool);
}
void* ArenaImpl::Alloc(PRInt32 size)
NS_IMETHODIMP_(void*)
ArenaImpl::Alloc(PRUint32 size)
{
// Adjust size so that it's a multiple of sizeof(double)
PRInt32 align = size & (sizeof(double) - 1);
PRUint32 align = size & (sizeof(double) - 1);
if (0 != align) {
size += sizeof(double) - align;
}
@@ -69,12 +51,36 @@ void* ArenaImpl::Alloc(PRInt32 size)
return p;
}
NS_BASE nsresult NS_NewHeapArena(nsIArena** aInstancePtrResult,
PRInt32 aArenaBlockSize)
NS_METHOD
ArenaImpl::Create(nsISupports *aOuter, REFNSIID aIID, void **aResult)
{
ArenaImpl* it = new ArenaImpl(aArenaBlockSize);
if (nsnull == it) {
if (aOuter)
return NS_ERROR_NO_AGGREGATION;
ArenaImpl* it = new ArenaImpl();
if (nsnull == it)
return NS_ERROR_OUT_OF_MEMORY;
}
return it->QueryInterface(kArenaIID, (void **) aInstancePtrResult);
NS_ADDREF(it);
nsresult rv = it->QueryInterface(aIID, aResult);
NS_RELEASE(it);
return rv;
}
NS_BASE nsresult NS_NewHeapArena(nsIArena** aInstancePtrResult,
PRUint32 aArenaBlockSize)
{
nsresult rv;
nsIArena* arena;
rv = ArenaImpl::Create(NULL, nsIArena::GetIID(), (void**)&arena);
if (NS_FAILED(rv)) return rv;
rv = arena->Init(aArenaBlockSize);
if (NS_FAILED(rv)) {
NS_RELEASE(arena);
return rv;
}
*aInstancePtrResult = arena;
return rv;
}

View File

@@ -15,7 +15,8 @@
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
#include "nsIAtom.h"
#include "nsAtomTable.h"
#include "nsString.h"
#include "nsCRT.h"
#include "plhash.h"
@@ -27,30 +28,6 @@
static nsrefcnt gAtoms;
static struct PLHashTable* gAtomHashTable;
class AtomImpl : public nsIAtom {
public:
AtomImpl();
virtual ~AtomImpl();
NS_DECL_ISUPPORTS
void* operator new(size_t size, const PRUnichar* us, PRInt32 uslen);
void operator delete(void* ptr) {
::operator delete(ptr);
}
virtual void ToString(nsString& aBuf) const;
virtual const PRUnichar* GetUnicode() const;
NS_IMETHOD SizeOf(nsISizeOfHandler* aHandler) const;
// Actually more; 0 terminated. This slot is reserved for the
// terminating zero.
PRUnichar mString[1];
};
AtomImpl::AtomImpl()
{
NS_INIT_REFCNT();

View File

@@ -58,6 +58,22 @@ nsBuffer::~nsBuffer()
NS_IMPL_ISUPPORTS(nsBuffer, nsIBuffer::GetIID());
NS_METHOD
nsBuffer::Create(nsISupports *aOuter, REFNSIID aIID, void **aResult)
{
if (aOuter)
return NS_ERROR_NO_AGGREGATION;
nsBuffer* buf = new nsBuffer();
if (buf == nsnull)
return NS_ERROR_OUT_OF_MEMORY;
NS_ADDREF(buf);
nsresult rv = buf->QueryInterface(aIID, aResult);
NS_RELEASE(buf);
return rv;
}
////////////////////////////////////////////////////////////////////////////////
nsresult
@@ -324,17 +340,16 @@ NS_NewBuffer(nsIBuffer* *result,
NS_WITH_SERVICE(nsIAllocator, alloc, kAllocatorCID, &rv);
if (NS_FAILED(rv)) return rv;
nsBuffer* buf = new nsBuffer();
if (buf == nsnull)
return NS_ERROR_OUT_OF_MEMORY;
nsBuffer* buf;
rv = nsBuffer::Create(NULL, nsIBuffer::GetIID(), (void**)&buf);
if (NS_FAILED(rv)) return rv;
rv = buf->Init(growBySize, maxSize, alloc);
if (NS_FAILED(rv)) {
delete buf;
NS_RELEASE(buf);
return rv;
}
NS_ADDREF(buf);
*result = buf;
return NS_OK;
}
@@ -349,17 +364,16 @@ NS_NewPageBuffer(nsIBuffer* *result,
NS_WITH_SERVICE(nsIAllocator, alloc, kPageManagerCID, &rv);
if (NS_FAILED(rv)) return rv;
nsBuffer* buf = new nsBuffer();
if (buf == nsnull)
return NS_ERROR_OUT_OF_MEMORY;
nsBuffer* buf;
rv = nsBuffer::Create(NULL, nsIBuffer::GetIID(), (void**)&buf);
if (NS_FAILED(rv)) return rv;
rv = buf->Init(growBySize, maxSize, alloc);
if (NS_FAILED(rv)) {
delete buf;
NS_RELEASE(buf);
return rv;
}
NS_ADDREF(buf);
*result = buf;
return NS_OK;
}

View File

@@ -28,6 +28,9 @@ class nsBuffer : public nsIBuffer {
public:
NS_DECL_ISUPPORTS
static NS_METHOD
Create(nsISupports *aOuter, REFNSIID aIID, void **aResult);
// nsIBuffer methods:
NS_IMETHOD Init(PRUint32 growBySize, PRUint32 maxSize,
nsIAllocator* allocator);

View File

@@ -15,39 +15,29 @@
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
#include "nsIByteBuffer.h"
#include "nsByteBuffer.h"
#include "nsIInputStream.h"
#include "nsCRT.h"
#define MIN_BUFFER_SIZE 32
class ByteBufferImpl : public nsIByteBuffer {
public:
ByteBufferImpl(PRUint32 aBufferSize);
virtual ~ByteBufferImpl();
ByteBufferImpl::ByteBufferImpl(void)
: mBuffer(NULL), mSpace(0), mLength(0)
{
NS_INIT_REFCNT();
}
NS_DECL_ISUPPORTS
NS_IMETHOD_(PRUint32) GetLength(void) const;
NS_IMETHOD_(PRUint32) GetBufferSize(void) const;
NS_IMETHOD_(char*) GetBuffer() const;
NS_IMETHOD_(PRBool) Grow(PRUint32 aNewSize);
NS_IMETHOD_(PRInt32) Fill(nsresult* aErrorCode, nsIInputStream* aStream,
PRUint32 aKeep);
char* mBuffer;
PRUint32 mSpace;
PRUint32 mLength;
};
ByteBufferImpl::ByteBufferImpl(PRUint32 aBufferSize)
NS_IMETHODIMP
ByteBufferImpl::Init(PRUint32 aBufferSize)
{
if (aBufferSize < MIN_BUFFER_SIZE) {
aBufferSize = MIN_BUFFER_SIZE;
}
mSpace = aBufferSize;
mBuffer = new char[aBufferSize];
mLength = 0;
NS_INIT_REFCNT();
mBuffer = new char[aBufferSize];
return mBuffer ? NS_OK : NS_ERROR_OUT_OF_MEMORY;
}
NS_DEFINE_IID(kByteBufferIID,NS_IBYTE_BUFFER_IID);
@@ -62,6 +52,22 @@ ByteBufferImpl::~ByteBufferImpl()
mLength = 0;
}
NS_METHOD
ByteBufferImpl::Create(nsISupports *aOuter, REFNSIID aIID, void **aResult)
{
if (aOuter)
return NS_ERROR_NO_AGGREGATION;
ByteBufferImpl* it = new ByteBufferImpl();
if (nsnull == it)
return NS_ERROR_OUT_OF_MEMORY;
NS_ADDREF(it);
nsresult rv = it->QueryInterface(aIID, (void**)aResult);
NS_RELEASE(it);
return rv;
}
NS_IMETHODIMP_(PRUint32)
ByteBufferImpl::GetLength(void) const
{
@@ -131,12 +137,16 @@ NS_BASE nsresult NS_NewByteBuffer(nsIByteBuffer** aInstancePtrResult,
nsISupports* aOuter,
PRUint32 aBufferSize)
{
if (nsnull != aOuter) {
return NS_ERROR_NO_AGGREGATION;
nsresult rv;
nsIByteBuffer* buf;
rv = ByteBufferImpl::Create(aOuter, nsIByteBuffer::GetIID(), (void**)&buf);
if (NS_FAILED(rv)) return rv;
rv = buf->Init(aBufferSize);
if (NS_FAILED(rv)) {
NS_RELEASE(buf);
return rv;
}
ByteBufferImpl* it = new ByteBufferImpl(aBufferSize);
if (nsnull == it) {
return NS_ERROR_OUT_OF_MEMORY;
}
return it->QueryInterface(kByteBufferIID, (void **) aInstancePtrResult);
*aInstancePtrResult = buf;
return rv;
}

View File

@@ -39,7 +39,9 @@ class nsIArena : public nsISupports {
public:
static const nsIID& GetIID() { static nsIID iid = NS_IARENA_IID; return iid; }
virtual void* Alloc(PRInt32 size) = 0;
NS_IMETHOD Init(PRUint32 arenaBlockSize) = 0;
NS_IMETHOD_(void*) Alloc(PRUint32 size) = 0;
};
/**
@@ -48,6 +50,17 @@ public:
* using the PR heap.
*/
extern NS_BASE nsresult NS_NewHeapArena(nsIArena** aInstancePtrResult,
PRInt32 aArenaBlockSize = 0);
PRUint32 aArenaBlockSize = 0);
// XXX regenerate:
#define NS_ARENA_CID \
{ /* e139e1d0-0a89-11d3-9331-000000000000 */ \
0xe139e1d0, \
0x0a89, \
0x11d3, \
{0x93, 0x31, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00} \
}
#endif /* nsIArena_h___ */

View File

@@ -31,6 +31,8 @@ class nsIInputStream;
/** Interface to a buffer that holds bytes */
class nsIByteBuffer : public nsISupports {
public:
NS_IMETHOD Init(PRUint32 aBufferSize) = 0;
/** @return length of buffer, i.e. how many bytes are currently in it. */
NS_IMETHOD_(PRUint32) GetLength(void) const = 0;
@@ -49,6 +51,15 @@ public:
PRUint32 aKeep) = 0;
};
// XXX regenerate:
#define NS_BYTEBUFFER_CID \
{ /* 78323f10-0a8c-11d3-9331-000000000000 */ \
0x78323f10, \
0x0a8c, \
0x11d3, \
{0x93, 0x31, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00} \
}
/** Create a new byte buffer using the given buffer size. */
extern NS_BASE nsresult
NS_NewByteBuffer(nsIByteBuffer** aInstancePtrResult,

View File

@@ -1,55 +1,90 @@
/*
* DO NOT EDIT. THIS FILE IS GENERATED FROM nsICollection.idl
/* -*- Mode: C++; tab-width: 2; 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 specifzic 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 nsICollection_h___
#define nsICollection_h___
#ifndef __gen_nsICollection_h__
#define __gen_nsICollection_h__
#include "nsISupports.h"
#include "nsISupports.h" /* interface nsISupports */
#include "nsrootidl.h" /* interface nsrootidl */
#include "nsIEnumerator.h" /* interface nsIEnumerator */
class nsIEnumerator;
#ifdef XPIDL_JS_STUBS
#include "jsapi.h"
#endif
// IID for the nsICollection interface
#define NS_ICOLLECTION_IID \
{ /* 83b6019c-cbc4-11d2-8cca-0060b0fc14a3 */ \
0x83b6019c, \
0xcbc4, \
0x11d2, \
{0x8c, 0xca, 0x00, 0x60, 0xb0, 0xfc, 0x14, 0xa3} \
}
/* starting interface: nsICollection */
// IID for the nsICollection Factory interface
#define NS_ICOLLECTIONFACTORY_IID \
{ 0xf8052641, 0x8768, 0x11d2, \
{ 0x8f, 0x39, 0x0, 0x60, 0x8, 0x31, 0x1, 0x94 } }
/* {83b6019c-cbc4-11d2-8cca-0060b0fc14a3} */
#define NS_ICOLLECTION_IID_STR "83b6019c-cbc4-11d2-8cca-0060b0fc14a3"
#define NS_ICOLLECTION_IID \
{0x83b6019c, 0xcbc4, 0x11d2, \
{ 0x8c, 0xca, 0x00, 0x60, 0xb0, 0xfc, 0x14, 0xa3 }}
//----------------------------------------------------------------------
/** nsICollection Interface
* this may be ordered or not. a list or array, the implementation is opaque
*/
class nsICollection : public nsISupports {
public:
NS_DEFINE_STATIC_IID_ACCESSOR(NS_ICOLLECTION_IID)
public:
/* unsigned long Count (); */
NS_IMETHOD Count(PRUint32 *_retval) = 0;
static const nsIID& GetIID(void) { static nsIID iid = NS_ICOLLECTION_IID; return iid; }
/* nsISupports GetElementAt (in unsigned long index); */
NS_IMETHOD GetElementAt(PRUint32 index, nsISupports **_retval) = 0;
/** Return the count of elements in the collection.
*/
NS_IMETHOD Count(PRUint32 *result) = 0;
/* void SetElementAt (in unsigned long index, in nsISupports item); */
NS_IMETHOD SetElementAt(PRUint32 index, nsISupports *item) = 0;
/**
* Gets an element by index.
*/
NS_IMETHOD GetElementAt(PRUint32 index, nsISupports* *result) = 0;
/* void AppendElement (in nsISupports item); */
NS_IMETHOD AppendElement(nsISupports *item) = 0;
/**
* Sets an element by index. Any existing element will be released.
*/
NS_IMETHOD SetElementAt(PRUint32 index, nsISupports* value) = 0;
/* void RemoveElement (in nsISupports item); */
NS_IMETHOD RemoveElement(nsISupports *item) = 0;
/**
* AppendElement will take an ISupports and keep track of it
* @param aItem is the Item to be added WILL BE ADDREFFED
* @return NS_OK if successfully added
* @return NS_ERROR_FAILURE otherwise
*/
NS_IMETHOD AppendElement(nsISupports *aItem) = 0;
/* nsIEnumerator Enumerate (); */
NS_IMETHOD Enumerate(nsIEnumerator **_retval) = 0;
/** RemoveElement will take an nsISupports and remove it from the collection
* @param aItem is the item to be removed WILL BE RELEASED
* @return NS_OK if successfully added
* @return NS_ERROR_FAILURE otherwise
*/
NS_IMETHOD RemoveElement(nsISupports *aItem) = 0;
/* void Clear (); */
NS_IMETHOD Clear() = 0;
/** Return an enumeration for the collection.
*/
NS_IMETHOD Enumerate(nsIEnumerator* *result) = 0;
/** Clear will clear all items from list
*/
NS_IMETHOD Clear(void) = 0;
#ifdef XPIDL_JS_STUBS
static NS_EXPORT_(JSObject *) InitJSClass(JSContext *cx);
static NS_EXPORT_(JSObject *) GetJSObject(JSContext *cx, nsICollection *priv);
#endif
};
#endif /* __gen_nsICollection_h__ */
#endif /* nsICollection_h___ */

View File

@@ -89,6 +89,7 @@ class nsIBidirectionalEnumerator : public nsIEnumerator {
static NS_EXPORT_(JSObject *) GetJSObject(JSContext *cx, nsIBidirectionalEnumerator *priv);
#endif
};
extern "C" NS_COM nsresult
NS_NewEmptyEnumerator(nsISimpleEnumerator** aResult);
// Construct and return an implementation of a "conjoining enumerator." This

View File

@@ -38,8 +38,8 @@ public:
NS_IMETHOD Notify(nsISupports** result) = 0;
};
extern NS_BASE nsresult NS_NewObserver(nsIObserver** anObserver);
extern NS_BASE nsresult NS_NewObserver(nsIObserver** anObserver, nsISupports* outer = NULL);
#define NS_OBSERVER_PROGID "component:||netscape|Observer"
#define NS_OBSERVER_PROGID "component://netscape/xpcom/observer"
#endif /* nsIObserver_h__ */

View File

@@ -29,6 +29,15 @@
{0x93, 0x11, 0x00, 0xe0, 0x98, 0x05, 0x57, 0x0f} \
}
// XXX regenerate:
#define NS_PROPERTIES_CID \
{ /* 9017a8a0-0a90-11d3-9331-000000000000 */ \
0x9017a8a0, \
0x0a90, \
0x11d3, \
{0x93, 0x31, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00} \
}
class nsIProperties : public nsISupports {
public:
static const nsIID& GetIID() { static nsIID iid = NS_IPROPERTIES_IID; return iid; }

View File

@@ -29,6 +29,15 @@ class nsIBidirectionalEnumerator;
{0x791eafa0, 0xb9e6, 0x11d1, \
{0x80, 0x31, 0x00, 0x60, 0x08, 0x15, 0x9b, 0x5a}}
// XXX regenerate:
#define NS_SUPPORTSARRAY_CID \
{ /* 5fe6e340-0a97-11d3-9331-000000000000 */ \
0x5fe6e340, \
0x0a97, \
0x11d3, \
{0x93, 0x31, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00} \
}
// Enumerator callback function. Return PR_FALSE to stop
typedef PRBool (*nsISupportsArrayEnumFunc)(nsISupports* aElement, void *aData);

View File

@@ -22,25 +22,37 @@
#include "nsISupports.h"
class nsIUnicharInputStream;
#define NS_IUNICHAR_BUFFER_IID \
#define NS_IUNICHARBUFFER_IID \
{ 0x14cf6970, 0x93b5, 0x11d1, \
{0x89, 0x5b, 0x00, 0x60, 0x08, 0x91, 0x1b, 0x81} }
/// Interface to a buffer that holds unicode characters
class nsIUnicharBuffer : public nsISupports {
public:
virtual PRInt32 GetLength() const = 0;
virtual PRInt32 GetBufferSize() const = 0;
virtual PRUnichar* GetBuffer() const = 0;
virtual PRBool Grow(PRInt32 aNewSize) = 0;
virtual PRInt32 Fill(nsresult* aErrorCode, nsIUnicharInputStream* aStream,
PRInt32 aKeep) = 0;
NS_DEFINE_STATIC_IID_ACCESSOR(NS_IUNICHARBUFFER_IID);
NS_IMETHOD Init(PRUint32 aBufferSize) = 0;
NS_IMETHOD_(PRInt32) GetLength() const = 0;
NS_IMETHOD_(PRInt32) GetBufferSize() const = 0;
NS_IMETHOD_(PRUnichar*) GetBuffer() const = 0;
NS_IMETHOD_(PRBool) Grow(PRInt32 aNewSize) = 0;
NS_IMETHOD_(PRInt32) Fill(nsresult* aErrorCode, nsIUnicharInputStream* aStream,
PRInt32 aKeep) = 0;
};
/// Factory method for nsIUnicharBuffer.
extern NS_BASE nsresult
NS_NewUnicharBuffer(nsIUnicharBuffer** aInstancePtrResult,
nsISupports* aOuter,
PRUint32 aBufferSize = 0);
NS_NewUnicharBuffer(nsIUnicharBuffer** aInstancePtrResult,
nsISupports* aOuter,
PRUint32 aBufferSize = 0);
// XXX regenerate:
#define NS_UNICHARBUFFER_CID \
{ /* c86b1be0-0a94-11d3-9331-000000000000 */ \
0xc86b1be0, \
0x0a94, \
0x11d3, \
{0x93, 0x31, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00} \
}
#endif /* nsIUnicharBuffer_h___ */

View File

@@ -35,25 +35,34 @@ static NS_DEFINE_IID(kObserverCID, NS_OBSERVER_CID);
NS_IMPL_AGGREGATED(nsObserver);
NS_BASE nsresult NS_NewObserver(nsIObserver** anObserver)
NS_BASE nsresult NS_NewObserver(nsIObserver** anObserver, nsISupports* outer)
{
if (anObserver == NULL)
{
return NS_ERROR_NULL_POINTER;
}
nsObserver* it = new nsObserver();
if (it == 0) {
return NS_ERROR_OUT_OF_MEMORY;
}
return it->QueryInterface(kIObserverIID, (void **) anObserver);
return nsObserver::Create(outer, kIObserverIID, (void**)anObserver);
}
nsObserver::nsObserver()
NS_METHOD
nsObserver::Create(nsISupports* outer, const nsIID& aIID, void* *anObserver)
{
NS_INIT_REFCNT();
if (anObserver == NULL)
return NS_ERROR_NULL_POINTER;
nsObserver* it = new nsObserver(outer);
if (it == NULL)
return NS_ERROR_OUT_OF_MEMORY;
nsISupports* inner = outer ? it->GetInner() : it;
nsresult rv = inner->QueryInterface(aIID, anObserver);
if (NS_FAILED(rv)) {
delete it;
return rv;
}
return rv;
}
nsObserver::nsObserver(nsISupports* outer)
{
NS_INIT_AGGREGATED(outer);
}
nsObserver::~nsObserver(void)
@@ -67,7 +76,7 @@ nsObserver::AggregatedQueryInterface(const nsIID& aIID, void** aInstancePtr)
return NS_ERROR_NULL_POINTER;
if (aIID.Equals(nsIObserver::GetIID()) ||
aIID.Equals(nsISupports::GetIID())) {
*aInstancePtr = this;
*aInstancePtr = (nsIObserver*)this;
NS_ADDREF_THIS();
return NS_OK;
}

View File

@@ -1,4 +1,4 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* 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
@@ -27,12 +27,14 @@ public:
NS_IMETHOD Notify(nsISupports** result);
nsObserver();
nsObserver(nsISupports* outer);
virtual ~nsObserver(void);
static NS_METHOD
Create(nsISupports* outer, const nsIID& aIID, void* *aInstancePtr);
NS_DECL_AGGREGATED
private:
};

View File

@@ -34,30 +34,6 @@ static NS_DEFINE_IID(kObserverServiceCID, NS_OBSERVERSERVICE_CID);
////////////////////////////////////////////////////////////////////////////////
class nsObserverService : public nsIObserverService {
public:
static nsresult GetObserverService(nsIObserverService** anObserverService);
NS_IMETHOD AddObserver(nsIObserver** anObserver, nsString* aTopic);
NS_IMETHOD RemoveObserver(nsIObserver** anObserver, nsString* aTopic);
NS_IMETHOD EnumerateObserverList(nsIEnumerator** anEnumerator, nsString* aTopic);
nsObserverService();
virtual ~nsObserverService(void);
NS_DECL_ISUPPORTS
private:
NS_IMETHOD GetObserverList(nsIObserverList** anObserverList, nsString* aTopic);
nsHashtable *mObserverTopicTable;
};
static nsObserverService* gObserverService = nsnull; // The one-and-only ObserverService
////////////////////////////////////////////////////////////////////////////////
@@ -85,6 +61,18 @@ nsObserverService::~nsObserverService(void)
gObserverService = nsnull;
}
NS_METHOD
nsObserverService::Create(nsISupports* outer, const nsIID& aIID, void* *aInstancePtr)
{
nsresult rv;
nsObserverService* os = new nsObserverService();
if (os == NULL)
return NS_ERROR_OUT_OF_MEMORY;
NS_ADDREF(os);
rv = os->QueryInterface(aIID, aInstancePtr);
NS_RELEASE(os);
return rv;
}
nsresult nsObserverService::GetObserverService(nsIObserverService** anObserverService)
{

View File

@@ -19,4 +19,34 @@
#ifndef nsObserverService_h___
#define nsObserverService_h___
#include "nsIObserverService.h"
class nsHashtable;
class nsObserverService : public nsIObserverService {
public:
static nsresult GetObserverService(nsIObserverService** anObserverService);
NS_IMETHOD AddObserver(nsIObserver** anObserver, nsString* aTopic);
NS_IMETHOD RemoveObserver(nsIObserver** anObserver, nsString* aTopic);
NS_IMETHOD EnumerateObserverList(nsIEnumerator** anEnumerator, nsString* aTopic);
nsObserverService();
virtual ~nsObserverService(void);
NS_DECL_ISUPPORTS
static NS_METHOD
Create(nsISupports* outer, const nsIID& aIID, void* *aInstancePtr);
private:
NS_IMETHOD GetObserverList(nsIObserverList** anObserverList, nsString* aTopic);
nsHashtable* mObserverTopicTable;
};
#endif /* nsObserverService_h___ */

View File

@@ -416,6 +416,26 @@ nsPageMgr::~nsPageMgr()
}
}
NS_METHOD
nsPageMgr::Create(nsISupports *aOuter, REFNSIID aIID, void **aResult)
{
if (aOuter)
return NS_ERROR_NO_AGGREGATION;
nsPageMgr* pageMgr = new nsPageMgr();
if (pageMgr == nsnull)
return NS_ERROR_OUT_OF_MEMORY;
NS_ADDREF(pageMgr);
nsresult rv = pageMgr->Init();
if (NS_FAILED(rv)) {
NS_RELEASE(pageMgr);
return rv;
}
rv = pageMgr->QueryInterface(aIID, aResult);
NS_RELEASE(pageMgr);
return NS_OK;
}
NS_IMPL_ADDREF(nsPageMgr);
NS_IMPL_RELEASE(nsPageMgr);

View File

@@ -102,6 +102,9 @@ class nsPageMgr : public nsIPageManager, public nsIAllocator {
public:
NS_DECL_ISUPPORTS
static NS_METHOD
Create(nsISupports *aOuter, REFNSIID aIID, void **aResult);
// nsIPageManager methods:
NS_IMETHOD AllocPages(PRUint32 pageCount, void* *result);
NS_IMETHOD DeallocPages(PRUint32 pageCount, void* pages);

View File

@@ -1,4 +1,4 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* 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
@@ -22,10 +22,23 @@
////////////////////////////////////////////////////////////////////////////////
NS_IMPL_ISUPPORTS(nsProperties, nsIProperties::GetIID());
nsProperties::nsProperties()
nsProperties::nsProperties(nsISupports* outer)
{
NS_INIT_AGGREGATED(outer);
}
NS_METHOD
nsProperties::Create(nsISupports *outer, REFNSIID aIID, void **aResult)
{
if (outer && !aIID.Equals(nsISupports::GetIID()))
return NS_NOINTERFACE; // XXX right error?
nsProperties* props = new nsProperties(outer);
if (props == NULL)
return NS_ERROR_OUT_OF_MEMORY;
NS_ADDREF(props);
nsresult rv = props->QueryInterface(aIID, aResult);
NS_RELEASE(props);
return NS_OK;
}
PRBool
@@ -41,6 +54,23 @@ nsProperties::~nsProperties()
Enumerate(ReleaseValues);
}
NS_IMPL_AGGREGATED(nsProperties);
NS_METHOD
nsProperties::AggregatedQueryInterface(const nsIID& aIID, void** aInstancePtr)
{
if (NULL == aInstancePtr) {
return NS_ERROR_NULL_POINTER;
}
if (aIID.Equals(nsIProperties::GetIID()) ||
aIID.Equals(nsISupports::GetIID())) {
*aInstancePtr = (void*) this;
NS_ADDREF_THIS();
return NS_OK;
}
return NS_NOINTERFACE;
}
NS_IMETHODIMP
nsProperties::DefineProperty(const char* prop, nsISupports* initialValue)
{
@@ -108,12 +138,7 @@ nsProperties::HasProperty(const char* prop, nsISupports* expectedValue)
nsresult
NS_NewIProperties(nsIProperties* *result)
{
nsProperties* props = new nsProperties();
if (props == NULL)
return NS_ERROR_OUT_OF_MEMORY;
NS_ADDREF(props);
*result = props;
return NS_OK;
return nsProperties::Create(NULL, nsIProperties::GetIID(), (void**)result);
}
////////////////////////////////////////////////////////////////////////////////
@@ -121,7 +146,6 @@ NS_NewIProperties(nsIProperties* *result)
////////////////////////////////////////////////////////////////////////////////
#include "nsID.h"
#include "nsBaseDLL.h"
#include "nsCRT.h"
#include "nsIInputStream.h"
#include "nsIProperties.h"
@@ -156,6 +180,20 @@ nsPersistentProperties::~nsPersistentProperties()
}
}
NS_METHOD
nsPersistentProperties::Create(nsISupports *aOuter, REFNSIID aIID, void **aResult)
{
if (aOuter)
return NS_ERROR_NO_AGGREGATION;
nsPersistentProperties* props = new nsPersistentProperties();
if (props == nsnull)
return NS_ERROR_OUT_OF_MEMORY;
NS_ADDREF(props);
nsresult rv = props->QueryInterface(aIID, aResult);
NS_RELEASE(props);
return rv;
}
NS_IMPL_ADDREF(nsPersistentProperties)
NS_IMPL_RELEASE(nsPersistentProperties)

View File

@@ -21,13 +21,14 @@
#include "nsIProperties.h"
#include "nsHashtable.h"
#include "nsAgg.h"
class nsIUnicharInputStream;
class nsProperties : public nsIProperties, public nsHashtable {
public:
NS_DECL_ISUPPORTS
NS_DECL_AGGREGATED
// nsIProperties methods:
NS_IMETHOD DefineProperty(const char* prop, nsISupports* initialValue);
@@ -37,9 +38,12 @@ public:
NS_IMETHOD HasProperty(const char* prop, nsISupports* value);
// nsProperties methods:
nsProperties();
nsProperties(nsISupports* outer);
virtual ~nsProperties();
static NS_METHOD
Create(nsISupports *aOuter, REFNSIID aIID, void **aResult);
static PRBool ReleaseValues(nsHashKey* key, void* data, void* closure);
};
@@ -52,6 +56,9 @@ public:
NS_DECL_ISUPPORTS
static NS_METHOD
Create(nsISupports *aOuter, REFNSIID aIID, void **aResult);
// nsIProperties methods:
NS_IMETHOD DefineProperty(const char* prop, nsISupports* initialValue);
NS_IMETHOD UndefineProperty(const char* prop);

View File

@@ -829,8 +829,8 @@ nsString2& nsString2::Append(const char* aCString,PRInt32 aCount) {
nsStr temp;
Initialize(temp,eOneByte);
temp.mStr=(char*)aCString;
if(-1==aCount) aCount= nsCRT::strlen(aCString);
temp.mLength = aCount;
temp.mLength=nsCRT::strlen(aCString);
if(-1==aCount) aCount=temp.mLength;
nsStr::Append(*this,temp,0,aCount,mAgent);
}
return *this;
@@ -848,8 +848,8 @@ nsString2& nsString2::Append(const PRUnichar* aString,PRInt32 aCount) {
nsStr temp;
Initialize(temp,eTwoByte);
temp.mUStr=(PRUnichar*)aString;
if(-1==aCount) aCount= nsCRT::strlen(aString);
temp.mLength = aCount;
temp.mLength=nsCRT::strlen(aString);
if(-1==aCount) aCount=temp.mLength;
nsStr::Append(*this,temp,0,aCount,mAgent);
}
return *this;

View File

@@ -34,6 +34,22 @@ nsSupportsArray::~nsSupportsArray()
DeleteArray();
}
NS_METHOD
nsSupportsArray::Create(nsISupports *aOuter, REFNSIID aIID, void **aResult)
{
if (aOuter)
return NS_ERROR_NO_AGGREGATION;
nsSupportsArray *it = new nsSupportsArray();
if (it == NULL)
return NS_ERROR_OUT_OF_MEMORY;
NS_ADDREF(it);
nsresult rv = it->QueryInterface(aIID, aResult);
NS_RELEASE(it);
return rv;
}
NS_IMPL_ISUPPORTS(nsSupportsArray, nsISupportsArray::GetIID());
void nsSupportsArray::DeleteArray(void)
@@ -348,14 +364,9 @@ nsSupportsArray::Enumerate(nsIEnumerator* *result)
NS_COM nsresult
NS_NewISupportsArray(nsISupportsArray** aInstancePtrResult)
{
if (aInstancePtrResult == 0)
return NS_ERROR_NULL_POINTER;
nsSupportsArray *it = new nsSupportsArray();
if (0 == it)
return NS_ERROR_OUT_OF_MEMORY;
NS_ADDREF(it);
*aInstancePtrResult = it;
return NS_OK;
nsresult rv;
rv = nsSupportsArray::Create(NULL, nsISupportsArray::GetIID(),
(void**)aInstancePtrResult);
return rv;
}

View File

@@ -28,6 +28,9 @@ public:
nsSupportsArray(void);
virtual ~nsSupportsArray(void);
static NS_METHOD
Create(nsISupports *aOuter, REFNSIID aIID, void **aResult);
NS_DECL_ISUPPORTS
// nsICollection methods:

View File

@@ -15,43 +15,48 @@
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
#include "nsIUnicharBuffer.h"
#include "nsUnicharBuffer.h"
#include "nsIUnicharInputStream.h"
#include "nsCRT.h"
#define MIN_BUFFER_SIZE 32
class UnicharBufferImpl : public nsIUnicharBuffer {
public:
UnicharBufferImpl(PRUint32 aBufferSize);
virtual ~UnicharBufferImpl();
UnicharBufferImpl::UnicharBufferImpl()
: mBuffer(NULL), mSpace(0), mLength(0)
{
NS_INIT_REFCNT();
}
NS_DECL_ISUPPORTS
virtual PRInt32 GetLength() const;
virtual PRInt32 GetBufferSize() const;
virtual PRUnichar* GetBuffer() const;
virtual PRBool Grow(PRInt32 aNewSize);
virtual PRInt32 Fill(nsresult* aErrorCode, nsIUnicharInputStream* aStream,
PRInt32 aKeep);
NS_METHOD
UnicharBufferImpl::Create(nsISupports *aOuter, REFNSIID aIID, void **aResult)
{
if (aOuter)
return NS_ERROR_NO_AGGREGATION;
PRUnichar* mBuffer;
PRUint32 mSpace;
PRUint32 mLength;
};
UnicharBufferImpl* it = new UnicharBufferImpl();
if (it == nsnull)
return NS_ERROR_OUT_OF_MEMORY;
UnicharBufferImpl::UnicharBufferImpl(PRUint32 aBufferSize)
NS_ADDREF(it);
nsresult rv = it->QueryInterface(aIID, aResult);
NS_RELEASE(it);
return rv;
}
NS_IMETHODIMP
UnicharBufferImpl::Init(PRUint32 aBufferSize)
{
if (aBufferSize < MIN_BUFFER_SIZE) {
aBufferSize = MIN_BUFFER_SIZE;
}
mSpace = aBufferSize;
mBuffer = new PRUnichar[aBufferSize];
mLength = 0;
NS_INIT_REFCNT();
mBuffer = new PRUnichar[aBufferSize];
return mBuffer ? NS_OK : NS_ERROR_OUT_OF_MEMORY;
}
NS_DEFINE_IID(kUnicharBufferIID, NS_IUNICHAR_BUFFER_IID);
NS_IMPL_ISUPPORTS(UnicharBufferImpl,kUnicharBufferIID)
NS_IMPL_ISUPPORTS(UnicharBufferImpl, nsIUnicharBuffer::GetIID())
UnicharBufferImpl::~UnicharBufferImpl()
{
@@ -62,22 +67,26 @@ UnicharBufferImpl::~UnicharBufferImpl()
mLength = 0;
}
PRInt32 UnicharBufferImpl::GetLength() const
NS_IMETHODIMP_(PRInt32)
UnicharBufferImpl::GetLength() const
{
return mLength;
}
PRInt32 UnicharBufferImpl::GetBufferSize() const
NS_IMETHODIMP_(PRInt32)
UnicharBufferImpl::GetBufferSize() const
{
return mSpace;
}
PRUnichar* UnicharBufferImpl::GetBuffer() const
NS_IMETHODIMP_(PRUnichar*)
UnicharBufferImpl::GetBuffer() const
{
return mBuffer;
}
PRBool UnicharBufferImpl::Grow(PRInt32 aNewSize)
NS_IMETHODIMP_(PRBool)
UnicharBufferImpl::Grow(PRInt32 aNewSize)
{
if (PRUint32(aNewSize) < MIN_BUFFER_SIZE) {
aNewSize = MIN_BUFFER_SIZE;
@@ -94,9 +103,10 @@ PRBool UnicharBufferImpl::Grow(PRInt32 aNewSize)
return PR_FALSE;
}
PRInt32 UnicharBufferImpl::Fill(nsresult* aErrorCode,
nsIUnicharInputStream* aStream,
PRInt32 aKeep)
NS_IMETHODIMP_(PRInt32)
UnicharBufferImpl::Fill(nsresult* aErrorCode,
nsIUnicharInputStream* aStream,
PRInt32 aKeep)
{
NS_PRECONDITION(nsnull != aStream, "null stream");
NS_PRECONDITION(PRUint32(aKeep) < PRUint32(mLength), "illegal keep count");
@@ -127,16 +137,21 @@ PRInt32 UnicharBufferImpl::Fill(nsresult* aErrorCode,
return nb;
}
NS_BASE nsresult NS_NewUnicharBuffer(nsIUnicharBuffer** aInstancePtrResult,
nsISupports* aOuter,
PRUint32 aBufferSize)
NS_BASE nsresult
NS_NewUnicharBuffer(nsIUnicharBuffer** aInstancePtrResult,
nsISupports* aOuter,
PRUint32 aBufferSize)
{
if (nsnull != aOuter) {
return NS_ERROR_NO_AGGREGATION;
nsresult rv;
nsIUnicharBuffer* buf;
rv = UnicharBufferImpl::Create(aOuter, nsIUnicharBuffer::GetIID(),
(void**)&buf);
if (NS_FAILED(rv)) return rv;
rv = buf->Init(aBufferSize);
if (NS_FAILED(rv)) {
NS_RELEASE(buf);
return rv;
}
UnicharBufferImpl* it = new UnicharBufferImpl(aBufferSize);
if (nsnull == it) {
return NS_ERROR_OUT_OF_MEMORY;
}
return it->QueryInterface(kUnicharBufferIID, (void **) aInstancePtrResult);
*aInstancePtrResult = buf;
return rv;
}

View File

@@ -35,11 +35,11 @@ NS_METHOD nsGenericFactory::QueryInterface(const nsIID& aIID, void** aInstancePt
if (NULL == aInstancePtr) {
return NS_ERROR_NULL_POINTER;
}
if (aIID.Equals(nsIFactory::GetIID()) ||
aIID.Equals(nsIGenericFactory::GetIID()) ||
aIID.Equals(nsISupports::GetIID())) {
*aInstancePtr = (void*) this;
AddRef();
if (aIID.Equals(nsIGenericFactory::GetIID()) ||
aIID.Equals(nsIFactory::GetIID()) ||
aIID.Equals(nsISupports::GetIID())) {
*aInstancePtr = (nsIGenericFactory*) this;
NS_ADDREF_THIS();
return NS_OK;
}
return NS_NOINTERFACE;
@@ -86,3 +86,25 @@ NS_METHOD nsGenericFactory::Create(nsISupports* outer, const nsIID& aIID, void*
}
return res;
}
extern nsresult
NS_NewGenericFactory(nsIGenericFactory* *result,
nsIGenericFactory::ConstructorProcPtr constructor,
nsIGenericFactory::DestructorProcPtr destructor)
{
nsresult rv;
nsIGenericFactory* fact;
rv = nsGenericFactory::Create(NULL, nsIGenericFactory::GetIID(), (void**)&fact);
if (NS_FAILED(rv)) return rv;
rv = fact->SetConstructor(constructor);
if (NS_FAILED(rv)) goto error;
rv = fact->SetDestructor(destructor);
if (NS_FAILED(rv)) goto error;
*result = fact;
return rv;
error:
NS_RELEASE(fact);
return rv;
}

View File

@@ -54,4 +54,40 @@ public:
NS_IMETHOD SetDestructor(DestructorProcPtr destructor) = 0;
};
extern nsresult
NS_NewGenericFactory(nsIGenericFactory* *result,
nsIGenericFactory::ConstructorProcPtr constructor,
nsIGenericFactory::DestructorProcPtr destructor = NULL);
#define NS_GENERIC_FACTORY_CONSTRUCTOR(_InstanceClass) \
static nsresult \
_InstanceClass##Constructor(nsISupports *aOuter, REFNSIID aIID, void **aResult) \
{ \
nsresult rv; \
\
_InstanceClass * inst; \
\
if (NULL == aResult) { \
rv = NS_ERROR_NULL_POINTER; \
goto done; \
} \
*aResult = NULL; \
if (NULL != aOuter) { \
rv = NS_ERROR_NO_AGGREGATION; \
goto done; \
} \
\
NS_NEWXPCOM(inst, _InstanceClass); \
if (NULL == inst) { \
rv = NS_ERROR_OUT_OF_MEMORY; \
goto done; \
} \
NS_ADDREF(inst); \
rv = inst->QueryInterface(aIID, aResult); \
NS_RELEASE(inst); \
\
done: \
return rv; \
}
#endif /* nsIGenericFactory_h___ */

View File

@@ -38,7 +38,13 @@ EXPORTS = \
nsSpecialSystemDirectory.h \
$(NULL)
XPIDLSRCS = \
xXPILD_MODULE = xpcom_io
xXPIDLSRCS = \
.\nsIUri.idl \
.\nsIUrl.idl \
.\nsIFileUrl.idl \
.\nsIUriManager.idl \
$(NULL)
################################################################################
@@ -62,6 +68,7 @@ CPP_OBJS = \
.\$(OBJDIR)\nsFileStream.obj \
.\$(OBJDIR)\nsIFileStream.obj \
.\$(OBJDIR)\nsIStringStream.obj \
.\$(OBJDIR)\nsPipe.obj \
.\$(OBJDIR)\nsSpecialSystemDirectory.obj \
.\$(OBJDIR)\nsUnicharInputStream.obj \
$(NULL)

View File

@@ -16,164 +16,9 @@
* Reserved.
*/
#include "nsIByteBufferInputStream.h"
#include "nsCRT.h"
#include "nsByteBufferInputStream.h"
#include "prcmon.h"
class nsByteBufferInputStream;
////////////////////////////////////////////////////////////////////////////////
class nsByteBufferOutputStream : public nsIOutputStream
{
public:
NS_DECL_ISUPPORTS
// nsIBaseStream methods:
NS_IMETHOD Close(void);
// nsIOutputStream methods:
NS_IMETHOD Write(const char* aBuf, PRUint32 aCount, PRUint32 *aWriteCount);
NS_IMETHOD Write(nsIInputStream* fromStream, PRUint32 *aWriteCount);
NS_IMETHOD Flush(void);
// nsByteBufferOutputStream methods:
nsByteBufferOutputStream(nsByteBufferInputStream* in);
virtual ~nsByteBufferOutputStream();
protected:
nsByteBufferInputStream* mInputStream;
};
////////////////////////////////////////////////////////////////////////////////
class nsByteBufferInputStream : public nsIByteBufferInputStream
{
public:
NS_DECL_ISUPPORTS
// nsIBaseStream methods:
NS_IMETHOD Close(void);
// nsIInputStream methods:
NS_IMETHOD GetLength(PRUint32 *aLength);
NS_IMETHOD Read(char* aBuf, PRUint32 aCount, PRUint32 *aReadCount);
// nsIByteBufferInputStream methods:
NS_IMETHOD Fill(nsIInputStream* stream, PRUint32 *aWriteCount);
NS_IMETHOD Fill(const char* aBuf, PRUint32 aCount, PRUint32 *aWriteCount);
// nsByteBufferInputStream methods:
nsByteBufferInputStream(PRBool blocking, PRUint32 size);
virtual ~nsByteBufferInputStream();
friend class nsByteBufferOutputStream;
nsresult Init(void);
nsresult SetEOF(void);
nsresult Drain(void);
PRBool AtEOF() { return mEOF && (mReadCursor == mWriteCursor) && !mFull; }
PRUint32 ReadableAmount() {
if (mReadCursor < mWriteCursor)
return mWriteCursor - mReadCursor;
else if (mReadCursor == mWriteCursor && !mFull)
return 0;
else
return (mLength - mReadCursor) + mWriteCursor;
}
PRUint32 WritableAmount() {
if (mWriteCursor < mReadCursor)
return mWriteCursor - mReadCursor;
else if (mReadCursor == mWriteCursor && mFull)
return 0;
else
return (mLength - mWriteCursor) + mReadCursor;
}
void ReadChunk(char* toBuf, PRUint32 max,
PRUint32 end, PRUint32 *totalRef)
{
NS_ASSERTION(mReadCursor <= end, "bad range");
PRUint32 diff = end - mReadCursor;
PRInt32 amt = PR_MIN(max, diff);
if (amt > 0) {
nsCRT::memcpy(toBuf, &mBuffer[mReadCursor], amt);
#ifdef DEBUG_warren
// nsCRT::memset(&mBuffer[mReadCursor], 0xDD, amt);
#endif
mReadCursor += amt;
*totalRef += amt;
}
}
nsresult WriteChunk(nsIInputStream* in,
PRUint32 end, PRUint32 *totalRef)
{
NS_ASSERTION(mWriteCursor <= end, "bad range");
PRUint32 amt = end - mWriteCursor;
if (amt > 0) {
PRUint32 readAmt;
nsresult rv = in->Read(&mBuffer[mWriteCursor], amt, &readAmt);
if (NS_FAILED(rv)) return rv;
mWriteCursor += readAmt;
*totalRef += readAmt;
}
return NS_OK;
}
protected:
char* mBuffer;
PRUint32 mLength;
PRUint32 mReadCursor;
PRUint32 mWriteCursor;
PRBool mFull;
PRBool mClosed;
PRBool mEOF;
PRBool mBlocking;
};
////////////////////////////////////////////////////////////////////////////////
class nsDummyBufferStream : public nsIInputStream
{
public:
NS_DECL_ISUPPORTS
// nsIBaseStream methods:
NS_IMETHOD Close(void) {
NS_NOTREACHED("nsDummyBufferStream::Close");
return NS_ERROR_FAILURE;
}
// nsIInputStream methods:
NS_IMETHOD GetLength(PRUint32 *aLength) {
*aLength = mLength;
return NS_OK;
}
NS_IMETHOD Read(char* aBuf, PRUint32 aCount, PRUint32 *aReadCount) {
PRUint32 amt = PR_MIN(aCount, mLength);
if (amt > 0) {
nsCRT::memcpy(aBuf, mBuffer, amt);
mBuffer += amt;
mLength -= amt;
}
*aReadCount = amt;
return NS_OK;
}
// nsDummyBufferStream methods:
nsDummyBufferStream(const char* buffer, PRUint32 length)
: mBuffer(buffer), mLength(length) {}
virtual ~nsDummyBufferStream() {}
protected:
const char* mBuffer;
PRUint32 mLength;
};
NS_IMETHODIMP
nsDummyBufferStream::QueryInterface(REFNSIID aIID, void** aInstancePtr)
{

View File

@@ -437,11 +437,11 @@ void nsFileSpecHelpers::MakeAllDirectories(const char* inPath, int mode)
#endif // XP_PC || XP_UNIX
#if defined(XP_PC)
#include "windows/nsFileSpecWin.cpp" // Windows-specific implementations
#include "nsFileSpecWin.cpp" // Windows-specific implementations
#elif defined(XP_MAC)
#include "nsFileSpecMac.cpp" // Macintosh-specific implementations
#elif defined(XP_UNIX)
#include "unix/nsFileSpecUnix.cpp" // Unix-specific implementations
#include "nsFileSpecUnix.cpp" // Unix-specific implementations
#endif
//========================================================================================

View File

@@ -26,6 +26,7 @@ DIRS= typelib \
components \
threads \
reflect \
proxy \
tools \
build \
tests

View File

@@ -28,5 +28,6 @@ nsXPComCIID.h
nsXPIDLString.h
nsIEventQueue.h
nsIEventQueueService.h
nsICollection.h
nsIAllocator.h
nsIGenericFactory.h

View File

@@ -1,4 +1,3 @@
nsICollection.h
nsIEnumerator.h
nsIFactory.h
nsrootidl.h

View File

@@ -829,8 +829,8 @@ nsString2& nsString2::Append(const char* aCString,PRInt32 aCount) {
nsStr temp;
Initialize(temp,eOneByte);
temp.mStr=(char*)aCString;
if(-1==aCount) aCount= nsCRT::strlen(aCString);
temp.mLength = aCount;
temp.mLength=nsCRT::strlen(aCString);
if(-1==aCount) aCount=temp.mLength;
nsStr::Append(*this,temp,0,aCount,mAgent);
}
return *this;
@@ -848,8 +848,8 @@ nsString2& nsString2::Append(const PRUnichar* aString,PRInt32 aCount) {
nsStr temp;
Initialize(temp,eTwoByte);
temp.mUStr=(PRUnichar*)aString;
if(-1==aCount) aCount= nsCRT::strlen(aString);
temp.mLength = aCount;
temp.mLength=nsCRT::strlen(aString);
if(-1==aCount) aCount=temp.mLength;
nsStr::Append(*this,temp,0,aCount,mAgent);
}
return *this;

View File

@@ -18,7 +18,6 @@
#define NS_IMPL_IDS
#include "nsXPComCIID.h"
#include "nsIEventQueueService.h"
#include "nsINetService.h"
#include "nsIProperties.h"
@@ -29,7 +28,7 @@
#include "plevent.h"
#endif
#define TEST_URL "resource:/res/test.properties"
#define TEST_URL "resource:/res/test.PersistentProperties"
#ifdef XP_PC
#define NETLIB_DLL "netlib.dll"
@@ -46,7 +45,6 @@
#define XPCOM_DLL "libxpcom.so"
#endif
#endif
static NS_DEFINE_IID(kEventQueueCID, NS_EVENTQUEUE_CID);
static NS_DEFINE_IID(kEventQueueServiceCID, NS_EVENTQUEUESERVICE_CID);
static NS_DEFINE_IID(kIEventQueueServiceIID, NS_IEVENTQUEUESERVICE_IID);
static NS_DEFINE_IID(kINetServiceIID, NS_INETSERVICE_IID);
@@ -59,42 +57,21 @@ extern "C" void NS_SetupRegistry();
#endif
int
main(int argc, char* argv[])
main(int argc, char *argv[])
{
nsresult ret;
ret = nsComponentManager::RegisterComponent(kNetServiceCID, NULL,
NULL, NETLIB_DLL, PR_FALSE, PR_FALSE);
if (NS_FAILED(ret)) {
printf("cannot register net service\n");
return 1;
}
ret = nsComponentManager::RegisterComponent(kEventQueueCID, NULL,
NULL, XPCOM_DLL, PR_FALSE, PR_FALSE);
if (NS_FAILED(ret)) {
printf("cannot register event queue\n");
return 1;
}
ret = nsComponentManager::RegisterComponent(kEventQueueServiceCID, NULL,
NULL, XPCOM_DLL, PR_FALSE, PR_FALSE);
if (NS_FAILED(ret)) {
printf("cannot register event queue service\n");
return 1;
}
ret = nsComponentManager::RegisterComponent(kPersistentPropertiesCID, NULL,
NULL, RAPTORBASE_DLL, PR_FALSE, PR_FALSE);
if (NS_FAILED(ret)) {
printf("cannot register persistent properties\n");
return 1;
}
nsComponentManager::RegisterComponent(kNetServiceCID, NULL, NULL, NETLIB_DLL,
PR_FALSE, PR_FALSE);
nsComponentManager::RegisterComponent(kEventQueueServiceCID, NULL, NULL, XPCOM_DLL,
PR_FALSE, PR_FALSE);
#ifdef XP_MAC // have not build this on PC and UNIX yet so make it #ifdef XP_MAC
NS_SetupRegistry();
#endif
nsresult ret;
nsIEventQueueService* pEventQueueService = nsnull;
ret = nsServiceManager::GetService(kEventQueueServiceCID,
kIEventQueueServiceIID, (nsISupports**) &pEventQueueService);
if (NS_FAILED(ret) || (!pEventQueueService)) {
if (NS_FAILED(ret)) {
printf("cannot get event queue service\n");
return 1;
}
@@ -106,53 +83,43 @@ main(int argc, char* argv[])
nsINetService* pNetService = nsnull;
ret = nsServiceManager::GetService(kNetServiceCID, kINetServiceIID,
(nsISupports**) &pNetService);
if (NS_FAILED(ret) || (!pNetService)) {
if (NS_FAILED(ret)) {
printf("cannot get net service\n");
return 1;
}
nsIURL* url = nsnull;
nsIURL *url = nsnull;
ret = pNetService->CreateURL(&url, nsString(TEST_URL), nsnull, nsnull,
nsnull);
if (NS_FAILED(ret) || (!url)) {
if (NS_FAILED(ret)) {
printf("cannot create URL\n");
return 1;
}
nsIInputStream* in = nsnull;
nsIInputStream *in = nsnull;
ret = pNetService->OpenBlockingStream(url, nsnull, &in);
if (NS_FAILED(ret) || (!in)) {
if (NS_FAILED(ret)) {
printf("cannot open stream\n");
return 1;
}
nsIPersistentProperties* props = nsnull;
nsIPersistentProperties *props = nsnull;
ret = nsComponentManager::CreateInstance(kPersistentPropertiesCID, NULL,
kIPersistentPropertiesIID, (void**) &props);
if (NS_FAILED(ret) || (!props)) {
if (NS_FAILED(ret)) {
printf("create nsIPersistentProperties failed\n");
return 1;
}
ret = props->Load(in);
if (NS_FAILED(ret)) {
printf("cannot load properties\n");
return 1;
}
props->Load(in);
int i = 1;
while (1) {
char name[16];
name[0] = 0;
sprintf(name, "%d", i);
nsAutoString v("");
ret = props->GetProperty(name, v);
if (NS_FAILED(ret) || (!v.Length())) {
props->GetProperty(name, v);
if (!v.Length()) {
break;
}
char* value = v.ToNewCString();
if (value) {
cout << "\"" << i << "\"=\"" << value << "\"" << endl;
delete[] value;
}
else {
printf("%d: ToNewCString failed\n", i);
}
char *value = v.ToNewCString();
cout << "\"" << i << "\"=\"" << value << "\"" << endl;
delete[] value;
i++;
}

View File

@@ -21,7 +21,7 @@
#include "nsIComponentManager.h"
#include "nsIServiceManager.h"
#include "nsAutoLock.h"
#include "nsPageMgr.h"
#include "nsIPageManager.h"
#include "nsCRT.h"
#include "prprf.h"
#include "prmem.h"

View File

@@ -28,8 +28,6 @@ EXPORTS = \
nsIEventQueue.h \
nsIEventQueueService.h \
nsIThread.h \
nsITimer.h \
nsITimerCallback.h \
$(NULL)
XPIDLSRCS = \
@@ -51,7 +49,6 @@ CPP_OBJS = \
.\$(OBJDIR)\nsEventQueue.obj \
.\$(OBJDIR)\nsEventQueueService.obj \
.\$(OBJDIR)\nsThread.obj \
.\$(OBJDIR)\nsTimer_win.obj \
$(NULL)
include <$(DEPTH)\config\rules.mak>

View File

@@ -113,5 +113,8 @@ nsEventQueueImpl::Create(nsISupports *aOuter,
if (evt == NULL)
return NS_ERROR_OUT_OF_MEMORY;
nsresult rv = evt->QueryInterface(aIID, aResult);
if (NS_FAILED(rv)) {
delete evt;
}
return rv;
}

View File

@@ -19,7 +19,6 @@
#include "prmon.h"
#include "nsIEventQueue.h"
#include "nsXPComFactory.h"
static NS_DEFINE_IID(kIEventQueueIID, NS_IEVENTQUEUE_IID);

View File

@@ -16,56 +16,14 @@
* Corporation. Portions created by Netscape are Copyright (C) 1998
* Netscape Communications Corporation. All Rights Reserved.
*/
#include "nsEventQueueService.h"
#include "prmon.h"
#include "nsComponentManager.h"
#include "nsIEventQueueService.h"
#include "nsIEventQueue.h"
#include "nsHashtable.h"
#include "nsXPComFactory.h"
static NS_DEFINE_IID(kIEventQueueServiceIID, NS_IEVENTQUEUESERVICE_IID);
// XXX move to nsID.h or nsHashtable.h? (copied from nsComponentManager.cpp)
class ThreadKey: public nsHashKey {
private:
const PRThread* id;
public:
ThreadKey(const PRThread* aID) {
id = aID;
}
PRUint32 HashValue(void) const {
return (PRUint32)id;
}
PRBool Equals(const nsHashKey *aKey) const {
return (id == ((const ThreadKey *) aKey)->id);
}
nsHashKey *Clone(void) const {
return new ThreadKey(id);
}
};
/* This class is used with the EventQueueEntries to allow us to nest
event queues */
class EventQueueStack
{
public:
EventQueueStack(EventQueueStack* next = NULL);
~EventQueueStack();
nsIEventQueue* GetEventQueue();
EventQueueStack* GetNext();
void SetNext(EventQueueStack* aStack);
private:
nsIEventQueue* mEventQueue;
EventQueueStack* mNextQueue;
};
static NS_DEFINE_IID(kIEventQueueIID, NS_IEVENTQUEUE_IID);
static NS_DEFINE_IID(kEventQueueCID, NS_EVENTQUEUE_CID);
@@ -113,30 +71,7 @@ void EventQueueStack::SetNext(EventQueueStack* aStack)
mNextQueue = aStack;
}
/*
* This class maintains the data associated with each entry in the EventQueue
* service's hash table...
*
* It derives from nsISupports merely as a convienence since the entries are
* reference counted...
*/
class EventQueueEntry : public nsISupports
{
public:
EventQueueEntry();
virtual ~EventQueueEntry();
// nsISupports interface...
NS_DECL_ISUPPORTS
nsIEventQueue* GetEventQueue(void);
void PushQueue(void);
void PopQueue(void);
private:
EventQueueStack* mQueueStack;
};
////////////////////////////////////////////////////////////////////////////////
/* nsISupports interface implementation... */
NS_IMPL_ISUPPORTS(EventQueueEntry,kISupportsIID);
@@ -182,34 +117,7 @@ void EventQueueEntry::PopQueue(void)
delete popped;
}
class nsEventQueueServiceImpl : public nsIEventQueueService
{
public:
nsEventQueueServiceImpl();
virtual ~nsEventQueueServiceImpl();
// nsISupports interface...
NS_DECL_ISUPPORTS
// nsIEventQueueService interface...
NS_IMETHOD CreateThreadEventQueue(void);
NS_IMETHOD DestroyThreadEventQueue(void);
NS_IMETHOD GetThreadEventQueue(PRThread* aThread, nsIEventQueue** aResult);
NS_IMETHOD CreateFromPLEventQueue(PLEventQueue* aPLEventQueue, nsIEventQueue** aResult);
NS_IMETHOD PushThreadEventQueue(void);
NS_IMETHOD PopThreadEventQueue(void);
#ifdef XP_MAC
NS_IMETHOD ProcessEvents();
#endif // XP_MAC
private:
nsHashtable* mEventQTable;
PRMonitor* mEventQMonitor;
};
////////////////////////////////////////////////////////////////////////////////
nsEventQueueServiceImpl::nsEventQueueServiceImpl()
{
@@ -239,6 +147,20 @@ nsEventQueueServiceImpl::~nsEventQueueServiceImpl()
PR_DestroyMonitor(mEventQMonitor);
}
NS_METHOD
nsEventQueueServiceImpl::Create(nsISupports *aOuter, REFNSIID aIID, void **aResult)
{
if (aOuter)
return NS_ERROR_NO_AGGREGATION;
nsEventQueueServiceImpl* eqs = new nsEventQueueServiceImpl();
if (eqs == NULL)
return NS_ERROR_OUT_OF_MEMORY;
NS_ADDREF(eqs);
nsresult rv = eqs->QueryInterface(aIID, aResult);
NS_RELEASE(eqs);
return rv;
}
/* nsISupports interface implementation... */
NS_IMPL_ISUPPORTS(nsEventQueueServiceImpl,kIEventQueueServiceIID);
@@ -418,6 +340,7 @@ done:
PR_ExitMonitor(mEventQMonitor);
return rv;
}
#ifdef XP_MAC
// Callback from the enumeration of the HashTable.
static PRBool EventDispatchingFunc(nsHashKey *aKey, void *aData, void* closure)
@@ -442,77 +365,5 @@ NS_IMETHODIMP nsEventQueueServiceImpl::ProcessEvents()
}
#endif
//----------------------------------------------------------------------
static nsEventQueueServiceImpl* gServiceInstance = NULL;
NS_DEF_FACTORY(EventQueueServiceGen,nsEventQueueServiceImpl)
class nsEventQueueServiceFactory : public nsEventQueueServiceGenFactory
{
public:
NS_IMETHOD CreateInstance(nsISupports *aOuter,
const nsIID &aIID,
void **aResult);
};
NS_IMETHODIMP
nsEventQueueServiceFactory::CreateInstance(nsISupports *aOuter,
const nsIID &aIID,
void **aResult)
{
nsresult rv;
nsISupports* inst;
// Parameter validation...
if (NULL == aResult) {
rv = NS_ERROR_NULL_POINTER;
goto done;
}
// Do not support aggregatable components...
*aResult = NULL;
if (NULL != aOuter) {
rv = NS_ERROR_NO_AGGREGATION;
goto done;
}
if (NULL == gServiceInstance) {
// Create a new instance of the component...
NS_NEWXPCOM(gServiceInstance, nsEventQueueServiceImpl);
if (NULL == gServiceInstance) {
rv = NS_ERROR_OUT_OF_MEMORY;
goto done;
}
NS_ADDREF(gServiceInstance);
}
// If the QI fails, the component will be destroyed...
//
// Use a local copy so the NS_RELEASE() will not null the global
// pointer...
inst = gServiceInstance;
NS_ADDREF(inst);
rv = inst->QueryInterface(aIID, aResult);
NS_RELEASE(inst);
done:
return rv;
}
// Entry point to create nsEventQueueService factory instances...
nsresult NS_NewEventQueueServiceFactory(nsIFactory** aResult)
{
nsresult rv = NS_OK;
nsIFactory* inst = new nsEventQueueServiceFactory();
if (NULL == inst) {
rv = NS_ERROR_OUT_OF_MEMORY;
}
else {
NS_ADDREF(inst);
}
*aResult = inst;
return rv;
}
////////////////////////////////////////////////////////////////////////////////

View File

@@ -30,6 +30,11 @@
{ 0xa6cf90dc, 0x15b3, 0x11d2, \
{0x93, 0x2e, 0x00, 0x80, 0x5f, 0x8a, 0xdd, 0x32} }
/* be761f00-a3b0-11d2-996c-0080c7cb1080 */
#define NS_EVENTQUEUESERVICE_CID \
{ 0xbe761f00, 0xa3b0, 0x11d2, \
{0x99, 0x6c, 0x00, 0x80, 0xc7, 0xcb, 0x10, 0x80} }
class nsIEventQueueService : public nsISupports
{
public:

View File

@@ -44,7 +44,7 @@ FindMode(char *mode)
gboolean enable_debug = FALSE;
gboolean enable_warnings = FALSE;
gboolean verbose_mode = FALSE;
gboolean emit_js_stub_decls = FALSE;
gboolean emit_js_stub_decls = TRUE; /* XXX change default to FALSE */
static char xpidl_usage_str[] =
"Usage: %s [-m mode] [-w] [-v] [-I path] [-o basename] filename.idl\n"

View File

@@ -14,7 +14,7 @@
# Copyright (C) 1998 Netscape Communications Corporation. All Rights
# Reserved.
DEPTH = ../..
DEPTH = ../../..
topsrcdir = @top_srcdir@
VPATH = @srcdir@
srcdir = @srcdir@
@@ -23,9 +23,7 @@ include $(DEPTH)/config/autoconf.mk
DIRS = public src
ifdef ENABLE_TESTS
DIRS += tests
endif
DIRS += tests
DIRS += tools

View File

@@ -14,7 +14,7 @@
# Copyright (C) 1998 Netscape Communications Corporation. All Rights
# Reserved.
DEPTH=..\..
DEPTH=..\..\..
IGNORE_MANIFEST=1
# Don't recur into xptinfo and xptcall, because they may require xpidl,

View File

@@ -14,7 +14,7 @@
# Copyright (C) 1998 Netscape Communications Corporation. All Rights
# Reserved.
DEPTH = ../../..
DEPTH = ../../../..
topsrcdir = @top_srcdir@
srcdir = @srcdir@
VPATH = @srcdir@

View File

@@ -17,7 +17,7 @@
IGNORE_MANIFEST=1
DEPTH=..\..\..
DEPTH=..\..\..\..
EXPORTS = xpt_struct.h \
xpt_xdr.h \

View File

@@ -15,7 +15,7 @@
# Reserved.
#
DEPTH = ../../..
DEPTH = ../../../..
topsrcdir = @top_srcdir@
srcdir = @srcdir@
VPATH = @srcdir@

View File

@@ -19,7 +19,7 @@ IGNORE_MANIFEST=1
MAKE_OBJ_TYPE = DLL
DEPTH=..\..\..
DEPTH=..\..\..\..
LIBNAME = .\$(OBJDIR)\libxpt$(MOZ_BITS)
DLL = $(LIBNAME).dll

View File

@@ -117,13 +117,11 @@ XPT_NewHeader(PRUint16 num_interfaces)
header->major_version = XPT_MAJOR_VERSION;
header->minor_version = XPT_MINOR_VERSION;
header->num_interfaces = num_interfaces;
if (num_interfaces) {
header->interface_directory = XPT_CALLOC(num_interfaces *
sizeof(XPTInterfaceDirectoryEntry));
if (!header->interface_directory) {
XPT_DELETE(header);
return NULL;
}
header->interface_directory = XPT_CALLOC(num_interfaces *
sizeof(XPTInterfaceDirectoryEntry));
if (!header->interface_directory) {
XPT_DELETE(header);
return NULL;
}
header->data_pool = 0; /* XXX do we even need this struct any more? */
@@ -174,7 +172,7 @@ XPT_DoHeader(XPTCursor *cursor, XPTHeader **headerp)
if (mode == XPT_DECODE)
XPT_DataOffset(cursor->state, &header->data_pool);
if (mode == XPT_DECODE && header->num_interfaces) {
if (mode == XPT_DECODE) {
header->interface_directory =
XPT_CALLOC(header->num_interfaces *
sizeof(XPTInterfaceDirectoryEntry));
@@ -593,7 +591,7 @@ XPT_FillMethodDescriptor(XPTMethodDescriptor *meth, PRUint8 flags, char *name,
if (!name)
return PR_FALSE;
meth->num_args = num_args;
if (num_args) {
if (meth->num_args) {
meth->params = XPT_CALLOC(num_args * sizeof(XPTParamDescriptor));
if (!meth->params)
goto free_name;

View File

@@ -14,7 +14,7 @@
# Copyright (C) 1998 Netscape Communications Corporation. All Rights
# Reserved.
DEPTH = ../../..
DEPTH = ../../../..
topsrcdir = @top_srcdir@
srcdir = @srcdir@
VPATH = @srcdir@

View File

@@ -15,7 +15,7 @@
# Copyright (C) 1998 Netscape Communications Corporation. All Rights
# Reserved.
DEPTH=..\..\..
DEPTH=..\..\..\..
IGNORE_MANIFEST=1
@@ -33,7 +33,7 @@ REQUIRES=xpcom libxpt
LINCS=-I$(PUBLIC)\xpcom -I$(PUBLIC)\raptor -I$(PUBLIC)\libxpt
LLIBS= \
$(DIST)\lib\xpcom32.lib \
$(DIST)\lib\xpcom.lib \
$(DIST)\lib\libxpt32.lib \
$(NULL)

View File

@@ -14,7 +14,7 @@
# Copyright (C) 1998 Netscape Communications Corporation. All Rights
# Reserved.
DEPTH = ../../..
DEPTH = ../../../..
topsrcdir = @top_srcdir@
srcdir = @srcdir@
VPATH = @srcdir@

View File

@@ -15,7 +15,7 @@
# Copyright (C) 1998 Netscape Communications Corporation. All Rights
# Reserved.
DEPTH=..\..\..
DEPTH=..\..\..\..
IGNORE_MANIFEST=1