Replace useless reinterpret_cast by static_cast
Former-commit-id: f61d644d968d4fe9523a5cd122e11525a9c2765d
This commit is contained in:
parent
9efed23cbc
commit
a31a969409
|
|
@ -34,7 +34,7 @@ namespace Nz
|
|||
|
||||
inline void SwapBytes(void* buffer, unsigned int size)
|
||||
{
|
||||
UInt8* bytes = reinterpret_cast<UInt8*>(buffer);
|
||||
UInt8* bytes = static_cast<UInt8*>(buffer);
|
||||
unsigned int i = 0;
|
||||
unsigned int j = size - 1;
|
||||
|
||||
|
|
|
|||
|
|
@ -161,7 +161,7 @@ namespace Nz
|
|||
template<typename T>
|
||||
void SparsePtr<T>::SetPtr(VoidPtr ptr)
|
||||
{
|
||||
m_ptr = reinterpret_cast<BytePtr>(ptr);
|
||||
m_ptr = static_cast<BytePtr>(ptr);
|
||||
}
|
||||
|
||||
/*!
|
||||
|
|
|
|||
|
|
@ -87,12 +87,12 @@ namespace Nz
|
|||
wchar_t* buffer = nullptr;
|
||||
|
||||
FormatMessageW(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_IGNORE_INSERTS,
|
||||
nullptr,
|
||||
code,
|
||||
0,
|
||||
reinterpret_cast<LPWSTR>(&buffer),
|
||||
0,
|
||||
nullptr);
|
||||
nullptr,
|
||||
code,
|
||||
0,
|
||||
reinterpret_cast<LPWSTR>(&buffer),
|
||||
0,
|
||||
nullptr);
|
||||
|
||||
String error(String::Unicode(buffer));
|
||||
LocalFree(buffer);
|
||||
|
|
|
|||
|
|
@ -110,7 +110,7 @@ namespace Nz
|
|||
pthread_mutex_lock(&s_mutex);
|
||||
#endif
|
||||
|
||||
Block* ptr = reinterpret_cast<Block*>(std::malloc(size+sizeof(Block)));
|
||||
Block* ptr = static_cast<Block*>(std::malloc(size+sizeof(Block)));
|
||||
if (!ptr)
|
||||
{
|
||||
char timeStr[23];
|
||||
|
|
@ -209,7 +209,7 @@ namespace Nz
|
|||
if (!pointer)
|
||||
return;
|
||||
|
||||
Block* ptr = reinterpret_cast<Block*>(reinterpret_cast<UInt8*>(pointer) - sizeof(Block));
|
||||
Block* ptr = reinterpret_cast<Block*>(static_cast<UInt8*>(pointer) - sizeof(Block));
|
||||
if (ptr->magic != s_allocatedId)
|
||||
{
|
||||
char timeStr[23];
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ namespace Nz
|
|||
|
||||
MemoryView::MemoryView(void* ptr, UInt64 size) :
|
||||
Stream(StreamOption_None, OpenMode_ReadWrite),
|
||||
m_ptr(reinterpret_cast<UInt8*>(ptr)),
|
||||
m_ptr(static_cast<UInt8*>(ptr)),
|
||||
m_pos(0),
|
||||
m_size(size)
|
||||
{
|
||||
|
|
@ -43,7 +43,7 @@ namespace Nz
|
|||
|
||||
MemoryView::MemoryView(const void* ptr, UInt64 size) :
|
||||
Stream(StreamOption_None, OpenMode_ReadOnly),
|
||||
m_ptr(reinterpret_cast<UInt8*>(const_cast<void*>(ptr))), //< Okay, right, const_cast is bad, but this pointer is still read-only
|
||||
m_ptr(static_cast<UInt8*>(const_cast<void*>(ptr))), //< Okay, right, const_cast is bad, but this pointer is still read-only
|
||||
m_pos(0),
|
||||
m_size(size)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -195,7 +195,7 @@ namespace Nz
|
|||
|
||||
unsigned int __stdcall TaskSchedulerImpl::WorkerProc(void* userdata)
|
||||
{
|
||||
unsigned int workerID = *reinterpret_cast<unsigned int*>(userdata);
|
||||
unsigned int workerID = *static_cast<unsigned int*>(userdata);
|
||||
SetEvent(s_doneEvents[workerID]);
|
||||
|
||||
Worker& worker = s_workers[workerID];
|
||||
|
|
|
|||
|
|
@ -272,7 +272,7 @@ namespace Nz
|
|||
{
|
||||
// On ouvre le buffer en écriture
|
||||
BufferMapper<VertexBuffer> vertexMapper(m_spriteBuffer, BufferAccess_DiscardAndWrite);
|
||||
VertexStruct_XYZ_Color_UV* vertices = reinterpret_cast<VertexStruct_XYZ_Color_UV*>(vertexMapper.GetPointer());
|
||||
VertexStruct_XYZ_Color_UV* vertices = static_cast<VertexStruct_XYZ_Color_UV*>(vertexMapper.GetPointer());
|
||||
|
||||
unsigned int spriteCount = 0;
|
||||
unsigned int maxSpriteCount = std::min(s_maxQuads, m_spriteBuffer.GetVertexCount()/4);
|
||||
|
|
@ -411,7 +411,7 @@ namespace Nz
|
|||
billboardCount -= renderedBillboardCount;
|
||||
|
||||
BufferMapper<VertexBuffer> vertexMapper(m_billboardPointBuffer, BufferAccess_DiscardAndWrite, 0, renderedBillboardCount*4);
|
||||
BillboardPoint* vertices = reinterpret_cast<BillboardPoint*>(vertexMapper.GetPointer());
|
||||
BillboardPoint* vertices = static_cast<BillboardPoint*>(vertexMapper.GetPointer());
|
||||
|
||||
for (unsigned int i = 0; i < renderedBillboardCount; ++i)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -633,7 +633,7 @@ namespace Nz
|
|||
|
||||
void LuaInstance::PushFunction(LuaFunction func) const
|
||||
{
|
||||
LuaFunction* luaFunc = reinterpret_cast<LuaFunction*>(lua_newuserdata(m_state, sizeof(LuaFunction)));
|
||||
LuaFunction* luaFunc = static_cast<LuaFunction*>(lua_newuserdata(m_state, sizeof(LuaFunction)));
|
||||
PlacementNew<LuaFunction>(luaFunc, std::move(func));
|
||||
|
||||
lua_pushcclosure(m_state, ProxyFunc, 1);
|
||||
|
|
|
|||
|
|
@ -221,7 +221,7 @@ namespace Nz
|
|||
{
|
||||
int sendSize = static_cast<int>(std::min<std::size_t>(size - totalByteSent, std::numeric_limits<int>::max())); //< Handle very large send
|
||||
int sentSize;
|
||||
if (!SocketImpl::Send(m_handle, reinterpret_cast<const UInt8*>(buffer) + totalByteSent, sendSize, &sentSize, &m_lastError))
|
||||
if (!SocketImpl::Send(m_handle, static_cast<const UInt8*>(buffer) + totalByteSent, sendSize, &sentSize, &m_lastError))
|
||||
{
|
||||
switch (m_lastError)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -405,7 +405,7 @@ namespace Nz
|
|||
NazaraAssert(handle != InvalidHandle, "Invalid handle");
|
||||
NazaraAssert(buffer && length > 0, "Invalid buffer");
|
||||
|
||||
int byteRead = recv(handle, reinterpret_cast<char*>(buffer), length, 0);
|
||||
int byteRead = recv(handle, static_cast<char*>(buffer), length, 0);
|
||||
if (byteRead == SOCKET_ERROR)
|
||||
{
|
||||
int errorCode = WSAGetLastError();
|
||||
|
|
|
|||
|
|
@ -67,7 +67,7 @@ namespace Nz
|
|||
}
|
||||
|
||||
BufferMapper<VertexBuffer> mapper(s_vertexBuffer, BufferAccess_DiscardAndWrite, 0, 24);
|
||||
VertexStruct_XYZ* vertex = reinterpret_cast<VertexStruct_XYZ*>(mapper.GetPointer());
|
||||
VertexStruct_XYZ* vertex = static_cast<VertexStruct_XYZ*>(mapper.GetPointer());
|
||||
|
||||
Vector3f max, min;
|
||||
max = box.GetMaximum();
|
||||
|
|
@ -158,7 +158,7 @@ namespace Nz
|
|||
}
|
||||
|
||||
BufferMapper<VertexBuffer> mapper(s_vertexBuffer, BufferAccess_DiscardAndWrite, 0, 24);
|
||||
VertexStruct_XYZ* vertex = reinterpret_cast<VertexStruct_XYZ*>(mapper.GetPointer());
|
||||
VertexStruct_XYZ* vertex = static_cast<VertexStruct_XYZ*>(mapper.GetPointer());
|
||||
|
||||
vertex->position.Set(frustum.GetCorner(BoxCorner_NearLeftBottom));
|
||||
vertex++;
|
||||
|
|
@ -240,7 +240,7 @@ namespace Nz
|
|||
}
|
||||
|
||||
BufferMapper<VertexBuffer> mapper(s_vertexBuffer, BufferAccess_DiscardAndWrite, 0, 24);
|
||||
VertexStruct_XYZ* vertex = reinterpret_cast<VertexStruct_XYZ*>(mapper.GetPointer());
|
||||
VertexStruct_XYZ* vertex = static_cast<VertexStruct_XYZ*>(mapper.GetPointer());
|
||||
|
||||
vertex->position.Set(orientedBox.GetCorner(BoxCorner_NearLeftBottom));
|
||||
vertex++;
|
||||
|
|
@ -329,7 +329,7 @@ namespace Nz
|
|||
}
|
||||
|
||||
BufferMapper<VertexBuffer> mapper(s_vertexBuffer, BufferAccess_DiscardAndWrite, 0, jointCount*2);
|
||||
VertexStruct_XYZ* vertex = reinterpret_cast<VertexStruct_XYZ*>(mapper.GetPointer());
|
||||
VertexStruct_XYZ* vertex = static_cast<VertexStruct_XYZ*>(mapper.GetPointer());
|
||||
|
||||
unsigned int vertexCount = 0;
|
||||
for (unsigned int i = 0; i < jointCount; ++i)
|
||||
|
|
@ -407,8 +407,8 @@ namespace Nz
|
|||
BufferMapper<VertexBuffer> inputMapper(subMesh->GetVertexBuffer(), BufferAccess_ReadOnly);
|
||||
BufferMapper<VertexBuffer> outputMapper(s_vertexBuffer, BufferAccess_DiscardAndWrite, 0, vertexCount);
|
||||
|
||||
MeshVertex* inputVertex = reinterpret_cast<MeshVertex*>(inputMapper.GetPointer());
|
||||
VertexStruct_XYZ* outputVertex = reinterpret_cast<VertexStruct_XYZ*>(outputMapper.GetPointer());
|
||||
MeshVertex* inputVertex = static_cast<MeshVertex*>(inputMapper.GetPointer());
|
||||
VertexStruct_XYZ* outputVertex = static_cast<VertexStruct_XYZ*>(outputMapper.GetPointer());
|
||||
|
||||
for (unsigned int i = 0; i < normalCount; ++i)
|
||||
{
|
||||
|
|
@ -449,7 +449,7 @@ namespace Nz
|
|||
transformMatrix.SetTranslation(origin);
|
||||
|
||||
BufferMapper<VertexBuffer> mapper(s_vertexBuffer, BufferAccess_DiscardAndWrite, 0, 16);
|
||||
VertexStruct_XYZ* vertex = reinterpret_cast<VertexStruct_XYZ*>(mapper.GetPointer());
|
||||
VertexStruct_XYZ* vertex = static_cast<VertexStruct_XYZ*>(mapper.GetPointer());
|
||||
|
||||
// On calcule le reste des points
|
||||
Vector3f base(Vector3f::Forward()*length);
|
||||
|
|
@ -575,8 +575,8 @@ namespace Nz
|
|||
BufferMapper<VertexBuffer> inputMapper(subMesh->GetVertexBuffer(), BufferAccess_ReadOnly);
|
||||
BufferMapper<VertexBuffer> outputMapper(s_vertexBuffer, BufferAccess_DiscardAndWrite, 0, vertexCount);
|
||||
|
||||
MeshVertex* inputVertex = reinterpret_cast<MeshVertex*>(inputMapper.GetPointer());
|
||||
VertexStruct_XYZ* outputVertex = reinterpret_cast<VertexStruct_XYZ*>(outputMapper.GetPointer());
|
||||
MeshVertex* inputVertex = static_cast<MeshVertex*>(inputMapper.GetPointer());
|
||||
VertexStruct_XYZ* outputVertex = static_cast<VertexStruct_XYZ*>(outputMapper.GetPointer());
|
||||
|
||||
for (unsigned int i = 0; i < normalCount; ++i)
|
||||
{
|
||||
|
|
@ -622,8 +622,8 @@ namespace Nz
|
|||
BufferMapper<VertexBuffer> inputMapper(subMesh->GetVertexBuffer(), BufferAccess_ReadOnly);
|
||||
BufferMapper<VertexBuffer> outputMapper(s_vertexBuffer, BufferAccess_DiscardAndWrite, 0, vertexCount);
|
||||
|
||||
MeshVertex* inputVertex = reinterpret_cast<MeshVertex*>(inputMapper.GetPointer());
|
||||
VertexStruct_XYZ* outputVertex = reinterpret_cast<VertexStruct_XYZ*>(outputMapper.GetPointer());
|
||||
MeshVertex* inputVertex = static_cast<MeshVertex*>(inputMapper.GetPointer());
|
||||
VertexStruct_XYZ* outputVertex = static_cast<VertexStruct_XYZ*>(outputMapper.GetPointer());
|
||||
|
||||
for (unsigned int i = 0; i < tangentCount; ++i)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ namespace Nz
|
|||
Context::EnsureContext();
|
||||
|
||||
m_id = 0;
|
||||
glGenQueries(1, reinterpret_cast<GLuint*>(&m_id));
|
||||
glGenQueries(1, static_cast<GLuint*>(&m_id));
|
||||
|
||||
#ifdef NAZARA_DEBUG
|
||||
if (!m_id)
|
||||
|
|
|
|||
|
|
@ -115,7 +115,7 @@ namespace Nz
|
|||
stream.Read(&triangles[0], header.num_tris*sizeof(MD2_Triangle));
|
||||
|
||||
BufferMapper<IndexBuffer> indexMapper(indexBuffer, BufferAccess_DiscardAndWrite);
|
||||
UInt16* index = reinterpret_cast<UInt16*>(indexMapper.GetPointer());
|
||||
UInt16* index = static_cast<UInt16*>(indexMapper.GetPointer());
|
||||
|
||||
for (unsigned int i = 0; i < header.num_tris; ++i)
|
||||
{
|
||||
|
|
@ -190,7 +190,7 @@ namespace Nz
|
|||
translate *= s;
|
||||
|
||||
BufferMapper<VertexBuffer> vertexMapper(vertexBuffer, BufferAccess_DiscardAndWrite);
|
||||
MeshVertex* vertex = reinterpret_cast<MeshVertex*>(vertexMapper.GetPointer());
|
||||
MeshVertex* vertex = static_cast<MeshVertex*>(vertexMapper.GetPointer());
|
||||
|
||||
/// Chargement des coordonnées de texture
|
||||
const unsigned int indexFix[3] = {0, 2, 1}; // Pour respécifier les indices dans le bon ordre
|
||||
|
|
|
|||
|
|
@ -249,7 +249,7 @@ namespace Nz
|
|||
VertexBufferRef vertexBuffer = VertexBuffer::New(VertexDeclaration::Get(VertexLayout_XYZ_Normal_UV_Tangent), vertexCount, parameters.storage);
|
||||
BufferMapper<VertexBuffer> vertexMapper(vertexBuffer, BufferAccess_WriteOnly);
|
||||
|
||||
MeshVertex* vertex = reinterpret_cast<MeshVertex*>(vertexMapper.GetPointer());
|
||||
MeshVertex* vertex = static_cast<MeshVertex*>(vertexMapper.GetPointer());
|
||||
for (const MD5MeshParser::Vertex& md5Vertex : md5Mesh.vertices)
|
||||
{
|
||||
// Skinning MD5 (Formule d'Id Tech)
|
||||
|
|
|
|||
|
|
@ -14,25 +14,25 @@ namespace Nz
|
|||
{
|
||||
UInt32 Getter16(const void* buffer, unsigned int i)
|
||||
{
|
||||
const UInt16* ptr = reinterpret_cast<const UInt16*>(buffer);
|
||||
const UInt16* ptr = static_cast<const UInt16*>(buffer);
|
||||
return ptr[i];
|
||||
}
|
||||
|
||||
UInt32 Getter32(const void* buffer, unsigned int i)
|
||||
{
|
||||
const UInt32* ptr = reinterpret_cast<const UInt32*>(buffer);
|
||||
const UInt32* ptr = static_cast<const UInt32*>(buffer);
|
||||
return ptr[i];
|
||||
}
|
||||
|
||||
void Setter16(void* buffer, unsigned int i, UInt32 value)
|
||||
{
|
||||
UInt16* ptr = reinterpret_cast<UInt16*>(buffer);
|
||||
UInt16* ptr = static_cast<UInt16*>(buffer);
|
||||
ptr[i] = static_cast<UInt16>(value);
|
||||
}
|
||||
|
||||
void Setter32(void* buffer, unsigned int i, UInt32 value)
|
||||
{
|
||||
UInt32* ptr = reinterpret_cast<UInt32*>(buffer);
|
||||
UInt32* ptr = static_cast<UInt32*>(buffer);
|
||||
ptr[i] = value;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -213,7 +213,7 @@ namespace Nz
|
|||
|
||||
Vector2i EventImpl::GetMousePosition(const Window& relativeTo)
|
||||
{
|
||||
HWND handle = reinterpret_cast<HWND>(relativeTo.GetHandle());
|
||||
HWND handle = static_cast<HWND>(relativeTo.GetHandle());
|
||||
if (handle)
|
||||
{
|
||||
POINT pos;
|
||||
|
|
@ -283,7 +283,7 @@ namespace Nz
|
|||
|
||||
void EventImpl::SetMousePosition(int x, int y, const Window& relativeTo)
|
||||
{
|
||||
HWND handle = reinterpret_cast<HWND>(relativeTo.GetHandle());
|
||||
HWND handle = static_cast<HWND>(relativeTo.GetHandle());
|
||||
if (handle)
|
||||
{
|
||||
POINT pos = {x, y};
|
||||
|
|
|
|||
|
|
@ -193,7 +193,7 @@ namespace Nz
|
|||
|
||||
bool WindowImpl::Create(WindowHandle handle)
|
||||
{
|
||||
m_handle = reinterpret_cast<HWND>(handle);
|
||||
m_handle = static_cast<HWND>(handle);
|
||||
|
||||
if (!m_handle || !IsWindow(m_handle))
|
||||
{
|
||||
|
|
@ -342,7 +342,7 @@ namespace Nz
|
|||
#endif
|
||||
|
||||
if (cursor != WindowCursor_None)
|
||||
m_cursor = reinterpret_cast<HCURSOR>(LoadImage(nullptr, windowsCursors[cursor], IMAGE_CURSOR, 0, 0, LR_SHARED));
|
||||
m_cursor = static_cast<HCURSOR>(LoadImage(nullptr, windowsCursors[cursor], IMAGE_CURSOR, 0, 0, LR_SHARED));
|
||||
else
|
||||
m_cursor = nullptr;
|
||||
|
||||
|
|
@ -1125,7 +1125,7 @@ namespace Nz
|
|||
WindowImpl* me;
|
||||
if (message == WM_CREATE)
|
||||
{
|
||||
me = reinterpret_cast<WindowImpl*>(reinterpret_cast<CREATESTRUCT*>(lParam)->lpCreateParams);
|
||||
me = static_cast<WindowImpl*>(reinterpret_cast<CREATESTRUCT*>(lParam)->lpCreateParams);
|
||||
SetWindowLongPtr(window, GWL_USERDATA, reinterpret_cast<LONG_PTR>(me));
|
||||
}
|
||||
else
|
||||
|
|
|
|||
Loading…
Reference in New Issue