NS_GET_IID(). Thanks to patch from pp@ludasdesign.com r=dp@netscape.com
This commit is contained in:
@@ -18,6 +18,7 @@
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Pierre Phaneuf <pp@ludusdesign.com>
|
||||
*/
|
||||
|
||||
|
||||
@@ -442,7 +443,10 @@ void* CompletedEventHandler(PLEvent *self)
|
||||
}
|
||||
|
||||
#ifdef AUTOPROXIFICATION
|
||||
// ssc@netscape.com wishes he could get rid of this instance of |NS_DEFINE_IID|, but |ProxyEventClassIdentity| is not visible from here
|
||||
/* ssc@netscape.com wishes he could get rid of this instance of
|
||||
* |NS_DEFINE_IID|, but |ProxyEventClassIdentity| is not visible from
|
||||
* here.
|
||||
*/
|
||||
static NS_DEFINE_IID(kProxyObject_Identity_Class_IID, NS_PROXYEVENT_IDENTITY_CLASS_IID);
|
||||
|
||||
nsresult
|
||||
@@ -645,7 +649,10 @@ AutoProxyParameterList(PRUint32 methodIndex, nsXPTMethodInfo *methodInfo, nsXPTC
|
||||
nsProxyEventObject* replaceInterface = ((nsProxyEventObject*)params[i].val.p);
|
||||
if (replaceInterface)
|
||||
{
|
||||
// ssc@netscape.com wishes he could get rid of this instance of |NS_DEFINE_IID|, but |ProxyEventClassIdentity| is not visible from here
|
||||
/* ssc@netscape.com wishes he could get rid of this
|
||||
* instance of |NS_DEFINE_IID|, but
|
||||
* |ProxyEventClassIdentity| is not visible from here
|
||||
*/
|
||||
nsISupports *aIdentificationObject;
|
||||
rv = replaceInterface->QueryInterface(kProxyObject_Identity_Class_IID, (void**)&aIdentificationObject);
|
||||
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Pierre Phaneuf <pp@ludusdesign.com>
|
||||
*/
|
||||
|
||||
|
||||
@@ -40,7 +41,7 @@
|
||||
|
||||
static uint32 zero_methods_descriptor;
|
||||
|
||||
|
||||
static NS_DEFINE_IID(kProxyEventClassIID, NS_PROXYEVENT_CLASS_IID);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// nsProxyEventClass
|
||||
@@ -92,7 +93,7 @@ nsProxyEventClass::GetNewOrUsedClass(REFNSIID aIID)
|
||||
nsID* iid;
|
||||
if(NS_SUCCEEDED(oldest->GetIID(&iid)))
|
||||
{
|
||||
isISupportsDescendent = iid->Equals(nsCOMTypeInfo<nsISupports>::GetIID());
|
||||
isISupportsDescendent = iid->Equals(NS_GET_IID(nsISupports));
|
||||
nsAllocator::Free(iid);
|
||||
}
|
||||
|
||||
@@ -230,7 +231,7 @@ nsProxyEventClass::DelegatedQueryInterface(nsProxyEventObject* self,
|
||||
void** aInstancePtr)
|
||||
{
|
||||
|
||||
if(aIID.Equals(ProxyEventClassIdentity::GetIID()))
|
||||
if(aIID.Equals(NS_GET_IID(ProxyEventClassIdentity)))
|
||||
{
|
||||
*aInstancePtr = (void**)self; //todo this should be a static cast
|
||||
NS_ADDREF(self);
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Pierre Phaneuf <pp@ludusdesign.com>
|
||||
*/
|
||||
|
||||
#include "prprf.h"
|
||||
@@ -31,8 +32,8 @@
|
||||
|
||||
#include "nsIInterfaceInfoManager.h"
|
||||
#include "xptcall.h"
|
||||
static NS_DEFINE_IID(kProxyObject_Identity_Class_IID, NS_PROXYEVENT_IDENTITY_CLASS_IID);
|
||||
|
||||
static NS_DEFINE_IID(kProxyObject_Identity_Class_IID, NS_PROXYEVENT_IDENTITY_CLASS_IID);
|
||||
|
||||
#ifdef DEBUG_dougt
|
||||
static PRMonitor* mon = nsnull;
|
||||
@@ -136,7 +137,7 @@ nsProxyEventObject::GetNewOrUsedProxy(nsIEventQueue *destQueue,
|
||||
|
||||
// always find the native root if the |real| object.
|
||||
nsCOMPtr<nsISupports> rootObject;
|
||||
if(NS_FAILED(aObj->QueryInterface(nsCOMTypeInfo<nsISupports>::GetIID(), getter_AddRefs(rootObject))))
|
||||
if(NS_FAILED(aObj->QueryInterface(NS_GET_IID(nsISupports), getter_AddRefs(rootObject))))
|
||||
return nsnull;
|
||||
|
||||
/* get our hash table */
|
||||
@@ -156,7 +157,7 @@ nsProxyEventObject::GetNewOrUsedProxy(nsIEventQueue *destQueue,
|
||||
// this will be our key in the hash table.
|
||||
|
||||
nsCOMPtr<nsISupports> destQRoot;
|
||||
if(NS_FAILED(destQueue->QueryInterface(nsCOMTypeInfo<nsISupports>::GetIID(), (void**)&destQueue)))
|
||||
if(NS_FAILED(destQueue->QueryInterface(NS_GET_IID(nsISupports), (void**)&destQueue)))
|
||||
return nsnull;
|
||||
|
||||
char* rootKeyString = PR_sprintf_append(nsnull, "%p.%p.%d", (PRUint32)rootObject.get(), (PRUint32)destQRoot.get(), proxyType);
|
||||
@@ -205,7 +206,7 @@ nsProxyEventObject::GetNewOrUsedProxy(nsIEventQueue *destQueue,
|
||||
{
|
||||
// just a root proxy
|
||||
nsCOMPtr<nsProxyEventClass> rootClazz = getter_AddRefs ( nsProxyEventClass::GetNewOrUsedClass(
|
||||
nsCOMTypeInfo<nsISupports>::GetIID()) );
|
||||
NS_GET_IID(nsISupports)) );
|
||||
|
||||
if (!rootClazz)
|
||||
{
|
||||
@@ -349,7 +350,7 @@ nsProxyEventObject::Find(REFNSIID aIID)
|
||||
{
|
||||
nsProxyEventObject* cur = (mRoot ? mRoot : this);
|
||||
|
||||
if(aIID.Equals(nsCOMTypeInfo<nsISupports>::GetIID()))
|
||||
if(aIID.Equals(NS_GET_IID(nsISupports)))
|
||||
{
|
||||
return cur;
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Pierre Phaneuf <pp@ludusdesign.com>
|
||||
*/
|
||||
|
||||
#ifndef __nsProxyEventPrivate_h_
|
||||
@@ -54,17 +55,13 @@ class nsProxyEventClass;
|
||||
{ 0xec373590, 0x9164, 0x11d3, \
|
||||
{0x8c, 0x73, 0x00, 0x00, 0x64, 0x65, 0x73, 0x74} }
|
||||
|
||||
static NS_DEFINE_IID(kProxyEventClassIID, NS_PROXYEVENT_CLASS_IID);
|
||||
static NS_DEFINE_IID(kProxyEventObjectIID, NS_PROXYEVENT_OBJECT_IID);
|
||||
|
||||
|
||||
class nsProxyEventClass : public nsISupports
|
||||
{
|
||||
public:
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
|
||||
static const nsIID& GetIID() {static nsIID iid = NS_PROXYEVENT_CLASS_IID; return iid;}
|
||||
NS_DEFINE_STATIC_IID_ACCESSOR(NS_PROXYEVENT_CLASS_IID)
|
||||
static nsProxyEventClass* GetNewOrUsedClass(REFNSIID aIID);
|
||||
|
||||
NS_IMETHOD DelegatedQueryInterface( nsProxyEventObject* self,
|
||||
@@ -96,7 +93,8 @@ class nsProxyEventObject : public nsXPTCStubBase
|
||||
public:
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
static const nsIID& GetIID() {static nsIID iid = NS_PROXYEVENT_OBJECT_IID; return iid;}
|
||||
|
||||
NS_DEFINE_STATIC_IID_ACCESSOR(NS_PROXYEVENT_OBJECT_IID)
|
||||
|
||||
static nsProxyEventObject* GetNewOrUsedProxy(nsIEventQueue *destQueue,
|
||||
PRInt32 proxyType,
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Pierre Phaneuf <pp@ludusdesign.com>
|
||||
*/
|
||||
|
||||
|
||||
@@ -188,7 +189,7 @@ nsProxyObjectManager::GetProxyObject(nsIEventQueue *destQueue,
|
||||
if (ciObject == nsnull)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
nsresult rv = GetProxyObject(destQueue, nsIProxyCreateInstance::GetIID(), ciObject, PROXY_SYNC, (void**)&ciProxy);
|
||||
nsresult rv = GetProxyObject(destQueue, NS_GET_IID(nsIProxyCreateInstance), ciObject, PROXY_SYNC, (void**)&ciProxy);
|
||||
|
||||
if (NS_FAILED(rv))
|
||||
{
|
||||
@@ -321,7 +322,7 @@ NSRegisterSelf(nsISupports* aServMgr, const char *path)
|
||||
|
||||
nsIComponentManager* compMgr;
|
||||
rv = servMgr->GetService(kComponentManagerCID,
|
||||
nsIComponentManager::GetIID(),
|
||||
NS_GET_IID(nsIComponentManager),
|
||||
(nsISupports**)&compMgr);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
@@ -347,7 +348,7 @@ NSUnregisterSelf(nsISupports* aServMgr, const char *path)
|
||||
|
||||
nsIComponentManager* compMgr;
|
||||
rv = servMgr->GetService(kComponentManagerCID,
|
||||
nsIComponentManager::GetIID(),
|
||||
NS_GET_IID(nsIComponentManager),
|
||||
(nsISupports**)&compMgr);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Pierre Phaneuf <pp@ludusdesign.com>
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
@@ -36,7 +37,6 @@
|
||||
#include "nsProxyObjectManager.h"
|
||||
#include "nsIEventQueueService.h"
|
||||
|
||||
static NS_DEFINE_IID(kProxyObjectManagerIID, NS_IPROXYEVENT_MANAGER_IID);
|
||||
static NS_DEFINE_CID(kEventQueueServiceCID, NS_EVENTQUEUESERVICE_CID);
|
||||
|
||||
/***************************************************************************/
|
||||
@@ -72,8 +72,7 @@ nsTestXPCFoo::~nsTestXPCFoo()
|
||||
{
|
||||
}
|
||||
|
||||
static NS_DEFINE_IID(kITestXPCFooIID, NS_ITESTPROXY_IID);
|
||||
NS_IMPL_ISUPPORTS(nsTestXPCFoo,kITestXPCFooIID)
|
||||
NS_IMPL_ISUPPORTS(nsTestXPCFoo, NS_GET_IID(nsITestProxy))
|
||||
|
||||
NS_IMETHODIMP nsTestXPCFoo::Test(PRInt32 p1, PRInt32 p2, PRInt32* retval)
|
||||
{
|
||||
@@ -96,7 +95,7 @@ NS_IMETHODIMP nsTestXPCFoo::Test3(nsISupports *p1, nsISupports **p2)
|
||||
{
|
||||
nsITestProxy *test;
|
||||
|
||||
p1->QueryInterface(nsITestProxy::GetIID(), (void**)&test);
|
||||
p1->QueryInterface(NS_GET_IID(nsITestProxy), (void**)&test);
|
||||
|
||||
test->Test2();
|
||||
PRInt32 a;
|
||||
@@ -133,8 +132,8 @@ nsTestXPCFoo2::nsTestXPCFoo2()
|
||||
nsTestXPCFoo2::~nsTestXPCFoo2()
|
||||
{
|
||||
}
|
||||
//kITestXPCFooIID defined above for nsTestXPCFoo(1)
|
||||
NS_IMPL_ISUPPORTS(nsTestXPCFoo2,kITestXPCFooIID)
|
||||
|
||||
NS_IMPL_ISUPPORTS(nsTestXPCFoo2,NS_GET_IID(nsITestProxy))
|
||||
|
||||
NS_IMETHODIMP nsTestXPCFoo2::Test(PRInt32 p1, PRInt32 p2, PRInt32* retval)
|
||||
{
|
||||
@@ -144,14 +143,14 @@ printf("calling back to caller!\n\n");
|
||||
nsITestProxy * proxyObject;
|
||||
|
||||
nsServiceManager::GetService( NS_XPCOMPROXY_PROGID,
|
||||
kProxyObjectManagerIID,
|
||||
NS_GET_IID(nsIProxyObjectManager),
|
||||
(nsISupports **)&manager);
|
||||
|
||||
printf("ProxyObjectManager: %p \n", manager);
|
||||
|
||||
PR_ASSERT(manager);
|
||||
|
||||
manager->GetProxyObject((nsIEventQueue*)p1, nsITestProxy::GetIID(), this, PROXY_SYNC, (void**)&proxyObject);
|
||||
manager->GetProxyObject((nsIEventQueue*)p1, NS_GET_IID(nsITestProxy), this, PROXY_SYNC, (void**)&proxyObject);
|
||||
proxyObject->Test3(nsnull, nsnull);
|
||||
|
||||
printf("Deleting Proxy Object\n");
|
||||
@@ -194,7 +193,7 @@ void TestCase_TwoClassesOneInterface(void *arg)
|
||||
nsIProxyObjectManager* manager;
|
||||
|
||||
nsServiceManager::GetService( NS_XPCOMPROXY_PROGID,
|
||||
kProxyObjectManagerIID,
|
||||
NS_GET_IID(nsIProxyObjectManager),
|
||||
(nsISupports **)&manager);
|
||||
|
||||
printf("ProxyObjectManager: %p \n", manager);
|
||||
@@ -211,9 +210,9 @@ void TestCase_TwoClassesOneInterface(void *arg)
|
||||
PR_ASSERT(foo2);
|
||||
|
||||
|
||||
manager->GetProxyObject(argsStruct->queue, nsITestProxy::GetIID(), foo, PROXY_SYNC, (void**)&proxyObject);
|
||||
manager->GetProxyObject(argsStruct->queue, NS_GET_IID(nsITestProxy), foo, PROXY_SYNC, (void**)&proxyObject);
|
||||
|
||||
manager->GetProxyObject(argsStruct->queue, nsITestProxy::GetIID(), foo2, PROXY_SYNC, (void**)&proxyObject2);
|
||||
manager->GetProxyObject(argsStruct->queue, NS_GET_IID(nsITestProxy), foo2, PROXY_SYNC, (void**)&proxyObject2);
|
||||
|
||||
|
||||
|
||||
@@ -265,7 +264,7 @@ void TestCase_NestedLoop(void *arg)
|
||||
nsIProxyObjectManager* manager;
|
||||
|
||||
nsServiceManager::GetService( NS_XPCOMPROXY_PROGID,
|
||||
kProxyObjectManagerIID,
|
||||
NS_GET_IID(nsIProxyObjectManager),
|
||||
(nsISupports **)&manager);
|
||||
|
||||
printf("ProxyObjectManager: %d \n", manager);
|
||||
@@ -278,7 +277,7 @@ void TestCase_NestedLoop(void *arg)
|
||||
PR_ASSERT(foo);
|
||||
|
||||
|
||||
manager->GetProxyObject(argsStruct->queue, nsITestProxy::GetIID(), foo, PROXY_SYNC, (void**)&proxyObject);
|
||||
manager->GetProxyObject(argsStruct->queue, NS_GET_IID(nsITestProxy), foo, PROXY_SYNC, (void**)&proxyObject);
|
||||
|
||||
if (proxyObject)
|
||||
{
|
||||
@@ -328,7 +327,7 @@ void TestCase_2(void *arg)
|
||||
nsIProxyObjectManager* manager;
|
||||
|
||||
nsServiceManager::GetService( NS_XPCOMPROXY_PROGID,
|
||||
kProxyObjectManagerIID,
|
||||
NS_GET_IID(nsIProxyObjectManager),
|
||||
(nsISupports **)&manager);
|
||||
|
||||
PR_ASSERT(manager);
|
||||
@@ -336,9 +335,9 @@ void TestCase_2(void *arg)
|
||||
nsITestProxy *proxyObject;
|
||||
|
||||
manager->GetProxyObject(argsStruct->queue,
|
||||
nsITestProxy::GetIID(), // should be CID!
|
||||
NS_GET_IID(nsITestProxy), // should be CID!
|
||||
nsnull,
|
||||
nsITestProxy::GetIID(),
|
||||
NS_GET_IID(nsITestProxy),
|
||||
PROXY_SYNC,
|
||||
(void**)&proxyObject);
|
||||
|
||||
@@ -358,7 +357,7 @@ void TestCase_nsISupports(void *arg)
|
||||
nsIProxyObjectManager* manager;
|
||||
|
||||
nsServiceManager::GetService( NS_XPCOMPROXY_PROGID,
|
||||
kProxyObjectManagerIID,
|
||||
NS_GET_IID(nsIProxyObjectManager),
|
||||
(nsISupports **)&manager);
|
||||
|
||||
PR_ASSERT(manager);
|
||||
@@ -368,7 +367,7 @@ void TestCase_nsISupports(void *arg)
|
||||
|
||||
PR_ASSERT(foo);
|
||||
|
||||
manager->GetProxyObject(argsStruct->queue, nsITestProxy::GetIID(), foo, PROXY_SYNC, (void**)&proxyObject);
|
||||
manager->GetProxyObject(argsStruct->queue, NS_GET_IID(nsITestProxy), foo, PROXY_SYNC, (void**)&proxyObject);
|
||||
|
||||
if (proxyObject != nsnull)
|
||||
{
|
||||
@@ -378,7 +377,7 @@ void TestCase_nsISupports(void *arg)
|
||||
proxyObject->Test3(bISupports, &cISupports);
|
||||
|
||||
nsITestProxy *test;
|
||||
bISupports->QueryInterface(nsITestProxy::GetIID(), (void**)&test);
|
||||
bISupports->QueryInterface(NS_GET_IID(nsITestProxy), (void**)&test);
|
||||
|
||||
test->Test2();
|
||||
|
||||
@@ -426,7 +425,7 @@ static void PR_CALLBACK EventLoop( void *arg )
|
||||
}
|
||||
if (NS_FAILED(rv)) return;
|
||||
|
||||
rv = eventQ->QueryInterface(nsIEventQueue::GetIID(), (void**)&gEventQueue);
|
||||
rv = eventQ->QueryInterface(NS_GET_IID(nsIEventQueue), (void**)&gEventQueue);
|
||||
if (NS_FAILED(rv)) return;
|
||||
|
||||
|
||||
@@ -435,7 +434,7 @@ static void PR_CALLBACK EventLoop( void *arg )
|
||||
nsIProxyObjectManager* manager;
|
||||
|
||||
nsServiceManager::GetService( NS_XPCOMPROXY_PROGID,
|
||||
kProxyObjectManagerIID,
|
||||
NS_GET_IID(nsIProxyObjectManager),
|
||||
(nsISupports **)&manager);
|
||||
|
||||
PR_ASSERT(manager);
|
||||
@@ -445,7 +444,7 @@ static void PR_CALLBACK EventLoop( void *arg )
|
||||
|
||||
PR_ASSERT(foo);
|
||||
|
||||
manager->GetProxyObject(gEventQueue, nsITestProxy::GetIID(), foo, PROXY_SYNC, (void**)&proxyObject);
|
||||
manager->GetProxyObject(gEventQueue, NS_GET_IID(nsITestProxy), foo, PROXY_SYNC, (void**)&proxyObject);
|
||||
|
||||
PRInt32 a;
|
||||
proxyObject->Test(1, 2, &a);
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Pierre Phaneuf <pp@ludusdesign.com>
|
||||
*/
|
||||
|
||||
/* Invoke tests xptcall. */
|
||||
@@ -39,6 +40,7 @@ static void DoMultipleInheritenceTest2();
|
||||
class InvokeTestTargetInterface : public nsISupports
|
||||
{
|
||||
public:
|
||||
NS_DEFINE_STATIC_IID_ACCESSOR(INVOKETESTTARGET_IID)
|
||||
NS_IMETHOD AddTwoInts(PRInt32 p1, PRInt32 p2, PRInt32* retval) = 0;
|
||||
NS_IMETHOD MultTwoInts(PRInt32 p1, PRInt32 p2, PRInt32* retval) = 0;
|
||||
NS_IMETHOD AddTwoLLs(PRInt64 p1, PRInt64 p2, PRInt64* retval) = 0;
|
||||
@@ -73,8 +75,7 @@ public:
|
||||
InvokeTestTarget();
|
||||
};
|
||||
|
||||
static NS_DEFINE_IID(kInvokeTestTargetIID, INVOKETESTTARGET_IID);
|
||||
NS_IMPL_ISUPPORTS(InvokeTestTarget, kInvokeTestTargetIID);
|
||||
NS_IMPL_ISUPPORTS(InvokeTestTarget, NS_GET_IID(InvokeTestTargetInterface));
|
||||
|
||||
InvokeTestTarget::InvokeTestTarget()
|
||||
{
|
||||
@@ -379,6 +380,7 @@ int main()
|
||||
class nsIFoo : public nsISupports
|
||||
{
|
||||
public:
|
||||
NS_DEFINE_STATIC_IID_ACCESSOR(FOO_IID)
|
||||
NS_IMETHOD FooMethod1(PRInt32 i) = 0;
|
||||
NS_IMETHOD FooMethod2(PRInt32 i) = 0;
|
||||
};
|
||||
@@ -386,6 +388,7 @@ public:
|
||||
class nsIBar : public nsISupports
|
||||
{
|
||||
public:
|
||||
NS_DEFINE_STATIC_IID_ACCESSOR(BAR_IID)
|
||||
NS_IMETHOD BarMethod1(PRInt32 i) = 0;
|
||||
NS_IMETHOD BarMethod2(PRInt32 i) = 0;
|
||||
};
|
||||
@@ -499,9 +502,6 @@ char* FooBarImpl::ImplName()
|
||||
return MyName;
|
||||
}
|
||||
|
||||
static NS_DEFINE_IID(kFooIID, FOO_IID);
|
||||
static NS_DEFINE_IID(kBarIID, BAR_IID);
|
||||
|
||||
NS_IMETHODIMP
|
||||
FooBarImpl::QueryInterface(REFNSIID aIID, void** aInstancePtr)
|
||||
{
|
||||
@@ -512,18 +512,18 @@ FooBarImpl::QueryInterface(REFNSIID aIID, void** aInstancePtr)
|
||||
*aInstancePtr = NULL;
|
||||
|
||||
|
||||
if (aIID.Equals(kFooIID)) {
|
||||
if (aIID.Equals(NS_GET_IID(nsIFoo))) {
|
||||
*aInstancePtr = (void*) NS_STATIC_CAST(nsIFoo*,this);
|
||||
NS_ADDREF_THIS();
|
||||
return NS_OK;
|
||||
}
|
||||
if (aIID.Equals(kBarIID)) {
|
||||
if (aIID.Equals(NS_GET_IID(nsIBar))) {
|
||||
*aInstancePtr = (void*) NS_STATIC_CAST(nsIBar*,this);
|
||||
NS_ADDREF_THIS();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
if (aIID.Equals(nsCOMTypeInfo<nsISupports>::GetIID())) {
|
||||
if (aIID.Equals(NS_GET_IID(nsISupports))) {
|
||||
*aInstancePtr = (void*) NS_STATIC_CAST(nsISupports*,
|
||||
NS_STATIC_CAST(nsIFoo*,this));
|
||||
NS_ADDREF_THIS();
|
||||
@@ -548,8 +548,8 @@ static void DoMultipleInheritenceTest()
|
||||
nsXPTCVariant var[1];
|
||||
|
||||
printf("\n");
|
||||
if(NS_SUCCEEDED(impl->QueryInterface(kFooIID, (void**)&foo)) &&
|
||||
NS_SUCCEEDED(impl->QueryInterface(kBarIID, (void**)&bar)))
|
||||
if(NS_SUCCEEDED(impl->QueryInterface(NS_GET_IID(nsIFoo), (void**)&foo)) &&
|
||||
NS_SUCCEEDED(impl->QueryInterface(NS_GET_IID(nsIBar), (void**)&bar)))
|
||||
{
|
||||
printf("impl == %x\n", (int) impl);
|
||||
printf("foo == %x\n", (int) foo);
|
||||
@@ -646,9 +646,6 @@ FooBarImpl2::~FooBarImpl2()
|
||||
{
|
||||
}
|
||||
|
||||
static NS_DEFINE_IID(kFooIID2, FOO_IID);
|
||||
static NS_DEFINE_IID(kBarIID2, BAR_IID);
|
||||
|
||||
NS_IMETHODIMP FooBarImpl2::FooMethod1(PRInt32 i)
|
||||
{
|
||||
printf("\tFooBarImpl2::FooMethod1 called with i == %d, local value = %x\n",
|
||||
@@ -687,18 +684,18 @@ FooBarImpl2::QueryInterface(REFNSIID aIID, void** aInstancePtr)
|
||||
*aInstancePtr = NULL;
|
||||
|
||||
|
||||
if (aIID.Equals(kFooIID2)) {
|
||||
if (aIID.Equals(NS_GET_IID(nsIFoo))) {
|
||||
*aInstancePtr = (void*) NS_STATIC_CAST(nsIFoo2*,this);
|
||||
NS_ADDREF_THIS();
|
||||
return NS_OK;
|
||||
}
|
||||
if (aIID.Equals(kBarIID2)) {
|
||||
if (aIID.Equals(NS_GET_IID(nsIBar))) {
|
||||
*aInstancePtr = (void*) NS_STATIC_CAST(nsIBar2*,this);
|
||||
NS_ADDREF_THIS();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
if (aIID.Equals(nsCOMTypeInfo<nsISupports>::GetIID())) {
|
||||
if (aIID.Equals(NS_GET_IID(nsISupports))) {
|
||||
*aInstancePtr = (void*) NS_STATIC_CAST(nsISupports*,
|
||||
NS_STATIC_CAST(nsIFoo2*,this));
|
||||
NS_ADDREF_THIS();
|
||||
@@ -722,8 +719,8 @@ static void DoMultipleInheritenceTest2()
|
||||
nsXPTCVariant var[1];
|
||||
|
||||
printf("\n");
|
||||
if(NS_SUCCEEDED(impl->QueryInterface(kFooIID2, (void**)&foo)) &&
|
||||
NS_SUCCEEDED(impl->QueryInterface(kBarIID2, (void**)&bar)))
|
||||
if(NS_SUCCEEDED(impl->QueryInterface(NS_GET_IID(nsIFoo), (void**)&foo)) &&
|
||||
NS_SUCCEEDED(impl->QueryInterface(NS_GET_IID(nsIBar), (void**)&bar)))
|
||||
{
|
||||
printf("impl == %x\n", (int) impl);
|
||||
printf("foo == %x\n", (int) foo);
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Pierre Phaneuf <pp@ludusdesign.com>
|
||||
*/
|
||||
|
||||
/* Implementation of nsIInterfaceInfoManager. */
|
||||
@@ -521,7 +522,7 @@ NS_IMETHODIMP convert_interface_record(nsHashKey *key, void *data,
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
rv = iinfo->QueryInterface(nsCOMTypeInfo<nsISupports>::GetIID(),
|
||||
rv = iinfo->QueryInterface(NS_GET_IID(nsISupports),
|
||||
(void **)retval);
|
||||
|
||||
#ifdef DEBUG
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Pierre Phaneuf <pp@ludusdesign.com>
|
||||
*/
|
||||
|
||||
|
||||
@@ -107,7 +108,7 @@ nsSampleImpl::~nsSampleImpl()
|
||||
* Notice that the second parameter to the macro is the static IID accessor
|
||||
* method, and NOT the #defined IID.
|
||||
*/
|
||||
NS_IMPL_ISUPPORTS(nsSampleImpl, nsISample::GetIID());
|
||||
NS_IMPL_ISUPPORTS(nsSampleImpl, NS_GET_IID(nsISample));
|
||||
|
||||
/**
|
||||
* Notice that in the protoype for this function, the NS_IMETHOD macro was
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Pierre Phaneuf <pp@ludusdesign.com>
|
||||
*/
|
||||
|
||||
/*
|
||||
@@ -37,7 +38,7 @@
|
||||
/**
|
||||
* IIDs and CIDs (aka CLSIDs) are 32 digit hexadecimal numbers, called Globally
|
||||
* Unique IDs (GUIDs) as a whole. They should only be generated by a trusted
|
||||
* guid generator. GUID generatoration algorithms rely on parameters such as
|
||||
* guid generator. GUID generation algorithms rely on parameters such as
|
||||
* the MAC address of your NIC, and the date/time of GUID creation to ensure
|
||||
* that no two GUIDs are ever the same. The Windows program 'uuidgen' is one
|
||||
* way to create these numbers. The Unix alternative is probably out there
|
||||
@@ -47,9 +48,9 @@
|
||||
* that will be used later. IID and CID objects are of the same form, so the
|
||||
* distinction between InterfaceID and ClassID is made strictly by what the
|
||||
* ID represents, and not by any binary differences.
|
||||
*
|
||||
* Note: NS_DEFINE_IID is now deprecated by NS_GET_IID.
|
||||
*/
|
||||
static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
|
||||
static NS_DEFINE_IID(kIFactoryIID, NS_IFACTORY_IID);
|
||||
static NS_DEFINE_CID(kComponentManagerCID, NS_COMPONENTMANAGER_CID);
|
||||
static NS_DEFINE_CID(kSampleCID, NS_SAMPLE_CID);
|
||||
|
||||
@@ -144,11 +145,11 @@ SampleFactoryImpl::QueryInterface(const nsIID &aIID, void **aResult)
|
||||
// Always NULL result, in case of failure
|
||||
*aResult = nsnull;
|
||||
|
||||
if (aIID.Equals(kISupportsIID)) {
|
||||
if (aIID.Equals(NS_GET_IID(nsISupports))) {
|
||||
*aResult = NS_STATIC_CAST(nsISupports*, this);
|
||||
AddRef();
|
||||
return NS_OK;
|
||||
} else if (aIID.Equals(kIFactoryIID)) {
|
||||
} else if (aIID.Equals(NS_GET_IID(nsIFactory))) {
|
||||
*aResult = NS_STATIC_CAST(nsIFactory*, this);
|
||||
AddRef();
|
||||
return NS_OK;
|
||||
|
||||
@@ -30,10 +30,10 @@ DIRS = dynamic services
|
||||
|
||||
TESTS_NOT_COMPILING = \
|
||||
TestArray.cpp \
|
||||
TestServMgr.cpp \
|
||||
$(NULL)
|
||||
|
||||
CPPSRCS = \
|
||||
TestServMgr.cpp \
|
||||
TestFactory.cpp \
|
||||
TestCOMPtr.cpp \
|
||||
TestID.cpp \
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Pierre Phaneuf <pp@ludusdesign.com>
|
||||
*/
|
||||
|
||||
#define NS_IMPL_IDS
|
||||
@@ -56,12 +57,9 @@ static NS_DEFINE_CID(kIOServiceCID, NS_IOSERVICE_CID);
|
||||
#define XPCOM_DLL "libxpcom"MOZ_DLL_SUFFIX
|
||||
#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(kIPersistentPropertiesIID, NS_IPERSISTENTPROPERTIES_IID);
|
||||
|
||||
|
||||
static NS_DEFINE_CID(kEventQueueCID, NS_EVENTQUEUE_CID);
|
||||
static NS_DEFINE_CID(kEventQueueServiceCID, NS_EVENTQUEUESERVICE_CID);
|
||||
|
||||
/***************************************************************************/
|
||||
extern "C" void
|
||||
@@ -79,7 +77,7 @@ NS_SetupRegistry()
|
||||
|
||||
pEventQService = nsnull;
|
||||
nsresult result = nsServiceManager::GetService(kEventQueueServiceCID,
|
||||
kIEventQueueServiceIID,
|
||||
NS_GET_IID(nsIEventQueueService),
|
||||
(nsISupports **)&pEventQService);
|
||||
if (NS_SUCCEEDED(result)) {
|
||||
// XXX: What if this fails?
|
||||
@@ -125,7 +123,7 @@ main(int argc, char* argv[])
|
||||
|
||||
nsIPersistentProperties* props = nsnull;
|
||||
ret = nsComponentManager::CreateInstance(kPersistentPropertiesCID, NULL,
|
||||
kIPersistentPropertiesIID, (void**) &props);
|
||||
NS_GET_IID(nsIPersistentProperties), (void**) &props);
|
||||
if (NS_FAILED(ret) || (!props)) {
|
||||
printf("create nsIPersistentProperties failed\n");
|
||||
return 1;
|
||||
|
||||
@@ -48,10 +48,6 @@ NS_DEF_PTR(nsIDOMNode);
|
||||
|
||||
On Macintosh, both nsCOMPtr and nsIPtr generate out-of-line destructors which are
|
||||
not referenced, and which can be stripped by the linker.
|
||||
|
||||
Also note that on all platforms, each use of the |NS_DEFINE_IID| macro adds 16 bytes of static
|
||||
data per file, while GetIID() has the same code profile and adds only 16 bytes of data to the entire
|
||||
program, reguardless of the number of uses (greater than one).
|
||||
*/
|
||||
|
||||
void
|
||||
|
||||
@@ -8,7 +8,6 @@
|
||||
#pragma exceptions off
|
||||
#endif
|
||||
|
||||
static NS_DEFINE_IID(kIDOMNodeIID, NS_IDOMNODE_IID);
|
||||
NS_DEF_PTR(nsIDOMNode);
|
||||
|
||||
/*
|
||||
@@ -54,7 +53,7 @@ Test02_Raw00( nsISupports* aDOMNode, nsString* aResult )
|
||||
// return NS_ERROR_NULL_POINTER;
|
||||
|
||||
nsIDOMNode* node = 0;
|
||||
nsresult status = aDOMNode->QueryInterface(kIDOMNodeIID, (void**)&node);
|
||||
nsresult status = aDOMNode->QueryInterface(NS_GET_IID(nsIDOMNode), (void**)&node);
|
||||
if ( NS_SUCCEEDED(status) )
|
||||
{
|
||||
node->GetNodeName(*aResult);
|
||||
@@ -73,7 +72,7 @@ Test02_Raw01( nsISupports* aDOMNode, nsString* aResult )
|
||||
// return NS_ERROR_NULL_POINTER;
|
||||
|
||||
nsIDOMNode* node;
|
||||
nsresult status = aDOMNode->QueryInterface(kIDOMNodeIID, (void**)&node);
|
||||
nsresult status = aDOMNode->QueryInterface(NS_GET_IID(nsIDOMNode(, (void**)&node);
|
||||
if ( NS_SUCCEEDED(status) )
|
||||
{
|
||||
node->GetNodeName(*aResult);
|
||||
@@ -104,7 +103,7 @@ Test02_nsIPtr( nsISupports* aDOMNode, nsString* aResult )
|
||||
// return NS_ERROR_NULL_POINTER;
|
||||
|
||||
nsIDOMNodePtr node;
|
||||
nsresult status = aDOMNode->QueryInterface(kIDOMNodeIID, node.Query());
|
||||
nsresult status = aDOMNode->QueryInterface(NS_GET_IID(nsIDOMNode), node.Query());
|
||||
|
||||
if ( NS_SUCCEEDED(status) )
|
||||
node->GetNodeName(*aResult);
|
||||
|
||||
@@ -7,9 +7,6 @@
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsIPtr.h"
|
||||
|
||||
static NS_DEFINE_IID(kIScriptGlobalObjectIID, NS_ISCRIPTGLOBALOBJECT_IID);
|
||||
static NS_DEFINE_IID(kIWebShellWindowIID, NS_IWEBSHELL_WINDOW_IID);
|
||||
|
||||
NS_DEF_PTR(nsIScriptGlobalObject);
|
||||
NS_DEF_PTR(nsIWebShell);
|
||||
NS_DEF_PTR(nsIWebShellContainer);
|
||||
@@ -52,7 +49,7 @@ Test06_raw( nsIDOMWindow* aDOMWindow, nsIWebShellWindow** aWebShellWindow )
|
||||
// return NS_ERROR_NULL_POINTER;
|
||||
|
||||
nsIScriptGlobalObject* scriptGlobalObject = 0;
|
||||
nsresult status = aDOMWindow->QueryInterface(kIScriptGlobalObjectIID, (void**)&scriptGlobalObject);
|
||||
nsresult status = aDOMWindow->QueryInterface(NS_GET_IID(nsIScriptGlobalObject), (void**)&scriptGlobalObject);
|
||||
|
||||
nsIWebShell* webShell = 0;
|
||||
if ( scriptGlobalObject )
|
||||
@@ -67,7 +64,7 @@ Test06_raw( nsIDOMWindow* aDOMWindow, nsIWebShellWindow** aWebShellWindow )
|
||||
status = rootWebShell->GetContainer(webShellContainer);
|
||||
|
||||
if ( webShellContainer )
|
||||
status = webShellContainer->QueryInterface(kIWebShellWindowIID, (void**)aWebShellWindow);
|
||||
status = webShellContainer->QueryInterface(NS_GET_IID(nsIWebShellWindow), (void**)aWebShellWindow);
|
||||
else
|
||||
(*aWebShellWindow) = 0;
|
||||
|
||||
@@ -90,7 +87,7 @@ Test06_raw_optimized( nsIDOMWindow* aDOMWindow, nsIWebShellWindow** aWebShellWin
|
||||
(*aWebShellWindow) = 0;
|
||||
|
||||
nsIScriptGlobalObject* scriptGlobalObject;
|
||||
nsresult status = aDOMWindow->QueryInterface(kIScriptGlobalObjectIID, (void**)&scriptGlobalObject);
|
||||
nsresult status = aDOMWindow->QueryInterface(NS_GET_IID(nsIScriptGlobalObject), (void**)&scriptGlobalObject);
|
||||
if ( NS_SUCCEEDED(status) )
|
||||
{
|
||||
nsIWebShell* webShell;
|
||||
@@ -105,7 +102,7 @@ Test06_raw_optimized( nsIDOMWindow* aDOMWindow, nsIWebShellWindow** aWebShellWin
|
||||
status = rootWebShell->GetContainer(webShellContainer);
|
||||
if ( NS_SUCCEEDED(status) )
|
||||
{
|
||||
status = webShellContainer->QueryInterface(kIWebShellWindowIID, (void**)aWebShellWindow);
|
||||
status = webShellContainer->QueryInterface(NS_GET_IID(nsIWebShellWindow), (void**)aWebShellWindow);
|
||||
NS_RELEASE(webShellContainer);
|
||||
}
|
||||
|
||||
@@ -171,7 +168,7 @@ Test06_nsCOMPtr00( nsIDOMWindow* aDOMWindow, nsIWebShellWindow** aWebShellWindow
|
||||
nsCOMPtr<nsIWebShellContainer> webShellContainer = dont_AddRef(temp2);
|
||||
|
||||
if ( webShellContainer )
|
||||
status = webShellContainer->QueryInterface(nsIWebShellWindow::GetIID(), (void**)aWebShellWindow);
|
||||
status = webShellContainer->QueryInterface(NS_GET_IID(nsIWebShellWindow), (void**)aWebShellWindow);
|
||||
else
|
||||
(*aWebShellWindow) = 0;
|
||||
|
||||
@@ -236,7 +233,7 @@ Test06_nsCOMPtr02( nsIDOMWindow* aDOMWindow, nsIWebShellWindow** aWebShellWindow
|
||||
nsCOMPtr<nsIWebShellContainer> webShellContainer = dont_AddRef(temp1);
|
||||
|
||||
if ( webShellContainer )
|
||||
status = webShellContainer->QueryInterface(nsIWebShellWindow::GetIID(), (void**)aWebShellWindow);
|
||||
status = webShellContainer->QueryInterface(NS_GET_IID(nsIWebShellWindow), (void**)aWebShellWindow);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -287,7 +284,7 @@ Test06_nsIPtr( nsIDOMWindow* aDOMWindow, nsIWebShellWindow** aWebShellWindow )
|
||||
// return NS_ERROR_NULL_POINTER;
|
||||
|
||||
nsIScriptGlobalObjectPtr scriptGlobalObject;
|
||||
nsresult status = aDOMWindow->QueryInterface(kIScriptGlobalObjectIID, scriptGlobalObject.Query());
|
||||
nsresult status = aDOMWindow->QueryInterface(NS_GET_IID(nsIScriptGlobalObject), scriptGlobalObject.Query());
|
||||
|
||||
nsIWebShellPtr webShell;
|
||||
if ( scriptGlobalObject.IsNotNull() )
|
||||
@@ -302,7 +299,7 @@ Test06_nsIPtr( nsIDOMWindow* aDOMWindow, nsIWebShellWindow** aWebShellWindow )
|
||||
status = rootWebShell->GetContainer( webShellContainer.AssignRef() );
|
||||
|
||||
if ( webShellContainer.IsNotNull() )
|
||||
status = webShellContainer->QueryInterface(kIWebShellWindowIID, (void**)aWebShellWindow);
|
||||
status = webShellContainer->QueryInterface(NS_GET_IID(nsIWebShellWindow), (void**)aWebShellWindow);
|
||||
else
|
||||
(*aWebShellWindow) = 0;
|
||||
|
||||
@@ -317,7 +314,7 @@ Test06_nsIPtr_optimized( nsIDOMWindow* aDOMWindow, nsIWebShellWindow** aWebShell
|
||||
// return NS_ERROR_NULL_POINTER;
|
||||
|
||||
nsIScriptGlobalObject* temp0;
|
||||
nsresult status = aDOMWindow->QueryInterface(kIScriptGlobalObjectIID, (void**)&temp0);
|
||||
nsresult status = aDOMWindow->QueryInterface(NS_GET_IID(nsIScriptGlobalObject), (void**)&temp0);
|
||||
nsIScriptGlobalObjectPtr scriptGlobalObject = temp0;
|
||||
|
||||
nsIWebShell* temp1 = 0;
|
||||
@@ -336,7 +333,7 @@ Test06_nsIPtr_optimized( nsIDOMWindow* aDOMWindow, nsIWebShellWindow** aWebShell
|
||||
nsIWebShellContainerPtr webShellContainer = temp3;
|
||||
|
||||
if ( webShellContainer.IsNotNull() )
|
||||
status = webShellContainer->QueryInterface(kIWebShellWindowIID, (void**)aWebShellWindow);
|
||||
status = webShellContainer->QueryInterface(NS_GET_IID(nsIWebShellWindow), (void**)aWebShellWindow);
|
||||
else
|
||||
(*aWebShellWindow) = 0;
|
||||
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Pierre Phaneuf <pp@ludusdesign.com>
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
@@ -31,8 +32,6 @@
|
||||
|
||||
static const PRBool kExitOnError = PR_TRUE;
|
||||
|
||||
static NS_DEFINE_IID(kIFooIID, NS_IFOO_IID);
|
||||
|
||||
class IFoo : public nsISupports {
|
||||
public:
|
||||
IFoo(PRInt32 aID);
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Pierre Phaneuf <pp@ludusdesign.com>
|
||||
*/
|
||||
|
||||
#include "nsIBuffer.h"
|
||||
@@ -99,7 +100,7 @@ protected:
|
||||
PRBool mDone;
|
||||
};
|
||||
|
||||
NS_IMPL_ISUPPORTS(Reader, nsIRunnable::GetIID());
|
||||
NS_IMPL_ISUPPORTS(Reader, NS_GET_IID(nsIRunnable));
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Pierre Phaneuf <pp@ludusdesign.com>
|
||||
*/
|
||||
|
||||
#include <iostream.h>
|
||||
@@ -248,7 +249,7 @@ IBar::QueryInterface( const nsID& aIID, void** aResult )
|
||||
|
||||
if ( aIID.Equals(GetIID()) )
|
||||
rawPtr = this;
|
||||
else if ( aIID.Equals(IFoo::GetIID()) )
|
||||
else if ( aIID.Equals(NS_GET_IID(IFoo)) )
|
||||
rawPtr = STATIC_CAST(IFoo*, this);
|
||||
else
|
||||
{
|
||||
@@ -321,7 +322,7 @@ TestBloat_Raw()
|
||||
try
|
||||
{
|
||||
IFoo* fooP = 0;
|
||||
if ( NS_SUCCEEDED( result = barP->QueryInterface(IFoo::GetIID(), REINTERPRET_CAST(void**, &fooP)) ) )
|
||||
if ( NS_SUCCEEDED( result = barP->QueryInterface(NS_GET_IID(IFoo), REINTERPRET_CAST(void**, &fooP)) ) )
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -359,7 +360,7 @@ TestBloat_Raw_Unsafe()
|
||||
if ( barP )
|
||||
{
|
||||
IFoo* fooP = 0;
|
||||
if ( NS_SUCCEEDED( result = barP->QueryInterface(IFoo::GetIID(), REINTERPRET_CAST(void**, &fooP)) ) )
|
||||
if ( NS_SUCCEEDED( result = barP->QueryInterface(NS_GET_IID(IFoo), REINTERPRET_CAST(void**, &fooP)) ) )
|
||||
{
|
||||
fooP->print_totals();
|
||||
NS_RELEASE(fooP);
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Pierre Phaneuf <pp@ludusdesign.com>
|
||||
*/
|
||||
|
||||
#include <iostream.h>
|
||||
@@ -26,10 +27,8 @@
|
||||
#include "nsIComponentManager.h"
|
||||
#include "nsIServiceManager.h"
|
||||
|
||||
NS_DEFINE_IID(kFactoryIID, NS_IFACTORY_IID);
|
||||
NS_DEFINE_CID(kTestFactoryCID, NS_TESTFACTORY_CID);
|
||||
NS_DEFINE_CID(kTestLoadedFactoryCID, NS_TESTLOADEDFACTORY_CID);
|
||||
NS_DEFINE_IID(kTestClassIID, NS_ITESTCLASS_IID);
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
nsresult rv;
|
||||
@@ -43,7 +42,7 @@ int main(int argc, char **argv) {
|
||||
ITestClass *t = NULL;
|
||||
nsComponentManager::CreateInstance(kTestFactoryCID,
|
||||
NULL,
|
||||
kTestClassIID,
|
||||
NS_GET_IID(ITestClass),
|
||||
(void **) &t);
|
||||
|
||||
if (t != NULL) {
|
||||
@@ -57,7 +56,7 @@ int main(int argc, char **argv) {
|
||||
|
||||
nsComponentManager::CreateInstance(kTestLoadedFactoryCID,
|
||||
NULL,
|
||||
kTestClassIID,
|
||||
NS_GET_IID(ITestClass),
|
||||
(void **) &t);
|
||||
|
||||
if (t != NULL) {
|
||||
@@ -86,7 +85,7 @@ public:
|
||||
void Test();
|
||||
};
|
||||
|
||||
NS_IMPL_ISUPPORTS(TestClassImpl, kTestClassIID);
|
||||
NS_IMPL_ISUPPORTS(TestClassImpl, NS_GET_IID(ITestClass));
|
||||
|
||||
void TestClassImpl::Test() {
|
||||
cout << "hello, world!\n";
|
||||
@@ -111,7 +110,7 @@ public:
|
||||
NS_IMETHOD LockFactory(PRBool aLock) { return NS_OK; }
|
||||
};
|
||||
|
||||
NS_IMPL_ISUPPORTS(TestFactory, kFactoryIID);
|
||||
NS_IMPL_ISUPPORTS(TestFactory, NS_GET_IID(nsIFactory));
|
||||
|
||||
nsresult TestFactory::CreateInstance(nsISupports *aDelegate,
|
||||
const nsIID &aIID,
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Pierre Phaneuf <pp@ludusdesign.com>
|
||||
*/
|
||||
|
||||
#ifndef __TestFactory_h
|
||||
@@ -42,6 +43,7 @@
|
||||
|
||||
class ITestClass: public nsISupports {
|
||||
public:
|
||||
NS_DEFINE_STATIC_IID_ACCESSOR(NS_ITESTCLASS_IID)
|
||||
virtual void Test() = 0;
|
||||
};
|
||||
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Pierre Phaneuf <pp@ludusdesign.com>
|
||||
*/
|
||||
|
||||
#define NS_IMPL_IDS
|
||||
@@ -59,7 +60,7 @@ public:
|
||||
nsString mName;
|
||||
};
|
||||
|
||||
NS_IMPL_ISUPPORTS( TestObserver, nsIObserver::GetIID() );
|
||||
NS_IMPL_ISUPPORTS( TestObserver, NS_GET_IID(nsIObserver) );
|
||||
|
||||
NS_IMETHODIMP
|
||||
TestObserver::Observe( nsISupports *aSubject,
|
||||
@@ -82,7 +83,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
nsresult res = nsComponentManager::CreateInstance(NS_OBSERVERSERVICE_PROGID,
|
||||
NULL,
|
||||
nsIObserverService::GetIID(),
|
||||
NS_GET_IID(nsIObserverService),
|
||||
(void **) &anObserverService);
|
||||
|
||||
if (res == NS_OK) {
|
||||
@@ -129,7 +130,7 @@ int main(int argc, char *argv[])
|
||||
for (e->First(); e->IsDone() != NS_OK; e->Next()) {
|
||||
rv = e->CurrentItem(&inst);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
rv = inst->QueryInterface(nsIObserver::GetIID(),(void**)&anObserver);
|
||||
rv = inst->QueryInterface(NS_GET_IID(nsIObserver),(void**)&anObserver);
|
||||
cout << "Calling observe on enumerated observer "
|
||||
<< ((TestObserver*)inst)->mName << "..." << endl;
|
||||
rv = anObserver->Observe( inst, topicA.GetUnicode(), nsString("during enumeration").GetUnicode() );
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Pierre Phaneuf <pp@ludusdesign.com>
|
||||
*/
|
||||
|
||||
#include "nsIThread.h"
|
||||
@@ -97,7 +98,7 @@ protected:
|
||||
PRUint32 mCount;
|
||||
};
|
||||
|
||||
NS_IMPL_ISUPPORTS(nsReceiver, nsIRunnable::GetIID());
|
||||
NS_IMPL_ISUPPORTS(nsReceiver, NS_GET_IID(nsIRunnable));
|
||||
|
||||
nsresult
|
||||
TestPipe(nsIInputStream* in, nsIOutputStream* out)
|
||||
@@ -207,7 +208,7 @@ protected:
|
||||
PRUint32 mReceived;
|
||||
};
|
||||
|
||||
NS_IMPL_ISUPPORTS(nsShortReader, nsIRunnable::GetIID());
|
||||
NS_IMPL_ISUPPORTS(nsShortReader, NS_GET_IID(nsIRunnable));
|
||||
|
||||
nsresult
|
||||
TestShortWrites(nsIInputStream* in, nsIOutputStream* out)
|
||||
@@ -277,7 +278,7 @@ public:
|
||||
virtual ~nsPipeObserver() {}
|
||||
};
|
||||
|
||||
NS_IMPL_ISUPPORTS(nsPipeObserver, nsIPipeObserver::GetIID());
|
||||
NS_IMPL_ISUPPORTS(nsPipeObserver, NS_GET_IID(nsIPipeObserver));
|
||||
|
||||
nsresult
|
||||
TestPipeObserver()
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Pierre Phaneuf <pp@ludusdesign.com>
|
||||
*/
|
||||
|
||||
#include "MyService.h"
|
||||
@@ -25,8 +26,7 @@
|
||||
#include "nsIComponentManager.h"
|
||||
#include <stdio.h>
|
||||
|
||||
static NS_DEFINE_IID(kIMyServiceCID, NS_IMYSERVICE_CID);
|
||||
static NS_DEFINE_IID(kIMyServiceIID, NS_IMYSERVICE_IID);
|
||||
static NS_DEFINE_CID(kIMyServiceCID, NS_IMYSERVICE_CID);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@@ -37,7 +37,7 @@ BeginTest(int testNumber)
|
||||
{
|
||||
nsresult err;
|
||||
NS_ASSERTION(myServ == NULL, "myServ not reset");
|
||||
err = nsServiceManager::GetService(kIMyServiceCID, kIMyServiceIID,
|
||||
err = nsServiceManager::GetService(kIMyServiceCID, NS_GET_IID(IMyService),
|
||||
(nsISupports**)&myServ);
|
||||
return err;
|
||||
}
|
||||
@@ -113,7 +113,7 @@ AsyncNoShutdownTest(int testNumber)
|
||||
// Create some other user of kIMyServiceCID, preventing it from
|
||||
// really going away:
|
||||
IMyService* otherClient;
|
||||
err = nsServiceManager::GetService(kIMyServiceCID, kIMyServiceIID,
|
||||
err = nsServiceManager::GetService(kIMyServiceCID, NS_GET_IID(IMyService),
|
||||
(nsISupports**)&otherClient);
|
||||
if (err != NS_OK) return err;
|
||||
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Pierre Phaneuf <pp@ludusdesign.com>
|
||||
*/
|
||||
|
||||
#include "nsIServiceManager.h"
|
||||
@@ -39,13 +40,13 @@ void main(int argc, char* argv[])
|
||||
nsCID cid;
|
||||
cid.Parse(cidStr);
|
||||
rv = nsComponentManager::CreateInstance(cid, nsnull,
|
||||
nsCOMTypeInfo<nsISupports>::GetIID(),
|
||||
NS_GET_IID(nsISupports),
|
||||
(void**)&obj);
|
||||
}
|
||||
else {
|
||||
// progID case:
|
||||
rv = nsComponentManager::CreateInstance(cidStr, nsnull,
|
||||
nsCOMTypeInfo<nsISupports>::GetIID(),
|
||||
NS_GET_IID(nsISupports),
|
||||
(void**)&obj);
|
||||
}
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Pierre Phaneuf <pp@ludusdesign.com>
|
||||
*/
|
||||
|
||||
#include "nsIThread.h"
|
||||
@@ -54,7 +55,7 @@ protected:
|
||||
int mNum;
|
||||
};
|
||||
|
||||
NS_IMPL_ISUPPORTS(nsRunner, nsIRunnable::GetIID());
|
||||
NS_IMPL_ISUPPORTS(nsRunner, NS_GET_IID(nsIRunnable));
|
||||
|
||||
nsresult
|
||||
TestThreads()
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Pierre Phaneuf <pp@ludusdesign.com>
|
||||
*/
|
||||
|
||||
#include <iostream.h>
|
||||
@@ -31,9 +32,7 @@
|
||||
|
||||
static NS_DEFINE_CID(kComponentManagerCID, NS_COMPONENTMANAGER_CID);
|
||||
|
||||
NS_DEFINE_IID(kFactoryIID, NS_IFACTORY_IID);
|
||||
NS_DEFINE_CID(kTestLoadedFactoryCID, NS_TESTLOADEDFACTORY_CID);
|
||||
NS_DEFINE_IID(kTestClassIID, NS_ITESTCLASS_IID);
|
||||
|
||||
/**
|
||||
* ITestClass implementation
|
||||
@@ -48,7 +47,7 @@ class TestDynamicClassImpl: public ITestClass {
|
||||
void Test();
|
||||
};
|
||||
|
||||
NS_IMPL_ISUPPORTS(TestDynamicClassImpl, kTestClassIID);
|
||||
NS_IMPL_ISUPPORTS(TestDynamicClassImpl, NS_GET_IID(ITestClass));
|
||||
|
||||
void TestDynamicClassImpl::Test() {
|
||||
cout << "hello, dynamic world!\n";
|
||||
@@ -87,7 +86,7 @@ class TestDynamicFactory: public nsIFactory {
|
||||
};
|
||||
};
|
||||
|
||||
NS_IMPL_ISUPPORTS(TestDynamicFactory, kFactoryIID);
|
||||
NS_IMPL_ISUPPORTS(TestDynamicFactory, NS_GET_IID(nsIFactory));
|
||||
|
||||
nsresult TestDynamicFactory::CreateInstance(nsISupports *aDelegate,
|
||||
const nsIID &aIID,
|
||||
@@ -124,7 +123,7 @@ extern "C" NS_EXPORT nsresult NSGetFactory(nsISupports* aServMgr,
|
||||
}
|
||||
if (aClass.Equals(kTestLoadedFactoryCID)) {
|
||||
TestDynamicFactory *factory = new TestDynamicFactory();
|
||||
nsresult res = factory->QueryInterface(kFactoryIID, (void **) aFactory);
|
||||
nsresult res = factory->QueryInterface(NS_GET_IID(nsIFactory), (void **) aFactory);
|
||||
if (NS_FAILED(res)) {
|
||||
*aFactory = NULL;
|
||||
delete factory;
|
||||
@@ -147,7 +146,7 @@ extern "C" NS_EXPORT nsresult NSRegisterSelf(nsISupports* aServMgr , const char
|
||||
|
||||
nsIComponentManager* compMgr;
|
||||
rv = servMgr->GetService(kComponentManagerCID,
|
||||
nsIComponentManager::GetIID(),
|
||||
NS_GET_IID(nsIComponentManager),
|
||||
(nsISupports**)&compMgr);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
@@ -167,7 +166,7 @@ extern "C" NS_EXPORT nsresult NSUnregisterSelf(nsISupports* aServMgr, const char
|
||||
|
||||
nsIComponentManager* compMgr;
|
||||
rv = servMgr->GetService(kComponentManagerCID,
|
||||
nsIComponentManager::GetIID(),
|
||||
NS_GET_IID(nsIComponentManager),
|
||||
(nsISupports**)&compMgr);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Pierre Phaneuf <pp@ludusdesign.com>
|
||||
*/
|
||||
|
||||
#include "MyService.h"
|
||||
@@ -74,9 +75,7 @@ MyServiceFactory* gFact = NULL;
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// MyService Implementation
|
||||
|
||||
static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
|
||||
static NS_DEFINE_IID(kIMyServiceIID, NS_IMYSERVICE_IID);
|
||||
NS_IMPL_ISUPPORTS(MyService, kIMyServiceIID);
|
||||
NS_IMPL_ISUPPORTS(MyService, NS_GET_IID(IMyService));
|
||||
|
||||
MyService::MyService(nsISupports* outer)
|
||||
{
|
||||
@@ -103,8 +102,7 @@ MyService::Doit(void)
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// MyServiceFactory Implementation
|
||||
|
||||
static NS_DEFINE_IID(kIFactoryIID, NS_IFACTORY_IID);
|
||||
NS_IMPL_ISUPPORTS(MyServiceFactory, kIFactoryIID);
|
||||
NS_IMPL_ISUPPORTS(MyServiceFactory, NS_GET_IID(nsIFactory));
|
||||
|
||||
MyServiceFactory::MyServiceFactory(void)
|
||||
: mStarted(PR_FALSE), mOutstandingInstances(0)
|
||||
@@ -138,7 +136,7 @@ MyServiceFactory::LockFactory(PRBool aLock)
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// DLL Entry Points:
|
||||
|
||||
static NS_DEFINE_IID(kIMyServiceCID, NS_IMYSERVICE_CID);
|
||||
static NS_DEFINE_CID(kIMyServiceCID, NS_IMYSERVICE_CID);
|
||||
|
||||
extern "C" NS_EXPORT nsresult
|
||||
NSGetFactory(nsISupports* serviceMgr,
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Pierre Phaneuf <pp@ludusdesign.com>
|
||||
*/
|
||||
|
||||
#ifndef MyService_h__
|
||||
@@ -25,14 +26,6 @@
|
||||
|
||||
#include "nsISupports.h"
|
||||
|
||||
class IMyService : public nsISupports {
|
||||
public:
|
||||
|
||||
NS_IMETHOD
|
||||
Doit(void) = 0;
|
||||
|
||||
};
|
||||
|
||||
#define NS_IMYSERVICE_IID \
|
||||
{ /* fedc3380-3648-11d2-8163-006008119d7a */ \
|
||||
0xfedc3380, \
|
||||
@@ -41,6 +34,15 @@ public:
|
||||
{0x81, 0x63, 0x00, 0x60, 0x08, 0x11, 0x9d, 0x7a} \
|
||||
}
|
||||
|
||||
class IMyService : public nsISupports {
|
||||
public:
|
||||
NS_DEFINE_STATIC_IID_ACCESSOR(NS_IMYSERVICE_IID)
|
||||
|
||||
NS_IMETHOD
|
||||
Doit(void) = 0;
|
||||
|
||||
};
|
||||
|
||||
#define NS_IMYSERVICE_CID \
|
||||
{ /* 34876550-364b-11d2-8163-006008119d7a */ \
|
||||
0x34876550, \
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Pierre Phaneuf <pp@ludusdesign.com>
|
||||
*/
|
||||
|
||||
#include <windows.h>
|
||||
@@ -33,13 +34,10 @@
|
||||
class nsITestCom: public nsISupports
|
||||
{
|
||||
public:
|
||||
NS_DEFINE_STATIC_IID_ACCESSOR(NS_ITEST_COM_IID)
|
||||
NS_IMETHOD Test() = 0;
|
||||
};
|
||||
|
||||
static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
|
||||
static NS_DEFINE_IID(kIFactoryIID, NS_IFACTORY_IID);
|
||||
static NS_DEFINE_IID(kITestComIID, NS_ITEST_COM_IID);
|
||||
|
||||
/*
|
||||
* nsTestCom
|
||||
*/
|
||||
@@ -61,7 +59,7 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
NS_IMPL_QUERY_INTERFACE(nsTestCom, kITestComIID);
|
||||
NS_IMPL_QUERY_INTERFACE(nsTestCom, NS_GET_IID(nsITestCom));
|
||||
|
||||
nsrefcnt nsTestCom::AddRef()
|
||||
{
|
||||
@@ -101,7 +99,7 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
NS_IMPL_ISUPPORTS(nsTestComFactory, kIFactoryIID);
|
||||
NS_IMPL_ISUPPORTS(nsTestComFactory, NS_GET_IID(nsIFactory));
|
||||
|
||||
nsresult nsTestComFactory::CreateInstance(nsISupports *aOuter,
|
||||
const nsIID &aIID,
|
||||
@@ -137,7 +135,7 @@ int main(int argc, char *argv[])
|
||||
{
|
||||
nsTestComFactory *inst = new nsTestComFactory();
|
||||
IClassFactory *iFactory;
|
||||
inst->QueryInterface(kIFactoryIID, (void **) &iFactory);
|
||||
inst->QueryInterface(NS_GET_IID(nsIFactory), (void **) &iFactory);
|
||||
|
||||
IUnknown *iUnknown;
|
||||
nsITestCom *iTestCom;
|
||||
|
||||
@@ -18,14 +18,13 @@
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Pierre Phaneuf <pp@ludusdesign.com>
|
||||
*/
|
||||
|
||||
#include "prmon.h"
|
||||
#include "nsIEventQueue.h"
|
||||
#include "nsPIEventQueueChain.h"
|
||||
|
||||
static NS_DEFINE_IID(kIEventQueueIID, NS_IEVENTQUEUE_IID);
|
||||
|
||||
class nsEventQueueImpl : public nsIEventQueue,
|
||||
public nsPIEventQueueChain
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user