Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(60)

Unified Diff: tools/gn/value_extractors.h

Issue 26537002: Add a UniqueVector class to GN (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: REview comments, remove npos Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « tools/gn/unique_vector_unittest.cc ('k') | tools/gn/value_extractors.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/gn/value_extractors.h
diff --git a/tools/gn/value_extractors.h b/tools/gn/value_extractors.h
index 38c89ab4957633d3b35315e36a3e023c3d2ea08c..afda1d687883340ec68a995d628bed91896f7ff1 100644
--- a/tools/gn/value_extractors.h
+++ b/tools/gn/value_extractors.h
@@ -8,30 +8,15 @@
#include <string>
#include <vector>
-#include "tools/gn/target.h"
-#include "tools/gn/value.h"
+#include "tools/gn/label_ptr.h"
+#include "tools/gn/unique_vector.h"
class BuildSettings;
class Err;
class Label;
class SourceDir;
class SourceFile;
-
-// Sets the error and returns false on failure.
-template<typename T, class Converter>
-bool ListValueExtractor(const Value& value, std::vector<T>* dest,
- Err* err,
- const Converter& converter) {
- if (!value.VerifyTypeIs(Value::LIST, err))
- return false;
- const std::vector<Value>& input_list = value.list_value();
- dest->resize(input_list.size());
- for (size_t i = 0; i < input_list.size(); i++) {
- if (!converter(input_list[i], &(*dest)[i], err))
- return false;
- }
- return true;
-}
+class Value;
// On failure, returns false and sets the error.
bool ExtractListOfStringValues(const Value& value,
@@ -57,14 +42,23 @@ bool ExtractListOfRelativeDirs(const BuildSettings* build_settings,
bool ExtractListOfLabels(const Value& value,
const SourceDir& current_dir,
const Label& current_toolchain,
- LabelConfigVector* dest,
- Err* err);
-bool ExtractListOfLabels(const Value& value,
- const SourceDir& current_dir,
- const Label& current_toolchain,
LabelTargetVector* dest,
Err* err);
+// Extracts the list of labels and their origins to the given vector. Only the
+// labels are filled in, the ptr for each pair in the vector will be null. Sets
+// an error and returns false if a label is maformed or there are duplicates.
+bool ExtractListOfUniqueLabels(const Value& value,
+ const SourceDir& current_dir,
+ const Label& current_toolchain,
+ UniqueVector<LabelConfigPair>* dest,
+ Err* err);
+bool ExtractListOfUniqueLabels(const Value& value,
+ const SourceDir& current_dir,
+ const Label& current_toolchain,
+ UniqueVector<LabelTargetPair>* dest,
+ Err* err);
+
bool ExtractRelativeFile(const BuildSettings* build_settings,
const Value& value,
const SourceDir& current_dir,
« no previous file with comments | « tools/gn/unique_vector_unittest.cc ('k') | tools/gn/value_extractors.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698