Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(166)

Side by Side Diff: mojo/public/tools/bindings/pylib/mojom/generate/module.py

Issue 1753013002: Mojom runtime type info: New implementation for Dart. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: No changes to sha1s Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « mojo/public/tools/bindings/generators/mojom_dart_generator.py ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 445 matching lines...) Expand 10 before | Expand all | Expand 10 after
456 def AddStruct(self, name, attributes=None): 456 def AddStruct(self, name, attributes=None):
457 struct = Struct(name, self, attributes) 457 struct = Struct(name, self, attributes)
458 self.structs.append(struct) 458 self.structs.append(struct)
459 return struct 459 return struct
460 460
461 def AddUnion(self, name, attributes=None): 461 def AddUnion(self, name, attributes=None):
462 union = Union(name, self, attributes) 462 union = Union(name, self, attributes)
463 self.unions.append(union) 463 self.unions.append(union)
464 return union 464 return union
465 465
466 def GetMojomTypeName(kind):
467 """Get the mojom type's name from its kind."""
468 # Note: InterfaceRequest's should use the Interface inside them.
469 if IsInterfaceRequestKind(kind):
470 return kind.kind.name
471 elif hasattr(kind, 'name'):
472 return kind.name
473 else:
474 # These kinds (e.g., simple kinds, maps, and arrays) lack names.
475 raise Exception('Unexpected kind: %s' % kind)
476
477 def GetPackageName(kind): 466 def GetPackageName(kind):
478 """Get the package name from the given kind's module.""" 467 """Get the package name from the given kind's module."""
479 return kind.module.name.split('.')[0] 468 return kind.module.name.split('.')[0]
480 469
481 # TODO(rudominer) Remove this once the switch to the new runtime type
482 # discovery mechanism is complete.
483 def GetMojomTypeIdentifier(kind):
484 """Get the mojom type's unique identifier from the kind's package and name."""
485 # Note: InterfaceRequest's should use the Interface inside them.
486 if hasattr(kind, 'module'):
487 package = GetPackageName(kind)
488 elif IsInterfaceRequestKind(kind):
489 package = GetPackageName(kind.kind)
490 else:
491 # These kinds (e.g., simple kinds and fields) lack identifiers.
492 raise Exception('Unexpected kind: %s' % kind)
493 return "%s_%s__" % (package, GetMojomTypeName(kind))
494
495
496 # Returns a string of the form package.path.TypeName - the full identifier
497 # for an element.
498 # TODO(rudominer) Remove this once the switch to the new runtime type
499 # discovery mechanism is complete.
500 def GetMojomTypeFullIdentifier(kind, exported=True):
501 """Get the Full Identifier for a Mojom Type. Format: package.path.TypeName"""
502 return '%s.%s' % (kind.module.namespace, GetMojomTypeName(kind))
503
504
505 def IsBoolKind(kind): 470 def IsBoolKind(kind):
506 return kind.spec == BOOL.spec 471 return kind.spec == BOOL.spec
507 472
508 473
509 def IsFloatKind(kind): 474 def IsFloatKind(kind):
510 return kind.spec == FLOAT.spec 475 return kind.spec == FLOAT.spec
511 476
512 477
513 def IsDoubleKind(kind): 478 def IsDoubleKind(kind):
514 return kind.spec == DOUBLE.spec 479 return kind.spec == DOUBLE.spec
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
639 604
640 def IsCloneableKind(kind): 605 def IsCloneableKind(kind):
641 return not ContainsHandles(kind, set()) 606 return not ContainsHandles(kind, set())
642 607
643 608
644 def HasCallbacks(interface): 609 def HasCallbacks(interface):
645 for method in interface.methods: 610 for method in interface.methods:
646 if method.response_parameters != None: 611 if method.response_parameters != None:
647 return True 612 return True
648 return False 613 return False
OLDNEW
« no previous file with comments | « mojo/public/tools/bindings/generators/mojom_dart_generator.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698