sqconfig.h 5.5 KB

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