| OLD | NEW |
| 1 # Copyright 2013 The Chromium Authors. All rights reserved. | 1 # Copyright 2013 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 # This module's classes provide an interface to mojo modules. Modules are | 5 # This module's classes provide an interface to mojo modules. Modules are |
| 6 # collections of interfaces and structs to be used by mojo ipc clients and | 6 # collections of interfaces and structs to be used by mojo ipc clients and |
| 7 # servers. | 7 # servers. |
| 8 # | 8 # |
| 9 # A simple interface would be created this way: | 9 # A simple interface would be created this way: |
| 10 # module = mojom.generate.module.Module('Foo') | 10 # module = mojom.generate.module.Module('Foo') |
| (...skipping 605 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 616 else: | 616 else: |
| 617 return GenericRepr(self, {'name': False, 'fields': False}) | 617 return GenericRepr(self, {'name': False, 'fields': False}) |
| 618 | 618 |
| 619 @property | 619 @property |
| 620 def extensible(self): | 620 def extensible(self): |
| 621 return self.attributes.get(ATTRIBUTE_EXTENSIBLE, False) \ | 621 return self.attributes.get(ATTRIBUTE_EXTENSIBLE, False) \ |
| 622 if self.attributes else False | 622 if self.attributes else False |
| 623 | 623 |
| 624 | 624 |
| 625 class Module(object): | 625 class Module(object): |
| 626 def __init__(self, name=None, namespace=None, attributes=None): | 626 def __init__(self, path=None, namespace=None, attributes=None): |
| 627 self.name = name | 627 self.path = path |
| 628 self.path = name | |
| 629 self.namespace = namespace | 628 self.namespace = namespace |
| 630 self.structs = [] | 629 self.structs = [] |
| 631 self.unions = [] | 630 self.unions = [] |
| 632 self.interfaces = [] | 631 self.interfaces = [] |
| 633 self.kinds = {} | 632 self.kinds = {} |
| 634 self.attributes = attributes | 633 self.attributes = attributes |
| 635 | 634 |
| 636 def __repr__(self): | 635 def __repr__(self): |
| 637 # Gives us a decent __repr__ for modules. | 636 # Gives us a decent __repr__ for modules. |
| 638 return self.Repr() | 637 return self.Repr() |
| 639 | 638 |
| 640 def Repr(self, as_ref=True): | 639 def Repr(self, as_ref=True): |
| 641 if as_ref: | 640 if as_ref: |
| 642 return '<%s name=%r namespace=%r>' % ( | 641 return '<%s path=%r namespace=%r>' % ( |
| 643 self.__class__.__name__, self.name, self.namespace) | 642 self.__class__.__name__, self.path, self.namespace) |
| 644 else: | 643 else: |
| 645 return GenericRepr(self, {'name': False, 'namespace': False, | 644 return GenericRepr(self, {'path': False, 'namespace': False, |
| 646 'attributes': False, 'structs': False, | 645 'attributes': False, 'structs': False, |
| 647 'interfaces': False, 'unions': False}) | 646 'interfaces': False, 'unions': False}) |
| 648 | 647 |
| 649 def AddInterface(self, name, attributes=None): | 648 def AddInterface(self, name, attributes=None): |
| 650 interface = Interface(name, self, attributes) | 649 interface = Interface(name, self, attributes) |
| 651 self.interfaces.append(interface) | 650 self.interfaces.append(interface) |
| 652 return interface | 651 return interface |
| 653 | 652 |
| 654 def AddStruct(self, name, attributes=None): | 653 def AddStruct(self, name, attributes=None): |
| 655 struct = Struct(name, self, attributes) | 654 struct = Struct(name, self, attributes) |
| (...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 873 return True | 872 return True |
| 874 elif IsAnyInterfaceKind(kind): | 873 elif IsAnyInterfaceKind(kind): |
| 875 return True | 874 return True |
| 876 elif IsArrayKind(kind): | 875 elif IsArrayKind(kind): |
| 877 return Check(kind.kind) | 876 return Check(kind.kind) |
| 878 elif IsMapKind(kind): | 877 elif IsMapKind(kind): |
| 879 return Check(kind.key_kind) or Check(kind.value_kind) | 878 return Check(kind.key_kind) or Check(kind.value_kind) |
| 880 else: | 879 else: |
| 881 return False | 880 return False |
| 882 return Check(kind) | 881 return Check(kind) |
| OLD | NEW |