| OLD | NEW |
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # | 2 # |
| 3 # Copyright 2014 The Chromium Authors. All rights reserved. | 3 # Copyright 2014 The Chromium Authors. All rights reserved. |
| 4 # Use of this source code is governed by a BSD-style license that can be | 4 # Use of this source code is governed by a BSD-style license that can be |
| 5 # found in the LICENSE file. | 5 # found in the LICENSE file. |
| 6 | 6 |
| 7 import collections | 7 import collections |
| 8 import re | 8 import re |
| 9 import optparse | 9 import optparse |
| 10 import os | 10 import os |
| 11 from string import Template | 11 from string import Template |
| 12 import sys | 12 import sys |
| 13 | 13 |
| 14 from util import build_utils | 14 from util import build_utils |
| 15 | 15 |
| 16 # List of C++ types that are compatible with the Java code generated by this | 16 # List of C++ types that are compatible with the Java code generated by this |
| 17 # script. | 17 # script. |
| 18 # |
| 19 # This script can parse .idl files however, at present it ignores special |
| 20 # rules such as [cpp_enum_prefix_override="ax_attr"]. |
| 18 ENUM_FIXED_TYPE_WHITELIST = ['char', 'unsigned char', | 21 ENUM_FIXED_TYPE_WHITELIST = ['char', 'unsigned char', |
| 19 'short', 'unsigned short', | 22 'short', 'unsigned short', |
| 20 'int', 'int8_t', 'int16_t', 'int32_t', 'uint8_t', 'uint16_t'] | 23 'int', 'int8_t', 'int16_t', 'int32_t', 'uint8_t', 'uint16_t'] |
| 21 | 24 |
| 22 class EnumDefinition(object): | 25 class EnumDefinition(object): |
| 23 def __init__(self, original_enum_name=None, class_name_override=None, | 26 def __init__(self, original_enum_name=None, class_name_override=None, |
| 24 enum_package=None, entries=None, fixed_type=None): | 27 enum_package=None, entries=None, fixed_type=None): |
| 25 self.original_enum_name = original_enum_name | 28 self.original_enum_name = original_enum_name |
| 26 self.class_name_override = class_name_override | 29 self.class_name_override = class_name_override |
| 27 self.enum_package = enum_package | 30 self.enum_package = enum_package |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 127 multi_line_generator_directive_start_re = re.compile( | 130 multi_line_generator_directive_start_re = re.compile( |
| 128 r'^\s*//\s+GENERATED_JAVA_(\w+)\s*:\s*\(([\.\w]*)$') | 131 r'^\s*//\s+GENERATED_JAVA_(\w+)\s*:\s*\(([\.\w]*)$') |
| 129 multi_line_directive_continuation_re = re.compile( | 132 multi_line_directive_continuation_re = re.compile( |
| 130 r'^\s*//\s+([\.\w]+)$') | 133 r'^\s*//\s+([\.\w]+)$') |
| 131 multi_line_directive_end_re = re.compile( | 134 multi_line_directive_end_re = re.compile( |
| 132 r'^\s*//\s+([\.\w]*)\)$') | 135 r'^\s*//\s+([\.\w]*)\)$') |
| 133 | 136 |
| 134 optional_class_or_struct_re = r'(class|struct)?' | 137 optional_class_or_struct_re = r'(class|struct)?' |
| 135 enum_name_re = r'(\w+)' | 138 enum_name_re = r'(\w+)' |
| 136 optional_fixed_type_re = r'(\:\s*(\w+\s*\w+?))?' | 139 optional_fixed_type_re = r'(\:\s*(\w+\s*\w+?))?' |
| 137 enum_start_re = re.compile(r'^\s*enum\s+' + optional_class_or_struct_re + | 140 enum_start_re = re.compile(r'^\s*(?:\[cpp.*\])?\s*enum\s+' + |
| 138 '\s*' + enum_name_re + '\s*' + optional_fixed_type_re + '\s*{\s*$') | 141 optional_class_or_struct_re + '\s*' + enum_name_re + '\s*' + |
| 142 optional_fixed_type_re + '\s*{\s*$') |
| 139 | 143 |
| 140 def __init__(self, lines, path=None): | 144 def __init__(self, lines, path=None): |
| 141 self._lines = lines | 145 self._lines = lines |
| 142 self._path = path | 146 self._path = path |
| 143 self._enum_definitions = [] | 147 self._enum_definitions = [] |
| 144 self._in_enum = False | 148 self._in_enum = False |
| 145 self._current_definition = None | 149 self._current_definition = None |
| 146 self._generator_directives = DirectiveSet() | 150 self._generator_directives = DirectiveSet() |
| 147 self._multi_line_generator_directive = None | 151 self._multi_line_generator_directive = None |
| 148 | 152 |
| (...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 327 AssertFilesList(output_paths, options.assert_files_list) | 331 AssertFilesList(output_paths, options.assert_files_list) |
| 328 | 332 |
| 329 if options.verbose: | 333 if options.verbose: |
| 330 print 'Output paths:' | 334 print 'Output paths:' |
| 331 print '\n'.join(output_paths) | 335 print '\n'.join(output_paths) |
| 332 | 336 |
| 333 return ' '.join(output_paths) | 337 return ' '.join(output_paths) |
| 334 | 338 |
| 335 if __name__ == '__main__': | 339 if __name__ == '__main__': |
| 336 DoMain(sys.argv[1:]) | 340 DoMain(sys.argv[1:]) |
| OLD | NEW |