Skip to content

Commit aa23a77

Browse files
author
dp%netscape.com
committed
NS_GET_IID(). Thanks to patch from pp@ludasdesign.com r=dp@netscape.com
1 parent 5b37280 commit aa23a77

30 files changed

+149
-150
lines changed

xpcom/proxy/src/nsProxyEvent.cpp

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
* Rights Reserved.
1919
*
2020
* Contributor(s):
21+
* Pierre Phaneuf <pp@ludusdesign.com>
2122
*/
2223

2324

@@ -442,7 +443,10 @@ void* CompletedEventHandler(PLEvent *self)
442443
}
443444

444445
#ifdef AUTOPROXIFICATION
445-
// ssc@netscape.com wishes he could get rid of this instance of |NS_DEFINE_IID|, but |ProxyEventClassIdentity| is not visible from here
446+
/* ssc@netscape.com wishes he could get rid of this instance of
447+
* |NS_DEFINE_IID|, but |ProxyEventClassIdentity| is not visible from
448+
* here.
449+
*/
446450
static NS_DEFINE_IID(kProxyObject_Identity_Class_IID, NS_PROXYEVENT_IDENTITY_CLASS_IID);
447451

448452
nsresult
@@ -645,7 +649,10 @@ AutoProxyParameterList(PRUint32 methodIndex, nsXPTMethodInfo *methodInfo, nsXPTC
645649
nsProxyEventObject* replaceInterface = ((nsProxyEventObject*)params[i].val.p);
646650
if (replaceInterface)
647651
{
648-
// ssc@netscape.com wishes he could get rid of this instance of |NS_DEFINE_IID|, but |ProxyEventClassIdentity| is not visible from here
652+
/* ssc@netscape.com wishes he could get rid of this
653+
* instance of |NS_DEFINE_IID|, but
654+
* |ProxyEventClassIdentity| is not visible from here
655+
*/
649656
nsISupports *aIdentificationObject;
650657
rv = replaceInterface->QueryInterface(kProxyObject_Identity_Class_IID, (void**)&aIdentificationObject);
651658

xpcom/proxy/src/nsProxyEventClass.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
* Rights Reserved.
1919
*
2020
* Contributor(s):
21+
* Pierre Phaneuf <pp@ludusdesign.com>
2122
*/
2223

2324

@@ -40,7 +41,7 @@
4041

4142
static uint32 zero_methods_descriptor;
4243

43-
44+
static NS_DEFINE_IID(kProxyEventClassIID, NS_PROXYEVENT_CLASS_IID);
4445

4546
//////////////////////////////////////////////////////////////////////////////////////////////////
4647
// nsProxyEventClass
@@ -92,7 +93,7 @@ nsProxyEventClass::GetNewOrUsedClass(REFNSIID aIID)
9293
nsID* iid;
9394
if(NS_SUCCEEDED(oldest->GetIID(&iid)))
9495
{
95-
isISupportsDescendent = iid->Equals(nsCOMTypeInfo<nsISupports>::GetIID());
96+
isISupportsDescendent = iid->Equals(NS_GET_IID(nsISupports));
9697
nsAllocator::Free(iid);
9798
}
9899

@@ -230,7 +231,7 @@ nsProxyEventClass::DelegatedQueryInterface(nsProxyEventObject* self,
230231
void** aInstancePtr)
231232
{
232233

233-
if(aIID.Equals(ProxyEventClassIdentity::GetIID()))
234+
if(aIID.Equals(NS_GET_IID(ProxyEventClassIdentity)))
234235
{
235236
*aInstancePtr = (void**)self; //todo this should be a static cast
236237
NS_ADDREF(self);

xpcom/proxy/src/nsProxyEventObject.cpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
* Rights Reserved.
1919
*
2020
* Contributor(s):
21+
* Pierre Phaneuf <pp@ludusdesign.com>
2122
*/
2223

2324
#include "prprf.h"
@@ -31,8 +32,8 @@
3132

3233
#include "nsIInterfaceInfoManager.h"
3334
#include "xptcall.h"
34-
static NS_DEFINE_IID(kProxyObject_Identity_Class_IID, NS_PROXYEVENT_IDENTITY_CLASS_IID);
3535

36+
static NS_DEFINE_IID(kProxyObject_Identity_Class_IID, NS_PROXYEVENT_IDENTITY_CLASS_IID);
3637

3738
#ifdef DEBUG_dougt
3839
static PRMonitor* mon = nsnull;
@@ -136,7 +137,7 @@ nsProxyEventObject::GetNewOrUsedProxy(nsIEventQueue *destQueue,
136137

137138
// always find the native root if the |real| object.
138139
nsCOMPtr<nsISupports> rootObject;
139-
if(NS_FAILED(aObj->QueryInterface(nsCOMTypeInfo<nsISupports>::GetIID(), getter_AddRefs(rootObject))))
140+
if(NS_FAILED(aObj->QueryInterface(NS_GET_IID(nsISupports), getter_AddRefs(rootObject))))
140141
return nsnull;
141142

142143
/* get our hash table */
@@ -156,7 +157,7 @@ nsProxyEventObject::GetNewOrUsedProxy(nsIEventQueue *destQueue,
156157
// this will be our key in the hash table.
157158

158159
nsCOMPtr<nsISupports> destQRoot;
159-
if(NS_FAILED(destQueue->QueryInterface(nsCOMTypeInfo<nsISupports>::GetIID(), (void**)&destQueue)))
160+
if(NS_FAILED(destQueue->QueryInterface(NS_GET_IID(nsISupports), (void**)&destQueue)))
160161
return nsnull;
161162

162163
char* rootKeyString = PR_sprintf_append(nsnull, "%p.%p.%d", (PRUint32)rootObject.get(), (PRUint32)destQRoot.get(), proxyType);
@@ -205,7 +206,7 @@ nsProxyEventObject::GetNewOrUsedProxy(nsIEventQueue *destQueue,
205206
{
206207
// just a root proxy
207208
nsCOMPtr<nsProxyEventClass> rootClazz = getter_AddRefs ( nsProxyEventClass::GetNewOrUsedClass(
208-
nsCOMTypeInfo<nsISupports>::GetIID()) );
209+
NS_GET_IID(nsISupports)) );
209210

210211
if (!rootClazz)
211212
{
@@ -349,7 +350,7 @@ nsProxyEventObject::Find(REFNSIID aIID)
349350
{
350351
nsProxyEventObject* cur = (mRoot ? mRoot : this);
351352

352-
if(aIID.Equals(nsCOMTypeInfo<nsISupports>::GetIID()))
353+
if(aIID.Equals(NS_GET_IID(nsISupports)))
353354
{
354355
return cur;
355356
}

xpcom/proxy/src/nsProxyEventPrivate.h

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
* Rights Reserved.
1919
*
2020
* Contributor(s):
21+
* Pierre Phaneuf <pp@ludusdesign.com>
2122
*/
2223

2324
#ifndef __nsProxyEventPrivate_h_
@@ -54,17 +55,13 @@ class nsProxyEventClass;
5455
{ 0xec373590, 0x9164, 0x11d3, \
5556
{0x8c, 0x73, 0x00, 0x00, 0x64, 0x65, 0x73, 0x74} }
5657

57-
static NS_DEFINE_IID(kProxyEventClassIID, NS_PROXYEVENT_CLASS_IID);
58-
static NS_DEFINE_IID(kProxyEventObjectIID, NS_PROXYEVENT_OBJECT_IID);
59-
6058

6159
class nsProxyEventClass : public nsISupports
6260
{
6361
public:
6462
NS_DECL_ISUPPORTS
6563

66-
67-
static const nsIID& GetIID() {static nsIID iid = NS_PROXYEVENT_CLASS_IID; return iid;}
64+
NS_DEFINE_STATIC_IID_ACCESSOR(NS_PROXYEVENT_CLASS_IID)
6865
static nsProxyEventClass* GetNewOrUsedClass(REFNSIID aIID);
6966

7067
NS_IMETHOD DelegatedQueryInterface( nsProxyEventObject* self,
@@ -96,7 +93,8 @@ class nsProxyEventObject : public nsXPTCStubBase
9693
public:
9794

9895
NS_DECL_ISUPPORTS
99-
static const nsIID& GetIID() {static nsIID iid = NS_PROXYEVENT_OBJECT_IID; return iid;}
96+
97+
NS_DEFINE_STATIC_IID_ACCESSOR(NS_PROXYEVENT_OBJECT_IID)
10098

10199
static nsProxyEventObject* GetNewOrUsedProxy(nsIEventQueue *destQueue,
102100
PRInt32 proxyType,

xpcom/proxy/src/nsProxyObjectManager.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
* Rights Reserved.
1919
*
2020
* Contributor(s):
21+
* Pierre Phaneuf <pp@ludusdesign.com>
2122
*/
2223

2324

@@ -188,7 +189,7 @@ nsProxyObjectManager::GetProxyObject(nsIEventQueue *destQueue,
188189
if (ciObject == nsnull)
189190
return NS_ERROR_NULL_POINTER;
190191

191-
nsresult rv = GetProxyObject(destQueue, nsIProxyCreateInstance::GetIID(), ciObject, PROXY_SYNC, (void**)&ciProxy);
192+
nsresult rv = GetProxyObject(destQueue, NS_GET_IID(nsIProxyCreateInstance), ciObject, PROXY_SYNC, (void**)&ciProxy);
192193

193194
if (NS_FAILED(rv))
194195
{
@@ -321,7 +322,7 @@ NSRegisterSelf(nsISupports* aServMgr, const char *path)
321322

322323
nsIComponentManager* compMgr;
323324
rv = servMgr->GetService(kComponentManagerCID,
324-
nsIComponentManager::GetIID(),
325+
NS_GET_IID(nsIComponentManager),
325326
(nsISupports**)&compMgr);
326327
if (NS_FAILED(rv)) return rv;
327328

@@ -347,7 +348,7 @@ NSUnregisterSelf(nsISupports* aServMgr, const char *path)
347348

348349
nsIComponentManager* compMgr;
349350
rv = servMgr->GetService(kComponentManagerCID,
350-
nsIComponentManager::GetIID(),
351+
NS_GET_IID(nsIComponentManager),
351352
(nsISupports**)&compMgr);
352353
if (NS_FAILED(rv)) return rv;
353354

xpcom/proxy/tests/proxytests.cpp

Lines changed: 21 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
* Rights Reserved.
1919
*
2020
* Contributor(s):
21+
* Pierre Phaneuf <pp@ludusdesign.com>
2122
*/
2223

2324
#include <stdio.h>
@@ -36,7 +37,6 @@
3637
#include "nsProxyObjectManager.h"
3738
#include "nsIEventQueueService.h"
3839

39-
static NS_DEFINE_IID(kProxyObjectManagerIID, NS_IPROXYEVENT_MANAGER_IID);
4040
static NS_DEFINE_CID(kEventQueueServiceCID, NS_EVENTQUEUESERVICE_CID);
4141

4242
/***************************************************************************/
@@ -72,8 +72,7 @@ nsTestXPCFoo::~nsTestXPCFoo()
7272
{
7373
}
7474

75-
static NS_DEFINE_IID(kITestXPCFooIID, NS_ITESTPROXY_IID);
76-
NS_IMPL_ISUPPORTS(nsTestXPCFoo,kITestXPCFooIID)
75+
NS_IMPL_ISUPPORTS(nsTestXPCFoo, NS_GET_IID(nsITestProxy))
7776

7877
NS_IMETHODIMP nsTestXPCFoo::Test(PRInt32 p1, PRInt32 p2, PRInt32* retval)
7978
{
@@ -96,7 +95,7 @@ NS_IMETHODIMP nsTestXPCFoo::Test3(nsISupports *p1, nsISupports **p2)
9695
{
9796
nsITestProxy *test;
9897

99-
p1->QueryInterface(nsITestProxy::GetIID(), (void**)&test);
98+
p1->QueryInterface(NS_GET_IID(nsITestProxy), (void**)&test);
10099

101100
test->Test2();
102101
PRInt32 a;
@@ -133,8 +132,8 @@ nsTestXPCFoo2::nsTestXPCFoo2()
133132
nsTestXPCFoo2::~nsTestXPCFoo2()
134133
{
135134
}
136-
//kITestXPCFooIID defined above for nsTestXPCFoo(1)
137-
NS_IMPL_ISUPPORTS(nsTestXPCFoo2,kITestXPCFooIID)
135+
136+
NS_IMPL_ISUPPORTS(nsTestXPCFoo2,NS_GET_IID(nsITestProxy))
138137

139138
NS_IMETHODIMP nsTestXPCFoo2::Test(PRInt32 p1, PRInt32 p2, PRInt32* retval)
140139
{
@@ -144,14 +143,14 @@ printf("calling back to caller!\n\n");
144143
nsITestProxy * proxyObject;
145144

146145
nsServiceManager::GetService( NS_XPCOMPROXY_PROGID,
147-
kProxyObjectManagerIID,
146+
NS_GET_IID(nsIProxyObjectManager),
148147
(nsISupports **)&manager);
149148

150149
printf("ProxyObjectManager: %p \n", manager);
151150

152151
PR_ASSERT(manager);
153152

154-
manager->GetProxyObject((nsIEventQueue*)p1, nsITestProxy::GetIID(), this, PROXY_SYNC, (void**)&proxyObject);
153+
manager->GetProxyObject((nsIEventQueue*)p1, NS_GET_IID(nsITestProxy), this, PROXY_SYNC, (void**)&proxyObject);
155154
proxyObject->Test3(nsnull, nsnull);
156155

157156
printf("Deleting Proxy Object\n");
@@ -194,7 +193,7 @@ void TestCase_TwoClassesOneInterface(void *arg)
194193
nsIProxyObjectManager* manager;
195194

196195
nsServiceManager::GetService( NS_XPCOMPROXY_PROGID,
197-
kProxyObjectManagerIID,
196+
NS_GET_IID(nsIProxyObjectManager),
198197
(nsISupports **)&manager);
199198

200199
printf("ProxyObjectManager: %p \n", manager);
@@ -211,9 +210,9 @@ void TestCase_TwoClassesOneInterface(void *arg)
211210
PR_ASSERT(foo2);
212211

213212

214-
manager->GetProxyObject(argsStruct->queue, nsITestProxy::GetIID(), foo, PROXY_SYNC, (void**)&proxyObject);
213+
manager->GetProxyObject(argsStruct->queue, NS_GET_IID(nsITestProxy), foo, PROXY_SYNC, (void**)&proxyObject);
215214

216-
manager->GetProxyObject(argsStruct->queue, nsITestProxy::GetIID(), foo2, PROXY_SYNC, (void**)&proxyObject2);
215+
manager->GetProxyObject(argsStruct->queue, NS_GET_IID(nsITestProxy), foo2, PROXY_SYNC, (void**)&proxyObject2);
217216

218217

219218

@@ -265,7 +264,7 @@ void TestCase_NestedLoop(void *arg)
265264
nsIProxyObjectManager* manager;
266265

267266
nsServiceManager::GetService( NS_XPCOMPROXY_PROGID,
268-
kProxyObjectManagerIID,
267+
NS_GET_IID(nsIProxyObjectManager),
269268
(nsISupports **)&manager);
270269

271270
printf("ProxyObjectManager: %d \n", manager);
@@ -278,7 +277,7 @@ void TestCase_NestedLoop(void *arg)
278277
PR_ASSERT(foo);
279278

280279

281-
manager->GetProxyObject(argsStruct->queue, nsITestProxy::GetIID(), foo, PROXY_SYNC, (void**)&proxyObject);
280+
manager->GetProxyObject(argsStruct->queue, NS_GET_IID(nsITestProxy), foo, PROXY_SYNC, (void**)&proxyObject);
282281

283282
if (proxyObject)
284283
{
@@ -328,17 +327,17 @@ void TestCase_2(void *arg)
328327
nsIProxyObjectManager* manager;
329328

330329
nsServiceManager::GetService( NS_XPCOMPROXY_PROGID,
331-
kProxyObjectManagerIID,
330+
NS_GET_IID(nsIProxyObjectManager),
332331
(nsISupports **)&manager);
333332

334333
PR_ASSERT(manager);
335334

336335
nsITestProxy *proxyObject;
337336

338337
manager->GetProxyObject(argsStruct->queue,
339-
nsITestProxy::GetIID(), // should be CID!
338+
NS_GET_IID(nsITestProxy), // should be CID!
340339
nsnull,
341-
nsITestProxy::GetIID(),
340+
NS_GET_IID(nsITestProxy),
342341
PROXY_SYNC,
343342
(void**)&proxyObject);
344343

@@ -358,7 +357,7 @@ void TestCase_nsISupports(void *arg)
358357
nsIProxyObjectManager* manager;
359358

360359
nsServiceManager::GetService( NS_XPCOMPROXY_PROGID,
361-
kProxyObjectManagerIID,
360+
NS_GET_IID(nsIProxyObjectManager),
362361
(nsISupports **)&manager);
363362

364363
PR_ASSERT(manager);
@@ -368,7 +367,7 @@ void TestCase_nsISupports(void *arg)
368367

369368
PR_ASSERT(foo);
370369

371-
manager->GetProxyObject(argsStruct->queue, nsITestProxy::GetIID(), foo, PROXY_SYNC, (void**)&proxyObject);
370+
manager->GetProxyObject(argsStruct->queue, NS_GET_IID(nsITestProxy), foo, PROXY_SYNC, (void**)&proxyObject);
372371

373372
if (proxyObject != nsnull)
374373
{
@@ -378,7 +377,7 @@ void TestCase_nsISupports(void *arg)
378377
proxyObject->Test3(bISupports, &cISupports);
379378

380379
nsITestProxy *test;
381-
bISupports->QueryInterface(nsITestProxy::GetIID(), (void**)&test);
380+
bISupports->QueryInterface(NS_GET_IID(nsITestProxy), (void**)&test);
382381

383382
test->Test2();
384383

@@ -426,7 +425,7 @@ static void PR_CALLBACK EventLoop( void *arg )
426425
}
427426
if (NS_FAILED(rv)) return;
428427

429-
rv = eventQ->QueryInterface(nsIEventQueue::GetIID(), (void**)&gEventQueue);
428+
rv = eventQ->QueryInterface(NS_GET_IID(nsIEventQueue), (void**)&gEventQueue);
430429
if (NS_FAILED(rv)) return;
431430

432431

@@ -435,7 +434,7 @@ static void PR_CALLBACK EventLoop( void *arg )
435434
nsIProxyObjectManager* manager;
436435

437436
nsServiceManager::GetService( NS_XPCOMPROXY_PROGID,
438-
kProxyObjectManagerIID,
437+
NS_GET_IID(nsIProxyObjectManager),
439438
(nsISupports **)&manager);
440439

441440
PR_ASSERT(manager);
@@ -445,7 +444,7 @@ static void PR_CALLBACK EventLoop( void *arg )
445444

446445
PR_ASSERT(foo);
447446

448-
manager->GetProxyObject(gEventQueue, nsITestProxy::GetIID(), foo, PROXY_SYNC, (void**)&proxyObject);
447+
manager->GetProxyObject(gEventQueue, NS_GET_IID(nsITestProxy), foo, PROXY_SYNC, (void**)&proxyObject);
449448

450449
PRInt32 a;
451450
proxyObject->Test(1, 2, &a);

0 commit comments

Comments
 (0)