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

Unified Diff: tools/json_schema_compiler/cc_generator.py

Issue 2816513002: Revert of Change base::Value::ListStorage to std::vector<base::Value> (Closed)
Patch Set: Created 3 years, 8 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/commands.cc ('k') | tools/json_schema_compiler/util.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/json_schema_compiler/cc_generator.py
diff --git a/tools/json_schema_compiler/cc_generator.py b/tools/json_schema_compiler/cc_generator.py
index 0cde6cab3193639e7fdc2d5bf7041cfbebf71ac2..aa22ea1b4072d66a12b1efe56f580397056ae518 100644
--- a/tools/json_schema_compiler/cc_generator.py
+++ b/tools/json_schema_compiler/cc_generator.py
@@ -947,8 +947,7 @@
.Concat(self._GenerateStringToEnumConversion(item_type,
'(it)',
'tmp',
- failure_value,
- is_ptr=False))
+ failure_value))
.Append('%s%spush_back(tmp);' % (dst_var, accessor))
.Eblock('}')
)
@@ -958,8 +957,7 @@
type_,
src_var,
dst_var,
- failure_value,
- is_ptr=True):
+ failure_value):
"""Returns Code that converts a string type in |src_var| to an enum with
type |type_| in |dst_var|. In the generated code, if |src_var| is not
a valid enum name then the function will return |failure_value|.
@@ -971,14 +969,11 @@
cpp_type_namespace = ''
if type_.namespace != self._namespace:
cpp_type_namespace = '%s::' % type_.namespace.unix_name
- accessor = '->' if is_ptr else '.'
(c.Append('std::string %s;' % enum_as_string)
- .Sblock('if (!%s%sGetAsString(&%s)) {' % (src_var,
- accessor,
- enum_as_string))
+ .Sblock('if (!%s->GetAsString(&%s)) {' % (src_var, enum_as_string))
.Concat(self._GenerateError(
'"\'%%(key)s\': expected string, got " + ' +
- self._util_cc_helper.GetValueTypeString('%%(src_var)s', is_ptr)))
+ self._util_cc_helper.GetValueTypeString('%%(src_var)s', True)))
.Append('return %s;' % failure_value)
.Eblock('}')
.Append('%s = %sParse%s(%s);' % (dst_var,
« no previous file with comments | « tools/gn/commands.cc ('k') | tools/json_schema_compiler/util.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698