annotate loader/dshow/iunk.h @ 168:bdc4a8fc04d8

Initial revision
author arpi_esp
date Tue, 20 Mar 2001 00:05:27 +0000
parents
children da26060c81ef
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
168
bdc4a8fc04d8 Initial revision
arpi_esp
parents:
diff changeset
1 #ifndef _iunk_h
bdc4a8fc04d8 Initial revision
arpi_esp
parents:
diff changeset
2 #define _iunk_h
bdc4a8fc04d8 Initial revision
arpi_esp
parents:
diff changeset
3 #include "interfaces.h"
bdc4a8fc04d8 Initial revision
arpi_esp
parents:
diff changeset
4 #include "guids.h"
bdc4a8fc04d8 Initial revision
arpi_esp
parents:
diff changeset
5 #define DECLARE_IUNKNOWN(CLASSNAME) \
bdc4a8fc04d8 Initial revision
arpi_esp
parents:
diff changeset
6 int refcount; \
bdc4a8fc04d8 Initial revision
arpi_esp
parents:
diff changeset
7 static long STDCALL QueryInterface (IUnknown * This, GUID* riid, void **ppvObject); \
bdc4a8fc04d8 Initial revision
arpi_esp
parents:
diff changeset
8 static long STDCALL AddRef (IUnknown * This); \
bdc4a8fc04d8 Initial revision
arpi_esp
parents:
diff changeset
9 static long STDCALL Release (IUnknown * This);
bdc4a8fc04d8 Initial revision
arpi_esp
parents:
diff changeset
10
bdc4a8fc04d8 Initial revision
arpi_esp
parents:
diff changeset
11 #define IMPLEMENT_IUNKNOWN(CLASSNAME) \
bdc4a8fc04d8 Initial revision
arpi_esp
parents:
diff changeset
12 long STDCALL CLASSNAME ::QueryInterface (IUnknown * This, GUID* riid, void **ppvObject) \
bdc4a8fc04d8 Initial revision
arpi_esp
parents:
diff changeset
13 { \
bdc4a8fc04d8 Initial revision
arpi_esp
parents:
diff changeset
14 Debug printf(#CLASSNAME "::QueryInterface() called\n");\
bdc4a8fc04d8 Initial revision
arpi_esp
parents:
diff changeset
15 if(!ppvObject)return 0x80004003; \
bdc4a8fc04d8 Initial revision
arpi_esp
parents:
diff changeset
16 CLASSNAME * me=( CLASSNAME *)This; \
bdc4a8fc04d8 Initial revision
arpi_esp
parents:
diff changeset
17 int i=0; \
bdc4a8fc04d8 Initial revision
arpi_esp
parents:
diff changeset
18 for(const GUID* r=me->interfaces; i<sizeof(CLASSNAME ::interfaces)/sizeof(CLASSNAME ::interfaces[0]); r++, i++) \
bdc4a8fc04d8 Initial revision
arpi_esp
parents:
diff changeset
19 if(!memcmp(r, riid, 16)) \
bdc4a8fc04d8 Initial revision
arpi_esp
parents:
diff changeset
20 { \
bdc4a8fc04d8 Initial revision
arpi_esp
parents:
diff changeset
21 This->vt->AddRef((IUnknown*)This); \
bdc4a8fc04d8 Initial revision
arpi_esp
parents:
diff changeset
22 *ppvObject=This; \
bdc4a8fc04d8 Initial revision
arpi_esp
parents:
diff changeset
23 return 0; \
bdc4a8fc04d8 Initial revision
arpi_esp
parents:
diff changeset
24 } \
bdc4a8fc04d8 Initial revision
arpi_esp
parents:
diff changeset
25 Debug printf("Failed\n"); \
bdc4a8fc04d8 Initial revision
arpi_esp
parents:
diff changeset
26 return 0x80004002; \
bdc4a8fc04d8 Initial revision
arpi_esp
parents:
diff changeset
27 } \
bdc4a8fc04d8 Initial revision
arpi_esp
parents:
diff changeset
28 \
bdc4a8fc04d8 Initial revision
arpi_esp
parents:
diff changeset
29 long STDCALL CLASSNAME ::AddRef ( \
bdc4a8fc04d8 Initial revision
arpi_esp
parents:
diff changeset
30 IUnknown * This) \
bdc4a8fc04d8 Initial revision
arpi_esp
parents:
diff changeset
31 { \
bdc4a8fc04d8 Initial revision
arpi_esp
parents:
diff changeset
32 Debug printf(#CLASSNAME "::AddRef() called\n"); \
bdc4a8fc04d8 Initial revision
arpi_esp
parents:
diff changeset
33 CLASSNAME * me=( CLASSNAME *)This; \
bdc4a8fc04d8 Initial revision
arpi_esp
parents:
diff changeset
34 return ++(me->refcount); \
bdc4a8fc04d8 Initial revision
arpi_esp
parents:
diff changeset
35 } \
bdc4a8fc04d8 Initial revision
arpi_esp
parents:
diff changeset
36 \
bdc4a8fc04d8 Initial revision
arpi_esp
parents:
diff changeset
37 long STDCALL CLASSNAME ::Release ( \
bdc4a8fc04d8 Initial revision
arpi_esp
parents:
diff changeset
38 IUnknown * This) \
bdc4a8fc04d8 Initial revision
arpi_esp
parents:
diff changeset
39 { \
bdc4a8fc04d8 Initial revision
arpi_esp
parents:
diff changeset
40 Debug printf(#CLASSNAME "::Release() called\n"); \
bdc4a8fc04d8 Initial revision
arpi_esp
parents:
diff changeset
41 CLASSNAME* me=( CLASSNAME *)This; \
bdc4a8fc04d8 Initial revision
arpi_esp
parents:
diff changeset
42 if(--(me->refcount) ==0) \
bdc4a8fc04d8 Initial revision
arpi_esp
parents:
diff changeset
43 delete ( CLASSNAME *) This; \
bdc4a8fc04d8 Initial revision
arpi_esp
parents:
diff changeset
44 return 0; \
bdc4a8fc04d8 Initial revision
arpi_esp
parents:
diff changeset
45 }
bdc4a8fc04d8 Initial revision
arpi_esp
parents:
diff changeset
46
bdc4a8fc04d8 Initial revision
arpi_esp
parents:
diff changeset
47 #endif