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

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

Issue 397453004: Mojo: Correctly handle large unsigned integer literals. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: ULL Created 6 years, 5 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/mojom_cpp_generator.py ('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 2014 The Chromium Authors. All rights reserved. 1 # Copyright 2014 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 java source files from a mojom.Module.""" 5 """Generates java source files from a mojom.Module."""
6 6
7 import argparse 7 import argparse
8 import os 8 import os
9 import re 9 import re
10 10
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after
228 entity_name = (GetConstantsMainEntityName(named_value.module) + '.' + 228 entity_name = (GetConstantsMainEntityName(named_value.module) + '.' +
229 entity_name) 229 entity_name)
230 if GetPackage(named_value.module) == GetPackage(context.resolve('module')): 230 if GetPackage(named_value.module) == GetPackage(context.resolve('module')):
231 return entity_name 231 return entity_name
232 return GetPackage(named_value.module) + '.' + entity_name 232 return GetPackage(named_value.module) + '.' + entity_name
233 233
234 if isinstance(token, mojom.NamedValue): 234 if isinstance(token, mojom.NamedValue):
235 return _TranslateNamedValue(token) 235 return _TranslateNamedValue(token)
236 # Add Long suffix to all number literals. 236 # Add Long suffix to all number literals.
237 if re.match('^[0-9]+$', token): 237 if re.match('^[0-9]+$', token):
238 return token + 'L' 238 number = int(token)
239 # If the literal is too large to fit a signed long, convert it to the
240 # equivalent signed long.
241 if number >= 2 ** 63:
242 number -= 2 ** 64
243 return '%dL' % number
239 return token 244 return token
240 245
241 def IsPointerArrayKind(kind): 246 def IsPointerArrayKind(kind):
242 if not IsArray(kind): 247 if not IsArray(kind):
243 return False 248 return False
244 sub_kind = kind.kind 249 sub_kind = kind.kind
245 return generator.IsObjectKind(sub_kind) 250 return generator.IsObjectKind(sub_kind)
246 251
247 def GetConstantsMainEntityName(module): 252 def GetConstantsMainEntityName(module):
248 if 'JavaConstantsClassName' in module.attributes: 253 if 'JavaConstantsClassName' in module.attributes:
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
337 def GetJinjaParameters(self): 342 def GetJinjaParameters(self):
338 return { 343 return {
339 'lstrip_blocks': True, 344 'lstrip_blocks': True,
340 'trim_blocks': True, 345 'trim_blocks': True,
341 } 346 }
342 347
343 def GetGlobals(self): 348 def GetGlobals(self):
344 return { 349 return {
345 'module': self.module, 350 'module': self.module,
346 } 351 }
OLDNEW
« no previous file with comments | « mojo/public/tools/bindings/generators/mojom_cpp_generator.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698