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 499671fde496b63bc79e33258811908fc9ff49e9..cfb9233db0cd89e5087344f2419bc53db6560df3 100644 |
| --- a/tools/json_schema_compiler/cc_generator.py |
| +++ b/tools/json_schema_compiler/cc_generator.py |
| @@ -213,14 +213,15 @@ class _Generator(object): |
| t = prop.type_ |
| real_t = self._type_helper.FollowRef(t) |
| - if (prop.optional or |
| - t.property_type == PropertyType.ANY or |
| - t.property_type == PropertyType.ARRAY or |
| - t.property_type == PropertyType.BINARY or |
| - t.property_type == PropertyType.CHOICES or |
| - t.property_type == PropertyType.OBJECT or |
| - t.property_type == PropertyType.REF or |
| - t.property_type == PropertyType.STRING): |
| + if (real_t.property_type != PropertyType.ENUM and # enums handled below |
|
Devlin
2016/03/23 21:41:01
drive-by - was seeing "std::move(other.enum)"
asargent_no_longer_on_chrome
2016/03/24 17:03:56
optional: I don't think you necessarily need the "
Devlin
2016/03/24 17:35:57
SGTM, done.
|
| + (prop.optional or |
| + t.property_type == PropertyType.ANY or |
| + t.property_type == PropertyType.ARRAY or |
| + t.property_type == PropertyType.BINARY or |
| + t.property_type == PropertyType.CHOICES or |
| + t.property_type == PropertyType.OBJECT or |
| + t.property_type == PropertyType.REF or |
| + t.property_type == PropertyType.STRING)): |
| props.append(move_str % (prop.unix_name, prop.unix_name)) |
| elif t.property_type == PropertyType.FUNCTION: |
| dicts.append(prop.unix_name) |
| @@ -232,6 +233,14 @@ class _Generator(object): |
| else: |
| raise TypeError(t) |
| + if (type_.property_type == PropertyType.OBJECT and |
| + type_.additional_properties is not None): |
| + if type_.additional_properties.property_type == PropertyType.ANY: |
| + dicts.append('additional_properties') |
| + else: |
| + props.append(move_str % ('additional_properties', |
| + 'additional_properties')) |
| + |
| return (props, dicts) |
| def _GenerateMoveCtor(self, type_): |
| @@ -254,7 +263,7 @@ class _Generator(object): |
| if props: |
| s = s + '\n'.join(props) |
| for item in dicts: |
| - s = s + ('\n%s.Swap(&rhs.%s);' % (item, item)) |
| + s = s + ('%s.Swap(&rhs.%s);' % (item, item)) |
| s = s + '\nreturn *this;\n}' |
| return Code().Append(s) |
| @@ -472,6 +481,7 @@ class _Generator(object): |
| # Non-copyable types will be wrapped in a linked_ptr for inclusion in |
| # maps, so we need to unwrap them. |
| needs_unwrap = ( |
| + not 'use_movable_types' in type_.namespace.compiler_options and |
| not self._type_helper.IsCopyable(type_.additional_properties)) |
| (c.Sblock('for (const auto& it : additional_properties) {') |
| .Cblock(self._CreateValueFromType( |