Chromium Code Reviews| 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 bc552933bf02eea63fc610a735b0b727f2afaae7..ecf512a2671e4ab3469548b0e09e6780d6601f42 100644 |
| --- a/tools/json_schema_compiler/cc_generator.py |
| +++ b/tools/json_schema_compiler/cc_generator.py |
| @@ -98,7 +98,7 @@ class CCGenerator(object): |
| function)) |
| .Append() |
| ) |
| - else: |
| + elif type_.type_ == PropertyType.OBJECT: |
| (c.Concat(self._GeneratePropertyFunctions( |
| cpp_namespace, type_.properties.values())) |
| .Sblock('%(namespace)s::%(classname)s()') |
| @@ -321,7 +321,8 @@ class CCGenerator(object): |
| # for reference. |
| raise NotImplementedError( |
| 'Conversion of CHOICES to Value not implemented') |
| - if prop.type_ in (PropertyType.REF, PropertyType.OBJECT): |
| + if prop.type_ == PropertyType.OBJECT or \ |
|
Yoyo Zhou
2012/04/09 23:48:47
style nits: extra space. Also, the style is to con
cduvall
2012/04/10 03:06:08
That makes it way cleaner. Good idea.
|
| + (prop.type_ == PropertyType.REF and not prop.is_array): |
| if prop.optional: |
| return '%s->ToValue().release()' % var |
| else: |
| @@ -332,7 +333,8 @@ class CCGenerator(object): |
| return '%s.DeepCopy()' % var |
| elif prop.type_ == PropertyType.ENUM: |
| return 'CreateEnumValue(%s).release()' % var |
| - elif prop.type_ == PropertyType.ARRAY: |
| + elif prop.type_ == PropertyType.ARRAY or \ |
| + (prop.type_ == PropertyType.REF and prop.is_array): |
| return '%s.release()' % self._util_cc_helper.CreateValueFromArray( |
| prop, var) |
| elif prop.type_.is_fundamental: |
| @@ -455,7 +457,8 @@ class CCGenerator(object): |
| prop, value_var, '&%s->%s' % (dst, prop.unix_name))) |
| .Append('return %(failure_value)s;') |
| ) |
| - elif prop.type_ in (PropertyType.OBJECT, PropertyType.REF): |
| + elif prop.type_ == PropertyType.OBJECT or \ |
| + (prop.type_ == PropertyType.REF and not prop.is_array): |
| if prop.optional: |
| (c.Append('DictionaryValue* dictionary = NULL;') |
| .Append('if (!%(value_var)s->GetAsDictionary(&dictionary))') |
| @@ -477,7 +480,8 @@ class CCGenerator(object): |
| if prop.optional: |
| c.Append('%(dst)s->%(name)s.reset(new Any());') |
| c.Append(self._any_helper.Init(prop, value_var, dst) + ';') |
| - elif prop.type_ == PropertyType.ARRAY: |
| + elif prop.type_ == PropertyType.ARRAY or (prop.type_ == PropertyType.REF |
| + and prop.is_array): |
| # util_cc_helper deals with optional and required arrays |
| (c.Append('ListValue* list = NULL;') |
| .Append('if (!%(value_var)s->GetAsList(&list))') |