Skip to content

Truly independent web browser

Meta: Preserve type annotations through typedef resolution

Callum Lawef6a3fff73f2
diff --git a/Meta/Generators/libweb_bindings/context.py b/Meta/Generators/libweb_bindings/context.py
index 9cc2df4883a..8b9feac52d4 100644
--- a/Meta/Generators/libweb_bindings/context.py
+++ b/Meta/Generators/libweb_bindings/context.py
@@ -262,7 +262,9 @@ class GenerationContext:
seen_types.add(resolved_type_without_nullable)
typedef_type = self.typedefs[resolved_type.name].type
- resolved_type = typedef_type.clone_with_nullable(resolved_type.nullable or typedef_type.nullable)
+ resolved_type = typedef_type.clone_with_nullable(
+ resolved_type.nullable or typedef_type.nullable
+ ).with_extended_attributes({**typedef_type.extended_attributes, **resolved_type.extended_attributes})
if isinstance(resolved_type, IDLUnionType):
return IDLUnionType(
diff --git a/Meta/Utils/webidl_parser.py b/Meta/Utils/webidl_parser.py
index fabb992b88b..b31370b5d96 100644
--- a/Meta/Utils/webidl_parser.py
+++ b/Meta/Utils/webidl_parser.py
@@ -94,6 +94,9 @@ class IDLType:
def clone_with_nullable(self, nullable: bool) -> "IDLType":
return IDLType(self.name, nullable, self.extended_attributes)
+ def with_extended_attributes(self, extended_attributes: Dict[str, str]) -> "IDLType":
+ return IDLType(self.name, self.nullable, extended_attributes)
+
def without_nullable(self) -> "IDLType":
return self.clone_with_nullable(False)
@@ -140,9 +143,15 @@ class IDLUnionType(IDLType):
def clone_with_nullable(self, nullable: bool) -> "IDLUnionType":
return IDLUnionType(self.member_types, nullable, self.extended_attributes)
+ def with_extended_attributes(self, extended_attributes: Dict[str, str]) -> "IDLUnionType":
+ return IDLUnionType(self.member_types, self.nullable, extended_attributes)
+
def flattened_member_types(self) -> List[IDLType]:
flattened_member_types: List[IDLType] = []
for member_type in self.member_types:
+ member_type = member_type.with_extended_attributes(
+ {**self.extended_attributes, **member_type.extended_attributes}
+ )
flattened_member_types.extend(member_type.flattened_member_types())
return flattened_member_types
@@ -177,6 +186,9 @@ class IDLParameterizedType(IDLType):
def clone_with_nullable(self, nullable: bool) -> "IDLParameterizedType":
return IDLParameterizedType(self.name, self.parameters, nullable, self.extended_attributes)
+ def with_extended_attributes(self, extended_attributes: Dict[str, str]) -> "IDLParameterizedType":
+ return IDLParameterizedType(self.name, self.parameters, self.nullable, extended_attributes)
+
def child_types(self) -> Tuple[IDLType, ...]:
return self.parameters