mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-21 20:15:17 +00:00
Meta: Add a gdb pretty-printer for Optional
This commit is contained in:
parent
5bd9f4c31c
commit
e5685078c1
Notes:
sideshowbarker
2024-07-17 08:38:37 +09:00
Author: https://github.com/LucasChollet Commit: https://github.com/SerenityOS/serenity/commit/e5685078c1 Pull-request: https://github.com/SerenityOS/serenity/pull/19522
1 changed files with 23 additions and 0 deletions
|
@ -42,6 +42,8 @@ def handler_class_for_type(type, re=re.compile('^([^<]+)(<.*>)?$')):
|
|||
return AKStringImpl
|
||||
elif klass == 'AK::Variant':
|
||||
return AKVariant
|
||||
elif klass == 'AK::Optional':
|
||||
return AKOptional
|
||||
elif klass == 'AK::Vector':
|
||||
return AKVector
|
||||
elif klass == 'VirtualAddress':
|
||||
|
@ -229,6 +231,27 @@ class AKVariant:
|
|||
return f'AK::Variant<{names}>'
|
||||
|
||||
|
||||
class AKOptional:
|
||||
def __init__(self, val):
|
||||
self.val = val
|
||||
self.has_value = bool(self.val["m_has_value"])
|
||||
self.contained_type = self.val.type.strip_typedefs().template_argument(0)
|
||||
|
||||
def to_string(self):
|
||||
return AKOptional.prettyprint_type(self.val.type)
|
||||
|
||||
def children(self):
|
||||
if self.has_value:
|
||||
data = self.val["m_storage"]
|
||||
return [(self.contained_type.name, data.cast(self.contained_type.pointer()).referenced_value())]
|
||||
return [("OptionalNone", "{}")]
|
||||
|
||||
@classmethod
|
||||
def prettyprint_type(cls, type):
|
||||
template_type = type.template_argument(0)
|
||||
return f'AK::Optional<{template_type}>'
|
||||
|
||||
|
||||
class AKVector:
|
||||
def __init__(self, val):
|
||||
self.val = val
|
||||
|
|
Loading…
Add table
Reference in a new issue