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

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

Issue 844433003: Revert "Generate some of the C++ bindings for mojom tagged unions." (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 5 years, 11 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
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 404 matching lines...) Expand 10 before | Expand all | Expand 10 after
415 415
416 def IsSharedBufferKind(kind): 416 def IsSharedBufferKind(kind):
417 return (kind.spec == SHAREDBUFFER.spec or 417 return (kind.spec == SHAREDBUFFER.spec or
418 kind.spec == NULLABLE_SHAREDBUFFER.spec) 418 kind.spec == NULLABLE_SHAREDBUFFER.spec)
419 419
420 420
421 def IsStructKind(kind): 421 def IsStructKind(kind):
422 return isinstance(kind, Struct) 422 return isinstance(kind, Struct)
423 423
424 424
425 def IsUnionKind(kind):
426 return isinstance(kind, Union)
427
428
429 def IsArrayKind(kind): 425 def IsArrayKind(kind):
430 return isinstance(kind, Array) 426 return isinstance(kind, Array)
431 427
432 428
433 def IsInterfaceKind(kind): 429 def IsInterfaceKind(kind):
434 return isinstance(kind, Interface) 430 return isinstance(kind, Interface)
435 431
436 432
437 def IsInterfaceRequestKind(kind): 433 def IsInterfaceRequestKind(kind):
438 return isinstance(kind, InterfaceRequest) 434 return isinstance(kind, InterfaceRequest)
(...skipping 10 matching lines...) Expand all
449 def IsNullableKind(kind): 445 def IsNullableKind(kind):
450 return IsReferenceKind(kind) and kind.is_nullable 446 return IsReferenceKind(kind) and kind.is_nullable
451 447
452 448
453 def IsMapKind(kind): 449 def IsMapKind(kind):
454 return isinstance(kind, Map) 450 return isinstance(kind, Map)
455 451
456 452
457 def IsObjectKind(kind): 453 def IsObjectKind(kind):
458 return (IsStructKind(kind) or IsArrayKind(kind) or IsStringKind(kind) or 454 return (IsStructKind(kind) or IsArrayKind(kind) or IsStringKind(kind) or
459 IsMapKind(kind) or IsUnionKind(kind)) 455 IsMapKind(kind))
460 456
461 457
462 def IsNonInterfaceHandleKind(kind): 458 def IsNonInterfaceHandleKind(kind):
463 return (IsHandleKind(kind) or 459 return (IsHandleKind(kind) or
464 IsDataPipeConsumerKind(kind) or 460 IsDataPipeConsumerKind(kind) or
465 IsDataPipeProducerKind(kind) or 461 IsDataPipeProducerKind(kind) or
466 IsMessagePipeKind(kind) or 462 IsMessagePipeKind(kind) or
467 IsSharedBufferKind(kind)) 463 IsSharedBufferKind(kind))
468 464
469 465
(...skipping 10 matching lines...) Expand all
480 def IsCloneableKind(kind): 476 def IsCloneableKind(kind):
481 def ContainsHandles(kind, visited_kinds): 477 def ContainsHandles(kind, visited_kinds):
482 if kind in visited_kinds: 478 if kind in visited_kinds:
483 # No need to examine the kind again. 479 # No need to examine the kind again.
484 return False 480 return False
485 visited_kinds.add(kind) 481 visited_kinds.add(kind)
486 if IsAnyHandleKind(kind): 482 if IsAnyHandleKind(kind):
487 return True 483 return True
488 if IsArrayKind(kind): 484 if IsArrayKind(kind):
489 return ContainsHandles(kind.kind, visited_kinds) 485 return ContainsHandles(kind.kind, visited_kinds)
490 if IsStructKind(kind) or IsUnionKind(kind): 486 if IsStructKind(kind):
491 for field in kind.fields: 487 for field in kind.fields:
492 if ContainsHandles(field.kind, visited_kinds): 488 if ContainsHandles(field.kind, visited_kinds):
493 return True 489 return True
494 return False 490 return False
495 491
496 return not ContainsHandles(kind, set()) 492 return not ContainsHandles(kind, set())
497 493
498 494
499 def HasCallbacks(interface): 495 def HasCallbacks(interface):
500 for method in interface.methods: 496 for method in interface.methods:
501 if method.response_parameters != None: 497 if method.response_parameters != None:
502 return True 498 return True
503 return False 499 return False
504 500
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698