| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "tools/gn/visibility.h" | 5 #include "tools/gn/visibility.h" |
| 6 | 6 |
| 7 #include "base/strings/string_piece.h" | 7 #include "base/strings/string_piece.h" |
| 8 #include "base/strings/string_util.h" | 8 #include "base/strings/string_util.h" |
| 9 #include "tools/gn/err.h" | 9 #include "tools/gn/err.h" |
| 10 #include "tools/gn/filesystem_utils.h" | 10 #include "tools/gn/filesystem_utils.h" |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 71 const std::vector<Value>& list = value.list_value(); | 71 const std::vector<Value>& list = value.list_value(); |
| 72 for (size_t i = 0; i < list.size(); i++) { | 72 for (size_t i = 0; i < list.size(); i++) { |
| 73 patterns_.push_back(GetPattern(current_dir, list[i], err)); | 73 patterns_.push_back(GetPattern(current_dir, list[i], err)); |
| 74 if (err->has_error()) | 74 if (err->has_error()) |
| 75 return false; | 75 return false; |
| 76 } | 76 } |
| 77 return true; | 77 return true; |
| 78 } | 78 } |
| 79 | 79 |
| 80 void Visibility::SetPublic() { | 80 void Visibility::SetPublic() { |
| 81 patterns_.clear(); | |
| 82 patterns_.push_back( | 81 patterns_.push_back( |
| 83 VisPattern(VisPattern::RECURSIVE_DIRECTORY, SourceDir(), std::string())); | 82 VisPattern(VisPattern::RECURSIVE_DIRECTORY, SourceDir(), std::string())); |
| 84 } | 83 } |
| 85 | 84 |
| 86 void Visibility::SetPrivate(const SourceDir& current_dir) { | 85 void Visibility::SetPrivate(const SourceDir& current_dir) { |
| 87 patterns_.clear(); | |
| 88 patterns_.push_back( | 86 patterns_.push_back( |
| 89 VisPattern(VisPattern::DIRECTORY, current_dir, std::string())); | 87 VisPattern(VisPattern::DIRECTORY, current_dir, std::string())); |
| 90 } | 88 } |
| 91 | 89 |
| 92 bool Visibility::CanSeeMe(const Label& label) const { | 90 bool Visibility::CanSeeMe(const Label& label) const { |
| 93 for (size_t i = 0; i < patterns_.size(); i++) { | 91 for (size_t i = 0; i < patterns_.size(); i++) { |
| 94 if (patterns_[i].Matches(label)) | 92 if (patterns_[i].Matches(label)) |
| 95 return true; | 93 return true; |
| 96 } | 94 } |
| 97 return false; | 95 return false; |
| (...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 252 | 250 |
| 253 // static | 251 // static |
| 254 bool Visibility::FillItemVisibility(Item* item, Scope* scope, Err* err) { | 252 bool Visibility::FillItemVisibility(Item* item, Scope* scope, Err* err) { |
| 255 const Value* vis_value = scope->GetValue(variables::kVisibility, true); | 253 const Value* vis_value = scope->GetValue(variables::kVisibility, true); |
| 256 if (vis_value) | 254 if (vis_value) |
| 257 item->visibility().Set(scope->GetSourceDir(), *vis_value, err); | 255 item->visibility().Set(scope->GetSourceDir(), *vis_value, err); |
| 258 else // Default to public. | 256 else // Default to public. |
| 259 item->visibility().SetPublic(); | 257 item->visibility().SetPublic(); |
| 260 return !err->has_error(); | 258 return !err->has_error(); |
| 261 } | 259 } |
| OLD | NEW |