Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(26)

Side by Side Diff: tools/json_schema_compiler/cpp_type_generator.py

Issue 820673004: json_schema_compiler: Use std::vector<char> for binary values. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@simplify_json_schema
Patch Set: Fix merge error. Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « tools/json_schema_compiler/cc_generator.py ('k') | tools/json_schema_compiler/util.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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
OLDNEW
« no previous file with comments | « tools/json_schema_compiler/cc_generator.py ('k') | tools/json_schema_compiler/util.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698