mirror of
https://gitea.wildfiregames.com/0ad/0ad.git
synced 2026-09-21 20:06:40 +00:00
[SM60 2/2] Update to Spidermonkey 60 APIs
Two noteworthy changes:
- Proxies are update to the SM60 API, having an explicit reserved slot
and a private slot, in which the 'proxy data' and the C++ object are
stored. This fixes a debug assertion failure of SM52 (See bugs 1237504
and 1339411)
- The GC callback behaviour has changed slightly, and we should now only
look for GC_SLICE_BEGIN and GC_SLICE_END calls (Bug 1364547)
Other updates are minor:
- Bug 1339036: JSTYPE_VOID beomes JSTYPE_UNDEFINED
- Bug 1308236 - avoid ambiguous comparison by changing NULL to nullptr
- Bug 1421358, GC::reason::REFRESH_FRAME was removed. API is indicated
in jsapi.h so use that.
- Compartment behaviours update
- ClassOps changes (Bug 1389510 removed the getter/setter - 7c04ea0211 -
and bug 1370608 added one more before that so net minus one)
- Minor tests touchups again.
Tested by: SubitaNeo, Stan
Thanks to bellaz89 for the Shared Array fix
Closes #5859
Differential Revision: https://code.wildfiregames.com/D3116
This was SVN commit r24243.
This commit is contained in:
@@ -44,9 +44,9 @@ namespace {
|
||||
}
|
||||
|
||||
template <>
|
||||
bool JSI_GUIProxy<CText>::funcGetter(CText* elem, const std::string& propName, JS::MutableHandleValue vp) const
|
||||
bool JSI_GUIProxy<CText>::funcGetter(JS::HandleObject proxy, const std::string& propName, JS::MutableHandleValue vp) const
|
||||
{
|
||||
const SData& data = *static_cast<const SData*>(elem->GetGUI().GetProxyData(this));
|
||||
const SData& data = *static_cast<const SData*>(js::GetProxyReservedSlot(proxy, 0).toPrivate());
|
||||
if (propName == "toString")
|
||||
return vp.setObjectOrNull(data.m_ToString), true;
|
||||
if (propName == "focus")
|
||||
|
||||
@@ -64,7 +64,7 @@ protected:
|
||||
|
||||
// This handles returning function properties.
|
||||
// Specialize this.
|
||||
bool funcGetter(GUIObjectType* elem, const std::string& propName, JS::MutableHandleValue vp) const;
|
||||
bool funcGetter(JS::HandleObject proxy, const std::string& propName, JS::MutableHandleValue vp) const;
|
||||
protected:
|
||||
// BaseProxyHandler interface below
|
||||
|
||||
@@ -97,9 +97,9 @@ protected:
|
||||
return true;
|
||||
}
|
||||
// Return nothing.
|
||||
virtual bool enumerate(JSContext* UNUSED(cx), JS::HandleObject UNUSED(proxy), JS::MutableHandleObject UNUSED(objp)) const override
|
||||
virtual JSObject* enumerate(JSContext* UNUSED(cx), JS::HandleObject UNUSED(proxy)) const override
|
||||
{
|
||||
return true;
|
||||
return nullptr;
|
||||
}
|
||||
// Throw an exception is JS attempts to query the prototype.
|
||||
virtual bool getPrototypeIfOrdinary(JSContext* UNUSED(cx), JS::HandleObject UNUSED(proxy), bool* UNUSED(isOrdinary), JS::MutableHandleObject UNUSED(protop)) const override
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
template <typename T>
|
||||
js::Class& JSI_GUIProxy<T>::ClassDefinition()
|
||||
{
|
||||
static js::Class c = PROXY_CLASS_DEF("GUIObjectProxy", JSCLASS_HAS_PRIVATE | JSCLASS_HAS_CACHED_PROTO(JSProto_Proxy));
|
||||
static js::Class c = PROXY_CLASS_DEF("GUIObjectProxy", JSCLASS_HAS_CACHED_PROTO(JSProto_Proxy) | JSCLASS_HAS_RESERVED_SLOTS(1));
|
||||
return c;
|
||||
}
|
||||
|
||||
@@ -37,7 +37,7 @@ template<class OG, class R, void (R::*funcptr)(ScriptInterface&, JS::MutableHand
|
||||
inline bool apply_to(JSContext* cx, uint argc, JS::Value* vp)
|
||||
{
|
||||
JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
|
||||
OG* e = static_cast<OG*>(JS_GetPrivate(args.thisv().toObjectOrNull()));
|
||||
OG* e = static_cast<OG*>(js::GetProxyPrivate(args.thisv().toObjectOrNull()).toPrivate());
|
||||
if (!e)
|
||||
return false;
|
||||
|
||||
@@ -53,7 +53,7 @@ bool JSI_GUIProxy<T>::get(JSContext* cx, JS::HandleObject proxy, JS::HandleValue
|
||||
ScriptInterface* pScriptInterface = ScriptInterface::GetScriptInterfaceAndCBData(cx)->pScriptInterface;
|
||||
ScriptRequest rq(*pScriptInterface);
|
||||
|
||||
T* e = static_cast<T*>(JS_GetPrivate(proxy.get()));
|
||||
T* e = static_cast<T*>(js::GetProxyPrivate(proxy.get()).toPrivate());
|
||||
if (!e)
|
||||
return false;
|
||||
|
||||
@@ -66,7 +66,7 @@ bool JSI_GUIProxy<T>::get(JSContext* cx, JS::HandleObject proxy, JS::HandleValue
|
||||
return false;
|
||||
|
||||
// Return function properties. Specializable.
|
||||
if (funcGetter(e, propName, vp))
|
||||
if (funcGetter(proxy, propName, vp))
|
||||
return true;
|
||||
|
||||
// Use onWhatever to access event handlers
|
||||
@@ -121,7 +121,7 @@ template <typename T>
|
||||
bool JSI_GUIProxy<T>::set(JSContext* cx, JS::HandleObject proxy, JS::HandleId id, JS::HandleValue vp,
|
||||
JS::HandleValue UNUSED(receiver), JS::ObjectOpResult& result) const
|
||||
{
|
||||
T* e = static_cast<T*>(JS_GetPrivate(proxy.get()));
|
||||
T* e = static_cast<T*>(js::GetProxyPrivate(proxy.get()).toPrivate());
|
||||
if (!e)
|
||||
return result.fail(JSMSG_NOT_NONNULL_OBJECT);
|
||||
|
||||
@@ -173,7 +173,7 @@ bool JSI_GUIProxy<T>::set(JSContext* cx, JS::HandleObject proxy, JS::HandleId id
|
||||
template<typename T>
|
||||
bool JSI_GUIProxy<T>::delete_(JSContext* cx, JS::HandleObject proxy, JS::HandleId id, JS::ObjectOpResult& result) const
|
||||
{
|
||||
T* e = static_cast<T*>(JS_GetPrivate(proxy.get()));
|
||||
T* e = static_cast<T*>(js::GetProxyPrivate(proxy.get()).toPrivate());
|
||||
if (!e)
|
||||
return result.fail(JSMSG_NOT_NONNULL_OBJECT);
|
||||
|
||||
|
||||
@@ -30,7 +30,7 @@ JSClassOps JSI_GUISize::JSI_classops = {
|
||||
nullptr, nullptr,
|
||||
nullptr, nullptr,
|
||||
nullptr, nullptr, nullptr, nullptr,
|
||||
nullptr, nullptr, JSI_GUISize::construct, nullptr
|
||||
nullptr, JSI_GUISize::construct, nullptr
|
||||
};
|
||||
|
||||
JSFunctionSpec JSI_GUISize::JSI_methods[] =
|
||||
|
||||
@@ -43,9 +43,9 @@ namespace {
|
||||
}
|
||||
|
||||
template <>
|
||||
bool JSI_GUIProxy<IGUIObject>::funcGetter(IGUIObject* elem, const std::string& propName, JS::MutableHandleValue vp) const
|
||||
bool JSI_GUIProxy<IGUIObject>::funcGetter(JS::HandleObject proxy, const std::string& propName, JS::MutableHandleValue vp) const
|
||||
{
|
||||
const SData& data = *static_cast<const SData*>(elem->GetGUI().GetProxyData(this));
|
||||
const SData& data = *static_cast<const SData*>(js::GetProxyReservedSlot(proxy, 0).toPrivate());
|
||||
if (propName == "toString")
|
||||
return vp.setObjectOrNull(data.m_ToString), true;
|
||||
if (propName == "focus")
|
||||
|
||||
Reference in New Issue
Block a user