| 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 457 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 468 elif hasattr(kind, 'name'): | 468 elif hasattr(kind, 'name'): |
| 469 return kind.name | 469 return kind.name |
| 470 else: | 470 else: |
| 471 # These kinds (e.g., simple kinds, maps, and arrays) lack names. | 471 # These kinds (e.g., simple kinds, maps, and arrays) lack names. |
| 472 raise Exception('Unexpected kind: %s' % kind) | 472 raise Exception('Unexpected kind: %s' % kind) |
| 473 | 473 |
| 474 def GetPackageName(kind): | 474 def GetPackageName(kind): |
| 475 """Get the package name from the given kind's module.""" | 475 """Get the package name from the given kind's module.""" |
| 476 return kind.module.name.split('.')[0] | 476 return kind.module.name.split('.')[0] |
| 477 | 477 |
| 478 # TODO(rudominer) Remove this once the switch to the new runtime type |
| 479 # discovery mechanism is complete. |
| 478 def GetMojomTypeIdentifier(kind): | 480 def GetMojomTypeIdentifier(kind): |
| 479 """Get the mojom type's unique identifier from the kind's package and name.""" | 481 """Get the mojom type's unique identifier from the kind's package and name.""" |
| 480 # Note: InterfaceRequest's should use the Interface inside them. | 482 # Note: InterfaceRequest's should use the Interface inside them. |
| 481 if hasattr(kind, 'module'): | 483 if hasattr(kind, 'module'): |
| 482 package = GetPackageName(kind) | 484 package = GetPackageName(kind) |
| 483 elif IsInterfaceRequestKind(kind): | 485 elif IsInterfaceRequestKind(kind): |
| 484 package = GetPackageName(kind.kind) | 486 package = GetPackageName(kind.kind) |
| 485 else: | 487 else: |
| 486 # These kinds (e.g., simple kinds and fields) lack identifiers. | 488 # These kinds (e.g., simple kinds and fields) lack identifiers. |
| 487 raise Exception('Unexpected kind: %s' % kind) | 489 raise Exception('Unexpected kind: %s' % kind) |
| 488 return "%s_%s__" % (package, GetMojomTypeName(kind)) | 490 return "%s_%s__" % (package, GetMojomTypeName(kind)) |
| 489 | 491 |
| 490 | 492 |
| 491 # Returns a string of the form package.path.TypeName - the full identifier | 493 # Returns a string of the form package.path.TypeName - the full identifier |
| 492 # for an element. | 494 # for an element. |
| 495 # TODO(rudominer) Remove this once the switch to the new runtime type |
| 496 # discovery mechanism is complete. |
| 493 def GetMojomTypeFullIdentifier(kind, exported=True): | 497 def GetMojomTypeFullIdentifier(kind, exported=True): |
| 494 """Get the Full Identifier for a Mojom Type. Format: package.path.TypeName""" | 498 """Get the Full Identifier for a Mojom Type. Format: package.path.TypeName""" |
| 495 return '%s.%s' % (kind.module.namespace, GetMojomTypeName(kind)) | 499 return '%s.%s' % (kind.module.namespace, GetMojomTypeName(kind)) |
| 496 | 500 |
| 497 | 501 |
| 498 def IsBoolKind(kind): | 502 def IsBoolKind(kind): |
| 499 return kind.spec == BOOL.spec | 503 return kind.spec == BOOL.spec |
| 500 | 504 |
| 501 | 505 |
| 502 def IsFloatKind(kind): | 506 def IsFloatKind(kind): |
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 631 return False | 635 return False |
| 632 | 636 |
| 633 return not ContainsHandles(kind, set()) | 637 return not ContainsHandles(kind, set()) |
| 634 | 638 |
| 635 | 639 |
| 636 def HasCallbacks(interface): | 640 def HasCallbacks(interface): |
| 637 for method in interface.methods: | 641 for method in interface.methods: |
| 638 if method.response_parameters != None: | 642 if method.response_parameters != None: |
| 639 return True | 643 return True |
| 640 return False | 644 return False |
| OLD | NEW |