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: mojo/public/tools/bindings/generators/mojom_cpp_generator.py

Issue 469393004: Mojo: Add warning of invalid serialization results (in debug build). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 4 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 | Annotate | Revision Log
« no previous file with comments | « mojo/public/tools/bindings/generators/cpp_templates/struct_serialization_definition.tmpl ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright 2013 The Chromium Authors. All rights reserved. 1 # Copyright 2013 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 """Generates C++ source files from a mojom.Module.""" 5 """Generates C++ source files from a mojom.Module."""
6 6
7 import mojom.generate.generator as generator 7 import mojom.generate.generator as generator
8 import mojom.generate.module as mojom 8 import mojom.generate.module as mojom
9 import mojom.generate.pack as pack 9 import mojom.generate.pack as pack
10 from mojom.generate.template_expander import UseJinja 10 from mojom.generate.template_expander import UseJinja
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after
242 if mojom.IsMoveOnlyKind(field.kind): 242 if mojom.IsMoveOnlyKind(field.kind):
243 return False 243 return False
244 return True 244 return True
245 245
246 def GetArrayValidateParams(kind): 246 def GetArrayValidateParams(kind):
247 if not mojom.IsAnyArrayKind(kind) and not mojom.IsStringKind(kind): 247 if not mojom.IsAnyArrayKind(kind) and not mojom.IsStringKind(kind):
248 return "mojo::internal::NoValidateParams" 248 return "mojo::internal::NoValidateParams"
249 249
250 if mojom.IsStringKind(kind): 250 if mojom.IsStringKind(kind):
251 expected_num_elements = 0 251 expected_num_elements = 0
252 element_nullable = False 252 element_is_nullable = False
253 element_validate_params = "mojo::internal::NoValidateParams" 253 element_validate_params = "mojo::internal::NoValidateParams"
254 else: 254 else:
255 expected_num_elements = generator.ExpectedArraySize(kind) 255 expected_num_elements = generator.ExpectedArraySize(kind)
256 element_nullable = mojom.IsNullableKind(kind.kind) 256 element_is_nullable = mojom.IsNullableKind(kind.kind)
257 element_validate_params = GetArrayValidateParams(kind.kind) 257 element_validate_params = GetArrayValidateParams(kind.kind)
258 258
259 return "mojo::internal::ArrayValidateParams<%d, %s,\n%s> " % ( 259 return "mojo::internal::ArrayValidateParams<%d, %s,\n%s> " % (
260 expected_num_elements, 260 expected_num_elements,
261 'true' if element_nullable else 'false', 261 'true' if element_is_nullable else 'false',
262 element_validate_params) 262 element_validate_params)
263 263
264 _HEADER_SIZE = 8 264 _HEADER_SIZE = 8
265 265
266 class Generator(generator.Generator): 266 class Generator(generator.Generator):
267 267
268 cpp_filters = { 268 cpp_filters = {
269 "constant_value": ConstantValue, 269 "constant_value": ConstantValue,
270 "cpp_const_wrapper_type": GetCppConstWrapperType, 270 "cpp_const_wrapper_type": GetCppConstWrapperType,
271 "cpp_field_type": GetCppFieldType, 271 "cpp_field_type": GetCppFieldType,
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
320 320
321 @UseJinja("cpp_templates/module.cc.tmpl", filters=cpp_filters) 321 @UseJinja("cpp_templates/module.cc.tmpl", filters=cpp_filters)
322 def GenerateModuleSource(self): 322 def GenerateModuleSource(self):
323 return self.GetJinjaExports() 323 return self.GetJinjaExports()
324 324
325 def GenerateFiles(self, args): 325 def GenerateFiles(self, args):
326 self.Write(self.GenerateModuleHeader(), "%s.h" % self.module.name) 326 self.Write(self.GenerateModuleHeader(), "%s.h" % self.module.name)
327 self.Write(self.GenerateModuleInternalHeader(), 327 self.Write(self.GenerateModuleInternalHeader(),
328 "%s-internal.h" % self.module.name) 328 "%s-internal.h" % self.module.name)
329 self.Write(self.GenerateModuleSource(), "%s.cc" % self.module.name) 329 self.Write(self.GenerateModuleSource(), "%s.cc" % self.module.name)
OLDNEW
« no previous file with comments | « mojo/public/tools/bindings/generators/cpp_templates/struct_serialization_definition.tmpl ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698