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 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
105 cpp_type = 'base::Value' | 105 cpp_type = 'base::Value' |
106 elif type_.property_type == PropertyType.FUNCTION: | 106 elif type_.property_type == PropertyType.FUNCTION: |
107 # Functions come into the json schema compiler as empty objects. We can | 107 # Functions come into the json schema compiler as empty objects. We can |
108 # record these as empty DictionaryValues so that we know if the function | 108 # record these as empty DictionaryValues so that we know if the function |
109 # was passed in or not. | 109 # was passed in or not. |
110 cpp_type = 'base::DictionaryValue' | 110 cpp_type = 'base::DictionaryValue' |
111 elif type_.property_type == PropertyType.ARRAY: | 111 elif type_.property_type == PropertyType.ARRAY: |
112 item_cpp_type = self.GetCppType(type_.item_type, is_in_container=True) | 112 item_cpp_type = self.GetCppType(type_.item_type, is_in_container=True) |
113 cpp_type = 'std::vector<%s>' % cpp_util.PadForGenerics(item_cpp_type) | 113 cpp_type = 'std::vector<%s>' % cpp_util.PadForGenerics(item_cpp_type) |
114 elif type_.property_type == PropertyType.BINARY: | 114 elif type_.property_type == PropertyType.BINARY: |
115 cpp_type = 'std::string' | 115 cpp_type = 'std::vector<char>' |
116 else: | 116 else: |
117 raise NotImplementedError('Cannot get type of %s' % type_.property_type) | 117 raise NotImplementedError('Cannot get type of %s' % type_.property_type) |
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 if is_in_container and (is_ptr or not self.IsCopyable(type_)): | 123 if is_in_container and (is_ptr or not self.IsCopyable(type_)): |
124 cpp_type = 'linked_ptr<%s>' % cpp_util.PadForGenerics(cpp_type) | 124 cpp_type = 'linked_ptr<%s>' % cpp_util.PadForGenerics(cpp_type) |
125 elif is_ptr: | 125 elif is_ptr: |
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
264 child_code = self.GeneratePropertyValues(child_property, | 264 child_code = self.GeneratePropertyValues(child_property, |
265 line, | 265 line, |
266 nodoc=nodoc) | 266 nodoc=nodoc) |
267 if child_code: | 267 if child_code: |
268 has_child_code = True | 268 has_child_code = True |
269 c.Concat(child_code) | 269 c.Concat(child_code) |
270 c.Eblock('} // namespace %s' % prop.name) | 270 c.Eblock('} // namespace %s' % prop.name) |
271 if not has_child_code: | 271 if not has_child_code: |
272 c = None | 272 c = None |
273 return c | 273 return c |
OLD | NEW |