Team Fortress 2 Source Code as on 22/4/2020
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.

414 lines
14 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. // $NoKeywords: $
  6. //
  7. //=============================================================================//
  8. #ifndef JM_OPT_H
  9. #define JM_OPT_H
  10. /* #define JM_AUTO_CONFIGURE */
  11. #ifdef JM_AUTO_CONFIGURE
  12. /* Namespace Options: */
  13. /* JM_NO_NAMESPACES Define if your compiler does not support namespaces */
  14. /* #define JM_NO_NAMESPACES */
  15. /* __JM Defines the namespace used for this library,
  16. defaults to "jm", but can be changed by defining
  17. __JM on the command line. */
  18. /* #define __JM */
  19. /* __JM_STD Defines the namespace used by the underlying STL
  20. (if any), defaults to "std", can be changed by
  21. defining __JM_STD on the command line. */
  22. /* #define __JM_STD */
  23. /* __JM_STDC Defines the namespace used by the C Library defs.
  24. Defaults to "std" as recomended by the latest
  25. draft standard, can be redefined by defining
  26. __JM_STDC on the command line. */
  27. /* #define __JM_STDC */
  28. /* Compiler options: */
  29. /* JM_NO_EXCEPTIONS Disables exception handling support. */
  30. /* #define JM_NO_EXCEPTIONS */
  31. /* JM_NO_MUTABLE Disables use of mutable keyword. */
  32. /* #define JM_NO_MUTABLE */
  33. /* JM_INT32 The type for 32-bit integers - what C calls intfast32_t */
  34. /* #define JM_INT32 */
  35. /* JM_NO_DEFAULT_PARAM If templates can not have default parameters. */
  36. /* #define JM_NO_DEFAULT_PARAM */
  37. /* JM_NO_TRICKY_DEFAULT_PARAM If templates can not have derived default parameters. */
  38. /* #define JM_NO_TRICKY_DEFAULT_PARAM */
  39. /* JM_NO_TEMPLATE_TYPENAME If class scope typedefs of the form:
  40. typedef typename X<T> Y;
  41. where T is a template parameter to this,
  42. do not compile unless the typename is omitted. */
  43. /* #define JM_NO_TEMPLATE_TYPENAME */
  44. /* JM_NO_TEMPLATE_FRIEND If template friend declarations are not supported */
  45. /* #define JM_NO_TEMPLATE_FRIEND */
  46. /* JM_PLATFORM_WINDOWS Platform is MS Windows. */
  47. /* #define JM_PLATFORM_WINDOWS */
  48. /* JM_PLATFORM_DOS Platform if MSDOS. */
  49. /* #define JM_PLATFORM_DOS */
  50. /* JM_PLATFORM_W32 Platform is MS Win32 */
  51. /* #define JM_PLATFORM_W32 */
  52. /* JM_NO_WIN32 Disable Win32 support even when present */
  53. /* #define JM_NO_WIN32 */
  54. /* JM_NO_BOOL If bool is not a distict type. */
  55. /* #define JM_NO_BOOL */
  56. /* JM_NO_WCHAR_H If there is no <wchar.h> */
  57. /* #define JM_NO_WCHAR_H */
  58. /* JM_NO_WCTYPE_H If there is no <wctype.h> */
  59. /* #define JM_NO_WCTYPE_H */
  60. /* JM_NO_WCSTRING If there are no wcslen and wcsncmp functions available. */
  61. /* #define JM_NO_WCSTRING */
  62. /* JM_NO_SWPRINTF If there is no swprintf available. */
  63. /* #define JM_NO_SWPRINTF */
  64. /* JM_NO_WSPRINTF If there is no wsprintf available. */
  65. /* #define JM_NO_WSPRINTF */
  66. /* JM_NO_MEMBER_TEMPLATES If member function templates or nested template classes are not allowed. */
  67. /* #define JM_NO_MEMBER_TEMPLATES */
  68. /* JM_NO_TEMPLATE_RETURNS If template functions based on return type are not supported. */
  69. /* #define JM_NO_TEMPLATE_RETURNS */
  70. /* JM_NO_PARTIAL_FUNC_SPEC If partial template function specialisation is not supported */
  71. /* #define JM_NO_PARTIAL_FUNC_SPEC */
  72. /* JM_NO_INT64 If 64bit integers are not supported. */
  73. /* JM_INT64t The type of a 64-bit signed integer if available. */
  74. /* JM_IMM64(val) Declares a 64-bit immediate value by appending any
  75. necessary suffix to val. */
  76. /* JM_INT64_T 0 = NA
  77. 1 = short
  78. 2 = int
  79. 3 = long
  80. 4 = int64_t
  81. 5 = long long
  82. 6 = __int64 */
  83. /* #define JM_INT64_T */
  84. /* JM_NO_CAT Define if the compiler does not support POSIX style
  85. message categories (catopen catgets catclose). */
  86. /* #define JM_NO_CAT */
  87. /* JM_THREADS Define if the compiler supports multiple threads in
  88. the current translation mode. */
  89. /* #define JM_THREADS */
  90. /* JM_TEMPLATE_SPECIALISE Defaults to template<> , ie the template specialisation
  91. prefix, can be redefined to nothing for older compilers. */
  92. /* #define JM_TEMPLATE_SPECIALISE */
  93. /* JM_NESTED_TEMPLATE_DECL Defaults to template, the standard prefix when accessing
  94. nested template classes, can be redefined to nothing if
  95. the compiler does not support this. */
  96. /* #define JM_NESTED_TEMPLATE_DECL */
  97. /* JM_NO_TEMPLATE_INST If explicit template instantiation with the "template class X<T>"
  98. syntax is not supported */
  99. /* #define JM_NO_TEMPLATE_INST */
  100. /* JM_NO_TEMPLATE_MERGE If template in separate translation units don't merge at link time */
  101. /* #define JM_NO_TEMPLATE_MERGE */
  102. /* JM_NO_TEMPLATE_MERGE_A If template merging from library archives is not supported */
  103. /* #define JM_NO_TEMPLATE_MERGE_A */
  104. /* JM_NO_TEMPLATE_SWITCH_MERGE If merging of templates containing switch statements is not supported */
  105. /* #define JM_NO_TEMPLATE_SWITCH_MERGE */
  106. /* RE_CALL Optionally define a calling convention for C++ functions */
  107. /* #define RE_CALL */
  108. /* RE_CCALL Optionally define a calling convention for C functions */
  109. /* #define RE_CCALL */
  110. /* JM_SIZEOF_SHORT sizeof(short) */
  111. /* #define JM_SIZEOF_SHORT */
  112. /* JM_SIZEOF_INT sizeof(int) */
  113. /* #define JM_SIZEOF_INT */
  114. /* JM_SIZEOF_LONG sizeof(long) */
  115. /* #define JM_SIZEOF_LONG */
  116. /* JM_SIZEOF_WCHAR_T sizeof(wchar_t) */
  117. /* #define JM_SIZEOF_WCHAR_T */
  118. /* STL options: */
  119. /* JM_NO_EXCEPTION_H Define if you do not a compliant <exception>
  120. header file. */
  121. /* #define JM_NO_EXCEPTION_H */
  122. /* JM_NO_ITERATOR_H Define if you do not have a version of <iterator>. */
  123. /* #define JM_NO_ITERATOR_H */
  124. /* JM_NO_MEMORY_H Define if <memory> does not fully comply with the
  125. latest standard, and is not auto-recognised,
  126. that means nested template classes
  127. which hardly any compilers support at present. */
  128. /* #define JM_NO_MEMORY_H */
  129. /* JM_NO_LOCALE_H Define if there is no verion of the standard
  130. <locale> header available. */
  131. /* #define JM_NO_LOCALE_H */
  132. /* JM_NO_STL Disables the use of any supporting STL code. */
  133. /* #define JM_NO_STL */
  134. /* JM_NO_NOT_EQUAL Disables the generation of operator!= if this
  135. clashes with the STL version. */
  136. /* JM_NO_STRING_H Define if <string> not available */
  137. /* #define JM_NO_STRING_H */
  138. /* JM_NO_STRING_DEF_ARGS Define if std::basic_string<charT> not allowed - in
  139. other words if the template is missing its required
  140. default arguments. */
  141. /* #define JM_NO_STRING_DEF_ARGS */
  142. /* JM_NO_TYPEINFO Define if <typeinfo> is absent or non-standard */
  143. /* #define JM_NO_TYPEINFO */
  144. /* JM_USE_ALGO If <algo.h> not <algorithm> is present */
  145. /* #define JM_USE_ALGO */
  146. /* JM_OLD_IOSTREAM If the new iostreamm classes are not available */
  147. /* #define JM_OLD_IOSTREAM */
  148. /* JM_DISTANCE_T For std::distance:
  149. 0 = NA
  150. 1 = std::distance(i, j, n)
  151. 2 = n = std::distance(i, j) */
  152. /* #define JM_DISTANCE_T */
  153. /* JM_ITERATOR_T Defines generic standard iterator type if available, use this as
  154. a shortcut to define all the other iterator types.
  155. 1 = __JM_STD::iterator<__JM_STD::tag_type, T, D, T*, T&>
  156. 2 = __JM_STD::iterator<__JM_STD::tag_type, T, D> */
  157. /* #define JM_ITERATOR_T */
  158. /* JM_OI_T For output iterators:
  159. 0 = NA
  160. 1 = __JM_STD::iterator<__JM_STD::output_iterator_tag, T, D, T*, T&>
  161. 2 = __JM_STD::iterator<__JM_STD::output_iterator_tag, T, D>
  162. 3 = __JM_STD::output_iterator */
  163. /* #define JM_OI_T */
  164. /* JM_II_T For input iterators:
  165. 0 = NA
  166. 1 = __JM_STD::iterator<__JM_STD::input_iterator_tag, T, D, T*, T&>
  167. 2 = __JM_STD::iterator<__JM_STD::input_iterator_tag, T, D>
  168. 3 = __JM_STD::input_iterator<T, D>
  169. 4 = __JM_STD::input_iterator<T> */
  170. /* #define JM_II_T */
  171. /* JM_FI_T For forward iterators:
  172. 0 = NA
  173. 1 = __JM_STD::iterator<__JM_STD::forward_iterator_tag, T, D, T*, T&>
  174. 2 = __JM_STD::iterator<__JM_STD::forward_iterator_tag, T, D>
  175. 3 = __JM_STD::forward_iterator<T, D> */
  176. /* #define JM_FI_T */
  177. /* JM_BI_T For bidirectional iterators:
  178. 0 = NA
  179. 1 = __JM_STD::iterator<__JM_STD::bidirectional_iterator_tag, T, D, T*, T&>
  180. 2 = __JM_STD::iterator<__JM_STD::bidirectional_iterator_tag, T, D>
  181. 3 = __JM_STD::bidirectional_iterator<T, D> */
  182. /* #define JM_BI_T */
  183. /* JM_RI_T For random access iterators:
  184. 0 = NA
  185. 1 = __JM_STD::iterator<__JM_STD::random_access_iterator_tag, T, D, T*, T&>
  186. 2 = __JM_STD::iterator<__JM_STD::random_access_iterator_tag, T, D>
  187. 3 = __JM_STD::random_access_iterator<T, D> */
  188. /* #define JM_RI_T */
  189. /* JM_NO_OI_ASSIGN If output iterators ostream_iterator<>, back_insert_iterator<> and
  190. front_insert_iterator<> do not have assignment operators */
  191. /* #define JM_NO_OI_ASSIGN */
  192. #if JM_INT64_T == 0
  193. #define JM_NO_INT64
  194. #elif JM_INT64_T == 1
  195. #define JM_INT64t short
  196. #define JM_IMM64(val) val
  197. #elif JM_INT64_T == 2
  198. #define JM_INT64t int
  199. #define JM_IMM64(val) val
  200. #elif JM_INT64_T == 3
  201. #define JM_INT64t long
  202. #define JM_IMM64(val) val##L
  203. #elif JM_INT64_T == 4
  204. #define JM_INT64t int64_t
  205. #define JM_IMM64(val) INT64_C(val)
  206. #elif JM_INT64_T == 5
  207. #define JM_INT64t long long
  208. #define JM_IMM64(val) val##LL
  209. #elif JM_INT64_T == 6
  210. #define JM_INT64t __int64
  211. #define JM_IMM64(val) val##i64
  212. #else
  213. syntax error: unknown value for JM_INT64_T
  214. #endif
  215. #if JM_DISTANCE_T == 0
  216. # define JM_DISTANCE(i, j, n) n = j - i
  217. #elif JM_DISTANCE_T == 1
  218. # define JM_DISTANCE(i, j, n) n = __JM_STD::distance(i, j)
  219. #elif JM_DISTANCE_T == 2
  220. # define JM_DISTANCE(i, j, n) (n = 0, __JM_STD::distance(i, j, n))
  221. #else
  222. syntax erorr
  223. #endif
  224. #ifdef JM_ITERATOR_T
  225. #ifndef JM_OI_T
  226. #define JM_OI_T JM_ITERATOR_T
  227. #endif
  228. #ifndef JM_II_T
  229. #define JM_II_T JM_ITERATOR_T
  230. #endif
  231. #ifndef JM_FI_T
  232. #define JM_FI_T JM_ITERATOR_T
  233. #endif
  234. #ifndef JM_BI_T
  235. #define JM_BI_T JM_ITERATOR_T
  236. #endif
  237. #ifndef JM_RI_T
  238. #define JM_RI_T JM_ITERATOR_T
  239. #endif
  240. #endif
  241. #if JM_OI_T == 0
  242. # define JM_OUTPUT_ITERATOR(T, D) dummy_iterator_base<T>
  243. #elif JM_OI_T == 1
  244. # define JM_OUTPUT_ITERATOR(T, D) __JM_STD::iterator<__JM_STD::output_iterator_tag, T, D, T*, T&>
  245. #elif JM_OI_T == 2
  246. # define JM_OUTPUT_ITERATOR(T, D) __JM_STD::iterator<__JM_STD::output_iterator_tag, T, D>
  247. #elif JM_OI_T == 3
  248. # define JM_OUTPUT_ITERATOR(T, D) __JM_STD::output_iterator
  249. #else
  250. syntax error
  251. #endif
  252. #if JM_II_T == 0
  253. # define JM_INPUT_ITERATOR(T, D) dummy_iterator_base<T>
  254. #elif JM_II_T == 1
  255. #define JM_INPUT_ITERATOR(T, D) __JM_STD::iterator<__JM_STD::input_iterator_tag, T, D, T*, T&>
  256. #elif JM_II_T == 2
  257. #define JM_INPUT_ITERATOR(T, D) __JM_STD::iterator<__JM_STD::input_iterator_tag, T, D>
  258. #elif JM_II_T == 3
  259. # define JM_INPUT_ITERATOR(T, D) __JM_STD::input_iterator<T, D>
  260. #elif JM_II_T == 4
  261. # define JM_INPUT_ITERATOR(T, D) __JM_STD::input_iterator<T>
  262. #else
  263. syntax error
  264. #endif
  265. #if JM_FI_T == 0
  266. # define JM_FWD_ITERATOR(T, D) dummy_iterator_base<T>
  267. #elif JM_FI_T == 1
  268. # define JM_FWD_ITERATOR(T, D) __JM_STD::iterator<__JM_STD::forward_iterator_tag, T, D, T*, T&>
  269. #elif JM_FI_T == 2
  270. # define JM_FWD_ITERATOR(T, D) __JM_STD::iterator<__JM_STD::forward_iterator_tag, T, D>
  271. #elif JM_FI_T == 3
  272. # define JM_FWD_ITERATOR(T, D) __JM_STD::forward_iterator<T, D>
  273. #else
  274. syntax error
  275. #endif
  276. #if JM_BI_T == 0
  277. # define JM_BIDI_ITERATOR(T, D) dummy_iterator_base<T>
  278. #elif JM_BI_T == 1
  279. # define JM_BIDI_ITERATOR(T, D) __JM_STD::iterator<__JM_STD::bidirectional_iterator_tag, T, D, T*, T&>
  280. #elif JM_BI_T == 2
  281. # define JM_BIDI_ITERATOR(T, D) __JM_STD::iterator<__JM_STD::bidirectional_iterator_tag, T, D>
  282. #elif JM_BI_T == 3
  283. # define JM_BIDI_ITERATOR(T, D) __JM_STD::bidirectional_iterator<T, D>
  284. #else
  285. syntax error
  286. #endif
  287. #if JM_RI_T == 0
  288. # define JM_RA_ITERATOR(T, D) dummy_iterator_base<T>
  289. #elif JM_RI_T == 1
  290. # define JM_RA_ITERATOR(T, D) __JM_STD::iterator<__JM_STD::random_access_iterator_tag, T, D, T*, T&>
  291. #elif JM_RI_T == 2
  292. # define JM_RA_ITERATOR(T, D) __JM_STD::iterator<__JM_STD::random_access_iterator_tag, T, D>
  293. #elif JM_RI_T == 3
  294. # define JM_RA_ITERATOR(T, D) __JM_STD::random_access_iterator<T, D>
  295. #else
  296. syntax error
  297. #endif
  298. #ifndef JM_NO_EXCEPTION_H
  299. #include <exception>
  300. #endif
  301. #ifndef JM_NO_ITERATOR_H
  302. #include <iterator>
  303. #ifdef JM_USE_ALGO
  304. #include <algo.h>
  305. #else
  306. #include <algorithm>
  307. #endif
  308. #endif
  309. #ifdef JM_NO_MEMORY_H
  310. #define JM_OLD_ALLOCATORS
  311. #define REBIND_INSTANCE(x, y, inst) re_alloc_binder<x, y>(inst)
  312. #define REBIND_TYPE(x, y) re_alloc_binder<x, y>
  313. #define JM_DEF_ALLOC_PARAM(x) JM_DEFAULT_PARAM( jm_def_alloc )
  314. #define JM_DEF_ALLOC(x) jm_def_alloc
  315. #define JM_NEED_BINDER
  316. #define JM_NEED_ALLOC
  317. #else
  318. #include <memory>
  319. #define REBIND_INSTANCE(x, y, inst) y::JM_NESTED_TEMPLATE_DECL rebind<x>::other(inst)
  320. #define REBIND_TYPE(x, y) y::JM_NESTED_TEMPLATE_DECL rebind<x>::other
  321. #define JM_DEF_ALLOC_PARAM(x) JM_TRICKY_DEFAULT_PARAM( __JM_STD::allocator<x> )
  322. #define JM_DEF_ALLOC(x) __JM_STD::allocator<x>
  323. #endif
  324. #endif // JM_AUTO_CONFIGURE
  325. #endif /* JM_OPT_H */