OLD | NEW |
1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
4 | 4 |
5 from code import Code | 5 from code import Code |
6 from model import PropertyType | 6 from model import PropertyType |
7 import cpp_util | 7 import cpp_util |
8 from json_parse import OrderedDict | 8 from json_parse import OrderedDict |
9 import schema_util | 9 import schema_util |
10 | 10 |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
118 | 118 |
119 # HACK: optional ENUM is represented elsewhere with a _NONE value, so it | 119 # HACK: optional ENUM is represented elsewhere with a _NONE value, so it |
120 # never needs to be wrapped in pointer shenanigans. | 120 # never needs to be wrapped in pointer shenanigans. |
121 # TODO(kalman): change this - but it's an exceedingly far-reaching change. | 121 # TODO(kalman): change this - but it's an exceedingly far-reaching change. |
122 if not self.FollowRef(type_).property_type == PropertyType.ENUM: | 122 if not self.FollowRef(type_).property_type == PropertyType.ENUM: |
123 is_base_value = (cpp_type == 'base::Value' or | 123 is_base_value = (cpp_type == 'base::Value' or |
124 cpp_type == 'base::DictionaryValue') | 124 cpp_type == 'base::DictionaryValue') |
125 # Wrap ptrs and base::Values in containers (which aren't movable) in | 125 # Wrap ptrs and base::Values in containers (which aren't movable) in |
126 # scoped_ptrs. | 126 # scoped_ptrs. |
127 if is_ptr or (is_in_container and is_base_value): | 127 if is_ptr or (is_in_container and is_base_value): |
128 cpp_type = 'scoped_ptr<%s>' % cpp_util.PadForGenerics(cpp_type) | 128 cpp_type = 'std::unique_ptr<%s>' % cpp_util.PadForGenerics(cpp_type) |
129 | 129 |
130 return cpp_type | 130 return cpp_type |
131 | 131 |
132 def IsCopyable(self, type_): | 132 def IsCopyable(self, type_): |
133 return not (self.FollowRef(type_).property_type in (PropertyType.ANY, | 133 return not (self.FollowRef(type_).property_type in (PropertyType.ANY, |
134 PropertyType.ARRAY, | 134 PropertyType.ARRAY, |
135 PropertyType.OBJECT, | 135 PropertyType.OBJECT, |
136 PropertyType.CHOICES)) | 136 PropertyType.CHOICES)) |
137 | 137 |
138 def GenerateForwardDeclarations(self): | 138 def GenerateForwardDeclarations(self): |
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
267 child_code = self.GeneratePropertyValues(child_property, | 267 child_code = self.GeneratePropertyValues(child_property, |
268 line, | 268 line, |
269 nodoc=nodoc) | 269 nodoc=nodoc) |
270 if child_code: | 270 if child_code: |
271 has_child_code = True | 271 has_child_code = True |
272 c.Concat(child_code) | 272 c.Concat(child_code) |
273 c.Eblock('} // namespace %s' % prop.name) | 273 c.Eblock('} // namespace %s' % prop.name) |
274 if not has_child_code: | 274 if not has_child_code: |
275 c = None | 275 c = None |
276 return c | 276 return c |
OLD | NEW |