зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1673435 - Don't print out nsISupports in XPCWrappedNative::ToString() unless it is the only interface. r=nika
The first interface is always nsISupports, so there's no need for the check here. This lets me remove the cx argument. Differential Revision: https://phabricator.services.mozilla.com/D94756
This commit is contained in:
Родитель
9817823a41
Коммит
1982467281
|
@ -1704,7 +1704,7 @@ NS_IMETHODIMP XPCWrappedNative::DebugDump(int16_t depth) {
|
|||
/***************************************************************************/
|
||||
|
||||
char* XPCWrappedNative::ToString(
|
||||
JSContext* cx, XPCWrappedNativeTearOff* to /* = nullptr */) const {
|
||||
XPCWrappedNativeTearOff* to /* = nullptr */) const {
|
||||
#ifdef DEBUG
|
||||
# define FMT_ADDR " @ 0x%p"
|
||||
# define FMT_STR(str) str
|
||||
|
@ -1729,19 +1729,22 @@ char* XPCWrappedNative::ToString(
|
|||
} else if (!name) {
|
||||
XPCNativeSet* set = GetSet();
|
||||
XPCNativeInterface** array = set->GetInterfaceArray();
|
||||
RefPtr<XPCNativeInterface> isupp = XPCNativeInterface::GetISupports(cx);
|
||||
uint16_t count = set->GetInterfaceCount();
|
||||
MOZ_RELEASE_ASSERT(count >= 1, "Expected at least one interface");
|
||||
MOZ_ASSERT(*array[0]->GetIID() == NS_GET_IID(nsISupports),
|
||||
"The first interface must be nsISupports");
|
||||
|
||||
// The first interface is always nsISupports, so don't print it, unless
|
||||
// there are no others.
|
||||
if (count == 1) {
|
||||
name =
|
||||
JS_sprintf_append(std::move(name), "%s", array[0]->GetNameString());
|
||||
} else if (count == 2 && array[0] == isupp) {
|
||||
name = JS_sprintf_append(std::move(name), "nsISupports");
|
||||
} else if (count == 2) {
|
||||
name =
|
||||
JS_sprintf_append(std::move(name), "%s", array[1]->GetNameString());
|
||||
} else {
|
||||
for (uint16_t i = 0; i < count; i++) {
|
||||
for (uint16_t i = 1; i < count; i++) {
|
||||
const char* fmt =
|
||||
(i == 0) ? "(%s" : (i == count - 1) ? ", %s)" : ", %s";
|
||||
(i == 1) ? "(%s" : (i == count - 1) ? ", %s)" : ", %s";
|
||||
name =
|
||||
JS_sprintf_append(std::move(name), fmt, array[i]->GetNameString());
|
||||
}
|
||||
|
|
|
@ -44,7 +44,7 @@ static bool ToStringGuts(XPCCallContext& ccx) {
|
|||
XPCWrappedNative* wrapper = ccx.GetWrapper();
|
||||
|
||||
if (wrapper) {
|
||||
sz.reset(wrapper->ToString(ccx, ccx.GetTearOff()));
|
||||
sz.reset(wrapper->ToString(ccx.GetTearOff()));
|
||||
} else {
|
||||
sz = JS_smprintf("[xpconnect wrapped native prototype]");
|
||||
}
|
||||
|
|
|
@ -1508,7 +1508,7 @@ class XPCWrappedNative final : public nsIXPConnectWrappedNative {
|
|||
|
||||
// Returns a string that should be freed with js_free, or nullptr on
|
||||
// failure.
|
||||
char* ToString(JSContext* cx, XPCWrappedNativeTearOff* to = nullptr) const;
|
||||
char* ToString(XPCWrappedNativeTearOff* to = nullptr) const;
|
||||
|
||||
static nsIXPCScriptable* GatherProtoScriptable(nsIClassInfo* classInfo);
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче