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.

857 lines
41 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. extern long g_debuglevel;
  19. #ifdef DEBUG
  20. #define DPF(n,o) {if (g_debuglevel >= n) { OutputDebugString(o);}}
  21. #define DPF1(n,o,p) {if (g_debuglevel >= n) {char szOutN[1024]; wsprintf(szOutN,o,p);OutputDebugString(szOutN);}}
  22. #define DPF2(n,o,p,e) {if (g_debuglevel >= n) {char szOutN[1024]; wsprintf(szOutN,o,p,e);OutputDebugString(szOutN);}}
  23. #else
  24. #ifdef DBG
  25. #define DPF(n,o) {if (g_debuglevel >= n) { OutputDebugString(o);}}
  26. #define DPF1(n,o,p) {if (g_debuglevel >= n) {char szOutN[1024]; wsprintf(szOutN,o,p);OutputDebugString(szOutN);}}
  27. #define DPF2(n,o,p,e) {if (g_debuglevel >= n) {char szOutN[1024]; wsprintf(szOutN,o,p,e);OutputDebugString(szOutN);}}
  28. #else
  29. #define DPF(n,o)
  30. #define DPF1(n,o,p)
  31. #define DPF2(n,o,p,e)
  32. #endif
  33. #endif
  34. #define INTERNAL_CREATE_RETOBJ(objType,objOther,retval,classobj) \
  35. { C##objType##Object *prev=NULL; \
  36. *retval = NULL; \
  37. for(C##objType##Object *ptr=(C##objType##Object *)g##objType##; ptr; ptr=(C##objType##Object *)ptr->nextobj) \
  38. { IUnknown *unk=0; \
  39. ptr->InternalGetObject(&unk); \
  40. if(unk == objOther) \
  41. { \
  42. *retval = (I##objType*)ptr->pinterface; \
  43. IUNK(ptr->pinterface)->AddRef(); \
  44. IUNK(objOther)->Release(); \
  45. classobj=ptr; \
  46. break; \
  47. } \
  48. prev = ptr; \
  49. } \
  50. if(!ptr) \
  51. { C##objType##Object *c=new CComObject<C##objType##Object>;if( c == NULL ) { objOther->Release(); return E_FAIL;} \
  52. c->parent = this; \
  53. ((I##objType *)this)->AddRef(); \
  54. c->InternalSetObject(objOther); \
  55. if (FAILED( ((I##objType *)c)->QueryInterface(IID_I##objType, (void **)retval))) \
  56. return E_FAIL; \
  57. c->pinterface = (void*)*retval; \
  58. classobj=c; \
  59. } }
  60. #define INTERNAL_CREATE_STRUCT(objType,retval) { C##objType##Object *c=new CComObject<C##objType##Object>;\
  61. if (c==NULL) return E_OUTOFMEMORY;\
  62. if (FAILED(((I##objType *)c)->QueryInterface(IID_I##objType, (void **)retval))) return E_FAIL;\
  63. }
  64. #define INTERNAL_CREATE_NOADDREF(objType,objOther,retval) {C##objType##Object *prev=NULL; *retval = NULL; \
  65. 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; } \
  66. 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; }}
  67. // Given a java interface (objtype), envoke InternalSetObject and set the given
  68. // DIRECTX pointer (objOther). Also envoke QueryInterface and set a ** interface
  69. // ptr to a DIRECTX object (retval). So we create a DIRECTX object.
  70. //#define INTERNAL_CREATE(objType,objOther,retval){C##objType##Object *c=new CComObject<C##objType##Object>;if( c == NULL ) { objOther->Release(); return E_FAIL;} \
  71. //c->parent = this; AddRef(); c->InternalSetObject(objOther);if (FAILED(c->QueryInterface(IID_I##objType, (void **)retval))) return E_FAIL; }
  72. // if (FAILED(ptr->QueryInterface(IID_I##objType, (void **)retval))) return E_FAIL;
  73. #ifdef _DEBUG
  74. #define INTERNAL_CREATE(objType,objOther,retval) \
  75. { \
  76. DWORD refcount; char buffer[256]; wsprintf(buffer,"INTERNAL_CREATE %s \n",__FILE__); \
  77. OutputDebugString(buffer); \
  78. C##objType##Object *prev=NULL; \
  79. *retval = NULL; \
  80. for(C##objType##Object *ptr=(C##objType##Object *)g##objType##; ptr; ptr=(C##objType##Object *)ptr->nextobj) \
  81. {\
  82. IUnknown *unk=0; \
  83. ptr->InternalGetObject(&unk); \
  84. if(unk == objOther) \
  85. { \
  86. *retval = (I##objType*)ptr->pinterface;\
  87. IUNK(ptr->pinterface)->AddRef();\
  88. IUNK(objOther)->Release(); \
  89. refcount = *(((DWORD*)ptr)+1); \
  90. wsprintf(buffer," Retrived Object [%s] RefCount %d \n\r",__FILE__, refcount);\
  91. OutputDebugString(buffer);\
  92. break; \
  93. } \
  94. prev = ptr; \
  95. } \
  96. if(!ptr) \
  97. { \
  98. C##objType##Object *c=new CComObject<C##objType##Object>;if( c == NULL ) { objOther->Release(); return E_FAIL;} \
  99. c->parent = this; \
  100. ((I##objType *)this)->AddRef(); \
  101. refcount = *(((DWORD*)this)+1); \
  102. wsprintf(buffer,"Object [%s] RefCount[%d]\n\r",__FILE__, refcount);\
  103. OutputDebugString(buffer);\
  104. c->InternalSetObject(objOther);if (FAILED(( ((I##objType *)c))->QueryInterface(IID_I##objType, (void **)retval))) return E_FAIL; \
  105. c->pinterface = (void*)*retval; \
  106. } \
  107. }
  108. #else
  109. #define INTERNAL_CREATE(objType,objOther,retval) \
  110. { \
  111. C##objType##Object *prev=NULL; \
  112. *retval = NULL; \
  113. for(C##objType##Object *ptr=(C##objType##Object *)g##objType##; ptr; ptr=(C##objType##Object *)ptr->nextobj) \
  114. {\
  115. IUnknown *unk=0; \
  116. ptr->InternalGetObject(&unk); \
  117. if(unk == objOther) \
  118. { \
  119. *retval = (I##objType*)ptr->pinterface; \
  120. IUNK(ptr->pinterface)->AddRef(); \
  121. IUNK(objOther)->Release(); \
  122. break; \
  123. } \
  124. prev = ptr; \
  125. } \
  126. if(!ptr) \
  127. { \
  128. C##objType##Object *c=new CComObject<C##objType##Object>;if( c == NULL ) { objOther->Release(); return E_FAIL;} \
  129. c->parent = this; \
  130. ((I##objType *)this)->AddRef(); \
  131. c->InternalSetObject(objOther); \
  132. if (FAILED( ((I##objType *)c)->QueryInterface(IID_I##objType, (void **)retval))) return E_FAIL; \
  133. c->pinterface = (void*)*retval; \
  134. } \
  135. }
  136. #endif
  137. #define INTERNAL_CREATE_NO_PARENT(objType,objOther,retval) \
  138. { \
  139. C##objType##Object *prev=NULL; \
  140. *retval = NULL; \
  141. for(C##objType##Object *ptr=(C##objType##Object *)g##objType##; ptr; ptr=(C##objType##Object *)ptr->nextobj) \
  142. {\
  143. IUnknown *unk=0; \
  144. ptr->InternalGetObject(&unk); \
  145. if(unk == objOther) \
  146. { \
  147. *retval = (I##objType*)ptr->pinterface; \
  148. IUNK(ptr->pinterface)->AddRef(); \
  149. IUNK(objOther)->Release(); \
  150. break; \
  151. } \
  152. prev = ptr; \
  153. } \
  154. if(!ptr) \
  155. { \
  156. C##objType##Object *c=new CComObject<C##objType##Object>;if( c == NULL ) { objOther->Release(); return E_FAIL;} \
  157. c->InternalSetObject(objOther); \
  158. if (FAILED( ((I##objType *)c)->QueryInterface(IID_I##objType, (void **)retval))) return E_FAIL; \
  159. c->pinterface = (void*)*retval; \
  160. } \
  161. }
  162. #define INTERNAL_CREATE_ADDRESS(objType,objOther,retval) \
  163. { \
  164. C##objType##Object *c=new CComObject<C##objType##Object>;if( c == NULL ) { objOther->Release(); return E_FAIL;} \
  165. c->InternalSetObject(objOther); \
  166. if (FAILED( ((I##objType *)c)->QueryInterface(IID_I##objType, (void **)retval))) return E_FAIL; \
  167. c->pinterface = (void*)*retval; \
  168. }
  169. #define INTERNAL_CREATE_2REFS(objType,objParentType,objParent, objOther,retval) \
  170. { \
  171. C##objType##Object *prev=NULL; \
  172. *retval = NULL; \
  173. for(C##objType##Object *ptr=(C##objType##Object *)g##objType##; ptr; ptr=(C##objType##Object *)ptr->nextobj) \
  174. {\
  175. IUnknown *unk=0; \
  176. ptr->InternalGetObject(&unk); \
  177. if(unk == objOther) \
  178. { \
  179. *retval = (I##objType*)ptr->pinterface; \
  180. IUNK(ptr->pinterface)->AddRef(); \
  181. IUNK(objOther)->Release(); \
  182. break; \
  183. } \
  184. prev = ptr; \
  185. } \
  186. if(!ptr) \
  187. { \
  188. C##objType##Object *c=new CComObject<C##objType##Object>;if( c == NULL ) { objOther->Release(); return E_FAIL;} \
  189. c->parent = this; \
  190. c->parent2 = IUNK(objParent); \
  191. ((I##objType *)this)->AddRef(); \
  192. ((I##objParentType*)objParent)->AddRef(); \
  193. c->InternalSetObject(objOther); \
  194. if (FAILED( ((I##objType *)c)->QueryInterface(IID_I##objType, (void **)retval))) return E_FAIL; \
  195. c->pinterface = (void*)*retval; \
  196. } \
  197. }
  198. #define INTERNAL_CREATE_1REFS(objType,objParentType,objParent, objOther,retval) \
  199. { \
  200. C##objType##Object *prev=NULL; \
  201. *retval = NULL; \
  202. for(C##objType##Object *ptr=(C##objType##Object *)g##objType##; ptr; ptr=(C##objType##Object *)ptr->nextobj) \
  203. {\
  204. IUnknown *unk=0; \
  205. ptr->InternalGetObject(&unk); \
  206. if(unk == objOther) \
  207. { \
  208. *retval = (I##objType*)ptr->pinterface; \
  209. IUNK(ptr->pinterface)->AddRef(); \
  210. IUNK(objOther)->Release(); \
  211. break; \
  212. } \
  213. prev = ptr; \
  214. } \
  215. if(!ptr) \
  216. { \
  217. C##objType##Object *c=new CComObject<C##objType##Object>; \
  218. if( c == NULL ) \
  219. { objOther->Release(); return E_FAIL;} \
  220. c->parent = IUNK(objParent); \
  221. ((I##objParentType*)objParent)->AddRef(); \
  222. c->InternalSetObject(objOther); \
  223. if (FAILED( ((I##objType *)c)->QueryInterface(IID_I##objType, (void **)retval))) return E_FAIL; \
  224. c->pinterface = (void*)*retval; \
  225. } \
  226. }
  227. /////////////////////////////////////////////////////////////////////////
  228. #define MAX_INTERNAL_STR_LEN 256
  229. struct JavaString
  230. {
  231. DWORD nBytes;
  232. WCHAR Item[MAX_INTERNAL_STR_LEN];
  233. };
  234. /////////////////////////////////////////////////////////////////////////
  235. /////////////////////////////////////////////////////////////////////////
  236. // mod:dp helper macros for stuffing expanded unions in DirectX Structures
  237. #define IUNK(o) ((IUnknown*)(void*)(o))
  238. #define IS_NULLGUID(g) (\
  239. (g->data1==0) && \
  240. (g->data2==0) && \
  241. (g->data3==0) && \
  242. (g->data4[0]==0) && \
  243. (g->data4[1]==0) && \
  244. (g->data4[2]==0) && \
  245. (g->data4[3]==0) && \
  246. (g->data4[4]==0) && \
  247. (g->data4[5]==0) && \
  248. (g->data4[6]==0) && \
  249. (g->data4[7]==0) )
  250. /////////////////////////////////////////////////////////////////////////
  251. #define JAVASTRING(item) {sizeof(item)*2-2, L##item}
  252. #define PASS_THROUGH(cl,m) STDMETHODIMP C##cl##Object::m() { return m_##cl->m();}
  253. #define PASS_THROUGH1(c,m,t1) STDMETHODIMP C##c##Object::m(t1 v1) { return m_##c->m(v1);}
  254. #define PASS_THROUGH2(c,m,t1,t2) STDMETHODIMP C##c##Object::m(t1 v1, t2 v2) { return m_##c->m(v1, v2);}
  255. #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);}
  256. #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);}
  257. #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);}
  258. #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);}
  259. #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);}
  260. #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);}
  261. #define PASS_THROUGH_CAST_1(c,m,t1,tt1) STDMETHODIMP C##c##Object::m(t1 v1) { return m_##c->m(tt1 v1);}
  262. #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);}
  263. #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);}
  264. #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);}
  265. #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);}
  266. #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);}
  267. #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);}
  268. #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);}
  269. //mod:dp additions due to renaming
  270. #define PASS_THROUGH_R(c,m1,m2) STDMETHODIMP C##c##Object::m1() { if(m_##c==NULL)return E_FAIL; return m_##c->m2();}
  271. #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);}
  272. #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);}
  273. #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);}
  274. #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);}
  275. #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);}
  276. #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);}
  277. #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);}
  278. #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);}
  279. #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);}
  280. #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);}
  281. #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);}
  282. #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);}
  283. #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);}
  284. #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);}
  285. #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);}
  286. #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);}
  287. #define COPY_OR_CLEAR(dest, src, si) {if(src) memcpy((void *)dest, (void *)src, si);else memset((void *)dest, si, 0);}
  288. #define COPY(dest, src, si) memcpy((void *)dest, (void *)src, si)
  289. // ??
  290. #define DECLSET_OBJECT(ifacevar, var, typ) {if(var) var->Release(); var = (typ)ifacevar;}
  291. #define DECLGET_OBJECT(ifacevar, var){*ifacevar = (IUnknown *)var;}
  292. #define ISEQUAL(c) \
  293. STDMETHODIMP C##c##Object::isEqual(I##c *d, int *retval)\
  294. { IUnknown *IU1;\
  295. IUnknown *IU2;\
  296. if (d == NULL)\
  297. return E_FAIL; \
  298. this->InternalGetObject((IUnknown **)(&IU1)); \
  299. d->InternalGetObject((IUnknown **)(&IU2)); \
  300. if (IU1 == IU2) \
  301. *retval = TRUE; \
  302. else \
  303. *retval = FALSE; \
  304. return S_OK;}
  305. #define DX3J_GLOBAL_LINKS( obj_type ) \
  306. int creationid;\
  307. void *parent; \
  308. void *pinterface; \
  309. void *nextobj;
  310. /*STDMETHOD(isEqual)(IUnknown *pobj, int *ret)*/;
  311. // Given a class (c)
  312. #define GETSET_OBJECT(c) \
  313. STDMETHODIMP C##c##Object::InternalSetObject(IUnknown *l)\
  314. {DECLSET_OBJECT(l,m_##c,typedef_##c);return S_OK;} \
  315. STDMETHODIMP C##c##Object::InternalGetObject(IUnknown **l)\
  316. {DECLGET_OBJECT(l,m_##c);return S_OK;}
  317. //ISEQUAL(c);
  318. // Given a java interface, go get a pointer_to_a_pointer to a DIRECTX object
  319. //pac DO_GETOBJECT_NOTNULL is too dangerous and is commented. use DO_GETOBJECT_NOTNULL
  320. //#define DO_GETOBJECT(t,v,i) t v;i->InternalGetObject((IUnknown **)(&v));
  321. #define DO_GETOBJECT_NOTNULL(t,v,i) t v=NULL;if(i) i->InternalGetObject((IUnknown **)(&v));
  322. //
  323. extern int g_creationcount;
  324. #ifdef _DEBUG
  325. #define CONSTRUCTOR(c, o) C##c##Object::C##c##Object(){ \
  326. m_##c = NULL; parent = NULL; pinterface = NULL; \
  327. nextobj = g##c##;\
  328. creationid = ++g_creationcount;\
  329. char buffer[256];\
  330. wsprintf(buffer,"Constructor Creation Id [%d] %s",g_creationcount,__FILE__);\
  331. OutputDebugString(buffer);\
  332. g##c## = (void *)this; o }
  333. #else
  334. #define CONSTRUCTOR(c, o) C##c##Object::C##c##Object(){ \
  335. m_##c = NULL; parent = NULL; pinterface = NULL; \
  336. nextobj = (void*)g##c##; \
  337. creationid = ++g_creationcount; \
  338. g##c## = (void*)this; o}
  339. #endif
  340. #ifdef _DEBUG
  341. #define DESTRUCTOR(c, o) C##c##Object::~C##c##Object(){o; \
  342. char buffer[256]; \
  343. wsprintf(buffer,"Destructor Id[%d] %s ",creationid,__FILE__); \
  344. OutputDebugString(buffer); C##c##Object *prev=NULL; \
  345. for(C##c##Object *ptr=(C##c##Object *)g##c##; ptr; ptr=(C##c##Object *)ptr->nextobj) \
  346. {\
  347. if(ptr == this) \
  348. { \
  349. if(prev) \
  350. prev->nextobj = ptr->nextobj; \
  351. else \
  352. g##c## = (void*)ptr->nextobj; \
  353. break; \
  354. } \
  355. prev = ptr; \
  356. } \
  357. if(m_##c){ int count = IUNK(m_##c)->Release(); wsprintf(buffer,"DirectX %s Ref count [%d]",__FILE__,count); OutputDebugString(buffer); \
  358. if(count==0){ char szOut[512];wsprintf(szOut,"\n Real %s released \n",__FILE__); OutputDebugString(szOut); m_##c = NULL; } \
  359. } \
  360. if(parent) IUNK(parent)->Release(); \
  361. }
  362. #else
  363. #define DESTRUCTOR(c, o) C##c##Object::~C##c##Object(){o; \
  364. C##c##Object *prev=NULL; \
  365. for(C##c##Object *ptr=(C##c##Object *)g##c##; ptr; ptr=(C##c##Object *)ptr->nextobj) \
  366. {\
  367. if(ptr == this) \
  368. { \
  369. if(prev) \
  370. prev->nextobj = ptr->nextobj; \
  371. else \
  372. g##c## = (void*)ptr->nextobj; \
  373. break; \
  374. } \
  375. prev = ptr; \
  376. } \
  377. if(m_##c){ \
  378. if (IUNK(m_##c)->Release()==0) m_##c = NULL; \
  379. } \
  380. if(parent) IUNK(parent)->Release();\
  381. }
  382. #endif
  383. #define OBJCHECK(lable, c) { \
  384. char buffer[256];\
  385. if ( g##c ) \
  386. {\
  387. int count = 0; \
  388. C##c##Object *prev=NULL; \
  389. C##c##Object *ptr;\
  390. for(ptr=(C##c##Object *)g##c##; ptr; ptr=(C##c##Object *)ptr->nextobj) \
  391. {\
  392. DWORD refcount = *(((DWORD*)ptr)+1);\
  393. wsprintf( buffer,"%s: Ref Count [%d] CreateId [%d]\n\r",lable,refcount,ptr->creationid);\
  394. OutputDebugString(buffer);\
  395. count++;\
  396. }\
  397. wsprintf(buffer,"%s: %d \n\r",lable,count);\
  398. OutputDebugString(buffer);\
  399. }\
  400. }
  401. #ifdef _DEBUG
  402. #define CONSTRUCTOR_STRUCT(c, o) C##c##Object::C##c##Object(){ nextobj = g##c##;\
  403. creationid = ++g_creationcount;\
  404. char buffer[256];\
  405. wsprintf(buffer,"Creation Id [%d]",g_creationcount);\
  406. OutputDebugString(buffer);\
  407. g##c## = (void*)this;o}
  408. #else
  409. #define CONSTRUCTOR_STRUCT(c, o) C##c##Object::C##c##Object(){ \
  410. nextobj =(void*) g##c##; \
  411. creationid = ++g_creationcount; \
  412. g##c## = (void*)this; \
  413. o}
  414. #endif
  415. #define DESTRUCTOR_STRUCT(c, o) C##c##Object::~C##c##Object(){o; \
  416. C##c##Object *prev=NULL; \
  417. for(C##c##Object *ptr=(C##c##Object *)g##c##; ptr; ptr=(C##c##Object *)ptr->nextobj) \
  418. {\
  419. if(ptr == this) \
  420. { \
  421. if(prev) \
  422. prev->nextobj = ptr->nextobj; \
  423. else \
  424. g##c## = (void*)ptr->nextobj; \
  425. break; \
  426. } \
  427. prev = ptr; \
  428. } \
  429. }
  430. // Given a java class (c), create a DIRECTX object and an interface ** ptr to it.
  431. #define RETURN_NEW_ITEM(c,m,oc) STDMETHODIMP C##c##Object::m(I##oc **rv){typedef_##oc lp;\
  432. if( m_##c->m(&lp) != S_OK)return E_FAIL;INTERNAL_CREATE(oc, lp, rv);\
  433. return S_OK;}
  434. #define RETURN_NEW_ITEM_CAST(c,m,oc, ty) STDMETHODIMP C##c##Object::m(I##oc **rv){typedef_##oc lp;\
  435. if( m_##c->m(ty &lp) != S_OK)return E_FAIL;INTERNAL_CREATE(oc, lp, rv);\
  436. return S_OK;}
  437. #define RETURN_NEW_ITEM_NOREL(c,m,oc) STDMETHODIMP C##c##Object::m(I##oc **rv){typedef_##oc lp;\
  438. if( m_##c->m(&lp) != S_OK)return E_FAIL;INTERNAL_CREATE_NOREL(oc, lp, rv);\
  439. return S_OK;}
  440. #define RETURN_NEW_ITEM1(c,m,oc,t1) STDMETHODIMP C##c##Object::m(t1 v1, I##oc **rv){typedef_##oc lp;\
  441. if( m_##c->m(v1,&lp) != S_OK)return E_FAIL;INTERNAL_CREATE(oc, lp, rv);\
  442. return S_OK;}
  443. #define RETURN_NEW_ITEM2(c,m,oc,t1,t2) STDMETHODIMP C##c##Object::m(t1 v1, t2 v2,I##oc **rv){typedef_##oc lp;\
  444. if( m_##c->m(v1,v2,&lp) != S_OK)return E_FAIL;INTERNAL_CREATE(oc, lp, rv);\
  445. return S_OK;}
  446. #define RETURN_NEW_ITEM_CAST_1(c,m,oc,t1,tt1) STDMETHODIMP C##c##Object::m(t1 v1, I##oc **rv){typedef_##oc lp;\
  447. if( m_##c->m(tt1 v1,&lp) != S_OK)return E_FAIL;INTERNAL_CREATE(oc, lp, rv);\
  448. return S_OK;}
  449. #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;\
  450. if( m_##c->m(tt1 v1,tt2 v2,&lp) != S_OK)return E_FAIL;INTERNAL_CREATE(oc, lp, rv);\
  451. return S_OK;}
  452. #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;\
  453. if( m_##c->m(tt1 v1,tt2 v2,tt3 v3,&lp) != S_OK)return E_FAIL;INTERNAL_CREATE(oc, lp, rv);\
  454. return S_OK;}
  455. //mod:dp additions due to renaming
  456. // Given a java class (c), create a DIRECTX object and an interface ** ptr to it.
  457. #define RETURN_NEW_ITEM_R(c,m,m2,oc) STDMETHODIMP C##c##Object::m(I##oc **rv){typedef_##oc lp;\
  458. if( m_##c->m2(&lp) != S_OK)return E_FAIL;INTERNAL_CREATE(oc, lp, rv);\
  459. return S_OK;}
  460. #define RETURN_NEW_ITEM1_R(c,m,m2,oc,t1) STDMETHODIMP C##c##Object::m(t1 v1, I##oc **rv){typedef_##oc lp;\
  461. if( m_##c->m2(v1,&lp) != S_OK)return E_FAIL;INTERNAL_CREATE(oc, lp, rv);\
  462. return S_OK;}
  463. #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;\
  464. if( m_##c->m2(v1,v2,&lp) != S_OK)return E_FAIL;INTERNAL_CREATE(oc, lp, rv);\
  465. return S_OK;}
  466. #define RETURN_NEW_ITEM_CAST_R(c,m,m2,oc,ty) STDMETHODIMP C##c##Object::m(I##oc **rv){typedef_##oc lp;\
  467. if( m_##c->m2(ty &lp) != S_OK)return E_FAIL;INTERNAL_CREATE(oc, lp, rv);\
  468. return S_OK;}
  469. #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;\
  470. if( m_##c->m2(tt1 v1,&lp) != S_OK)return E_FAIL;INTERNAL_CREATE(oc, lp, rv);\
  471. return S_OK;}
  472. #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;\
  473. if( m_##c->m2(tt1 v1,tt2 v2,&lp) != S_OK)return E_FAIL;INTERNAL_CREATE(oc, lp, rv);\
  474. return S_OK;}
  475. #if 0
  476. #define RETURN_NEW_ITEM_NOREL(c,m,oc) STDMETHODIMP C##c##Object::m(I##oc **rv){typedef_##oc lp;\
  477. if( m_##c->m(&lp) != S_OK)return E_FAIL;INTERNAL_CREATE_NOREL(oc, lp, rv);\
  478. return S_OK;}
  479. #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;\
  480. if( m_##c->m(tt1 v1,tt2 v2,tt3 v3,&lp) != S_OK)return E_FAIL;INTERNAL_CREATE(oc, lp, rv);\
  481. return S_OK;}
  482. #endif
  483. // Return a primitive value by reference.
  484. #define GET_DIRECT(cl,met,t) STDMETHODIMP C##cl##Object::met(t *h){*h=(t)m_##cl->met();return S_OK;}
  485. #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;}
  486. #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;}
  487. #define GET_DIRECT_R(cl,met,met2,t) STDMETHODIMP C##cl##Object::met(t *h){*h=(t)m_##cl->met2();return S_OK;}
  488. #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;}
  489. #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;}
  490. // Return a pointer to a primitive value as a ** ptr.
  491. #define GET_DIRECTPTR(cl,met,t) STDMETHODIMP C##cl##Object::met(t **h){*h=(struct t*)m_##cl->met();return S_OK;}
  492. #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;}
  493. #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;}
  494. //Do a DO_GETOBJECT_NOTNULL and then call a method on the object
  495. #define DO_GETOBJECT_ANDUSEIT(cl,me,iface) STDMETHODIMP C##cl##Object::me(I##iface *vis) \
  496. {DO_GETOBJECT_NOTNULL( typedef_##iface, lp, vis); if ( m_##cl == NULL ) return E_FAIL; return m_##cl->me(lp); }
  497. #define DO_GETOBJECT_ANDUSEIT_CAST(cl,me,iface, t1) STDMETHODIMP C##cl##Object::me(I##iface *vis) \
  498. {DO_GETOBJECT_NOTNULL( typedef_##iface, lp, vis); if ( m_##cl == NULL ) return E_FAIL; return m_##cl->me((t1)lp); }
  499. #define DO_GETOBJECT_ANDUSEIT1(cl,me,iface,t1) STDMETHODIMP C##cl##Object::me(t1 v1,I##iface *vis) \
  500. {DO_GETOBJECT_NOTNULL( typedef_##iface, lp, vis); if ( m_##cl == NULL ) return E_FAIL; return m_##cl->me(v1, lp); }
  501. #define DO_GETOBJECT_ANDUSEIT2(cl,me,iface,t1,t2) STDMETHODIMP C##cl##Object::me(t1 v1,t2 v2,I##iface *vis) \
  502. {DO_GETOBJECT_NOTNULL( typedef_##iface, lp, vis); if ( m_##cl == NULL ) return E_FAIL; return m_##cl->me(v1, v2, lp); }
  503. //mod:dp additions due to renaming
  504. //Do a DO_GETOBJECT_NOTNULL and then call a method on the object
  505. #define DO_GETOBJECT_ANDUSEIT_R(cl,me, m2, iface) STDMETHODIMP C##cl##Object::me(I##iface *vis) \
  506. {DO_GETOBJECT_NOTNULL( typedef_##iface, lp, vis); if ( m_##cl == NULL ) return E_FAIL; return m_##cl->m2(lp); }
  507. #define DO_GETOBJECT_ANDUSEIT_CAST_R(cl,me, m2, iface, t1) STDMETHODIMP C##cl##Object::me(I##iface *vis) \
  508. {DO_GETOBJECT_NOTNULL( typedef_##iface, lp, vis); if ( m_##cl == NULL ) return E_FAIL; return m_##cl->m2((t1)lp); }
  509. #define DO_GETOBJECT_ANDUSEIT1_R(cl,me, m2, iface,t1) STDMETHODIMP C##cl##Object::me(t1 v1,I##iface *vis) \
  510. {DO_GETOBJECT_NOTNULL( typedef_##iface, lp, vis); if ( m_##cl == NULL ) return E_FAIL; return m_##cl->m2(v1, lp); }
  511. #define DO_GETOBJECT_ANDUSEIT2_R(cl,me, m2, iface,t1,t2) STDMETHODIMP C##cl##Object::me(t1 v1,t2 v2,I##iface *vis) \
  512. {DO_GETOBJECT_NOTNULL( typedef_##iface, lp, vis); if ( m_##cl == NULL ) return E_FAIL; return m_##cl->m2(v1, v2, lp); }
  513. // Make a copy of an object!
  514. //#define CLONE(cl) STDMETHODIMP C##cl##Object::Clone(Id3drmObject **retval){typedef_##cl lp;\
  515. // m_##cl->Clone(0,IID_I##cl,(void **)&lp);INTERNAL_CREATE(cl,lp,retval);return S_OK;}
  516. //#define CLONE(cl) STDMETHODIMP C##cl##Object::Clone(I##cl **retval){typedef_##cl lp;\
  517. //m_##cl->Clone(0,IID_I##cl,(void **)&lp);INTERNAL_CREATE(cl, lp, retval); return S_OK;}
  518. //#define CLONE_R(cl,c2) STDMETHODIMP C##cl##Object::clone(I##cl **retval){typedef_##cl lp;\
  519. //m_##cl->Clone(0,IID_I##c2,(void **)&lp);INTERNAL_CREATE(cl, lp, retval); return S_OK;}
  520. #define CLONE_R(cl,c2) STDMETHODIMP C##cl##Object::clone(IUnknown **retval){typedef_##cl lp;\
  521. m_##cl->Clone(0,IID_I##c2,(void **)&lp);INTERNAL_CREATE(cl, lp, (I##cl **)retval); return S_OK;}
  522. #define GETNAME(cl) STDMETHODIMP C##cl##Object::GetName(BSTR *n){return _GetName(m_##cl, n, TRUE);}
  523. #define GETCLASSNAME(cl) STDMETHODIMP C##cl##Object::GetClassName(BSTR *n){return _GetName(m_##cl, n, FALSE);}
  524. #define SETNAME(cl) STDMETHODIMP C##cl##Object::SetName(BSTR Name){ \
  525. USES_CONVERSION;\
  526. LPSTR str = NULL; \
  527. __try { str = W2T(Name); } __except(EXCEPTION_EXECUTE_HANDLER) { return E_FAIL; } return m_##cl->SetName( str );}
  528. #define GETNAME_R(cl) STDMETHODIMP C##cl##Object::getName(BSTR *n){return _GetName(m_##cl, n, TRUE);}
  529. #define GETCLASSNAME_R(cl) STDMETHODIMP C##cl##Object::getClassName(BSTR *n){return _GetName(m_##cl, n, FALSE);}
  530. #define SETNAME_R(cl) STDMETHODIMP C##cl##Object::setName(BSTR Name){ \
  531. USES_CONVERSION;\
  532. LPSTR str = NULL; \
  533. __try { str = W2T(Name); } __except(EXCEPTION_EXECUTE_HANDLER) { return E_FAIL; } return m_##cl->SetName( str );}
  534. #define CLONETO(clMe, cl, ifaceThat) STDMETHODIMP C##clMe##Object::Get##cl(I##cl **retval) \
  535. { typedef_##cl lp; if (m_##clMe->QueryInterface(ifaceThat, (void **) &lp) != S_OK) return S_FALSE; \
  536. INTERNAL_CREATE( cl, lp, retval); return S_OK; }
  537. #define ISSAFEARRAY1D(ppsa,count) ((*ppsa) && ( ((SAFEARRAY*)*ppsa)->cDims==1) && (((SAFEARRAY*)*ppsa)->rgsabound[0].cElements >= count))
  538. /**********************************************************************************************/
  539. extern "C" BOOL ParseWaveResource(void *pvRes, WAVEFORMATEX **ppWaveHeader, BYTE **ppbWaveData, DWORD *pcbWaveSize);
  540. extern "C" BOOL GetWaveResource(HMODULE hModule, LPCTSTR lpName,
  541. WAVEFORMATEX **ppWaveHeader, BYTE **ppbWaveData, DWORD *pcbWaveSize);
  542. extern "C" DWORD bppToddbd(int bpp);
  543. extern "C" void PassBackUnicode(LPSTR str, BSTR *Name, DWORD cnt);
  544. extern "C" void ctojDSBufferDesc( LPDSBUFFERDESC lpdd,
  545. DSBUFFERDESC_CDESC *ddsb, WAVEFORMATEX_CDESC *wave);
  546. extern "C" void jtocDSBufferDesc( LPDSBUFFERDESC lpdd, DSBUFFERDESC_CDESC *ddsb, WAVEFORMATEX_CDESC *wave);
  547. extern "C" void ctojWaveFormatEx( LPWAVEFORMATEX lpdd, WAVEFORMATEX_CDESC *wave);
  548. extern "C" void CopyFloats(D3DVALUE *mat1, D3DVALUE *mat2, DWORD count);
  549. extern "C" BOOL PASCAL myEnumSoundDriversCallback(GUID &SPGuid, LPSTR description,
  550. LPSTR module, void *lpArg);
  551. extern "C" BOOL CALLBACK myEnumDeviceObjectsCallback( LPCDIDEVICEOBJECTINSTANCE pI, LPVOID lpArg ) ;
  552. extern "C" BOOL CALLBACK myEnumCreatedEffectObjectsCallback(LPDIRECTINPUTEFFECT peff, LPVOID lpArg );
  553. extern "C" BOOL CALLBACK myEnumEffectsCallback( LPCDIEFFECTINFO pdei, LPVOID lpArg );
  554. extern "C" BOOL CALLBACK myEnumInputDevicesCallback( LPDIDEVICEINSTANCE lpddi, LPVOID pvRef );
  555. //////////////////////////////////////////////////////////////////////////
  556. /*
  557. **********************************************************************
  558. * INTERNAL_CREATE(thisClass, var, retval)
  559. * thisClass class we are working on
  560. * var variable created in routine to get DirectX object
  561. * retval return value back to java
  562. *
  563. * wrap a DirectX object in one of ours and shove it in the return value
  564. ***********************************************************************
  565. * INTERNAL_CREATE_NOREL(thisClass, var, retval)
  566. * thisClass class we are working on
  567. * var variable created in routine to get DirectX object
  568. * retval return value back to java
  569. *
  570. * wrap a DirectX object in one of ours and shove it in the return value
  571. * If the layer obejct fails, DONT release the DirectX object
  572. ***********************************************************************
  573. * DO_GETOBJECT_NOTNULL(type,var,iface)
  574. * type type of variable we are creating
  575. * var variable we are creating
  576. * iface layer iface where we are getting the object from
  577. *
  578. * declare and get a DirectX object from a layer object
  579. ***********************************************************************
  580. * DO_GETOBJECT_NOTNULL(type,var,iface)
  581. * type type of variable we are creating
  582. * var variable we are creating
  583. * iface layer iface where we are getting the object from
  584. *
  585. * same as DO_GETOBJECT_NOTNULL except that we check for iface==NULL before calling
  586. ***********************************************************************
  587. * PASS_THROUGH[x](class,method,[...])
  588. * class this class
  589. * method method to call
  590. *
  591. * pass call straight through
  592. ***********************************************************************
  593. * PASS_THROUGH_CAST_[x](class,method,[...])
  594. * class this class
  595. * method method to call
  596. *
  597. * pass call straight through, casting the parameters to allow the call to pass
  598. ***********************************************************************
  599. * RETURN_NEW_ITEM(thisClass,method,OtherClass)
  600. * thisClass class being worked on
  601. * method method working on
  602. * otherClass class whose object we want
  603. *
  604. * call DirectX method to get the DirectX object, then wrap it in one of our layer
  605. * objects
  606. ***********************************************************************
  607. * RETURN_NEW_ITEM[1,2](thisClass,method,OtherClass,type)
  608. * thisClass class being worked on
  609. * method method working on
  610. * otherClass class whose object we want
  611. * type type of parameter
  612. *
  613. * Same as RETURN_NEWITEM except that there is an extra parameter (or two) BEFORE the
  614. * returned one
  615. ***********************************************************************
  616. * RETURN_NEW_ITEM_CAST_[1,2](thisClass,method,OtherClass,type)
  617. * thisClass class being worked on
  618. * method method working on
  619. * otherClass class whose object we want
  620. * type type of parameter
  621. *
  622. * Same as RETURN_NEW_ITEM[1,2] except that there the extra parameter(s) are type cast
  623. ******************************************************************************
  624. * RETURN_NEW_ITEM_NOREL(thisClass,method,OtherClass)
  625. * thisClass class being worked on
  626. * method method working on
  627. * otherClass class whose object we want
  628. *
  629. * same as RETURN_NEW_ITEM except that calls INTERNAL_CREATE_NOTREL instead of
  630. * INTERNAL_CREATE
  631. ******************************************************************************
  632. * GET_DIRECT(cl,met,t)
  633. * class class being worked on
  634. * method method being worked on
  635. * t type of the variable being returned
  636. *
  637. * DirectX returns value directly (no HRESULT), we get the value from Direct and
  638. * then return S_OK. (see CddSurfaceObject::Restore, may need to be added).
  639. * Note: the value is passed back via a pointer to that value.
  640. ******************************************************************************
  641. * GET_DIRECT[1,2](cl,met,t,t1)
  642. * class class being worked on
  643. * method method being worked on
  644. * t type of the variable being returned
  645. * t1 type of extra variable(s) BEFORE retval
  646. *
  647. * same as GET_DIRECT but there is another parameter (or two) BEFORE the returned one
  648. ****************************************************************************************
  649. * GET_DIRECTPTR(cl,met,t)
  650. * class class being worked on
  651. * method method being worked on
  652. * t type of the variable being returned
  653. *
  654. * DirectX returns a pointer to a value directly (no HRESULT), we get the value from
  655. * Direct and then return S_OK. In this case it is a pointer to a pointer.
  656. ***************************************************************************************
  657. * GET_DIRECTPTR[1,2](cl,met,t,t1)
  658. * class class being worked on
  659. * method method being worked on
  660. * t type of the variable being returned
  661. * t1 type of extra variable(s) BEFORE retval
  662. *
  663. * same as GET_DIRECTPTR but there is a parameter (or two) BEFORE the one returned.
  664. ***************************************************************************************
  665. * DO_GETOBJECT_ANDUSEIT(cl,me,iface)
  666. * class class being worked on
  667. * method method being worked on
  668. * iface secondary interface we are interested in
  669. *
  670. * get an internal object from iface and use it in the method. we return from the method
  671. ***************************************************************************************
  672. * DO_GETOBJECT_ANDUSEIT_CAST(cl,me,iface,type)
  673. * class class being worked on
  674. * method method being worked on
  675. * iface secondary interface we are interested in
  676. * type type to cast to in the actual call.
  677. * get an internal object from iface and use it in the method. we return from the method
  678. ***************************************************************************************
  679. * DO_GETOBJECT_ANDUSEIT[1,2](cl,me,iface,ty)
  680. * class class being worked on
  681. * method method being worked on
  682. * iface secondary interface we are interested in
  683. * type type of parameter BEFORE 2nd object
  684. *
  685. * same as DO_GETOBJECT_ANDUSEIT except there is another parameter (or two) BEFORE
  686. * the object one
  687. ************************************************************************************
  688. * CLONE(cl)
  689. * class class to clone
  690. *
  691. * >>>>>>> THIS IS A D3DRMOBJECT METHOD <<<<<<<<<<
  692. ************************************************************************************
  693. * GETNAME(cl)
  694. * class class to retive name of
  695. * >>>>>>> THIS IS A D3DRMOBJECT METHOD <<<<<<<<<<
  696. ************************************************************************************
  697. * GETCLASSNAME(cl)
  698. * class class to retive name of
  699. * >>>>>>> THIS IS A D3DRMOBJECT METHOD <<<<<<<<<<
  700. ************************************************************************************
  701. * DELETEDESTROYCALLBACK(cl)
  702. * class class to retive name of
  703. * >>>>>>> THIS IS A D3DRMOBJECT METHOD <<<<<<<<<<
  704. ************************************************************************************
  705. * QIOVERLOAD(cl, ifaceThat, clThat)
  706. * class class being worked on
  707. * iface iface of DIRECT object. Should really typedef_## this!
  708. * clThat object we are going to create
  709. *
  710. * this is really bright - overloading QI to get new objects
  711. ************************************************************************************
  712. * CLONETO(cl, clThat, ifaceThat)
  713. * class class being worked on
  714. * iface iface of DIRECT object. Should really typedef_## this!
  715. * clThat object we are going to create
  716. *
  717. * this is really bright - overloading QI to get new objects
  718. ************************************************************************************
  719. */
  720. extern void *g_dxj_DirectSound3dListener;
  721. extern void *g_dxj_DirectSoundBuffer;
  722. extern void *g_dxj_DirectSound3dBuffer;
  723. extern void *g_dxj_DirectSound;
  724. extern void *g_dxj_DirectSoundCapture;
  725. extern void *g_dxj_DirectSoundCaptureBuffer;
  726. extern void *g_dxj_DirectSoundNotify;
  727. extern void *g_dxj_DirectInput8;
  728. extern void *g_dxj_DirectInputDevice8;
  729. extern void *g_dxj_DirectInputEffect;
  730. extern void *g_dxj_DirectPlayVoiceClient;
  731. extern void *g_dxj_DirectPlayVoiceServer;
  732. extern void *g_dxj_DirectPlayVoiceSetup;
  733. #define DXHEAPALLOC malloc
  734. #define DXSTACKALLOC lalloc
  735. #define DXHEAPFREE free
  736. #define DXALLOCBSTR SysAllocString
  737. #define Byte unsigned char