OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/json_schema_compiler/util.h" | 5 #include "tools/json_schema_compiler/util.h" |
6 | 6 |
7 #include "base/strings/utf_string_conversions.h" | 7 #include "base/strings/utf_string_conversions.h" |
8 #include "base/values.h" | 8 #include "base/values.h" |
9 | 9 |
10 namespace json_schema_compiler { | 10 namespace json_schema_compiler { |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
131 } | 131 } |
132 error->append(base::UTF8ToUTF16("expected dictionary, got " + | 132 error->append(base::UTF8ToUTF16("expected dictionary, got " + |
133 ValueTypeToString(from.GetType()))); | 133 ValueTypeToString(from.GetType()))); |
134 return false; | 134 return false; |
135 } | 135 } |
136 *out = dict->CreateDeepCopy(); | 136 *out = dict->CreateDeepCopy(); |
137 return true; | 137 return true; |
138 } | 138 } |
139 | 139 |
140 void AddItemToList(const int from, base::ListValue* out) { | 140 void AddItemToList(const int from, base::ListValue* out) { |
141 out->Append(new base::FundamentalValue(from)); | 141 out->AppendInteger(from); |
142 } | 142 } |
143 | 143 |
144 void AddItemToList(const bool from, base::ListValue* out) { | 144 void AddItemToList(const bool from, base::ListValue* out) { |
145 out->Append(new base::FundamentalValue(from)); | 145 out->AppendBoolean(from); |
146 } | 146 } |
147 | 147 |
148 void AddItemToList(const double from, base::ListValue* out) { | 148 void AddItemToList(const double from, base::ListValue* out) { |
149 out->Append(new base::FundamentalValue(from)); | 149 out->AppendDouble(from); |
150 } | 150 } |
151 | 151 |
152 void AddItemToList(const std::string& from, base::ListValue* out) { | 152 void AddItemToList(const std::string& from, base::ListValue* out) { |
153 out->Append(new base::StringValue(from)); | 153 out->AppendString(from); |
154 } | 154 } |
155 | 155 |
156 void AddItemToList(const std::vector<char>& from, base::ListValue* out) { | 156 void AddItemToList(const std::vector<char>& from, base::ListValue* out) { |
157 out->Append( | 157 out->Append( |
158 base::BinaryValue::CreateWithCopiedBuffer(from.data(), from.size())); | 158 base::BinaryValue::CreateWithCopiedBuffer(from.data(), from.size())); |
159 } | 159 } |
160 | 160 |
161 void AddItemToList(const std::unique_ptr<base::Value>& from, | 161 void AddItemToList(const std::unique_ptr<base::Value>& from, |
162 base::ListValue* out) { | 162 base::ListValue* out) { |
163 out->Append(from->CreateDeepCopy()); | 163 out->Append(from->CreateDeepCopy()); |
(...skipping 22 matching lines...) Expand all Loading... |
186 return "dictionary"; | 186 return "dictionary"; |
187 case base::Value::TYPE_LIST: | 187 case base::Value::TYPE_LIST: |
188 return "list"; | 188 return "list"; |
189 } | 189 } |
190 NOTREACHED(); | 190 NOTREACHED(); |
191 return ""; | 191 return ""; |
192 } | 192 } |
193 | 193 |
194 } // namespace util | 194 } // namespace util |
195 } // namespace json_schema_compiler | 195 } // namespace json_schema_compiler |
OLD | NEW |