| 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 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 242 self.name = name | 242 self.name = name |
| 243 self.attribute_list = attribute_list | 243 self.attribute_list = attribute_list |
| 244 | 244 |
| 245 def __eq__(self, other): | 245 def __eq__(self, other): |
| 246 return super(Module, self).__eq__(other) and \ | 246 return super(Module, self).__eq__(other) and \ |
| 247 self.name == other.name and \ | 247 self.name == other.name and \ |
| 248 self.attribute_list == other.attribute_list | 248 self.attribute_list == other.attribute_list |
| 249 | 249 |
| 250 | 250 |
| 251 class Mojom(NodeBase): | 251 class Mojom(NodeBase): |
| 252 """Represents an entire .mojom file. (This is the root node.""" | 252 """Represents an entire .mojom file. (This is the root node.)""" |
| 253 | 253 |
| 254 def __init__(self, module, import_list, definition_list, **kwargs): | 254 def __init__(self, module, import_list, definition_list, **kwargs): |
| 255 assert module is None or isinstance(module, Module) | 255 assert module is None or isinstance(module, Module) |
| 256 assert isinstance(import_list, ImportList) | 256 assert isinstance(import_list, ImportList) |
| 257 assert isinstance(definition_list, list) | 257 assert isinstance(definition_list, list) |
| 258 super(Mojom, self).__init__(**kwargs) | 258 super(Mojom, self).__init__(**kwargs) |
| 259 self.module = module | 259 self.module = module |
| 260 self.import_list = import_list | 260 self.import_list = import_list |
| 261 self.definition_list = definition_list | 261 self.definition_list = definition_list |
| 262 | 262 |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 345 self.ordinal == other.ordinal and \ | 345 self.ordinal == other.ordinal and \ |
| 346 self.typename == other.typename and \ | 346 self.typename == other.typename and \ |
| 347 self.default_value == other.default_value | 347 self.default_value == other.default_value |
| 348 | 348 |
| 349 | 349 |
| 350 # This needs to be declared after |StructField|. | 350 # This needs to be declared after |StructField|. |
| 351 class StructBody(NodeListBase): | 351 class StructBody(NodeListBase): |
| 352 """Represents the body of (i.e., list of definitions inside) a struct.""" | 352 """Represents the body of (i.e., list of definitions inside) a struct.""" |
| 353 | 353 |
| 354 _list_item_type = (Const, Enum, StructField) | 354 _list_item_type = (Const, Enum, StructField) |
| OLD | NEW |