| 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 """Node classes for the AST for a Mojo IDL file.""" | 5 """Node classes for the AST for a Mojo IDL file.""" |
| 6 | 6 |
| 7 # Note: For convenience of testing, you probably want to define __eq__() methods | 7 # Note: For convenience of testing, you probably want to define __eq__() methods |
| 8 # for all node types; it's okay to be slightly lax (e.g., not compare filename | 8 # for all node types; it's okay to be slightly lax (e.g., not compare filename |
| 9 # and lineno). You may also define __repr__() to help with analyzing test | 9 # and lineno). You may also define __repr__() to help with analyzing test |
| 10 # failures, especially for more complex types. | 10 # failures, especially for more complex types. |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 131 return super(Const, self).__eq__(other) and \ | 131 return super(Const, self).__eq__(other) and \ |
| 132 self.typename == other.typename and \ | 132 self.typename == other.typename and \ |
| 133 self.value == other.value | 133 self.value == other.value |
| 134 | 134 |
| 135 | 135 |
| 136 class Enum(Definition): | 136 class Enum(Definition): |
| 137 """Represents an enum definition.""" | 137 """Represents an enum definition.""" |
| 138 | 138 |
| 139 def __init__(self, name, attribute_list, enum_value_list, **kwargs): | 139 def __init__(self, name, attribute_list, enum_value_list, **kwargs): |
| 140 assert attribute_list is None or isinstance(attribute_list, AttributeList) | 140 assert attribute_list is None or isinstance(attribute_list, AttributeList) |
| 141 assert isinstance(enum_value_list, EnumValueList) | 141 assert isinstance(enum_value_list, EnumValueList) or enum_value_list is None |
| 142 super(Enum, self).__init__(name, **kwargs) | 142 super(Enum, self).__init__(name, **kwargs) |
| 143 self.attribute_list = attribute_list | 143 self.attribute_list = attribute_list |
| 144 self.enum_value_list = enum_value_list | 144 self.enum_value_list = enum_value_list |
| 145 | 145 |
| 146 def __eq__(self, other): | 146 def __eq__(self, other): |
| 147 return super(Enum, self).__eq__(other) and \ | 147 return super(Enum, self).__eq__(other) and \ |
| 148 self.attribute_list == other.attribute_list and \ | 148 self.attribute_list == other.attribute_list and \ |
| 149 self.enum_value_list == other.enum_value_list | 149 self.enum_value_list == other.enum_value_list |
| 150 | 150 |
| 151 | 151 |
| (...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 401 def __eq__(self, other): | 401 def __eq__(self, other): |
| 402 return super(UnionField, self).__eq__(other) and \ | 402 return super(UnionField, self).__eq__(other) and \ |
| 403 self.attribute_list == other.attribute_list and \ | 403 self.attribute_list == other.attribute_list and \ |
| 404 self.ordinal == other.ordinal and \ | 404 self.ordinal == other.ordinal and \ |
| 405 self.typename == other.typename | 405 self.typename == other.typename |
| 406 | 406 |
| 407 | 407 |
| 408 class UnionBody(NodeListBase): | 408 class UnionBody(NodeListBase): |
| 409 | 409 |
| 410 _list_item_type = UnionField | 410 _list_item_type = UnionField |
| OLD | NEW |