mirror of
https://gitea.wildfiregames.com/0ad/0ad.git
synced 2026-07-14 00:55:42 +00:00
SpiderMonkey-related changes in preparation for the upgrade to SpiderMonkey 45, refs #4893.
- Remove JSVAL_ZERO and JSVAL_NULL https://bugzilla.mozilla.org/show_bug.cgi?id=1177825 - Remove *_TO_JSVAL https://bugzilla.mozilla.org/show_bug.cgi?id=1177892 - Drop support for parent object in the deserializer https://bugzilla.mozilla.org/show_bug.cgi?id=1136345, https://bugzilla.mozilla.org/show_bug.cgi?id=805052 - Correctly use boolean values in JS::RuntimeOptionsRef - Use JS_FN instead of JS_FS: in future versions, JS_FS is not public because it isn't supposed to be used in JSAPI code - Allow to select flags for global objects, and correctly mark progress bars in the loading screen as not readonly+permanent - Remove empty JSI_props in IGUIObject Reviewed By: wraitii, elexis Differential Revision: https://code.wildfiregames.com/D1716 This was SVN commit r22052.
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
/* Copyright (C) 2017 Wildfire Games.
|
||||
/* Copyright (C) 2019 Wildfire Games.
|
||||
* This file is part of 0 A.D.
|
||||
*
|
||||
* 0 A.D. is free software: you can redistribute it and/or modify
|
||||
@@ -86,7 +86,6 @@ JSClass global_class = {
|
||||
|
||||
void ErrorReporter(JSContext* cx, const char* message, JSErrorReport* report)
|
||||
{
|
||||
|
||||
std::stringstream msg;
|
||||
bool isWarning = JSREPORT_IS_WARNING(report->flags);
|
||||
msg << (isWarning ? "JavaScript warning: " : "JavaScript error: ");
|
||||
@@ -364,10 +363,11 @@ ScriptInterface_impl::ScriptInterface_impl(const char* nativeScopeName, const sh
|
||||
JS_SetGlobalJitCompilerOption(m_runtime->m_rt, JSJITCOMPILER_ION_ENABLE, 1);
|
||||
JS_SetGlobalJitCompilerOption(m_runtime->m_rt, JSJITCOMPILER_BASELINE_ENABLE, 1);
|
||||
|
||||
JS::RuntimeOptionsRef(m_cx).setExtraWarnings(1)
|
||||
.setWerror(0)
|
||||
.setVarObjFix(1)
|
||||
.setStrictMode(1);
|
||||
JS::RuntimeOptionsRef(m_cx)
|
||||
.setExtraWarnings(true)
|
||||
.setWerror(false)
|
||||
.setVarObjFix(true)
|
||||
.setStrictMode(true);
|
||||
|
||||
JS::CompartmentOptions opt;
|
||||
opt.setVersion(JSVERSION_LATEST);
|
||||
@@ -602,7 +602,7 @@ JS::Value ScriptInterface::GetGlobalObject() const
|
||||
return JS::ObjectValue(*JS::CurrentGlobalOrNull(m->m_cx));
|
||||
}
|
||||
|
||||
bool ScriptInterface::SetGlobal_(const char* name, JS::HandleValue value, bool replace)
|
||||
bool ScriptInterface::SetGlobal_(const char* name, JS::HandleValue value, bool replace, bool constant, bool enumerate)
|
||||
{
|
||||
JSAutoRequest rq(m->m_cx);
|
||||
JS::RootedObject global(m->m_cx, m->m_glob);
|
||||
@@ -618,9 +618,13 @@ bool ScriptInterface::SetGlobal_(const char* name, JS::HandleValue value, bool r
|
||||
}
|
||||
}
|
||||
|
||||
bool ok = JS_DefineProperty(m->m_cx, global, name, value, JSPROP_ENUMERATE | JSPROP_READONLY
|
||||
| JSPROP_PERMANENT);
|
||||
return ok;
|
||||
uint attrs = 0;
|
||||
if (constant)
|
||||
attrs |= JSPROP_READONLY | JSPROP_PERMANENT;
|
||||
if (enumerate)
|
||||
attrs |= JSPROP_ENUMERATE;
|
||||
|
||||
return JS_DefineProperty(m->m_cx, global, name, value, attrs);
|
||||
}
|
||||
|
||||
bool ScriptInterface::SetProperty_(JS::HandleValue obj, const char* name, JS::HandleValue value, bool constant, bool enumerate) const
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* Copyright (C) 2018 Wildfire Games.
|
||||
/* Copyright (C) 2019 Wildfire Games.
|
||||
* This file is part of 0 A.D.
|
||||
*
|
||||
* 0 A.D. is free software: you can redistribute it and/or modify
|
||||
@@ -142,7 +142,7 @@ public:
|
||||
* to set an already-defined value will fail.
|
||||
*/
|
||||
template<typename T>
|
||||
bool SetGlobal(const char* name, const T& value, bool replace = false);
|
||||
bool SetGlobal(const char* name, const T& value, bool replace = false, bool constant = true, bool enumerate = true);
|
||||
|
||||
/**
|
||||
* Set the named property on the given object.
|
||||
@@ -362,7 +362,7 @@ private:
|
||||
bool CallFunction_(JS::HandleValue val, const char* name, JS::HandleValueArray argv, JS::MutableHandleValue ret) const;
|
||||
bool Eval_(const char* code, JS::MutableHandleValue ret) const;
|
||||
bool Eval_(const wchar_t* code, JS::MutableHandleValue ret) const;
|
||||
bool SetGlobal_(const char* name, JS::HandleValue value, bool replace);
|
||||
bool SetGlobal_(const char* name, JS::HandleValue value, bool replace, bool constant, bool enumerate);
|
||||
bool SetProperty_(JS::HandleValue obj, const char* name, JS::HandleValue value, bool readonly, bool enumerate) const;
|
||||
bool SetProperty_(JS::HandleValue obj, const wchar_t* name, JS::HandleValue value, bool readonly, bool enumerate) const;
|
||||
bool SetPropertyInt_(JS::HandleValue obj, int name, JS::HandleValue value, bool readonly, bool enumerate) const;
|
||||
@@ -488,12 +488,12 @@ inline JS::HandleValue ScriptInterface::AssignOrFromJSVal<JS::HandleValue>(JSCon
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
bool ScriptInterface::SetGlobal(const char* name, const T& value, bool replace)
|
||||
bool ScriptInterface::SetGlobal(const char* name, const T& value, bool replace, bool constant, bool enumerate)
|
||||
{
|
||||
JSAutoRequest rq(GetContext());
|
||||
JS::RootedValue val(GetContext());
|
||||
AssignOrToJSVal(GetContext(), &val, value);
|
||||
return SetGlobal_(name, val, replace);
|
||||
return SetGlobal_(name, val, replace, constant, enumerate);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
|
||||
Reference in New Issue
Block a user