Pass -Wshadow (#97)

Requested from:
https://github.com/robinlinden/hastur/pull/12
This commit is contained in:
Arthur Sonzogni 2021-05-16 17:18:11 +02:00 committed by GitHub
parent cf4fdf257e
commit a574a6c3ee
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
16 changed files with 59 additions and 56 deletions

View File

@ -158,6 +158,7 @@ foreach(lib screen dom component)
target_compile_options(${lib} PRIVATE "-Werror")
target_compile_options(${lib} PRIVATE "-Wmissing-declarations")
target_compile_options(${lib} PRIVATE "-Wdeprecated")
target_compile_options(${lib} PRIVATE "-Wshadow-all")
endif()
endforeach()

View File

@ -35,9 +35,9 @@ class Node {
// Step 3: Draw this element.
virtual void Render(Screen& screen);
std::vector<Element> children;
protected:
std::vector<Element> children_;
Requirement requirement_;
Box box_;
};

View File

@ -49,8 +49,8 @@ RadioboxBase* RadioboxBase::From(Component component) {
}
RadioboxBase::RadioboxBase(const std::vector<std::wstring>* entries,
int* selected_)
: entries_(entries), selected_(selected_) {}
int* selected)
: entries_(entries), selected_(selected) {}
Element RadioboxBase::Render() {
std::vector<Element> elements;

View File

@ -44,7 +44,7 @@ class TerminalInputParser {
CursorReporting cursor;
};
Output(Type type) : type(type) {}
Output(Type t) : type(t) {}
};
void Send(Output type);

View File

@ -29,12 +29,12 @@ class Border : public Node {
void ComputeRequirement() override {
Node::ComputeRequirement();
requirement_ = children[0]->requirement();
requirement_ = children_[0]->requirement();
requirement_.min_x += 2;
requirement_.min_y += 2;
if (children.size() == 2) {
if (children_.size() == 2) {
requirement_.min_x =
std::max(requirement_.min_x, children[1]->requirement().min_x + 2);
std::max(requirement_.min_x, children_[1]->requirement().min_x + 2);
}
requirement_.selected_box.x_min++;
requirement_.selected_box.x_max++;
@ -44,24 +44,24 @@ class Border : public Node {
void SetBox(Box box) override {
Node::SetBox(box);
if (children.size() == 2) {
if (children_.size() == 2) {
Box title_box;
title_box.x_min = box.x_min + 1;
title_box.x_max = box.x_max - 1;
title_box.y_min = box.y_min;
title_box.y_max = box.y_min;
children[1]->SetBox(title_box);
children_[1]->SetBox(title_box);
}
box.x_min++;
box.x_max--;
box.y_min++;
box.y_max--;
children[0]->SetBox(box);
children_[0]->SetBox(box);
}
void Render(Screen& screen) override {
// Draw content.
children[0]->Render(screen);
children_[0]->Render(screen);
// Draw the border.
if (box_.x_min >= box_.x_max || box_.y_min >= box_.y_max)
@ -88,8 +88,8 @@ class Border : public Node {
}
// Draw title.
if (children.size() == 2)
children[1]->Render(screen);
if (children_.size() == 2)
children_[1]->Render(screen);
}
void RenderChar(Screen& screen) {

View File

@ -22,7 +22,7 @@ class DBox : public Node {
requirement_.flex_grow_y = 0;
requirement_.flex_shrink_x = 0;
requirement_.flex_shrink_y = 0;
for (auto& child : children) {
for (auto& child : children_) {
child->ComputeRequirement();
requirement_.min_x =
std::max(requirement_.min_x, child->requirement().min_x);
@ -39,17 +39,17 @@ class DBox : public Node {
void SetBox(Box box) override {
Node::SetBox(box);
for (auto& child : children)
for (auto& child : children_)
child->SetBox(box);
}
};
/// @brief Stack several element on top of each other.
/// @param children The input element.
/// @param children_ The input element.
/// @return The right aligned element.
/// @ingroup dom
Element dbox(Elements children) {
return std::make_shared<DBox>(std::move(children));
Element dbox(Elements children_) {
return std::make_shared<DBox>(std::move(children_));
}
} // namespace ftxui

View File

@ -73,17 +73,17 @@ class Flex : public Node {
void ComputeRequirement() override {
requirement_.min_x = 0;
requirement_.min_y = 0;
if (!children.empty()) {
children[0]->ComputeRequirement();
requirement_ = children[0]->requirement();
if (!children_.empty()) {
children_[0]->ComputeRequirement();
requirement_ = children_[0]->requirement();
}
f_(requirement_);
}
void SetBox(Box box) override {
if (children.empty())
if (children_.empty())
return;
children[0]->SetBox(box);
children_[0]->SetBox(box);
}
FlexFunction f_;

View File

@ -21,7 +21,7 @@ class Select : public Node {
void ComputeRequirement() override {
Node::ComputeRequirement();
requirement_ = children[0]->requirement();
requirement_ = children_[0]->requirement();
auto& selected_box = requirement_.selected_box;
selected_box.x_min = 0;
selected_box.y_min = 0;
@ -32,7 +32,7 @@ class Select : public Node {
void SetBox(Box box) override {
box_ = box;
children[0]->SetBox(box);
children_[0]->SetBox(box);
}
};
@ -70,7 +70,7 @@ class Frame : public Node {
void ComputeRequirement() override {
Node::ComputeRequirement();
requirement_ = children[0]->requirement();
requirement_ = children_[0]->requirement();
}
void SetBox(Box box) override {
@ -98,13 +98,13 @@ class Frame : public Node {
children_box.y_max = box.y_min + internal_dimy - dy;
}
children[0]->SetBox(children_box);
children_[0]->SetBox(children_box);
}
void Render(Screen& screen) override {
AutoReset<Box> stencil(&screen.stencil,
Box::Intersection(box_, screen.stencil));
children[0]->Render(screen);
children_[0]->Render(screen);
}
private:

View File

@ -22,7 +22,7 @@ class HBox : public Node {
requirement_.flex_grow_y = 0;
requirement_.flex_shrink_x = 0;
requirement_.flex_shrink_y = 0;
for (auto& child : children) {
for (auto& child : children_) {
child->ComputeRequirement();
if (requirement_.selection < child->requirement().selection) {
requirement_.selection = child->requirement().selection;
@ -46,7 +46,7 @@ class HBox : public Node {
int flex_grow_sum = 0;
int flex_shrink_sum = 0;
int flex_shrink_size = 0;
for (auto& child : children) {
for (auto& child : children_) {
const Requirement& r = child->requirement();
flex_grow_sum += r.flex_grow_x;
flex_shrink_sum += r.min_x * r.flex_shrink_x;
@ -67,7 +67,7 @@ class HBox : public Node {
void SetBoxGrow(Box box, int extra_space, int flex_grow_sum) {
int x = box.x_min;
for (auto& child : children) {
for (auto& child : children_) {
Box child_box = box;
const Requirement& r = child->requirement();
@ -86,7 +86,7 @@ class HBox : public Node {
void SetBoxShrinkEasy(Box box, int extra_space, int flex_shrink_sum) {
int x = box.x_min;
for (auto& child : children) {
for (auto& child : children_) {
Box child_box = box;
const Requirement& r = child->requirement();
@ -105,7 +105,7 @@ class HBox : public Node {
void SetBoxShrinkHard(Box box, int extra_space, int size) {
int x = box.x_min;
for (auto& child : children) {
for (auto& child : children_) {
Box child_box = box;
const Requirement& r = child->requirement();

View File

@ -22,7 +22,7 @@ class HFlow : public Node {
requirement_.flex_grow_y = 1;
requirement_.flex_shrink_x = 0;
requirement_.flex_shrink_y = 0;
for (auto& child : children)
for (auto& child : children_)
child->ComputeRequirement();
}
@ -34,7 +34,7 @@ class HFlow : public Node {
int y = box.y_min;
int y_next = y; // The position of next row of elements.
for (auto& child : children) {
for (auto& child : children_) {
Requirement requirement = child->requirement();
// Does it fit the end of the row?

View File

@ -8,13 +8,13 @@ namespace ftxui {
using ftxui::Screen;
Node::Node() {}
Node::Node(Elements children) : children(std::move(children)) {}
Node::Node(Elements children) : children_(std::move(children)) {}
Node::~Node() {}
/// @brief Compute how much space an elements needs.
/// @ingroup dom
void Node::ComputeRequirement() {
for (auto& child : children)
for (auto& child : children_)
child->ComputeRequirement();
}
@ -27,7 +27,7 @@ void Node::SetBox(Box box) {
/// @brief Display an element on a ftxui::Screen.
/// @ingroup dom
void Node::Render(Screen& screen) {
for (auto& child : children)
for (auto& child : children_)
child->Render(screen);
}

View File

@ -9,12 +9,12 @@ namespace ftxui {
void NodeDecorator::ComputeRequirement() {
Node::ComputeRequirement();
requirement_ = children[0]->requirement();
requirement_ = children_[0]->requirement();
}
void NodeDecorator::SetBox(Box box) {
Node::SetBox(box);
children[0]->SetBox(box);
children_[0]->SetBox(box);
}
} // namespace ftxui

View File

@ -13,22 +13,22 @@ namespace ftxui {
class Reflect : public Node {
public:
Reflect(Element child, Box& box)
: Node(unpack(std::move(child))), box_(box) {}
: Node(unpack(std::move(child))), reflected_box_(box) {}
~Reflect() override {}
void ComputeRequirement() final {
Node::ComputeRequirement();
requirement_ = children[0]->requirement();
requirement_ = children_[0]->requirement();
}
void SetBox(Box box) final {
box_ = box;
Node::SetBox(box_);
children[0]->SetBox(box_);
reflected_box_ = box;
Node::SetBox(reflected_box_);
children_[0]->SetBox(reflected_box_);
}
private:
Box& box_;
Box& reflected_box_;
};
Decorator reflect(Box& box) {

View File

@ -45,10 +45,12 @@ class Separator : public Node {
class SeparatorWithPixel : public Separator {
public:
SeparatorWithPixel(Pixel p) : p(p) {}
SeparatorWithPixel(Pixel pixel) : pixel_(pixel) {}
~SeparatorWithPixel() override {}
void Render(Screen& screen) override { RenderWithPixel(screen, p); }
Pixel p;
void Render(Screen& screen) override { RenderWithPixel(screen, pixel_); }
private:
Pixel pixel_;
};
Element separator() {

View File

@ -23,7 +23,7 @@ class Size : public Node {
void ComputeRequirement() override {
Node::ComputeRequirement();
requirement_ = children[0]->requirement();
requirement_ = children_[0]->requirement();
auto& value = direction_ == WIDTH ? requirement_.min_x : requirement_.min_y;
@ -70,7 +70,7 @@ class Size : public Node {
break;
}
}
children[0]->SetBox(box);
children_[0]->SetBox(box);
}
private:

View File

@ -22,7 +22,7 @@ class VBox : public Node {
requirement_.flex_grow_y = 0;
requirement_.flex_shrink_x = 0;
requirement_.flex_shrink_y = 0;
for (auto& child : children) {
for (auto& child : children_) {
child->ComputeRequirement();
if (requirement_.selection < child->requirement().selection) {
requirement_.selection = child->requirement().selection;
@ -46,7 +46,7 @@ class VBox : public Node {
int flex_grow_sum = 0;
int flex_shrink_sum = 0;
int flex_shrink_size = 0;
for (auto& child : children) {
for (auto& child : children_) {
const Requirement& r = child->requirement();
flex_grow_sum += r.flex_grow_y;
flex_shrink_sum += r.min_y * r.flex_shrink_y;
@ -67,7 +67,7 @@ class VBox : public Node {
void SetBoxGrow(Box box, int extra_space, int flex_grow_sum) {
int y = box.y_min;
for (auto& child : children) {
for (auto& child : children_) {
Box child_box = box;
const Requirement& r = child->requirement();
@ -86,7 +86,7 @@ class VBox : public Node {
void SetBoxShrinkEasy(Box box, int extra_space, int flex_shrink_sum) {
int y = box.y_min;
for (auto& child : children) {
for (auto& child : children_) {
Box child_box = box;
const Requirement& r = child->requirement();
@ -105,7 +105,7 @@ class VBox : public Node {
void SetBoxShrinkHard(Box box, int extra_space, int size) {
int y = box.y_min;
for (auto& child : children) {
for (auto& child : children_) {
Box child_box = box;
const Requirement& r = child->requirement();