From 22b518af1f33966263c4087537170481cb210bb1 Mon Sep 17 00:00:00 2001 From: Chris Thrasher Date: Sun, 17 Dec 2023 15:41:31 -0700 Subject: [PATCH] Remove unused function --- src/SFML/Window/CMakeLists.txt | 2 - src/SFML/Window/macOS/WindowImplCocoa.mm | 16 +++++- src/SFML/Window/macOS/cpp_objc_conversion.h | 44 -------------- src/SFML/Window/macOS/cpp_objc_conversion.mm | 60 -------------------- 4 files changed, 15 insertions(+), 107 deletions(-) delete mode 100644 src/SFML/Window/macOS/cpp_objc_conversion.h delete mode 100644 src/SFML/Window/macOS/cpp_objc_conversion.mm diff --git a/src/SFML/Window/CMakeLists.txt b/src/SFML/Window/CMakeLists.txt index f1f581536..2cdecf189 100644 --- a/src/SFML/Window/CMakeLists.txt +++ b/src/SFML/Window/CMakeLists.txt @@ -165,8 +165,6 @@ elseif(SFML_OS_LINUX OR SFML_OS_FREEBSD OR SFML_OS_OPENBSD OR SFML_OS_NETBSD) elseif(SFML_OS_MACOS) enable_language(OBJC OBJCXX) set(PLATFORM_SRC - ${SRCROOT}/macOS/cpp_objc_conversion.h - ${SRCROOT}/macOS/cpp_objc_conversion.mm ${SRCROOT}/macOS/cg_sf_conversion.hpp ${SRCROOT}/macOS/cg_sf_conversion.mm ${SRCROOT}/macOS/CursorImpl.hpp diff --git a/src/SFML/Window/macOS/WindowImplCocoa.mm b/src/SFML/Window/macOS/WindowImplCocoa.mm index 14e2368db..90335a157 100644 --- a/src/SFML/Window/macOS/WindowImplCocoa.mm +++ b/src/SFML/Window/macOS/WindowImplCocoa.mm @@ -34,7 +34,6 @@ #import #import #include -#import #include #include @@ -55,6 +54,21 @@ namespace sf::priv namespace { bool isCursorHidden = false; // initially, the cursor is visible + +NSString* sfStringToNSString(const sf::String& string) +{ + const auto length = static_cast(string.getSize() * sizeof(std::uint32_t)); + const void* data = reinterpret_cast(string.getData()); + + NSStringEncoding encoding; + if (NSHostByteOrder() == NS_LittleEndian) + encoding = NSUTF32LittleEndianStringEncoding; + else + encoding = NSUTF32BigEndianStringEncoding; + + NSString* const str = [[NSString alloc] initWithBytes:data length:length encoding:encoding]; + return [str autorelease]; +} } diff --git a/src/SFML/Window/macOS/cpp_objc_conversion.h b/src/SFML/Window/macOS/cpp_objc_conversion.h deleted file mode 100644 index db55045e5..000000000 --- a/src/SFML/Window/macOS/cpp_objc_conversion.h +++ /dev/null @@ -1,44 +0,0 @@ -//////////////////////////////////////////////////////////// -// -// SFML - Simple and Fast Multimedia Library -// Copyright (C) 2007-2023 Marco Antognini (antognini.marco@gmail.com), -// Laurent Gomila (laurent@sfml-dev.org) -// -// This software is provided 'as-is', without any express or implied warranty. -// In no event will the authors be held liable for any damages arising from the use of this software. -// -// Permission is granted to anyone to use this software for any purpose, -// including commercial applications, and to alter it and redistribute it freely, -// subject to the following restrictions: -// -// 1. The origin of this software must not be misrepresented; -// you must not claim that you wrote the original software. -// If you use this software in a product, an acknowledgment -// in the product documentation would be appreciated but is not required. -// -// 2. Altered source versions must be plainly marked as such, -// and must not be misrepresented as being the original software. -// -// 3. This notice may not be removed or altered from any source distribution. -// -//////////////////////////////////////////////////////////// - -//////////////////////////////////////////////////////////// -// Headers -//////////////////////////////////////////////////////////// -#include - -#import -#include - -//////////////////////////////////////////////////////////// -/// \brief Returns a NSString construct with +stringWithCString:encoding: -/// -//////////////////////////////////////////////////////////// -NSString* stringToNSString(const std::string& string); - -//////////////////////////////////////////////////////////// -/// \brief Returns a NSString construct with +stringWithCString:encoding: -/// -//////////////////////////////////////////////////////////// -NSString* sfStringToNSString(const sf::String& string); diff --git a/src/SFML/Window/macOS/cpp_objc_conversion.mm b/src/SFML/Window/macOS/cpp_objc_conversion.mm deleted file mode 100644 index a705fd870..000000000 --- a/src/SFML/Window/macOS/cpp_objc_conversion.mm +++ /dev/null @@ -1,60 +0,0 @@ -//////////////////////////////////////////////////////////// -// -// SFML - Simple and Fast Multimedia Library -// Copyright (C) 2007-2023 Marco Antognini (antognini.marco@gmail.com), -// Laurent Gomila (laurent@sfml-dev.org) -// -// This software is provided 'as-is', without any express or implied warranty. -// In no event will the authors be held liable for any damages arising from the use of this software. -// -// Permission is granted to anyone to use this software for any purpose, -// including commercial applications, and to alter it and redistribute it freely, -// subject to the following restrictions: -// -// 1. The origin of this software must not be misrepresented; -// you must not claim that you wrote the original software. -// If you use this software in a product, an acknowledgment -// in the product documentation would be appreciated but is not required. -// -// 2. Altered source versions must be plainly marked as such, -// and must not be misrepresented as being the original software. -// -// 3. This notice may not be removed or altered from any source distribution. -// -//////////////////////////////////////////////////////////// - -//////////////////////////////////////////////////////////// -// Headers -//////////////////////////////////////////////////////////// -#import - -#include - -#import - -//////////////////////////////////////////////////////////// -NSString* stringToNSString(const std::string& string) -{ - std::string utf8; - utf8.reserve(string.size() + 1); - sf::Utf8::fromAnsi(string.begin(), string.end(), std::back_inserter(utf8)); - NSString* const str = [NSString stringWithCString:utf8.c_str() encoding:NSUTF8StringEncoding]; - - return str; -} - -//////////////////////////////////////////////////////////// -NSString* sfStringToNSString(const sf::String& string) -{ - const auto length = static_cast(string.getSize() * sizeof(std::uint32_t)); - const void* data = reinterpret_cast(string.getData()); - - NSStringEncoding encoding; - if (NSHostByteOrder() == NS_LittleEndian) - encoding = NSUTF32LittleEndianStringEncoding; - else - encoding = NSUTF32BigEndianStringEncoding; - - NSString* const str = [[NSString alloc] initWithBytes:data length:length encoding:encoding]; - return [str autorelease]; -}