Commit 187194e9 authored by Yuki Shiino's avatar Yuki Shiino Committed by Commit Bot

IDL compiler: Support {Constructor,Operation}Group.components

Bug: 839389
Change-Id: If04ceea51b0e709fb8da91f6947140f754889ea6
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1943077
Commit-Queue: Yuki Shiino <yukishiino@chromium.org>
Reviewed-by: default avatarHitoshi Yoshida <peria@chromium.org>
Cr-Commit-Position: refs/heads/master@{#720421}
parent ed90a5ee
......@@ -2,6 +2,8 @@
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
import functools
from .code_generator_info import CodeGeneratorInfo
from .composition_parts import Identifier
from .composition_parts import WithCodeGeneratorInfo
......@@ -56,7 +58,7 @@ class Constructor(FunctionLike, WithExtendedAttributes, WithCodeGeneratorInfo,
class ConstructorGroup(OverloadGroup, WithCodeGeneratorInfo, WithExposure,
WithOwner, WithDebugInfo):
WithOwner, WithComponent, WithDebugInfo):
"""
Represents a group of constructors for an interface.
......@@ -84,9 +86,14 @@ class ConstructorGroup(OverloadGroup, WithCodeGeneratorInfo, WithExposure,
assert all(constructor.identifier == ir.identifier
for constructor in constructors)
components = functools.reduce(
lambda s, constructor: s.union(constructor.components),
constructors, set())
ir = make_copy(ir)
OverloadGroup.__init__(self, functions=constructors)
WithCodeGeneratorInfo.__init__(self, ir, readonly=True)
WithExposure.__init__(self, ir, readonly=True)
WithOwner.__init__(self, owner)
WithComponent.__init__(self, sorted(components))
WithDebugInfo.__init__(self, ir)
......@@ -2,6 +2,8 @@
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
import functools
from .argument import Argument
from .code_generator_info import CodeGeneratorInfo
from .composition_parts import WithCodeGeneratorInfo
......@@ -68,7 +70,7 @@ class Operation(FunctionLike, WithExtendedAttributes, WithCodeGeneratorInfo,
class OperationGroup(OverloadGroup, WithCodeGeneratorInfo, WithExposure,
WithOwner, WithDebugInfo):
WithOwner, WithComponent, WithDebugInfo):
"""
Represents a group of operations with the same identifier.
......@@ -95,9 +97,14 @@ class OperationGroup(OverloadGroup, WithCodeGeneratorInfo, WithExposure,
assert all(
operation.identifier == ir.identifier for operation in operations)
components = functools.reduce(
lambda s, operation: s.union(operation.components), operations,
set())
ir = make_copy(ir)
OverloadGroup.__init__(self, functions=operations)
WithCodeGeneratorInfo.__init__(self, ir, readonly=True)
WithExposure.__init__(self, ir, readonly=True)
WithOwner.__init__(self, owner)
WithComponent.__init__(self, sorted(components))
WithDebugInfo.__init__(self, ir)
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment