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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « mojo/public/tools/bindings/generators/mojom_cpp_generator.py ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/public/tools/bindings/generators/mojom_java_generator.py
diff --git a/mojo/public/tools/bindings/generators/mojom_java_generator.py b/mojo/public/tools/bindings/generators/mojom_java_generator.py
index 7364afc56ad725ff594c1180e68fc377d69071ce..ec897f750f2b97d4824cb6d1540355ae48b6f221 100644
--- a/mojo/public/tools/bindings/generators/mojom_java_generator.py
+++ b/mojo/public/tools/bindings/generators/mojom_java_generator.py
@@ -235,7 +235,12 @@ def ExpressionToText(context, token):
return _TranslateNamedValue(token)
# Add Long suffix to all number literals.
if re.match('^[0-9]+$', token):
- return token + 'L'
+ number = int(token)
+ # If the literal is too large to fit a signed long, convert it to the
+ # equivalent signed long.
+ if number >= 2 ** 63:
+ number -= 2 ** 64
+ return '%dL' % number
return token
def IsPointerArrayKind(kind):
« 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