1
0
forked from mirrors/0ad

Enable latest JS language features.

Load GUI scripts as UTF-8.

This was SVN commit r7650.
This commit is contained in:
Ykkrosh
2010-06-30 21:23:41 +00:00
parent e88391e5d8
commit c5d204c7ff
3 changed files with 46 additions and 4 deletions
@@ -233,6 +233,8 @@ ScriptInterface_impl::ScriptInterface_impl(const char* nativeScopeName, JSContex
| JSOPTION_VAROBJFIX // "recommended" (fixes variable scoping)
);
JS_SetVersion(m_cx, JSVERSION_LATEST);
JS_SetExtraGCRoots(m_rt, jshook_trace, this);
// Threadsafe SpiderMonkey requires that we have a request before doing anything much
@@ -601,6 +603,15 @@ bool ScriptInterface::Eval_(const wchar_t* code, jsval& rval)
return ok ? true : false;
}
std::wstring ScriptInterface::ToString(jsval obj)
{
if (JSVAL_IS_VOID(obj))
return L"(void 0)";
std::wstring source = L"(error)";
CallFunction(obj, "toSource", source);
return source;
}
void ScriptInterface::ReportError(const char* msg)
{
// JS_ReportError by itself doesn't seem to set a JS-style exception, and so