Commit d7be14b9 authored by Andrew McCreight's avatar Andrew McCreight
Browse files

Bug 15399486, part 3 - Only allow nostdcall methods and attributes on...

Bug 15399486, part 3 - Only allow nostdcall methods and attributes on builtinclass interfaces. r=nika

We don't properly implement them in JS, so only allow them for C++.

This patch also makes the only remaining non-builtinclass interface
with a nostdcall method, nsIBinaryOutputStream, builtinclass.

This also changes the isScriptable() method to be consistent,
though I think the change doesn't matter because the only
place that calls it also checks if the interface is builtinclass.

Differential Revision: https://phabricator.services.mozilla.com/D98863
parent a7c29997
Loading
Loading
Loading
Loading
+12 −6
Original line number Diff line number Diff line
@@ -1061,11 +1061,8 @@ def ensureInfallibleIsSound(methodOrAttribute):
        )


# An interface cannot be implemented by JS if it has a notxpcom
# An interface cannot be implemented by JS if it has a notxpcom or nostdcall
# method or attribute, so it must be marked as builtinclass.
#
# XXX(nika): Why does nostdcall not imply builtinclass?
# It could screw up the shims as well...
def ensureBuiltinClassIfNeeded(methodOrAttribute):
    iface = methodOrAttribute.iface
    if not iface.attributes.scriptable or iface.attributes.builtinclass:
@@ -1081,6 +1078,15 @@ def ensureBuiltinClassIfNeeded(methodOrAttribute):
            % (iface.name, methodOrAttribute.kind, methodOrAttribute.name),
            methodOrAttribute.location,
        )
    if methodOrAttribute.nostdcall:
        raise IDLError(
            (
                "scriptable interface '%s' must be marked [builtinclass] because it "
                "contains a [nostdcall] %s '%s'"
            )
            % (iface.name, methodOrAttribute.kind, methodOrAttribute.name),
            methodOrAttribute.location,
        )


class Attribute(object):
@@ -1179,7 +1185,7 @@ class Attribute(object):
    def isScriptable(self):
        if not self.iface.attributes.scriptable:
            return False
        return not (self.noscript or self.notxpcom)
        return not (self.noscript or self.notxpcom or self.nostdcall)

    def __str__(self):
        return "\t%sattribute %s %s\n" % (
@@ -1289,7 +1295,7 @@ class Method(object):
    def isScriptable(self):
        if not self.iface.attributes.scriptable:
            return False
        return not (self.noscript or self.notxpcom)
        return not (self.noscript or self.notxpcom or self.nostdcall)

    def __str__(self):
        return "\t%s %s(%s)\n" % (
+1 −1
Original line number Diff line number Diff line
@@ -24,7 +24,7 @@ native Bytes(mozilla::Span<const uint8_t>);
 * @See nsIBinaryInputStream
 */

[scriptable, uuid(204ee610-8765-11d3-90cf-0040056a906e)]
[scriptable, builtinclass, uuid(204ee610-8765-11d3-90cf-0040056a906e)]
interface nsIBinaryOutputStream : nsIOutputStream {
    void setOutputStream(in nsIOutputStream aOutputStream);