From c0725a31caa3727cbdad03b707ab764ca3a8df15 Mon Sep 17 00:00:00 2001 From: Ben Vanik Date: Sat, 1 Aug 2015 03:55:44 -0700 Subject: [PATCH] clang fixes. --- src/el/animation_manager.cc | 2 +- src/el/elements/text_box.cc | 2 +- src/el/graphics/bitmap_fragment_map.cc | 2 ++ src/el/io/memory_file_system.cc | 1 + ...system.cc => win32_res_file_system_win.cc} | 2 +- ...e_system.h => win32_res_file_system_win.h} | 6 +++--- src/el/list_item.h | 20 +++++++++---------- src/el/parsing/parse_node.cc | 2 ++ src/el/parsing/parse_node.h | 1 + src/el/parsing/text_parser_stream.cc | 2 ++ src/el/text/caret.cc | 5 +---- src/el/text/font_face.cc | 1 + src/el/text/text_fragment.cc | 14 ++++++------- src/el/text/text_fragment_content.cc | 4 ++-- testbed/testbed_application.cc | 2 +- 15 files changed, 36 insertions(+), 30 deletions(-) rename src/el/io/{win32_res_file_system.cc => win32_res_file_system_win.cc} (98%) rename src/el/io/{win32_res_file_system.h => win32_res_file_system_win.h} (86%) diff --git a/src/el/animation_manager.cc b/src/el/animation_manager.cc index deb6d9c..2056056 100644 --- a/src/el/animation_manager.cc +++ b/src/el/animation_manager.cc @@ -113,7 +113,7 @@ void AnimationManager::StartAnimation(Animation* obj, } obj->adjust_start_time = animation_time == AnimationTime::kFirstUpdate; obj->animation_start_time = util::GetTimeMS(); - obj->animation_duration = std::max(animation_duration, 0ull); + obj->animation_duration = std::max(animation_duration, uint64_t(0)); obj->animation_curve = animation_curve; animating_objects.AddLast(obj); obj->InvokeOnAnimationStart(); diff --git a/src/el/elements/text_box.cc b/src/el/elements/text_box.cc index e708254..15d19f4 100644 --- a/src/el/elements/text_box.cc +++ b/src/el/elements/text_box.cc @@ -607,7 +607,7 @@ int TextBox::TextBoxContentFactory::GetContent(const char* text) { text::TextFragmentContent* TextBox::TextBoxContentFactory::CreateFragmentContent(const char* text, size_t text_len) { - if (strncmp(text, " + #include "el/graphics/bitmap_fragment_map.h" #include "el/graphics/renderer.h" #include "el/util/math.h" diff --git a/src/el/io/memory_file_system.cc b/src/el/io/memory_file_system.cc index d39c610..185bc52 100644 --- a/src/el/io/memory_file_system.cc +++ b/src/el/io/memory_file_system.cc @@ -8,6 +8,7 @@ */ #include +#include #include "el/io/memory_file_system.h" diff --git a/src/el/io/win32_res_file_system.cc b/src/el/io/win32_res_file_system_win.cc similarity index 98% rename from src/el/io/win32_res_file_system.cc rename to src/el/io/win32_res_file_system_win.cc index 5cd33fc..c8e006f 100644 --- a/src/el/io/win32_res_file_system.cc +++ b/src/el/io/win32_res_file_system_win.cc @@ -12,7 +12,7 @@ #include #include -#include "el/io/win32_res_file_system.h" +#include "el/io/win32_res_file_system_win.h" #ifndef WIN32_LEAN_AND_MEAN #define WIN32_LEAN_AND_MEAN diff --git a/src/el/io/win32_res_file_system.h b/src/el/io/win32_res_file_system_win.h similarity index 86% rename from src/el/io/win32_res_file_system.h rename to src/el/io/win32_res_file_system_win.h index 4bdf520..fac6a30 100644 --- a/src/el/io/win32_res_file_system.h +++ b/src/el/io/win32_res_file_system_win.h @@ -7,8 +7,8 @@ ****************************************************************************** */ -#ifndef EL_IO_WIN32_RES_FILE_SYSTEM_H_ -#define EL_IO_WIN32_RES_FILE_SYSTEM_H_ +#ifndef EL_IO_WIN32_RES_FILE_SYSTEM_WIN_H_ +#define EL_IO_WIN32_RES_FILE_SYSTEM_WIN_H_ #include #include @@ -31,4 +31,4 @@ class Win32ResFileSystem : public FileSystem { } // namespace io } // namespace el -#endif // EL_IO_WIN32_RES_FILE_SYSTEM_H_ +#endif // EL_IO_WIN32_RES_FILE_SYSTEM_WIN_H_ diff --git a/src/el/list_item.h b/src/el/list_item.h index 57e43e7..d677366 100644 --- a/src/el/list_item.h +++ b/src/el/list_item.h @@ -257,7 +257,7 @@ struct ItemListElementNode : public ElementNode { auto items_node = Node::GetOrCreateNode("items"); auto node = ParseNode::Create("item"); auto text_node = ParseNode::Create("text"); - text_node->TakeValue(el::Value(text.c_str())); + text_node->EmplaceValue(el::Value(text.c_str())); node->Add(text_node); items_node->Add(node); return *reinterpret_cast(this); @@ -267,10 +267,10 @@ struct ItemListElementNode : public ElementNode { auto items_node = Node::GetOrCreateNode("items"); auto node = ParseNode::Create("item"); auto id_node = ParseNode::Create("id"); - id_node->TakeValue(el::Value(id.c_str())); + id_node->EmplaceValue(el::Value(id.c_str())); node->Add(id_node); auto text_node = ParseNode::Create("text"); - text_node->TakeValue(el::Value(text.c_str())); + text_node->EmplaceValue(el::Value(text.c_str())); node->Add(text_node); items_node->Add(node); return *reinterpret_cast(this); @@ -280,10 +280,10 @@ struct ItemListElementNode : public ElementNode { auto items_node = Node::GetOrCreateNode("items"); auto node = ParseNode::Create("item"); auto id_node = ParseNode::Create("id"); - id_node->TakeValue(el::Value(id)); + id_node->EmplaceValue(el::Value(id)); node->Add(id_node); auto text_node = ParseNode::Create("text"); - text_node->TakeValue(el::Value(text.c_str())); + text_node->EmplaceValue(el::Value(text.c_str())); node->Add(text_node); items_node->Add(node); return *reinterpret_cast(this); @@ -294,7 +294,7 @@ struct ItemListElementNode : public ElementNode { for (auto& item : items) { auto node = ParseNode::Create("item"); auto text_node = ParseNode::Create("text"); - text_node->TakeValue(el::Value(item.c_str())); + text_node->EmplaceValue(el::Value(item.c_str())); node->Add(text_node); items_node->Add(node); } @@ -306,10 +306,10 @@ struct ItemListElementNode : public ElementNode { for (auto& item : items) { auto node = ParseNode::Create("item"); auto id_node = ParseNode::Create("id"); - id_node->TakeValue(el::Value(item.first)); + id_node->EmplaceValue(el::Value(item.first)); node->Add(id_node); auto text_node = ParseNode::Create("text"); - text_node->TakeValue(el::Value(item.second.c_str())); + text_node->EmplaceValue(el::Value(item.second.c_str())); node->Add(text_node); items_node->Add(node); } @@ -321,10 +321,10 @@ struct ItemListElementNode : public ElementNode { for (auto& item : items) { auto node = ParseNode::Create("item"); auto id_node = ParseNode::Create("id"); - id_node->TakeValue(el::Value(item.id.c_str())); + id_node->EmplaceValue(el::Value(item.id.c_str())); node->Add(id_node); auto text_node = ParseNode::Create("text"); - text_node->TakeValue(el::Value(item.text.c_str())); + text_node->EmplaceValue(el::Value(item.text.c_str())); node->Add(text_node); items_node->Add(node); } diff --git a/src/el/parsing/parse_node.cc b/src/el/parsing/parse_node.cc index fb3d515..4164b37 100644 --- a/src/el/parsing/parse_node.cc +++ b/src/el/parsing/parse_node.cc @@ -231,6 +231,8 @@ class ParseNodeTarget : public TextParserTarget { void ParseNode::TakeValue(Value& value) { m_value.TakeOver(value); } +void ParseNode::EmplaceValue(Value value) { m_value.TakeOver(value); } + bool ParseNode::ReadFile(const std::string& filename, ReadFlags flags) { if (!any(flags & ReadFlags::kAppend)) { Clear(); diff --git a/src/el/parsing/parse_node.h b/src/el/parsing/parse_node.h index da7353c..2c69761 100644 --- a/src/el/parsing/parse_node.h +++ b/src/el/parsing/parse_node.h @@ -42,6 +42,7 @@ class ParseNode : public util::IntrusiveListEntry { static ParseNode* Create(const char* name); void TakeValue(Value& value); + void EmplaceValue(Value value); // Reads a tree of nodes from file into this node. // Returns true on success. diff --git a/src/el/parsing/text_parser_stream.cc b/src/el/parsing/text_parser_stream.cc index bc21388..2c9fc68 100644 --- a/src/el/parsing/text_parser_stream.cc +++ b/src/el/parsing/text_parser_stream.cc @@ -7,6 +7,8 @@ ****************************************************************************** */ +#include + #include "el/io/file_manager.h" #include "el/parsing/text_parser_stream.h" diff --git a/src/el/text/caret.cc b/src/el/text/caret.cc index bd66948..9094d4f 100644 --- a/src/el/text/caret.cc +++ b/src/el/text/caret.cc @@ -118,13 +118,10 @@ bool Caret::Place(TextBlock* block, size_t ofs, bool allow_snap, ofs -= block->str_len; block = block->GetNext(); } - while (block->prev && ofs < 0ull) { + while (block->prev) { block = block->GetPrev(); ofs += block->str_len; } - if (ofs < 0ull) { - ofs = 0; - } if (ofs > block->str_len) { ofs = block->str_len; } diff --git a/src/el/text/font_face.cc b/src/el/text/font_face.cc index 24e7ff5..4aa914c 100644 --- a/src/el/text/font_face.cc +++ b/src/el/text/font_face.cc @@ -8,6 +8,7 @@ */ #include +#include #include #include "el/text/font_face.h" diff --git a/src/el/text/text_fragment.cc b/src/el/text/text_fragment.cc index f98a29d..7823c27 100644 --- a/src/el/text/text_fragment.cc +++ b/src/el/text/text_fragment.cc @@ -1,9 +1,9 @@ -/** +/** ****************************************************************************** * Elemental Forms : a lightweight user interface framework * ****************************************************************************** - * ©2015 Ben Vanik. All rights reserved. Released under the BSD license. * - * Portions ©2011-2015 Emil Segerås: https://github.com/fruxo/turbobadger * + * ©2015 Ben Vanik. All rights reserved. Released under the BSD license. * + * Portions ©2011-2015 Emil SegerÃ¥s: https://github.com/fruxo/turbobadger * ****************************************************************************** */ @@ -27,11 +27,11 @@ namespace text { const int TAB_SPACE = 4; -const char* special_char_newln = "¶"; // 00B6 PILCROW SIGN -const char* special_char_space = "·"; // 00B7 MIDDLE DOT +const char* special_char_newln = "¶"; // 00B6 PILCROW SIGN +const char* special_char_space = "·"; // 00B7 MIDDLE DOT const char* special_char_tab = - "»"; // 00BB RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK -const char* special_char_password = "•"; // 2022 BULLET + "»"; // 00BB RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK +const char* special_char_password = "•"; // 2022 BULLET // Checks if no line wrapping is allowed before the character at the given // offset. The string must be null terminated. diff --git a/src/el/text/text_fragment_content.cc b/src/el/text/text_fragment_content.cc index 4e0e848..ace7b10 100644 --- a/src/el/text/text_fragment_content.cc +++ b/src/el/text/text_fragment_content.cc @@ -32,11 +32,11 @@ TextFragmentContent* TextFragmentContentFactory::CreateFragmentContent( return new TextFragmentContentHR(100, 2); } else if (strncmp(text, "", text_len) == 0) { return new TextFragmentContentUnderline(); - } else if (strncmp(text, "