Adding Autoproxification.

git-svn-id: svn://10.0.0.236/trunk@34629 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
dougt%netscape.com 1999-06-10 20:24:15 +00:00
parent 140dd409d2
commit 0de862590b
9 changed files with 289 additions and 200 deletions

View File

@ -26,7 +26,7 @@
#include "nsIEventQueue.h"
#include "plevent.h"
#include "xptcall.h"
#include "xptinfo.h"
typedef enum
{
@ -76,23 +76,33 @@ class nsProxyObject : public nsISupports
virtual ~nsProxyObject();
nsresult Post( PRUint32 methodIndex, /* which method to be called? */
PRUint32 paramCount, /* number of params */
nsXPTCVariant *params);
nsresult Post(PRUint32 methodIndex, nsXPTMethodInfo *info, nsXPTCMiniVariant *params, nsIInterfaceInfo *interfaceInfo);
nsISupports* GetRealObject() const { return mRealObject; }
nsIEventQueue* GetQueue() const { return mDestQueue; }
ProxyType GetProxyType() const { return mProxyType; }
private:
nsIEventQueue *mDestQueue; /* destination queue */
nsISupports *mRealObject; /* the non-proxy object that this event is referring to */
typedef enum
{
convertOutParameters = 1,
convertInParameters,
convertAllParameters
} AutoProxyConvertTypes;
PRBool mRealObjectOwned;
ProxyType mProxyType;
void AutoProxyParameterList(nsXPTMethodInfo *methodInfo, nsXPTCMiniVariant * params,
nsIInterfaceInfo *interfaceInfo, AutoProxyConvertTypes convertType);
nsIEventQueue *mDestQueue; /* destination queue */
nsISupports *mRealObject; /* the non-proxy object that this event is referring to */
PRBool mRealObjectOwned;
ProxyType mProxyType;
};
@ -126,21 +136,7 @@ private:
nsXPTCVariant *mParameterList; /* marshalled in parameter buffer */
PRUint32 mParameterCount; /* number of params */
PLEvent *mEvent; /* the current plevent */
};
#define NS_DECL_PROXY(_class, _interface) \
public: \
_class(nsIEventQueue *, _interface *); \
private: \
nsProxyObject mProxyObject;\
public:
#define NS_IMPL_PROXY(_class, _interface)\
_class::_class(nsIEventQueue *eventQueue, _interface *realObject) \
: mProxyObject(eventQueue, realObject) \
{\
}\
#endif

View File

@ -18,20 +18,27 @@
#include "nsProxyEvent.h"
#include "nsProxyEventPrivate.h"
#include "nsProxyObjectManager.h"
#include "prmem.h" // for PR_NEW
#include "xptcall.h"
#include "nsRepository.h"
#include "nsIServiceManager.h"
#include "nsIAllocator.h"
static NS_DEFINE_IID(kProxyObjectManagerIID, NS_IPROXYEVENT_MANAGER_IID);
static NS_DEFINE_IID(kProxyObject_Identity_Class_IID, NS_PROXYEVENT_IDENTITY_CLASS_IID);
static void* EventHandler(PLEvent *self);
static void DestroyHandler(PLEvent *self);
nsProxyObjectCallInfo::nsProxyObjectCallInfo(nsProxyObject* owner,
PRUint32 methodIndex,
nsXPTCVariant* parameterList,
PRUint32 parameterCount,
PLEvent *event)
PRUint32 methodIndex,
nsXPTCVariant* parameterList,
PRUint32 parameterCount,
PLEvent *event)
{
mOwner = owner;
mMethodIndex = methodIndex;
@ -76,6 +83,7 @@ nsProxyObject::nsProxyObject(nsIEventQueue *destQueue, ProxyType proxyType, nsIS
NS_ADDREF(mRealObject);
NS_ADDREF(mDestQueue);
}
@ -106,7 +114,7 @@ nsProxyObject::~nsProxyObject()
{
if (mDestQueue)
mDestQueue->EnterMonitor();
// Shit! mDestQueue->RevokeEvents(this);
// FIX! mDestQueue->RevokeEvents(this);
if(mRealObject != nsnull)
{
@ -124,17 +132,35 @@ nsProxyObject::~nsProxyObject()
}
nsresult
nsProxyObject::Post( PRUint32 methodIndex, /* which method to be called? */
PRUint32 paramCount, /* number of params */
nsXPTCVariant *params)
nsProxyObject::Post( PRUint32 methodIndex, nsXPTMethodInfo *methodInfo, nsXPTCMiniVariant * params, nsIInterfaceInfo *interfaceInfo)
{
if (mDestQueue == nsnull)
return NS_ERROR_OUT_OF_MEMORY;
if (mRealObject == nsnull)
return NS_ERROR_OUT_OF_MEMORY;
///////////////////////////////////////////////////////////////////////
// Auto-proxification
///////////////////////////////////////////////////////////////////////
AutoProxyParameterList(methodInfo, params, interfaceInfo, convertInParameters);
///////////////////////////////////////////////////////////////////////
// convert the nsXPTCMiniVariant to a nsXPTCVariant
uint8 paramCount = methodInfo->GetParamCount();
nsXPTCVariant *fullParam = (nsXPTCVariant*)malloc(sizeof(nsXPTCVariant) * paramCount);
for (int index = 0; index < paramCount; index++)
{
fullParam[index].flags = 0;
fullParam[index].val = params[index].val;
}
mDestQueue->EnterMonitor();
NS_ASSERTION(mRealObject, "no native object");
@ -149,11 +175,11 @@ nsProxyObject::Post( PRUint32 methodIndex, /* which method to
return NS_ERROR_OUT_OF_MEMORY;
}
nsProxyObjectCallInfo *info = new nsProxyObjectCallInfo(this, methodIndex, params, paramCount, event);
nsProxyObjectCallInfo *proxyInfo = new nsProxyObjectCallInfo(this, methodIndex, fullParam, paramCount, event);
PL_InitEvent(event,
info,
proxyInfo,
EventHandler,
DestroyHandler);
@ -161,9 +187,15 @@ nsProxyObject::Post( PRUint32 methodIndex, /* which method to
{
mDestQueue->PostSynchronousEvent(event, nsnull);
nsresult rv = info->GetResult();
delete info;
nsresult rv = proxyInfo->GetResult();
delete proxyInfo;
///////////////////////////////////////////////////////////////////////
// Auto-proxification
///////////////////////////////////////////////////////////////////////
AutoProxyParameterList(methodInfo, params, interfaceInfo, convertOutParameters);
///////////////////////////////////////////////////////////////////////
mDestQueue->ExitMonitor();
return rv;
}
@ -180,6 +212,80 @@ nsProxyObject::Post( PRUint32 methodIndex, /* which method to
}
void
nsProxyObject::AutoProxyParameterList(nsXPTMethodInfo *methodInfo, nsXPTCMiniVariant * params,
nsIInterfaceInfo *interfaceInfo, AutoProxyConvertTypes convertType)
{
uint8 paramCount = methodInfo->GetParamCount();
for (PRUint32 i = 0; i < paramCount; i++)
{
nsXPTParamInfo paramInfo = methodInfo->GetParam(i);
if (paramInfo.GetType().TagPart() != nsXPTType::T_INTERFACE )
continue;
if ( (convertType == convertOutParameters && paramInfo.IsOut()) ||
(convertType == convertInParameters && paramInfo.IsIn()) ||
(convertType == convertAllParameters))
{
// We found an out parameter which is a interface, check for proxy
if (params[i].val.p == nsnull)
continue;
nsISupports* anInterface = nsnull;
if (paramInfo.IsOut())
anInterface = *((nsISupports**)params[i].val.p);
else
anInterface = ((nsISupports*)params[i].val.p);
if (anInterface == nsnull)
continue;
nsISupports *aProxyObject;
nsresult rv = anInterface->QueryInterface(kProxyObject_Identity_Class_IID, (void**)&aProxyObject);
if (NS_FAILED(rv))
{
// create a proxy
nsIProxyObjectManager* manager;
rv = nsServiceManager::GetService( NS_XPCOMPROXY_PROGID,
kProxyObjectManagerIID,
(nsISupports **)&manager);
if (NS_SUCCEEDED(rv))
{
nsIID* iid;
interfaceInfo->GetIIDForParam(&paramInfo, &iid);
manager->GetProxyObject( GetQueue(),
*iid,
anInterface,
GetProxyType(),
(void**) &aProxyObject);
nsAllocator::Free((void*)iid);
if (paramInfo.IsOut())
*((void**)params[i].val.p) = ((void*)aProxyObject);
else
(params[i].val.p) = ((void*)aProxyObject);
NS_RELEASE(manager);
}
}
else
{
// It already is a proxy!
}
}
}
}
void DestroyHandler(PLEvent *self)
{
nsProxyObjectCallInfo* owner = (nsProxyObjectCallInfo*)PL_GetEventOwner(self);
@ -210,14 +316,14 @@ void* EventHandler(PLEvent *self)
eventQ->EnterMonitor();
// invoke the magic of xptc...
// invoke the magic of xptc...
nsresult rv = XPTC_InvokeByIndex( proxyObject->GetRealObject(),
info->GetMethodIndex(),
info->GetParameterCount(),
info->GetParameterList());
info->SetResult(rv);
eventQ->ExitMonitor();
}
return NULL;

View File

@ -223,13 +223,8 @@ nsProxyEventClass::CallQueryInterfaceOnProxy(nsProxyEventObject* self, REFNSIID
// that call returns NS_OK and the pointer is to our singleton, then the
// interface must be implemented by a nsProxy object. NOTE: the
// 'ProxyEventClassIdentity' object is not a real XPCOM object and should not be
// used for anything else (hence it is declared in this implementation file).
/* eea90d45-b059-11d2-915e-c12b696c9333 */
#define NS_PROXYEVENT_IDENTITY_CLASS_IID \
{ 0xeea90d45, 0xb059, 0x11d2, \
{ 0x91, 0x5e, 0xc1, 0x2b, 0x69, 0x6c, 0x93, 0x33 } }
// used for anything else
// NS_PROXYEVENT_IDENTITY_CLASS_IID defined in nsProxyEventPrivate.h
class ProxyEventClassIdentity
{
// no instance methods...

View File

@ -270,19 +270,7 @@ nsProxyEventObject::CallMethod(PRUint16 methodIndex,
const nsXPTMethodInfo* info,
nsXPTCMiniVariant * params)
{
uint8 paramCount = info->GetParamCount();
nsXPTCVariant *fullParam = (nsXPTCVariant*)malloc(sizeof(nsXPTCVariant) * paramCount);
for (int index = 0; index < paramCount; index++)
{
fullParam[index].flags = 0;
fullParam[index].val = params[index].val;
}
// fullParam will be deleted inside the mProxyObject
return mProxyObject->Post(methodIndex, paramCount, fullParam);
return mProxyObject->Post(methodIndex, (nsXPTMethodInfo*)info, params, GetClass()->GetInterfaceInfo());
}

View File

@ -40,6 +40,11 @@ class nsProxyEventClass;
{0x91, 0x5e, 0xc1, 0x2b, 0x69, 0x6c, 0x93, 0x33}\
}
#define NS_PROXYEVENT_IDENTITY_CLASS_IID \
{ 0xeea90d45, 0xb059, 0x11d2, \
{ 0x91, 0x5e, 0xc1, 0x2b, 0x69, 0x6c, 0x93, 0x33 } }
class nsProxyEventClass : public nsISupports
{
// all the interface method declarations...

View File

@ -21,10 +21,12 @@ VPATH = @srcdir@
include $(DEPTH)/config/autoconf.mk
MODULE = proxy
MODULE = proxytest
CPPSRCS = proxytests.cpp
XPIDLSRCS = nsITestProxy.idl
LIBS = \
-L$(DIST)/bin \
-lxpcom \

View File

@ -17,7 +17,10 @@
DEPTH=..\..\..
MAKE_OBJ_TYPE = EXE
PROGRAM = .\$(OBJDIR)\ProxyEventTest.exe
PROGRAM = .\$(OBJDIR)\ProxyTest.exe
MODULE = proxytest
XPIDLSRCS = .\nsITestProxy.idl
OBJS = \
.\$(OBJDIR)\proxytests.obj \
@ -39,7 +42,7 @@ install:: $(PROGRAM)
$(MAKE_INSTALL) $(PROGRAM) $(DIST)\bin
clobber::
rm -f $(DIST)\bin\ProxyEventTest.exe
rm -f $(DIST)\bin\ProxyTest.exe
$(PROGRAM):: $(OBJS) $(LLIBS)

View File

@ -0,0 +1,12 @@
#include "nsISupports.idl"
/* XXX should be built in */
native nsID(nsID *);
[uuid(1979e980-1cfd-11d3-915e-0000863011c4)]
interface nsITestProxy : nsISupports
{
long Test(in long p1, in long p2);
void Test2();
void Test3(in nsISupports p1, out nsISupports p2);
};

View File

@ -27,64 +27,12 @@
#include "nspr.h"
#include "prmon.h"
//--
/* {159E36D0-991E-11d2-AC3F-00C09300144B} */
#define NS_ITESTXPCFOO_IID_STR "159E36D0-991E-11d2-AC3F-00C09300144B"
#define NS_ITESTXPCFOO_IID \
{0x159E36D0, 0x991E, 0x11d2, \
{ 0xAC, 0x3F, 0x00, 0xC0, 0x93, 0x00, 0x14, 0x4B }}
class nsITestXPCFoo : public nsISupports {
public:
NS_DEFINE_STATIC_IID_ACCESSOR(NS_ITESTXPCFOO_IID)
/* long Test (in long p1, in long p2); */
NS_IMETHOD Test(PRInt32 p1, PRInt32 p2, PRInt32 *_retval) = 0;
/* void Test2 (); */
NS_IMETHOD Test2() = 0;
enum { one = 1 };
enum { five = 5 };
enum { six = 6 };
#ifdef XPIDL_JS_STUBS
static NS_EXPORT_(JSObject *) InitJSClass(JSContext *cx);
static NS_EXPORT_(JSObject *) GetJSObject(JSContext *cx, nsITestXPCFoo *priv);
#endif
};
#include "nsITestProxy.h"
//
#include "nsProxyObjectManager.h"
static NS_DEFINE_IID(kProxyObjectManagerIID, NS_IPROXYEVENT_MANAGER_IID);
static NS_DEFINE_IID(kProxyObjectManagerCID, NS_PROXYEVENT_MANAGER_CID);
/***************************************************************************/
/* Setup nsIAllocator */
/***************************************************************************/
#include "nsIAllocator.h"
static NS_DEFINE_IID(kIAllocatorIID, NS_IALLOCATOR_IID);
static NS_DEFINE_IID(kAllocatorCID, NS_ALLOCATOR_CID);
#ifdef XP_PC
#define XPCOM_DLL "xpcom.dll"
#else
#ifdef XP_MAC
#define XPCOM_DLL "XPCOM_DLL"
#else
#define XPCOM_DLL "libxpcom"MOZ_DLL_SUFFIX
#endif
#endif
/***************************************************************************/
extern "C" void
@ -99,13 +47,6 @@ NS_SetupRegistry()
const char *componentsDir = sysdir.GetCString(); // native path
if (componentsDir != NULL)
{
#ifdef XP_PC
/* The PC version of the directory from filePath is of the form
* /y|/moz/mozilla/dist/bin/components
* We need to remove the initial / and change the | to :
* for all this to work with NSPR.
*/
#endif /* XP_PC */
printf("nsComponentManager: Using components dir: %s\n", componentsDir);
#ifdef XP_MAC
@ -116,25 +57,19 @@ NS_SetupRegistry()
// XXX Look for user specific components
// XXX UNIX: ~/.mozilla/components
}
nsComponentManager::RegisterComponent(kAllocatorCID, NULL, NULL, XPCOM_DLL,
PR_FALSE, PR_FALSE);
nsComponentManager::RegisterComponent(kProxyObjectManagerCID, NULL, NULL, XPCOM_DLL,
PR_FALSE, PR_FALSE);
}
/***************************************************************************/
/* nsTestXPCFoo */
/***************************************************************************/
class nsTestXPCFoo : public nsITestXPCFoo
class nsTestXPCFoo : public nsITestProxy
{
NS_DECL_ISUPPORTS
NS_IMETHOD Test(PRInt32 p1, PRInt32 p2, PRInt32* retval);
NS_IMETHOD Test2();
NS_IMETHOD Test3(nsISupports *p1, nsISupports **p2);
nsTestXPCFoo();
virtual ~nsTestXPCFoo();
@ -150,13 +85,13 @@ nsTestXPCFoo::~nsTestXPCFoo()
{
}
static NS_DEFINE_IID(kITestXPCFooIID, NS_ITESTXPCFOO_IID);
static NS_DEFINE_IID(kITestXPCFooIID, NS_ITESTPROXY_IID);
NS_IMPL_ISUPPORTS(nsTestXPCFoo,kITestXPCFooIID)
NS_IMETHODIMP nsTestXPCFoo::Test(PRInt32 p1, PRInt32 p2, PRInt32* retval)
{
printf("Thread (%ld) Test Called successfully! Party on...\n", p1);
*retval = 0;
*retval = p1+p2;
return NS_OK;
}
@ -168,16 +103,35 @@ NS_IMETHODIMP nsTestXPCFoo::Test2()
return NS_OK;
}
NS_IMETHODIMP nsTestXPCFoo::Test3(nsISupports *p1, nsISupports **p2)
{
if (p1 != nsnull)
{
nsITestProxy *test;
p1->QueryInterface(nsITestProxy::GetIID(), (void**)&test);
test->Test2();
PRInt32 a;
test->Test( 1, 2, &a);
printf("\n1+2=%d\n",a);
}
*p2 = new nsTestXPCFoo();
return NS_OK;
}
/***************************************************************************/
/* nsTestXPCFoo2 */
/***************************************************************************/
class nsTestXPCFoo2 : public nsITestXPCFoo
class nsTestXPCFoo2 : public nsITestProxy
{
NS_DECL_ISUPPORTS
NS_IMETHOD Test(PRInt32 p1, PRInt32 p2, PRInt32* retval);
NS_IMETHOD Test2();
NS_IMETHOD Test3(nsISupports *p1, nsISupports **p2);
nsTestXPCFoo2();
virtual ~nsTestXPCFoo2();
@ -211,7 +165,11 @@ NS_IMETHODIMP nsTestXPCFoo2::Test2()
}
NS_IMETHODIMP nsTestXPCFoo2::Test3(nsISupports *p1, nsISupports **p2)
{
*p2 = nsnull;
return NS_OK;
}
@ -223,88 +181,79 @@ typedef struct _ArgsStruct
// This will create two objects both descendants of a single IID.
void TestCase_TwoClassesOneInterface(void *arg)
{
ArgsStruct *argsStruct = (ArgsStruct*) arg;
nsIProxyObjectManager* proxyObjectFactory;
nsIProxyObjectManager* manager;
nsComponentManager::CreateInstance(kProxyObjectManagerCID,
nsnull,
nsIProxyObjectManager::GetIID(),
(void**)&proxyObjectFactory);
nsServiceManager::GetService( NS_XPCOMPROXY_PROGID,
kProxyObjectManagerIID,
(nsISupports **)&manager);
printf("ProxyObjectManager: %x ", proxyObjectFactory);
printf("ProxyObjectManager: %x \n", manager);
PR_ASSERT(proxyObjectFactory);
PR_ASSERT(manager);
nsITestXPCFoo *proxyObject;
nsITestXPCFoo *proxyObject2;
nsITestProxy *proxyObject;
nsITestProxy *proxyObject2;
nsTestXPCFoo* foo = new nsTestXPCFoo();
nsTestXPCFoo2* foo2 = new nsTestXPCFoo2();
PR_ASSERT(foo);
PR_ASSERT(foo2);
proxyObjectFactory->GetProxyObject(argsStruct->queue, nsITestXPCFoo::GetIID(), foo, PROXY_SYNC, (void**)&proxyObject);
proxyObjectFactory->GetProxyObject(argsStruct->queue, nsITestXPCFoo::GetIID(), foo2, PROXY_SYNC, (void**)&proxyObject2);
manager->GetProxyObject(argsStruct->queue, nsITestProxy::GetIID(), foo, PROXY_SYNC, (void**)&proxyObject);
manager->GetProxyObject(argsStruct->queue, nsITestProxy::GetIID(), foo2, PROXY_SYNC, (void**)&proxyObject2);
if (proxyObject && proxyObject2)
{
// release ownership of the real object.
//printf("Deleting real Object (%ld)\n", threadNumber);
NS_RELEASE(foo);
//printf("Deleting real Object 2 (%ld)\n", threadNumber);
NS_RELEASE(foo2);
// release ownership of the real object.
PRInt32 a;
nsresult rv;
PRInt32 threadNumber = argsStruct->threadNumber;
printf("Deleting real Object (%ld)\n", threadNumber);
NS_RELEASE(foo);
printf("Deleting real Object 2 (%ld)\n", threadNumber);
NS_RELEASE(foo2);
//printf("Thread (%ld) Prior to calling proxyObject->Test.\n", threadNumber);
printf("Thread (%ld) Prior to calling proxyObject->Test.\n", threadNumber);
rv = proxyObject->Test(threadNumber, 0, &a);
//printf("Thread (%ld) error: %ld.\n", threadNumber, rv);
printf("Thread (%ld) error: %ld.\n", threadNumber, rv);
//printf("Thread (%ld) Prior to calling proxyObject->Test2.\n", threadNumber);
printf("Thread (%ld) Prior to calling proxyObject->Test2.\n", threadNumber);
rv = proxyObject->Test2();
//printf("Thread (%ld) error: %ld.\n", threadNumber, rv);
printf("Thread (%ld) error: %ld.\n", threadNumber, rv);
//printf("Thread (%ld) Prior to calling proxyObject2->Test.\n", threadNumber);
printf("Thread (%ld) Prior to calling proxyObject2->Test.\n", threadNumber);
rv = proxyObject2->Test(threadNumber, 0, &a);
//printf("Thread (%ld) proxyObject2 error: %ld.\n", threadNumber, rv);
printf("Thread (%ld) proxyObject2 error: %ld.\n", threadNumber, rv);
//printf("Thread (%ld) Prior to calling proxyObject2->Test2.\n", threadNumber);
printf("Thread (%ld) Prior to calling proxyObject2->Test2.\n", threadNumber);
rv = proxyObject2->Test2();
//printf("Thread (%ld) proxyObject2 error: %ld.\n", threadNumber, rv);
printf("Thread (%ld) proxyObject2 error: %ld.\n", threadNumber, rv);
//printf("Deleting Proxy Object (%ld)\n", threadNumber );
printf("Deleting Proxy Object (%ld)\n", threadNumber );
NS_RELEASE(proxyObject);
//printf("Deleting Proxy Object 2 (%ld)\n", threadNumber );
printf("Deleting Proxy Object 2 (%ld)\n", threadNumber );
NS_RELEASE(proxyObject2);
}
// PR_Sleep( PR_MillisecondsToInterval(10000) ); // If your thread goes away, your stack goes away. Only use ASYNC on calls that do not have out parameters
PR_Sleep( PR_MillisecondsToInterval(1000) ); // If your thread goes away, your stack goes away. Only use ASYNC on calls that do not have out parameters
}
@ -317,31 +266,65 @@ void TestCase_2(void *arg)
ArgsStruct *argsStruct = (ArgsStruct*) arg;
nsIProxyObjectManager* proxyObjectFactory;
nsIProxyObjectManager* manager;
nsComponentManager::CreateInstance(kProxyObjectManagerCID,
nsnull,
nsIProxyObjectManager::GetIID(),
(void**)&proxyObjectFactory);
nsServiceManager::GetService( NS_XPCOMPROXY_PROGID,
kProxyObjectManagerIID,
(nsISupports **)&manager);
PR_ASSERT(proxyObjectFactory);
PR_ASSERT(manager);
nsITestXPCFoo *proxyObject;
nsITestProxy *proxyObject;
proxyObjectFactory->GetProxyObject(argsStruct->queue,
nsITestXPCFoo::GetIID(), // should be a cid
nsnull,
nsITestXPCFoo::GetIID(),
PROXY_SYNC,
(void**)&proxyObject);
manager->GetProxyObject(argsStruct->queue,
nsITestProxy::GetIID(), // should be CID!
nsnull,
nsITestProxy::GetIID(),
PROXY_SYNC,
(void**)&proxyObject);
if (proxyObject != nsnull)
{
nsISupports *a;
nsISupports *b;
NS_RELEASE(proxyObject);
}
}
void TestCase_nsISupports(void *arg)
{
ArgsStruct *argsStruct = (ArgsStruct*) arg;
nsIProxyObjectManager* manager;
nsServiceManager::GetService( NS_XPCOMPROXY_PROGID,
kProxyObjectManagerIID,
(nsISupports **)&manager);
PR_ASSERT(manager);
nsITestProxy *proxyObject;
nsTestXPCFoo* foo = new nsTestXPCFoo();
PR_ASSERT(foo);
manager->GetProxyObject(argsStruct->queue, nsITestProxy::GetIID(), foo, PROXY_SYNC, (void**)&proxyObject);
if (proxyObject != nsnull)
{
nsISupports *bISupports = nsnull, *cISupports = nsnull;
proxyObject->Test3(foo, &bISupports);
proxyObject->Test3(bISupports, &cISupports);
nsITestProxy *test;
bISupports->QueryInterface(nsITestProxy::GetIID(), (void**)&test);
test->Test2();
NS_RELEASE(foo);
NS_RELEASE(proxyObject);
}
}
@ -355,18 +338,17 @@ void TestCase_2(void *arg)
static void PR_CALLBACK ProxyTest( void *arg )
{
TestCase_TwoClassesOneInterface(arg);
TestCase_TwoClassesOneInterface(arg);
// TestCase_2(arg);
TestCase_nsISupports(arg);
NS_RELEASE( ((ArgsStruct*) arg)->queue);
free((void*) arg);
}
#include "nsIEventQueueService.h"
static NS_DEFINE_CID(kEventQueueServiceCID, NS_EVENTQUEUESERVICE_CID);
nsIEventQueue *gEventQueue = nsnull;
static void PR_CALLBACK EventLoop( void *arg )
@ -434,7 +416,7 @@ main(int argc, char **argv)
0 );
PR_Sleep(PR_MillisecondsToInterval(1000));
PR_Sleep(PR_MillisecondsToInterval(10000));
NS_ASSERTION(gEventQueue, "no main event queue"); // BAD BAD BAD. EVENT THREAD DID NOT CREATE QUEUE. This may be a timing issue, set the
// sleep about longer, and try again.
@ -459,7 +441,7 @@ main(int argc, char **argv)
printf("\tThread (%ld) spawned\n", spawn);
//PR_Sleep( PR_MillisecondsToInterval(250) );
PR_Sleep( PR_MillisecondsToInterval(250) );
}
printf("All Threads Spawned.\n\n");