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 2c47b5ed00b192ba9a38c2f53058f0253d31e6f8..91e307ce4c21c41fe7f84fd5cb03c69b32e6c80d 100644 |
--- a/tools/json_schema_compiler/cc_generator.py |
+++ b/tools/json_schema_compiler/cc_generator.py |
@@ -686,7 +686,7 @@ class _Generator(object): |
item_type = self._type_helper.FollowRef(underlying_type.item_type) |
if item_type.property_type == PropertyType.ENUM: |
c.Concat(self._GenerateListValueToEnumArrayConversion( |
- item_type, |
+ underlying_type.item_type, |
'list', |
dst_var, |
failure_value, |
@@ -799,6 +799,14 @@ class _Generator(object): |
""" |
c = Code() |
enum_as_string = '%s_as_string' % type_.unix_name |
+ cpp_type_fullname = self._type_helper.GetCppType(type_) |
not at google - send to devlin
2014/03/31 15:18:59
this isn't used
mtomasz
2014/04/03 21:50:22
Done.
|
+ # The passed type may be either of REF type, or directly ENUM. Note, that |
+ # the second case is used only by JSON. |
+ enum_type = (type_ if type_.property_type == PropertyType.ENUM else |
not at google - send to devlin
2014/03/31 15:18:59
see comment above, note that FollowRef does this c
mtomasz
2014/04/03 21:50:22
Done.
|
+ self._type_helper.FollowRef(type_)) |
+ cpp_type_namespace = (enum_type.namespace.unix_name |
not at google - send to devlin
2014/03/31 15:18:59
if you make sure this includes the '::' then that
Nils Barth (inactive)
2014/04/01 01:39:16
BTW, as a style point, an alternative style is sin
not at google - send to devlin
2014/04/01 01:40:25
I don't mind either way.
mtomasz
2014/04/03 21:50:22
Done.
|
+ if enum_type.namespace != self._namespace else '') |
+ cpp_type_name = self._type_helper.GetCppType(enum_type) |
not at google - send to devlin
2014/03/31 15:18:59
if you go back to inlining this, and implement the
mtomasz
2014/04/03 21:50:22
Done.
|
(c.Append('std::string %s;' % enum_as_string) |
.Sblock('if (!%s->GetAsString(&%s)) {' % (src_var, enum_as_string)) |
.Concat(self._GenerateError( |
@@ -806,11 +814,15 @@ class _Generator(object): |
self._util_cc_helper.GetValueTypeString('%%(src_var)s', True))) |
.Append('return %s;' % failure_value) |
.Eblock('}') |
- .Append('%s = Parse%s(%s);' % (dst_var, |
- self._type_helper.GetCppType(type_), |
- enum_as_string)) |
- .Sblock('if (%s == %s) {' % (dst_var, |
- self._type_helper.GetEnumNoneValue(type_))) |
not at google - send to devlin
2014/03/31 15:18:59
if/when you do change this back, mind indenting th
mtomasz
2014/04/03 21:50:22
Done.
|
+ .Append('%s = %sParse%s(%s);' % ( |
+ dst_var, |
+ cpp_type_namespace + '::' if cpp_type_namespace else '', |
+ cpp_type_name, |
+ enum_as_string)) |
+ .Sblock('if (%s == %s%s) {' % ( |
+ dst_var, |
+ cpp_type_namespace + '::' if cpp_type_namespace else '', |
+ self._type_helper.GetEnumNoneValue(type_))) |
.Concat(self._GenerateError( |
'\"\'%%(key)s\': expected \\"' + |
'\\" or \\"'.join( |