Skip to content

Commit

Permalink
修warning,加速编译
Browse files Browse the repository at this point in the history
  • Loading branch information
SaeruHikari committed Feb 2, 2021
1 parent 5dc9c4c commit b13cfe3
Show file tree
Hide file tree
Showing 12 changed files with 64 additions and 122 deletions.
57 changes: 11 additions & 46 deletions SakuraEngine/Extern/utf8/utf8/checked.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,51 +29,16 @@ DEALINGS IN THE SOFTWARE.
#define UTF8_FOR_CPP_CHECKED_H_2675DCD0_9480_4c0c_B92A_CC14C027B731

#include "core.h"
#include <stdexcept>

namespace utf8
{
// Base for the exceptions that may be thrown from the library
class exception : public ::std::exception {
};

// Exceptions that may be thrown from the library functions.
class invalid_code_point : public exception {
uint32_t cp;
public:
invalid_code_point(uint32_t codepoint) : cp(codepoint) {}
virtual const char* what() const UTF_CPP_NOEXCEPT UTF_CPP_OVERRIDE { return "Invalid code point"; }
uint32_t code_point() const {return cp;}
};

class invalid_utf8 : public exception {
uint8_t u8;
public:
invalid_utf8 (uint8_t u) : u8(u) {}
virtual const char* what() const UTF_CPP_NOEXCEPT UTF_CPP_OVERRIDE { return "Invalid UTF-8"; }
uint8_t utf8_octet() const {return u8;}
};

class invalid_utf16 : public exception {
uint16_t u16;
public:
invalid_utf16 (uint16_t u) : u16(u) {}
virtual const char* what() const UTF_CPP_NOEXCEPT UTF_CPP_OVERRIDE { return "Invalid UTF-16"; }
uint16_t utf16_word() const {return u16;}
};

class not_enough_room : public exception {
public:
virtual const char* what() const UTF_CPP_NOEXCEPT UTF_CPP_OVERRIDE { return "Not enough space"; }
};

/// The library API - functions intended to be called by the users

template <typename octet_iterator>
octet_iterator append(uint32_t cp, octet_iterator result)
{
if (!utf8::internal::is_code_point_valid(cp))
;// throw invalid_code_point(cp);
abort();// throw invalid_code_point(cp);

if (cp < 0x80) // one octet
*(result++) = static_cast<uint8_t>(cp);
Expand Down Expand Up @@ -144,13 +109,13 @@ namespace utf8
case internal::UTF8_OK :
break;
case internal::NOT_ENOUGH_ROOM :
;// throw not_enough_room();
abort();// throw not_enough_room();
case internal::INVALID_LEAD :
case internal::INCOMPLETE_SEQUENCE :
case internal::OVERLONG_SEQUENCE :
;// throw invalid_utf8(*it);
abort();// throw invalid_utf8(*it);
case internal::INVALID_CODE_POINT :
;// throw invalid_code_point(cp);
abort();// throw invalid_code_point(cp);
}
return cp;
}
Expand All @@ -166,13 +131,13 @@ namespace utf8
{
// can't do much if it == start
if (it == start)
;// throw not_enough_room();
abort();// throw not_enough_room();

octet_iterator end = it;
// Go back until we hit either a lead octet or start
while (utf8::internal::is_trail(*(--it)))
if (it == start)
;// throw invalid_utf8(*it); // error - no lead byte in the sequence
abort();// throw invalid_utf8(*it); // error - no lead byte in the sequence
return utf8::peek_next(it, end);
}

Expand Down Expand Up @@ -213,15 +178,15 @@ namespace utf8
if (utf8::internal::is_trail_surrogate(trail_surrogate))
cp = (cp << 10) + trail_surrogate + internal::SURROGATE_OFFSET;
else
;// throw invalid_utf16(static_cast<uint16_t>(trail_surrogate));
abort();// throw invalid_utf16(static_cast<uint16_t>(trail_surrogate));
}
else
;// throw invalid_utf16(static_cast<uint16_t>(cp));
abort();// throw invalid_utf16(static_cast<uint16_t>(cp));

}
// Lone trail surrogate
else if (utf8::internal::is_trail_surrogate(cp))
;// throw invalid_utf16(static_cast<uint16_t>(cp));
abort();// throw invalid_utf16(static_cast<uint16_t>(cp));

result = utf8::append(cp, result);
}
Expand Down Expand Up @@ -280,7 +245,7 @@ namespace utf8
it(octet_it), range_start(rangestart), range_end(rangeend)
{
if (it < range_start || it > range_end)
;// throw std::out_of_range("Invalid utf-8 iterator position");
abort();// throw std::out_of_range("Invalid utf-8 iterator position");
}
// the default "big three" are OK
octet_iterator base () const { return it; }
Expand All @@ -292,7 +257,7 @@ namespace utf8
bool operator == (const iterator& rhs) const
{
if (range_start != rhs.range_start || range_end != rhs.range_end)
;// throw std::logic_error("Comparing utf-8 iterators defined with different ranges");
abort();// throw std::logic_error("Comparing utf-8 iterators defined with different ranges");
return (it == rhs.it);
}
bool operator != (const iterator& rhs) const
Expand Down
2 changes: 1 addition & 1 deletion SakuraEngine/Source/Runtime/CMakeImported/Dots
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

#include <vulkan/vulkan_core.h>



#include "Math/Math.hpp"
#include "Math/Matrix.h"
#include "ShaderCompiler/ShaderCompiler.h"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -389,10 +389,6 @@ namespace sakura::graphics
inline operator size_t() const { return id_; }
inline operator bool() const { return id_; }
inline RenderGraphId id() const { return id_; }
FORCEINLINE bool operator==(const RenderObjectHandle& other) const
{
return this->id_ == other.id_;
}
FORCEINLINE bool operator==(const GenerationalId& other) const
{
return this->id_ == other;
Expand All @@ -408,10 +404,6 @@ namespace sakura::graphics
inline operator size_t() const { return id_; }
inline operator bool() const { return id_; }
inline RenderGraphId id() const { return id_; }
FORCEINLINE bool operator==(const RenderPassHandle& other) const
{
return this->id_ == other.id_;
}
FORCEINLINE bool operator==(const GenerationalId& other) const
{
return this->id_ == other;
Expand All @@ -428,10 +420,6 @@ namespace sakura::graphics
inline operator size_t() const { return id_; }
inline operator bool() const { return id_; }
inline RenderGraphId id() const { return id_; }
FORCEINLINE bool operator==(const RenderResourceHandle& other) const
{
return this->id_ == other.id_;
}
FORCEINLINE bool operator==(const GenerationalId& other) const
{
return this->id_ == other;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,8 @@ namespace sakura
typedef unsigned int uint;
typedef unsigned char uchar;

using char8_t = char;

using uint8 = uint8_t;
using uint8_t = uint8_t;
using uint16 = uint16_t;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,9 @@
#include "SakuraSTL.hpp"
#include <System/Time.h>
#include <System/VirtualFileSystem.h>
#include <System/Log.h>
#include <Base/GUID.h>
#include "Module.h"
#include "RuntimeCore/Resource.h"
#include "Base/GenerationalId.h"
#include "System/Window.h"
#include "Module.h"
#include "Math/Math.hpp"
#ifdef SAKURA_TARGET_PLATFORM_WIN
#include "Platform/Windows/Messages.hpp"
Expand Down
40 changes: 1 addition & 39 deletions SakuraEngine/Source/Runtime/RuntimeCore/Include/SakuraSTL.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,49 +28,27 @@
#include "RuntimeCore/Memory.h"
#include <spdlog/fmt/fmt.h>
#include <chrono>
#include <string>
#include <string_view>
#include <variant>
#include <atomic>
#include "SakuraSTL/span.hpp"
#include "SakuraSTL/array.hpp"
#include "SakuraSTL/vector.hpp"
#include "SakuraSTL/unordered_map.hpp"
#include "SakuraSTL/string.hpp"
#include "SakuraSTL/codecvt.hpp"

namespace sakura
{
using u8string = std::string;
using u8string_view = std::string_view;
using namespace utf_converter;

using std::unique_ptr;
using std::string_view;
using std::variant;
using std::pair;
using std::function;
using std::make_pair;
using std::move;
using std::forward;
using std::to_string;
using std::to_wstring;
}
using char8_t = char;

#ifdef WHEN_PMR_IS_USABLE
#include <memory_resource>
namespace sakura
{
using std::pmr::string;
using std::pmr::wstring;
}
#else
namespace sakura
{
using string = std::string;
using wstring = std::wstring;
}
#endif

#include <ctime>

Expand All @@ -90,22 +68,6 @@ namespace sakura

namespace sakura
{
template<typename string_type>
void string_replace(
string_type& src,
const string_type& to_replace, const string_type& replacement)
{
typename string_type::size_type pos = 0;
typename string_type::size_type srclen = to_replace.size();
typename string_type::size_type dstlen = replacement.size();

while ((pos = src.find(to_replace, pos)) != string_type::npos)
{
src.replace(pos, srclen, replacement);
pos += dstlen;
}
}

template <typename T, uint32_t size>
struct storage
{
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#pragma once
#include "Base/Definations.h"
#include <string>
#include <string_view>

#ifdef WHEN_PMR_IS_USABLE
#include <memory_resource>
namespace sakura
{
using std::pmr::string;
using std::pmr::wstring;
}
#else
namespace sakura
{
using string = std::string;
using wstring = std::wstring;
}
#endif
namespace sakura
{
using std::string_view;
using std::to_string;
using std::to_wstring;

using u8string = std::string;
using u8string_view = std::string_view;

template<typename string_type>
void string_replace(
string_type& src,
const string_type& to_replace, const string_type& replacement)
{
typename string_type::size_type pos = 0;
typename string_type::size_type srclen = to_replace.size();
typename string_type::size_type dstlen = replacement.size();

while ((pos = src.find(to_replace, pos)) != string_type::npos)
{
src.replace(pos, srclen, replacement);
pos += dstlen;
}
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#pragma once
#include <Base/Definations.h>
#include <SakuraSTL/string.hpp>

namespace sakura
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,8 @@ namespace sakura::windows

sakura::pos2d sakura::Monitor::screen_to_client(Window window, const pos2d& inPos)
{
POINT mouse_client_pos = {inPos.x, inPos.y};
POINT mouse_client_pos = {
static_cast<LONG>(inPos.x), static_cast<LONG>(inPos.y)};
::ScreenToClient(static_cast<HWND>(window.handle()), &mouse_client_pos);
pos2d outPos = { mouse_client_pos.x, mouse_client_pos.y };
return outPos;
Expand Down
17 changes: 2 additions & 15 deletions SakuraEngine/Source/Test/Boids/Source/Boids.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,11 @@
#endif
#define TRACY_ENABLE
#include "tracy/Tracy.hpp"

#include "RuntimeCore/RuntimeCore.h"
#include "spdlog/spdlog.h"
#include "marl/finally.h"
#include "SakuraSTL.hpp"

#include "System/VirtualFileSystem.h"
#include "System/Log.h"

#include "ECS/ECS.h"
#include "RingBuffer.h"

#include "TransformComponents.h"
#include "RenderSystem.h"
#include "Boids.h"
Expand All @@ -24,13 +17,10 @@
#include "kdtree.h"
#include <iostream>
#include <random>
#include <cmath>
#include <fstream>
#include <filesystem>
#include "System/Messages.h"
#include "imgui/sakura_imgui.h"


#define forloop(i, z, n) for(auto i = std::decay_t<decltype(n)>(z); i<(n); ++i)
#define def static constexpr auto

Expand Down Expand Up @@ -62,8 +52,6 @@ struct Timer
std::chrono::system_clock::time_point tmpt;
};



struct buffer_serializer final : sakura::ecs::serializer_i
{
std::vector<char>& buffer;
Expand Down Expand Up @@ -747,7 +735,6 @@ void BoidMainLoop(task_system::ecs::pipeline& ppl, float deltaTime)
Local2XSystem<LocalToWorld>(ppl, wrd_filter, PassLocation(LocalToWorld));
}


filters c2p_filter;
c2p_filter.archetypeFilter = {
{complist<LocalToParent, Parent>},
Expand Down Expand Up @@ -802,7 +789,7 @@ int main()
WorldToLocal, Child, Parent, Boid, BoidTarget, MoveToward, RandomMoveTarget, Heading, BoidDebugData>();
SpawnBoidSetting();
SpawnBoidTargets(10);

task_system::ecs::pipeline ppl(std::move(ctx));
if (!bUseImGui)
{
Expand Down Expand Up @@ -878,7 +865,7 @@ int main()
ctx.serialize(&archive);
memory_used += snapshot.size();
snapshots.emplace_back(std::move(snapshot));
while (memory_used > (long long)memory_size_limit * 1024 * 1024)
while (memory_used > (size_t)memory_size_limit * 1024 * 1024)
{
memory_used -= snapshots.front().size();
snapshots.pop_front();
Expand Down
Loading

0 comments on commit b13cfe3

Please sign in to comment.