Commit 60685f5e authored by Yuki Shiino's avatar Yuki Shiino Committed by Commit Bot

IDL compiler: Support unwrap of variadic argument types

IdlType.unwrap supports variadic={True,False} in addition to
nullable and typedef.

Bug: 839389
Change-Id: I2f2d2cb2a79e0c33f56ab9df4d322f778c756dee
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1932137Reviewed-by: default avatarHitoshi Yoshida <peria@chromium.org>
Commit-Queue: Yuki Shiino <yukishiino@chromium.org>
Cr-Commit-Position: refs/heads/master@{#718551}
parent 43b7bd32
......@@ -225,14 +225,15 @@ def bind_v8_set_return_value(code_node, cg_context):
_1 = "V8SetReturnValue"
_2 = ["${info}", "${return_value}"]
if cg_context.return_type.unwrap().is_void:
return_type = cg_context.return_type.unwrap(nullable=True, typedef=True)
if return_type.is_void:
# Render a SymbolNode |return_value| discarding the content text, and
# let a symbol definition be added.
pattern = "<% str(return_value) %>"
elif (cg_context.for_world == cg_context.MAIN_WORLD
and cg_context.return_type.unwrap().is_interface):
and return_type.is_interface):
_1 = "V8SetReturnValueForMainWorld"
elif cg_context.return_type.unwrap().is_interface:
elif return_type.is_interface:
_2.append("${creation_context_object}")
text = _format(pattern, _1=_1, _2=", ".join(_2))
......
......@@ -219,7 +219,7 @@ class IdlType(WithExtendedAttributes, WithDebugInfo):
"""
callback(self)
def unwrap(self, nullable=None, typedef=None):
def unwrap(self, nullable=None, typedef=None, variadic=None):
"""
Returns the body part of the actual type, i.e. returns the interesting
part of this type.
......@@ -237,6 +237,7 @@ class IdlType(WithExtendedAttributes, WithDebugInfo):
switches = {
'nullable': nullable,
'typedef': typedef,
'variadic': variadic,
}
value_counts = {None: 0, False: 0, True: 0}
......@@ -886,6 +887,11 @@ class VariadicType(_ArrayLikeType):
def is_variadic(self):
return True
def _unwrap(self, switches):
if switches['variadic']:
return self.element_type._unwrap(switches)
return self
class RecordType(IdlType):
"""https://heycam.github.io/webidl/#idl-record"""
......
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