| OLD | NEW |
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # Copyright 2013 The Chromium Authors. All rights reserved. | 2 # Copyright 2013 The Chromium Authors. All rights reserved. |
| 3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
| 4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
| 5 | 5 |
| 6 """Translate parse tree to Mojom IR""" | 6 """Translate parse tree to Mojom IR""" |
| 7 | 7 |
| 8 | 8 |
| 9 import os | 9 import os |
| 10 import sys | 10 import sys |
| (...skipping 13 matching lines...) Expand all Loading... |
| 24 'uint8': 'u8', | 24 'uint8': 'u8', |
| 25 'uint16': 'u16', | 25 'uint16': 'u16', |
| 26 'uint32': 'u32', | 26 'uint32': 'u32', |
| 27 'uint64': 'u64', | 27 'uint64': 'u64', |
| 28 'float': 'f', | 28 'float': 'f', |
| 29 'double': 'd', | 29 'double': 'd', |
| 30 'string': 's', | 30 'string': 's', |
| 31 'handle': 'h', | 31 'handle': 'h', |
| 32 'handle<data_pipe_consumer>': 'h:d:c', | 32 'handle<data_pipe_consumer>': 'h:d:c', |
| 33 'handle<data_pipe_producer>': 'h:d:p', | 33 'handle<data_pipe_producer>': 'h:d:p', |
| 34 'handle<message_pipe>': 'h:m'} | 34 'handle<message_pipe>': 'h:m', |
| 35 'handle<shared_buffer>': 'h:s'} |
| 35 if kind.endswith('[]'): | 36 if kind.endswith('[]'): |
| 36 return 'a:' + MapKind(kind[0:len(kind)-2]) | 37 return 'a:' + MapKind(kind[0:len(kind)-2]) |
| 37 if kind in map_to_kind: | 38 if kind in map_to_kind: |
| 38 return map_to_kind[kind] | 39 return map_to_kind[kind] |
| 39 return 'x:' + kind | 40 return 'x:' + kind |
| 40 | 41 |
| 41 def MapOrdinal(ordinal): | 42 def MapOrdinal(ordinal): |
| 42 if ordinal == None: | 43 if ordinal == None: |
| 43 return None | 44 return None |
| 44 return int(ordinal[1:]) # Strip leading '@' | 45 return int(ordinal[1:]) # Strip leading '@' |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 135 print("usage: %s filename" % (sys.argv[0])) | 136 print("usage: %s filename" % (sys.argv[0])) |
| 136 sys.exit(1) | 137 sys.exit(1) |
| 137 tree = eval(open(sys.argv[1]).read()) | 138 tree = eval(open(sys.argv[1]).read()) |
| 138 name = os.path.splitext(os.path.basename(sys.argv[1]))[0] | 139 name = os.path.splitext(os.path.basename(sys.argv[1]))[0] |
| 139 result = Translate(tree, name) | 140 result = Translate(tree, name) |
| 140 print(result) | 141 print(result) |
| 141 | 142 |
| 142 | 143 |
| 143 if __name__ == '__main__': | 144 if __name__ == '__main__': |
| 144 Main() | 145 Main() |
| OLD | NEW |