add some common windows pointer type conversions to standard types

This commit is contained in:
Robert Reif 2011-09-19 23:14:58 -04:00
parent b349d36c50
commit e234e8cc5b
2 changed files with 93 additions and 3 deletions

View File

@ -6667,6 +6667,61 @@ void Tokenizer::simplifyPlatformTypes()
}
else if (tok->str() == "LONG")
tok->str("long");
else if (Token::Match(tok, "LPBOOL|PBOOL"))
{
tok->str("int");
tok->insertToken("*");
}
else if (Token::Match(tok, "LPBYTE|PBOOLEAN|PBYTE"))
{
tok->str("unsigned");
tok->insertToken("*");
tok->insertToken("char");
}
else if (Token::Match(tok, "LPCSTR|PCSTR"))
{
tok->str("const");
tok->insertToken("*");
tok->insertToken("char");
}
else if (tok->str() == "LPCVOID")
{
tok->str("const");
tok->insertToken("*");
tok->insertToken("void");
}
else if (tok->str() == "LPDWORD")
{
tok->str("unsigned");
tok->insertToken("*");
tok->insertToken("long");
}
else if (Token::Match(tok, "LPINT|PINT"))
{
tok->str("int");
tok->insertToken("*");
}
else if (Token::Match(tok, "LPLONG|PLONG"))
{
tok->str("long");
tok->insertToken("*");
}
else if (Token::Match(tok, "LPSTR|PSTR|PCHAR"))
{
tok->str("char");
tok->insertToken("*");
}
else if (Token::Match(tok, "LPVOID|PVOID"))
{
tok->str("void");
tok->insertToken("*");
}
else if (Token::Match(tok, "LPWORD|PWORD"))
{
tok->str("unsigned");
tok->insertToken("*");
tok->insertToken("short");
}
else if (tok->str() == "SHORT")
tok->str("short");
else if (tok->str() == "UINT")

View File

@ -5978,8 +5978,25 @@ private:
"ULONG s;"
"USHORT t;"
"WORD u;"
"VOID * v;";
"VOID *v;"
"LPBOOL w;"
"PBOOL x;"
"LPBYTE y;"
"PBOOLEAN z;"
"PBYTE A;"
"LPCSTR B;"
"PCSTR C;"
"LPCVOID D;"
"LPDWORD E;"
"LPINT F;"
"PINT G;"
"LPLONG H;"
"PLONG I;"
"LPSTR J;"
"PSTR K;"
"PCHAR L;"
"LPVOID M;"
"PVOID N;";
const char expected[] = "unsigned int sizeof_short ; sizeof_short = 2 ; "
"unsigned int sizeof_unsigned_short ; sizeof_unsigned_short = 2 ; "
@ -6016,7 +6033,25 @@ private:
"unsigned long s ; "
"unsigned short t ; "
"unsigned short u ; "
"void * v ;";
"void * v ; "
"int * w ; "
"int * x ; "
"unsigned char * y ; "
"unsigned char * z ; "
"unsigned char * A ; "
"const char * B ; "
"const char * C ; "
"const void * D ; "
"unsigned long * E ; "
"int * F ; "
"int * G ; "
"long * H ; "
"long * I ; "
"char * J ; "
"char * K ; "
"char * L ; "
"void * M ; "
"void * N ;";
ASSERT_EQUALS(expected, tokenizeAndStringify(code, true, true, Settings::Win32));
}