| 1 |  | 
|---|
| 2 | #ifdef _SQ64 | 
|---|
| 3 |  | 
|---|
| 4 | #ifdef _MSC_VER | 
|---|
| 5 | typedef __int64 SQInteger; | 
|---|
| 6 | typedef unsigned __int64 SQUnsignedInteger; | 
|---|
| 7 | typedef unsigned __int64 SQHash; /*should be the same size of a pointer*/ | 
|---|
| 8 | #else | 
|---|
| 9 | typedef long long SQInteger; | 
|---|
| 10 | typedef unsigned long long SQUnsignedInteger; | 
|---|
| 11 | typedef unsigned long long SQHash; /*should be the same size of a pointer*/ | 
|---|
| 12 | #endif | 
|---|
| 13 | typedef int SQInt32; | 
|---|
| 14 | typedef unsigned int SQUnsignedInteger32; | 
|---|
| 15 | #else | 
|---|
| 16 | typedef int SQInteger; | 
|---|
| 17 | typedef int SQInt32; /*must be 32 bits(also on 64bits processors)*/ | 
|---|
| 18 | typedef unsigned int SQUnsignedInteger32; /*must be 32 bits(also on 64bits processors)*/ | 
|---|
| 19 | typedef unsigned int SQUnsignedInteger; | 
|---|
| 20 | typedef unsigned int SQHash; /*should be the same size of a pointer*/ | 
|---|
| 21 | #endif | 
|---|
| 22 |  | 
|---|
| 23 |  | 
|---|
| 24 | #ifdef SQUSEDOUBLE | 
|---|
| 25 | typedef double SQFloat; | 
|---|
| 26 | #else | 
|---|
| 27 | typedef float SQFloat; | 
|---|
| 28 | #endif | 
|---|
| 29 |  | 
|---|
| 30 | #if defined(SQUSEDOUBLE) && !defined(_SQ64) || !defined(SQUSEDOUBLE) && defined(_SQ64) | 
|---|
| 31 | #ifdef _MSC_VER | 
|---|
| 32 | typedef __int64 SQRawObjectVal; //must be 64bits | 
|---|
| 33 | #else | 
|---|
| 34 | typedef long long SQRawObjectVal; //must be 64bits | 
|---|
| 35 | #endif | 
|---|
| 36 | #define SQ_OBJECT_RAWINIT() { _unVal.raw = 0; } | 
|---|
| 37 | #else | 
|---|
| 38 | typedef SQUnsignedInteger SQRawObjectVal; //is 32 bits on 32 bits builds and 64 bits otherwise | 
|---|
| 39 | #define SQ_OBJECT_RAWINIT() | 
|---|
| 40 | #endif | 
|---|
| 41 |  | 
|---|
| 42 | #ifndef SQ_ALIGNMENT // SQ_ALIGNMENT shall be less than or equal to SQ_MALLOC alignments, and its value shall be power of 2. | 
|---|
| 43 | #if defined(SQUSEDOUBLE) || defined(_SQ64) | 
|---|
| 44 | #define SQ_ALIGNMENT 8 | 
|---|
| 45 | #else | 
|---|
| 46 | #define SQ_ALIGNMENT 4 | 
|---|
| 47 | #endif | 
|---|
| 48 | #endif | 
|---|
| 49 |  | 
|---|
| 50 | typedef void* SQUserPointer; | 
|---|
| 51 | typedef SQUnsignedInteger SQBool; | 
|---|
| 52 | typedef SQInteger SQRESULT; | 
|---|
| 53 |  | 
|---|
| 54 | #ifdef SQUNICODE | 
|---|
| 55 | #include <wchar.h> | 
|---|
| 56 | #include <wctype.h> | 
|---|
| 57 |  | 
|---|
| 58 |  | 
|---|
| 59 | typedef wchar_t SQChar; | 
|---|
| 60 |  | 
|---|
| 61 |  | 
|---|
| 62 | #define scstrcmp    wcscmp | 
|---|
| 63 | #ifdef _WIN32 | 
|---|
| 64 | #define scsprintf   _snwprintf | 
|---|
| 65 | #else | 
|---|
| 66 | #define scsprintf   swprintf | 
|---|
| 67 | #endif | 
|---|
| 68 | #define scstrlen    wcslen | 
|---|
| 69 | #define scstrtod    wcstod | 
|---|
| 70 | #ifdef _SQ64 | 
|---|
| 71 | #define scstrtol    wcstoll | 
|---|
| 72 | #else | 
|---|
| 73 | #define scstrtol    wcstol | 
|---|
| 74 | #endif | 
|---|
| 75 | #define scstrtoul   wcstoul | 
|---|
| 76 | #define scvsprintf  vswprintf | 
|---|
| 77 | #define scstrstr    wcsstr | 
|---|
| 78 | #define scprintf    wprintf | 
|---|
| 79 |  | 
|---|
| 80 | #ifdef _WIN32 | 
|---|
| 81 | #define WCHAR_SIZE 2 | 
|---|
| 82 | #define WCHAR_SHIFT_MUL 1 | 
|---|
| 83 | #define MAX_CHAR 0xFFFF | 
|---|
| 84 | #else | 
|---|
| 85 | #define WCHAR_SIZE 4 | 
|---|
| 86 | #define WCHAR_SHIFT_MUL 2 | 
|---|
| 87 | #define MAX_CHAR 0xFFFFFFFF | 
|---|
| 88 | #endif | 
|---|
| 89 |  | 
|---|
| 90 | #define _SC(a) L##a | 
|---|
| 91 |  | 
|---|
| 92 |  | 
|---|
| 93 | #define scisspace   iswspace | 
|---|
| 94 | #define scisdigit   iswdigit | 
|---|
| 95 | #define scisprint   iswprint | 
|---|
| 96 | #define scisxdigit  iswxdigit | 
|---|
| 97 | #define scisalpha   iswalpha | 
|---|
| 98 | #define sciscntrl   iswcntrl | 
|---|
| 99 | #define scisalnum   iswalnum | 
|---|
| 100 |  | 
|---|
| 101 |  | 
|---|
| 102 | #define sq_rsl(l) ((l)<<WCHAR_SHIFT_MUL) | 
|---|
| 103 |  | 
|---|
| 104 | #else | 
|---|
| 105 | typedef char SQChar; | 
|---|
| 106 | #define _SC(a) a | 
|---|
| 107 | #define scstrcmp    strcmp | 
|---|
| 108 | #ifdef _MSC_VER | 
|---|
| 109 | #define scsprintf   _snprintf | 
|---|
| 110 | #else | 
|---|
| 111 | #define scsprintf   snprintf | 
|---|
| 112 | #endif | 
|---|
| 113 | #define scstrlen    strlen | 
|---|
| 114 | #define scstrtod    strtod | 
|---|
| 115 | #ifdef _SQ64 | 
|---|
| 116 | #ifdef _MSC_VER | 
|---|
| 117 | #define scstrtol    _strtoi64 | 
|---|
| 118 | #else | 
|---|
| 119 | #define scstrtol    strtoll | 
|---|
| 120 | #endif | 
|---|
| 121 | #else | 
|---|
| 122 | #define scstrtol    strtol | 
|---|
| 123 | #endif | 
|---|
| 124 | #define scstrtoul   strtoul | 
|---|
| 125 | #define scvsprintf  vsnprintf | 
|---|
| 126 | #define scstrstr    strstr | 
|---|
| 127 | #define scisspace   isspace | 
|---|
| 128 | #define scisdigit   isdigit | 
|---|
| 129 | #define scisprint   isprint | 
|---|
| 130 | #define scisxdigit  isxdigit | 
|---|
| 131 | #define sciscntrl   iscntrl | 
|---|
| 132 | #define scisalpha   isalpha | 
|---|
| 133 | #define scisalnum   isalnum | 
|---|
| 134 | #define scprintf    printf | 
|---|
| 135 | #define MAX_CHAR 0xFF | 
|---|
| 136 |  | 
|---|
| 137 | #define sq_rsl(l) (l) | 
|---|
| 138 |  | 
|---|
| 139 | #endif | 
|---|
| 140 |  | 
|---|
| 141 | #ifdef _SQ64 | 
|---|
| 142 | #define _PRINT_INT_PREC _SC("ll") | 
|---|
| 143 | #define _PRINT_INT_FMT _SC("%lld") | 
|---|
| 144 | #else | 
|---|
| 145 | #define _PRINT_INT_FMT _SC("%d") | 
|---|
| 146 | #endif | 
|---|
| 147 |  | 
|---|