Commit 231ae791 authored by Yuki Shiino's avatar Yuki Shiino Committed by Commit Bot

IDL compiler: Support IdlType.unwrap

Bug: 839389
Change-Id: I3132a118c708a85cb193379b147f8f09bf8564e9
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1882247Reviewed-by: default avatarHitoshi Yoshida <peria@chromium.org>
Commit-Queue: Yuki Shiino <yukishiino@chromium.org>
Cr-Commit-Position: refs/heads/master@{#709829}
parent ff3ee46b
......@@ -180,6 +180,18 @@ class IdlType(WithExtendedAttributes, WithDebugInfo):
"""
callback(self)
def unwrap(self, nullable=True, typedef=True):
"""
Returns the body part of the actual type, i.e. returns the interesting
part of this type.
Args:
nullable: Unwraps a nullable type and returns |inner_type| if True.
typedef: Dereferences a typedef type and returns |original_type| if
True.
"""
return self
@property
def does_include_nullable_type(self):
"""
......@@ -644,6 +656,12 @@ class TypedefType(IdlType, WithIdentifier):
callback(self)
self.original_type.apply_to_all_composing_elements(callback)
def unwrap(self, nullable=True, typedef=True):
if typedef:
return self.original_type.unwrap(
nullable=nullable, typedef=typedef)
return self
@property
def does_include_nullable_type(self):
return self.original_type.does_include_nullable_type
......@@ -1032,6 +1050,11 @@ class NullableType(IdlType):
callback(self)
self.inner_type.apply_to_all_composing_elements(callback)
def unwrap(self, nullable=True, typedef=True):
if nullable:
return self.inner_type.unwrap(nullable=nullable, typedef=typedef)
return self
@property
def does_include_nullable_type(self):
return True
......
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