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

Unified Diff: tools/json_schema_compiler/util_cc_helper.py

Issue 276603003: Support converting referenced enum array into string. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix win compile error Created 6 years, 7 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/json_schema_compiler/util.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/json_schema_compiler/util_cc_helper.py
diff --git a/tools/json_schema_compiler/util_cc_helper.py b/tools/json_schema_compiler/util_cc_helper.py
index 864028364eece9787ba441fa9a846c845fe95e7b..0e41abfa12b06c7d0b96bde0c5cbe6c67f7790b7 100644
--- a/tools/json_schema_compiler/util_cc_helper.py
+++ b/tools/json_schema_compiler/util_cc_helper.py
@@ -2,9 +2,6 @@
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
-from model import PropertyType
-
-
_API_UTIL_NAMESPACE = 'json_schema_compiler::util'
@@ -55,30 +52,17 @@ class UtilCCHelper(object):
'dst': dst
}
- def CreateValueFromArray(self, cpp_namespace, type_, src, optional):
+ def CreateValueFromArray(self, src, optional):
"""Generates code to create a scoped_pt<Value> from the array at src.
- |cpp_namespace| The namespace which contains |type_|. This is needed for
- enum conversions, where the ToString method is on the containing
- namespace.
- |type_| The type of the values being converted. This is needed for enum
- conversions, to know whether to use the Enum form of conversion.
|src| The variable to convert, either a vector or scoped_ptr<vector>.
|optional| Whether |type_| was optional. Optional types are pointers so
must be treated differently.
"""
- if type_.item_type.property_type == PropertyType.ENUM:
- # Enums are treated specially because C++ templating thinks that they're
- # ints, but really they're strings.
- if optional:
- name = 'CreateValueFromOptionalEnumArray<%s>' % cpp_namespace
- else:
- name = 'CreateValueFromEnumArray<%s>' % cpp_namespace
+ if optional:
+ name = 'CreateValueFromOptionalArray'
else:
- if optional:
- name = 'CreateValueFromOptionalArray'
- else:
- name = 'CreateValueFromArray'
+ name = 'CreateValueFromArray'
return '%s::%s(%s)' % (_API_UTIL_NAMESPACE, name, src)
def GetIncludePath(self):
« no previous file with comments | « tools/json_schema_compiler/util.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698