| 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 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 112 if (mojom.IsEnumKind(element) or mojom.IsInterfaceKind(element) or | 112 if (mojom.IsEnumKind(element) or mojom.IsInterfaceKind(element) or |
| 113 mojom.IsStructKind(element)): | 113 mojom.IsStructKind(element)): |
| 114 return UpperCamelCase(element.name) | 114 return UpperCamelCase(element.name) |
| 115 if mojom.IsInterfaceRequestKind(element): | 115 if mojom.IsInterfaceRequestKind(element): |
| 116 return GetNameForElement(element.kind) | 116 return GetNameForElement(element.kind) |
| 117 if isinstance(element, (mojom.Method, | 117 if isinstance(element, (mojom.Method, |
| 118 mojom.Parameter, | 118 mojom.Parameter, |
| 119 mojom.Field)): | 119 mojom.Field)): |
| 120 return CamelCase(element.name) | 120 return CamelCase(element.name) |
| 121 if isinstance(element, mojom.EnumValue): | 121 if isinstance(element, mojom.EnumValue): |
| 122 return (UpperCamelCase(element.enum_name) + '.' + | 122 return (GetNameForElement(element.enum) + '.' + |
| 123 ConstantStyle(element.name)) | 123 ConstantStyle(element.name)) |
| 124 if isinstance(element, (mojom.NamedValue, | 124 if isinstance(element, (mojom.NamedValue, |
| 125 mojom.Constant)): | 125 mojom.Constant)): |
| 126 return ConstantStyle(element.name) | 126 return ConstantStyle(element.name) |
| 127 raise Exception('Unexpected element: ' % element) | 127 raise Exception('Unexpected element: ' % element) |
| 128 | 128 |
| 129 def GetInterfaceResponseName(method): | 129 def GetInterfaceResponseName(method): |
| 130 return UpperCamelCase(method.name + 'Response') | 130 return UpperCamelCase(method.name + 'Response') |
| 131 | 131 |
| 132 def ParseStringAttribute(attribute): | 132 def ParseStringAttribute(attribute): |
| (...skipping 320 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 453 return { | 453 return { |
| 454 'lstrip_blocks': True, | 454 'lstrip_blocks': True, |
| 455 'trim_blocks': True, | 455 'trim_blocks': True, |
| 456 } | 456 } |
| 457 | 457 |
| 458 def GetGlobals(self): | 458 def GetGlobals(self): |
| 459 return { | 459 return { |
| 460 'namespace': self.module.namespace, | 460 'namespace': self.module.namespace, |
| 461 'module': self.module, | 461 'module': self.module, |
| 462 } | 462 } |
| OLD | NEW |