| 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 contextlib | 9 import contextlib |
| 10 import os | 10 import os |
| (...skipping 375 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 386 with zipfile.ZipFile(zip_filename, 'w') as zip_file: | 386 with zipfile.ZipFile(zip_filename, 'w') as zip_file: |
| 387 for dirname, _, files in os.walk(root): | 387 for dirname, _, files in os.walk(root): |
| 388 for filename in files: | 388 for filename in files: |
| 389 path = os.path.join(dirname, filename) | 389 path = os.path.join(dirname, filename) |
| 390 path_in_archive = os.path.relpath(path, root) | 390 path_in_archive = os.path.relpath(path, root) |
| 391 zip_file.write(path, path_in_archive) | 391 zip_file.write(path, path_in_archive) |
| 392 | 392 |
| 393 class Generator(generator.Generator): | 393 class Generator(generator.Generator): |
| 394 | 394 |
| 395 java_filters = { | 395 java_filters = { |
| 396 'array': GetArrayKind, |
| 396 'array_expected_length': GetArrayExpectedLength, | 397 'array_expected_length': GetArrayExpectedLength, |
| 397 'array': GetArrayKind, | 398 'interface_response_name': GetInterfaceResponseName, |
| 398 'constant_value': ConstantValue, | 399 'constant_value': ConstantValue, |
| 400 'default_value': DefaultValue, |
| 399 'decode_method': DecodeMethod, | 401 'decode_method': DecodeMethod, |
| 400 'default_value': DefaultValue, | 402 'expression_to_text': ExpressionToText, |
| 401 'encode_method': EncodeMethod, | 403 'encode_method': EncodeMethod, |
| 402 'expression_to_text': ExpressionToText, | 404 'has_method_with_response': HasMethodWithResponse, |
| 403 'has_method_without_response': HasMethodWithoutResponse, | 405 'has_method_without_response': HasMethodWithoutResponse, |
| 404 'has_method_with_response': HasMethodWithResponse, | |
| 405 'interface_response_name': GetInterfaceResponseName, | |
| 406 'is_array_kind': mojom.IsArrayKind, | |
| 407 'is_handle': mojom.IsNonInterfaceHandleKind, | 406 'is_handle': mojom.IsNonInterfaceHandleKind, |
| 408 'is_map_kind': mojom.IsMapKind, | 407 'is_map_kind': mojom.IsMapKind, |
| 409 'is_nullable_kind': mojom.IsNullableKind, | 408 'is_nullable_kind': mojom.IsNullableKind, |
| 410 'is_pointer_array_kind': IsPointerArrayKind, | 409 'is_pointer_array_kind': IsPointerArrayKind, |
| 411 'is_reference_kind': mojom.IsReferenceKind, | |
| 412 'is_struct_kind': mojom.IsStructKind, | 410 'is_struct_kind': mojom.IsStructKind, |
| 411 'java_type': GetJavaType, |
| 413 'java_true_false': GetJavaTrueFalse, | 412 'java_true_false': GetJavaTrueFalse, |
| 414 'java_type': GetJavaType, | |
| 415 'method_ordinal_name': GetMethodOrdinalName, | 413 'method_ordinal_name': GetMethodOrdinalName, |
| 416 'name': GetNameForElement, | 414 'name': GetNameForElement, |
| 417 'new_array': NewArray, | 415 'new_array': NewArray, |
| 418 'response_struct_from_method': GetResponseStructFromMethod, | 416 'response_struct_from_method': GetResponseStructFromMethod, |
| 419 'struct_from_method': GetStructFromMethod, | 417 'struct_from_method': GetStructFromMethod, |
| 420 'struct_size': lambda ps: ps.GetTotalSize() + _HEADER_SIZE, | 418 'struct_size': lambda ps: ps.GetTotalSize() + _HEADER_SIZE, |
| 421 } | 419 } |
| 422 | 420 |
| 423 def GetJinjaExports(self): | 421 def GetJinjaExports(self): |
| 424 return { | 422 return { |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 513 return { | 511 return { |
| 514 'lstrip_blocks': True, | 512 'lstrip_blocks': True, |
| 515 'trim_blocks': True, | 513 'trim_blocks': True, |
| 516 } | 514 } |
| 517 | 515 |
| 518 def GetGlobals(self): | 516 def GetGlobals(self): |
| 519 return { | 517 return { |
| 520 'namespace': self.module.namespace, | 518 'namespace': self.module.namespace, |
| 521 'module': self.module, | 519 'module': self.module, |
| 522 } | 520 } |
| OLD | NEW |