| 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_expected_length': GetArrayExpectedLength, |
| 396 'array': GetArrayKind, | 397 'array': GetArrayKind, |
| 397 'array_expected_length': GetArrayExpectedLength, | 398 'constant_value': ConstantValue, |
| 399 'decode_method': DecodeMethod, |
| 400 'default_value': DefaultValue, |
| 401 'encode_method': EncodeMethod, |
| 402 'expression_to_text': ExpressionToText, |
| 403 'has_method_without_response': HasMethodWithoutResponse, |
| 404 'has_method_with_response': HasMethodWithResponse, |
| 398 'interface_response_name': GetInterfaceResponseName, | 405 'interface_response_name': GetInterfaceResponseName, |
| 399 'constant_value': ConstantValue, | 406 'is_array_kind': mojom.IsArrayKind, |
| 400 'default_value': DefaultValue, | |
| 401 'decode_method': DecodeMethod, | |
| 402 'expression_to_text': ExpressionToText, | |
| 403 'encode_method': EncodeMethod, | |
| 404 'has_method_with_response': HasMethodWithResponse, | |
| 405 'has_method_without_response': HasMethodWithoutResponse, | |
| 406 'is_handle': mojom.IsNonInterfaceHandleKind, | 407 'is_handle': mojom.IsNonInterfaceHandleKind, |
| 407 'is_map_kind': mojom.IsMapKind, | 408 'is_map_kind': mojom.IsMapKind, |
| 408 'is_nullable_kind': mojom.IsNullableKind, | 409 'is_nullable_kind': mojom.IsNullableKind, |
| 409 'is_pointer_array_kind': IsPointerArrayKind, | 410 'is_pointer_array_kind': IsPointerArrayKind, |
| 411 'is_reference_kind': mojom.IsReferenceKind, |
| 410 'is_struct_kind': mojom.IsStructKind, | 412 'is_struct_kind': mojom.IsStructKind, |
| 413 'java_true_false': GetJavaTrueFalse, |
| 411 'java_type': GetJavaType, | 414 'java_type': GetJavaType, |
| 412 'java_true_false': GetJavaTrueFalse, | |
| 413 'method_ordinal_name': GetMethodOrdinalName, | 415 'method_ordinal_name': GetMethodOrdinalName, |
| 414 'name': GetNameForElement, | 416 'name': GetNameForElement, |
| 415 'new_array': NewArray, | 417 'new_array': NewArray, |
| 416 'response_struct_from_method': GetResponseStructFromMethod, | 418 'response_struct_from_method': GetResponseStructFromMethod, |
| 417 'struct_from_method': GetStructFromMethod, | 419 'struct_from_method': GetStructFromMethod, |
| 418 'struct_size': lambda ps: ps.GetTotalSize() + _HEADER_SIZE, | 420 'struct_size': lambda ps: ps.GetTotalSize() + _HEADER_SIZE, |
| 419 } | 421 } |
| 420 | 422 |
| 421 def GetJinjaExports(self): | 423 def GetJinjaExports(self): |
| 422 return { | 424 return { |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 511 return { | 513 return { |
| 512 'lstrip_blocks': True, | 514 'lstrip_blocks': True, |
| 513 'trim_blocks': True, | 515 'trim_blocks': True, |
| 514 } | 516 } |
| 515 | 517 |
| 516 def GetGlobals(self): | 518 def GetGlobals(self): |
| 517 return { | 519 return { |
| 518 'namespace': self.module.namespace, | 520 'namespace': self.module.namespace, |
| 519 'module': self.module, | 521 'module': self.module, |
| 520 } | 522 } |
| OLD | NEW |