mirror of
https://github.com/ArthurSonzogni/Diagon.git
synced 2026-08-29 08:34:44 +08:00
Add more warning. Fix some valgrind issues.
This commit is contained in:
@@ -61,6 +61,20 @@ function(ANTLR source)
|
||||
)
|
||||
endfunction()
|
||||
|
||||
function(target_add_warning target)
|
||||
if (MSVC)
|
||||
target_compile_options(${target} PRIVATE "/wd4244")
|
||||
target_compile_options(${target} PRIVATE "/wd4267")
|
||||
target_compile_options(${target} PRIVATE "/wd4996")
|
||||
target_compile_options(${target} PRIVATE "/wd4305")
|
||||
else()
|
||||
target_compile_options(${target} PRIVATE "-Wall")
|
||||
target_compile_options(${target} PRIVATE "-Werror")
|
||||
target_compile_options(${target} PRIVATE "-Wno-sign-compare")
|
||||
target_compile_options(${target} PRIVATE "-Wno-attributes")
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
# Build the ANTLR runtime.
|
||||
add_subdirectory(
|
||||
${CMAKE_SOURCE_DIR}/tools/antlr/cpp_runtime/
|
||||
|
||||
@@ -89,6 +89,7 @@ if (Web)
|
||||
translator/Translator.h
|
||||
translator/Factory.h
|
||||
)
|
||||
target_add_warning(main)
|
||||
target_link_libraries(main
|
||||
translator_frame
|
||||
translator_math
|
||||
@@ -108,6 +109,7 @@ else()
|
||||
translator/Translator.h
|
||||
translator/Factory.h
|
||||
)
|
||||
target_add_warning(diagon)
|
||||
find_package(Threads REQUIRED)
|
||||
target_link_libraries(diagon
|
||||
translator_frame
|
||||
|
||||
+5
-1
@@ -81,11 +81,12 @@ int PrintVersion() {
|
||||
std::cout << "version: " << git_version << std::endl;
|
||||
std::cout << "Written by Arthur Sonzogni" << std::endl;
|
||||
std::cout << "License MIT" << std::endl;
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
int PrintError(std::string error) {
|
||||
std::cout << error << std::endl;
|
||||
return EXIT_SUCCESS;
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
int PrintTranslatorHelp(TranslatorFactory factory) {
|
||||
@@ -127,6 +128,8 @@ int PrintTranslatorHelp(TranslatorFactory factory) {
|
||||
std::cout << " " << output << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
int Translate(TranslatorFactory translator_factory,
|
||||
@@ -203,6 +206,7 @@ int Translate(TranslatorFactory translator_factory,
|
||||
auto translator = translator_factory();
|
||||
std::string output = translator->Translate(input, option_list);
|
||||
std::cout << output << std::endl;
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
int PrintTranslatorNotFound(const std::string& translator) {
|
||||
|
||||
@@ -1 +1,2 @@
|
||||
add_library(screen Screen.cpp)
|
||||
target_add_warning(screen)
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
add_library(translator_frame STATIC
|
||||
Frame.cpp
|
||||
)
|
||||
target_add_warning(translator_frame)
|
||||
|
||||
@@ -5,3 +5,4 @@ add_library(translator_math STATIC
|
||||
MathParser.cpp
|
||||
Math.cpp
|
||||
)
|
||||
#target_add_warning(translator_math)
|
||||
|
||||
@@ -19,3 +19,7 @@ add_library(translator_planar_graph STATIC
|
||||
PlanarGraphParser.cpp
|
||||
PlanarGraph.cpp
|
||||
)
|
||||
if (MSVC)
|
||||
else()
|
||||
target_compile_options(translator_planar_graph PRIVATE "-Wno-attributes")
|
||||
endif()
|
||||
|
||||
@@ -288,7 +288,7 @@ void PlanarGraph::Write() {
|
||||
|
||||
std::function<void(int)> refresh_x = [&](int y) {
|
||||
int i = y + 1;
|
||||
while (x[i] < x[y] && i < x.size()) {
|
||||
while (i < x.size() && x[i] < x[y]) {
|
||||
x[i] = x[y];
|
||||
++i;
|
||||
};
|
||||
|
||||
@@ -5,3 +5,4 @@ add_library(translator_sequence STATIC
|
||||
SequenceParser.cpp
|
||||
Sequence.cpp
|
||||
)
|
||||
target_add_warning(translator_sequence)
|
||||
|
||||
@@ -608,7 +608,6 @@ void Sequence::LayoutComputeMessagesPositions() {
|
||||
const graph::Node& node = topological_order[i];
|
||||
auto& message = messages[message_index[node.message]];
|
||||
|
||||
bool is_separated = true;
|
||||
if (started_message.count(node.message) == 0) {
|
||||
started_message.insert(node.message);
|
||||
if (i + 1 < 0 ||
|
||||
@@ -684,14 +683,11 @@ std::string Sequence::Draw() {
|
||||
|
||||
Screen screen(width, height);
|
||||
|
||||
int x = 0;
|
||||
for (auto& actor : actors) {
|
||||
for (auto& actor : actors)
|
||||
actor.Draw(screen, height);
|
||||
}
|
||||
|
||||
for(auto message : messages) {
|
||||
for(auto message : messages)
|
||||
message.Draw(screen);
|
||||
}
|
||||
|
||||
if (ascii_only_)
|
||||
screen.ASCIIfy(0);
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
add_library(translator_table STATIC
|
||||
Table.cpp
|
||||
)
|
||||
target_add_warning(translator_table)
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
add_library(translator_tree STATIC
|
||||
Tree.cpp
|
||||
)
|
||||
target_add_warning(translator_tree)
|
||||
|
||||
@@ -201,6 +201,7 @@ DisplayTree MergeDisplayTree(std::wstring content,
|
||||
|
||||
// Draw Child vertical connector.
|
||||
for (auto& line : child.content) {
|
||||
(void)line;
|
||||
if (y >= first_entrance && y <= last_entrance) {
|
||||
ret.content[y][content.size() + 1] = U'│';
|
||||
}
|
||||
@@ -240,10 +241,8 @@ DisplayTree MergeDisplayTree(std::wstring content,
|
||||
|
||||
DisplayTree MakeDisplayTree(Node* tree, Align align) {
|
||||
std::vector<DisplayTree> children_tree;
|
||||
int i = 0;
|
||||
for (auto& child : tree->children) {
|
||||
for (auto& child : tree->children)
|
||||
children_tree.push_back(MakeDisplayTree(child.get(), align));
|
||||
}
|
||||
return MergeDisplayTree(tree->content, std::move(children_tree), align);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user