Skip to content

Commit

Permalink
Clean up a crapload of warnings with -Wshadow.
Browse files Browse the repository at this point in the history
Hopefully no regressions ... :D
  • Loading branch information
Hans-Kristian Arntzen committed Mar 25, 2019
1 parent 1f21760 commit 7783ebd
Show file tree
Hide file tree
Showing 137 changed files with 1,330 additions and 1,442 deletions.
2 changes: 1 addition & 1 deletion .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
url = http://bitbucket.org/Themaister/astc-encoder
[submodule "third_party/fossilize"]
path = third_party/fossilize
url = git://github.com/Themaister/Fossilize
url = git://github.com/ValveSoftware/Fossilize
[submodule "third_party/volk"]
path = third_party/volk
url = git://github.com/zeux/volk
Expand Down
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ set(CMAKE_C_STANDARD 99)
project(Granite LANGUAGES CXX C)

if (CMAKE_COMPILER_IS_GNUCXX OR (${CMAKE_CXX_COMPILER_ID} MATCHES "Clang"))
set(GRANITE_CXX_FLAGS -Wall -Wextra -Wno-comment -Wno-missing-field-initializers -Wno-empty-body -ffast-math)
set(GRANITE_CXX_FLAGS -Wshadow -Wall -Wextra -Wno-comment -Wno-missing-field-initializers -Wno-empty-body -ffast-math)
if (${CMAKE_CXX_COMPILER_ID} MATCHES "Clang")
set(GRANITE_CXX_FLAGS ${GRANITE_CXX_FLAGS} -Wno-backslash-newline-escape)
endif()
Expand Down
10 changes: 5 additions & 5 deletions application/application.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ Application::Application()
bool Application::init_wsi(std::unique_ptr<WSIPlatform> new_platform)
{
platform = move(new_platform);
wsi.set_platform(platform.get());
if (!platform->has_external_swapchain() && !wsi.init())
application_wsi.set_platform(platform.get());
if (!platform->has_external_swapchain() && !application_wsi.init())
return false;

return true;
Expand Down Expand Up @@ -99,9 +99,9 @@ bool Application::poll()

void Application::run_frame()
{
wsi.begin_frame();
render_frame(wsi.get_smooth_frame_time(), wsi.get_smooth_elapsed_time());
wsi.end_frame();
application_wsi.begin_frame();
render_frame(application_wsi.get_smooth_frame_time(), application_wsi.get_smooth_elapsed_time());
application_wsi.end_frame();
}

}
4 changes: 2 additions & 2 deletions application/application.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class Application

Vulkan::WSI &get_wsi()
{
return wsi;
return application_wsi;
}

Vulkan::WSIPlatform &get_platform()
Expand Down Expand Up @@ -77,7 +77,7 @@ class Application

private:
std::unique_ptr<Vulkan::WSIPlatform> platform;
Vulkan::WSI wsi;
Vulkan::WSI application_wsi;
bool requested_shutdown = false;
};

Expand Down
26 changes: 15 additions & 11 deletions application/application_wsi_events.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ class DeviceCreatedEvent : public Granite::Event
public:
GRANITE_EVENT_TYPE_DECL(DeviceCreatedEvent)

DeviceCreatedEvent(Device *device)
: device(*device)
explicit DeviceCreatedEvent(Device *device_)
: device(*device_)
{}

Device &get_device() const
Expand All @@ -52,11 +52,11 @@ class DisplayTimingStutterEvent : public Granite::Event
public:
GRANITE_EVENT_TYPE_DECL(WSIStutterEvent)

DisplayTimingStutterEvent(uint32_t current_serial, uint32_t observed_serial,
unsigned dropped_frames)
: current_serial(current_serial),
observed_serial(observed_serial),
dropped_frames(dropped_frames)
DisplayTimingStutterEvent(uint32_t current_serial_, uint32_t observed_serial_,
unsigned dropped_frames_)
: current_serial(current_serial_),
observed_serial(observed_serial_),
dropped_frames(dropped_frames_)
{
}

Expand Down Expand Up @@ -86,8 +86,12 @@ class SwapchainParameterEvent : public Granite::Event
public:
GRANITE_EVENT_TYPE_DECL(SwapchainParameterEvent)

SwapchainParameterEvent(Device *device, unsigned width, unsigned height, float aspect_ratio, unsigned count, VkFormat format)
: device(*device), width(width), height(height), aspect_ratio(aspect_ratio), image_count(count), format(format)
SwapchainParameterEvent(Device *device_,
unsigned width_, unsigned height_,
float aspect_ratio_, unsigned count_,
VkFormat format_)
: device(*device_), width(width_), height(height_),
aspect_ratio(aspect_ratio_), image_count(count_), format(format_)
{}

Device &get_device() const
Expand Down Expand Up @@ -135,8 +139,8 @@ class SwapchainIndexEvent : public Granite::Event
public:
GRANITE_EVENT_TYPE_DECL(SwapchainIndexEvent)

SwapchainIndexEvent(Device *device, unsigned index)
: device(*device), index(index)
SwapchainIndexEvent(Device *device_, unsigned index_)
: device(*device_), index(index_)
{}

Device &get_device() const
Expand Down
8 changes: 4 additions & 4 deletions application/events/application_events.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ class ApplicationLifecycleEvent : public Event
public:
GRANITE_EVENT_TYPE_DECL(ApplicationLifecycleEvent)

ApplicationLifecycleEvent(ApplicationLifecycle lifecycle)
: lifecycle(lifecycle)
explicit ApplicationLifecycleEvent(ApplicationLifecycle lifecycle_)
: lifecycle(lifecycle_)
{
}

Expand All @@ -58,8 +58,8 @@ class FrameTickEvent : public Granite::Event
public:
GRANITE_EVENT_TYPE_DECL(FrameTickEvent)

FrameTickEvent(double frame_time, double elapsed_time)
: frame_time(frame_time), elapsed_time(elapsed_time)
FrameTickEvent(double frame_time_, double elapsed_time_)
: frame_time(frame_time_), elapsed_time(elapsed_time_)
{
}

Expand Down
64 changes: 39 additions & 25 deletions application/input/input.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -272,8 +272,8 @@ class JoypadConnectionEvent : public Granite::Event
{
public:
GRANITE_EVENT_TYPE_DECL(JoypadConnectionEvent)
JoypadConnectionEvent(unsigned index, bool connected)
: index(index), connected(connected)
JoypadConnectionEvent(unsigned index_, bool connected_)
: index(index_), connected(connected_)
{
}

Expand All @@ -297,8 +297,8 @@ class TouchGestureEvent : public Granite::Event
public:
GRANITE_EVENT_TYPE_DECL(TouchGestureEvent)

TouchGestureEvent(const TouchState &state)
: state(state)
explicit TouchGestureEvent(const TouchState &state_)
: state(state_)
{
}

Expand All @@ -316,8 +316,12 @@ class TouchDownEvent : public Granite::Event
public:
GRANITE_EVENT_TYPE_DECL(TouchDownEvent)

TouchDownEvent(unsigned index, unsigned id, float x, float y, unsigned screen_width, unsigned screen_height)
: index(index), id(id), x(x), y(y), width(screen_width), height(screen_height)
TouchDownEvent(unsigned index_, unsigned id_,
float x_, float y_,
unsigned screen_width_, unsigned screen_height_)
: index(index_), id(id_),
x(x_), y(y_),
width(screen_width_), height(screen_height_)
{
}

Expand Down Expand Up @@ -362,8 +366,12 @@ class TouchUpEvent : public Granite::Event
public:
GRANITE_EVENT_TYPE_DECL(TouchUpEvent)

TouchUpEvent(unsigned id, float x, float y, float start_x, float start_y, unsigned screen_width, unsigned screen_height)
: id(id), x(x), y(y), start_x(start_x), start_y(start_y), width(screen_width), height(screen_height)
TouchUpEvent(unsigned id_, float x_, float y_,
float start_x_, float start_y_,
unsigned screen_width_, unsigned screen_height_)
: id(id_), x(x_), y(y_),
start_x(start_x_), start_y(start_y_),
width(screen_width_), height(screen_height_)
{
}

Expand Down Expand Up @@ -414,8 +422,8 @@ class JoypadButtonEvent : public Granite::Event
public:
GRANITE_EVENT_TYPE_DECL(JoypadButtonEvent)

JoypadButtonEvent(unsigned index, JoypadKey key, JoypadKeyState state)
: index(index), key(key), state(state)
JoypadButtonEvent(unsigned index_, JoypadKey key_, JoypadKeyState state_)
: index(index_), key(key_), state(state_)
{
}

Expand Down Expand Up @@ -445,8 +453,8 @@ class JoypadAxisEvent : public Granite::Event
public:
GRANITE_EVENT_TYPE_DECL(JoypadAxisEvent)

JoypadAxisEvent(unsigned index, JoypadAxis axis, float value)
: index(index), axis(axis), value(value)
JoypadAxisEvent(unsigned index_, JoypadAxis axis_, float value_)
: index(index_), axis(axis_), value(value_)
{
}

Expand Down Expand Up @@ -476,8 +484,8 @@ class KeyboardEvent : public Granite::Event
public:
GRANITE_EVENT_TYPE_DECL(KeyboardEvent)

KeyboardEvent(Key key, KeyState state)
: key(key), state(state)
KeyboardEvent(Key key_, KeyState state_)
: key(key_), state(state_)
{
}

Expand All @@ -500,8 +508,8 @@ class OrientationEvent : public Granite::Event
{
public:
GRANITE_EVENT_TYPE_DECL(OrientationEvent)
OrientationEvent(quat rot)
: rot(rot)
explicit OrientationEvent(const quat &rot_)
: rot(rot_)
{
}

Expand All @@ -519,8 +527,8 @@ class MouseButtonEvent : public Granite::Event
public:
GRANITE_EVENT_TYPE_DECL(MouseButtonEvent)

MouseButtonEvent(MouseButton button, double abs_x, double abs_y, bool pressed)
: button(button), abs_x(abs_x), abs_y(abs_y), pressed(pressed)
MouseButtonEvent(MouseButton button_, double abs_x_, double abs_y_, bool pressed_)
: button(button_), abs_x(abs_x_), abs_y(abs_y_), pressed(pressed_)
{
}

Expand Down Expand Up @@ -556,9 +564,11 @@ class MouseMoveEvent : public Granite::Event
public:
GRANITE_EVENT_TYPE_DECL(MouseMoveEvent);

MouseMoveEvent(double delta_x, double delta_y, double abs_x, double abs_y,
uint64_t key_mask, uint8_t btn_mask)
: delta_x(delta_x), delta_y(delta_y), abs_x(abs_x), abs_y(abs_y), key_mask(key_mask), btn_mask(btn_mask)
MouseMoveEvent(double delta_x_, double delta_y_, double abs_x_, double abs_y_,
uint64_t key_mask_, uint8_t btn_mask_)
: delta_x(delta_x_), delta_y(delta_y_),
abs_x(abs_x_), abs_y(abs_y_),
key_mask(key_mask_), btn_mask(btn_mask_)
{
}

Expand Down Expand Up @@ -603,8 +613,9 @@ class JoypadStateEvent : public Granite::Event
public:
GRANITE_EVENT_TYPE_DECL(JoypadStateEvent)

JoypadStateEvent(uint8_t active_mask, const JoypadState *states, unsigned count, double delta_time)
: states(states), count(count), delta_time(delta_time), active_mask(active_mask)
JoypadStateEvent(uint8_t active_mask_, const JoypadState *states_,
unsigned count_, double delta_time_)
: states(states_), count(count_), delta_time(delta_time_), active_mask(active_mask_)
{
}

Expand Down Expand Up @@ -642,8 +653,11 @@ class InputStateEvent : public Granite::Event
public:
GRANITE_EVENT_TYPE_DECL(InputStateEvent)

InputStateEvent(double abs_x, double abs_y, double delta_time, uint64_t key_mask, uint8_t btn_mask, bool mouse_active)
: abs_x(abs_x), abs_y(abs_y), delta_time(delta_time), key_mask(key_mask), btn_mask(btn_mask), mouse_active(mouse_active)
InputStateEvent(double abs_x_, double abs_y_,
double delta_time_, uint64_t key_mask_, uint8_t btn_mask_, bool mouse_active_)
: abs_x(abs_x_), abs_y(abs_y_),
delta_time(delta_time_), key_mask(key_mask_),
btn_mask(btn_mask_), mouse_active(mouse_active_)
{
}

Expand Down
6 changes: 3 additions & 3 deletions application/input/input_linux.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -580,10 +580,10 @@ void LinuxInputManager::input_handle_joystick(Device &dev, const input_event &e)
}
}

bool LinuxInputManager::init(LinuxInputManagerFlags flags, InputTracker *tracker)
bool LinuxInputManager::init(LinuxInputManagerFlags flags_, InputTracker *tracker_)
{
this->flags = flags;
this->tracker = tracker;
flags = flags_;
tracker = tracker_;
terminal_disable_input();
init_key_table();

Expand Down
6 changes: 3 additions & 3 deletions application/platforms/application_glfw.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -158,11 +158,11 @@ struct WSIPlatformGLFW : GraniteWSIPlatform
glfwDestroyWindow(window);
}

void notify_resize(unsigned width, unsigned height)
void notify_resize(unsigned width_, unsigned height_)
{
resize = true;
this->width = width;
this->height = height;
width = width_;
height = height_;
}

struct CachedWindow
Expand Down
Loading

0 comments on commit 7783ebd

Please sign in to comment.