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

Side by Side Diff: mojo/public/tools/bindings/generators/mojom_cpp_generator.py

Issue 605443002: The default value for NullableString should be null (was "") (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Added missing types, renamed test functions and struct types Created 6 years, 2 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
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 215 matching lines...) Expand 10 before | Expand all | Expand 10 after
226 226
227 if isinstance(token, mojom.BuiltinValue): 227 if isinstance(token, mojom.BuiltinValue):
228 if token.value == "double.INFINITY" or token.value == "float.INFINITY": 228 if token.value == "double.INFINITY" or token.value == "float.INFINITY":
229 return "INFINITY"; 229 return "INFINITY";
230 if token.value == "double.NEGATIVE_INFINITY" or \ 230 if token.value == "double.NEGATIVE_INFINITY" or \
231 token.value == "float.NEGATIVE_INFINITY": 231 token.value == "float.NEGATIVE_INFINITY":
232 return "-INFINITY"; 232 return "-INFINITY";
233 if token.value == "double.NAN" or token.value == "float.NAN": 233 if token.value == "double.NAN" or token.value == "float.NAN":
234 return "NAN"; 234 return "NAN";
235 235
236 if (kind is not None and mojom.IsFloatKind(kind)):
237 return token if token.isdigit() else token + "f";
238
236 return '%s%s' % (token, _kind_to_cpp_literal_suffix.get(kind, '')) 239 return '%s%s' % (token, _kind_to_cpp_literal_suffix.get(kind, ''))
237 240
238 def ExpressionToText(value, kind=None): 241 def ExpressionToText(value, kind=None):
239 return TranslateConstants(value, kind) 242 return TranslateConstants(value, kind)
240 243
241 def ShouldInlineStruct(struct): 244 def ShouldInlineStruct(struct):
242 # TODO(darin): Base this on the size of the wrapper class. 245 # TODO(darin): Base this on the size of the wrapper class.
243 if len(struct.fields) > 4: 246 if len(struct.fields) > 4:
244 return False 247 return False
245 for field in struct.fields: 248 for field in struct.fields:
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
324 327
325 @UseJinja("cpp_templates/module.cc.tmpl", filters=cpp_filters) 328 @UseJinja("cpp_templates/module.cc.tmpl", filters=cpp_filters)
326 def GenerateModuleSource(self): 329 def GenerateModuleSource(self):
327 return self.GetJinjaExports() 330 return self.GetJinjaExports()
328 331
329 def GenerateFiles(self, args): 332 def GenerateFiles(self, args):
330 self.Write(self.GenerateModuleHeader(), "%s.h" % self.module.name) 333 self.Write(self.GenerateModuleHeader(), "%s.h" % self.module.name)
331 self.Write(self.GenerateModuleInternalHeader(), 334 self.Write(self.GenerateModuleInternalHeader(),
332 "%s-internal.h" % self.module.name) 335 "%s-internal.h" % self.module.name)
333 self.Write(self.GenerateModuleSource(), "%s.cc" % self.module.name) 336 self.Write(self.GenerateModuleSource(), "%s.cc" % self.module.name)
OLDNEW
« no previous file with comments | « mojo/public/js/bindings/struct_unittests.js ('k') | mojo/public/tools/bindings/generators/mojom_js_generator.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698