diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-06-12 05:35:29 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-06-12 05:35:29 +0000 |
commit | 59203c63bb777a3bacec32fb8830fba33540e809 (patch) | |
tree | 58298e711c0ff0575818c30485b44a2f21bf28a0 /dom/bindings/Codegen.py | |
parent | Adding upstream version 126.0.1. (diff) | |
download | firefox-59203c63bb777a3bacec32fb8830fba33540e809.tar.xz firefox-59203c63bb777a3bacec32fb8830fba33540e809.zip |
Adding upstream version 127.0.upstream/127.0
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'dom/bindings/Codegen.py')
-rw-r--r-- | dom/bindings/Codegen.py | 24 |
1 files changed, 16 insertions, 8 deletions
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 = [] |