Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1111 lines
47 KiB

  1. //+-------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. //
  5. // Copyright (C) Microsoft Corporation, 1998 - 1999
  6. //
  7. // File: dms.h
  8. //
  9. //--------------------------------------------------------------------------
  10. //
  11. // dms.h : david's funky stuff
  12. //
  13. // CLONETO, QIOVERLOAD: see d3drmVisualObj.cpp
  14. //
  15. //
  16. //
  17. #include "basetsd.h"
  18. #include "dvp.h"
  19. #ifdef DEBUG
  20. #define DPF(n,o) {OutputDebugString(o);}
  21. #define DPF1(n,o,p) {char szOutN[1024]; wsprintf(szOutN,o,p);OutputDebugString(szOutN);}
  22. #define DPF2(n,o,p,e) {char szOutN[1024]; wsprintf(szOutN,o,p,e);OutputDebugString(szOutN);}
  23. #else
  24. #define DPF(n,o)
  25. #define DPF1(n,o,p)
  26. #define DPF2(n,o,p,e)
  27. #endif
  28. #define INTERNAL_CREATE_RETOBJ(objType,objOther,retval,classobj) \
  29. { C##objType##Object *prev=NULL; \
  30. *retval = NULL; \
  31. for(C##objType##Object *ptr=(C##objType##Object *)g##objType##; ptr; ptr=(C##objType##Object *)ptr->nextobj) \
  32. { IUnknown *unk=0; \
  33. ptr->InternalGetObject(&unk); \
  34. if(unk == objOther) \
  35. { \
  36. *retval = (I##objType*)ptr->pinterface; \
  37. IUNK(ptr->pinterface)->AddRef(); \
  38. IUNK(objOther)->Release(); \
  39. classobj=ptr; \
  40. break; \
  41. } \
  42. prev = ptr; \
  43. } \
  44. if(!ptr) \
  45. { C##objType##Object *c=new CComObject<C##objType##Object>;if( c == NULL ) { objOther->Release(); return E_FAIL;} \
  46. c->parent = this; \
  47. ((I##objType *)this)->AddRef(); \
  48. c->InternalSetObject(objOther); \
  49. if (FAILED( ((I##objType *)c)->QueryInterface(IID_I##objType, (void **)retval))) \
  50. return E_FAIL; \
  51. c->pinterface = (void*)*retval; \
  52. classobj=c; \
  53. } }
  54. #define INTERNAL_CREATE_STRUCT(objType,retval) { C##objType##Object *c=new CComObject<C##objType##Object>;\
  55. if (c==NULL) return E_OUTOFMEMORY;\
  56. if (FAILED(((I##objType *)c)->QueryInterface(IID_I##objType, (void **)retval))) return E_FAIL;\
  57. }
  58. #define INTERNAL_CREATE_NOADDREF(objType,objOther,retval) {C##objType##Object *prev=NULL; *retval = NULL; \
  59. for(C##objType##Object *ptr=(C##objType##Object *)g##objType##; ptr; ptr=(C##objType##Object *)ptr->nextobj){IUnknown *unk=0;ptr->InternalGetObject(&unk); if(unk == objOther) { *retval = (I##objType*)ptr->pinterface; IUNK(ptr->pinterface)->AddRef(); IUNK(objOther)->Release(); break; } prev = ptr; } \
  60. if(!ptr) { C##objType##Object *c=new CComObject<C##objType##Object>; if( c == NULL ) { objOther->Release();return E_FAIL;} c->InternalSetObject(objOther); if FAILED(((I##objType *)c)->QueryInterface(IID_I##objType, (void **)retval)) return E_FAIL; c->pinterface = (void*)*retval; }}
  61. // Given a java interface (objtype), envoke InternalSetObject and set the given
  62. // DIRECTX pointer (objOther). Also envoke QueryInterface and set a ** interface
  63. // ptr to a DIRECTX object (retval). So we create a DIRECTX object.
  64. //#define INTERNAL_CREATE(objType,objOther,retval){C##objType##Object *c=new CComObject<C##objType##Object>;if( c == NULL ) { objOther->Release(); return E_FAIL;} \
  65. //c->parent = this; AddRef(); c->InternalSetObject(objOther);if (FAILED(c->QueryInterface(IID_I##objType, (void **)retval))) return E_FAIL; }
  66. // if (FAILED(ptr->QueryInterface(IID_I##objType, (void **)retval))) return E_FAIL;
  67. #ifdef _DEBUG
  68. #define INTERNAL_CREATE(objType,objOther,retval) \
  69. { \
  70. DWORD refcount; char buffer[256]; wsprintf(buffer,"INTERNAL_CREATE %s \n",__FILE__); \
  71. OutputDebugString(buffer); \
  72. C##objType##Object *prev=NULL; \
  73. *retval = NULL; \
  74. for(C##objType##Object *ptr=(C##objType##Object *)g##objType##; ptr; ptr=(C##objType##Object *)ptr->nextobj) \
  75. {\
  76. IUnknown *unk=0; \
  77. ptr->InternalGetObject(&unk); \
  78. if(unk == objOther) \
  79. { \
  80. *retval = (I##objType*)ptr->pinterface;\
  81. IUNK(ptr->pinterface)->AddRef();\
  82. IUNK(objOther)->Release(); \
  83. refcount = *(((DWORD*)ptr)+1); \
  84. wsprintf(buffer," Retrived Object [%s] RefCount %d \n\r",__FILE__, refcount);\
  85. OutputDebugString(buffer);\
  86. break; \
  87. } \
  88. prev = ptr; \
  89. } \
  90. if(!ptr) \
  91. { \
  92. C##objType##Object *c=new CComObject<C##objType##Object>;if( c == NULL ) { objOther->Release(); return E_FAIL;} \
  93. c->parent = this; \
  94. ((I##objType *)this)->AddRef(); \
  95. refcount = *(((DWORD*)this)+1); \
  96. wsprintf(buffer,"Object [%s] RefCount[%d]\n\r",__FILE__, refcount);\
  97. OutputDebugString(buffer);\
  98. c->InternalSetObject(objOther);if (FAILED(( ((I##objType *)c))->QueryInterface(IID_I##objType, (void **)retval))) return E_FAIL; \
  99. c->pinterface = (void*)*retval; \
  100. } \
  101. }
  102. #else
  103. #define INTERNAL_CREATE(objType,objOther,retval) \
  104. { \
  105. C##objType##Object *prev=NULL; \
  106. *retval = NULL; \
  107. for(C##objType##Object *ptr=(C##objType##Object *)g##objType##; ptr; ptr=(C##objType##Object *)ptr->nextobj) \
  108. {\
  109. IUnknown *unk=0; \
  110. ptr->InternalGetObject(&unk); \
  111. if(unk == objOther) \
  112. { \
  113. *retval = (I##objType*)ptr->pinterface; \
  114. IUNK(ptr->pinterface)->AddRef(); \
  115. IUNK(objOther)->Release(); \
  116. break; \
  117. } \
  118. prev = ptr; \
  119. } \
  120. if(!ptr) \
  121. { \
  122. C##objType##Object *c=new CComObject<C##objType##Object>;if( c == NULL ) { objOther->Release(); return E_FAIL;} \
  123. c->parent = this; \
  124. ((I##objType *)this)->AddRef(); \
  125. c->InternalSetObject(objOther); \
  126. if (FAILED( ((I##objType *)c)->QueryInterface(IID_I##objType, (void **)retval))) return E_FAIL; \
  127. c->pinterface = (void*)*retval; \
  128. } \
  129. }
  130. #endif
  131. #define INTERNAL_CREATE_2REFS(objType,objParentType,objParent, objOther,retval) \
  132. { \
  133. C##objType##Object *prev=NULL; \
  134. *retval = NULL; \
  135. for(C##objType##Object *ptr=(C##objType##Object *)g##objType##; ptr; ptr=(C##objType##Object *)ptr->nextobj) \
  136. {\
  137. IUnknown *unk=0; \
  138. ptr->InternalGetObject(&unk); \
  139. if(unk == objOther) \
  140. { \
  141. *retval = (I##objType*)ptr->pinterface; \
  142. IUNK(ptr->pinterface)->AddRef(); \
  143. IUNK(objOther)->Release(); \
  144. break; \
  145. } \
  146. prev = ptr; \
  147. } \
  148. if(!ptr) \
  149. { \
  150. C##objType##Object *c=new CComObject<C##objType##Object>;if( c == NULL ) { objOther->Release(); return E_FAIL;} \
  151. c->parent = this; \
  152. c->parent2 = IUNK(objParent); \
  153. ((I##objType *)this)->AddRef(); \
  154. ((I##objParentType*)objParent)->AddRef(); \
  155. c->InternalSetObject(objOther); \
  156. if (FAILED( ((I##objType *)c)->QueryInterface(IID_I##objType, (void **)retval))) return E_FAIL; \
  157. c->pinterface = (void*)*retval; \
  158. } \
  159. }
  160. #define INTERNAL_CREATE_1REFS(objType,objParentType,objParent, objOther,retval) \
  161. { \
  162. C##objType##Object *prev=NULL; \
  163. *retval = NULL; \
  164. for(C##objType##Object *ptr=(C##objType##Object *)g##objType##; ptr; ptr=(C##objType##Object *)ptr->nextobj) \
  165. {\
  166. IUnknown *unk=0; \
  167. ptr->InternalGetObject(&unk); \
  168. if(unk == objOther) \
  169. { \
  170. *retval = (I##objType*)ptr->pinterface; \
  171. IUNK(ptr->pinterface)->AddRef(); \
  172. IUNK(objOther)->Release(); \
  173. break; \
  174. } \
  175. prev = ptr; \
  176. } \
  177. if(!ptr) \
  178. { \
  179. C##objType##Object *c=new CComObject<C##objType##Object>; \
  180. if( c == NULL ) \
  181. { objOther->Release(); return E_FAIL;} \
  182. c->parent = IUNK(objParent); \
  183. ((I##objParentType*)objParent)->AddRef(); \
  184. c->InternalSetObject(objOther); \
  185. if (FAILED( ((I##objType *)c)->QueryInterface(IID_I##objType, (void **)retval))) return E_FAIL; \
  186. c->pinterface = (void*)*retval; \
  187. } \
  188. }
  189. typedef struct FrameMoveCallback3
  190. {
  191. FrameMoveCallback3 *next;
  192. FrameMoveCallback3 *prev;
  193. I_dxj_Direct3dRMFrameMoveCallback3 *c;
  194. IUnknown *pUser;
  195. IUnknown *pParent;
  196. IUnknown *m_obj;
  197. int m_stopflag;
  198. } FrameMoveCallback3;
  199. struct TextureCallback
  200. {
  201. TextureCallback *next;
  202. TextureCallback *prev;
  203. I_dxj_Direct3dRMLoadTextureCallback3 *c;
  204. IUnknown *pUser;
  205. IUnknown *pParent;
  206. IUnknown *m_obj;
  207. int m_stopflag;
  208. };
  209. typedef struct TextureCallback3
  210. {
  211. TextureCallback3 *next;
  212. TextureCallback3 *prev;
  213. I_dxj_Direct3dRMLoadTextureCallback3 *c;
  214. IUnknown *pUser;
  215. IUnknown *pParent;
  216. IUnknown *m_obj;
  217. int m_stopflag;
  218. } TextureCallback3;
  219. struct d3drmCallback // used for AddDestroyCallback
  220. {
  221. d3drmCallback *next;
  222. d3drmCallback *prev;
  223. I_dxj_Direct3dRMCallback *c;
  224. IUnknown *pUser;
  225. IUnknown *pParent;
  226. IUnknown *m_obj;
  227. int m_stopflag;
  228. };
  229. struct DestroyCallback
  230. {
  231. DestroyCallback *next;
  232. DestroyCallback *prev;
  233. I_dxj_Direct3dRMCallback *c;
  234. IUnknown *pUser;
  235. IUnknown *pParent;
  236. IUnknown *m_obj;
  237. int m_stopflag;
  238. };
  239. struct EnumerateObjectsCallback
  240. {
  241. EnumerateObjectsCallback *next;
  242. EnumerateObjectsCallback *prev;
  243. I_dxj_Direct3dRMEnumerateObjectsCallback *c;
  244. IUnknown *pUser;
  245. IUnknown *pParent;
  246. IUnknown *m_obj;
  247. int m_stopflag;
  248. };
  249. struct GeneralCallback
  250. {
  251. GeneralCallback *next;
  252. GeneralCallback *prev;
  253. IUnknown *c;
  254. IUnknown *pUser;
  255. IUnknown *pParent;
  256. IUnknown *m_obj;
  257. int m_stopflag;
  258. };
  259. typedef struct DeviceUpdateCallback3
  260. {
  261. DeviceUpdateCallback3 *next;
  262. DeviceUpdateCallback3 *prev;
  263. I_dxj_Direct3dRMDeviceUpdateCallback3 *c;
  264. IUnknown *pUser;
  265. IUnknown *pParent;
  266. IUnknown *m_obj;
  267. int m_stopflag;
  268. } DeviceUpdateCallback3;
  269. struct LoadCallback
  270. {
  271. LoadCallback *next;
  272. LoadCallback *prev;
  273. I_dxj_Direct3dRMLoadCallback *c;
  274. IUnknown *pUser;
  275. IUnknown *pParent;
  276. IUnknown *m_obj;
  277. int m_stopflag;
  278. };
  279. /////////////////////////////////////////////////////////////////////////
  280. #define MAX_INTERNAL_STR_LEN 256
  281. struct JavaString
  282. {
  283. DWORD nBytes;
  284. WCHAR Item[MAX_INTERNAL_STR_LEN];
  285. };
  286. /////////////////////////////////////////////////////////////////////////
  287. /////////////////////////////////////////////////////////////////////////
  288. // mod:dp helper macros for stuffing expanded unions in DirectX Structures
  289. #define IUNK(o) ((IUnknown*)(void*)(o))
  290. #define IS_NULLGUID(g) (\
  291. (g->data1==0) && \
  292. (g->data2==0) && \
  293. (g->data3==0) && \
  294. (g->data4[0]==0) && \
  295. (g->data4[1]==0) && \
  296. (g->data4[2]==0) && \
  297. (g->data4[3]==0) && \
  298. (g->data4[4]==0) && \
  299. (g->data4[5]==0) && \
  300. (g->data4[6]==0) && \
  301. (g->data4[7]==0) )
  302. extern HRESULT CopyOutDDSurfaceDesc2(DDSurfaceDesc2 *dOut,DDSURFACEDESC2 *d);
  303. extern HRESULT CopyInDDSurfaceDesc2(DDSURFACEDESC2 *dOut,DDSurfaceDesc2 *d);
  304. extern HRESULT CopyInDDPixelFormat(DDPIXELFORMAT *ddpfOut,DDPixelFormat *pf);
  305. extern HRESULT CopyOutDDPixelFormat( DDPixelFormat *ddpfOut,DDPIXELFORMAT *pf);
  306. /////////////////////////////////////////////////////////////////////////
  307. #define JAVASTRING(item) {sizeof(item)*2-2, L##item}
  308. #define PASS_THROUGH(cl,m) STDMETHODIMP C##cl##Object::m() { return m_##cl->m();}
  309. #define PASS_THROUGH1(c,m,t1) STDMETHODIMP C##c##Object::m(t1 v1) { return m_##c->m(v1);}
  310. #define PASS_THROUGH2(c,m,t1,t2) STDMETHODIMP C##c##Object::m(t1 v1, t2 v2) { return m_##c->m(v1, v2);}
  311. #define PASS_THROUGH3(c,m,t1,t2,t3) STDMETHODIMP C##c##Object::m(t1 v1, t2 v2,t3 v3) { return m_##c->m(v1, v2,v3);}
  312. #define PASS_THROUGH4(c,m,t1,t2,t3,t4) STDMETHODIMP C##c##Object::m(t1 v1,t2 v2,t3 v3,t4 v4){return m_##c->m(v1, v2,v3,v4);}
  313. #define PASS_THROUGH5(c,m,t1,t2,t3,t4,t5) STDMETHODIMP C##c##Object::m(t1 v1,t2 v2,t3 v3,t4 v4,t5 v5){return m_##c->m(v1, v2,v3,v4,v5);}
  314. #define PASS_THROUGH6(c,m,t1,t2,t3,t4,t5,t6) STDMETHODIMP C##c##Object::m(t1 v1,t2 v2,t3 v3,t4 v4,t5 v5,t6 v6){return m_##c->m(v1, v2,v3,v4,v5,v6);}
  315. #define PASS_THROUGH7(c,m,t1,t2,t3,t4,t5,t6,t7) STDMETHODIMP C##c##Object::m(t1 v1,t2 v2,t3 v3,t4 v4,t5 v5,t6 v6,t7 v7){return m_##c->m(v1, v2,v3,v4,v5,v6,v7);}
  316. #define PASS_THROUGH8(c,m,t1,t2,t3,t4,t5,t6,t7,t8) STDMETHODIMP C##c##Object::m(t1 v1,t2 v2,t3 v3,t4 v4,t5 v5,t6 v6,t7 v7,t8 v8){return m_##c->m(v1,v2,v3,v4,v5,v6,v7,v8);}
  317. #define PASS_THROUGH_CAST_1(c,m,t1,tt1) STDMETHODIMP C##c##Object::m(t1 v1) { return m_##c->m(tt1 v1);}
  318. #define PASS_THROUGH_CAST_2(c,m,t1,tt1,t2,tt2) STDMETHODIMP C##c##Object::m(t1 v1, t2 v2) { return m_##c->m(tt1 v1, tt2 v2);}
  319. #define PASS_THROUGH_CAST_3(c,m,t1,tt1,t2,tt2,t3,tt3) STDMETHODIMP C##c##Object::m(t1 v1, t2 v2,t3 v3) { return m_##c->m(tt1 v1,tt2 v2,tt3 v3);}
  320. #define PASS_THROUGH_CAST_4(c,m,t1,tt1,t2,tt2,t3,tt3,t4,tt4) STDMETHODIMP C##c##Object::m(t1 v1,t2 v2,t3 v3,t4 v4){return m_##c->m(tt1 v1, tt2 v2,tt3 v3,tt4 v4);}
  321. #define PASS_THROUGH_CAST_5(c,m,t1,tt1,t2,tt2,t3,tt3,t4,tt4,t5,tt5) STDMETHODIMP C##c##Object::m(t1 v1,t2 v2,t3 v3,t4 v4,t5 v5){return m_##c->m(tt1 v1,tt2 v2,tt3 v3,tt4 v4,tt5 v5);}
  322. #define PASS_THROUGH_CAST_6(c,m,t1,tt1,t2,tt2,t3,tt3,t4,tt4,t5,tt5,t6,tt6) STDMETHODIMP C##c##Object::m(t1 v1,t2 v2,t3 v3,t4 v4,t5 v5,t6 v6){return m_##c->m(tt1 v1,tt2 v2,tt3 v3,tt4 v4,tt5 v5,tt6 v6);}
  323. #define PASS_THROUGH_CAST_7(c,m,t1,tt1,t2,tt2,t3,tt3,t4,tt4,t5,tt5,t6,tt6,t7,tt7) STDMETHODIMP C##c##Object::m(t1 v1,t2 v2,t3 v3,t4 v4,t5 v5,t6 v6,t7 v7){return m_##c->m(tt1 v1,tt2 v2,tt3 v3,tt4 v4,tt5 v5,tt6 v6,tt7 v7);}
  324. #define PASS_THROUGH_CAST_8(c,m,t1,tt1,t2,tt2,t3,tt3,t4,tt4,t5,tt5,t6,tt6,t7,tt7,t8,tt8) STDMETHODIMP C##c##Object::m(t1 v1,t2 v2,t3 v3,t4 v4,t5 v5,t6 v6,t7 v7,t8 v8){return m_##c->m(tt1 v1,tt2 v2,tt3 v3,tt4 v4,tt5 v5,tt6 v6,tt7 v7,tt8 v8);}
  325. //mod:dp additions due to renaming
  326. #define PASS_THROUGH_R(c,m1,m2) STDMETHODIMP C##c##Object::m1() { if(m_##c==NULL)return E_FAIL; return m_##c->m2();}
  327. #define PASS_THROUGH1_R(c,m1,m2,t1) STDMETHODIMP C##c##Object::m1(t1 v1) { if(m_##c==NULL)return E_FAIL; return m_##c->m2(v1);}
  328. #define PASS_THROUGH2_R(c,m1,m2,t1,t2) STDMETHODIMP C##c##Object::m1(t1 v1, t2 v2) { if(m_##c==NULL)return E_FAIL; return m_##c->m2(v1, v2);}
  329. #define PASS_THROUGH3_R(c,m1,m2,t1,t2,t3) STDMETHODIMP C##c##Object::m1(t1 v1, t2 v2,t3 v3) { if(m_##c==NULL)return E_FAIL; return m_##c->m2(v1, v2,v3);}
  330. #define PASS_THROUGH4_R(c,m1,m2,t1,t2,t3,t4) STDMETHODIMP C##c##Object::m1(t1 v1,t2 v2,t3 v3,t4 v4){ if(m_##c==NULL)return E_FAIL; return m_##c->m2(v1, v2,v3,v4);}
  331. #define PASS_THROUGH5_R(c,m1,m2,t1,t2,t3,t4,t5) STDMETHODIMP C##c##Object::m1(t1 v1,t2 v2,t3 v3,t4 v4,t5 v5){ if(m_##c==NULL)return E_FAIL; return m_##c->m2(v1, v2,v3,v4,v5);}
  332. #define PASS_THROUGH6_R(c,m1,m2,t1,t2,t3,t4,t5,t6) STDMETHODIMP C##c##Object::m1(t1 v1,t2 v2,t3 v3,t4 v4,t5 v5,t6 v6){ if(m_##c==NULL)return E_FAIL; return m_##c->m2(v1, v2,v3,v4,v5,v6);}
  333. #define PASS_THROUGH7_R(c,m1,m2,t1,t2,t3,t4,t5,t6,t7) STDMETHODIMP C##c##Object::m1(t1 v1,t2 v2,t3 v3,t4 v4,t5 v5,t6 v6,t7 v7){if(m_##c==NULL)return E_FAIL; return m_##c->m2(v1, v2,v3,v4,v5,v6,v7);}
  334. #define PASS_THROUGH8_R(c,m1,m2,t1,t2,t3,t4,t5,t6,t7,t8) STDMETHODIMP C##c##Object::m1(t1 v1,t2 v2,t3 v3,t4 v4,t5 v5,t6 v6,t7 v7,t8 v8){ if(m_##c==NULL)return E_FAIL; return m_##c->m2(v1,v2,v3,v4,v5,v6,v7,v8);}
  335. #define PASS_THROUGH_CAST_1_R(c,m1,m2,t1,tt1) STDMETHODIMP C##c##Object::m1(t1 v1) { if(m_##c==NULL)return E_FAIL; return m_##c->m2(tt1 v1);}
  336. #define PASS_THROUGH_CAST_2_R(c,m1,m2,t1,tt1,t2,tt2) STDMETHODIMP C##c##Object::m1(t1 v1, t2 v2) { if(m_##c==NULL)return E_FAIL; return m_##c->m2(tt1 v1, tt2 v2);}
  337. #define PASS_THROUGH_CAST_3_R(c,m1,m2,t1,tt1,t2,tt2,t3,tt3) STDMETHODIMP C##c##Object::m1(t1 v1, t2 v2,t3 v3) { if(m_##c==NULL)return E_FAIL; return m_##c->m2(tt1 v1,tt2 v2,tt3 v3);}
  338. #define PASS_THROUGH_CAST_4_R(c,m1,m2,t1,tt1,t2,tt2,t3,tt3,t4,tt4) STDMETHODIMP C##c##Object::m1(t1 v1,t2 v2,t3 v3,t4 v4){ if(m_##c==NULL)return E_FAIL; return m_##c->m2(tt1 v1, tt2 v2,tt3 v3,tt4 v4);}
  339. #define PASS_THROUGH_CAST_5_R(c,m1,m2,t1,tt1,t2,tt2,t3,tt3,t4,tt4,t5,tt5) STDMETHODIMP C##c##Object::m1(t1 v1,t2 v2,t3 v3,t4 v4,t5 v5){ if(m_##c==NULL)return E_FAIL; return m_##c->m2(tt1 v1,tt2 v2,tt3 v3,tt4 v4,tt5 v5);}
  340. #define PASS_THROUGH_CAST_6_R(c,m1,m2,t1,tt1,t2,tt2,t3,tt3,t4,tt4,t5,tt5,t6,tt6) STDMETHODIMP C##c##Object::m1(t1 v1,t2 v2,t3 v3,t4 v4,t5 v5,t6 v6){ if(m_##c==NULL)return E_FAIL; return m_##c->m2(tt1 v1,tt2 v2,tt3 v3,tt4 v4,tt5 v5,tt6 v6);}
  341. #define PASS_THROUGH_CAST_7_R(c,m1,m2,t1,tt1,t2,tt2,t3,tt3,t4,tt4,t5,tt5,t6,tt6,t7,tt7) STDMETHODIMP C##c##Object::m1(t1 v1,t2 v2,t3 v3,t4 v4,t5 v5,t6 v6,t7 v7){ if(m_##c==NULL)return E_FAIL; return m_##c->m2(tt1 v1,tt2 v2,tt3 v3,tt4 v4,tt5 v5,tt6 v6,tt7 v7);}
  342. #define PASS_THROUGH_CAST_8_R(c,m1,m2,t1,tt1,t2,tt2,t3,tt3,t4,tt4,t5,tt5,t6,tt6,t7,tt7,t8,tt8) STDMETHODIMP C##c##Object::m1(t1 v1,t2 v2,t3 v3,t4 v4,t5 v5,t6 v6,t7 v7,t8 v8){ if(m_##c==NULL)return E_FAIL; return m_##c->m2(tt1 v1,tt2 v2,tt3 v3,tt4 v4,tt5 v5,tt6 v6,tt7 v7,tt8 v8);}
  343. #define COPY_OR_CLEAR(dest, src, si) {if(src) memcpy((void *)dest, (void *)src, si);else memset((void *)dest, si, 0);}
  344. #define COPY(dest, src, si) memcpy((void *)dest, (void *)src, si)
  345. // ??
  346. #define DECLSET_OBJECT(ifacevar, var, typ) {if(var) var->Release(); var = (typ)ifacevar;}
  347. #define DECLGET_OBJECT(ifacevar, var){*ifacevar = (IUnknown *)var;}
  348. #define ISEQUAL(c) \
  349. STDMETHODIMP C##c##Object::isEqual(I##c *d, int *retval)\
  350. { IUnknown *IU1;\
  351. IUnknown *IU2;\
  352. if (d == NULL)\
  353. return E_FAIL; \
  354. this->InternalGetObject((IUnknown **)(&IU1)); \
  355. d->InternalGetObject((IUnknown **)(&IU2)); \
  356. if (IU1 == IU2) \
  357. *retval = TRUE; \
  358. else \
  359. *retval = FALSE; \
  360. return S_OK;}
  361. #define DX3J_GLOBAL_LINKS( obj_type ) \
  362. int creationid;\
  363. void *parent; \
  364. void *pinterface; \
  365. void *nextobj;
  366. /*STDMETHOD(isEqual)(IUnknown *pobj, int *ret)*/;
  367. // Given a class (c)
  368. #define GETSET_OBJECT(c) \
  369. STDMETHODIMP C##c##Object::InternalSetObject(IUnknown *l)\
  370. {DECLSET_OBJECT(l,m_##c,typedef_##c);return S_OK;} \
  371. STDMETHODIMP C##c##Object::InternalGetObject(IUnknown **l)\
  372. {DECLGET_OBJECT(l,m_##c);return S_OK;}
  373. //ISEQUAL(c);
  374. // Given a java interface, go get a pointer_to_a_pointer to a DIRECTX object
  375. //pac DO_GETOBJECT_NOTNULL is too dangerous and is commented. use DO_GETOBJECT_NOTNULL
  376. //#define DO_GETOBJECT(t,v,i) t v;i->InternalGetObject((IUnknown **)(&v));
  377. #define DO_GETOBJECT_NOTNULL(t,v,i) t v=NULL;if(i) i->InternalGetObject((IUnknown **)(&v));
  378. //
  379. extern int g_creationcount;
  380. #ifdef _DEBUG
  381. #define CONSTRUCTOR(c, o) C##c##Object::C##c##Object(){ \
  382. m_##c = NULL; parent = NULL; pinterface = NULL; \
  383. nextobj = g##c##;\
  384. creationid = ++g_creationcount;\
  385. char buffer[256];\
  386. wsprintf(buffer,"Constructor Creation Id [%d] %s",g_creationcount,__FILE__);\
  387. OutputDebugString(buffer);\
  388. g##c## = (void *)this; o }
  389. #else
  390. #define CONSTRUCTOR(c, o) C##c##Object::C##c##Object(){ \
  391. m_##c = NULL; parent = NULL; pinterface = NULL; \
  392. nextobj = (void*)g##c##; \
  393. creationid = ++g_creationcount; \
  394. g##c## = (void*)this; o}
  395. #endif
  396. #ifdef _DEBUG
  397. #define DESTRUCTOR(c, o) C##c##Object::~C##c##Object(){o; \
  398. char buffer[256]; \
  399. wsprintf(buffer,"Destructor Id[%d] %s ",creationid,__FILE__); \
  400. OutputDebugString(buffer); C##c##Object *prev=NULL; \
  401. for(C##c##Object *ptr=(C##c##Object *)g##c##; ptr; ptr=(C##c##Object *)ptr->nextobj) \
  402. {\
  403. if(ptr == this) \
  404. { \
  405. if(prev) \
  406. prev->nextobj = ptr->nextobj; \
  407. else \
  408. g##c## = (void*)ptr->nextobj; \
  409. break; \
  410. } \
  411. prev = ptr; \
  412. } \
  413. if(m_##c){ int count = IUNK(m_##c)->Release(); wsprintf(buffer,"DirectX %s Ref count [%d]",__FILE__,count); OutputDebugString(buffer); \
  414. if(count==0){ char szOut[512];wsprintf(szOut,"\n Real %s released \n",__FILE__); OutputDebugString(szOut); m_##c = NULL; } \
  415. } \
  416. if(parent) IUNK(parent)->Release(); \
  417. }
  418. #else
  419. #define DESTRUCTOR(c, o) C##c##Object::~C##c##Object(){o; \
  420. C##c##Object *prev=NULL; \
  421. for(C##c##Object *ptr=(C##c##Object *)g##c##; ptr; ptr=(C##c##Object *)ptr->nextobj) \
  422. {\
  423. if(ptr == this) \
  424. { \
  425. if(prev) \
  426. prev->nextobj = ptr->nextobj; \
  427. else \
  428. g##c## = (void*)ptr->nextobj; \
  429. break; \
  430. } \
  431. prev = ptr; \
  432. } \
  433. if(m_##c){ \
  434. if (IUNK(m_##c)->Release()==0) m_##c = NULL; \
  435. } \
  436. if(parent) IUNK(parent)->Release();\
  437. }
  438. #endif
  439. #define OBJCHECK(lable, c) { \
  440. char buffer[256];\
  441. if ( g##c ) \
  442. {\
  443. int count = 0; \
  444. C##c##Object *prev=NULL; \
  445. C##c##Object *ptr;\
  446. for(ptr=(C##c##Object *)g##c##; ptr; ptr=(C##c##Object *)ptr->nextobj) \
  447. {\
  448. DWORD refcount = *(((DWORD*)ptr)+1);\
  449. wsprintf( buffer,"%s: Ref Count [%d] CreateId [%d]\n\r",lable,refcount,ptr->creationid);\
  450. OutputDebugString(buffer);\
  451. count++;\
  452. }\
  453. wsprintf(buffer,"%s: %d \n\r",lable,count);\
  454. OutputDebugString(buffer);\
  455. }\
  456. }
  457. #ifdef _DEBUG
  458. #define CONSTRUCTOR_STRUCT(c, o) C##c##Object::C##c##Object(){ nextobj = g##c##;\
  459. creationid = ++g_creationcount;\
  460. char buffer[256];\
  461. wsprintf(buffer,"Creation Id [%d]",g_creationcount);\
  462. OutputDebugString(buffer);\
  463. g##c## = (void*)this;o}
  464. #else
  465. #define CONSTRUCTOR_STRUCT(c, o) C##c##Object::C##c##Object(){ \
  466. nextobj =(void*) g##c##; \
  467. creationid = ++g_creationcount; \
  468. g##c## = (void*)this; \
  469. o}
  470. #endif
  471. #define DESTRUCTOR_STRUCT(c, o) C##c##Object::~C##c##Object(){o; \
  472. C##c##Object *prev=NULL; \
  473. for(C##c##Object *ptr=(C##c##Object *)g##c##; ptr; ptr=(C##c##Object *)ptr->nextobj) \
  474. {\
  475. if(ptr == this) \
  476. { \
  477. if(prev) \
  478. prev->nextobj = ptr->nextobj; \
  479. else \
  480. g##c## = (void*)ptr->nextobj; \
  481. break; \
  482. } \
  483. prev = ptr; \
  484. } \
  485. }
  486. #define CHECK_AND_RETURN_RMVIS(real,cover,f) {##real *lpReal=NULL;\
  487. if (S_OK==lp->QueryInterface(IID_##real, (void**) &lpReal)){\
  488. I##cover *lpFake=NULL;\
  489. INTERNAL_CREATE(cover, lpReal, (void**)&lpFake);\
  490. if (!lpFake) {IUNK(lpFake)->Release(); return E_OUTOFMEMORY;}\
  491. ((I##cover *)lpFake)->QueryInterface(IID_I_dxj_Direct3dRMVisual,(void**)f);\
  492. ((I##cover *)lpFake)->Release();\
  493. return S_OK;\
  494. }}
  495. // Given a java class (c), create a DIRECTX object and an interface ** ptr to it.
  496. #define RETURN_NEW_ITEM(c,m,oc) STDMETHODIMP C##c##Object::m(I##oc **rv){typedef_##oc lp;\
  497. if( m_##c->m(&lp) != S_OK)return E_FAIL;INTERNAL_CREATE(oc, lp, rv);\
  498. return S_OK;}
  499. #define RETURN_NEW_ITEM_CAST(c,m,oc, ty) STDMETHODIMP C##c##Object::m(I##oc **rv){typedef_##oc lp;\
  500. if( m_##c->m(ty &lp) != S_OK)return E_FAIL;INTERNAL_CREATE(oc, lp, rv);\
  501. return S_OK;}
  502. #define RETURN_NEW_ITEM_NOREL(c,m,oc) STDMETHODIMP C##c##Object::m(I##oc **rv){typedef_##oc lp;\
  503. if( m_##c->m(&lp) != S_OK)return E_FAIL;INTERNAL_CREATE_NOREL(oc, lp, rv);\
  504. return S_OK;}
  505. #define RETURN_NEW_ITEM1(c,m,oc,t1) STDMETHODIMP C##c##Object::m(t1 v1, I##oc **rv){typedef_##oc lp;\
  506. if( m_##c->m(v1,&lp) != S_OK)return E_FAIL;INTERNAL_CREATE(oc, lp, rv);\
  507. return S_OK;}
  508. #define RETURN_NEW_ITEM2(c,m,oc,t1,t2) STDMETHODIMP C##c##Object::m(t1 v1, t2 v2,I##oc **rv){typedef_##oc lp;\
  509. if( m_##c->m(v1,v2,&lp) != S_OK)return E_FAIL;INTERNAL_CREATE(oc, lp, rv);\
  510. return S_OK;}
  511. #define RETURN_NEW_ITEM_CAST_1(c,m,oc,t1,tt1) STDMETHODIMP C##c##Object::m(t1 v1, I##oc **rv){typedef_##oc lp;\
  512. if( m_##c->m(tt1 v1,&lp) != S_OK)return E_FAIL;INTERNAL_CREATE(oc, lp, rv);\
  513. return S_OK;}
  514. #define RETURN_NEW_ITEM_CAST_2(c,m,oc,t1,tt1,t2,tt2) STDMETHODIMP C##c##Object::m(t1 v1, t2 v2,I##oc **rv){typedef_##oc lp;\
  515. if( m_##c->m(tt1 v1,tt2 v2,&lp) != S_OK)return E_FAIL;INTERNAL_CREATE(oc, lp, rv);\
  516. return S_OK;}
  517. #define RETURN_NEW_ITEM_CAST_3(c,m,oc,t1,tt1,t2,tt2,t3,tt3) STDMETHODIMP C##c##Object::m(t1 v1, t2 v2, t3 v3, I##oc **rv){typedef_##oc lp;\
  518. if( m_##c->m(tt1 v1,tt2 v2,tt3 v3,&lp) != S_OK)return E_FAIL;INTERNAL_CREATE(oc, lp, rv);\
  519. return S_OK;}
  520. //mod:dp additions due to renaming
  521. // Given a java class (c), create a DIRECTX object and an interface ** ptr to it.
  522. #define RETURN_NEW_ITEM_R(c,m,m2,oc) STDMETHODIMP C##c##Object::m(I##oc **rv){typedef_##oc lp;\
  523. if( m_##c->m2(&lp) != S_OK)return E_FAIL;INTERNAL_CREATE(oc, lp, rv);\
  524. return S_OK;}
  525. #define RETURN_NEW_ITEM1_R(c,m,m2,oc,t1) STDMETHODIMP C##c##Object::m(t1 v1, I##oc **rv){typedef_##oc lp;\
  526. if( m_##c->m2(v1,&lp) != S_OK)return E_FAIL;INTERNAL_CREATE(oc, lp, rv);\
  527. return S_OK;}
  528. #define RETURN_NEW_ITEM2_R(c,m,m2,oc,t1,t2) STDMETHODIMP C##c##Object::m(t1 v1, t2 v2,I##oc **rv){typedef_##oc lp;\
  529. if( m_##c->m2(v1,v2,&lp) != S_OK)return E_FAIL;INTERNAL_CREATE(oc, lp, rv);\
  530. return S_OK;}
  531. #define RETURN_NEW_ITEM_CAST_R(c,m,m2,oc,ty) STDMETHODIMP C##c##Object::m(I##oc **rv){typedef_##oc lp;\
  532. if( m_##c->m2(ty &lp) != S_OK)return E_FAIL;INTERNAL_CREATE(oc, lp, rv);\
  533. return S_OK;}
  534. #define RETURN_NEW_ITEM_CAST_1_R(c,m,m2,oc,t1,tt1) STDMETHODIMP C##c##Object::m(t1 v1, I##oc **rv){typedef_##oc lp;\
  535. if( m_##c->m2(tt1 v1,&lp) != S_OK)return E_FAIL;INTERNAL_CREATE(oc, lp, rv);\
  536. return S_OK;}
  537. #define RETURN_NEW_ITEM_CAST_2_R(c,m,m2,oc,t1,tt1,t2,tt2) STDMETHODIMP C##c##Object::m(t1 v1, t2 v2,I##oc **rv){typedef_##oc lp;\
  538. if( m_##c->m2(tt1 v1,tt2 v2,&lp) != S_OK)return E_FAIL;INTERNAL_CREATE(oc, lp, rv);\
  539. return S_OK;}
  540. #if 0
  541. #define RETURN_NEW_ITEM_NOREL(c,m,oc) STDMETHODIMP C##c##Object::m(I##oc **rv){typedef_##oc lp;\
  542. if( m_##c->m(&lp) != S_OK)return E_FAIL;INTERNAL_CREATE_NOREL(oc, lp, rv);\
  543. return S_OK;}
  544. #define RETURN_NEW_ITEM_CAST_3(c,m,oc,t1,tt1,t2,tt2,t3,tt3) STDMETHODIMP C##c##Object::m(t1 v1, t2 v2, t3 v3, I##oc **rv){typedef_##oc lp;\
  545. if( m_##c->m(tt1 v1,tt2 v2,tt3 v3,&lp) != S_OK)return E_FAIL;INTERNAL_CREATE(oc, lp, rv);\
  546. return S_OK;}
  547. #endif
  548. // Return a primitive value by reference.
  549. #define GET_DIRECT(cl,met,t) STDMETHODIMP C##cl##Object::met(t *h){*h=(t)m_##cl->met();return S_OK;}
  550. #define GET_DIRECT1(cl,met,t,t1) STDMETHODIMP C##cl##Object::met(t1 v1,t *h){*h=(t)m_##cl->met(v1);return S_OK;}
  551. #define GET_DIRECT2(cl,met,t,t1,t2) STDMETHODIMP C##cl##Object::met(t1 v1, t2 v2, t *h){*h=(t)m_##cl->met(v1,v2);return S_OK;}
  552. #define GET_DIRECT_R(cl,met,met2,t) STDMETHODIMP C##cl##Object::met(t *h){*h=(t)m_##cl->met2();return S_OK;}
  553. #define GET_DIRECT1_R(cl,met,met2,t,t1) STDMETHODIMP C##cl##Object::met(t1 v1,t *h){*h=(t)m_##cl->met2(v1);return S_OK;}
  554. #define GET_DIRECT2_R(cl,met,met2,t,t1,t2) STDMETHODIMP C##cl##Object::met(t1 v1, t2 v2, t *h){*h=(t)m_##cl->met2(v1,v2);return S_OK;}
  555. // Return a pointer to a primitive value as a ** ptr.
  556. #define GET_DIRECTPTR(cl,met,t) STDMETHODIMP C##cl##Object::met(t **h){*h=(struct t*)m_##cl->met();return S_OK;}
  557. #define GET_DIRECTPTR1(cl,met,t,t1) STDMETHODIMP C##cl##Object::met(t1 v1,t **h){*h=(struct t*)m_##cl->met(v1);return S_OK;}
  558. #define GET_DIRECTPTR2(cl,met,t,t1,t2) STDMETHODIMP C##cl##Object::met(t1 v1, t2 v2, t **h){*h=(struct t*)m_##cl->met(v1,v2);return S_OK;}
  559. //Do a DO_GETOBJECT_NOTNULL and then call a method on the object
  560. #define DO_GETOBJECT_ANDUSEIT(cl,me,iface) STDMETHODIMP C##cl##Object::me(I##iface *vis) \
  561. {DO_GETOBJECT_NOTNULL( typedef_##iface, lp, vis); if ( m_##cl == NULL ) return E_FAIL; return m_##cl->me(lp); }
  562. #define DO_GETOBJECT_ANDUSEIT_CAST(cl,me,iface, t1) STDMETHODIMP C##cl##Object::me(I##iface *vis) \
  563. {DO_GETOBJECT_NOTNULL( typedef_##iface, lp, vis); if ( m_##cl == NULL ) return E_FAIL; return m_##cl->me((t1)lp); }
  564. #define DO_GETOBJECT_ANDUSEIT1(cl,me,iface,t1) STDMETHODIMP C##cl##Object::me(t1 v1,I##iface *vis) \
  565. {DO_GETOBJECT_NOTNULL( typedef_##iface, lp, vis); if ( m_##cl == NULL ) return E_FAIL; return m_##cl->me(v1, lp); }
  566. #define DO_GETOBJECT_ANDUSEIT2(cl,me,iface,t1,t2) STDMETHODIMP C##cl##Object::me(t1 v1,t2 v2,I##iface *vis) \
  567. {DO_GETOBJECT_NOTNULL( typedef_##iface, lp, vis); if ( m_##cl == NULL ) return E_FAIL; return m_##cl->me(v1, v2, lp); }
  568. //mod:dp additions due to renaming
  569. //Do a DO_GETOBJECT_NOTNULL and then call a method on the object
  570. #define DO_GETOBJECT_ANDUSEIT_R(cl,me, m2, iface) STDMETHODIMP C##cl##Object::me(I##iface *vis) \
  571. {DO_GETOBJECT_NOTNULL( typedef_##iface, lp, vis); if ( m_##cl == NULL ) return E_FAIL; return m_##cl->m2(lp); }
  572. #define DO_GETOBJECT_ANDUSEIT_CAST_R(cl,me, m2, iface, t1) STDMETHODIMP C##cl##Object::me(I##iface *vis) \
  573. {DO_GETOBJECT_NOTNULL( typedef_##iface, lp, vis); if ( m_##cl == NULL ) return E_FAIL; return m_##cl->m2((t1)lp); }
  574. #define DO_GETOBJECT_ANDUSEIT1_R(cl,me, m2, iface,t1) STDMETHODIMP C##cl##Object::me(t1 v1,I##iface *vis) \
  575. {DO_GETOBJECT_NOTNULL( typedef_##iface, lp, vis); if ( m_##cl == NULL ) return E_FAIL; return m_##cl->m2(v1, lp); }
  576. #define DO_GETOBJECT_ANDUSEIT2_R(cl,me, m2, iface,t1,t2) STDMETHODIMP C##cl##Object::me(t1 v1,t2 v2,I##iface *vis) \
  577. {DO_GETOBJECT_NOTNULL( typedef_##iface, lp, vis); if ( m_##cl == NULL ) return E_FAIL; return m_##cl->m2(v1, v2, lp); }
  578. // Make a copy of an object!
  579. //#define CLONE(cl) STDMETHODIMP C##cl##Object::Clone(Id3drmObject **retval){typedef_##cl lp;\
  580. // m_##cl->Clone(0,IID_I##cl,(void **)&lp);INTERNAL_CREATE(cl,lp,retval);return S_OK;}
  581. //#define CLONE(cl) STDMETHODIMP C##cl##Object::Clone(I##cl **retval){typedef_##cl lp;\
  582. //m_##cl->Clone(0,IID_I##cl,(void **)&lp);INTERNAL_CREATE(cl, lp, retval); return S_OK;}
  583. //#define CLONE_R(cl,c2) STDMETHODIMP C##cl##Object::clone(I##cl **retval){typedef_##cl lp;\
  584. //m_##cl->Clone(0,IID_I##c2,(void **)&lp);INTERNAL_CREATE(cl, lp, retval); return S_OK;}
  585. #define CLONE_R(cl,c2) STDMETHODIMP C##cl##Object::clone(IUnknown **retval){typedef_##cl lp;\
  586. m_##cl->Clone(0,IID_I##c2,(void **)&lp);INTERNAL_CREATE(cl, lp, (I##cl **)retval); return S_OK;}
  587. // ??
  588. // Call the d3drmObject->GetName method
  589. extern "C" HRESULT _GetName(IDirect3DRMObject *i, BSTR *Name, BOOL bName);
  590. #define GETNAME(cl) STDMETHODIMP C##cl##Object::GetName(BSTR *n){return _GetName(m_##cl, n, TRUE);}
  591. #define GETCLASSNAME(cl) STDMETHODIMP C##cl##Object::GetClassName(BSTR *n){return _GetName(m_##cl, n, FALSE);}
  592. #define SETNAME(cl) STDMETHODIMP C##cl##Object::SetName(BSTR Name){ \
  593. USES_CONVERSION;\
  594. LPSTR str = NULL; \
  595. __try { str = W2T(Name); /* Now convert to ANSI */ } __except(EXCEPTION_EXECUTE_HANDLER) { return E_FAIL; } \
  596. return m_##cl->SetName( str );}
  597. #define GETNAME_R(cl) STDMETHODIMP C##cl##Object::getName(BSTR *n){return _GetName(m_##cl, n, TRUE);}
  598. #define GETCLASSNAME_R(cl) STDMETHODIMP C##cl##Object::getClassName(BSTR *n){return _GetName(m_##cl, n, FALSE);}
  599. #define SETNAME_R(cl) STDMETHODIMP C##cl##Object::setName(BSTR Name){ \
  600. USES_CONVERSION;\
  601. LPSTR str = W2T(Name); return m_##cl->SetName( str );}
  602. extern "C" HRESULT _DeleteDestroyCallback(IDirect3DRMObject *iface, I_dxj_Direct3dRMCallback *oC,
  603. IUnknown *args);
  604. #define DELETEDESTROYCALLBACK(cl) STDMETHODIMP C##cl##Object::DeleteDestroyCallback( I_dxj_Direct3dRMCallback *oC, IUnknown *args) \
  605. {return _DeleteDestroyCallback(m_##cl, oC, args);}
  606. #define DELETEDESTROYCALLBACK_R(cl) STDMETHODIMP C##cl##Object::deleteDestroyCallback( I_dxj_Direct3dRMCallback *oC, IUnknown *args) \
  607. {return _DeleteDestroyCallback(m_##cl, oC, args);}
  608. extern "C" HRESULT _AddDestroyCallback(IDirect3DRMObject *iface, I_dxj_Direct3dRMCallback *oC,
  609. IUnknown *args);
  610. #define ADDDESTROYCALLBACK(cl) STDMETHODIMP C##cl##Object::AddDestroyCallback(I_dxj_Direct3dRMCallback *oC, IUnknown *args) \
  611. {return _AddDestroyCallback(m_##cl, oC, args);}
  612. #define ADDDESTROYCALLBACK_R(cl) STDMETHODIMP C##cl##Object::addDestroyCallback(I_dxj_Direct3dRMCallback *oC, IUnknown *args) \
  613. {return _AddDestroyCallback(m_##cl, oC, args);}
  614. #define CLONETO(clMe, cl, ifaceThat) STDMETHODIMP C##clMe##Object::Get##cl(I##cl **retval) \
  615. { typedef_##cl lp; if (m_##clMe->QueryInterface(ifaceThat, (void **) &lp) != S_OK) return S_FALSE; \
  616. INTERNAL_CREATE( cl, lp, retval); return S_OK; }
  617. #define CLONETO_RX(clMe, cl, ifaceThat) \
  618. STDMETHODIMP C##clMe##Object::getDirect3dRM##cl(I_dxj_Direct3dRM##cl **retval) \
  619. { \
  620. typedef__dxj_Direct3dRM##cl lp; \
  621. if (m_##clMe->QueryInterface(ifaceThat, (void **) &lp) != S_OK) \
  622. return S_FALSE; \
  623. INTERNAL_CREATE( _dxj_Direct3dRM##cl, lp, retval); \
  624. return S_OK; \
  625. }
  626. #define ISSAFEARRAY1D(ppsa,count) ((*ppsa) && ( ((SAFEARRAY*)*ppsa)->cDims==1) && (((SAFEARRAY*)*ppsa)->rgsabound[0].cElements >= count))
  627. /**********************************************************************************************/
  628. extern "C" BOOL ParseWaveResource(void *pvRes, WAVEFORMATEX **ppWaveHeader,
  629. BYTE **ppbWaveData,DWORD *pcbWaveSize);
  630. extern "C" BOOL GetWaveResource(HMODULE hModule, LPCTSTR lpName,
  631. WAVEFORMATEX **ppWaveHeader, BYTE **ppbWaveData, DWORD *pcbWaveSize);
  632. extern "C" DWORD bppToddbd(int bpp);
  633. extern "C" void UndoCallbackLink(GeneralCallback *e, GeneralCallback **h);
  634. extern "C" void PassBackUnicode(LPSTR str, BSTR *Name, DWORD cnt);
  635. extern "C" void ctojDSBufferDesc( LPDSBUFFERDESC lpdd,
  636. DSBufferDesc *ddsb, WaveFormatex *wave);
  637. extern "C" void jtocDSBufferDesc( LPDSBUFFERDESC lpdd,
  638. DSBufferDesc *ddsb, WaveFormatex *wave);
  639. extern "C" void ctojWaveFormatEx( LPWAVEFORMATEX lpdd, WaveFormatex *wave);
  640. extern "C" void CopyFloats(D3DVALUE *mat1, D3DVALUE *mat2, DWORD count);
  641. extern "C" void* CheckCallbackLink(void *current, void **head);
  642. extern "C" void* AddCallbackLink(void **ptr2, I_dxj_Direct3dRMCallback *enumC, void *args);
  643. extern "C" void* AddCallbackLinkRetVal(IUnknown *m_obj, void **ptr2, I_dxj_Direct3dRMCallback *enumC, void *args);
  644. extern "C" void SetStopFlag(IUnknown *m_obj, void** ptr2);
  645. extern "C" BOOL PASCAL myEnumSoundDriversCallback(GUID &SPGuid, LPSTR description,
  646. LPSTR module, void *lpArg);
  647. extern "C" void __cdecl myFrameMoveCallback( LPDIRECT3DRMFRAME lpf,
  648. void *lpArg, D3DVALUE delta);
  649. extern "C" void __cdecl myFrameMoveCallback2( LPDIRECT3DRMFRAME lpf,
  650. void *lpArg, D3DVALUE delta);
  651. extern "C" void __cdecl myFrameMoveCallback3( LPDIRECT3DRMFRAME3 lpf,
  652. void *lpArg, D3DVALUE delta);
  653. extern "C" HRESULT __cdecl myLoadTextureCallback(char *tex_name,
  654. void *lpArg,LPDIRECT3DRMTEXTURE * lpD3DRMTex);
  655. extern "C" HRESULT __cdecl myLoadTextureCallback3(char *tex_name,
  656. void *lpArg,LPDIRECT3DRMTEXTURE3 * lpD3DRMTex);
  657. extern "C" void __cdecl myAddUpdateCallback3(LPDIRECT3DRMDEVICE3 ref,
  658. void *lpArg, int rectCount, LPD3DRECT update);
  659. extern "C" void __cdecl myEnumerateObjectsCallback( LPDIRECT3DRMOBJECT lpo,void *lpArg);
  660. extern "C" int __cdecl myUserVisualCallback(LPDIRECT3DRMUSERVISUAL lpUV,void *lpArg,
  661. DWORD reason, LPDIRECT3DRMDEVICE lpD, LPDIRECT3DRMVIEWPORT lpV);
  662. extern "C" BOOL PASCAL myEnumServiceProvidersCallback(LPGUID lpSPGuid, LPWSTR lpFriendlyName,
  663. DWORD dwMajorVersion,DWORD dwMinorVersion, void *lpArg);
  664. extern "C" BOOL PASCAL myEnumPlayersCallback2(DPID dpid,
  665. DWORD dwPlayerType, LPCDPNAME lpName,
  666. DWORD dwFlags, LPVOID lpContext);
  667. extern "C" BOOL PASCAL myEnumSessionsCallback2(const DPSESSIONDESC2 *gameDesc,
  668. DWORD *timeout, DWORD dwFlags, void *lpArg);
  669. extern "C" BOOL PASCAL myEnumAddressCallback(LPGUID guidDataType,
  670. DWORD dwDataSize, LPCVOID lpData, LPVOID lpContext);
  671. extern "C" BOOL PASCAL myEnumAddressTypesCallback(LPGUID guidDataType,
  672. LPVOID lpContext, DWORD dwFlags);
  673. extern "C" BOOL PASCAL myEnumLocalApplicationsCallback(LPCDPLAPPINFO lpAppInfo,
  674. LPVOID lpContext, DWORD dwFlags);
  675. extern "C" BOOL PASCAL myEnumConnectionsCallback( LPCGUID lpguidSP,
  676. LPVOID lpConnection, DWORD dwConnectionSize, LPCDPNAME lpName,
  677. DWORD dwFlags, LPVOID lpContext);
  678. extern "C" HRESULT PASCAL myEnumSurfacesCallback(LPDIRECTDRAWSURFACE lpDDSurface,
  679. LPDDSURFACEDESC lpDDSurfaceDesc,void *lpContext);
  680. extern "C" HRESULT PASCAL myEnumModesCallback(LPDDSURFACEDESC lpDDSurfaceDesc,
  681. void *lpContext);
  682. extern "C" HRESULT myEnumOverlayZOrdersCallback(LPDIRECTDRAWSURFACE lpDDS,
  683. void *lpContext);
  684. extern "C" HRESULT PASCAL myEnumDevicesCallback( LPGUID Guid, LPSTR DevDesc,
  685. LPSTR DevName, LPD3DDEVICEDESC lpD3DHWDevDesc,
  686. LPD3DDEVICEDESC lpD3DHELDevDesc, void *lpArg);
  687. extern "C" void myd3dValidateCallback(void *lpArg, DWORD offset);
  688. extern "C" HRESULT myEnumTextureFormatsCallback(
  689. LPDDSURFACEDESC lpDdsd, void *lpArg);
  690. extern "C" void __cdecl myAddDestroyCallback(LPDIRECT3DRMOBJECT lpObj,void *lpArg);
  691. extern "C" void __cdecl myd3drmLoadCallback(LPDIRECT3DRMOBJECT lpo,
  692. REFIID ObjectGuid, LPVOID lpArg);
  693. extern "C" HRESULT WINAPI myEnumVideoCallback( LPDDVIDEOPORTCAPS lpDDVideoPortCaps, LPVOID lpContext );
  694. extern "C" BOOL WINAPI myDirectDrawEnumCallback( GUID FAR *lpGUID, LPSTR lpDriverDescription,
  695. LPSTR lpDriverName, LPVOID lpContext );
  696. extern "C" BOOL CALLBACK myEnumDeviceObjectsCallback( LPCDIDEVICEOBJECTINSTANCE pI, LPVOID lpArg ) ;
  697. extern "C" BOOL CALLBACK myEnumCreatedEffectObjectsCallback(LPDIRECTINPUTEFFECT peff, LPVOID lpArg );
  698. extern "C" BOOL CALLBACK myEnumEffectsCallback( LPCDIEFFECTINFO pdei, LPVOID lpArg );
  699. extern "C" BOOL CALLBACK myEnumInputDevicesCallback( LPDIDEVICEINSTANCE lpddi, LPVOID pvRef );
  700. //////////////////////////////////////////////////////////////////////////
  701. extern "C" TextureCallback *TextureCallbacks; //d3drmTexture3
  702. extern "C" TextureCallback3 *TextureCallbacks3; //d3drmTexture3
  703. extern "C" FrameMoveCallback3 *FrameMoveCallbacks3; //d3drmFrame3
  704. extern "C" DeviceUpdateCallback3 *DeviceUpdateCallbacks3;
  705. extern "C" EnumerateObjectsCallback *EnumCallbacks;
  706. extern "C" LoadCallback *LoadCallbacks;
  707. extern "C" DestroyCallback *DestroyCallbacks;
  708. extern HRESULT CopyInDDSuraceDesc2(DDSURFACEDESC2 *dOut,DDSurfaceDesc2 *d);
  709. extern HRESULT CopyInDDPixelFormat(DDPIXELFORMAT *pfOut, DDPixelFormat *pf);
  710. extern HRESULT CopyOutDDSurfaceDesc2(DDSurfaceDesc2 *dOut,DDSURFACEDESC2 *d);
  711. extern HRESULT CopyOutDDPixelFormat(DDPixelFormat *pfOut, DDPIXELFORMAT *pf);
  712. extern HRESULT CreateCoverObject(LPDIRECT3DRMOBJECT lp, I_dxj_Direct3dRMObject** f);
  713. extern HRESULT CreateCoverVisual(LPDIRECT3DRMOBJECT lp, I_dxj_Direct3dRMVisual** v);
  714. /*
  715. **********************************************************************
  716. * INTERNAL_CREATE(thisClass, var, retval)
  717. * thisClass class we are working on
  718. * var variable created in routine to get DirectX object
  719. * retval return value back to java
  720. *
  721. * wrap a DirectX object in one of ours and shove it in the return value
  722. ***********************************************************************
  723. * INTERNAL_CREATE_NOREL(thisClass, var, retval)
  724. * thisClass class we are working on
  725. * var variable created in routine to get DirectX object
  726. * retval return value back to java
  727. *
  728. * wrap a DirectX object in one of ours and shove it in the return value
  729. * If the layer obejct fails, DONT release the DirectX object
  730. ***********************************************************************
  731. * DO_GETOBJECT_NOTNULL(type,var,iface)
  732. * type type of variable we are creating
  733. * var variable we are creating
  734. * iface layer iface where we are getting the object from
  735. *
  736. * declare and get a DirectX object from a layer object
  737. ***********************************************************************
  738. * DO_GETOBJECT_NOTNULL(type,var,iface)
  739. * type type of variable we are creating
  740. * var variable we are creating
  741. * iface layer iface where we are getting the object from
  742. *
  743. * same as DO_GETOBJECT_NOTNULL except that we check for iface==NULL before calling
  744. ***********************************************************************
  745. * PASS_THROUGH[x](class,method,[...])
  746. * class this class
  747. * method method to call
  748. *
  749. * pass call straight through
  750. ***********************************************************************
  751. * PASS_THROUGH_CAST_[x](class,method,[...])
  752. * class this class
  753. * method method to call
  754. *
  755. * pass call straight through, casting the parameters to allow the call to pass
  756. ***********************************************************************
  757. * RETURN_NEW_ITEM(thisClass,method,OtherClass)
  758. * thisClass class being worked on
  759. * method method working on
  760. * otherClass class whose object we want
  761. *
  762. * call DirectX method to get the DirectX object, then wrap it in one of our layer
  763. * objects
  764. ***********************************************************************
  765. * RETURN_NEW_ITEM[1,2](thisClass,method,OtherClass,type)
  766. * thisClass class being worked on
  767. * method method working on
  768. * otherClass class whose object we want
  769. * type type of parameter
  770. *
  771. * Same as RETURN_NEWITEM except that there is an extra parameter (or two) BEFORE the
  772. * returned one
  773. ***********************************************************************
  774. * RETURN_NEW_ITEM_CAST_[1,2](thisClass,method,OtherClass,type)
  775. * thisClass class being worked on
  776. * method method working on
  777. * otherClass class whose object we want
  778. * type type of parameter
  779. *
  780. * Same as RETURN_NEW_ITEM[1,2] except that there the extra parameter(s) are type cast
  781. ******************************************************************************
  782. * RETURN_NEW_ITEM_NOREL(thisClass,method,OtherClass)
  783. * thisClass class being worked on
  784. * method method working on
  785. * otherClass class whose object we want
  786. *
  787. * same as RETURN_NEW_ITEM except that calls INTERNAL_CREATE_NOTREL instead of
  788. * INTERNAL_CREATE
  789. ******************************************************************************
  790. * GET_DIRECT(cl,met,t)
  791. * class class being worked on
  792. * method method being worked on
  793. * t type of the variable being returned
  794. *
  795. * DirectX returns value directly (no HRESULT), we get the value from Direct and
  796. * then return S_OK. (see CddSurfaceObject::Restore, may need to be added).
  797. * Note: the value is passed back via a pointer to that value.
  798. ******************************************************************************
  799. * GET_DIRECT[1,2](cl,met,t,t1)
  800. * class class being worked on
  801. * method method being worked on
  802. * t type of the variable being returned
  803. * t1 type of extra variable(s) BEFORE retval
  804. *
  805. * same as GET_DIRECT but there is another parameter (or two) BEFORE the returned one
  806. ****************************************************************************************
  807. * GET_DIRECTPTR(cl,met,t)
  808. * class class being worked on
  809. * method method being worked on
  810. * t type of the variable being returned
  811. *
  812. * DirectX returns a pointer to a value directly (no HRESULT), we get the value from
  813. * Direct and then return S_OK. In this case it is a pointer to a pointer.
  814. ***************************************************************************************
  815. * GET_DIRECTPTR[1,2](cl,met,t,t1)
  816. * class class being worked on
  817. * method method being worked on
  818. * t type of the variable being returned
  819. * t1 type of extra variable(s) BEFORE retval
  820. *
  821. * same as GET_DIRECTPTR but there is a parameter (or two) BEFORE the one returned.
  822. ***************************************************************************************
  823. * DO_GETOBJECT_ANDUSEIT(cl,me,iface)
  824. * class class being worked on
  825. * method method being worked on
  826. * iface secondary interface we are interested in
  827. *
  828. * get an internal object from iface and use it in the method. we return from the method
  829. ***************************************************************************************
  830. * DO_GETOBJECT_ANDUSEIT_CAST(cl,me,iface,type)
  831. * class class being worked on
  832. * method method being worked on
  833. * iface secondary interface we are interested in
  834. * type type to cast to in the actual call.
  835. * get an internal object from iface and use it in the method. we return from the method
  836. ***************************************************************************************
  837. * DO_GETOBJECT_ANDUSEIT[1,2](cl,me,iface,ty)
  838. * class class being worked on
  839. * method method being worked on
  840. * iface secondary interface we are interested in
  841. * type type of parameter BEFORE 2nd object
  842. *
  843. * same as DO_GETOBJECT_ANDUSEIT except there is another parameter (or two) BEFORE
  844. * the object one
  845. ************************************************************************************
  846. * CLONE(cl)
  847. * class class to clone
  848. *
  849. * >>>>>>> THIS IS A D3DRMOBJECT METHOD <<<<<<<<<<
  850. ************************************************************************************
  851. * GETNAME(cl)
  852. * class class to retive name of
  853. * >>>>>>> THIS IS A D3DRMOBJECT METHOD <<<<<<<<<<
  854. ************************************************************************************
  855. * GETCLASSNAME(cl)
  856. * class class to retive name of
  857. * >>>>>>> THIS IS A D3DRMOBJECT METHOD <<<<<<<<<<
  858. ************************************************************************************
  859. * DELETEDESTROYCALLBACK(cl)
  860. * class class to retive name of
  861. * >>>>>>> THIS IS A D3DRMOBJECT METHOD <<<<<<<<<<
  862. ************************************************************************************
  863. * QIOVERLOAD(cl, ifaceThat, clThat)
  864. * class class being worked on
  865. * iface iface of DIRECT object. Should really typedef_## this!
  866. * clThat object we are going to create
  867. *
  868. * this is really bright - overloading QI to get new objects
  869. ************************************************************************************
  870. * CLONETO(cl, clThat, ifaceThat)
  871. * class class being worked on
  872. * iface iface of DIRECT object. Should really typedef_## this!
  873. * clThat object we are going to create
  874. *
  875. * this is really bright - overloading QI to get new objects
  876. ************************************************************************************
  877. */
  878. extern void *g_dxj_DirectDraw7;
  879. extern void *g_dxj_Direct3dTexture7;
  880. extern void *g_dxj_DirectDrawSurface7;
  881. extern void *g_dxj_Direct3dDevice7;
  882. extern void *g_dxj_Direct3dVertexBuffer7;
  883. extern void *g_dxj_Direct3d7;
  884. extern void *g_dxj_DirectDrawSurface4;
  885. extern void *g_dxj_Direct3dDevice3;
  886. extern void *g_dxj_Direct3dLight;
  887. extern void *g_dxj_Direct3dMaterial3;
  888. extern void *g_dxj_Direct3dVertexBuffer;
  889. extern void *g_dxj_Direct3d3;
  890. extern void *g_dxj_Direct3dRMAnimation2;
  891. extern void *g_dxj_Direct3dRMAnimationSet2;
  892. extern void *g_dxj_Direct3dRMObjectArray;
  893. extern void *g_dxj_Direct3dRMDeviceArray;
  894. extern void *g_dxj_Direct3dRMDevice3;
  895. extern void *g_dxj_Direct3dRMFaceArray;
  896. extern void *g_dxj_Direct3dRMFace2;
  897. extern void *g_dxj_Direct3dRMFrameArray;
  898. extern void *g_dxj_Direct3dRMFrame3;
  899. extern void *g_dxj_Direct3dRMLightArray;
  900. extern void *g_dxj_Direct3dRMLight;
  901. extern void *g_dxj_Direct3dRMMaterial2;
  902. extern void *g_dxj_Direct3dRMMeshBuilder3;
  903. extern void *g_dxj_Direct3dRMMesh;
  904. extern void *g_dxj_Direct3dRMProgressiveMesh;
  905. extern void *g_dxj_Direct3dRMObject;
  906. extern void *g_dxj_Direct3dRMPickArray;
  907. extern void *g_dxj_Direct3dRMPick2Array;
  908. extern void *g_dxj_Direct3dRMShadow2;
  909. extern void *g_dxj_Direct3dRMTexture3;
  910. extern void *g_dxj_Direct3dRMUserVisual;
  911. extern void *g_dxj_Direct3dRMViewportArray;
  912. extern void *g_dxj_Direct3dRMVisualArray;
  913. extern void *g_dxj_Direct3dRMVisual;
  914. extern void *g_dxj_Direct3dRMClippedVisual;
  915. extern void *g_dxj_Direct3dRMWinDevice;
  916. extern void *g_dxj_Direct3dRMWrap;
  917. extern void *g_dxj_Direct3dTexture2;
  918. extern void *g_dxj_Direct3dViewport3;
  919. extern void *g_dxj_DirectDrawClipper;
  920. extern void *g_dxj_DirectDrawPalette;
  921. extern void *g_dxj_DirectDraw4;
  922. extern void *g_dxj_DDVideoPortContainer;
  923. extern void *g_dxj_DirectDrawVideoPort;
  924. extern void *g_dxj_DirectDrawColorControl;
  925. extern void *g_dxj_DirectSound3dListener;
  926. extern void *g_dxj_DirectSoundBuffer;
  927. extern void *g_dxj_DirectSound3dBuffer;
  928. extern void *g_dxj_DirectSound;
  929. extern void *g_dxj_DirectSoundCapture;
  930. extern void *g_dxj_DirectSoundCaptureBuffer;
  931. extern void *g_dxj_DirectSoundNotify;
  932. extern void *g_dxj_DirectPlay3;
  933. extern void *g_dxj_DirectPlayLobby2;
  934. extern void *g_dxj_Direct3dRM3;
  935. extern void *g_dxj_Direct3dRMViewport2;
  936. extern void *g_dxj_DirectInput;
  937. extern void *g_dxj_DirectInputDevice;
  938. extern void *g_dxj_DirectInputEffect;
  939. extern void *g_dxj_DPAddress;
  940. extern void *g_dxj_DPLConnection;
  941. extern void *g_dxj_DirectDrawGammaControl;
  942. extern void *g_dxj_DirectPlay4;
  943. extern void *g_dxj_DirectPlayLobby3;
  944. #define DXHEAPALLOC malloc
  945. #define DXSTACKALLOC lalloc
  946. #define DXHEAPFREE free
  947. #define DXALLOCBSTR SysAllocString