From 8dd16259287f58f9273002717ec4d27e97127719 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Wed, 12 Jun 2024 07:43:14 +0200 Subject: Merging upstream version 127.0. Signed-off-by: Daniel Baumann --- dom/bindings/Codegen.py | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) (limited to 'dom/bindings/Codegen.py') diff --git a/dom/bindings/Codegen.py b/dom/bindings/Codegen.py index a6a49f9b2f..de9444b42f 100644 --- a/dom/bindings/Codegen.py +++ b/dom/bindings/Codegen.py @@ -8937,10 +8937,12 @@ def wrapTypeIntoCurrentCompartment(type, value, isMember=True): return CGList(memberWraps) if len(memberWraps) != 0 else None if type.isUnion(): - memberWraps = [] + origValue = value + origType = type if type.nullable(): type = type.inner value = "%s.Value()" % value + memberWraps = [] for member in type.flatMemberTypes: memberName = getUnionMemberName(member) memberWrap = wrapTypeIntoCurrentCompartment( @@ -8949,7 +8951,12 @@ def wrapTypeIntoCurrentCompartment(type, value, isMember=True): if memberWrap: memberWrap = CGIfWrapper(memberWrap, "%s.Is%s()" % (value, memberName)) memberWraps.append(memberWrap) - return CGList(memberWraps, "else ") if len(memberWraps) != 0 else None + if len(memberWraps) == 0: + return None + wrapCode = CGList(memberWraps, "else ") + if origType.nullable(): + wrapCode = CGIfWrapper(wrapCode, "!%s.IsNull()" % origValue) + return wrapCode if ( type.isUndefined() @@ -8996,7 +9003,8 @@ class CGPerSignatureCall(CGThing): actual return value (e.g. this is an attribute setter) or an IDLType if there's an IDL type involved (including |void|). 2) An argument list, which is allowed to be empty. - 3) A name of a native method to call. + 3) A name of a native method to call. It is ignored for methods + annotated with the "[WebExtensionStub=...]" extended attribute. 4) Whether or not this method is static. Note that this only controls how the method is called (|self->nativeMethodName(...)| vs |nativeMethodName(...)|). @@ -9370,7 +9378,7 @@ class CGPerSignatureCall(CGThing): nativeMethodName, argsPre, args, - ] = self.processWebExtensionStubAttribute(idlNode, cgThings) + ] = self.processWebExtensionStubAttribute(cgThings) else: args = self.getArguments() @@ -9439,9 +9447,9 @@ class CGPerSignatureCall(CGThing): def getArguments(self): return list(zip(self.arguments, self.getArgumentNames())) - def processWebExtensionStubAttribute(self, idlNode, cgThings): + def processWebExtensionStubAttribute(self, cgThings): nativeMethodName = "CallWebExtMethod" - stubNameSuffix = idlNode.getExtendedAttribute("WebExtensionStub") + stubNameSuffix = self.idlNode.getExtendedAttribute("WebExtensionStub") if isinstance(stubNameSuffix, list): nativeMethodName += stubNameSuffix[0] @@ -9454,7 +9462,7 @@ class CGPerSignatureCall(CGThing): if singleVariadicArg: argsPre = [ "cx", - 'u"%s"_ns' % idlNode.identifier.name, + 'u"%s"_ns' % self.idlNode.identifier.name, "Constify(%s)" % "arg0", ] args = [] @@ -9462,7 +9470,7 @@ class CGPerSignatureCall(CGThing): argsPre = [ "cx", - 'u"%s"_ns' % idlNode.identifier.name, + 'u"%s"_ns' % self.idlNode.identifier.name, "Constify(%s)" % "args_sequence", ] args = [] -- cgit v1.2.3