some warning fixes

This commit is contained in:
2019-01-28 11:07:59 +07:00
parent d9715f89ee
commit af69bbae53
11 changed files with 67 additions and 21 deletions

View File

@@ -37,22 +37,14 @@
#endif
#define E2D_CLEAR_ALLOCA(size)\
std::memset(E2D_ALLOCA(size), 0, size)
std::memset(E2D_ALLOCA((size)), 0, (size))
//
// E2D_UNUSED
//
template < typename T >
void E2D_UNUSED(T&& arg) noexcept {
(void)arg;
}
template < typename T, typename... Ts >
void E2D_UNUSED(T&& arg, Ts&&... args) noexcept {
E2D_UNUSED(arg);
E2D_UNUSED(std::forward<Ts>(args)...);
}
template < typename... Ts >
constexpr void E2D_UNUSED(Ts&&...) noexcept {}
//
// E2D_COUNTOF

View File

@@ -34,7 +34,7 @@ namespace e2d
using event_listener_uptr = std::unique_ptr<event_listener>;
public:
window(const v2u& size, str_view title, bool fullscreen);
~window() noexcept;
~window() noexcept final;
void hide() noexcept;
void show() noexcept;

View File

@@ -356,6 +356,14 @@ namespace e2d { namespace math
: static_cast<std::make_unsigned_t<T>>(-(v + 1)) + 1;
}
template < typename T >
std::enable_if_t<
std::is_integral<T>::value && std::is_unsigned<T>::value,
T>
abs_to_unsigned(T v) noexcept {
return v;
}
//
// sign
//

View File

@@ -13,9 +13,9 @@
#include "color32.hpp"
#include "filesystem.hpp"
#include "filesystem.inl"
#include "ilist.hpp"
#include "image.hpp"
#include "iptr.hpp"
#include "intrusive_list.hpp"
#include "intrusive_ptr.hpp"
#include "mesh.hpp"
#include "module.hpp"
#include "path.hpp"

View File

@@ -62,8 +62,8 @@ namespace e2d
read(T& v) noexcept;
private:
input_stream& stream_;
bool success_ = true;
std::exception_ptr exception_ = nullptr;
bool success_{true};
std::exception_ptr exception_{nullptr};
};
class output_sequence final : private noncopyable {
@@ -89,8 +89,8 @@ namespace e2d
write(T v) noexcept;
private:
output_stream& stream_;
bool success_ = true;
std::exception_ptr exception_ = nullptr;
bool success_{true};
std::exception_ptr exception_{nullptr};
};
}

View File

@@ -23,12 +23,18 @@ namespace e2d
explicit url(str_view schemepath);
url(str_view scheme, str_view path) noexcept;
template < typename T, typename U >
url(T&& scheme, U&& path) noexcept;
url& assign(url&& other) noexcept;
url& assign(const url& other);
url& assign(str_view schemepath);
url& assign(str_view scheme, str_view path) noexcept;
template < typename T, typename U >
url& assign(T&& scheme, U&& path) noexcept;
url& concat(str_view path);
url& append(str_view path);
@@ -47,6 +53,21 @@ namespace e2d
};
}
namespace e2d
{
template < typename T, typename U >
url::url(T&& scheme, U&& path) noexcept {
assign(std::forward<T>(scheme), std::forward<U>(path));
}
template < typename T, typename U >
url& url::assign(T&& scheme, U&& path) noexcept {
scheme_ = std::forward<T>(scheme);
path_ = std::forward<U>(path);
return *this;
}
}
namespace e2d
{
void swap(url& l, url& r) noexcept;

View File

@@ -16,7 +16,7 @@ namespace
using namespace e2d;
using namespace e2d::opengl;
class property_block_value_visitor : private noncopyable {
class property_block_value_visitor final : private noncopyable {
public:
property_block_value_visitor(debug& debug, uniform_info ui) noexcept
: debug_(debug)

View File

@@ -17,7 +17,7 @@ namespace
class glfw_state;
using glfw_state_ptr = std::shared_ptr<glfw_state>;
class glfw_state : private noncopyable {
class glfw_state final : private noncopyable {
public:
glfw_state() {
glfwSetErrorCallback(error_handler);

View File

@@ -42,7 +42,8 @@ namespace e2d { namespace path
str combine(str_view lhs, str_view rhs) {
if ( lhs.empty() || is_absolute(rhs) ) {
return rhs;
} else if ( rhs.empty() ) {
}
if ( rhs.empty() ) {
return lhs;
}
return is_directory_separator(lhs.back())

View File

@@ -0,0 +1,23 @@
/*******************************************************************************
* This file is part of the "Enduro2D"
* For conditions of distribution and use, see copyright notice in LICENSE.md
* Copyright (C) 2018 Matvey Cherevko
******************************************************************************/
#include "_base.hpp"
using namespace e2d;
TEST_CASE("macros") {
SECTION("E2D_CLEAR_ALLOCA") {
const u8* m = static_cast<u8*>(E2D_CLEAR_ALLOCA(32));
for ( std::size_t i = 0; i < 32; ++i ) {
REQUIRE_FALSE(m[i]);
}
}
SECTION("E2D_COUNTOF") {
u32 arr[12];
u32 arr2[E2D_COUNTOF(arr)];
REQUIRE(E2D_COUNTOF(arr) == 12);
REQUIRE(E2D_COUNTOF(arr2) == 12);
}
}

View File

@@ -235,6 +235,7 @@ TEST_CASE("math") {
REQUIRE(math::approximately(math::abs_to_unsigned(1), 1u));
REQUIRE(math::approximately(math::abs_to_unsigned(-1), 1u));
REQUIRE(math::approximately(math::abs_to_unsigned(i8(-128)), u8(128)));
REQUIRE(math::approximately(math::abs_to_unsigned(10u), 10u));
const auto imin = std::numeric_limits<i32>::min();
const auto umax = std::numeric_limits<u32>::max();