ECInterfaceDefs.h 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317
  1. /*
  2. * Copyright 2005 - 2016 Zarafa and its licensors
  3. *
  4. * This program is free software: you can redistribute it and/or modify
  5. * it under the terms of the GNU Affero General Public License, version 3,
  6. * as published by the Free Software Foundation.
  7. *
  8. * This program is distributed in the hope that it will be useful,
  9. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. * GNU Affero General Public License for more details.
  12. *
  13. * You should have received a copy of the GNU Affero General Public License
  14. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  15. *
  16. */
  17. /* C99-style: anonymous argument referenced by __VA_ARGS__, empty arg not OK */
  18. // @todo: Document
  19. #include <kopano/ECDebugPrint.h>
  20. #include <string>
  21. #define N_ARGS(...) N_ARGS_HELPER1((__VA_ARGS__, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0))
  22. #define N_ARGS_HELPER1(tuple) N_ARGS_HELPER2 tuple
  23. #define N_ARGS_HELPER2(x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13, x14, x15, x16, x17, x18, x19, x20, n, ...) n
  24. #define ARGLISTSET(...) ARGLISTSET_HELPER1(N_ARGS(__VA_ARGS__), __VA_ARGS__)
  25. #define ARGLISTSET_HELPER1(n, ...) ARGLISTSET_HELPER2(n, (__VA_ARGS__))
  26. #define ARGLISTSET_HELPER2(n, tuple) ARGLISTSET_HELPER3(n, tuple)
  27. #define ARGLISTSET_HELPER3(n, tuple) ARGLISTSET_##n tuple
  28. #define ARGLISTSET_1(v)
  29. #define ARGLISTSET_2(t1, a1) t1 a1
  30. #define ARGLISTSET_4(t1, a1, t2, a2) t1 a1, t2 a2
  31. #define ARGLIST(...) ARGLIST_HELPER1(N_ARGS(__VA_ARGS__), __VA_ARGS__)
  32. #define ARGLIST_HELPER1(n, ...) ARGLIST_HELPER2(n, (__VA_ARGS__))
  33. #define ARGLIST_HELPER2(n, tuple) ARGLIST_HELPER3(n, tuple)
  34. #define ARGLIST_HELPER3(n, tuple) ARGLIST_ ##n tuple
  35. #define ARGLIST_1(s1) ARGLISTSET s1
  36. #define ARGLIST_2(s1, s2) ARGLISTSET s1, ARGLISTSET s2
  37. #define ARGLIST_3(s1, s2, s3) ARGLISTSET s1, ARGLISTSET s2, ARGLISTSET s3
  38. #define ARGLIST_4(s1, s2, s3, s4) ARGLISTSET s1, ARGLISTSET s2, ARGLISTSET s3, ARGLISTSET s4
  39. #define ARGLIST_5(s1, s2, s3, s4, s5) ARGLISTSET s1, ARGLISTSET s2, ARGLISTSET s3, ARGLISTSET s4, ARGLISTSET s5
  40. #define ARGLIST_6(s1, s2, s3, s4, s5, s6) ARGLISTSET s1, ARGLISTSET s2, ARGLISTSET s3, ARGLISTSET s4, ARGLISTSET s5, ARGLISTSET s6
  41. #define ARGLIST_7(s1, s2, s3, s4, s5, s6, s7) ARGLISTSET s1, ARGLISTSET s2, ARGLISTSET s3, ARGLISTSET s4, ARGLISTSET s5, ARGLISTSET s6, ARGLISTSET s7
  42. #define ARGLIST_8(s1, s2, s3, s4, s5, s6, s7, s8) ARGLISTSET s1, ARGLISTSET s2, ARGLISTSET s3, ARGLISTSET s4, ARGLISTSET s5, ARGLISTSET s6, ARGLISTSET s7, ARGLISTSET s8
  43. #define ARGLIST_9(s1, s2, s3, s4, s5, s6, s7, s8, s9) ARGLISTSET s1, ARGLISTSET s2, ARGLISTSET s3, ARGLISTSET s4, ARGLISTSET s5, ARGLISTSET s6, ARGLISTSET s7, ARGLISTSET s8, ARGLISTSET s9
  44. #define ARGLIST_10(s1, s2, s3, s4, s5, s6, s7, s8, s9, s10) ARGLISTSET s1, ARGLISTSET s2, ARGLISTSET s3, ARGLISTSET s4, ARGLISTSET s5, ARGLISTSET s6, ARGLISTSET s7, ARGLISTSET s8, ARGLISTSET s9, ARGLISTSET s10
  45. #define ARGLIST_11(s1, s2, s3, s4, s5, s6, s7, s8, s9, s10, s11) ARGLISTSET s1, ARGLISTSET s2, ARGLISTSET s3, ARGLISTSET s4, ARGLISTSET s5, ARGLISTSET s6, ARGLISTSET s7, ARGLISTSET s8, ARGLISTSET s9, ARGLISTSET s10, ARGLISTSET s11
  46. #define ARGSSET(...) ARGSSET_HELPER1(N_ARGS(__VA_ARGS__), __VA_ARGS__)
  47. #define ARGSSET_HELPER1(n, ...) ARGSSET_HELPER2(n, (__VA_ARGS__))
  48. #define ARGSSET_HELPER2(n, tuple) ARGSSET_HELPER3(n, tuple)
  49. #define ARGSSET_HELPER3(n, tuple) ARGSSET_##n tuple
  50. #define ARGSSET_1(v)
  51. #define ARGSSET_2(t1, a1) a1
  52. #define ARGSSET_4(t1, a1, t2, a2) a1, a2
  53. #define ARGS(...) ARGS_HELPER1(N_ARGS(__VA_ARGS__), __VA_ARGS__)
  54. #define ARGS_HELPER1(n, ...) ARGS_HELPER2(n, (__VA_ARGS__))
  55. #define ARGS_HELPER2(n, tuple) ARGS_HELPER3(n, tuple)
  56. #define ARGS_HELPER3(n, tuple) ARGS_##n tuple
  57. #define ARGS_1(s1) ARGSSET s1
  58. #define ARGS_2(s1, s2) ARGSSET s1, ARGSSET s2
  59. #define ARGS_3(s1, s2, s3) ARGSSET s1, ARGSSET s2, ARGSSET s3
  60. #define ARGS_4(s1, s2, s3, s4) ARGSSET s1, ARGSSET s2, ARGSSET s3, ARGSSET s4
  61. #define ARGS_5(s1, s2, s3, s4, s5) ARGSSET s1, ARGSSET s2, ARGSSET s3, ARGSSET s4, ARGSSET s5
  62. #define ARGS_6(s1, s2, s3, s4, s5, s6) ARGSSET s1, ARGSSET s2, ARGSSET s3, ARGSSET s4, ARGSSET s5, ARGSSET s6
  63. #define ARGS_7(s1, s2, s3, s4, s5, s6, s7) ARGSSET s1, ARGSSET s2, ARGSSET s3, ARGSSET s4, ARGSSET s5, ARGSSET s6, ARGSSET s7
  64. #define ARGS_8(s1, s2, s3, s4, s5, s6, s7, s8) ARGSSET s1, ARGSSET s2, ARGSSET s3, ARGSSET s4, ARGSSET s5, ARGSSET s6, ARGSSET s7, ARGSSET s8
  65. #define ARGS_9(s1, s2, s3, s4, s5, s6, s7, s8, s9) ARGSSET s1, ARGSSET s2, ARGSSET s3, ARGSSET s4, ARGSSET s5, ARGSSET s6, ARGSSET s7, ARGSSET s8, ARGSSET s9
  66. #define ARGS_10(s1, s2, s3, s4, s5, s6, s7, s8, s9, s10) ARGSSET s1, ARGSSET s2, ARGSSET s3, ARGSSET s4, ARGSSET s5, ARGSSET s6, ARGSSET s7, ARGSSET s8, ARGSSET s9, ARGSSET s10
  67. #define ARGS_11(s1, s2, s3, s4, s5, s6, s7, s8, s9, s10, s11) ARGSSET s1, ARGSSET s2, ARGSSET s3, ARGSSET s4, ARGSSET s5, ARGSSET s6, ARGSSET s7, ARGSSET s8, ARGSSET s9, ARGSSET s10, ARGSSET s11
  68. #define FORMAT_ARGSSET(...) FORMAT_ARGSSET_HELPER1(N_ARGS(__VA_ARGS__), __VA_ARGS__)
  69. #define FORMAT_ARGSSET_HELPER1(n, ...) FORMAT_ARGSSET_HELPER2(n, (__VA_ARGS__))
  70. #define FORMAT_ARGSSET_HELPER2(n, tuple) FORMAT_ARGSSET_HELPER3(n, tuple)
  71. #define FORMAT_ARGSSET_HELPER3(n, tuple) FORMAT_ARGSSET_##n tuple
  72. #define FORMAT_ARGSSET_1(v) ""
  73. #define FORMAT_ARGSSET_2(t1, a1) #a1 "=%s"
  74. #define FORMAT_ARGSSET_4(t1, a1, t2, a2) "("#a1","#a2")=%s"
  75. #define FORMAT_ARGS(...) FORMAT_ARGS_HELPER1(N_ARGS(__VA_ARGS__), __VA_ARGS__)
  76. #define FORMAT_ARGS_HELPER1(n, ...) FORMAT_ARGS_HELPER2(n, (__VA_ARGS__))
  77. #define FORMAT_ARGS_HELPER2(n, tuple) FORMAT_ARGS_HELPER3(n, tuple)
  78. #define FORMAT_ARGS_HELPER3(n, tuple) FORMAT_ARGS_##n tuple
  79. #define FORMAT_ARGS_1(s1) FORMAT_ARGSSET s1
  80. #define FORMAT_ARGS_2(s1, s2) FORMAT_ARGSSET s1 ", " FORMAT_ARGSSET s2
  81. #define FORMAT_ARGS_3(s1, s2, s3) FORMAT_ARGSSET s1 ", " FORMAT_ARGSSET s2 ", " FORMAT_ARGSSET s3
  82. #define FORMAT_ARGS_4(s1, s2, s3, s4) FORMAT_ARGSSET s1 ", " FORMAT_ARGSSET s2 ", " FORMAT_ARGSSET s3 ", " FORMAT_ARGSSET s4
  83. #define FORMAT_ARGS_5(s1, s2, s3, s4, s5) FORMAT_ARGSSET s1 ", " FORMAT_ARGSSET s2 ", " FORMAT_ARGSSET s3 ", " FORMAT_ARGSSET s4 ", " FORMAT_ARGSSET s5
  84. #define FORMAT_ARGS_6(s1, s2, s3, s4, s5, s6) FORMAT_ARGSSET s1 ", " FORMAT_ARGSSET s2 ", " FORMAT_ARGSSET s3 ", " FORMAT_ARGSSET s4 ", " FORMAT_ARGSSET s5 ", " FORMAT_ARGSSET s6
  85. #define FORMAT_ARGS_7(s1, s2, s3, s4, s5, s6, s7) FORMAT_ARGSSET s1 ", " FORMAT_ARGSSET s2 ", " FORMAT_ARGSSET s3 ", " FORMAT_ARGSSET s4 ", " FORMAT_ARGSSET s5 ", " FORMAT_ARGSSET s6 ", " FORMAT_ARGSSET s7
  86. #define FORMAT_ARGS_8(s1, s2, s3, s4, s5, s6, s7, s8) FORMAT_ARGSSET s1 ", " FORMAT_ARGSSET s2 ", " FORMAT_ARGSSET s3 ", " FORMAT_ARGSSET s4 ", " FORMAT_ARGSSET s5 ", " FORMAT_ARGSSET s6 ", " FORMAT_ARGSSET s7 ", " FORMAT_ARGSSET s8
  87. #define FORMAT_ARGS_9(s1, s2, s3, s4, s5, s6, s7, s8, s9) FORMAT_ARGSSET s1 ", " FORMAT_ARGSSET s2 ", " FORMAT_ARGSSET s3 ", " FORMAT_ARGSSET s4 ", " FORMAT_ARGSSET s5 ", " FORMAT_ARGSSET s6 ", " FORMAT_ARGSSET s7 ", " FORMAT_ARGSSET s8 ", " FORMAT_ARGSSET s9
  88. #define FORMAT_ARGS_10(s1, s2, s3, s4, s5, s6, s7, s8, s9, s10) FORMAT_ARGSSET s1 ", " FORMAT_ARGSSET s2 ", " FORMAT_ARGSSET s3 ", " FORMAT_ARGSSET s4 ", " FORMAT_ARGSSET s5 ", " FORMAT_ARGSSET s6 ", " FORMAT_ARGSSET s7 ", " FORMAT_ARGSSET s8 ", " FORMAT_ARGSSET s9 ", " FORMAT_ARGSSET s10
  89. #define FORMAT_ARGS_11(s1, s2, s3, s4, s5, s6, s7, s8, s9, s10, s11) FORMAT_ARGSSET s1 ", " FORMAT_ARGSSET s2 ", " FORMAT_ARGSSET s3 ", " FORMAT_ARGSSET s4 ", " FORMAT_ARGSSET s5 ", " FORMAT_ARGSSET s6 ", " FORMAT_ARGSSET s7 ", " FORMAT_ARGSSET s8 ", " FORMAT_ARGSSET s9 ", " FORMAT_ARGSSET s10 ", " FORMAT_ARGSSET s11
  90. #define PRINT_ARGSSET_IN(...) PRINT_ARGSSET_IN_HELPER1(N_ARGS(__VA_ARGS__), __VA_ARGS__)
  91. #define PRINT_ARGSSET_IN_HELPER1(n, ...) PRINT_ARGSSET_IN_HELPER2(n, (__VA_ARGS__))
  92. #define PRINT_ARGSSET_IN_HELPER2(n, tuple) PRINT_ARGSSET_IN_HELPER3(n, tuple)
  93. #define PRINT_ARGSSET_IN_HELPER3(n, tuple) PRINT_ARGSSET_IN_##n tuple
  94. #define PRINT_ARGSSET_IN_1(v) NULL
  95. #define PRINT_ARGSSET_IN_2(t1, a1) ECDebugPrint<std::string, ECDebugPrintBase::NoDeref>::toString(a1).c_str()
  96. #define PRINT_ARGSSET_IN_4(t1, a1, t2, a2) ECDebugPrint<std::string, ECDebugPrintBase::NoDeref>::toString(a1, a2).c_str()
  97. #define PRINT_ARGSSET_OUT(...) PRINT_ARGSSET_OUT_HELPER1(N_ARGS(__VA_ARGS__), __VA_ARGS__)
  98. #define PRINT_ARGSSET_OUT_HELPER1(n, ...) PRINT_ARGSSET_OUT_HELPER2(n, (__VA_ARGS__))
  99. #define PRINT_ARGSSET_OUT_HELPER2(n, tuple) PRINT_ARGSSET_OUT_HELPER3(n, tuple)
  100. #define PRINT_ARGSSET_OUT_HELPER3(n, tuple) PRINT_ARGSSET_OUT_##n tuple
  101. #define PRINT_ARGSSET_OUT_1(v) NULL
  102. #define PRINT_ARGSSET_OUT_2(t1, a1) ECDebugPrint<std::string, ECDebugPrintBase::Deref>::toString(a1).c_str()
  103. #define PRINT_ARGSSET_OUT_4(t1, a1, t2, a2) ECDebugPrint<std::string, ECDebugPrintBase::Deref>::toString(a1, a2).c_str()
  104. #define PRINT_ARGS_IN(...) PRINT_ARGS_IN_HELPER1(N_ARGS(__VA_ARGS__), __VA_ARGS__)
  105. #define PRINT_ARGS_IN_HELPER1(n, ...) PRINT_ARGS_IN_HELPER2(n, (__VA_ARGS__))
  106. #define PRINT_ARGS_IN_HELPER2(n, tuple) PRINT_ARGS_IN_HELPER3(n, tuple)
  107. #define PRINT_ARGS_IN_HELPER3(n, tuple) PRINT_ARGS_IN_##n tuple
  108. #define PRINT_ARGS_IN_1(s1) PRINT_ARGSSET_IN s1
  109. #define PRINT_ARGS_IN_2(s1, s2) PRINT_ARGSSET_IN s1, PRINT_ARGSSET_IN s2
  110. #define PRINT_ARGS_IN_3(s1, s2, s3) PRINT_ARGSSET_IN s1, PRINT_ARGSSET_IN s2, PRINT_ARGSSET_IN s3
  111. #define PRINT_ARGS_IN_4(s1, s2, s3, s4) PRINT_ARGSSET_IN s1, PRINT_ARGSSET_IN s2, PRINT_ARGSSET_IN s3, PRINT_ARGSSET_IN s4
  112. #define PRINT_ARGS_IN_5(s1, s2, s3, s4, s5) PRINT_ARGSSET_IN s1, PRINT_ARGSSET_IN s2, PRINT_ARGSSET_IN s3, PRINT_ARGSSET_IN s4, PRINT_ARGSSET_IN s5
  113. #define PRINT_ARGS_IN_6(s1, s2, s3, s4, s5, s6) PRINT_ARGSSET_IN s1, PRINT_ARGSSET_IN s2, PRINT_ARGSSET_IN s3, PRINT_ARGSSET_IN s4, PRINT_ARGSSET_IN s5, PRINT_ARGSSET_IN s6
  114. #define PRINT_ARGS_IN_7(s1, s2, s3, s4, s5, s6, s7) PRINT_ARGSSET_IN s1, PRINT_ARGSSET_IN s2, PRINT_ARGSSET_IN s3, PRINT_ARGSSET_IN s4, PRINT_ARGSSET_IN s5, PRINT_ARGSSET_IN s6, PRINT_ARGSSET_IN s7
  115. #define PRINT_ARGS_IN_8(s1, s2, s3, s4, s5, s6, s7, s8) PRINT_ARGSSET_IN s1, PRINT_ARGSSET_IN s2, PRINT_ARGSSET_IN s3, PRINT_ARGSSET_IN s4, PRINT_ARGSSET_IN s5, PRINT_ARGSSET_IN s6, PRINT_ARGSSET_IN s7, PRINT_ARGSSET_IN s8
  116. #define PRINT_ARGS_IN_9(s1, s2, s3, s4, s5, s6, s7, s8, s9) PRINT_ARGSSET_IN s1, PRINT_ARGSSET_IN s2, PRINT_ARGSSET_IN s3, PRINT_ARGSSET_IN s4, PRINT_ARGSSET_IN s5, PRINT_ARGSSET_IN s6, PRINT_ARGSSET_IN s7, PRINT_ARGSSET_IN s8, PRINT_ARGSSET_IN s9
  117. #define PRINT_ARGS_IN_10(s1, s2, s3, s4, s5, s6, s7, s8, s9, s10) PRINT_ARGSSET_IN s1, PRINT_ARGSSET_IN s2, PRINT_ARGSSET_IN s3, PRINT_ARGSSET_IN s4, PRINT_ARGSSET_IN s5, PRINT_ARGSSET_IN s6, PRINT_ARGSSET_IN s7, PRINT_ARGSSET_IN s8, PRINT_ARGSSET_IN s9, PRINT_ARGSSET_IN s10
  118. #define PRINT_ARGS_IN_11(s1, s2, s3, s4, s5, s6, s7, s8, s9, s10, s11) PRINT_ARGSSET_IN s1, PRINT_ARGSSET_IN s2, PRINT_ARGSSET_IN s3, PRINT_ARGSSET_IN s4, PRINT_ARGSSET_IN s5, PRINT_ARGSSET_IN s6, PRINT_ARGSSET_IN s7, PRINT_ARGSSET_IN s8, PRINT_ARGSSET_IN s9, PRINT_ARGSSET_IN s10, PRINT_ARGSSET_IN s11
  119. #define PRINT_ARGS_OUT(...) PRINT_ARGS_OUT_HELPER1(N_ARGS(__VA_ARGS__), __VA_ARGS__)
  120. #define PRINT_ARGS_OUT_HELPER1(n, ...) PRINT_ARGS_OUT_HELPER2(n, (__VA_ARGS__))
  121. #define PRINT_ARGS_OUT_HELPER2(n, tuple) PRINT_ARGS_OUT_HELPER3(n, tuple)
  122. #define PRINT_ARGS_OUT_HELPER3(n, tuple) PRINT_ARGS_OUT_##n tuple
  123. #define PRINT_ARGS_OUT_1(s1) PRINT_ARGSSET_OUT s1
  124. #define PRINT_ARGS_OUT_2(s1, s2) PRINT_ARGSSET_OUT s1, PRINT_ARGSSET_OUT s2
  125. #define PRINT_ARGS_OUT_3(s1, s2, s3) PRINT_ARGSSET_OUT s1, PRINT_ARGSSET_OUT s2, PRINT_ARGSSET_OUT s3
  126. #define PRINT_ARGS_OUT_4(s1, s2, s3, s4) PRINT_ARGSSET_OUT s1, PRINT_ARGSSET_OUT s2, PRINT_ARGSSET_OUT s3, PRINT_ARGSSET_OUT s4
  127. #define PRINT_ARGS_OUT_5(s1, s2, s3, s4, s5) PRINT_ARGSSET_OUT s1, PRINT_ARGSSET_OUT s2, PRINT_ARGSSET_OUT s3, PRINT_ARGSSET_OUT s4, PRINT_ARGSSET_OUT s5
  128. #define PRINT_ARGS_OUT_6(s1, s2, s3, s4, s5, s6) PRINT_ARGSSET_OUT s1, PRINT_ARGSSET_OUT s2, PRINT_ARGSSET_OUT s3, PRINT_ARGSSET_OUT s4, PRINT_ARGSSET_OUT s5, PRINT_ARGSSET_OUT s6
  129. #define PRINT_ARGS_OUT_7(s1, s2, s3, s4, s5, s6, s7) PRINT_ARGSSET_OUT s1, PRINT_ARGSSET_OUT s2, PRINT_ARGSSET_OUT s3, PRINT_ARGSSET_OUT s4, PRINT_ARGSSET_OUT s5, PRINT_ARGSSET_OUT s6, PRINT_ARGSSET_OUT s7
  130. #define PRINT_ARGS_OUT_8(s1, s2, s3, s4, s5, s6, s7, s8) PRINT_ARGSSET_OUT s1, PRINT_ARGSSET_OUT s2, PRINT_ARGSSET_OUT s3, PRINT_ARGSSET_OUT s4, PRINT_ARGSSET_OUT s5, PRINT_ARGSSET_OUT s6, PRINT_ARGSSET_OUT s7, PRINT_ARGSSET_OUT s8
  131. #define PRINT_ARGS_OUT_9(s1, s2, s3, s4, s5, s6, s7, s8, s9) PRINT_ARGSSET_OUT s1, PRINT_ARGSSET_OUT s2, PRINT_ARGSSET_OUT s3, PRINT_ARGSSET_OUT s4, PRINT_ARGSSET_OUT s5, PRINT_ARGSSET_OUT s6, PRINT_ARGSSET_OUT s7, PRINT_ARGSSET_OUT s8, PRINT_ARGSSET_OUT s9
  132. #define PRINT_ARGS_OUT_10(s1, s2, s3, s4, s5, s6, s7, s8, s9, s10) PRINT_ARGSSET_OUT s1, PRINT_ARGSSET_OUT s2, PRINT_ARGSSET_OUT s3, PRINT_ARGSSET_OUT s4, PRINT_ARGSSET_OUT s5, PRINT_ARGSSET_OUT s6, PRINT_ARGSSET_OUT s7, PRINT_ARGSSET_OUT s8, PRINT_ARGSSET_OUT s9, PRINT_ARGSSET_OUT s10
  133. #define PRINT_ARGS_OUT_11(s1, s2, s3, s4, s5, s6, s7, s8, s9, s10, s11) PRINT_ARGSSET_OUT s1, PRINT_ARGSSET_OUT s2, PRINT_ARGSSET_OUT s3, PRINT_ARGSSET_OUT s4, PRINT_ARGSSET_OUT s5, PRINT_ARGSSET_OUT s6, PRINT_ARGSSET_OUT s7, PRINT_ARGSSET_OUT s8, PRINT_ARGSSET_OUT s9, PRINT_ARGSSET_OUT s10, PRINT_ARGSSET_OUT s11
  134. #define XCLASS(_iface) x ##_iface
  135. #define ICLASS(_iface) I ##_iface
  136. #define CLASSMETHOD(_class, _method) _class::_method
  137. #define METHODSTR(_iface, _method) METHODSTR_HELPER1(CLASSMETHOD(ICLASS(_iface), _method))
  138. #define METHODSTR_HELPER1(_method) METHODSTR_HELPER2(_method)
  139. #define METHODSTR_HELPER2(_method) #_method
  140. #define DEF_ULONGMETHOD(_trace, _class, _iface, _method, ...) \
  141. ULONG __stdcall CLASSMETHOD(_class, CLASSMETHOD(XCLASS(_iface), _method))(ARGLIST(__VA_ARGS__)) { \
  142. _trace(TRACE_ENTRY, METHODSTR(_iface, _method), FORMAT_ARGS(__VA_ARGS__), PRINT_ARGS_IN( __VA_ARGS__)); \
  143. ULONG ul = 0; \
  144. try { \
  145. METHOD_PROLOGUE_(_class, _iface); \
  146. ul = pThis->_method(ARGS(__VA_ARGS__)); \
  147. } catch (const std::bad_alloc &) { \
  148. ul = -1; \
  149. } \
  150. _trace(TRACE_RETURN, METHODSTR(_iface, _method), "SUCCESS: " FORMAT_ARGS(__VA_ARGS__), PRINT_ARGS_OUT(__VA_ARGS__)); \
  151. return ul; \
  152. }
  153. #define DEF_ULONGMETHOD1(_trace, _class, _iface, _method, ...) \
  154. ULONG __stdcall CLASSMETHOD(_class, CLASSMETHOD(XCLASS(_iface), _method))(ARGLIST(__VA_ARGS__)) \
  155. { \
  156. _trace(TRACE_ENTRY, METHODSTR(_iface, _method), FORMAT_ARGS(__VA_ARGS__), PRINT_ARGS_IN( __VA_ARGS__)); \
  157. ULONG ul = 0; \
  158. METHOD_PROLOGUE_(_class, _iface); \
  159. ul = pThis->_method(ARGS(__VA_ARGS__)); \
  160. _trace(TRACE_RETURN, METHODSTR(_iface, _method), "SUCCESS: " FORMAT_ARGS(__VA_ARGS__), PRINT_ARGS_OUT(__VA_ARGS__)); \
  161. return ul; \
  162. }
  163. #define DEF_ULONGMETHOD0(_class, _iface, _method, ...) \
  164. ULONG __stdcall CLASSMETHOD(_class, CLASSMETHOD(XCLASS(_iface), _method))(ARGLIST(__VA_ARGS__)) \
  165. { \
  166. METHOD_PROLOGUE_(_class, _iface); \
  167. return pThis->_method(ARGS(__VA_ARGS__)); \
  168. }
  169. #define DEF_HRMETHOD(_trace, _class, _iface, _method, ...) \
  170. HRESULT __stdcall CLASSMETHOD(_class, CLASSMETHOD(XCLASS(_iface), _method))(ARGLIST(__VA_ARGS__)) { \
  171. _trace(TRACE_ENTRY, METHODSTR(_iface, _method), FORMAT_ARGS(__VA_ARGS__), PRINT_ARGS_IN( __VA_ARGS__)); \
  172. HRESULT hr = hrSuccess; \
  173. try { \
  174. METHOD_PROLOGUE_(_class, _iface); \
  175. hr = pThis->_method(ARGS(__VA_ARGS__)); \
  176. } catch (const std::bad_alloc &) { \
  177. hr = MAPI_E_NOT_ENOUGH_MEMORY; \
  178. } \
  179. if (FAILED(hr)) \
  180. _trace(TRACE_RETURN, METHODSTR(_iface, _method), "FAILED: %s", GetMAPIErrorDescription(hr).c_str()); \
  181. else \
  182. _trace(TRACE_RETURN, METHODSTR(_iface, _method), "SUCCESS: " FORMAT_ARGS(__VA_ARGS__), PRINT_ARGS_OUT(__VA_ARGS__)); \
  183. return hr; \
  184. }
  185. /* without exception passthrough */
  186. #define DEF_HRMETHOD1(_trace, _class, _iface, _method, ...) \
  187. HRESULT __stdcall CLASSMETHOD(_class, CLASSMETHOD(XCLASS(_iface), _method))(ARGLIST(__VA_ARGS__)) \
  188. { \
  189. _trace(TRACE_ENTRY, METHODSTR(_iface, _method), FORMAT_ARGS(__VA_ARGS__), PRINT_ARGS_IN( __VA_ARGS__)); \
  190. METHOD_PROLOGUE_(_class, _iface); \
  191. HRESULT hr = pThis->_method(ARGS(__VA_ARGS__)); \
  192. if (FAILED(hr)) \
  193. _trace(TRACE_RETURN, METHODSTR(_iface, _method), "FAILED: %s", GetMAPIErrorDescription(hr).c_str()); \
  194. else \
  195. _trace(TRACE_RETURN, METHODSTR(_iface, _method), "SUCCESS: " FORMAT_ARGS(__VA_ARGS__), PRINT_ARGS_OUT(__VA_ARGS__)); \
  196. return hr; \
  197. }
  198. /* and without tracing */
  199. #define DEF_HRMETHOD0(_class, _iface, _method, ...) \
  200. HRESULT __stdcall CLASSMETHOD(_class, CLASSMETHOD(XCLASS(_iface), _method))(ARGLIST(__VA_ARGS__)) \
  201. { \
  202. METHOD_PROLOGUE_(_class, _iface); \
  203. return pThis->_method(ARGS(__VA_ARGS__)); \
  204. }
  205. #define DEF_HRMETHOD_EX(_trace, _class, _iface, _extra_fmt, _extra_arg, _method, ...) \
  206. HRESULT __stdcall CLASSMETHOD(_class, CLASSMETHOD(XCLASS(_iface), _method))(ARGLIST(__VA_ARGS__)) { \
  207. METHOD_PROLOGUE_(_class, _iface); \
  208. _trace(TRACE_ENTRY, METHODSTR(_iface, _method), _extra_fmt ", " FORMAT_ARGS(__VA_ARGS__), _extra_arg, PRINT_ARGS_IN( __VA_ARGS__)); \
  209. HRESULT hr = hrSuccess; \
  210. try { \
  211. hr = pThis->_method(ARGS(__VA_ARGS__)); \
  212. } catch (const std::bad_alloc &) { \
  213. hr = MAPI_E_NOT_ENOUGH_MEMORY; \
  214. } \
  215. if (FAILED(hr)) \
  216. _trace(TRACE_RETURN, METHODSTR(_iface, _method), "FAILED: %s " _extra_fmt, GetMAPIErrorDescription(hr).c_str(), _extra_arg); \
  217. else \
  218. _trace(TRACE_RETURN, METHODSTR(_iface, _method), "SUCCESS: " _extra_fmt ", " FORMAT_ARGS(__VA_ARGS__), _extra_arg, PRINT_ARGS_OUT(__VA_ARGS__)); \
  219. return hr; \
  220. }
  221. #define DEF_HRMETHOD_EX2(_trace, _class, _iface, _extra_fmt, _extra_arg1, _extra_arg2, _method, ...) \
  222. HRESULT __stdcall CLASSMETHOD(_class, CLASSMETHOD(XCLASS(_iface), _method))(ARGLIST(__VA_ARGS__)) { \
  223. METHOD_PROLOGUE_(_class, _iface); \
  224. _trace(TRACE_ENTRY, METHODSTR(_iface, _method), _extra_fmt ", " FORMAT_ARGS(__VA_ARGS__), _extra_arg1, _extra_arg2, PRINT_ARGS_IN( __VA_ARGS__)); \
  225. HRESULT hr = hrSuccess; \
  226. try { \
  227. hr = pThis->_method(ARGS(__VA_ARGS__)); \
  228. } catch (const std::bad_alloc &) { \
  229. hr = MAPI_E_NOT_ENOUGH_MEMORY; \
  230. } \
  231. if (FAILED(hr)) \
  232. _trace(TRACE_RETURN, METHODSTR(_iface, _method), "FAILED: %s " _extra_fmt, GetMAPIErrorDescription(hr).c_str(), _extra_arg1, _extra_arg2); \
  233. else \
  234. _trace(TRACE_RETURN, METHODSTR(_iface, _method), "SUCCESS: " _extra_fmt ", " FORMAT_ARGS(__VA_ARGS__), _extra_arg1, _extra_arg2, PRINT_ARGS_OUT(__VA_ARGS__)); \
  235. return hr; \
  236. }
  237. #define DEF_HRMETHOD_FORWARD(_trace, _class, _iface, _method, _member, ...) \
  238. HRESULT __stdcall CLASSMETHOD(_class, _method)(ARGLIST(__VA_ARGS__)) { \
  239. _trace(TRACE_ENTRY, METHODSTR(_iface, _method), FORMAT_ARGS(__VA_ARGS__), PRINT_ARGS_IN( __VA_ARGS__)); \
  240. HRESULT hr = hrSuccess; \
  241. try { \
  242. hr = _member->_method(ARGS(__VA_ARGS__)); \
  243. } catch (const std::bad_alloc &) { \
  244. hr = MAPI_E_NOT_ENOUGH_MEMORY; \
  245. } \
  246. if (FAILED(hr)) \
  247. _trace(TRACE_RETURN, METHODSTR(_iface, _method), "FAILED: %s", GetMAPIErrorDescription(hr).c_str()); \
  248. else \
  249. _trace(TRACE_RETURN, METHODSTR(_iface, _method), "SUCCESS: " FORMAT_ARGS(__VA_ARGS__), PRINT_ARGS_OUT(__VA_ARGS__)); \
  250. return hr; \
  251. }
  252. #define DEF_HRMETHOD_NOSUPPORT(_trace, _class, _iface, _method, ...) \
  253. HRESULT __stdcall CLASSMETHOD(_class, CLASSMETHOD(XCLASS(_iface), _method))(ARGLIST(__VA_ARGS__)) { \
  254. _trace(TRACE_ENTRY, METHODSTR(_iface, _method), FORMAT_ARGS(__VA_ARGS__), PRINT_ARGS_IN( __VA_ARGS__)); \
  255. HRESULT hr = MAPI_E_NO_SUPPORT; \
  256. _trace(TRACE_RETURN, METHODSTR(_iface, _method), "FAILED: %s", GetMAPIErrorDescription(hr).c_str()); \
  257. return hr; \
  258. }
  259. #define DEF_HRMETHOD0_NOSUPPORT(_class, _iface, _method, ...) \
  260. HRESULT __stdcall CLASSMETHOD(_class, CLASSMETHOD(XCLASS(_iface), _method))(ARGLIST(__VA_ARGS__)) \
  261. { \
  262. return MAPI_E_NO_SUPPORT; \
  263. }