| OLD | NEW |
| 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 ast | 8 import ast |
| 9 import os | 9 import os |
| 10 import re | 10 import re |
| (...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 253 # Add Long suffix to all integer literals. | 253 # Add Long suffix to all integer literals. |
| 254 number = ast.literal_eval(token.lstrip('+ ')) | 254 number = ast.literal_eval(token.lstrip('+ ')) |
| 255 if not isinstance(number, (int, long)): | 255 if not isinstance(number, (int, long)): |
| 256 raise ValueError('got unexpected type %r for int literal %r' % ( | 256 raise ValueError('got unexpected type %r for int literal %r' % ( |
| 257 type(number), token)) | 257 type(number), token)) |
| 258 # If the literal is too large to fit a signed long, convert it to the | 258 # If the literal is too large to fit a signed long, convert it to the |
| 259 # equivalent signed long. | 259 # equivalent signed long. |
| 260 if number >= 2 ** 63: | 260 if number >= 2 ** 63: |
| 261 number -= 2 ** 64 | 261 number -= 2 ** 64 |
| 262 return '%dL' % number | 262 return '%dL' % number |
| 263 if isinstance(token, mojom.BuiltinValue): |
| 264 if token.value == "double.INFINITY": |
| 265 return "java.lang.Double.POSITIVE_INFINITY" |
| 266 if token.value == "double.NEGATIVE_INFINITY": |
| 267 return "java.lang.Double.NEGATIVE_INFINITY" |
| 268 if token.value == "double.NAN": |
| 269 return "java.lang.Double.NaN" |
| 270 if token.value == "float.INFINITY": |
| 271 return "java.lang.Float.POSITIVE_INFINITY" |
| 272 if token.value == "float.NEGATIVE_INFINITY": |
| 273 return "java.lang.Float.NEGATIVE_INFINITY" |
| 274 if token.value == "float.NAN": |
| 275 return "java.lang.Float.NaN" |
| 263 return token | 276 return token |
| 264 | 277 |
| 265 def IsPointerArrayKind(kind): | 278 def IsPointerArrayKind(kind): |
| 266 if not mojom.IsAnyArrayKind(kind): | 279 if not mojom.IsAnyArrayKind(kind): |
| 267 return False | 280 return False |
| 268 sub_kind = kind.kind | 281 sub_kind = kind.kind |
| 269 return mojom.IsObjectKind(sub_kind) | 282 return mojom.IsObjectKind(sub_kind) |
| 270 | 283 |
| 271 def GetConstantsMainEntityName(module): | 284 def GetConstantsMainEntityName(module): |
| 272 if 'JavaConstantsClassName' in module.attributes: | 285 if 'JavaConstantsClassName' in module.attributes: |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 362 def GetJinjaParameters(self): | 375 def GetJinjaParameters(self): |
| 363 return { | 376 return { |
| 364 'lstrip_blocks': True, | 377 'lstrip_blocks': True, |
| 365 'trim_blocks': True, | 378 'trim_blocks': True, |
| 366 } | 379 } |
| 367 | 380 |
| 368 def GetGlobals(self): | 381 def GetGlobals(self): |
| 369 return { | 382 return { |
| 370 'module': self.module, | 383 'module': self.module, |
| 371 } | 384 } |
| OLD | NEW |