Bug 1554195. Remove MSG_THIS_DOES_NOT_IMPLEMENT_INTERFACE. r=mccr8

I was clearly trying to do that in bug 882653 part 3 and failed to.  Our
current behavior of passing two args to this error message (which only takes
one arg) is silly, and the only thing that makes it at all sane is that we only
use it in class hooks, which can never have the wrong sort of object, so it's
unreached code.

The comment cleanup is just to make the role of CGAbstractBindingMethod. and
the validity of the changes to it, clearer.

Differential Revision: https://phabricator.services.mozilla.com/D32478

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Boris Zbarsky 2019-05-24 17:31:42 +00:00
Родитель a859c53225
Коммит 943dde7841
3 изменённых файлов: 19 добавлений и 12 удалений

Просмотреть файл

@ -9402,14 +9402,14 @@ static void DoCustomElementCreate(Element** aElement, JSContext* aCx,
UNWRAP_OBJECT(Element, &constructResult, element);
if (aNodeInfo->NamespaceEquals(kNameSpaceID_XHTML)) {
if (!element || !element->IsHTMLElement()) {
aRv.ThrowTypeError<MSG_THIS_DOES_NOT_IMPLEMENT_INTERFACE>(
NS_LITERAL_STRING("HTMLElement"));
aRv.ThrowTypeError<MSG_DOES_NOT_IMPLEMENT_INTERFACE>(
NS_LITERAL_STRING("\"this\""), NS_LITERAL_STRING("HTMLElement"));
return;
}
} else {
if (!element || !element->IsXULElement()) {
aRv.ThrowTypeError<MSG_THIS_DOES_NOT_IMPLEMENT_INTERFACE>(
NS_LITERAL_STRING("XULElement"));
aRv.ThrowTypeError<MSG_DOES_NOT_IMPLEMENT_INTERFACE>(
NS_LITERAL_STRING("\"this\""), NS_LITERAL_STRING("XULElement"));
return;
}
}

Просмотреть файл

@ -8743,11 +8743,12 @@ class CGSetterCall(CGPerSignatureCall):
class CGAbstractBindingMethod(CGAbstractStaticMethod):
"""
Common class to generate the JSNatives for all our methods, getters, and
setters. This will generate the function declaration and unwrap the
|this| object. Subclasses are expected to override the generate_code
function to do the rest of the work. This function should return a
CGThing which is already properly indented.
Common class to generate some of our class hooks. This will generate the
function declaration, get a reference to the JS object for our binding
object (which might be an argument of the class hook or something we get
from a JS::CallArgs), and unwrap into the right C++ type. Subclasses are
expected to override the generate_code function to do the rest of the work.
This function should return a CGThing which is already properly indented.
getThisObj should be code for getting a JSObject* for the binding
object. "" can be passed in if the binding object is already stored in
@ -8755,14 +8756,21 @@ class CGAbstractBindingMethod(CGAbstractStaticMethod):
callArgs should be code for getting a JS::CallArgs into a variable
called 'args'. This can be "" if there is already such a variable
around.
around or if the body does not need a JS::CallArgs.
"""
def __init__(self, descriptor, name, args, getThisObj,
callArgs="JS::CallArgs args = JS::CallArgsFromVp(argc, vp);\n"):
CGAbstractStaticMethod.__init__(self, descriptor, name, "bool", args,
canRunScript=True)
self.unwrapFailureCode = 'return ThrowErrorMessage(cx, MSG_THIS_DOES_NOT_IMPLEMENT_INTERFACE, "Value", "%s");\n' % descriptor.interface.identifier.name
# This can't ever happen, because we only use this for class hooks.
self.unwrapFailureCode = fill(
"""
MOZ_CRASH("Unexpected object in '${name}' hook");
return false;
""",
name=name)
if getThisObj == "":
self.getThisObj = None

Просмотреть файл

@ -30,7 +30,6 @@ MSG_DEF(MSG_NOT_CONSTRUCTOR, 1, JSEXN_TYPEERR, "{0} is not a constructor.")
MSG_DEF(MSG_DOES_NOT_IMPLEMENT_INTERFACE, 2, JSEXN_TYPEERR, "{0} does not implement interface {1}.")
MSG_DEF(MSG_METHOD_THIS_DOES_NOT_IMPLEMENT_INTERFACE, 2, JSEXN_TYPEERR, "'{0}' called on an object that does not implement interface {1}.")
MSG_DEF(MSG_METHOD_THIS_UNWRAPPING_DENIED, 1, JSEXN_TYPEERR, "Permission to call '{0}' denied.")
MSG_DEF(MSG_THIS_DOES_NOT_IMPLEMENT_INTERFACE, 1, JSEXN_TYPEERR, "\"this\" object does not implement interface {0}.")
MSG_DEF(MSG_NOT_IN_UNION, 2, JSEXN_TYPEERR, "{0} could not be converted to any of: {1}.")
MSG_DEF(MSG_ILLEGAL_CONSTRUCTOR, 0, JSEXN_TYPEERR, "Illegal constructor.")
MSG_DEF(MSG_ILLEGAL_TYPE_PR_CONSTRUCTOR, 1, JSEXN_TYPEERR, "TypeError:{0}")