mirror of
https://gitea.wildfiregames.com/0ad/0ad.git
synced 2026-10-14 06:58:07 +00:00
Replace JS_THIS_OBJECT and JS::CallReceiver in preparation for SpiderMonkey 49 and 61.
Differential Revision: https://code.wildfiregames.com/D2173
Refs #4893, D1699, D2142, D844, 7c2e9027c2, ...
Refs https://bugzilla.mozilla.org/show_bug.cgi?id=1270977
Refs https://bugzilla.mozilla.org/show_bug.cgi?id=1255800
Tested on: clang 8, VS2015, Jenkins
This was SVN commit r22661.
This commit is contained in:
@@ -33,27 +33,23 @@ void JSI_IGUITextOwner::RegisterScriptFunctions(JSContext* cx, JS::HandleObject
|
||||
JS_DefineFunctions(cx, obj, JSI_methods);
|
||||
}
|
||||
|
||||
bool JSI_IGUITextOwner::GetTextSize(JSContext* cx, uint UNUSED(argc), JS::Value* vp)
|
||||
bool JSI_IGUITextOwner::GetTextSize(JSContext* cx, uint argc, JS::Value* vp)
|
||||
{
|
||||
JSAutoRequest rq(cx);
|
||||
JS::CallReceiver rec = JS::CallReceiverFromVp(vp);
|
||||
JS::RootedObject thisObj(cx, &rec.thisv().toObject());
|
||||
|
||||
IGUIObject* obj = static_cast<IGUIObject*>(JS_GetInstancePrivate(cx, thisObj, &JSI_IGUIObject::JSI_class, nullptr));
|
||||
// No JSAutoRequest needed for these calls
|
||||
JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
|
||||
IGUIObject* obj = ScriptInterface::GetPrivate<IGUIObject>(cx, args, &JSI_IGUIObject::JSI_class);
|
||||
if (!obj)
|
||||
{
|
||||
JS_ReportError(cx, "This is not an IGUIObject!");
|
||||
return false;
|
||||
}
|
||||
|
||||
// Avoid dynamic_cast for performance reasons
|
||||
IGUITextOwner* objText = static_cast<IGUITextOwner*>(obj->GetTextOwner());
|
||||
if (!objText)
|
||||
{
|
||||
JSAutoRequest rq(cx);
|
||||
JS_ReportError(cx, "This IGUIObject is not an IGUITextOwner!");
|
||||
return false;
|
||||
}
|
||||
|
||||
ScriptInterface::ToJSVal(cx, rec.rval(), objText->CalculateTextSize());
|
||||
ScriptInterface::ToJSVal(cx, args.rval(), objText->CalculateTextSize());
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user