[Android WebViewShell] Add inclusion test for webview exposed stable interfaces.
[chromium-blink-merge.git] / tools / gn / substitution_list.cc
bloba5bd30bf647c65277fe6d8dc209788ed22a7bec4
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
3 // found in the LICENSE file.
5 #include "tools/gn/substitution_list.h"
7 #include <string.h>
9 #include "tools/gn/value.h"
11 SubstitutionList::SubstitutionList() {
14 SubstitutionList::~SubstitutionList() {
17 bool SubstitutionList::Parse(const Value& value, Err* err) {
18 if (!value.VerifyTypeIs(Value::LIST, err))
19 return false;
21 const std::vector<Value>& input_list = value.list_value();
22 list_.resize(input_list.size());
23 for (size_t i = 0; i < input_list.size(); i++) {
24 if (!list_[i].Parse(input_list[i], err))
25 return false;
28 SubstitutionBits bits;
29 FillRequiredTypes(&bits);
30 bits.FillVector(&required_types_);
31 return true;
34 bool SubstitutionList::Parse(const std::vector<std::string>& values,
35 const ParseNode* origin,
36 Err* err) {
37 list_.resize(values.size());
38 for (size_t i = 0; i < values.size(); i++) {
39 if (!list_[i].Parse(values[i], origin, err))
40 return false;
43 SubstitutionBits bits;
44 FillRequiredTypes(&bits);
45 bits.FillVector(&required_types_);
46 return true;
49 SubstitutionList SubstitutionList::MakeForTest(
50 const char* a,
51 const char* b,
52 const char* c) {
53 std::vector<std::string> input_strings;
54 input_strings.push_back(a);
55 if (b)
56 input_strings.push_back(b);
57 if (c)
58 input_strings.push_back(c);
60 Err err;
61 SubstitutionList result;
62 result.Parse(input_strings, nullptr, &err);
63 return result;
66 void SubstitutionList::FillRequiredTypes(SubstitutionBits* bits) const {
67 for (const auto& item : list_)
68 item.FillRequiredTypes(bits);