From 26eb6348e53fd96890d3427bd33636c83edf0121 Mon Sep 17 00:00:00 2001 From: ZXShady <153229951+ZXShady@users.noreply.github.com> Date: Sat, 5 Oct 2024 07:53:48 +0100 Subject: [PATCH] Remove unneeded function prefix in implementation files I used nested namespaces from C++17 instead, of having to specify the namespace for the function implementation. --- src/SFML/Window/Joystick.cpp | 18 +++++++++--------- src/SFML/Window/Keyboard.cpp | 16 ++++++++-------- src/SFML/Window/Mouse.cpp | 14 +++++++------- src/SFML/Window/Sensor.cpp | 10 +++++----- src/SFML/Window/Touch.cpp | 10 +++++----- src/SFML/Window/Vulkan.cpp | 10 +++++----- 6 files changed, 39 insertions(+), 39 deletions(-) diff --git a/src/SFML/Window/Joystick.cpp b/src/SFML/Window/Joystick.cpp index 4bf5e4034..1f8369228 100644 --- a/src/SFML/Window/Joystick.cpp +++ b/src/SFML/Window/Joystick.cpp @@ -31,31 +31,31 @@ #include -namespace sf +namespace sf::Joystick { //////////////////////////////////////////////////////////// -bool Joystick::isConnected(unsigned int joystick) +bool isConnected(unsigned int joystick) { return priv::JoystickManager::getInstance().getState(joystick).connected; } //////////////////////////////////////////////////////////// -unsigned int Joystick::getButtonCount(unsigned int joystick) +unsigned int getButtonCount(unsigned int joystick) { return priv::JoystickManager::getInstance().getCapabilities(joystick).buttonCount; } //////////////////////////////////////////////////////////// -bool Joystick::hasAxis(unsigned int joystick, Axis axis) +bool hasAxis(unsigned int joystick, Axis axis) { return priv::JoystickManager::getInstance().getCapabilities(joystick).axes[axis]; } //////////////////////////////////////////////////////////// -bool Joystick::isButtonPressed(unsigned int joystick, unsigned int button) +bool isButtonPressed(unsigned int joystick, unsigned int button) { assert(button < Joystick::ButtonCount && "Button must be less than Joystick::ButtonCount"); return priv::JoystickManager::getInstance().getState(joystick).buttons[button]; @@ -63,23 +63,23 @@ bool Joystick::isButtonPressed(unsigned int joystick, unsigned int button) //////////////////////////////////////////////////////////// -float Joystick::getAxisPosition(unsigned int joystick, Axis axis) +float getAxisPosition(unsigned int joystick, Axis axis) { return priv::JoystickManager::getInstance().getState(joystick).axes[axis]; } //////////////////////////////////////////////////////////// -Joystick::Identification Joystick::getIdentification(unsigned int joystick) +Identification getIdentification(unsigned int joystick) { return priv::JoystickManager::getInstance().getIdentification(joystick); } //////////////////////////////////////////////////////////// -void Joystick::update() +void update() { priv::JoystickManager::getInstance().update(); } -} // namespace sf +} // namespace sf::Joystick diff --git a/src/SFML/Window/Keyboard.cpp b/src/SFML/Window/Keyboard.cpp index 8a765c2b0..e4b351166 100644 --- a/src/SFML/Window/Keyboard.cpp +++ b/src/SFML/Window/Keyboard.cpp @@ -31,42 +31,42 @@ #include -namespace sf +namespace sf::Keyboard { //////////////////////////////////////////////////////////// -bool Keyboard::isKeyPressed(Key key) +bool isKeyPressed(Key key) { return priv::InputImpl::isKeyPressed(key); } //////////////////////////////////////////////////////////// -bool Keyboard::isKeyPressed(Scancode code) +bool isKeyPressed(Scancode code) { return priv::InputImpl::isKeyPressed(code); } //////////////////////////////////////////////////////////// -Keyboard::Key Keyboard::localize(Scancode code) +Key localize(Scancode code) { return priv::InputImpl::localize(code); } //////////////////////////////////////////////////////////// -Keyboard::Scancode Keyboard::delocalize(Key key) +Scancode delocalize(Key key) { return priv::InputImpl::delocalize(key); } //////////////////////////////////////////////////////////// -String Keyboard::getDescription(Scancode code) +String getDescription(Scancode code) { return priv::InputImpl::getDescription(code); } //////////////////////////////////////////////////////////// -void Keyboard::setVirtualKeyboardVisible(bool visible) +void setVirtualKeyboardVisible(bool visible) { priv::InputImpl::setVirtualKeyboardVisible(visible); } -} // namespace sf +} // namespace sf::Keyboard diff --git a/src/SFML/Window/Mouse.cpp b/src/SFML/Window/Mouse.cpp index 00950f0ad..618f35c0b 100644 --- a/src/SFML/Window/Mouse.cpp +++ b/src/SFML/Window/Mouse.cpp @@ -29,40 +29,40 @@ #include -namespace sf +namespace sf::Mouse { //////////////////////////////////////////////////////////// -bool Mouse::isButtonPressed(Button button) +bool isButtonPressed(Button button) { return priv::InputImpl::isMouseButtonPressed(button); } //////////////////////////////////////////////////////////// -Vector2i Mouse::getPosition() +Vector2i getPosition() { return priv::InputImpl::getMousePosition(); } //////////////////////////////////////////////////////////// -Vector2i Mouse::getPosition(const WindowBase& relativeTo) +Vector2i getPosition(const WindowBase& relativeTo) { return priv::InputImpl::getMousePosition(relativeTo); } //////////////////////////////////////////////////////////// -void Mouse::setPosition(Vector2i position) +void setPosition(Vector2i position) { priv::InputImpl::setMousePosition(position); } //////////////////////////////////////////////////////////// -void Mouse::setPosition(Vector2i position, const WindowBase& relativeTo) +void setPosition(Vector2i position, const WindowBase& relativeTo) { priv::InputImpl::setMousePosition(position, relativeTo); } -} // namespace sf +} // namespace sf::Mouse diff --git a/src/SFML/Window/Sensor.cpp b/src/SFML/Window/Sensor.cpp index 4c23c0687..55f7e7c53 100644 --- a/src/SFML/Window/Sensor.cpp +++ b/src/SFML/Window/Sensor.cpp @@ -29,25 +29,25 @@ #include -namespace sf +namespace sf::Sensor { //////////////////////////////////////////////////////////// -bool Sensor::isAvailable(Type sensor) +bool isAvailable(Type sensor) { return priv::SensorManager::getInstance().isAvailable(sensor); } //////////////////////////////////////////////////////////// -void Sensor::setEnabled(Type sensor, bool enabled) +void setEnabled(Type sensor, bool enabled) { priv::SensorManager::getInstance().setEnabled(sensor, enabled); } //////////////////////////////////////////////////////////// -Vector3f Sensor::getValue(Type sensor) +Vector3f getValue(Type sensor) { return priv::SensorManager::getInstance().getValue(sensor); } -} // namespace sf +} // namespace sf::Sensor diff --git a/src/SFML/Window/Touch.cpp b/src/SFML/Window/Touch.cpp index d9c162ec5..29b81e3e2 100644 --- a/src/SFML/Window/Touch.cpp +++ b/src/SFML/Window/Touch.cpp @@ -29,26 +29,26 @@ #include -namespace sf +namespace sf::Touch { //////////////////////////////////////////////////////////// -bool Touch::isDown(unsigned int finger) +bool isDown(unsigned int finger) { return priv::InputImpl::isTouchDown(finger); } //////////////////////////////////////////////////////////// -Vector2i Touch::getPosition(unsigned int finger) +Vector2i getPosition(unsigned int finger) { return priv::InputImpl::getTouchPosition(finger); } //////////////////////////////////////////////////////////// -Vector2i Touch::getPosition(unsigned int finger, const WindowBase& relativeTo) +Vector2i getPosition(unsigned int finger, const WindowBase& relativeTo) { return priv::InputImpl::getTouchPosition(finger, relativeTo); } -} // namespace sf +} // namespace sf::Touch diff --git a/src/SFML/Window/Vulkan.cpp b/src/SFML/Window/Vulkan.cpp index 57b1af3e7..56825c1ea 100644 --- a/src/SFML/Window/Vulkan.cpp +++ b/src/SFML/Window/Vulkan.cpp @@ -53,10 +53,10 @@ #endif -namespace sf +namespace sf::Vulkan { //////////////////////////////////////////////////////////// -bool Vulkan::isAvailable([[maybe_unused]] bool requireGraphics) +bool isAvailable([[maybe_unused]] bool requireGraphics) { #if defined(SFML_VULKAN_IMPLEMENTATION_NOT_AVAILABLE) @@ -71,7 +71,7 @@ bool Vulkan::isAvailable([[maybe_unused]] bool requireGraphics) //////////////////////////////////////////////////////////// -VulkanFunctionPointer Vulkan::getFunction([[maybe_unused]] const char* name) +VulkanFunctionPointer getFunction([[maybe_unused]] const char* name) { assert(name && "Name cannot be a null pointer"); @@ -88,7 +88,7 @@ VulkanFunctionPointer Vulkan::getFunction([[maybe_unused]] const char* name) //////////////////////////////////////////////////////////// -const std::vector& Vulkan::getGraphicsRequiredInstanceExtensions() +const std::vector& getGraphicsRequiredInstanceExtensions() { #if defined(SFML_VULKAN_IMPLEMENTATION_NOT_AVAILABLE) @@ -103,4 +103,4 @@ const std::vector& Vulkan::getGraphicsRequiredInstanceExtensions() #endif } -} // namespace sf +} // namespace sf::Vulkan