1
0
forked from 0ad/0ad

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.
This commit is contained in:
Nicolas Auvray 2016-09-02 16:32:26 +00:00
parent ef764d5d64
commit c06eda0209

View File

@ -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<bool>(JSContext* cx, JS::HandleValue v, bool& out)
{