mirror of
https://gitea.wildfiregames.com/0ad/0ad
synced 2026-08-15 14:43:32 -07:00
Adapt JS API to ESR 140
This commit is contained in:
parent
3d5c59f2c9
commit
edff153f73
8 changed files with 14 additions and 11 deletions
|
|
@ -39,6 +39,7 @@
|
|||
#include <js/ComparisonOperators.h>
|
||||
#include <js/CompilationAndEvaluation.h>
|
||||
#include <js/CompileOptions.h>
|
||||
#include <js/EnvironmentChain.h>
|
||||
#include <js/GCAPI.h>
|
||||
#include <js/GCVector.h>
|
||||
#include <js/SourceText.h>
|
||||
|
|
@ -342,7 +343,7 @@ void IGUIObject::RegisterScriptHandler(const CStr& eventName, const CStr& Code,
|
|||
|
||||
JS::SourceText<mozilla::Utf8Unit> src;
|
||||
ENSURE(src.init(rq.cx, Code.c_str(), Code.length(), JS::SourceOwnership::Borrowed));
|
||||
JS::RootedObjectVector emptyScopeChain(rq.cx);
|
||||
JS::EnvironmentChain emptyScopeChain{ rq.cx, JS::SupportUnscopables::No };
|
||||
JS::RootedFunction func(rq.cx, JS::CompileFunction(rq.cx, emptyScopeChain, options, buf, paramCount, paramNames, src));
|
||||
if (func == nullptr)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -257,7 +257,7 @@ void Context::MaybeIncrementalGC()
|
|||
#endif
|
||||
|
||||
// There is a tradeoff between this time and the number of frames we must run GCs on, but overall we should prioritize smooth framerates.
|
||||
const js::SliceBudget GCSliceTimeBudget = js::SliceBudget(js::TimeBudget(6)); // Milliseconds an incremental slice is allowed to run. SM respects this fairly well.
|
||||
const JS::SliceBudget GCSliceTimeBudget = JS::SliceBudget(JS::TimeBudget(6)); // Milliseconds an incremental slice is allowed to run. SM respects this fairly well.
|
||||
|
||||
PrepareZonesForIncrementalGC();
|
||||
if (!JS::IsIncrementalGCInProgress(m_cx))
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@
|
|||
#include <js/Initialization.h>
|
||||
#include <list>
|
||||
|
||||
#if MOZJS_MAJOR_VERSION != 128
|
||||
#if MOZJS_MAJOR_VERSION != 140
|
||||
#error Your compiler is trying to use an incorrect major version of the \
|
||||
SpiderMonkey library. The SpiderMonkey API is subject to changes, and the \
|
||||
game will not build with the selected version of the library. Make sure \
|
||||
|
|
|
|||
|
|
@ -43,6 +43,7 @@
|
|||
#include <js/ComparisonOperators.h>
|
||||
#include <js/CompilationAndEvaluation.h>
|
||||
#include <js/CompileOptions.h>
|
||||
#include <js/EnvironmentChain.h>
|
||||
#include <js/GCVector.h>
|
||||
#include <js/GlobalObject.h>
|
||||
#include <js/PropertyAndElement.h>
|
||||
|
|
@ -674,7 +675,7 @@ bool Interface::LoadScript(const VfsPath& filename, const std::string& code) con
|
|||
|
||||
JS::SourceText<mozilla::Utf8Unit> src;
|
||||
ENSURE(src.init(rq.cx, code.c_str(), code.length(), JS::SourceOwnership::Borrowed));
|
||||
JS::RootedObjectVector emptyScopeChain(rq.cx);
|
||||
JS::EnvironmentChain emptyScopeChain{ rq.cx, JS::SupportUnscopables::No };
|
||||
JS::RootedFunction func(rq.cx, JS::CompileFunction(rq.cx, emptyScopeChain, options, NULL, 0, NULL, src));
|
||||
if (func == nullptr)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -69,9 +69,10 @@ void JobQueue::runJobs(JSContext*)
|
|||
}
|
||||
}
|
||||
|
||||
JSObject* JobQueue::getIncumbentGlobal(JSContext* cx)
|
||||
bool JobQueue::getHostDefinedData(JSContext* cx, JS::MutableHandle<JSObject*> data) const
|
||||
{
|
||||
return JS::CurrentGlobalOrNull(cx);
|
||||
data.set(JS::CurrentGlobalOrNull(cx));
|
||||
return true;
|
||||
}
|
||||
|
||||
bool JobQueue::enqueuePromiseJob(JSContext* cx, JS::HandleObject, JS::HandleObject job, JS::HandleObject,
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@ public:
|
|||
void runJobs(JSContext*) final;
|
||||
|
||||
private:
|
||||
JSObject* getIncumbentGlobal(JSContext* cx) final;
|
||||
bool getHostDefinedData(JSContext* cx, JS::MutableHandle<JSObject*> data) const final;
|
||||
|
||||
bool enqueuePromiseJob(JSContext* cx, JS::HandleObject, JS::HandleObject job, JS::HandleObject,
|
||||
JS::HandleObject) final;
|
||||
|
|
|
|||
|
|
@ -37,8 +37,8 @@ class CComponentTypeScript
|
|||
public:
|
||||
CComponentTypeScript(const Script::Interface& scriptInterface, JS::HandleValue instance);
|
||||
|
||||
JS::HandleValue GetInstance() const { return JS::HandleValue::fromMarkedLocation(m_Instance.address()); }
|
||||
JS::MutableHandleValue GetMutInstance() { return JS::MutableHandleValue::fromMarkedLocation(const_cast<JS::Value*>(m_Instance.address())); }
|
||||
JS::HandleValue GetInstance() const { return JS::HandleValue::fromMarkedLocation(m_Instance.unsafeAddress()); }
|
||||
JS::MutableHandleValue GetMutInstance() { return JS::MutableHandleValue::fromMarkedLocation(const_cast<JS::Value*>(m_Instance.unsafeAddress())); }
|
||||
static void Trace(JSTracer* trc, void* data);
|
||||
|
||||
void Init(CComponentManager& cmpMgr, const CParamNode& paramNode, entity_id_t ent);
|
||||
|
|
|
|||
|
|
@ -46,7 +46,7 @@
|
|||
JS::HandleValue ICmp##iname::GetJSInstance() const \
|
||||
{ \
|
||||
if (m_CachedInstance) \
|
||||
return JS::HandleValue::fromMarkedLocation(m_CachedInstance.address()); \
|
||||
return JS::HandleValue::fromMarkedLocation(m_CachedInstance.unsafeAddress()); \
|
||||
\
|
||||
const Script::Interface& si = GetSimContext().GetScriptInterface(); \
|
||||
Script::Request rq(si); \
|
||||
|
|
@ -55,7 +55,7 @@
|
|||
m_CachedInstance.setObject(*obj); \
|
||||
\
|
||||
GetSimContext().GetComponentManager().RegisterTrace(GetEntityId(), m_CachedInstance); \
|
||||
return JS::HandleValue::fromMarkedLocation(m_CachedInstance.address()); \
|
||||
return JS::HandleValue::fromMarkedLocation(m_CachedInstance.unsafeAddress()); \
|
||||
} \
|
||||
void RegisterComponentInterface_##iname(Script::Interface& scriptInterface) { \
|
||||
ICmp##iname::InterfaceInit(scriptInterface); \
|
||||
|
|
|
|||
Loading…
Reference in a new issue