| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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/value_extractors.h" | 5 #include "tools/gn/value_extractors.h" |
| 6 | 6 |
| 7 #include "tools/gn/build_settings.h" | 7 #include "tools/gn/build_settings.h" |
| 8 #include "tools/gn/err.h" | 8 #include "tools/gn/err.h" |
| 9 #include "tools/gn/label.h" | 9 #include "tools/gn/label.h" |
| 10 #include "tools/gn/source_dir.h" | 10 #include "tools/gn/source_dir.h" |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 48 if (!v.VerifyTypeIs(Value::STRING, err)) | 48 if (!v.VerifyTypeIs(Value::STRING, err)) |
| 49 return false; | 49 return false; |
| 50 *out = current_dir.ResolveRelativeDir(v.string_value(), | 50 *out = current_dir.ResolveRelativeDir(v.string_value(), |
| 51 build_settings->root_path_utf8()); | 51 build_settings->root_path_utf8()); |
| 52 return true; | 52 return true; |
| 53 } | 53 } |
| 54 const BuildSettings* build_settings; | 54 const BuildSettings* build_settings; |
| 55 const SourceDir& current_dir; | 55 const SourceDir& current_dir; |
| 56 }; | 56 }; |
| 57 | 57 |
| 58 struct LabelResolver { | 58 // Fills the label part of a LabelPtrPair, leaving the pointer null. |
| 59 template<typename T> struct LabelResolver { |
| 59 LabelResolver(const SourceDir& current_dir_in, | 60 LabelResolver(const SourceDir& current_dir_in, |
| 60 const Label& current_toolchain_in) | 61 const Label& current_toolchain_in) |
| 61 : current_dir(current_dir_in), | 62 : current_dir(current_dir_in), |
| 62 current_toolchain(current_toolchain_in) {} | 63 current_toolchain(current_toolchain_in) {} |
| 63 bool operator()(const Value& v, Label* out, Err* err) const { | 64 bool operator()(const Value& v, LabelPtrPair<T>* out, Err* err) const { |
| 64 if (!v.VerifyTypeIs(Value::STRING, err)) | 65 if (!v.VerifyTypeIs(Value::STRING, err)) |
| 65 return false; | 66 return false; |
| 66 *out = Label::Resolve(current_dir, current_toolchain, v, err); | 67 out->label = Label::Resolve(current_dir, current_toolchain, v, err); |
| 68 out->origin = v.origin(); |
| 67 return !err->has_error(); | 69 return !err->has_error(); |
| 68 } | 70 } |
| 69 const SourceDir& current_dir; | 71 const SourceDir& current_dir; |
| 70 const Label& current_toolchain; | 72 const Label& current_toolchain; |
| 71 }; | 73 }; |
| 72 | 74 |
| 73 } // namespace | 75 } // namespace |
| 74 | 76 |
| 75 bool ExtractListOfStringValues(const Value& value, | 77 bool ExtractListOfStringValues(const Value& value, |
| 76 std::vector<std::string>* dest, | 78 std::vector<std::string>* dest, |
| (...skipping 24 matching lines...) Expand all Loading... |
| 101 const SourceDir& current_dir, | 103 const SourceDir& current_dir, |
| 102 std::vector<SourceDir>* dest, | 104 std::vector<SourceDir>* dest, |
| 103 Err* err) { | 105 Err* err) { |
| 104 return ListValueExtractor(value, dest, err, | 106 return ListValueExtractor(value, dest, err, |
| 105 RelativeDirConverter(build_settings, current_dir)); | 107 RelativeDirConverter(build_settings, current_dir)); |
| 106 } | 108 } |
| 107 | 109 |
| 108 bool ExtractListOfLabels(const Value& value, | 110 bool ExtractListOfLabels(const Value& value, |
| 109 const SourceDir& current_dir, | 111 const SourceDir& current_dir, |
| 110 const Label& current_toolchain, | 112 const Label& current_toolchain, |
| 111 std::vector<Label>* dest, | 113 LabelConfigVector* dest, |
| 112 Err* err) { | 114 Err* err) { |
| 113 return ListValueExtractor(value, dest, err, | 115 return ListValueExtractor(value, dest, err, |
| 114 LabelResolver(current_dir, current_toolchain)); | 116 LabelResolver<Config>(current_dir, |
| 117 current_toolchain)); |
| 115 } | 118 } |
| 119 |
| 120 bool ExtractListOfLabels(const Value& value, |
| 121 const SourceDir& current_dir, |
| 122 const Label& current_toolchain, |
| 123 LabelTargetVector* dest, |
| 124 Err* err) { |
| 125 return ListValueExtractor(value, dest, err, |
| 126 LabelResolver<Target>(current_dir, |
| 127 current_toolchain)); |
| 128 } |
| OLD | NEW |