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 #ifndef TOOLS_GN_VISIBILITY_H_ | 5 #ifndef TOOLS_GN_VISIBILITY_H_ |
6 #define TOOLS_GN_VISIBILITY_H_ | 6 #define TOOLS_GN_VISIBILITY_H_ |
7 | 7 |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
61 // Sets the visibility to be public. | 61 // Sets the visibility to be public. |
62 void SetPublic(); | 62 void SetPublic(); |
63 | 63 |
64 // Sets the visibility to be private to the given directory. | 64 // Sets the visibility to be private to the given directory. |
65 void SetPrivate(const SourceDir& current_dir); | 65 void SetPrivate(const SourceDir& current_dir); |
66 | 66 |
67 // Returns true if the target with the given label can depend on one with the | 67 // Returns true if the target with the given label can depend on one with the |
68 // current visibility. | 68 // current visibility. |
69 bool CanSeeMe(const Label& label) const; | 69 bool CanSeeMe(const Label& label) const; |
70 | 70 |
71 // Returns a string listing the visibility. | 71 // Returns a string listing the visibility. |indent| number of spaces will |
72 std::string Describe() const; | 72 // be added on the left side of the output. If |include_brackets| is set, the |
| 73 // result will be wrapped in "[ ]" and the contents further indented. The |
| 74 // result will end in a newline. |
| 75 std::string Describe(int indent, bool include_brackets) const; |
73 | 76 |
74 // Converts the given input string to a pattern. This does special stuff | 77 // Converts the given input string to a pattern. This does special stuff |
75 // to treat the pattern as a label. Sets the error on failure. | 78 // to treat the pattern as a label. Sets the error on failure. |
76 static VisPattern GetPattern(const SourceDir& current_dir, | 79 static VisPattern GetPattern(const SourceDir& current_dir, |
77 const Value& value, | 80 const Value& value, |
78 Err* err); | 81 Err* err); |
79 | 82 |
80 // Helper function to check visibility between the given two items. If | 83 // Helper function to check visibility between the given two items. If |
81 // to is invisible to from, returns false and sets the error. | 84 // to is invisible to from, returns false and sets the error. |
82 static bool CheckItemVisibility(const Item* from, const Item* to, Err* err); | 85 static bool CheckItemVisibility(const Item* from, const Item* to, Err* err); |
83 | 86 |
84 // Helper function to fill an item's visibility from the "visibility" value | 87 // Helper function to fill an item's visibility from the "visibility" value |
85 // in the current scope. | 88 // in the current scope. |
86 static bool FillItemVisibility(Item* item, Scope* scope, Err* err); | 89 static bool FillItemVisibility(Item* item, Scope* scope, Err* err); |
87 | 90 |
88 private: | 91 private: |
89 std::vector<VisPattern> patterns_; | 92 std::vector<VisPattern> patterns_; |
90 | 93 |
91 DISALLOW_COPY_AND_ASSIGN(Visibility); | 94 DISALLOW_COPY_AND_ASSIGN(Visibility); |
92 }; | 95 }; |
93 | 96 |
94 #endif // TOOLS_GN_VISIBILITY_H_ | 97 #endif // TOOLS_GN_VISIBILITY_H_ |
OLD | NEW |