sqconfig.h 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259
  1. #ifndef NO_ABSTRACT_METHOD
  2. #define ABSTRACT_METHOD(m, i) m =0;
  3. #else
  4. #define ABSTRACT_METHOD(m, i) m i
  5. #endif
  6. typedef uintptr_t SQHash; /*should be the same size of a pointer*/
  7. typedef float SQFloat32;
  8. typedef double SQFloat64;
  9. typedef long long SQInt64;
  10. typedef unsigned long long SQUInt64;
  11. typedef int SQInt32; /*must be 32 bits(also on 64bits processors)*/
  12. typedef unsigned int SQUInt32; /*must be 32 bits(also on 64bits processors)*/
  13. typedef unsigned int SQUnsignedInteger32; /*must be 32 bits(also on 64bits processors)*/
  14. typedef short SQInt16;
  15. typedef unsigned short SQUInt16;
  16. typedef unsigned short SQUnsignedInt16;
  17. typedef char SQInt8;
  18. typedef unsigned char SQUInt8;
  19. #ifdef _SQ64
  20. #ifdef _MSC_VER
  21. #define SQ_INT_MAX _I64_MAX
  22. #define SQ_INT_MIN _I64_MIN
  23. #else
  24. #define SQ_INT_MAX LLONG_MAX
  25. #define SQ_INT_MIN LLONG_MIN
  26. #endif
  27. #ifdef _MSC_VER
  28. #define SQ_INT_MAX _I64_MAX
  29. #define SQ_INT_MIN _I64_MIN
  30. typedef __int64 SQInteger;
  31. typedef unsigned __int64 SQUnsignedInteger;
  32. #else
  33. #define SQ_INT_MAX LLONG_MAX
  34. #define SQ_INT_MIN LLONG_MIN
  35. typedef long long SQInteger;
  36. typedef unsigned long long SQUnsignedInteger;
  37. #endif
  38. #else
  39. #define SQ_INT_MAX INT_MAX
  40. #define SQ_INT_MIN INT_MIN
  41. typedef int SQInteger;
  42. typedef unsigned int SQUnsignedInteger;
  43. #endif
  44. #ifdef SQUSEDECIMAL64
  45. typedef _Decimal64 SQFloat;
  46. #elif defined(SQUSEDOUBLE)
  47. typedef double SQFloat;
  48. #else
  49. typedef float SQFloat;
  50. #endif
  51. #if defined(SQUSEDOUBLE) || defined(_SQ64)
  52. #ifdef _MSC_VER
  53. typedef __int64 SQRawObjectVal; //must be 64bits
  54. #else
  55. typedef long long SQRawObjectVal; //must be 64bits
  56. #endif
  57. #define SQ_OBJECT_RAWINIT() { _unVal.raw = 0; }
  58. #else
  59. typedef SQUnsignedInteger SQRawObjectVal; //is 32 bits on 32 bits builds and 64 bits otherwise
  60. #define SQ_OBJECT_RAWINIT()
  61. #endif
  62. #ifndef SQ_ALIGNMENT // SQ_ALIGNMENT shall be less than or equal to SQ_MALLOC alignments, and its value shall be power of 2.
  63. #if defined(SQUSEDOUBLE) || defined(_SQ64)
  64. #define SQ_ALIGNMENT 8
  65. #else
  66. #define SQ_ALIGNMENT 4
  67. #endif
  68. #endif
  69. typedef SQUnsignedInteger SQSizeType;
  70. typedef void* SQUserPointer;
  71. typedef SQInteger SQBool;
  72. typedef SQInteger SQRESULT;
  73. typedef SQUnsignedInteger SQUInteger;
  74. #ifdef SQUNICODE
  75. #include <wchar.h>
  76. #include <wctype.h>
  77. typedef wchar_t SQChar;
  78. typedef unsigned wchar_t SQUChar;
  79. #define scstrcmp wcscmp
  80. #ifdef _WIN32
  81. #define scsprintf _snwprintf
  82. #define scvfprintf _vfwprintf
  83. #define scfprintf fwprintf
  84. #define scvprintf vfwprintf
  85. #define scfopen _wfopen
  86. #define scgetenv _wgetenv
  87. #define scsystem _wsystem
  88. #define scasctime _wasctime
  89. #define scstrftime _wstrftime
  90. #define scremove _wremove
  91. #define screname _wrename
  92. #else
  93. #define scsprintf swprintf
  94. #define scvfprintf vfwprintf
  95. #define scfprintf fwprintf
  96. #define scvprintf vfwprintf
  97. #define scfopen wfopen
  98. #define scgetenv wgetenv
  99. #define scsystem wsystem
  100. #define scasctime wasctime
  101. #define scstrftime wstrftime
  102. #define scremove wremove
  103. #define screname wrename
  104. #endif
  105. #define scstrlen wcslen
  106. #define scstrcpy wcstrcpy
  107. #define scstrtod wcstod
  108. #ifdef _SQ64
  109. #define scstrtol wcstoll
  110. #else
  111. #define scstrtol wcstol
  112. #endif
  113. #define scstrtoul wcstoul
  114. #define scvsprintf vswprintf
  115. #define scstrstr wcsstr
  116. #define scstrchr wcschr
  117. #define scstrncmp wcstrncmp
  118. #define scstrpbrk wcspbrk
  119. #define scstrtok wcstrtok
  120. #define scprintf wprintf
  121. #define scgetenv wgetenv
  122. #define scsystem wsystem
  123. #define scasctime wasctime
  124. #define scstrftime wstrftime
  125. #define scremove wremove
  126. #define screname wrename
  127. #ifdef _WIN32
  128. #define WCHAR_SIZE 2
  129. #define WCHAR_SHIFT_MUL 1
  130. #define MAX_CHAR 0xFFFF
  131. #else
  132. #define WCHAR_SIZE 4
  133. #define WCHAR_SHIFT_MUL 2
  134. #define MAX_CHAR 0xFFFFFFFF
  135. #endif
  136. #define _SC(a) L##a
  137. #define scisspace iswspace
  138. #define scisdigit iswdigit
  139. #define scisprint iswprint
  140. #define scisxdigit iswxdigit
  141. #define scisalpha iswalpha
  142. #define sciscntrl iswcntrl
  143. #define scisalnum iswalnum
  144. #define scisupper iswupper
  145. #define scislower iswlower
  146. #define sq_rsl(l) ((l)<<WCHAR_SHIFT_MUL)
  147. #define sq_str_sizeof(p) (sizeof(p)/WCHAR_SIZE)
  148. #else
  149. typedef char SQChar;
  150. typedef unsigned char SQUChar;
  151. #define _SC(a) a
  152. #define scstrcmp strcmp
  153. #ifdef _MSC_VER
  154. #define scsprintf _snprintf
  155. #define scvfprintf _vfprintf
  156. #define scfprintf fprintf
  157. #define scvprintf vfprintf
  158. #define scfopen fopen
  159. #else
  160. #define scsprintf snprintf
  161. #define scvfprintf vfprintf
  162. #define scfprintf fprintf
  163. #define scvprintf vfprintf
  164. #define scfopen fopen
  165. #endif
  166. #define scstrlen strlen
  167. #define scstrcpy strcpy
  168. #define scstrtod strtod
  169. #ifdef _SQ64
  170. #ifdef _MSC_VER
  171. #define scstrtol _strtoi64
  172. #else
  173. #define scstrtol strtoll
  174. #endif
  175. #else
  176. #define scstrtol strtol
  177. #endif
  178. #define scstrtoul strtoul
  179. #define scvsprintf vsnprintf
  180. #define scstrstr strstr
  181. #define scstrpbrk strpbrk
  182. #define scstrchr strchr
  183. #define scstrncmp strncmp
  184. #define scstrtok strtok
  185. #define scisspace isspace
  186. #define scisdigit isdigit
  187. #define scisprint isprint
  188. #define scisxdigit isxdigit
  189. #define sciscntrl iscntrl
  190. #define scisalpha isalpha
  191. #define scisalnum isalnum
  192. #define scisupper isupper
  193. #define scislower islower
  194. #define scprintf printf
  195. #define MAX_CHAR 0xFF
  196. #define scgetenv getenv
  197. #define scsystem system
  198. #define scasctime asctime
  199. #define scstrftime strftime
  200. #define scremove remove
  201. #define screname rename
  202. #define sq_rsl(l) (l)
  203. #define sq_str_sizeof(p) (sizeof(p))
  204. #endif
  205. #ifdef _SQ64
  206. #define _PRINT_INT_PREC _SC("ll")
  207. #define _PRINT_INT_FMT _SC("%lld")
  208. #else
  209. #define _PRINT_INT_FMT _SC("%d")
  210. #endif
  211. #if defined(SQUSEDOUBLE)
  212. #define _PRINT_FLOAT_PREC _SC("%.14g")
  213. #else
  214. #define _PRINT_FLOAT_PREC _SC("%.7g")
  215. #endif
  216. #if !defined(SQUILU_MAX_PATH)
  217. #define SQUILU_MAX_PATH 1024
  218. #endif
  219. #if defined(_WIN32)
  220. #define SQUILU_DIRSEP _SC("\\")
  221. #else
  222. #define SQUILU_DIRSEP _SC("/")
  223. #endif
  224. #if !defined(SQUILU_PATH_VAR)
  225. #define SQUILU_PATH_VAR _SC("SQUILU_PATH")
  226. #endif
  227. #if !defined (SQUILU_PATH_SEP)
  228. #define SQUILU_PATH_SEP _SC(";")
  229. #endif