Changeset View
Changeset View
Standalone View
Standalone View
source/gui/Scripting/JSInterface_GUIProxy_impl.h
Show All 14 Lines | |||||
* along with 0 A.D. If not, see <http://www.gnu.org/licenses/>. | * along with 0 A.D. If not, see <http://www.gnu.org/licenses/>. | ||||
*/ | */ | ||||
// This file is included directly into actual implementation files. | // This file is included directly into actual implementation files. | ||||
template <typename T> | template <typename T> | ||||
js::Class& JSI_GUIProxy<T>::ClassDefinition() | 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_PRIVATE | JSCLASS_HAS_CACHED_PROTO(JSProto_Proxy) | JSCLASS_HAS_RESERVED_SLOTS(1)); | ||||
wraitii: This bit is required by SM, it static_asserts it. It doesn't seem to be required _by itself_… | |||||
return c; | return c; | ||||
} | } | ||||
template <typename T> | template <typename T> | ||||
JSI_GUIProxy<T>& JSI_GUIProxy<T>::Singleton() | JSI_GUIProxy<T>& JSI_GUIProxy<T>::Singleton() | ||||
{ | { | ||||
static JSI_GUIProxy<T> s; | static JSI_GUIProxy<T> s; | ||||
return s; | return s; | ||||
} | } | ||||
namespace | namespace | ||||
{ | { | ||||
template<class OG, class R, bool (R::*funcptr)(ScriptInterface&, JS::MutableHandleValue)> | template<class OG, class R, bool (R::*funcptr)(ScriptInterface&, JS::MutableHandleValue)> | ||||
inline bool apply_to(JSContext* cx, uint argc, JS::Value* vp) | inline bool apply_to(JSContext* cx, uint argc, JS::Value* vp) | ||||
{ | { | ||||
JS::CallArgs args = JS::CallArgsFromVp(argc, 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) | if (!e) | ||||
return false; | return false; | ||||
return (static_cast<R*>(e)->*(funcptr))(*(ScriptInterface::GetScriptInterfaceAndCBData(cx)->pScriptInterface), args.rval()); | return (static_cast<R*>(e)->*(funcptr))(*(ScriptInterface::GetScriptInterfaceAndCBData(cx)->pScriptInterface), args.rval()); | ||||
} | } | ||||
} | } | ||||
template <typename T> | template <typename T> | ||||
▲ Show 20 Lines • Show All 150 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator
This bit is required by SM, it static_asserts it. It doesn't seem to be required _by itself_, but they did it, so I'll use it.