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 any_helper | 7 import any_helper |
8 import cpp_util | 8 import cpp_util |
9 import model | 9 import model |
10 import schema_util | 10 import schema_util |
(...skipping 327 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
338 if prop.optional: | 338 if prop.optional: |
339 return '%s->ToValue().release()' % var | 339 return '%s->ToValue().release()' % var |
340 else: | 340 else: |
341 return '%s.ToValue().release()' % var | 341 return '%s.ToValue().release()' % var |
342 elif prop.type_ == PropertyType.ANY: | 342 elif prop.type_ == PropertyType.ANY: |
343 return '%s.DeepCopy()' % self._any_helper.GetValue(prop, var) | 343 return '%s.DeepCopy()' % self._any_helper.GetValue(prop, var) |
344 elif prop.type_ == PropertyType.ADDITIONAL_PROPERTIES: | 344 elif prop.type_ == PropertyType.ADDITIONAL_PROPERTIES: |
345 return '%s.DeepCopy()' % var | 345 return '%s.DeepCopy()' % var |
346 elif prop.type_ == PropertyType.ENUM: | 346 elif prop.type_ == PropertyType.ENUM: |
347 return 'CreateEnumValue(%s).release()' % var | 347 return 'CreateEnumValue(%s).release()' % var |
| 348 elif prop.type_ == PropertyType.BINARY: |
| 349 return '%s->DeepCopy()' % var |
348 elif self._IsArrayOrArrayRef(prop): | 350 elif self._IsArrayOrArrayRef(prop): |
349 return '%s.release()' % self._util_cc_helper.CreateValueFromArray( | 351 return '%s.release()' % self._util_cc_helper.CreateValueFromArray( |
350 self._cpp_type_generator.GetReferencedProperty(prop), var, | 352 self._cpp_type_generator.GetReferencedProperty(prop), var, |
351 prop.optional) | 353 prop.optional) |
352 elif self._IsFundamentalOrFundamentalRef(prop): | 354 elif self._IsFundamentalOrFundamentalRef(prop): |
353 if prop.optional: | 355 if prop.optional: |
354 var = '*' + var | 356 var = '*' + var |
355 prop = self._cpp_type_generator.GetReferencedProperty(prop); | 357 prop = self._cpp_type_generator.GetReferencedProperty(prop); |
356 return { | 358 return { |
357 PropertyType.STRING: 'Value::CreateStringValue(%s)', | 359 PropertyType.STRING: 'Value::CreateStringValue(%s)', |
(...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
658 """ | 660 """ |
659 return (self._cpp_type_generator.GetReferencedProperty(prop).type_ == | 661 return (self._cpp_type_generator.GetReferencedProperty(prop).type_ == |
660 PropertyType.ARRAY) | 662 PropertyType.ARRAY) |
661 | 663 |
662 def _IsFundamentalOrFundamentalRef(self, prop): | 664 def _IsFundamentalOrFundamentalRef(self, prop): |
663 """Determines if this property is a Fundamental type or is a ref to a | 665 """Determines if this property is a Fundamental type or is a ref to a |
664 Fundamental type. | 666 Fundamental type. |
665 """ | 667 """ |
666 return (self._cpp_type_generator.GetReferencedProperty(prop).type_. | 668 return (self._cpp_type_generator.GetReferencedProperty(prop).type_. |
667 is_fundamental) | 669 is_fundamental) |
OLD | NEW |