From c06eda02094a5f9483a4a3fbdfeee435d1c017cc Mon Sep 17 00:00:00 2001 From: Itms Date: Fri, 2 Sep 2016 16:32:26 +0000 Subject: [PATCH] SpiderMonkey 38 upgrade: 16/35 JS_GetTypeName was removed from the API, but we asked upstream to add it back (https://bugzilla.mozilla.org/show_bug.cgi?id=1037718). This was SVN commit r18670. --- source/scriptinterface/ScriptConversions.cpp | 23 +++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/source/scriptinterface/ScriptConversions.cpp b/source/scriptinterface/ScriptConversions.cpp index 044d9a93bf..67fa50fee4 100644 --- a/source/scriptinterface/ScriptConversions.cpp +++ b/source/scriptinterface/ScriptConversions.cpp @@ -28,7 +28,28 @@ #define FAIL(msg) STMT(JS_ReportError(cx, msg); return false) // Implicit type conversions often hide bugs, so warn about them -#define WARN_IF_NOT(c, v) STMT(if (!(c)) { JS_ReportWarning(cx, "Script value conversion check failed: %s (got type %s)", #c, JS_GetTypeName(cx, JS_TypeOfValue(cx, v))); }) +#define WARN_IF_NOT(c, v) STMT(if (!(c)) { JS_ReportWarning(cx, "Script value conversion check failed: %s (got type %s)", #c, InformalValueTypeName(v)); }) + +// TODO: SpiderMonkey: Follow upstream progresses about JS_InformalValueTypeName in the API +// https://bugzilla.mozilla.org/show_bug.cgi?id=1285917 +static const char* InformalValueTypeName(const JS::Value& v) +{ + if (v.isObject()) + return "object"; + if (v.isString()) + return "string"; + if (v.isSymbol()) + return "symbol"; + if (v.isNumber()) + return "number"; + if (v.isBoolean()) + return "boolean"; + if (v.isNull()) + return "null"; + if (v.isUndefined()) + return "undefined"; + return "value"; +} template<> bool ScriptInterface::FromJSVal(JSContext* cx, JS::HandleValue v, bool& out) {