| 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 308 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 319 """Represents a list of (method request or response) parameters.""" | 319 """Represents a list of (method request or response) parameters.""" |
| 320 | 320 |
| 321 _list_item_type = Parameter | 321 _list_item_type = Parameter |
| 322 | 322 |
| 323 | 323 |
| 324 class Struct(Definition): | 324 class Struct(Definition): |
| 325 """Represents a struct definition.""" | 325 """Represents a struct definition.""" |
| 326 | 326 |
| 327 def __init__(self, name, attribute_list, body, **kwargs): | 327 def __init__(self, name, attribute_list, body, **kwargs): |
| 328 assert attribute_list is None or isinstance(attribute_list, AttributeList) | 328 assert attribute_list is None or isinstance(attribute_list, AttributeList) |
| 329 assert isinstance(body, StructBody) | 329 assert isinstance(body, StructBody) or body is None |
| 330 super(Struct, self).__init__(name, **kwargs) | 330 super(Struct, self).__init__(name, **kwargs) |
| 331 self.attribute_list = attribute_list | 331 self.attribute_list = attribute_list |
| 332 self.body = body | 332 self.body = body |
| 333 | 333 |
| 334 def __eq__(self, other): | 334 def __eq__(self, other): |
| 335 return super(Struct, self).__eq__(other) and \ | 335 return super(Struct, self).__eq__(other) and \ |
| 336 self.attribute_list == other.attribute_list and \ | 336 self.attribute_list == other.attribute_list and \ |
| 337 self.body == other.body | 337 self.body == other.body |
| 338 | 338 |
| 339 | 339 |
| (...skipping 61 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 |