Convert all remaining enums to enum classes (!)
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
#include <Nazara/Network/Win32/IpAddressImpl.hpp>
|
||||
#include <Nazara/Core/Algorithm.hpp>
|
||||
#include <Nazara/Core/CallOnExit.hpp>
|
||||
#include <Nazara/Core/Error.hpp>
|
||||
#include <Nazara/Core/StringExt.hpp>
|
||||
@@ -187,7 +188,7 @@ namespace Nz
|
||||
}
|
||||
|
||||
if (error)
|
||||
*error = ResolveError_NoError;
|
||||
*error = ResolveError::NoError;
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -228,7 +229,7 @@ namespace Nz
|
||||
}
|
||||
|
||||
if (error)
|
||||
*error = ResolveError_NoError;
|
||||
*error = ResolveError::NoError;
|
||||
|
||||
return results;
|
||||
}
|
||||
@@ -239,7 +240,7 @@ namespace Nz
|
||||
{
|
||||
switch (ipAddress.GetProtocol())
|
||||
{
|
||||
case NetProtocol_IPv4:
|
||||
case NetProtocol::IPv4:
|
||||
{
|
||||
sockaddr_in* socketAddress = reinterpret_cast<sockaddr_in*>(buffer);
|
||||
|
||||
@@ -251,7 +252,7 @@ namespace Nz
|
||||
return sizeof(sockaddr_in);
|
||||
}
|
||||
|
||||
case NetProtocol_IPv6:
|
||||
case NetProtocol::IPv6:
|
||||
{
|
||||
sockaddr_in6* socketAddress = reinterpret_cast<sockaddr_in6*>(buffer);
|
||||
|
||||
@@ -271,7 +272,7 @@ namespace Nz
|
||||
}
|
||||
|
||||
default:
|
||||
NazaraInternalError("Unhandled ip protocol (0x" + NumberToString(ipAddress.GetProtocol()) + ')');
|
||||
NazaraInternalError("Unhandled ip protocol (0x" + NumberToString(UnderlyingCast(ipAddress.GetProtocol())) + ')');
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -285,13 +286,13 @@ namespace Nz
|
||||
switch (family)
|
||||
{
|
||||
case PF_INET:
|
||||
return NetProtocol_IPv4;
|
||||
return NetProtocol::IPv4;
|
||||
|
||||
case PF_INET6:
|
||||
return NetProtocol_IPv6;
|
||||
return NetProtocol::IPv6;
|
||||
|
||||
default:
|
||||
return NetProtocol_Unknown;
|
||||
return NetProtocol::Unknown;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -300,16 +301,16 @@ namespace Nz
|
||||
switch (socketType)
|
||||
{
|
||||
case SOCK_STREAM:
|
||||
return SocketType_TCP;
|
||||
return SocketType::TCP;
|
||||
|
||||
case SOCK_DGRAM:
|
||||
return SocketType_UDP;
|
||||
return SocketType::UDP;
|
||||
|
||||
case SOCK_RAW:
|
||||
return SocketType_Raw;
|
||||
return SocketType::Raw;
|
||||
|
||||
default:
|
||||
return SocketType_Unknown;
|
||||
return SocketType::Unknown;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -318,35 +319,35 @@ namespace Nz
|
||||
switch (error)
|
||||
{
|
||||
case 0:
|
||||
return ResolveError_NoError;
|
||||
return ResolveError::NoError;
|
||||
|
||||
// Engine error
|
||||
case WSAEFAULT:
|
||||
case WSAEINVAL:
|
||||
return ResolveError_Internal;
|
||||
return ResolveError::Internal;
|
||||
|
||||
case WSAEAFNOSUPPORT:
|
||||
case WSAESOCKTNOSUPPORT:
|
||||
case WSASERVICE_NOT_FOUND:
|
||||
return ResolveError_ProtocolNotSupported;
|
||||
return ResolveError::ProtocolNotSupported;
|
||||
|
||||
case WSAHOST_NOT_FOUND:
|
||||
return ResolveError_NotFound;
|
||||
return ResolveError::NotFound;
|
||||
|
||||
case WSANO_RECOVERY:
|
||||
return ResolveError_NonRecoverable;
|
||||
return ResolveError::NonRecoverable;
|
||||
|
||||
case WSANOTINITIALISED:
|
||||
return ResolveError_NotInitialized;
|
||||
return ResolveError::NotInitialized;
|
||||
|
||||
case WSA_NOT_ENOUGH_MEMORY:
|
||||
return ResolveError_ResourceError;
|
||||
return ResolveError::ResourceError;
|
||||
|
||||
case WSATRY_AGAIN:
|
||||
return ResolveError_TemporaryFailure;
|
||||
return ResolveError::TemporaryFailure;
|
||||
}
|
||||
|
||||
NazaraWarning("Unhandled WinSock error: " + Error::GetLastSystemError(error) + " (" + NumberToString(error) + ')');
|
||||
return ResolveError_Unknown;
|
||||
return ResolveError::Unknown;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
#include <Nazara/Network/Win32/SocketImpl.hpp>
|
||||
#include <Nazara/Core/Algorithm.hpp>
|
||||
#include <Nazara/Core/Error.hpp>
|
||||
#include <Nazara/Core/Log.hpp>
|
||||
#include <Nazara/Core/StackArray.hpp>
|
||||
@@ -52,7 +53,7 @@ namespace Nz
|
||||
*address = IpAddressImpl::FromSockAddr(reinterpret_cast<const sockaddr*>(&nameBuffer));
|
||||
|
||||
if (error)
|
||||
*error = SocketError_NoError;
|
||||
*error = SocketError::NoError;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -76,19 +77,19 @@ namespace Nz
|
||||
if (error)
|
||||
*error = TranslateWSAErrorToSocketError(WSAGetLastError());
|
||||
|
||||
return SocketState_NotConnected;
|
||||
return SocketState::NotConnected;
|
||||
}
|
||||
|
||||
if (error)
|
||||
*error = SocketError_NoError;
|
||||
*error = SocketError::NoError;
|
||||
|
||||
return SocketState_Bound;
|
||||
return SocketState::Bound;
|
||||
}
|
||||
|
||||
SocketHandle SocketImpl::Create(NetProtocol protocol, SocketType type, SocketError* error)
|
||||
{
|
||||
NazaraAssert(protocol != NetProtocol_Any, "Any protocol is not supported for socket creation");
|
||||
NazaraAssert(type <= SocketType_Max, "Type has value out of enum");
|
||||
NazaraAssert(protocol != NetProtocol::Any, "Any protocol is not supported for socket creation");
|
||||
NazaraAssert(type <= SocketType::Max, "Type has value out of enum");
|
||||
|
||||
SocketHandle handle = socket(TranslateNetProtocolToAF(protocol), TranslateSocketTypeToSock(type), 0);
|
||||
if (handle == InvalidHandle && error != nullptr)
|
||||
@@ -109,7 +110,7 @@ namespace Nz
|
||||
{
|
||||
NazaraAssert(handle != InvalidHandle, "Invalid handle");
|
||||
|
||||
if (GetLastError(handle, nullptr) < 0)
|
||||
if (GetLastError(handle, nullptr) != SocketError::Internal)
|
||||
NazaraWarning("Failed to clear socket error code: " + Error::GetLastSystemError(WSAGetLastError()));
|
||||
}
|
||||
|
||||
@@ -122,7 +123,7 @@ namespace Nz
|
||||
int bufferLength = IpAddressImpl::ToSockAddr(address, nameBuffer.data());
|
||||
|
||||
if (error)
|
||||
*error = SocketError_NoError;
|
||||
*error = SocketError::NoError;
|
||||
|
||||
// Clear socket error status
|
||||
ClearErrorCode(handle);
|
||||
@@ -135,24 +136,24 @@ namespace Nz
|
||||
case WSAEALREADY:
|
||||
case WSAEINVAL: //< In case of connect, WSAEINVAL may be returned instead of WSAEALREADY
|
||||
case WSAEWOULDBLOCK:
|
||||
return SocketState_Connecting;
|
||||
return SocketState::Connecting;
|
||||
|
||||
case WSAEISCONN:
|
||||
return SocketState_Connected;
|
||||
return SocketState::Connected;
|
||||
}
|
||||
|
||||
if (error)
|
||||
{
|
||||
if (errorCode == WSAEADDRNOTAVAIL)
|
||||
*error = SocketError_ConnectionRefused; //< ConnectionRefused seems more legit than AddressNotAvailable in connect case
|
||||
*error = SocketError::ConnectionRefused; //< ConnectionRefused seems more legit than AddressNotAvailable in connect case
|
||||
else
|
||||
*error = TranslateWSAErrorToSocketError(errorCode);
|
||||
}
|
||||
|
||||
return SocketState_NotConnected;
|
||||
return SocketState::NotConnected;
|
||||
}
|
||||
|
||||
return SocketState_Connected;
|
||||
return SocketState::Connected;
|
||||
}
|
||||
|
||||
bool SocketImpl::Initialize()
|
||||
@@ -172,7 +173,7 @@ namespace Nz
|
||||
{
|
||||
int code = GetLastErrorCode(handle, error);
|
||||
if (code < 0)
|
||||
return SocketError_Internal;
|
||||
return SocketError::Internal;
|
||||
|
||||
return TranslateWSAErrorToSocketError(code);
|
||||
}
|
||||
@@ -196,7 +197,7 @@ namespace Nz
|
||||
}
|
||||
|
||||
if (error)
|
||||
*error = SocketError_NoError;
|
||||
*error = SocketError::NoError;
|
||||
|
||||
return code;
|
||||
}
|
||||
@@ -214,7 +215,7 @@ namespace Nz
|
||||
if (error)
|
||||
*error = TranslateWSAErrorToSocketError(WSAGetLastError());
|
||||
|
||||
return SocketState_NotConnected;
|
||||
return SocketState::NotConnected;
|
||||
}
|
||||
|
||||
if (listen(handle, queueSize) == SOCKET_ERROR)
|
||||
@@ -222,13 +223,13 @@ namespace Nz
|
||||
if (error)
|
||||
*error = TranslateWSAErrorToSocketError(WSAGetLastError());
|
||||
|
||||
return SocketState_NotConnected;
|
||||
return SocketState::NotConnected;
|
||||
}
|
||||
|
||||
if (error)
|
||||
*error = SocketError_NoError;
|
||||
*error = SocketError::NoError;
|
||||
|
||||
return SocketState_Bound;
|
||||
return SocketState::Bound;
|
||||
}
|
||||
|
||||
std::size_t SocketImpl::QueryAvailableBytes(SocketHandle handle, SocketError* error)
|
||||
@@ -245,7 +246,7 @@ namespace Nz
|
||||
}
|
||||
|
||||
if (error)
|
||||
*error = SocketError_NoError;
|
||||
*error = SocketError::NoError;
|
||||
|
||||
return availableBytes;
|
||||
}
|
||||
@@ -264,7 +265,7 @@ namespace Nz
|
||||
}
|
||||
|
||||
if (error)
|
||||
*error = SocketError_NoError;
|
||||
*error = SocketError::NoError;
|
||||
|
||||
return code == TRUE;
|
||||
}
|
||||
@@ -283,7 +284,7 @@ namespace Nz
|
||||
}
|
||||
|
||||
if (error)
|
||||
*error = SocketError_NoError;
|
||||
*error = SocketError::NoError;
|
||||
|
||||
return code == TRUE;
|
||||
}
|
||||
@@ -302,7 +303,7 @@ namespace Nz
|
||||
}
|
||||
|
||||
if (error)
|
||||
*error = SocketError_NoError;
|
||||
*error = SocketError::NoError;
|
||||
|
||||
return code;
|
||||
}
|
||||
@@ -321,7 +322,7 @@ namespace Nz
|
||||
}
|
||||
|
||||
if (error)
|
||||
*error = SocketError_NoError;
|
||||
*error = SocketError::NoError;
|
||||
|
||||
return code == TRUE;
|
||||
}
|
||||
@@ -340,7 +341,7 @@ namespace Nz
|
||||
}
|
||||
|
||||
if (error)
|
||||
*error = SocketError_NoError;
|
||||
*error = SocketError::NoError;
|
||||
|
||||
return code;
|
||||
}
|
||||
@@ -363,7 +364,7 @@ namespace Nz
|
||||
}
|
||||
|
||||
if (error)
|
||||
*error = SocketError_NoError;
|
||||
*error = SocketError::NoError;
|
||||
|
||||
return IpAddressImpl::FromSockAddr(reinterpret_cast<sockaddr*>(nameBuffer.data()));
|
||||
}
|
||||
@@ -383,7 +384,7 @@ namespace Nz
|
||||
{
|
||||
int errorCode = WSAGetLastError();
|
||||
if (errorCode == WSAEINVAL)
|
||||
*error = SocketError_NoError;
|
||||
*error = SocketError::NoError;
|
||||
else
|
||||
*error = TranslateWSAErrorToSocketError(errorCode);
|
||||
}
|
||||
@@ -392,7 +393,7 @@ namespace Nz
|
||||
}
|
||||
|
||||
if (error)
|
||||
*error = SocketError_NoError;
|
||||
*error = SocketError::NoError;
|
||||
|
||||
return IpAddressImpl::FromSockAddr(reinterpret_cast<sockaddr*>(nameBuffer.data()));
|
||||
}
|
||||
@@ -411,7 +412,7 @@ namespace Nz
|
||||
}
|
||||
|
||||
if (error)
|
||||
*error = SocketError_NoError;
|
||||
*error = SocketError::NoError;
|
||||
|
||||
return code;
|
||||
}
|
||||
@@ -436,7 +437,7 @@ namespace Nz
|
||||
assert(result >= 0);
|
||||
|
||||
if (error)
|
||||
*error = SocketError_NoError;
|
||||
*error = SocketError::NoError;
|
||||
|
||||
return static_cast<unsigned int>(result);
|
||||
#else
|
||||
@@ -445,7 +446,7 @@ namespace Nz
|
||||
NazaraUnused(timeout);
|
||||
|
||||
if (error)
|
||||
*error = SocketError_NotSupported;
|
||||
*error = SocketError::NotSupported;
|
||||
|
||||
return 0;
|
||||
#endif
|
||||
@@ -465,7 +466,7 @@ namespace Nz
|
||||
if (error)
|
||||
*error = TranslateWSAErrorToSocketError(WSAGetLastError());
|
||||
|
||||
return SocketState_NotConnected;
|
||||
return SocketState::NotConnected;
|
||||
}
|
||||
else if (ret > 0)
|
||||
{
|
||||
@@ -474,14 +475,14 @@ namespace Nz
|
||||
if (error)
|
||||
*error = GetLastError(handle);
|
||||
|
||||
return SocketState_NotConnected;
|
||||
return SocketState::NotConnected;
|
||||
}
|
||||
else if (descriptor.revents & POLLWRNORM)
|
||||
return SocketState_Connected;
|
||||
return SocketState::Connected;
|
||||
else
|
||||
{
|
||||
NazaraWarning("Socket " + std::to_string(handle) + " was returned by poll without POLLOUT nor error events (events: 0x" + NumberToString(descriptor.revents, 16) + ')');
|
||||
return SocketState_NotConnected;
|
||||
return SocketState::NotConnected;
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -490,12 +491,12 @@ namespace Nz
|
||||
if (error)
|
||||
{
|
||||
if (msTimeout > 0)
|
||||
*error = SocketError_TimedOut;
|
||||
*error = SocketError::TimedOut;
|
||||
else
|
||||
*error = SocketError_NoError;
|
||||
*error = SocketError::NoError;
|
||||
}
|
||||
|
||||
return SocketState_Connecting;
|
||||
return SocketState::Connecting;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -529,7 +530,7 @@ namespace Nz
|
||||
else if (byteRead == 0)
|
||||
{
|
||||
if (error)
|
||||
*error = SocketError_ConnectionClosed;
|
||||
*error = SocketError::ConnectionClosed;
|
||||
|
||||
return false; //< Connection has been closed
|
||||
}
|
||||
@@ -538,7 +539,7 @@ namespace Nz
|
||||
*read = byteRead;
|
||||
|
||||
if (error)
|
||||
*error = SocketError_NoError;
|
||||
*error = SocketError::NoError;
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -581,7 +582,7 @@ namespace Nz
|
||||
else if (byteRead == 0)
|
||||
{
|
||||
if (error)
|
||||
*error = SocketError_ConnectionClosed;
|
||||
*error = SocketError::ConnectionClosed;
|
||||
|
||||
return false; //< Connection closed
|
||||
}
|
||||
@@ -595,7 +596,7 @@ namespace Nz
|
||||
*read = byteRead;
|
||||
|
||||
if (error)
|
||||
*error = SocketError_NoError;
|
||||
*error = SocketError::NoError;
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -650,7 +651,7 @@ namespace Nz
|
||||
if (flags & MSG_PARTIAL)
|
||||
{
|
||||
if (error)
|
||||
*error = SocketError_DatagramSize;
|
||||
*error = SocketError::DatagramSize;
|
||||
|
||||
return false;
|
||||
}
|
||||
@@ -662,7 +663,7 @@ namespace Nz
|
||||
*read = byteRead;
|
||||
|
||||
if (error)
|
||||
*error = SocketError_NoError;
|
||||
*error = SocketError::NoError;
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -698,7 +699,7 @@ namespace Nz
|
||||
*sent = byteSent;
|
||||
|
||||
if (error)
|
||||
*error = SocketError_NoError;
|
||||
*error = SocketError::NoError;
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -744,7 +745,7 @@ namespace Nz
|
||||
*sent = static_cast<int>(byteSent);
|
||||
|
||||
if (error)
|
||||
*error = SocketError_NoError;
|
||||
*error = SocketError::NoError;
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -783,7 +784,7 @@ namespace Nz
|
||||
*sent = byteSent;
|
||||
|
||||
if (error)
|
||||
*error = SocketError_NoError;
|
||||
*error = SocketError::NoError;
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -802,7 +803,7 @@ namespace Nz
|
||||
}
|
||||
|
||||
if (error)
|
||||
*error = SocketError_NoError;
|
||||
*error = SocketError::NoError;
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -821,7 +822,7 @@ namespace Nz
|
||||
}
|
||||
|
||||
if (error)
|
||||
*error = SocketError_NoError;
|
||||
*error = SocketError::NoError;
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -841,12 +842,12 @@ namespace Nz
|
||||
}
|
||||
|
||||
if (error)
|
||||
*error = SocketError_NoError;
|
||||
*error = SocketError::NoError;
|
||||
|
||||
return true;
|
||||
#else
|
||||
if (error)
|
||||
*error = SocketError_NotSupported;
|
||||
*error = SocketError::NotSupported;
|
||||
|
||||
return false;
|
||||
#endif
|
||||
@@ -871,7 +872,7 @@ namespace Nz
|
||||
}
|
||||
|
||||
if (error)
|
||||
*error = SocketError_NoError;
|
||||
*error = SocketError::NoError;
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -890,7 +891,7 @@ namespace Nz
|
||||
}
|
||||
|
||||
if (error)
|
||||
*error = SocketError_NoError;
|
||||
*error = SocketError::NoError;
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -909,7 +910,7 @@ namespace Nz
|
||||
}
|
||||
|
||||
if (error)
|
||||
*error = SocketError_NoError;
|
||||
*error = SocketError::NoError;
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -928,7 +929,7 @@ namespace Nz
|
||||
}
|
||||
|
||||
if (error)
|
||||
*error = SocketError_NoError;
|
||||
*error = SocketError::NoError;
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -938,7 +939,7 @@ namespace Nz
|
||||
switch (error)
|
||||
{
|
||||
case 0:
|
||||
return SocketError_NoError;
|
||||
return SocketError::NoError;
|
||||
|
||||
// Engine error
|
||||
case WSAEACCES:
|
||||
@@ -953,82 +954,82 @@ namespace Nz
|
||||
case WSAEISCONN:
|
||||
case WSAEWOULDBLOCK:
|
||||
NazaraWarning("Internal error occurred: " + Error::GetLastSystemError(error) + " (" + NumberToString(error) + ')');
|
||||
return SocketError_Internal;
|
||||
return SocketError::Internal;
|
||||
|
||||
case WSAEADDRNOTAVAIL:
|
||||
case WSAEADDRINUSE:
|
||||
return SocketError_AddressNotAvailable;
|
||||
return SocketError::AddressNotAvailable;
|
||||
|
||||
case WSAEAFNOSUPPORT:
|
||||
case WSAEPFNOSUPPORT:
|
||||
case WSAEOPNOTSUPP:
|
||||
case WSAEPROTONOSUPPORT:
|
||||
case WSAESOCKTNOSUPPORT:
|
||||
return SocketError_NotSupported;
|
||||
return SocketError::NotSupported;
|
||||
|
||||
case WSAECONNREFUSED:
|
||||
return SocketError_ConnectionRefused;
|
||||
return SocketError::ConnectionRefused;
|
||||
|
||||
case WSAECONNABORTED:
|
||||
case WSAECONNRESET:
|
||||
case WSAENOTCONN:
|
||||
case WSAESHUTDOWN:
|
||||
return SocketError_ConnectionClosed;
|
||||
return SocketError::ConnectionClosed;
|
||||
|
||||
case WSAEMSGSIZE:
|
||||
return SocketError_DatagramSize;
|
||||
return SocketError::DatagramSize;
|
||||
|
||||
case WSAEMFILE:
|
||||
case WSAENOBUFS:
|
||||
case WSA_NOT_ENOUGH_MEMORY:
|
||||
return SocketError_ResourceError;
|
||||
return SocketError::ResourceError;
|
||||
|
||||
case WSAEHOSTUNREACH:
|
||||
return SocketError_UnreachableHost;
|
||||
return SocketError::UnreachableHost;
|
||||
|
||||
case WSAENETDOWN:
|
||||
case WSAENETUNREACH:
|
||||
return SocketError_NetworkError;
|
||||
return SocketError::NetworkError;
|
||||
|
||||
case WSANOTINITIALISED:
|
||||
return SocketError_NotInitialized;
|
||||
return SocketError::NotInitialized;
|
||||
|
||||
case WSAETIMEDOUT:
|
||||
return SocketError_TimedOut;
|
||||
return SocketError::TimedOut;
|
||||
}
|
||||
|
||||
NazaraWarning("Unhandled WinSock error: " + Error::GetLastSystemError(error) + " (" + NumberToString(error) + ')');
|
||||
return SocketError_Unknown;
|
||||
return SocketError::Unknown;
|
||||
}
|
||||
|
||||
int SocketImpl::TranslateNetProtocolToAF(NetProtocol protocol)
|
||||
{
|
||||
NazaraAssert(protocol <= NetProtocol_Max, "Protocol has value out of enum");
|
||||
NazaraAssert(protocol <= NetProtocol::Max, "Protocol has value out of enum");
|
||||
|
||||
static int addressFamily[] = {
|
||||
AF_UNSPEC, //< NetProtocol_Any
|
||||
AF_INET, //< NetProtocol_IPv4
|
||||
AF_INET6, //< NetProtocol_IPv6
|
||||
-1 //< NetProtocol_Unknown
|
||||
AF_UNSPEC, //< NetProtocol::Any
|
||||
AF_INET, //< NetProtocol::IPv4
|
||||
AF_INET6, //< NetProtocol::IPv6
|
||||
-1 //< NetProtocol::Unknown
|
||||
};
|
||||
static_assert(sizeof(addressFamily) / sizeof(int) == NetProtocol_Max + 1, "Address family array is incomplete");
|
||||
static_assert(sizeof(addressFamily) / sizeof(int) == NetProtocolCount, "Address family array is incomplete");
|
||||
|
||||
return addressFamily[protocol];
|
||||
return addressFamily[UnderlyingCast(protocol)];
|
||||
}
|
||||
|
||||
int SocketImpl::TranslateSocketTypeToSock(SocketType type)
|
||||
{
|
||||
NazaraAssert(type <= SocketType_Max, "Socket type has value out of enum");
|
||||
NazaraAssert(type <= SocketType::Max, "Socket type has value out of enum");
|
||||
|
||||
static int socketType[] = {
|
||||
SOCK_RAW, //< SocketType_Raw
|
||||
SOCK_STREAM, //< SocketType_TCP
|
||||
SOCK_DGRAM, //< SocketType_UDP
|
||||
-1 //< SocketType_Unknown
|
||||
SOCK_RAW, //< SocketType::Raw
|
||||
SOCK_STREAM, //< SocketType::TCP
|
||||
SOCK_DGRAM, //< SocketType::UDP
|
||||
-1 //< SocketType::Unknown
|
||||
};
|
||||
static_assert(sizeof(socketType) / sizeof(int) == SocketType_Max + 1, "Socket type array is incomplete");
|
||||
static_assert(sizeof(socketType) / sizeof(int) == SocketTypeCount, "Socket type array is incomplete");
|
||||
|
||||
return socketType[type];
|
||||
return socketType[UnderlyingCast(type)];
|
||||
}
|
||||
|
||||
void SocketImpl::Uninitialize()
|
||||
|
||||
@@ -74,10 +74,10 @@ namespace Nz
|
||||
0
|
||||
};
|
||||
|
||||
if (eventFlags & SocketPollEvent_Read)
|
||||
if (eventFlags & SocketPollEvent::Read)
|
||||
entry.events |= POLLRDNORM;
|
||||
|
||||
if (eventFlags & SocketPollEvent_Write)
|
||||
if (eventFlags & SocketPollEvent::Write)
|
||||
entry.events |= POLLWRNORM;
|
||||
|
||||
m_allSockets[socket] = m_sockets.size();
|
||||
@@ -85,7 +85,7 @@ namespace Nz
|
||||
#else
|
||||
for (std::size_t i = 0; i < 2; ++i)
|
||||
{
|
||||
if ((eventFlags & ((i == 0) ? SocketPollEvent_Read : SocketPollEvent_Write)) == 0)
|
||||
if ((eventFlags & ((i == 0) ? SocketPollEvent::Read : SocketPollEvent::Write)) == 0)
|
||||
continue;
|
||||
|
||||
fd_set& targetSet = (i == 0) ? m_readSockets : m_writeSockets;
|
||||
@@ -202,7 +202,7 @@ namespace Nz
|
||||
activeSockets = static_cast<unsigned int>(selectValue);
|
||||
|
||||
if (error)
|
||||
*error = SocketError_NoError;
|
||||
*error = SocketError::NoError;
|
||||
#endif
|
||||
|
||||
return activeSockets;
|
||||
|
||||
Reference in New Issue
Block a user