Added support for sizeof(wchar_t). Improved <Windows.h> type testing for Win64 platform.
This commit is contained in:
parent
5555e055f1
commit
e5ebb49312
|
@ -147,6 +147,7 @@ bool Settings::platform(PlatformType type)
|
|||
sizeof_float = sizeof(float);
|
||||
sizeof_double = sizeof(double);
|
||||
sizeof_long_double = sizeof(long double);
|
||||
sizeof_wchar_t = sizeof(wchar_t);
|
||||
sizeof_size_t = sizeof(std::size_t);
|
||||
sizeof_pointer = sizeof(void *);
|
||||
return true;
|
||||
|
@ -161,6 +162,7 @@ bool Settings::platform(PlatformType type)
|
|||
sizeof_float = 4;
|
||||
sizeof_double = 8;
|
||||
sizeof_long_double = 8;
|
||||
sizeof_wchar_t = 2;
|
||||
sizeof_size_t = 4;
|
||||
sizeof_pointer = 4;
|
||||
return true;
|
||||
|
@ -174,6 +176,7 @@ bool Settings::platform(PlatformType type)
|
|||
sizeof_float = 4;
|
||||
sizeof_double = 8;
|
||||
sizeof_long_double = 8;
|
||||
sizeof_wchar_t = 2;
|
||||
sizeof_size_t = 8;
|
||||
sizeof_pointer = 8;
|
||||
return true;
|
||||
|
@ -187,6 +190,7 @@ bool Settings::platform(PlatformType type)
|
|||
sizeof_float = 4;
|
||||
sizeof_double = 8;
|
||||
sizeof_long_double = 12;
|
||||
sizeof_wchar_t = 4;
|
||||
sizeof_size_t = 4;
|
||||
sizeof_pointer = 4;
|
||||
return true;
|
||||
|
@ -200,6 +204,7 @@ bool Settings::platform(PlatformType type)
|
|||
sizeof_float = 4;
|
||||
sizeof_double = 8;
|
||||
sizeof_long_double = 16;
|
||||
sizeof_wchar_t = 4;
|
||||
sizeof_size_t = 8;
|
||||
sizeof_pointer = 8;
|
||||
return true;
|
||||
|
|
|
@ -205,6 +205,7 @@ public:
|
|||
unsigned int sizeof_float;
|
||||
unsigned int sizeof_double;
|
||||
unsigned int sizeof_long_double;
|
||||
unsigned int sizeof_wchar_t;
|
||||
unsigned int sizeof_size_t;
|
||||
unsigned int sizeof_pointer;
|
||||
|
||||
|
|
|
@ -1569,6 +1569,7 @@ bool Tokenizer::tokenize(std::istream &code,
|
|||
_typeSize["long"] = _settings->sizeof_long;
|
||||
_typeSize["float"] = _settings->sizeof_float;
|
||||
_typeSize["double"] = _settings->sizeof_double;
|
||||
_typeSize["wchar_t"] = _settings->sizeof_wchar_t;
|
||||
_typeSize["size_t"] = _settings->sizeof_size_t;
|
||||
_typeSize["*"] = _settings->sizeof_pointer;
|
||||
|
||||
|
|
|
@ -446,6 +446,7 @@ private:
|
|||
// a = b = 0;
|
||||
TEST_CASE(multipleAssignment);
|
||||
|
||||
TEST_CASE(platformWin);
|
||||
TEST_CASE(platformWin32);
|
||||
TEST_CASE(platformWin32A);
|
||||
TEST_CASE(platformWin32W);
|
||||
|
@ -7011,27 +7012,8 @@ private:
|
|||
ASSERT_EQUALS("a = b = 0 ;", tokenizeAndStringify("a=b=0;"));
|
||||
}
|
||||
|
||||
void platformWin32() {
|
||||
const char code[] = "unsigned int sizeof_short = sizeof(short);"
|
||||
"unsigned int sizeof_unsigned_short = sizeof(unsigned short);"
|
||||
"unsigned int sizeof_int = sizeof(int);"
|
||||
"unsigned int sizeof_unsigned_int = sizeof(unsigned int);"
|
||||
"unsigned int sizeof_long = sizeof(long);"
|
||||
"unsigned int sizeof_unsigned_long = sizeof(unsigned long);"
|
||||
"unsigned int sizeof_long_long = sizeof(long long);"
|
||||
"unsigned int sizeof_unsigned_long_long = sizeof(unsigned long long);"
|
||||
"unsigned int sizeof_float = sizeof(float);"
|
||||
"unsigned int sizeof_double = sizeof(double);"
|
||||
"unsigned int sizeof_long_double = sizeof(long double);"
|
||||
"unsigned int sizeof_bool = sizeof(bool);"
|
||||
"unsigned int sizeof_pointer = sizeof(void *);"
|
||||
"unsigned int sizeof_size_t = sizeof(size_t);"
|
||||
"size_t a;"
|
||||
"ssize_t b;"
|
||||
"ptrdiff_t c;"
|
||||
"intptr_t d;"
|
||||
"uintptr_t e;"
|
||||
"BOOL f;"
|
||||
void platformWin() {
|
||||
const char code[] = "BOOL f;"
|
||||
"BOOLEAN g;"
|
||||
"BYTE h;"
|
||||
"CHAR i;"
|
||||
|
@ -7066,12 +7048,6 @@ private:
|
|||
"PCHAR L;"
|
||||
"LPVOID M;"
|
||||
"PVOID N;"
|
||||
"DWORD_PTR O;"
|
||||
"ULONG_PTR P;"
|
||||
"SIZE_T Q;"
|
||||
"HRESULT R;"
|
||||
"LONG_PTR S;"
|
||||
"HANDLE T;"
|
||||
"BOOL _bool;"
|
||||
"HFILE hfile;"
|
||||
"LONG32 long32;"
|
||||
|
@ -7079,7 +7055,6 @@ private:
|
|||
"LCTYPE lctype;"
|
||||
"LGRPID lgrpid;"
|
||||
"LONG64 long64;"
|
||||
"SSIZE_T _ssize_t;"
|
||||
"PUCHAR puchar;"
|
||||
"LPCOLORREF lpcolorref;"
|
||||
"PDWORD pdword;"
|
||||
|
@ -7102,36 +7077,13 @@ private:
|
|||
"HWINSTA hwinsta;"
|
||||
"PWCHAR pwchar;"
|
||||
"PUSHORT pushort;"
|
||||
"UINT_PTR uint_ptr;"
|
||||
"WPARAM wparam;"
|
||||
"LANGID langid;"
|
||||
"DWORD64 dword64;"
|
||||
"ULONG64 ulong64;"
|
||||
"HALF_PTR half_ptr;"
|
||||
"INT_PTR int_ptr;"
|
||||
"LPWSTR lpcwstr;"
|
||||
"LPCWSTR lpcwstr;";
|
||||
|
||||
const char expected[] = "unsigned int sizeof_short ; sizeof_short = 2 ; "
|
||||
"unsigned int sizeof_unsigned_short ; sizeof_unsigned_short = 2 ; "
|
||||
"unsigned int sizeof_int ; sizeof_int = 4 ; "
|
||||
"unsigned int sizeof_unsigned_int ; sizeof_unsigned_int = 4 ; "
|
||||
"unsigned int sizeof_long ; sizeof_long = 4 ; "
|
||||
"unsigned int sizeof_unsigned_long ; sizeof_unsigned_long = 4 ; "
|
||||
"unsigned int sizeof_long_long ; sizeof_long_long = 8 ; "
|
||||
"unsigned int sizeof_unsigned_long_long ; sizeof_unsigned_long_long = 8 ; "
|
||||
"unsigned int sizeof_float ; sizeof_float = 4 ; "
|
||||
"unsigned int sizeof_double ; sizeof_double = 8 ; "
|
||||
"unsigned int sizeof_long_double ; sizeof_long_double = 8 ; "
|
||||
"unsigned int sizeof_bool ; sizeof_bool = 1 ; "
|
||||
"unsigned int sizeof_pointer ; sizeof_pointer = 4 ; "
|
||||
"unsigned int sizeof_size_t ; sizeof_size_t = 4 ; "
|
||||
"unsigned long a ; "
|
||||
"long b ; "
|
||||
"long c ; "
|
||||
"long d ; "
|
||||
"unsigned long e ; "
|
||||
"int f ; "
|
||||
const char expected[] = "int f ; "
|
||||
"unsigned char g ; "
|
||||
"unsigned char h ; "
|
||||
"char i ; "
|
||||
|
@ -7166,12 +7118,6 @@ private:
|
|||
"char * L ; "
|
||||
"void * M ; "
|
||||
"void * N ; "
|
||||
"unsigned long O ; "
|
||||
"unsigned long P ; "
|
||||
"unsigned long Q ; "
|
||||
"long R ; "
|
||||
"long S ; "
|
||||
"void * T ; "
|
||||
"int _bool ; "
|
||||
"int hfile ; "
|
||||
"int long32 ; "
|
||||
|
@ -7179,7 +7125,6 @@ private:
|
|||
"unsigned long lctype ; "
|
||||
"unsigned long lgrpid ; "
|
||||
"long long long64 ; "
|
||||
"long _ssize_t ; "
|
||||
"unsigned char * puchar ; "
|
||||
"unsigned long * lpcolorref ; "
|
||||
"unsigned long * pdword ; "
|
||||
|
@ -7202,16 +7147,86 @@ private:
|
|||
"void * hwinsta ; "
|
||||
"wchar_t * pwchar ; "
|
||||
"unsigned short * pushort ; "
|
||||
"unsigned int uint_ptr ; "
|
||||
"unsigned int wparam ; "
|
||||
"unsigned short langid ; "
|
||||
"unsigned long dword64 ; "
|
||||
"unsigned long ulong64 ; "
|
||||
"short half_ptr ; "
|
||||
"int int_ptr ; "
|
||||
"wchar_t * lpcwstr ; "
|
||||
"const wchar_t * lpcwstr ;";
|
||||
|
||||
// These types should be defined the same on all Windows platforms
|
||||
std::string win32A = tokenizeAndStringify(code, true, true, Settings::Win32A);
|
||||
ASSERT_EQUALS(expected, win32A);
|
||||
ASSERT_EQUALS(win32A, tokenizeAndStringify(code, true, true, Settings::Win32W));
|
||||
ASSERT_EQUALS(win32A, tokenizeAndStringify(code, true, true, Settings::Win64));
|
||||
}
|
||||
|
||||
void platformWin32() {
|
||||
const char code[] = "unsigned int sizeof_short = sizeof(short);"
|
||||
"unsigned int sizeof_unsigned_short = sizeof(unsigned short);"
|
||||
"unsigned int sizeof_int = sizeof(int);"
|
||||
"unsigned int sizeof_unsigned_int = sizeof(unsigned int);"
|
||||
"unsigned int sizeof_long = sizeof(long);"
|
||||
"unsigned int sizeof_unsigned_long = sizeof(unsigned long);"
|
||||
"unsigned int sizeof_long_long = sizeof(long long);"
|
||||
"unsigned int sizeof_unsigned_long_long = sizeof(unsigned long long);"
|
||||
"unsigned int sizeof_float = sizeof(float);"
|
||||
"unsigned int sizeof_double = sizeof(double);"
|
||||
"unsigned int sizeof_long_double = sizeof(long double);"
|
||||
"unsigned int sizeof_bool = sizeof(bool);"
|
||||
"unsigned int sizeof_wchar_t = sizeof(wchar_t);"
|
||||
"unsigned int sizeof_pointer = sizeof(void *);"
|
||||
"unsigned int sizeof_size_t = sizeof(size_t);"
|
||||
"size_t a;"
|
||||
"ssize_t b;"
|
||||
"ptrdiff_t c;"
|
||||
"intptr_t d;"
|
||||
"uintptr_t e;"
|
||||
"DWORD_PTR O;"
|
||||
"ULONG_PTR P;"
|
||||
"SIZE_T Q;"
|
||||
"HRESULT R;"
|
||||
"LONG_PTR S;"
|
||||
"HANDLE T;"
|
||||
"PHANDLE U;"
|
||||
"SSIZE_T _ssize_t;"
|
||||
"UINT_PTR uint_ptr;"
|
||||
"WPARAM wparam;"
|
||||
"HALF_PTR half_ptr;"
|
||||
"INT_PTR int_ptr;";;
|
||||
|
||||
const char expected[] = "unsigned int sizeof_short ; sizeof_short = 2 ; "
|
||||
"unsigned int sizeof_unsigned_short ; sizeof_unsigned_short = 2 ; "
|
||||
"unsigned int sizeof_int ; sizeof_int = 4 ; "
|
||||
"unsigned int sizeof_unsigned_int ; sizeof_unsigned_int = 4 ; "
|
||||
"unsigned int sizeof_long ; sizeof_long = 4 ; "
|
||||
"unsigned int sizeof_unsigned_long ; sizeof_unsigned_long = 4 ; "
|
||||
"unsigned int sizeof_long_long ; sizeof_long_long = 8 ; "
|
||||
"unsigned int sizeof_unsigned_long_long ; sizeof_unsigned_long_long = 8 ; "
|
||||
"unsigned int sizeof_float ; sizeof_float = 4 ; "
|
||||
"unsigned int sizeof_double ; sizeof_double = 8 ; "
|
||||
"unsigned int sizeof_long_double ; sizeof_long_double = 8 ; "
|
||||
"unsigned int sizeof_bool ; sizeof_bool = 1 ; "
|
||||
"unsigned int sizeof_wchar_t ; sizeof_wchar_t = 2 ; "
|
||||
"unsigned int sizeof_pointer ; sizeof_pointer = 4 ; "
|
||||
"unsigned int sizeof_size_t ; sizeof_size_t = 4 ; "
|
||||
"unsigned long a ; "
|
||||
"long b ; "
|
||||
"long c ; "
|
||||
"long d ; "
|
||||
"unsigned long e ; "
|
||||
"unsigned long O ; "
|
||||
"unsigned long P ; "
|
||||
"unsigned long Q ; "
|
||||
"long R ; "
|
||||
"long S ; "
|
||||
"void * T ; "
|
||||
"void * * U ; "
|
||||
"long _ssize_t ; "
|
||||
"unsigned int uint_ptr ; "
|
||||
"unsigned int wparam ; "
|
||||
"short half_ptr ; "
|
||||
"int int_ptr ;";
|
||||
|
||||
// These types should be defined the same on all Win32 platforms
|
||||
std::string win32A = tokenizeAndStringify(code, true, true, Settings::Win32A);
|
||||
ASSERT_EQUALS(expected, win32A);
|
||||
|
@ -7323,6 +7338,7 @@ private:
|
|||
"unsigned int sizeof_double = sizeof(double);"
|
||||
"unsigned int sizeof_long_double = sizeof(long double);"
|
||||
"unsigned int sizeof_bool = sizeof(bool);"
|
||||
"unsigned int sizeof_wchar_t = sizeof(wchar_t);"
|
||||
"unsigned int sizeof_pointer = sizeof(void *);"
|
||||
"unsigned int sizeof_size_t = sizeof(size_t);"
|
||||
"size_t a;"
|
||||
|
@ -7355,6 +7371,7 @@ private:
|
|||
"unsigned int sizeof_double ; sizeof_double = 8 ; "
|
||||
"unsigned int sizeof_long_double ; sizeof_long_double = 8 ; "
|
||||
"unsigned int sizeof_bool ; sizeof_bool = 1 ; "
|
||||
"unsigned int sizeof_wchar_t ; sizeof_wchar_t = 2 ; "
|
||||
"unsigned int sizeof_pointer ; sizeof_pointer = 8 ; "
|
||||
"unsigned int sizeof_size_t ; sizeof_size_t = 8 ; "
|
||||
"unsigned long long a ; "
|
||||
|
@ -7391,6 +7408,7 @@ private:
|
|||
"unsigned int sizeof_double = sizeof(double);"
|
||||
"unsigned int sizeof_long_double = sizeof(long double);"
|
||||
"unsigned int sizeof_bool = sizeof(bool);"
|
||||
"unsigned int sizeof_wchar_t = sizeof(wchar_t);"
|
||||
"unsigned int sizeof_pointer = sizeof(void *);"
|
||||
"unsigned int sizeof_size_t = sizeof(size_t);"
|
||||
"size_t a;"
|
||||
|
@ -7411,6 +7429,7 @@ private:
|
|||
"unsigned int sizeof_double ; sizeof_double = 8 ; "
|
||||
"unsigned int sizeof_long_double ; sizeof_long_double = 12 ; "
|
||||
"unsigned int sizeof_bool ; sizeof_bool = 1 ; "
|
||||
"unsigned int sizeof_wchar_t ; sizeof_wchar_t = 4 ; "
|
||||
"unsigned int sizeof_pointer ; sizeof_pointer = 4 ; "
|
||||
"unsigned int sizeof_size_t ; sizeof_size_t = 4 ; "
|
||||
"unsigned long a ; "
|
||||
|
@ -7435,6 +7454,7 @@ private:
|
|||
"unsigned int sizeof_double = sizeof(double);"
|
||||
"unsigned int sizeof_long_double = sizeof(long double);"
|
||||
"unsigned int sizeof_bool = sizeof(bool);"
|
||||
"unsigned int sizeof_wchar_t = sizeof(wchar_t);"
|
||||
"unsigned int sizeof_pointer = sizeof(void *);"
|
||||
"unsigned int sizeof_size_t = sizeof(size_t);"
|
||||
"size_t a;"
|
||||
|
@ -7455,6 +7475,7 @@ private:
|
|||
"unsigned int sizeof_double ; sizeof_double = 8 ; "
|
||||
"unsigned int sizeof_long_double ; sizeof_long_double = 16 ; "
|
||||
"unsigned int sizeof_bool ; sizeof_bool = 1 ; "
|
||||
"unsigned int sizeof_wchar_t ; sizeof_wchar_t = 4 ; "
|
||||
"unsigned int sizeof_pointer ; sizeof_pointer = 8 ; "
|
||||
"unsigned int sizeof_size_t ; sizeof_size_t = 8 ; "
|
||||
"unsigned long long a ; "
|
||||
|
|
Loading…
Reference in New Issue