Changeset View
Changeset View
Standalone View
Standalone View
ps/trunk/source/gui/scripting/JSInterface_IGUIObject.cpp
/* Copyright (C) 2017 Wildfire Games. | /* Copyright (C) 2019 Wildfire Games. | ||||
* This file is part of 0 A.D. | * This file is part of 0 A.D. | ||||
* | * | ||||
* 0 A.D. is free software: you can redistribute it and/or modify | * 0 A.D. is free software: you can redistribute it and/or modify | ||||
* it under the terms of the GNU General Public License as published by | * it under the terms of the GNU General Public License as published by | ||||
* the Free Software Foundation, either version 2 of the License, or | * the Free Software Foundation, either version 2 of the License, or | ||||
* (at your option) any later version. | * (at your option) any later version. | ||||
* | * | ||||
* 0 A.D. is distributed in the hope that it will be useful, | * 0 A.D. is distributed in the hope that it will be useful, | ||||
Show All 24 Lines | |||||
JSClass JSI_IGUIObject::JSI_class = { | JSClass JSI_IGUIObject::JSI_class = { | ||||
"GUIObject", JSCLASS_HAS_PRIVATE, | "GUIObject", JSCLASS_HAS_PRIVATE, | ||||
nullptr, nullptr, | nullptr, nullptr, | ||||
JSI_IGUIObject::getProperty, JSI_IGUIObject::setProperty, | JSI_IGUIObject::getProperty, JSI_IGUIObject::setProperty, | ||||
nullptr, nullptr, nullptr, nullptr, | nullptr, nullptr, nullptr, nullptr, | ||||
nullptr, nullptr, JSI_IGUIObject::construct, nullptr | nullptr, nullptr, JSI_IGUIObject::construct, nullptr | ||||
}; | }; | ||||
JSPropertySpec JSI_IGUIObject::JSI_props[] = | |||||
{ | |||||
{ 0 } | |||||
}; | |||||
JSFunctionSpec JSI_IGUIObject::JSI_methods[] = | JSFunctionSpec JSI_IGUIObject::JSI_methods[] = | ||||
{ | { | ||||
JS_FS("toString", JSI_IGUIObject::toString, 0, 0), | JS_FN("toString", JSI_IGUIObject::toString, 0, 0), | ||||
JS_FS("focus", JSI_IGUIObject::focus, 0, 0), | JS_FN("focus", JSI_IGUIObject::focus, 0, 0), | ||||
JS_FS("blur", JSI_IGUIObject::blur, 0, 0), | JS_FN("blur", JSI_IGUIObject::blur, 0, 0), | ||||
JS_FS("getComputedSize", JSI_IGUIObject::getComputedSize, 0, 0), | JS_FN("getComputedSize", JSI_IGUIObject::getComputedSize, 0, 0), | ||||
JS_FS_END | JS_FS_END | ||||
}; | }; | ||||
bool JSI_IGUIObject::getProperty(JSContext* cx, JS::HandleObject obj, JS::HandleId id, JS::MutableHandleValue vp) | bool JSI_IGUIObject::getProperty(JSContext* cx, JS::HandleObject obj, JS::HandleId id, JS::MutableHandleValue vp) | ||||
{ | { | ||||
JSAutoRequest rq(cx); | JSAutoRequest rq(cx); | ||||
ScriptInterface* pScriptInterface = ScriptInterface::GetScriptInterfaceAndCBData(cx)->pScriptInterface; | ScriptInterface* pScriptInterface = ScriptInterface::GetScriptInterfaceAndCBData(cx)->pScriptInterface; | ||||
▲ Show 20 Lines • Show All 569 Lines • ▼ Show 20 Lines | bool JSI_IGUIObject::construct(JSContext* cx, uint argc, JS::Value* vp) | ||||
JS_SetPrivate(obj, guiObject); | JS_SetPrivate(obj, guiObject); | ||||
args.rval().setObject(*obj); | args.rval().setObject(*obj); | ||||
return true; | return true; | ||||
} | } | ||||
void JSI_IGUIObject::init(ScriptInterface& scriptInterface) | void JSI_IGUIObject::init(ScriptInterface& scriptInterface) | ||||
{ | { | ||||
scriptInterface.DefineCustomObjectType(&JSI_class, construct, 1, JSI_props, JSI_methods, NULL, NULL); | scriptInterface.DefineCustomObjectType(&JSI_class, construct, 1, nullptr, JSI_methods, nullptr, nullptr); | ||||
} | } | ||||
bool JSI_IGUIObject::toString(JSContext* cx, uint UNUSED(argc), JS::Value* vp) | bool JSI_IGUIObject::toString(JSContext* cx, uint UNUSED(argc), JS::Value* vp) | ||||
{ | { | ||||
JSAutoRequest rq(cx); | JSAutoRequest rq(cx); | ||||
JS::CallReceiver rec = JS::CallReceiverFromVp(vp); | JS::CallReceiver rec = JS::CallReceiverFromVp(vp); | ||||
JS::RootedObject thisObj(cx, JS_THIS_OBJECT(cx, vp)); | JS::RootedObject thisObj(cx, JS_THIS_OBJECT(cx, vp)); | ||||
▲ Show 20 Lines • Show All 78 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator