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

Side by Side Diff: tools/gn/substitution_list.cc

Issue 440333002: Support more configurability in GN toolchains (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: unsigned check 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « tools/gn/substitution_list.h ('k') | tools/gn/substitution_pattern.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/substitution_list.h" 5 #include "tools/gn/substitution_list.h"
6 6
7 #include <string.h> 7 #include <string.h>
8 8
9 #include "tools/gn/value.h" 9 #include "tools/gn/value.h"
10 10
11 SubstitutionList::SubstitutionList() { 11 SubstitutionList::SubstitutionList() {
12 } 12 }
13 13
14 SubstitutionList::~SubstitutionList() { 14 SubstitutionList::~SubstitutionList() {
15 } 15 }
16 16
17 bool SubstitutionList::Parse(const Value& value, Err* err) { 17 bool SubstitutionList::Parse(const Value& value, Err* err) {
18 if (!value.VerifyTypeIs(Value::LIST, err)) 18 if (!value.VerifyTypeIs(Value::LIST, err))
19 return false; 19 return false;
20 20
21 const std::vector<Value>& input_list = value.list_value(); 21 const std::vector<Value>& input_list = value.list_value();
22 list_.resize(input_list.size()); 22 list_.resize(input_list.size());
23 for (size_t i = 0; i < input_list.size(); i++) { 23 for (size_t i = 0; i < input_list.size(); i++) {
24 if (!list_[i].Parse(input_list[i], err)) 24 if (!list_[i].Parse(input_list[i], err))
25 return false; 25 return false;
26 } 26 }
27 27
28 FillRequiredTypes(); 28 SubstitutionBits bits;
29 FillRequiredTypes(&bits);
30 bits.FillVector(&required_types_);
29 return true; 31 return true;
30 } 32 }
31 33
32 bool SubstitutionList::Parse(const std::vector<std::string>& values, 34 bool SubstitutionList::Parse(const std::vector<std::string>& values,
33 const ParseNode* origin, 35 const ParseNode* origin,
34 Err* err) { 36 Err* err) {
35 list_.resize(values.size()); 37 list_.resize(values.size());
36 for (size_t i = 0; i < values.size(); i++) { 38 for (size_t i = 0; i < values.size(); i++) {
37 if (!list_[i].Parse(values[i], origin, err)) 39 if (!list_[i].Parse(values[i], origin, err))
38 return false; 40 return false;
39 } 41 }
40 42
41 FillRequiredTypes(); 43 SubstitutionBits bits;
44 FillRequiredTypes(&bits);
45 bits.FillVector(&required_types_);
42 return true; 46 return true;
43 } 47 }
44 48
45 SubstitutionList SubstitutionList::MakeForTest( 49 SubstitutionList SubstitutionList::MakeForTest(
46 const char* a, 50 const char* a,
47 const char* b, 51 const char* b,
48 const char* c) { 52 const char* c) {
49 std::vector<std::string> input_strings; 53 std::vector<std::string> input_strings;
50 input_strings.push_back(a); 54 input_strings.push_back(a);
51 if (b) 55 if (b)
52 input_strings.push_back(b); 56 input_strings.push_back(b);
53 if (c) 57 if (c)
54 input_strings.push_back(c); 58 input_strings.push_back(c);
55 59
56 Err err; 60 Err err;
57 SubstitutionList result; 61 SubstitutionList result;
58 result.Parse(input_strings, NULL, &err); 62 result.Parse(input_strings, NULL, &err);
59 return result; 63 return result;
60 } 64 }
61 65
62 void SubstitutionList::FillRequiredTypes() { 66 void SubstitutionList::FillRequiredTypes(SubstitutionBits* bits) const {
63 bool required_type_bits[SUBSTITUTION_NUM_TYPES];
64 memset(&required_type_bits, 0, SUBSTITUTION_NUM_TYPES);
65 for (size_t i = 0; i < list_.size(); i++) 67 for (size_t i = 0; i < list_.size(); i++)
66 list_[i].FillRequiredTypes(required_type_bits); 68 list_[i].FillRequiredTypes(bits);
67
68 for (size_t i = SUBSTITUTION_FIRST_PATTERN; i < SUBSTITUTION_NUM_TYPES; i++) {
69 if (required_type_bits[i])
70 required_types_.push_back(static_cast<SubstitutionType>(i));
71 }
72 } 69 }
OLDNEW
« no previous file with comments | « tools/gn/substitution_list.h ('k') | tools/gn/substitution_pattern.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698