From c824d3d57a5ef905a4453c9c2fde892c2aa8737b Mon Sep 17 00:00:00 2001 From: Pawel Paruzel Date: Sat, 18 Dec 2021 22:21:52 +0100 Subject: [PATCH] Fix all macOS clang warnings Co-authored-by: binary1248 --- cmake/CompilerWarnings.cmake | 7 +-- examples/cocoa/CocoaAppDelegate.mm | 14 ++++- examples/cocoa/NSString+stdstring.mm | 6 +- include/SFML/Config.hpp | 7 +++ include/SFML/System/Utf.inl | 2 +- src/SFML/Audio/ALCheck.cpp | 7 +++ src/SFML/Audio/ALCheck.hpp | 18 ++++++ src/SFML/Audio/AudioDevice.cpp | 7 +++ src/SFML/Audio/Music.cpp | 7 +++ src/SFML/Audio/Sound.cpp | 7 +++ src/SFML/Audio/SoundBuffer.cpp | 7 +++ src/SFML/Audio/SoundRecorder.cpp | 7 +++ src/SFML/Audio/SoundSource.cpp | 7 +++ src/SFML/Audio/SoundStream.cpp | 7 +++ src/SFML/Main/SFMLActivity.cpp | 3 +- src/SFML/Network/SocketSelector.cpp | 2 +- src/SFML/Network/TcpSocket.cpp | 2 +- src/SFML/Window/Android/SensorImpl.cpp | 8 ++- src/SFML/Window/Android/WindowImplAndroid.cpp | 47 ++++++++------- src/SFML/Window/EglContext.cpp | 3 +- src/SFML/Window/FreeBSD/JoystickImpl.cpp | 12 ++-- src/SFML/Window/OSX/HIDInputManager.mm | 19 +++--- src/SFML/Window/OSX/HIDJoystickManager.cpp | 2 +- src/SFML/Window/OSX/InputImpl.mm | 20 +++---- src/SFML/Window/OSX/JoystickImpl.cpp | 34 +++++------ src/SFML/Window/OSX/NSImage+raw.mm | 4 +- src/SFML/Window/OSX/SFApplication.m | 8 +++ src/SFML/Window/OSX/SFApplicationDelegate.m | 8 +++ src/SFML/Window/OSX/SFContext.mm | 24 +++++--- .../Window/OSX/SFKeyboardModifiersHelper.mm | 8 +++ src/SFML/Window/OSX/SFOpenGLView+keyboard.mm | 8 +++ src/SFML/Window/OSX/SFOpenGLView+mouse.mm | 20 +++++-- src/SFML/Window/OSX/SFOpenGLView.h | 18 ++++++ src/SFML/Window/OSX/SFOpenGLView.mm | 14 ++++- src/SFML/Window/OSX/SFViewController.mm | 8 +++ src/SFML/Window/OSX/SFWindowController.mm | 28 +++++---- src/SFML/Window/OSX/Scaling.h | 4 +- src/SFML/Window/OSX/VideoModeImpl.cpp | 2 +- src/SFML/Window/OSX/WindowImplCocoa.hpp | 17 ++++++ src/SFML/Window/OSX/WindowImplCocoa.mm | 8 +-- .../Window/OSX/WindowImplDelegateProtocol.h | 18 ++++++ src/SFML/Window/OSX/cg_sf_conversion.mm | 10 +++- src/SFML/Window/OSX/cpp_objc_conversion.mm | 2 +- src/SFML/Window/iOS/CursorImpl.cpp | 4 +- src/SFML/Window/iOS/EaglContext.mm | 21 +++++-- src/SFML/Window/iOS/InputImpl.mm | 16 ++--- src/SFML/Window/iOS/JoystickImpl.mm | 4 +- src/SFML/Window/iOS/SFAppDelegate.mm | 43 ++++++++++---- src/SFML/Window/iOS/SFView.mm | 16 +++-- src/SFML/Window/iOS/SensorImpl.mm | 30 +++++----- src/SFML/Window/iOS/VideoModeImpl.mm | 4 +- src/SFML/Window/iOS/WindowImplUIKit.mm | 58 ++++++++++++++----- 52 files changed, 473 insertions(+), 194 deletions(-) diff --git a/cmake/CompilerWarnings.cmake b/cmake/CompilerWarnings.cmake index 975f890d..e81162b6 100644 --- a/cmake/CompilerWarnings.cmake +++ b/cmake/CompilerWarnings.cmake @@ -4,12 +4,7 @@ # Helper function to enable compiler warnings for a specific set of files function(set_file_warnings) - if(APPLE) - # Temporarily disable Apple default until warnings are fixed - option(WARNINGS_AS_ERRORS "Treat compiler warnings as errors" FALSE) - else() - option(WARNINGS_AS_ERRORS "Treat compiler warnings as errors" TRUE) - endif() + option(WARNINGS_AS_ERRORS "Treat compiler warnings as errors" TRUE) set(MSVC_WARNINGS /W4 # Baseline reasonable warnings diff --git a/examples/cocoa/CocoaAppDelegate.mm b/examples/cocoa/CocoaAppDelegate.mm index 9edf1699..a42f3606 100644 --- a/examples/cocoa/CocoaAppDelegate.mm +++ b/examples/cocoa/CocoaAppDelegate.mm @@ -31,6 +31,14 @@ #define GREEN @"Green" #define RED @"Red" +#if defined(__APPLE__) + #if defined(__clang__) + #pragma clang diagnostic ignored "-Wdeprecated-declarations" + #elif defined(__GNUC__) + #pragma GCC diagnostic ignored "-Wdeprecated-declarations" + #endif +#endif + // Our PIMPL struct SFMLmainWindow { @@ -48,7 +56,7 @@ struct SFMLmainWindow sf::FloatRect rect = sprite.getLocalBounds(); sf::Vector2f size(rect.width, rect.height); sprite.setOrigin(size / 2.f); - sprite.scale(0.3, 0.3); + sprite.scale(0.3f, 0.3f); unsigned int ww = renderWindow.getSize().x; unsigned int wh = renderWindow.getSize().y; @@ -117,7 +125,7 @@ struct SFMLmainWindow self.visible = YES; // Launch the timer to periodically display our stuff into the Cocoa view. - self.renderTimer = [NSTimer timerWithTimeInterval:1.f/60.f + self.renderTimer = [NSTimer timerWithTimeInterval:1.0/60.0 target:self selector:@selector(renderMainWindow:) userInfo:nil @@ -148,7 +156,7 @@ struct SFMLmainWindow self.sfmlView = nil; self.textField = nil; - delete (SFMLmainWindow*) self.mainWindow; + delete static_cast(self.mainWindow); self.mainWindow = 0; self.renderTimer = nil; diff --git a/examples/cocoa/NSString+stdstring.mm b/examples/cocoa/NSString+stdstring.mm index 36a2f4df..b9adebe8 100644 --- a/examples/cocoa/NSString+stdstring.mm +++ b/examples/cocoa/NSString+stdstring.mm @@ -42,8 +42,8 @@ +(id)stringWithstdwstring:(const std::wstring&)string { - char* data = (char*)string.data(); - unsigned size = string.size() * sizeof(wchar_t); + const void* data = static_cast(string.data()); + unsigned size = static_cast(string.size() * sizeof(wchar_t)); NSString* str = [[[NSString alloc] initWithBytes:data length:size encoding:NSUTF32LittleEndianStringEncoding] autorelease]; @@ -67,7 +67,7 @@ // According to Wikipedia, Mac OS X is Little Endian on x86 and x86-64 // https://en.wikipedia.org/wiki/Endianness NSData* asData = [self dataUsingEncoding:NSUTF32LittleEndianStringEncoding]; - return std::wstring((wchar_t*)[asData bytes], [asData length] / sizeof(wchar_t)); + return std::wstring(static_cast([asData bytes]), [asData length] / sizeof(wchar_t)); } @end diff --git a/include/SFML/Config.hpp b/include/SFML/Config.hpp index 2066b73c..72d648b6 100644 --- a/include/SFML/Config.hpp +++ b/include/SFML/Config.hpp @@ -231,8 +231,15 @@ namespace sf typedef signed __int64 Int64; typedef unsigned __int64 Uint64; #else + #if defined(__clang__) + #pragma clang diagnostic push + #pragma clang diagnostic ignored "-Wc++11-long-long" + #endif typedef signed long long Int64; typedef unsigned long long Uint64; + #if defined(__clang__) + #pragma clang diagnostic pop + #endif #endif } // namespace sf diff --git a/include/SFML/System/Utf.inl b/include/SFML/System/Utf.inl index ee7d3fa1..76c5d9ce 100644 --- a/include/SFML/System/Utf.inl +++ b/include/SFML/System/Utf.inl @@ -97,7 +97,7 @@ Out Utf<8>::encode(Uint32 input, Out output, Uint8 replacement) { // Invalid character if (replacement) - *output++ = replacement; + output = std::copy(&replacement, &replacement + 1, output); } else { diff --git a/src/SFML/Audio/ALCheck.cpp b/src/SFML/Audio/ALCheck.cpp index 125fdb4e..1719c1b7 100644 --- a/src/SFML/Audio/ALCheck.cpp +++ b/src/SFML/Audio/ALCheck.cpp @@ -29,6 +29,13 @@ #include #include +#if defined(__APPLE__) + #if defined(__clang__) + #pragma clang diagnostic ignored "-Wdeprecated-declarations" + #elif defined(__GNUC__) + #pragma GCC diagnostic ignored "-Wdeprecated-declarations" + #endif +#endif namespace sf { diff --git a/src/SFML/Audio/ALCheck.hpp b/src/SFML/Audio/ALCheck.hpp index 9b1fb420..a560b542 100644 --- a/src/SFML/Audio/ALCheck.hpp +++ b/src/SFML/Audio/ALCheck.hpp @@ -30,6 +30,16 @@ //////////////////////////////////////////////////////////// #include +#if defined(__APPLE__) + #if defined(__clang__) + #pragma clang diagnostic push + #pragma clang diagnostic ignored "-Wdeprecated-declarations" + #elif defined(__GNUC__) + #pragma GCC diagnostic push + #pragma GCC diagnostic ignored "-Wdeprecated-declarations" + #endif +#endif + #include #include @@ -70,3 +80,11 @@ void alCheckError(const char* file, unsigned int line, const char* expression); #endif // SFML_ALCHECK_HPP + +#if defined(__APPLE__) + #if defined(__clang__) + #pragma clang diagnostic pop + #elif defined(__GNUC__) + #pragma GCC diagnostic pop + #endif +#endif diff --git a/src/SFML/Audio/AudioDevice.cpp b/src/SFML/Audio/AudioDevice.cpp index 25c86d99..6d729ef3 100644 --- a/src/SFML/Audio/AudioDevice.cpp +++ b/src/SFML/Audio/AudioDevice.cpp @@ -31,6 +31,13 @@ #include #include +#if defined(__APPLE__) + #if defined(__clang__) + #pragma clang diagnostic ignored "-Wdeprecated-declarations" + #elif defined(__GNUC__) + #pragma GCC diagnostic ignored "-Wdeprecated-declarations" + #endif +#endif namespace { diff --git a/src/SFML/Audio/Music.cpp b/src/SFML/Audio/Music.cpp index d375ef88..f7d627d8 100644 --- a/src/SFML/Audio/Music.cpp +++ b/src/SFML/Audio/Music.cpp @@ -32,6 +32,13 @@ #include #include +#if defined(__APPLE__) + #if defined(__clang__) + #pragma clang diagnostic ignored "-Wdeprecated-declarations" + #elif defined(__GNUC__) + #pragma GCC diagnostic ignored "-Wdeprecated-declarations" + #endif +#endif namespace sf { diff --git a/src/SFML/Audio/Sound.cpp b/src/SFML/Audio/Sound.cpp index bb5b9fab..9c74b044 100644 --- a/src/SFML/Audio/Sound.cpp +++ b/src/SFML/Audio/Sound.cpp @@ -29,6 +29,13 @@ #include #include +#if defined(__APPLE__) + #if defined(__clang__) + #pragma clang diagnostic ignored "-Wdeprecated-declarations" + #elif defined(__GNUC__) + #pragma GCC diagnostic ignored "-Wdeprecated-declarations" + #endif +#endif namespace sf { diff --git a/src/SFML/Audio/SoundBuffer.cpp b/src/SFML/Audio/SoundBuffer.cpp index cd88145b..f3ce56ed 100644 --- a/src/SFML/Audio/SoundBuffer.cpp +++ b/src/SFML/Audio/SoundBuffer.cpp @@ -34,6 +34,13 @@ #include #include +#if defined(__APPLE__) + #if defined(__clang__) + #pragma clang diagnostic ignored "-Wdeprecated-declarations" + #elif defined(__GNUC__) + #pragma GCC diagnostic ignored "-Wdeprecated-declarations" + #endif +#endif namespace sf { diff --git a/src/SFML/Audio/SoundRecorder.cpp b/src/SFML/Audio/SoundRecorder.cpp index d80182ce..22337e51 100644 --- a/src/SFML/Audio/SoundRecorder.cpp +++ b/src/SFML/Audio/SoundRecorder.cpp @@ -37,6 +37,13 @@ #pragma warning(disable: 4355) // 'this' used in base member initializer list #endif +#if defined(__APPLE__) + #if defined(__clang__) + #pragma clang diagnostic ignored "-Wdeprecated-declarations" + #elif defined(__GNUC__) + #pragma GCC diagnostic ignored "-Wdeprecated-declarations" + #endif +#endif namespace { diff --git a/src/SFML/Audio/SoundSource.cpp b/src/SFML/Audio/SoundSource.cpp index 6876f7bf..84c9fab5 100644 --- a/src/SFML/Audio/SoundSource.cpp +++ b/src/SFML/Audio/SoundSource.cpp @@ -28,6 +28,13 @@ #include #include +#if defined(__APPLE__) + #if defined(__clang__) + #pragma clang diagnostic ignored "-Wdeprecated-declarations" + #elif defined(__GNUC__) + #pragma GCC diagnostic ignored "-Wdeprecated-declarations" + #endif +#endif namespace sf { diff --git a/src/SFML/Audio/SoundStream.cpp b/src/SFML/Audio/SoundStream.cpp index df5eb6bd..9596e21c 100644 --- a/src/SFML/Audio/SoundStream.cpp +++ b/src/SFML/Audio/SoundStream.cpp @@ -36,6 +36,13 @@ #pragma warning(disable: 4355) // 'this' used in base member initializer list #endif +#if defined(__APPLE__) + #if defined(__clang__) + #pragma clang diagnostic ignored "-Wdeprecated-declarations" + #elif defined(__GNUC__) + #pragma GCC diagnostic ignored "-Wdeprecated-declarations" + #endif +#endif namespace sf { diff --git a/src/SFML/Main/SFMLActivity.cpp b/src/SFML/Main/SFMLActivity.cpp index f6b5c327..49f26e8f 100644 --- a/src/SFML/Main/SFMLActivity.cpp +++ b/src/SFML/Main/SFMLActivity.cpp @@ -77,7 +77,7 @@ const char *getLibraryName(JNIEnv* lJNIEnv, jobject& objectActivityInfo) exit(1); } - strncpy(name, applicationName, applicationNameLength); + strncpy(name, applicationName, static_cast(applicationNameLength)); name[applicationNameLength] = '\0'; lJNIEnv->ReleaseStringUTFChars(valueString, applicationName); @@ -141,7 +141,6 @@ void ANativeActivity_onCreate(ANativeActivity* activity, void* savedState, size_ // With libname being the library name such as "jpeg". // Retrieve JNI environment and JVM instance - // JavaVM* lJavaVM = activity->vm; JNIEnv* lJNIEnv = activity->env; // Retrieve the NativeActivity diff --git a/src/SFML/Network/SocketSelector.cpp b/src/SFML/Network/SocketSelector.cpp index 47fe597c..5765c4bd 100644 --- a/src/SFML/Network/SocketSelector.cpp +++ b/src/SFML/Network/SocketSelector.cpp @@ -158,7 +158,7 @@ bool SocketSelector::wait(Time timeout) // Setup the timeout timeval time; time.tv_sec = static_cast(timeout.asMicroseconds() / 1000000); - time.tv_usec = static_cast(timeout.asMicroseconds() % 1000000); + time.tv_usec = static_cast(timeout.asMicroseconds() % 1000000); // Initialize the set that will contain the sockets that are ready m_impl->socketsReady = m_impl->allSockets; diff --git a/src/SFML/Network/TcpSocket.cpp b/src/SFML/Network/TcpSocket.cpp index 02ed063b..67b7b6f2 100644 --- a/src/SFML/Network/TcpSocket.cpp +++ b/src/SFML/Network/TcpSocket.cpp @@ -175,7 +175,7 @@ Socket::Status TcpSocket::connect(const IpAddress& remoteAddress, unsigned short // Setup the timeout timeval time; time.tv_sec = static_cast(timeout.asMicroseconds() / 1000000); - time.tv_usec = static_cast(timeout.asMicroseconds() % 1000000); + time.tv_usec = static_cast(timeout.asMicroseconds() % 1000000); // Wait for something to write on our socket (which means that the connection request has returned) if (select(static_cast(getHandle() + 1), NULL, &selector, NULL, &time) > 0) diff --git a/src/SFML/Window/Android/SensorImpl.cpp b/src/SFML/Window/Android/SensorImpl.cpp index 2afe6ae4..5a08b743 100644 --- a/src/SFML/Window/Android/SensorImpl.cpp +++ b/src/SFML/Window/Android/SensorImpl.cpp @@ -29,6 +29,12 @@ #include #include +#if defined(__clang__) + #pragma clang diagnostic ignored "-Wdeprecated-declarations" +#elif defined(__GNUC__) + #pragma GCC diagnostic ignored "-Wdeprecated-declarations" +#endif + // Define missing constants #define ASENSOR_TYPE_GRAVITY 0x00000009 #define ASENSOR_TYPE_LINEAR_ACCELERATION 0x0000000a @@ -97,7 +103,7 @@ bool SensorImpl::open(Sensor::Type sensor) Time minimumDelay = microseconds(ASensor_getMinDelay(m_sensor)); // Set the event rate (not to consume too much battery) - ASensorEventQueue_setEventRate(sensorEventQueue, m_sensor, static_cast(minimumDelay.asMicroseconds())); + ASensorEventQueue_setEventRate(sensorEventQueue, m_sensor, static_cast(minimumDelay.asMicroseconds())); // Save the index of the sensor m_index = static_cast(sensor); diff --git a/src/SFML/Window/Android/WindowImplAndroid.cpp b/src/SFML/Window/Android/WindowImplAndroid.cpp index 6adccd77..afecc861 100644 --- a/src/SFML/Window/Android/WindowImplAndroid.cpp +++ b/src/SFML/Window/Android/WindowImplAndroid.cpp @@ -318,7 +318,6 @@ int WindowImplAndroid::processScrollEvent(AInputEvent* _event, ActivityStates& s { // Prepare the Java virtual machine jint lResult; - // jint lFlags = 0; JavaVM* lJavaVM = states.activity->vm; JNIEnv* lJNIEnv = states.activity->env; @@ -336,30 +335,33 @@ int WindowImplAndroid::processScrollEvent(AInputEvent* _event, ActivityStates& s } // Retrieve everything we need to create this MotionEvent in Java - sf::Int64 downTime = AMotionEvent_getDownTime(_event); - sf::Int64 eventTime = AMotionEvent_getEventTime(_event); - sf::Int32 action = AMotionEvent_getAction(_event); + Int64 downTime = AMotionEvent_getDownTime(_event); + Int64 eventTime = AMotionEvent_getEventTime(_event); + Int32 action = AMotionEvent_getAction(_event); float x = AMotionEvent_getX(_event, 0); float y = AMotionEvent_getY(_event, 0); float pressure = AMotionEvent_getPressure(_event, 0); float size = AMotionEvent_getSize(_event, 0); - sf::Int32 metaState = AMotionEvent_getMetaState(_event); + Int32 metaState = AMotionEvent_getMetaState(_event); float xPrecision = AMotionEvent_getXPrecision(_event); float yPrecision = AMotionEvent_getYPrecision(_event); - sf::Int32 deviceId = AInputEvent_getDeviceId(_event); - sf::Int32 edgeFlags = AMotionEvent_getEdgeFlags(_event); + Int32 deviceId = AInputEvent_getDeviceId(_event); + Int32 edgeFlags = AMotionEvent_getEdgeFlags(_event); // Create the MotionEvent object in Java trough its static constructor obtain() jclass ClassMotionEvent = lJNIEnv->FindClass("android/view/MotionEvent"); jmethodID StaticMethodObtain = lJNIEnv->GetStaticMethodID(ClassMotionEvent, "obtain", "(JJIFFFFIFFII)Landroid/view/MotionEvent;"); - // Harmless warning related to C standard compatibility - // varargs automatically promote floats to doubles - // even though the function signature declares float - #pragma clang diagnostic ignored "-Wdouble-promotion" + // Note: C standard compatibility, varargs + // automatically promote floats to doubles + // even though the function signature declares float jobject ObjectMotionEvent = lJNIEnv->CallStaticObjectMethod( ClassMotionEvent, StaticMethodObtain, downTime, - eventTime, action, x, y, pressure, size, metaState, - xPrecision, yPrecision, deviceId, edgeFlags); + eventTime, action, static_cast(x), + static_cast(y), static_cast(pressure), + static_cast(size), metaState, + static_cast(xPrecision), static_cast(yPrecision), + deviceId, edgeFlags + ); // Call its getAxisValue() method to get the delta value of our wheel move event jmethodID MethodGetAxisValue = lJNIEnv->GetMethodID(ClassMotionEvent, "getAxisValue", "(I)F"); @@ -387,7 +389,6 @@ int WindowImplAndroid::processScrollEvent(AInputEvent* _event, ActivityStates& s //////////////////////////////////////////////////////////// int WindowImplAndroid::processKeyEvent(AInputEvent* _event, ActivityStates& /* states */) { - // int32_t device = AInputEvent_getSource(_event); int32_t action = AKeyEvent_getAction(_event); int32_t key = AKeyEvent_getKeyCode(_event); @@ -409,10 +410,10 @@ int WindowImplAndroid::processKeyEvent(AInputEvent* _event, ActivityStates& /* s event.type = Event::KeyReleased; forwardEvent(event); - if (sf::Uint32 unicode = static_cast(getUnicode(_event))) + if (Uint32 unicode = static_cast(getUnicode(_event))) { event.type = Event::TextEntered; - event.text.unicode = unicode; + event.text.unicode = static_cast(unicode); forwardEvent(event); } return 1; @@ -432,10 +433,10 @@ int WindowImplAndroid::processKeyEvent(AInputEvent* _event, ActivityStates& /* s // https://code.google.com/p/android/issues/detail?id=33998 return 0; } - else if (sf::Uint32 unicode = static_cast(getUnicode(_event))) // This is a repeated sequence + else if (Uint32 unicode = static_cast(getUnicode(_event))) // This is a repeated sequence { event.type = Event::TextEntered; - event.text.unicode = unicode; + event.text.unicode = static_cast(unicode); int32_t repeats = AKeyEvent_getRepeatCount(_event); for (int32_t i = 0; i < repeats; ++i) @@ -452,20 +453,19 @@ int WindowImplAndroid::processKeyEvent(AInputEvent* _event, ActivityStates& /* s int WindowImplAndroid::processMotionEvent(AInputEvent* _event, ActivityStates& states) { int32_t device = AInputEvent_getSource(_event); - // int32_t action = AMotionEvent_getAction(_event); Event event; if (device == AINPUT_SOURCE_MOUSE) event.type = Event::MouseMoved; - else if (static_cast(device) & AINPUT_SOURCE_TOUCHSCREEN) + else if (static_cast(device) & AINPUT_SOURCE_TOUCHSCREEN) event.type = Event::TouchMoved; size_t pointerCount = AMotionEvent_getPointerCount(_event); for (size_t p = 0; p < pointerCount; p++) { - int id = AMotionEvent_getPointerId(_event, p); + int32_t id = AMotionEvent_getPointerId(_event, p); int x = static_cast(AMotionEvent_getX(_event, p)); int y = static_cast(AMotionEvent_getY(_event, p)); @@ -477,7 +477,7 @@ int WindowImplAndroid::processMotionEvent(AInputEvent* _event, ActivityStates& s states.mousePosition = Vector2i(event.mouseMove.x, event.mouseMove.y); } - else if (static_cast(device) & AINPUT_SOURCE_TOUCHSCREEN) + else if (static_cast(device) & AINPUT_SOURCE_TOUCHSCREEN) { if (states.touchEvents[id].x == x && states.touchEvents[id].y == y) continue; @@ -543,7 +543,7 @@ int WindowImplAndroid::processPointerEvent(bool isDown, AInputEvent* _event, Act if (id >= 0 && id < Mouse::ButtonCount) states.isButtonPressed[id] = false; } - else if (static_cast(device) & AINPUT_SOURCE_TOUCHSCREEN) + else if (static_cast(device) & AINPUT_SOURCE_TOUCHSCREEN) { event.type = Event::TouchEnded; event.touch.finger = static_cast(id); @@ -690,7 +690,6 @@ int WindowImplAndroid::getUnicode(AInputEvent* event) // Initializes JNI jint lResult; - // jint lFlags = 0; JavaVM* lJavaVM = states.activity->vm; JNIEnv* lJNIEnv = states.activity->env; diff --git a/src/SFML/Window/EglContext.cpp b/src/SFML/Window/EglContext.cpp index de1b1670..2bfe13c0 100644 --- a/src/SFML/Window/EglContext.cpp +++ b/src/SFML/Window/EglContext.cpp @@ -138,7 +138,6 @@ m_context (EGL_NO_CONTEXT), m_surface (EGL_NO_SURFACE), m_config (NULL) { - (void) owner; EglContextImpl::ensureInit(); #ifdef SFML_SYSTEM_ANDROID @@ -165,6 +164,8 @@ m_config (NULL) // Create EGL surface (except on Android because the window is created // asynchronously, its activity manager will call it for us) createSurface(owner->getSystemHandle()); +#else + (void) owner; #endif } diff --git a/src/SFML/Window/FreeBSD/JoystickImpl.cpp b/src/SFML/Window/FreeBSD/JoystickImpl.cpp index 22c78eac..88b2d8a7 100644 --- a/src/SFML/Window/FreeBSD/JoystickImpl.cpp +++ b/src/SFML/Window/FreeBSD/JoystickImpl.cpp @@ -123,7 +123,7 @@ namespace name += directoryEntry->d_name; if (isJoystick(name.c_str())) - plugged[joystickCount++] = name; + plugged[static_cast(joystickCount++)] = name; } directoryEntry = readdir(directory); @@ -149,8 +149,8 @@ namespace void hatValueToSfml(int value, sf::priv::JoystickState& state) { - state.axes[sf::Joystick::PovX] = hatValueMap[value].first; - state.axes[sf::Joystick::PovY] = hatValueMap[value].second; + state.axes[sf::Joystick::PovX] = static_cast(hatValueMap[value].first); + state.axes[sf::Joystick::PovY] = static_cast(hatValueMap[value].second); } } @@ -220,7 +220,7 @@ bool JoystickImpl::open(unsigned int index) // Then allocate a buffer for data retrieval m_length = hid_report_size(m_desc, hid_input, m_id); - m_buffer.resize(m_length); + m_buffer.resize(static_cast(m_length)); m_state.connected = true; @@ -292,7 +292,7 @@ Joystick::Identification JoystickImpl::getIdentification() const //////////////////////////////////////////////////////////// JoystickState JoystickImpl::JoystickImpl::update() { - while (read(m_file, &m_buffer[0], m_length) == m_length) + while (read(m_file, &m_buffer[0], static_cast(m_length)) == m_length) { hid_data_t data = hid_start_parse(m_desc, 1 << hid_input, m_id); @@ -328,7 +328,7 @@ JoystickState JoystickImpl::JoystickImpl::update() int maximum = item.logical_maximum; value = (value - minimum) * 200 / (maximum - minimum) - 100; - m_state.axes[axis] = value; + m_state.axes[axis] = static_cast(value); } } } diff --git a/src/SFML/Window/OSX/HIDInputManager.mm b/src/SFML/Window/OSX/HIDInputManager.mm index 8868d3e0..8e722d4c 100644 --- a/src/SFML/Window/OSX/HIDInputManager.mm +++ b/src/SFML/Window/OSX/HIDInputManager.mm @@ -60,7 +60,7 @@ long HIDInputManager::getLocationID(IOHIDDeviceRef device) if (!typeRef || (CFGetTypeID(typeRef) != CFNumberGetTypeID())) return 0; - CFNumberRef locRef = (CFNumberRef)typeRef; + CFNumberRef locRef = static_cast(typeRef); if (!CFNumberGetValue(locRef, kCFNumberLongType, &loc)) return 0; @@ -100,8 +100,7 @@ m_manager(0) { // Get the current keyboard layout TISInputSourceRef tis = TISCopyCurrentKeyboardLayoutInputSource(); - m_layoutData = (CFDataRef)TISGetInputSourceProperty(tis, - kTISPropertyUnicodeKeyLayoutData); + m_layoutData = static_cast(TISGetInputSourceProperty(tis, kTISPropertyUnicodeKeyLayoutData)); if (m_layoutData == 0) { @@ -112,7 +111,7 @@ m_manager(0) // Keep a reference for ourself CFRetain(m_layoutData); - m_layout = (UCKeyboardLayout *)CFDataGetBytePtr(m_layoutData); + m_layout = reinterpret_cast(const_cast(CFDataGetBytePtr(m_layoutData))); // The TIS is no more needed CFRelease(tis); @@ -160,12 +159,12 @@ void HIDInputManager::initializeKeyboard() CFIndex keyboardCount = CFSetGetCount(keyboards); // >= 1 (asserted by copyDevices) // Get an iterable array - CFTypeRef devicesArray[keyboardCount]; - CFSetGetValues(keyboards, devicesArray); + std::vector devicesArray(static_cast(keyboardCount)); + CFSetGetValues(keyboards, &devicesArray[0]); for (CFIndex i = 0; i < keyboardCount; ++i) { - IOHIDDeviceRef keyboard = (IOHIDDeviceRef)devicesArray[i]; + IOHIDDeviceRef keyboard = static_cast(const_cast(devicesArray[static_cast(i)])); loadKeyboard(keyboard); } @@ -202,7 +201,7 @@ void HIDInputManager::loadKeyboard(IOHIDDeviceRef keyboard) // Go through all connected elements. for (CFIndex i = 0; i < keysCount; ++i) { - IOHIDElementRef aKey = (IOHIDElementRef) CFArrayGetValueAtIndex(keys, i); + IOHIDElementRef aKey = static_cast(const_cast(CFArrayGetValueAtIndex(keys, i))); // Skip non-matching keys elements if (IOHIDElementGetUsagePage(aKey) != kHIDPage_KeyboardOrKeypad) @@ -233,7 +232,7 @@ void HIDInputManager::loadKey(IOHIDElementRef key) // Unicode string length is usually less or equal to 4 UniCharCount maxStringLength = 4; UniCharCount actualStringLength = 0; - UniChar unicodeString[maxStringLength]; + std::vector unicodeString(maxStringLength); OSStatus error; @@ -246,7 +245,7 @@ void HIDInputManager::loadKey(IOHIDElementRef key) &deadKeyState, // unused stuff maxStringLength, // our memory limit &actualStringLength, // length of what we get - unicodeString); // what we get + unicodeString.data()); // what we get if (error == noErr) { diff --git a/src/SFML/Window/OSX/HIDJoystickManager.cpp b/src/SFML/Window/OSX/HIDJoystickManager.cpp index edcb5a4c..11cc05fe 100644 --- a/src/SFML/Window/OSX/HIDJoystickManager.cpp +++ b/src/SFML/Window/OSX/HIDJoystickManager.cpp @@ -85,7 +85,7 @@ m_joystickCount(0) maskArray[0] = mask0; maskArray[1] = mask1; - CFArrayRef mask = CFArrayCreate(NULL, (const void**)maskArray, 2, NULL); + CFArrayRef mask = CFArrayCreate(NULL, reinterpret_cast(maskArray), 2, NULL); IOHIDManagerSetDeviceMatchingMultiple(m_manager, mask); CFRelease(mask); diff --git a/src/SFML/Window/OSX/InputImpl.mm b/src/SFML/Window/OSX/InputImpl.mm index a5c200a1..b60b05ad 100644 --- a/src/SFML/Window/OSX/InputImpl.mm +++ b/src/SFML/Window/OSX/InputImpl.mm @@ -58,7 +58,7 @@ namespace priv //////////////////////////////////////////////////////////// SFOpenGLView* getSFOpenGLViewFromSFMLWindow(const WindowBase& window) { - id nsHandle = (id)window.getSystemHandle(); + id nsHandle = static_cast(window.getSystemHandle()); // Get our SFOpenGLView from ... SFOpenGLView* view = nil; @@ -78,7 +78,7 @@ SFOpenGLView* getSFOpenGLViewFromSFMLWindow(const WindowBase& window) { if ([subview isKindOfClass:[SFOpenGLView class]]) { - view = (SFOpenGLView*)subview; + view = static_cast(subview); break; } } @@ -102,7 +102,7 @@ SFOpenGLView* getSFOpenGLViewFromSFMLWindow(const WindowBase& window) { if ([subview isKindOfClass:[SFOpenGLView class]]) { - view = (SFOpenGLView*)subview; + view = static_cast(subview); break; } } @@ -156,8 +156,8 @@ Vector2i InputImpl::getMousePosition() NSPoint pos = [NSEvent mouseLocation]; pos.y = sf::VideoMode::getDesktopMode().height - pos.y; - int scale = [[NSScreen mainScreen] backingScaleFactor]; - return Vector2i(pos.x, pos.y) * scale; + int scale = static_cast([[NSScreen mainScreen] backingScaleFactor]); + return Vector2i(static_cast(pos.x), static_cast(pos.y)) * scale; } @@ -174,8 +174,8 @@ Vector2i InputImpl::getMousePosition(const WindowBase& relativeTo) // Use -cursorPositionFromEvent: with nil. NSPoint pos = [view cursorPositionFromEvent:nil]; - int scale = [view displayScaleFactor]; - return Vector2i(pos.x, pos.y) * scale; + int scale = static_cast([view displayScaleFactor]); + return Vector2i(static_cast(pos.x), static_cast(pos.y)) * scale; } @@ -184,7 +184,7 @@ void InputImpl::setMousePosition(const Vector2i& position) { AutoreleasePool pool; // Here we don't need to reverse the coordinates. - int scale = [[NSScreen mainScreen] backingScaleFactor]; + int scale = static_cast([[NSScreen mainScreen] backingScaleFactor]); CGPoint pos = CGPointMake(position.x / scale, position.y / scale); // Place the cursor. @@ -209,10 +209,10 @@ void InputImpl::setMousePosition(const Vector2i& position, const WindowBase& rel return; // Let SFOpenGLView compute the position in global coordinate - int scale = [view displayScaleFactor]; + int scale = static_cast([view displayScaleFactor]); NSPoint p = NSMakePoint(position.x / scale, position.y / scale); p = [view computeGlobalPositionOfRelativePoint:p]; - setMousePosition(sf::Vector2i(p.x, p.y) * scale); + setMousePosition(sf::Vector2i(static_cast(p.x), static_cast(p.y)) * scale); } diff --git a/src/SFML/Window/OSX/JoystickImpl.cpp b/src/SFML/Window/OSX/JoystickImpl.cpp index f2a159a2..d5ab2c19 100644 --- a/src/SFML/Window/OSX/JoystickImpl.cpp +++ b/src/SFML/Window/OSX/JoystickImpl.cpp @@ -44,7 +44,7 @@ namespace std::string stringFromCFString(CFStringRef cfString) { CFIndex length = CFStringGetLength(cfString); - std::vector str(length); + std::vector str(static_cast(length)); CFIndex maxSize = CFStringGetMaximumSizeForEncoding(length, kCFStringEncodingUTF8); CFStringGetCString(cfString, &str[0], maxSize, kCFStringEncodingUTF8); return &str[0]; @@ -72,8 +72,8 @@ namespace if (typeRef && (CFGetTypeID(typeRef) == CFNumberGetTypeID())) { SInt32 value; - CFNumberGetValue((CFNumberRef)typeRef, kCFNumberSInt32Type, &value); - return value; + CFNumberGetValue(static_cast(typeRef), kCFNumberSInt32Type, &value); + return static_cast(value); } sf::err() << "Unable to read uint value for property '" << stringFromCFString(prop) << "' for joystick at index " << index << std::endl; @@ -143,15 +143,15 @@ bool JoystickImpl::isConnected(unsigned int index) CFIndex size = CFSetGetCount(devices); if (size > 0) { - CFTypeRef array[size]; // array of IOHIDDeviceRef - CFSetGetValues(devices, array); + std::vector array(static_cast(size)); // array of IOHIDDeviceRef + CFSetGetValues(devices, array.data()); // If there exists a device d s.t. there is no j s.t. // m_locationIDs[j] == d's location then we have a new device. for (CFIndex didx(0); !state && didx < size; ++didx) { - IOHIDDeviceRef d = (IOHIDDeviceRef)array[didx]; + IOHIDDeviceRef d = static_cast(const_cast(array[static_cast(didx)])); Location dloc = HIDInputManager::getLocationID(d); bool foundJ = false; @@ -194,14 +194,14 @@ bool JoystickImpl::open(unsigned int index) // Get a usable copy of the joysticks devices. CFIndex joysticksCount = CFSetGetCount(devices); - CFTypeRef devicesArray[joysticksCount]; - CFSetGetValues(devices, devicesArray); + std::vector devicesArray(static_cast(joysticksCount)); + CFSetGetValues(devices, devicesArray.data()); // Get the desired joystick. IOHIDDeviceRef self = 0; for (CFIndex i(0); self == 0 && i < joysticksCount; ++i) { - IOHIDDeviceRef d = (IOHIDDeviceRef)devicesArray[i]; + IOHIDDeviceRef d = static_cast(const_cast(devicesArray[static_cast(i)])); if (deviceLoc == HIDInputManager::getLocationID(d)) self = d; } @@ -229,7 +229,7 @@ bool JoystickImpl::open(unsigned int index) CFIndex elementsCount = CFArrayGetCount(elements); for (int i = 0; i < elementsCount; ++i) { - IOHIDElementRef element = (IOHIDElementRef) CFArrayGetValueAtIndex(elements, i); + IOHIDElementRef element = static_cast(const_cast(CFArrayGetValueAtIndex(elements, i))); switch (IOHIDElementGetUsagePage(element)) { case kHIDPage_GenericDesktop: @@ -353,7 +353,7 @@ JoystickCaps JoystickImpl::getCapabilities() const JoystickCaps caps; // Buttons: - caps.buttonCount = m_buttons.size(); + caps.buttonCount = static_cast(m_buttons.size()); // Axis: for (AxisMap::const_iterator it(m_axis.begin()); it != m_axis.end(); ++it) @@ -395,14 +395,14 @@ JoystickState JoystickImpl::update() // Get a usable copy of the joysticks devices. CFIndex joysticksCount = CFSetGetCount(devices); - CFTypeRef devicesArray[joysticksCount]; - CFSetGetValues(devices, devicesArray); + std::vector devicesArray(static_cast(joysticksCount)); + CFSetGetValues(devices, devicesArray.data()); // Search for it bool found = false; for (CFIndex i(0); !found && i < joysticksCount; ++i) { - IOHIDDeviceRef d = (IOHIDDeviceRef)devicesArray[i]; + IOHIDDeviceRef d = static_cast(const_cast(devicesArray[static_cast(i)])); if (selfLoc == HIDInputManager::getLocationID(d)) found = true; } @@ -453,12 +453,12 @@ JoystickState JoystickImpl::update() // This method might not be very accurate (the "0 position" can be // slightly shift with some device) but we don't care because most // of devices are so sensitive that this is not relevant. - double physicalMax = IOHIDElementGetPhysicalMax(it->second); - double physicalMin = IOHIDElementGetPhysicalMin(it->second); + double physicalMax = static_cast(IOHIDElementGetPhysicalMax(it->second)); + double physicalMin = static_cast(IOHIDElementGetPhysicalMin(it->second)); double scaledMin = -100; double scaledMax = 100; double physicalValue = IOHIDValueGetScaledValue(value, kIOHIDValueScaleTypePhysical); - float scaledValue = (((physicalValue - physicalMin) * (scaledMax - scaledMin)) / (physicalMax - physicalMin)) + scaledMin; + float scaledValue = static_cast((((physicalValue - physicalMin) * (scaledMax - scaledMin)) / (physicalMax - physicalMin)) + scaledMin); state.axes[it->first] = scaledValue; } diff --git a/src/SFML/Window/OSX/NSImage+raw.mm b/src/SFML/Window/OSX/NSImage+raw.mm index 4656bc87..987368da 100644 --- a/src/SFML/Window/OSX/NSImage+raw.mm +++ b/src/SFML/Window/OSX/NSImage+raw.mm @@ -35,8 +35,8 @@ // Create an empty image representation. NSBitmapImageRep* bitmap = [[NSBitmapImageRep alloc] initWithBitmapDataPlanes:0 // if 0: only allocate memory - pixelsWide:size.width - pixelsHigh:size.height + pixelsWide:(static_cast(size.width)) + pixelsHigh:(static_cast(size.height)) bitsPerSample:8 // The number of bits used to specify // one pixel in a single component of the data. samplesPerPixel:4 // 3 if no alpha, 4 with it diff --git a/src/SFML/Window/OSX/SFApplication.m b/src/SFML/Window/OSX/SFApplication.m index 8365c3a2..98678622 100644 --- a/src/SFML/Window/OSX/SFApplication.m +++ b/src/SFML/Window/OSX/SFApplication.m @@ -28,6 +28,14 @@ //////////////////////////////////////////////////////////// #import +#if defined(__APPLE__) + #if defined(__clang__) + #pragma clang diagnostic ignored "-Wdeprecated-declarations" + #elif defined(__GNUC__) + #pragma GCC diagnostic ignored "-Wdeprecated-declarations" + #endif +#endif + //////////////////////////////////////////////////////////// @implementation SFApplication diff --git a/src/SFML/Window/OSX/SFApplicationDelegate.m b/src/SFML/Window/OSX/SFApplicationDelegate.m index 86d74fdc..9e57b7a0 100644 --- a/src/SFML/Window/OSX/SFApplicationDelegate.m +++ b/src/SFML/Window/OSX/SFApplicationDelegate.m @@ -28,6 +28,14 @@ //////////////////////////////////////////////////////////// #import +#if defined(__APPLE__) + #if defined(__clang__) + #pragma clang diagnostic ignored "-Wdeprecated-declarations" + #elif defined(__GNUC__) + #pragma GCC diagnostic ignored "-Wdeprecated-declarations" + #endif +#endif + //////////////////////////////////////////////////////////// @implementation SFApplicationDelegate diff --git a/src/SFML/Window/OSX/SFContext.mm b/src/SFML/Window/OSX/SFContext.mm index 358172af..121b8fd3 100644 --- a/src/SFML/Window/OSX/SFContext.mm +++ b/src/SFML/Window/OSX/SFContext.mm @@ -33,6 +33,14 @@ #include #include +#if defined(__APPLE__) + #if defined(__clang__) + #pragma clang diagnostic ignored "-Wdeprecated-declarations" + #elif defined(__GNUC__) + #pragma GCC diagnostic ignored "-Wdeprecated-declarations" + #endif +#endif + namespace sf { namespace priv @@ -184,14 +192,14 @@ void SFContext::createContext(SFContext* shared, if (bitsPerPixel > 24) { attrs.push_back(NSOpenGLPFAAlphaSize); - attrs.push_back((NSOpenGLPixelFormatAttribute)8); + attrs.push_back(static_cast(8)); } attrs.push_back(NSOpenGLPFADepthSize); - attrs.push_back((NSOpenGLPixelFormatAttribute)m_settings.depthBits); + attrs.push_back(static_cast(m_settings.depthBits)); attrs.push_back(NSOpenGLPFAStencilSize); - attrs.push_back((NSOpenGLPixelFormatAttribute)m_settings.stencilBits); + attrs.push_back(static_cast(m_settings.stencilBits)); if (m_settings.antialiasingLevel > 0) { @@ -211,11 +219,11 @@ void SFContext::createContext(SFContext* shared, // Only one buffer is currently available attrs.push_back(NSOpenGLPFASampleBuffers); - attrs.push_back((NSOpenGLPixelFormatAttribute)1); + attrs.push_back(static_cast(1)); // Antialiasing level attrs.push_back(NSOpenGLPFASamples); - attrs.push_back((NSOpenGLPixelFormatAttribute)m_settings.antialiasingLevel); + attrs.push_back(static_cast(m_settings.antialiasingLevel)); // No software renderer - only hardware renderer attrs.push_back(NSOpenGLPFAAccelerated); @@ -232,7 +240,7 @@ void SFContext::createContext(SFContext* shared, if (legacy) { - m_settings.attributeFlags &= ~ContextSettings::Core; + m_settings.attributeFlags &= ~static_cast(ContextSettings::Core); m_settings.majorVersion = 2; m_settings.minorVersion = 1; attrs.push_back(NSOpenGLPFAOpenGLProfile); @@ -254,10 +262,10 @@ void SFContext::createContext(SFContext* shared, if (m_settings.attributeFlags & ContextSettings::Debug) { sf::err() << "Warning. OpenGL debugging not supported on this platform." << std::endl; - m_settings.attributeFlags &= ~ContextSettings::Debug; + m_settings.attributeFlags &= ~static_cast(ContextSettings::Debug); } - attrs.push_back((NSOpenGLPixelFormatAttribute)0); // end of array + attrs.push_back(static_cast(0)); // end of array // All OS X pixel formats are sRGB capable m_settings.sRgbCapable = true; diff --git a/src/SFML/Window/OSX/SFKeyboardModifiersHelper.mm b/src/SFML/Window/OSX/SFKeyboardModifiersHelper.mm index 5c73daeb..17b37c4c 100644 --- a/src/SFML/Window/OSX/SFKeyboardModifiersHelper.mm +++ b/src/SFML/Window/OSX/SFKeyboardModifiersHelper.mm @@ -30,6 +30,14 @@ #import +#if defined(__APPLE__) + #if defined(__clang__) + #pragma clang diagnostic ignored "-Wdeprecated-declarations" + #elif defined(__GNUC__) + #pragma GCC diagnostic ignored "-Wdeprecated-declarations" + #endif +#endif + //////////////////////////////////////////////////////////// /// Here are define the mask value for the 'modifiers' diff --git a/src/SFML/Window/OSX/SFOpenGLView+keyboard.mm b/src/SFML/Window/OSX/SFOpenGLView+keyboard.mm index 193d12c7..787dc162 100644 --- a/src/SFML/Window/OSX/SFOpenGLView+keyboard.mm +++ b/src/SFML/Window/OSX/SFOpenGLView+keyboard.mm @@ -33,6 +33,14 @@ #import #import +#if defined(__APPLE__) + #if defined(__clang__) + #pragma clang diagnostic ignored "-Wdeprecated-declarations" + #elif defined(__GNUC__) + #pragma GCC diagnostic ignored "-Wdeprecated-declarations" + #endif +#endif + //////////////////////////////////////////////////////////// /// In this file, we implement keyboard handling for SFOpenGLView /// diff --git a/src/SFML/Window/OSX/SFOpenGLView+mouse.mm b/src/SFML/Window/OSX/SFOpenGLView+mouse.mm index e505dfd6..35344ecd 100644 --- a/src/SFML/Window/OSX/SFOpenGLView+mouse.mm +++ b/src/SFML/Window/OSX/SFOpenGLView+mouse.mm @@ -32,6 +32,14 @@ #import #import +#if defined(__APPLE__) + #if defined(__clang__) + #pragma clang diagnostic ignored "-Wdeprecated-declarations" + #elif defined(__GNUC__) + #pragma GCC diagnostic ignored "-Wdeprecated-declarations" + #endif +#endif + //////////////////////////////////////////////////////////// /// In this file, we implement mouse handling for SFOpenGLView @@ -136,7 +144,7 @@ NSPoint loc = [self cursorPositionFromEvent:theEvent]; if (button != sf::Mouse::ButtonCount) - m_requester->mouseDownAt(button, loc.x, loc.y); + m_requester->mouseDownAt(button, static_cast(loc.x), static_cast(loc.y)); } } @@ -181,7 +189,7 @@ NSPoint loc = [self cursorPositionFromEvent:theEvent]; if (button != sf::Mouse::ButtonCount) - m_requester->mouseUpAt(button, loc.x, loc.y); + m_requester->mouseUpAt(button, static_cast(loc.x), static_cast(loc.y)); } } @@ -242,7 +250,7 @@ // when the mouse is dragged. That would be too easy!) [self updateMouseState]; if ((m_requester != 0) && m_mouseIsIn) - m_requester->mouseMovedAt(loc.x, loc.y); + m_requester->mouseMovedAt(static_cast(loc.x), static_cast(loc.y)); } @@ -290,7 +298,7 @@ { NSScreen* screen = [[self window] screen]; NSNumber* displayId = [[screen deviceDescription] objectForKey:@"NSScreenNumber"]; - return [displayId intValue]; + return static_cast([displayId intValue]); } @@ -300,7 +308,7 @@ if (m_requester != 0) { NSPoint loc = [self cursorPositionFromEvent:theEvent]; - m_requester->mouseWheelScrolledAt([theEvent deltaX], [theEvent deltaY], loc.x, loc.y); + m_requester->mouseWheelScrolledAt(static_cast([theEvent deltaX]), static_cast([theEvent deltaY]), static_cast(loc.x), static_cast(loc.y)); } // Transmit to non-SFML responder @@ -396,7 +404,7 @@ NSPoint loc = [self convertPoint:rawPos fromView:nil]; // Don't forget to change to SFML coord system. - float h = [self frame].size.height; + const double h = [self frame].size.height; loc.y = h - loc.y; return loc; diff --git a/src/SFML/Window/OSX/SFOpenGLView.h b/src/SFML/Window/OSX/SFOpenGLView.h index 38145f5a..632fd8e0 100644 --- a/src/SFML/Window/OSX/SFOpenGLView.h +++ b/src/SFML/Window/OSX/SFOpenGLView.h @@ -28,6 +28,16 @@ //////////////////////////////////////////////////////////// #import +#if defined(__APPLE__) + #if defined(__clang__) + #pragma clang diagnostic push + #pragma clang diagnostic ignored "-Wdeprecated-declarations" + #elif defined(__GNUC__) + #pragma GCC diagnostic push + #pragma GCC diagnostic ignored "-Wdeprecated-declarations" + #endif +#endif + namespace sf { namespace priv { class WindowImplCocoa; @@ -199,3 +209,11 @@ namespace sf { -(void)updateCursorGrabbed; @end + +#if defined(__APPLE__) + #if defined(__clang__) + #pragma clang diagnostic pop + #elif defined(__GNUC__) + #pragma GCC diagnostic pop + #endif +#endif diff --git a/src/SFML/Window/OSX/SFOpenGLView.mm b/src/SFML/Window/OSX/SFOpenGLView.mm index e0245a8e..ec7c9b7e 100644 --- a/src/SFML/Window/OSX/SFOpenGLView.mm +++ b/src/SFML/Window/OSX/SFOpenGLView.mm @@ -33,6 +33,14 @@ #import #import +#if defined(__APPLE__) + #if defined(__clang__) + #pragma clang diagnostic ignored "-Wdeprecated-declarations" + #elif defined(__GNUC__) + #pragma GCC diagnostic ignored "-Wdeprecated-declarations" + #endif +#endif + //////////////////////////////////////////////////////////// /// SFOpenGLView class: Privates Methods Declaration @@ -214,7 +222,7 @@ point = [self convertPointToScreen:point]; // Flip screen coordinates to match CGDisplayMoveCursorToPoint referential. - const float screenHeight = [[[self window] screen] frame].size.height; + const double screenHeight = [[[self window] screen] frame].size.height; point.y = screenHeight - point.y; return point; @@ -239,7 +247,7 @@ // Send a resize event if the scaling factor changed if ((m_scaleFactor != oldScaleFactor) && (m_requester != 0)) { NSSize newSize = [self frame].size; - m_requester->windowResized(newSize.width, newSize.height); + m_requester->windowResized(static_cast(newSize.width), static_cast(newSize.height)); } } @@ -271,7 +279,7 @@ // The new size NSSize newSize = [self frame].size; - m_requester->windowResized(newSize.width, newSize.height); + m_requester->windowResized(static_cast(newSize.width), static_cast(newSize.height)); } //////////////////////////////////////////////////////// diff --git a/src/SFML/Window/OSX/SFViewController.mm b/src/SFML/Window/OSX/SFViewController.mm index e3fe8ce9..f24eba31 100644 --- a/src/SFML/Window/OSX/SFViewController.mm +++ b/src/SFML/Window/OSX/SFViewController.mm @@ -33,6 +33,14 @@ #import #import +#if defined(__APPLE__) + #if defined(__clang__) + #pragma clang diagnostic ignored "-Wdeprecated-declarations" + #elif defined(__GNUC__) + #pragma GCC diagnostic ignored "-Wdeprecated-declarations" + #endif +#endif + @implementation SFViewController diff --git a/src/SFML/Window/OSX/SFWindowController.mm b/src/SFML/Window/OSX/SFWindowController.mm index ea05f15e..55d7cf33 100644 --- a/src/SFML/Window/OSX/SFWindowController.mm +++ b/src/SFML/Window/OSX/SFWindowController.mm @@ -42,6 +42,14 @@ #import #import +#if defined(__APPLE__) + #if defined(__clang__) + #pragma clang diagnostic ignored "-Wdeprecated-declarations" + #elif defined(__GNUC__) + #pragma GCC diagnostic ignored "-Wdeprecated-declarations" + #endif +#endif + //////////////////////////////////////////////////////////// /// SFBlackView is a simple view filled with black, nothing more /// @@ -153,7 +161,7 @@ m_window = nil; m_oglView = nil; m_requester = 0; - m_fullscreen = (style & sf::Style::Fullscreen); + m_fullscreen = ((style & sf::Style::Fullscreen) != 0) ? YES : NO; m_restoreResize = NO; m_highDpi = NO; @@ -359,7 +367,7 @@ -(void)setCursorGrabbed:(BOOL)grabbed { // Remove or restore resizeable style if needed - BOOL resizeable = [m_window styleMask] & NSResizableWindowMask; + BOOL resizeable = (([m_window styleMask] & NSResizableWindowMask) != 0) ? YES : NO; if (grabbed && resizeable) { m_restoreResize = YES; @@ -403,7 +411,7 @@ CGFloat y = screen.origin.y + [m_oglView frame].size.height; // Flip y-axis (titlebar was already taken into account above) - y = [self screenHeight] - y; + y = static_cast([self screenHeight]) - y; return NSMakePoint(x, y); } @@ -415,7 +423,7 @@ NSPoint point = NSMakePoint(x, y); // Flip for SFML window coordinate system and take titlebar into account - point.y = [self screenHeight] - point.y + [self titlebarHeight]; + point.y = static_cast([self screenHeight]) - point.y + static_cast([self titlebarHeight]); // Place the window. [m_window setFrameTopLeftPoint:point]; @@ -461,7 +469,7 @@ [m_window setStyleMask:styleMask ^ NSResizableWindowMask]; // Add titlebar height. - height += [self titlebarHeight]; + height += static_cast([self titlebarHeight]); // Corner case: don't set the window height bigger than the screen height // or the view will be resized _later_ without generating a resize event. @@ -469,11 +477,11 @@ CGFloat maxVisibleHeight = screenFrame.size.height; if (height > maxVisibleHeight) { - height = maxVisibleHeight; + height = static_cast(maxVisibleHeight); // The size is not the requested one, we fire an event if (m_requester != 0) - m_requester->windowResized(width, height - [self titlebarHeight]); + m_requester->windowResized(width, height - static_cast([self titlebarHeight])); } NSRect frame = NSMakeRect([m_window frame].origin.x, @@ -621,16 +629,16 @@ { NSDictionary* deviceDescription = [[m_window screen] deviceDescription]; NSNumber* screenNumber = [deviceDescription valueForKey:@"NSScreenNumber"]; - CGDirectDisplayID screenID = (CGDirectDisplayID)[screenNumber intValue]; + CGDirectDisplayID screenID = static_cast([screenNumber intValue]); CGFloat height = CGDisplayPixelsHigh(screenID); - return height; + return static_cast(height); } //////////////////////////////////////////////////////// -(float)titlebarHeight { - return NSHeight([m_window frame]) - NSHeight([[m_window contentView] frame]); + return static_cast(NSHeight([m_window frame]) - NSHeight([[m_window contentView] frame])); } @end diff --git a/src/SFML/Window/OSX/Scaling.h b/src/SFML/Window/OSX/Scaling.h index 975a3f03..cb54a1a7 100644 --- a/src/SFML/Window/OSX/Scaling.h +++ b/src/SFML/Window/OSX/Scaling.h @@ -54,7 +54,7 @@ inline CGFloat getDefaultScaleFactor() template void scaleIn(T& in, id delegate) { - in /= delegate ? [delegate displayScaleFactor] : getDefaultScaleFactor(); + in /= static_cast(delegate ? [delegate displayScaleFactor] : getDefaultScaleFactor()); } template @@ -81,7 +81,7 @@ void scaleInXY(T& in, id delegate) template void scaleOut(T& out, id delegate) { - out *= delegate ? [delegate displayScaleFactor] : getDefaultScaleFactor(); + out = out * static_cast(delegate ? [delegate displayScaleFactor] : getDefaultScaleFactor()); } template diff --git a/src/SFML/Window/OSX/VideoModeImpl.cpp b/src/SFML/Window/OSX/VideoModeImpl.cpp index 7df01a5a..5657558d 100644 --- a/src/SFML/Window/OSX/VideoModeImpl.cpp +++ b/src/SFML/Window/OSX/VideoModeImpl.cpp @@ -56,7 +56,7 @@ std::vector VideoModeImpl::getFullscreenModes() const CFIndex modesCount = CFArrayGetCount(cgmodes); for (CFIndex i = 0; i < modesCount; i++) { - CGDisplayModeRef cgmode = (CGDisplayModeRef)CFArrayGetValueAtIndex(cgmodes, i); + CGDisplayModeRef cgmode = static_cast(const_cast(CFArrayGetValueAtIndex(cgmodes, i))); VideoMode mode = convertCGModeToSFMode(cgmode); diff --git a/src/SFML/Window/OSX/WindowImplCocoa.hpp b/src/SFML/Window/OSX/WindowImplCocoa.hpp index 005eb76c..0dd03ebf 100644 --- a/src/SFML/Window/OSX/WindowImplCocoa.hpp +++ b/src/SFML/Window/OSX/WindowImplCocoa.hpp @@ -33,6 +33,16 @@ #include #include +#if defined(__APPLE__) + #if defined(__clang__) + #pragma clang diagnostic push + #pragma clang diagnostic ignored "-Wdeprecated-declarations" + #elif defined(__GNUC__) + #pragma GCC diagnostic push + #pragma GCC diagnostic ignored "-Wdeprecated-declarations" + #endif +#endif + //////////////////////////////////////////////////////////// /// Predefine OBJ-C classes //////////////////////////////////////////////////////////// @@ -373,5 +383,12 @@ private: } // namespace sf +#if defined(__APPLE__) + #if defined(__clang__) + #pragma clang diagnostic pop + #elif defined(__GNUC__) + #pragma GCC diagnostic pop + #endif +#endif #endif // SFML_WINDOWIMPLCOCOA_HPP diff --git a/src/SFML/Window/OSX/WindowImplCocoa.mm b/src/SFML/Window/OSX/WindowImplCocoa.mm index ce524ae6..73b79c19 100644 --- a/src/SFML/Window/OSX/WindowImplCocoa.mm +++ b/src/SFML/Window/OSX/WindowImplCocoa.mm @@ -88,7 +88,7 @@ m_showCursor(true) { AutoreleasePool pool; // Treat the handle as it real type - id nsHandle = (id)handle; + id nsHandle = static_cast(handle); if ([nsHandle isKindOfClass:[NSWindow class]]) { // We have a window. @@ -304,7 +304,7 @@ void WindowImplCocoa::mouseWheelScrolledAt(float deltaX, float deltaY, int x, in Event event; event.type = Event::MouseWheelMoved; - event.mouseWheel.delta = deltaY; + event.mouseWheel.delta = static_cast(deltaY); event.mouseWheel.x = x; event.mouseWheel.y = y; scaleOutXY(event.mouseWheel, m_delegate); @@ -415,7 +415,7 @@ Vector2i WindowImplCocoa::getPosition() const { AutoreleasePool pool; NSPoint pos = [m_delegate position]; - sf::Vector2i ret(pos.x, pos.y); + sf::Vector2i ret(static_cast(pos.x), static_cast(pos.y)); scaleOutXY(ret, m_delegate); return ret; } @@ -436,7 +436,7 @@ Vector2u WindowImplCocoa::getSize() const { AutoreleasePool pool; NSSize size = [m_delegate size]; - Vector2u ret(size.width, size.height); + Vector2u ret(static_cast(size.width), static_cast(size.height)); scaleOutXY(ret, m_delegate); return ret; } diff --git a/src/SFML/Window/OSX/WindowImplDelegateProtocol.h b/src/SFML/Window/OSX/WindowImplDelegateProtocol.h index dd767f5e..ba319484 100644 --- a/src/SFML/Window/OSX/WindowImplDelegateProtocol.h +++ b/src/SFML/Window/OSX/WindowImplDelegateProtocol.h @@ -31,6 +31,16 @@ #import +#if defined(__APPLE__) + #if defined(__clang__) + #pragma clang diagnostic push + #pragma clang diagnostic ignored "-Wdeprecated-declarations" + #elif defined(__GNUC__) + #pragma GCC diagnostic push + #pragma GCC diagnostic ignored "-Wdeprecated-declarations" + #endif +#endif + namespace sf { namespace priv { class WindowImplCocoa; @@ -232,3 +242,11 @@ namespace sf { -(void)applyContext:(NSOpenGLContext*)context; @end + +#if defined(__APPLE__) + #if defined(__clang__) + #pragma clang diagnostic pop + #elif defined(__GNUC__) + #pragma GCC diagnostic pop + #endif +#endif diff --git a/src/SFML/Window/OSX/cg_sf_conversion.mm b/src/SFML/Window/OSX/cg_sf_conversion.mm index 9f2aee0a..54b4bf11 100644 --- a/src/SFML/Window/OSX/cg_sf_conversion.mm +++ b/src/SFML/Window/OSX/cg_sf_conversion.mm @@ -31,6 +31,14 @@ #import +#if defined(__APPLE__) + #if defined(__clang__) + #pragma clang diagnostic ignored "-Wdeprecated-declarations" + #elif defined(__GNUC__) + #pragma GCC diagnostic ignored "-Wdeprecated-declarations" + #endif +#endif + namespace sf { namespace priv @@ -87,7 +95,7 @@ VideoMode convertCGModeToSFMode(CGDisplayModeRef cgmode) // // [1]: "APIs for Supporting High Resolution" > "Additions and Changes for OS X v10.8" // https://developer.apple.com/library/mac/documentation/GraphicsAnimation/Conceptual/HighResolutionOSX/APIs/APIs.html#//apple_ref/doc/uid/TP40012302-CH5-SW27 - VideoMode mode(CGDisplayModeGetWidth(cgmode), CGDisplayModeGetHeight(cgmode), modeBitsPerPixel(cgmode)); + VideoMode mode(static_cast(CGDisplayModeGetWidth(cgmode)), static_cast(CGDisplayModeGetHeight(cgmode)), static_cast(modeBitsPerPixel(cgmode))); scaleOutWidthHeight(mode, nil); return mode; } diff --git a/src/SFML/Window/OSX/cpp_objc_conversion.mm b/src/SFML/Window/OSX/cpp_objc_conversion.mm index 39de033e..e3d58a85 100644 --- a/src/SFML/Window/OSX/cpp_objc_conversion.mm +++ b/src/SFML/Window/OSX/cpp_objc_conversion.mm @@ -44,7 +44,7 @@ NSString* stringToNSString(const std::string& string) //////////////////////////////////////////////////////////// NSString* sfStringToNSString(const sf::String& string) { - sf::Uint32 length = string.getSize() * sizeof(sf::Uint32); + sf::Uint32 length = static_cast(string.getSize() * sizeof(sf::Uint32)); const void* data = reinterpret_cast(string.getData()); NSStringEncoding encoding; diff --git a/src/SFML/Window/iOS/CursorImpl.cpp b/src/SFML/Window/iOS/CursorImpl.cpp index 35249dd1..a8c06883 100644 --- a/src/SFML/Window/iOS/CursorImpl.cpp +++ b/src/SFML/Window/iOS/CursorImpl.cpp @@ -47,7 +47,7 @@ CursorImpl::~CursorImpl() //////////////////////////////////////////////////////////// -bool CursorImpl::loadFromPixels(const Uint8* pixels, Vector2u size, Vector2u hotspot) +bool CursorImpl::loadFromPixels(const Uint8* /* pixels */, Vector2u /* size */, Vector2u /* hotspot */) { // Not supported return false; @@ -55,7 +55,7 @@ bool CursorImpl::loadFromPixels(const Uint8* pixels, Vector2u size, Vector2u hot //////////////////////////////////////////////////////////// -bool CursorImpl::loadFromSystem(Cursor::Type type) +bool CursorImpl::loadFromSystem(Cursor::Type /* type */) { // Not supported return false; diff --git a/src/SFML/Window/iOS/EaglContext.mm b/src/SFML/Window/iOS/EaglContext.mm index 93fef51c..eec33e72 100644 --- a/src/SFML/Window/iOS/EaglContext.mm +++ b/src/SFML/Window/iOS/EaglContext.mm @@ -35,6 +35,14 @@ #include #include +#if defined(__APPLE__) + #if defined(__clang__) + #pragma clang diagnostic ignored "-Wdeprecated-declarations" + #elif defined(__GNUC__) + #pragma GCC diagnostic ignored "-Wdeprecated-declarations" + #endif +#endif + namespace { @@ -114,8 +122,8 @@ m_clock () //////////////////////////////////////////////////////////// -EaglContext::EaglContext(EaglContext* shared, const ContextSettings& settings, - unsigned int width, unsigned int height) : +EaglContext::EaglContext(EaglContext* /* shared */, const ContextSettings& /* settings */, + unsigned int /* width */, unsigned int /* height */) : m_context (nil), m_framebuffer (0), m_colorbuffer (0), @@ -171,7 +179,7 @@ GlFunctionPointer EaglContext::getFunction(const char* name) "/System/Library/Frameworks/OpenGLES.framework/OpenGLES", "OpenGLES.framework/OpenGLES" }; - + for (int i = 0; i < libCount; ++i) { if (!module) @@ -179,7 +187,8 @@ GlFunctionPointer EaglContext::getFunction(const char* name) } if (module) - return reinterpret_cast(dlsym(module, name)); + return reinterpret_cast( + reinterpret_cast(dlsym(module, name))); return 0; } @@ -205,7 +214,7 @@ void EaglContext::recreateRenderBuffers(SFView* glView) glGenRenderbuffersOESFunc(1, &m_colorbuffer); glBindRenderbufferOESFunc(GL_RENDERBUFFER_OES, m_colorbuffer); if (glView) - [m_context renderbufferStorage:GL_RENDERBUFFER_OES fromDrawable:(CAEAGLLayer*)glView.layer]; + [m_context renderbufferStorage:GL_RENDERBUFFER_OES fromDrawable:(static_cast(glView.layer))]; glFramebufferRenderbufferOESFunc(GL_FRAMEBUFFER_OES, GL_COLOR_ATTACHMENT0_OES, GL_RENDERBUFFER_OES, m_colorbuffer); // Create a depth buffer if requested @@ -278,7 +287,7 @@ void EaglContext::setVerticalSyncEnabled(bool enabled) //////////////////////////////////////////////////////////// void EaglContext::createContext(EaglContext* shared, const WindowImplUIKit* window, - unsigned int bitsPerPixel, + unsigned int /* bitsPerPixel */, const ContextSettings& settings) { // Save the settings diff --git a/src/SFML/Window/iOS/InputImpl.mm b/src/SFML/Window/iOS/InputImpl.mm index 795435ad..b445f39e 100644 --- a/src/SFML/Window/iOS/InputImpl.mm +++ b/src/SFML/Window/iOS/InputImpl.mm @@ -37,7 +37,7 @@ namespace sf namespace priv { //////////////////////////////////////////////////////////// -bool InputImpl::isKeyPressed(Keyboard::Key key) +bool InputImpl::isKeyPressed(Keyboard::Key /* key */) { // Not applicable return false; @@ -52,7 +52,7 @@ void InputImpl::setVirtualKeyboardVisible(bool visible) //////////////////////////////////////////////////////////// -bool InputImpl::isMouseButtonPressed(Mouse::Button button) +bool InputImpl::isMouseButtonPressed(Mouse::Button /* button */) { // Not applicable return false; @@ -67,23 +67,21 @@ Vector2i InputImpl::getMousePosition() //////////////////////////////////////////////////////////// -Vector2i InputImpl::getMousePosition(const WindowBase& relativeTo) +Vector2i InputImpl::getMousePosition(const WindowBase& /* relativeTo */) { - (void)relativeTo; - return getMousePosition(); } //////////////////////////////////////////////////////////// -void InputImpl::setMousePosition(const Vector2i& position) +void InputImpl::setMousePosition(const Vector2i& /* position */) { // Not applicable } //////////////////////////////////////////////////////////// -void InputImpl::setMousePosition(const Vector2i& position, const WindowBase& relativeTo) +void InputImpl::setMousePosition(const Vector2i& /* position */, const WindowBase& /* relativeTo */) { // Not applicable } @@ -104,10 +102,8 @@ Vector2i InputImpl::getTouchPosition(unsigned int finger) //////////////////////////////////////////////////////////// -Vector2i InputImpl::getTouchPosition(unsigned int finger, const WindowBase& relativeTo) +Vector2i InputImpl::getTouchPosition(unsigned int finger, const WindowBase& /* relativeTo */) { - (void)relativeTo; - return getTouchPosition(finger); } diff --git a/src/SFML/Window/iOS/JoystickImpl.mm b/src/SFML/Window/iOS/JoystickImpl.mm index 7be01bba..239eaf5d 100644 --- a/src/SFML/Window/iOS/JoystickImpl.mm +++ b/src/SFML/Window/iOS/JoystickImpl.mm @@ -47,7 +47,7 @@ void JoystickImpl::cleanup() //////////////////////////////////////////////////////////// -bool JoystickImpl::isConnected(unsigned int index) +bool JoystickImpl::isConnected(unsigned int /* index */) { // Not implemented return false; @@ -55,7 +55,7 @@ bool JoystickImpl::isConnected(unsigned int index) //////////////////////////////////////////////////////////// -bool JoystickImpl::open(unsigned int index) +bool JoystickImpl::open(unsigned int /* index */) { // Not implemented return false; diff --git a/src/SFML/Window/iOS/SFAppDelegate.mm b/src/SFML/Window/iOS/SFAppDelegate.mm index 309f42a8..6b954cfc 100644 --- a/src/SFML/Window/iOS/SFAppDelegate.mm +++ b/src/SFML/Window/iOS/SFAppDelegate.mm @@ -171,7 +171,26 @@ namespace if (!self.sfWindow) return false; +#if defined(__APPLE__) + #if defined(__clang__) + #pragma clang diagnostic push + #pragma clang diagnostic ignored "-Wold-style-cast" + #elif defined(__GNUC__) + #pragma GCC diagnostic push + #pragma GCC diagnostic ignored "-Wold-style-cast" + #endif +#endif + UIViewController* rootViewController = [((__bridge UIWindow*)(self.sfWindow->getSystemHandle())) rootViewController]; + +#if defined(__APPLE__) + #if defined(__clang__) + #pragma clang diagnostic pop + #elif defined(__GNUC__) + #pragma GCC diagnostic pop + #endif +#endif + if (!rootViewController || ![rootViewController shouldAutorotate]) return false; @@ -189,7 +208,7 @@ namespace if ([supportedOrientations containsObject:@"UIInterfaceOrientationLandscapeRight"]) appFlags += UIInterfaceOrientationMaskLandscapeRight; - return (1 << orientation) & [rootViewController supportedInterfaceOrientations] & appFlags; + return (1 << orientation) & [rootViewController supportedInterfaceOrientations] & static_cast(appFlags); } - (bool)needsToFlipFrameForOrientation:(UIDeviceOrientation)orientation @@ -244,11 +263,11 @@ namespace //////////////////////////////////////////////////////////// -- (void)notifyTouchBegin:(unsigned int)index atPosition:(sf::Vector2i)position; +- (void)notifyTouchBegin:(unsigned int)index atPosition:(sf::Vector2i)position { - position.x *= backingScaleFactor; - position.y *= backingScaleFactor; - + position.x *= static_cast(backingScaleFactor); + position.y *= static_cast(backingScaleFactor); + // save the touch position if (index >= touchPositions.size()) touchPositions.resize(index + 1, sf::Vector2i(-1, -1)); @@ -268,11 +287,11 @@ namespace //////////////////////////////////////////////////////////// -- (void)notifyTouchMove:(unsigned int)index atPosition:(sf::Vector2i)position; +- (void)notifyTouchMove:(unsigned int)index atPosition:(sf::Vector2i)position { - position.x *= backingScaleFactor; - position.y *= backingScaleFactor; - + position.x *= static_cast(backingScaleFactor); + position.y *= static_cast(backingScaleFactor); + // save the touch position if (index >= touchPositions.size()) touchPositions.resize(index + 1, sf::Vector2i(-1, -1)); @@ -292,7 +311,7 @@ namespace //////////////////////////////////////////////////////////// -- (void)notifyTouchEnd:(unsigned int)index atPosition:(sf::Vector2i)position; +- (void)notifyTouchEnd:(unsigned int)index atPosition:(sf::Vector2i)position { // clear the touch position if (index < touchPositions.size()) @@ -304,8 +323,8 @@ namespace sf::Event event; event.type = sf::Event::TouchEnded; event.touch.finger = index; - event.touch.x = position.x * backingScaleFactor; - event.touch.y = position.y * backingScaleFactor; + event.touch.x = position.x * static_cast(backingScaleFactor); + event.touch.y = position.y * static_cast(backingScaleFactor); sfWindow->forwardEvent(event); } } diff --git a/src/SFML/Window/iOS/SFView.mm b/src/SFML/Window/iOS/SFView.mm index 9b38bbf3..e4368215 100644 --- a/src/SFML/Window/iOS/SFView.mm +++ b/src/SFML/Window/iOS/SFView.mm @@ -31,6 +31,14 @@ #include #include +#if defined(__APPLE__) + #if defined(__clang__) + #pragma clang diagnostic ignored "-Wdeprecated-declarations" + #elif defined(__GNUC__) + #pragma GCC diagnostic ignored "-Wdeprecated-declarations" + #endif +#endif + @interface SFView() @property (nonatomic) NSMutableArray* touches; @@ -103,7 +111,7 @@ sf::Vector2i position(static_cast(point.x), static_cast(point.y)); // notify the application delegate - [[SFAppDelegate getInstance] notifyTouchBegin:index atPosition:position]; + [[SFAppDelegate getInstance] notifyTouchBegin:(static_cast(index)) atPosition:position]; } } @@ -122,7 +130,7 @@ sf::Vector2i position(static_cast(point.x), static_cast(point.y)); // notify the application delegate - [[SFAppDelegate getInstance] notifyTouchMove:index atPosition:position]; + [[SFAppDelegate getInstance] notifyTouchMove:(static_cast(index)) atPosition:position]; } } } @@ -142,7 +150,7 @@ sf::Vector2i position(static_cast(point.x), static_cast(point.y)); // notify the application delegate - [[SFAppDelegate getInstance] notifyTouchEnd:index atPosition:position]; + [[SFAppDelegate getInstance] notifyTouchEnd:(static_cast(index)) atPosition:position]; // remove the touch [self.touches replaceObjectAtIndex:index withObject:[NSNull null]]; @@ -187,7 +195,7 @@ self.touches = [NSMutableArray array]; // Configure the EAGL layer - CAEAGLLayer* eaglLayer = (CAEAGLLayer*)self.layer; + CAEAGLLayer* eaglLayer = static_cast(self.layer); eaglLayer.opaque = YES; eaglLayer.drawableProperties = [NSDictionary dictionaryWithObjectsAndKeys: [NSNumber numberWithBool:FALSE], kEAGLDrawablePropertyRetainedBacking, diff --git a/src/SFML/Window/iOS/SensorImpl.mm b/src/SFML/Window/iOS/SensorImpl.mm index 33c7159c..ae0d2bbb 100644 --- a/src/SFML/Window/iOS/SensorImpl.mm +++ b/src/SFML/Window/iOS/SensorImpl.mm @@ -139,37 +139,37 @@ Vector3f SensorImpl::update() { case Sensor::Accelerometer: // Acceleration is given in G, convert to m/s^2 - value.x = manager.accelerometerData.acceleration.x * 9.81f; - value.y = manager.accelerometerData.acceleration.y * 9.81f; - value.z = manager.accelerometerData.acceleration.z * 9.81f; + value.x = static_cast(manager.accelerometerData.acceleration.x * 9.81); + value.y = static_cast(manager.accelerometerData.acceleration.y * 9.81); + value.z = static_cast(manager.accelerometerData.acceleration.z * 9.81); break; case Sensor::Gyroscope: // Rotation rates are given in rad/s, convert to deg/s - value.x = toDegrees(manager.gyroData.rotationRate.x); - value.y = toDegrees(manager.gyroData.rotationRate.y); - value.z = toDegrees(manager.gyroData.rotationRate.z); + value.x = toDegrees(static_cast(manager.gyroData.rotationRate.x)); + value.y = toDegrees(static_cast(manager.gyroData.rotationRate.y)); + value.z = toDegrees(static_cast(manager.gyroData.rotationRate.z)); break; case Sensor::Magnetometer: // Magnetic field is given in microteslas - value.x = manager.magnetometerData.magneticField.x; - value.y = manager.magnetometerData.magneticField.y; - value.z = manager.magnetometerData.magneticField.z; + value.x = static_cast(manager.magnetometerData.magneticField.x); + value.y = static_cast(manager.magnetometerData.magneticField.y); + value.z = static_cast(manager.magnetometerData.magneticField.z); break; case Sensor::UserAcceleration: // User acceleration is given in G, convert to m/s^2 - value.x = manager.deviceMotion.userAcceleration.x * 9.81f; - value.y = manager.deviceMotion.userAcceleration.y * 9.81f; - value.z = manager.deviceMotion.userAcceleration.z * 9.81f; + value.x = static_cast(manager.deviceMotion.userAcceleration.x * 9.81); + value.y = static_cast(manager.deviceMotion.userAcceleration.y * 9.81); + value.z = static_cast(manager.deviceMotion.userAcceleration.z * 9.81); break; case Sensor::Orientation: // Absolute rotation (Euler) angles are given in radians, convert to degrees - value.x = toDegrees(manager.deviceMotion.attitude.yaw); - value.y = toDegrees(manager.deviceMotion.attitude.pitch); - value.z = toDegrees(manager.deviceMotion.attitude.roll); + value.x = toDegrees(static_cast(manager.deviceMotion.attitude.yaw)); + value.y = toDegrees(static_cast(manager.deviceMotion.attitude.pitch)); + value.z = toDegrees(static_cast(manager.deviceMotion.attitude.roll)); break; default: diff --git a/src/SFML/Window/iOS/VideoModeImpl.mm b/src/SFML/Window/iOS/VideoModeImpl.mm index 89e9f902..cbea3b16 100644 --- a/src/SFML/Window/iOS/VideoModeImpl.mm +++ b/src/SFML/Window/iOS/VideoModeImpl.mm @@ -50,8 +50,8 @@ std::vector VideoModeImpl::getFullscreenModes() VideoMode VideoModeImpl::getDesktopMode() { CGRect bounds = [[UIScreen mainScreen] bounds]; - float backingScale = [SFAppDelegate getInstance].backingScaleFactor; - return VideoMode(bounds.size.width * backingScale, bounds.size.height * backingScale); + double backingScale = [SFAppDelegate getInstance].backingScaleFactor; + return VideoMode(static_cast(bounds.size.width * backingScale), static_cast(bounds.size.height * backingScale)); } } // namespace priv diff --git a/src/SFML/Window/iOS/WindowImplUIKit.mm b/src/SFML/Window/iOS/WindowImplUIKit.mm index e5fe87d1..0bdab0b6 100644 --- a/src/SFML/Window/iOS/WindowImplUIKit.mm +++ b/src/SFML/Window/iOS/WindowImplUIKit.mm @@ -33,12 +33,20 @@ #include #include +#if defined(__APPLE__) + #if defined(__clang__) + #pragma clang diagnostic ignored "-Wdeprecated-declarations" + #elif defined(__GNUC__) + #pragma GCC diagnostic ignored "-Wdeprecated-declarations" + #endif +#endif + namespace sf { namespace priv { //////////////////////////////////////////////////////////// -WindowImplUIKit::WindowImplUIKit(WindowHandle handle) +WindowImplUIKit::WindowImplUIKit(WindowHandle /* handle */) { // Not implemented } @@ -46,11 +54,11 @@ WindowImplUIKit::WindowImplUIKit(WindowHandle handle) //////////////////////////////////////////////////////////// WindowImplUIKit::WindowImplUIKit(VideoMode mode, - const String& title, + const String& /* title */, unsigned long style, - const ContextSettings& /*settings*/) + const ContextSettings& /* settings */) { - m_backingScale = [SFAppDelegate getInstance].backingScaleFactor; + m_backingScale = static_cast([SFAppDelegate getInstance].backingScaleFactor); // Apply the fullscreen flag [UIApplication sharedApplication].statusBarHidden = !(style & Style::Titlebar) || (style & Style::Fullscreen); @@ -77,7 +85,7 @@ WindowImplUIKit::WindowImplUIKit(VideoMode mode, std::swap(viewRect.size.width, viewRect.size.height); // Create the view - m_view = [[SFView alloc] initWithFrame:viewRect andContentScaleFactor:m_backingScale]; + m_view = [[SFView alloc] initWithFrame:viewRect andContentScaleFactor:(static_cast(m_backingScale))]; [m_view resignFirstResponder]; // Create the view controller @@ -108,7 +116,25 @@ void WindowImplUIKit::processEvents() //////////////////////////////////////////////////////////// WindowHandle WindowImplUIKit::getSystemHandle() const { +#if defined(__APPLE__) + #if defined(__clang__) + #pragma clang diagnostic push + #pragma clang diagnostic ignored "-Wold-style-cast" + #elif defined(__GNUC__) + #pragma GCC diagnostic push + #pragma GCC diagnostic ignored "-Wold-style-cast" + #endif +#endif + return (__bridge WindowHandle)m_window; + +#if defined(__APPLE__) + #if defined(__clang__) + #pragma clang diagnostic pop + #elif defined(__GNUC__) + #pragma GCC diagnostic pop + #endif +#endif } @@ -116,12 +142,12 @@ WindowHandle WindowImplUIKit::getSystemHandle() const Vector2i WindowImplUIKit::getPosition() const { CGPoint origin = m_window.frame.origin; - return Vector2i(origin.x * m_backingScale, origin.y * m_backingScale); + return Vector2i(static_cast(origin.x * static_cast(m_backingScale)), static_cast(origin.y * static_cast(m_backingScale))); } //////////////////////////////////////////////////////////// -void WindowImplUIKit::setPosition(const Vector2i& position) +void WindowImplUIKit::setPosition(const Vector2i& /* position */) { } @@ -129,12 +155,12 @@ void WindowImplUIKit::setPosition(const Vector2i& position) //////////////////////////////////////////////////////////// Vector2u WindowImplUIKit::getSize() const { - auto physicalFrame = m_window.frame; + CGRect physicalFrame = m_window.frame; // iOS 7 and 8 do different stuff here. In iOS 7 frame.x(physicalFrame.size.width * static_cast(m_backingScale)), static_cast(physicalFrame.size.height * static_cast(m_backingScale))); } @@ -156,49 +182,49 @@ void WindowImplUIKit::setSize(const Vector2u& size) //////////////////////////////////////////////////////////// -void WindowImplUIKit::setTitle(const String& title) +void WindowImplUIKit::setTitle(const String& /* title */) { // Not applicable } //////////////////////////////////////////////////////////// -void WindowImplUIKit::setIcon(unsigned int width, unsigned int height, const Uint8* pixels) +void WindowImplUIKit::setIcon(unsigned int /* width */, unsigned int /* height */, const Uint8* /* pixels */) { // Not applicable } //////////////////////////////////////////////////////////// -void WindowImplUIKit::setVisible(bool visible) +void WindowImplUIKit::setVisible(bool /* visible */) { // Not applicable } //////////////////////////////////////////////////////////// -void WindowImplUIKit::setMouseCursorVisible(bool visible) +void WindowImplUIKit::setMouseCursorVisible(bool /* visible */) { // Not applicable } //////////////////////////////////////////////////////////// -void WindowImplUIKit::setMouseCursorGrabbed(bool grabbed) +void WindowImplUIKit::setMouseCursorGrabbed(bool /* grabbed */) { // Not applicable } //////////////////////////////////////////////////////////// -void WindowImplUIKit::setMouseCursor(const CursorImpl& cursor) +void WindowImplUIKit::setMouseCursor(const CursorImpl& /* cursor */) { // Not applicable } //////////////////////////////////////////////////////////// -void WindowImplUIKit::setKeyRepeatEnabled(bool enabled) +void WindowImplUIKit::setKeyRepeatEnabled(bool /* enabled */) { // Not applicable }