Use std::size_t

This commit is contained in:
Chris Thrasher 2022-08-20 22:36:15 -06:00 committed by Lukas Dürrenberger
parent f521e2ec48
commit 82b48a7520
14 changed files with 30 additions and 30 deletions

View File

@ -1611,7 +1611,7 @@ public:
void setupUniformBuffers() void setupUniformBuffers()
{ {
// Create a uniform buffer for every frame that might be in flight to prevent clobbering // Create a uniform buffer for every frame that might be in flight to prevent clobbering
for (size_t i = 0; i < swapchainImages.size(); ++i) for (std::size_t i = 0; i < swapchainImages.size(); ++i)
{ {
uniformBuffers.push_back(0); uniformBuffers.push_back(0);
uniformBuffersMemory.push_back(0); uniformBuffersMemory.push_back(0);

View File

@ -36,7 +36,7 @@
namespace namespace
{ {
size_t read(void* ptr, size_t size, size_t nmemb, void* data) std::size_t read(void* ptr, std::size_t size, std::size_t nmemb, void* data)
{ {
auto* stream = static_cast<sf::InputStream*>(data); auto* stream = static_cast<sf::InputStream*>(data);
return static_cast<std::size_t>(stream->read(ptr, static_cast<sf::Int64>(size * nmemb))); return static_cast<std::size_t>(stream->read(ptr, static_cast<sf::Int64>(size * nmemb)));

View File

@ -474,7 +474,7 @@ static void onConfigurationChanged(ANativeActivity* /* activity */)
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
static void* onSaveInstanceState(ANativeActivity* /* activity */, size_t* outLen) static void* onSaveInstanceState(ANativeActivity* /* activity */, std::size_t* outLen)
{ {
*outLen = 0; *outLen = 0;
@ -489,7 +489,7 @@ static void onLowMemory(ANativeActivity* /* activity */)
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
JNIEXPORT void ANativeActivity_onCreate(ANativeActivity* activity, void* savedState, size_t savedStateSize) JNIEXPORT void ANativeActivity_onCreate(ANativeActivity* activity, void* savedState, std::size_t savedStateSize)
{ {
// Create an activity states (will keep us in the know, about events we care) // Create an activity states (will keep us in the know, about events we care)
auto* states = new sf::priv::ActivityStates; auto* states = new sf::priv::ActivityStates;

View File

@ -38,7 +38,7 @@
namespace namespace
{ {
using activityOnCreatePointer = void (*)(ANativeActivity*, void*, size_t); using activityOnCreatePointer = void (*)(ANativeActivity*, void*, std::size_t);
} }
const char* getLibraryName(JNIEnv* lJNIEnv, jobject& objectActivityInfo) const char* getLibraryName(JNIEnv* lJNIEnv, jobject& objectActivityInfo)
@ -71,7 +71,7 @@ const char* getLibraryName(JNIEnv* lJNIEnv, jobject& objectActivityInfo)
} }
// Convert the application name to a C++ string and return it // Convert the application name to a C++ string and return it
const size_t applicationNameLength = static_cast<size_t>(lJNIEnv->GetStringUTFLength(valueString)); const std::size_t applicationNameLength = static_cast<std::size_t>(lJNIEnv->GetStringUTFLength(valueString));
const char* applicationName = lJNIEnv->GetStringUTFChars(valueString, nullptr); const char* applicationName = lJNIEnv->GetStringUTFChars(valueString, nullptr);
if (applicationNameLength >= 256) if (applicationNameLength >= 256)
@ -80,7 +80,7 @@ const char* getLibraryName(JNIEnv* lJNIEnv, jobject& objectActivityInfo)
exit(1); exit(1);
} }
strncpy(name, applicationName, static_cast<size_t>(applicationNameLength)); strncpy(name, applicationName, static_cast<std::size_t>(applicationNameLength));
name[applicationNameLength] = '\0'; name[applicationNameLength] = '\0';
lJNIEnv->ReleaseStringUTFChars(valueString, applicationName); lJNIEnv->ReleaseStringUTFChars(valueString, applicationName);
@ -132,7 +132,7 @@ void* loadLibrary(const char* libraryName, JNIEnv* lJNIEnv, jobject& ObjectActiv
return handle; return handle;
} }
void ANativeActivity_onCreate(ANativeActivity* activity, void* savedState, size_t savedStateSize) void ANativeActivity_onCreate(ANativeActivity* activity, void* savedState, std::size_t savedStateSize)
{ {
// Before we can load a library, we need to find out its location. As // Before we can load a library, we need to find out its location. As
// we're powerless here in C/C++, we need the JNI interface to communicate // we're powerless here in C/C++, we need the JNI interface to communicate

View File

@ -55,7 +55,7 @@ public:
// Types // Types
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
using AddrLength = socklen_t; using AddrLength = socklen_t;
using Size = size_t; using Size = std::size_t;
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// \brief Create an internal sockaddr_in address /// \brief Create an internal sockaddr_in address

View File

@ -68,7 +68,7 @@ struct ActivityStates
EglContext* context; EglContext* context;
void* savedState; void* savedState;
size_t savedStateSize; std::size_t savedStateSize;
std::recursive_mutex mutex; std::recursive_mutex mutex;

View File

@ -61,7 +61,7 @@ Int64 ResourceStream::read(void* data, Int64 size)
{ {
if (m_file) if (m_file)
{ {
return AAsset_read(m_file, data, static_cast<size_t>(size)); return AAsset_read(m_file, data, static_cast<std::size_t>(size));
} }
else else
{ {

View File

@ -476,9 +476,9 @@ int WindowImplAndroid::processMotionEvent(AInputEvent* _event, ActivityStates& s
else if (static_cast<Uint32>(device) & AINPUT_SOURCE_TOUCHSCREEN) else if (static_cast<Uint32>(device) & AINPUT_SOURCE_TOUCHSCREEN)
event.type = Event::TouchMoved; event.type = Event::TouchMoved;
size_t pointerCount = AMotionEvent_getPointerCount(_event); std::size_t pointerCount = AMotionEvent_getPointerCount(_event);
for (size_t p = 0; p < pointerCount; ++p) for (std::size_t p = 0; p < pointerCount; ++p)
{ {
int32_t id = AMotionEvent_getPointerId(_event, p); int32_t id = AMotionEvent_getPointerId(_event, p);
@ -516,7 +516,7 @@ int WindowImplAndroid::processPointerEvent(bool isDown, AInputEvent* _event, Act
int32_t device = AInputEvent_getSource(_event); int32_t device = AInputEvent_getSource(_event);
int32_t action = AMotionEvent_getAction(_event); int32_t action = AMotionEvent_getAction(_event);
size_t index = (action & AMOTION_EVENT_ACTION_POINTER_INDEX_MASK) >> AMOTION_EVENT_ACTION_POINTER_INDEX_SHIFT; std::size_t index = (action & AMOTION_EVENT_ACTION_POINTER_INDEX_MASK) >> AMOTION_EVENT_ACTION_POINTER_INDEX_SHIFT;
int32_t id = AMotionEvent_getPointerId(_event, index); int32_t id = AMotionEvent_getPointerId(_event, index);
int x = static_cast<int>(AMotionEvent_getX(_event, index)); int x = static_cast<int>(AMotionEvent_getX(_event, index));

View File

@ -315,8 +315,8 @@ void pushEvent(sf::Event& event)
TouchSlot& atSlot(int idx) TouchSlot& atSlot(int idx)
{ {
if (idx >= static_cast<int>(touchSlots.size())) if (idx >= static_cast<int>(touchSlots.size()))
touchSlots.resize(static_cast<size_t>(idx + 1)); touchSlots.resize(static_cast<std::size_t>(idx + 1));
return touchSlots.at(static_cast<size_t>(idx)); return touchSlots.at(static_cast<std::size_t>(idx));
} }
void processSlots() void processSlots()

View File

@ -228,7 +228,7 @@ bool JoystickImpl::open(unsigned int index)
// Then allocate a buffer for data retrieval // Then allocate a buffer for data retrieval
m_length = hid_report_size(m_desc, hid_input, m_id); m_length = hid_report_size(m_desc, hid_input, m_id);
m_buffer.resize(static_cast<size_t>(m_length)); m_buffer.resize(static_cast<std::size_t>(m_length));
m_state.connected = true; m_state.connected = true;
@ -300,7 +300,7 @@ Joystick::Identification JoystickImpl::getIdentification() const
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
JoystickState JoystickImpl::JoystickImpl::update() JoystickState JoystickImpl::JoystickImpl::update()
{ {
while (read(m_file, m_buffer.data(), static_cast<size_t>(m_length)) == m_length) while (read(m_file, m_buffer.data(), static_cast<std::size_t>(m_length)) == m_length)
{ {
hid_data_t data = hid_start_parse(m_desc, 1 << hid_input, m_id); hid_data_t data = hid_start_parse(m_desc, 1 << hid_input, m_id);

View File

@ -44,7 +44,7 @@ namespace priv
/// to represent video mode. Instead it uses a CGDisplayMode opaque type. /// to represent video mode. Instead it uses a CGDisplayMode opaque type.
/// ///
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
size_t modeBitsPerPixel(CGDisplayModeRef mode); std::size_t modeBitsPerPixel(CGDisplayModeRef mode);
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// \brief Get bpp for all OS X version /// \brief Get bpp for all OS X version
@ -53,7 +53,7 @@ size_t modeBitsPerPixel(CGDisplayModeRef mode);
/// display bits per pixel information for a given display id. /// display bits per pixel information for a given display id.
/// ///
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
size_t displayBitsPerPixel(CGDirectDisplayID displayId); std::size_t displayBitsPerPixel(CGDirectDisplayID displayId);
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// \brief Convert a Quartz video mode into a sf::VideoMode object /// \brief Convert a Quartz video mode into a sf::VideoMode object

View File

@ -38,9 +38,9 @@ namespace priv
{ {
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
size_t modeBitsPerPixel(CGDisplayModeRef mode) std::size_t modeBitsPerPixel(CGDisplayModeRef mode)
{ {
size_t bpp = 0; // no match std::size_t bpp = 0; // no match
// Compare encoding. // Compare encoding.
CFStringRef pixEnc = CGDisplayModeCopyPixelEncoding(mode); CFStringRef pixEnc = CGDisplayModeCopyPixelEncoding(mode);
@ -59,13 +59,13 @@ size_t modeBitsPerPixel(CGDisplayModeRef mode)
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
size_t displayBitsPerPixel(CGDirectDisplayID displayId) std::size_t displayBitsPerPixel(CGDirectDisplayID displayId)
{ {
// Get the display mode. // Get the display mode.
CGDisplayModeRef mode = CGDisplayCopyDisplayMode(displayId); CGDisplayModeRef mode = CGDisplayCopyDisplayMode(displayId);
// Get bpp for the mode. // Get bpp for the mode.
const size_t bpp = modeBitsPerPixel(mode); const std::size_t bpp = modeBitsPerPixel(mode);
// Clean up Memory. // Clean up Memory.
CGDisplayModeRelease(mode); CGDisplayModeRelease(mode);

View File

@ -87,7 +87,7 @@ void ClipboardImpl::setString(const String& text)
} }
// Create a Win32-compatible string // Create a Win32-compatible string
size_t string_size = (text.getSize() + 1) * sizeof(WCHAR); std::size_t string_size = (text.getSize() + 1) * sizeof(WCHAR);
HANDLE string_handle = GlobalAlloc(GMEM_MOVEABLE, string_size); HANDLE string_handle = GlobalAlloc(GMEM_MOVEABLE, string_size);
if (string_handle) if (string_handle)

View File

@ -17,7 +17,7 @@ struct StringMaker<std::vector<float>>
{ {
assert(!vector.empty()); assert(!vector.empty());
doctest::String out = "{ "; doctest::String out = "{ ";
for (size_t i = 0; i + 1 < vector.size(); ++i) for (std::size_t i = 0; i + 1 < vector.size(); ++i)
out += toString(vector[i]) + ", "; out += toString(vector[i]) + ", ";
out += toString(vector.back()) + " }"; out += toString(vector.back()) + " }";
return out; return out;