mirror of
https://gitea.wildfiregames.com/0ad/0ad.git
synced 2026-07-13 18:13:31 +00:00
More exact stack rooting (CallFunction object).
Changes CallFunction and CallFunctionVoid to use a HandleValue as object parameter. Also changes some JS serialization/deserialization functions to only support the JSAPI rooted types (drop support for CScriptVal and CScriptValRooted there). Some other functions got changed too because they were closely related. Refs #2415 Refs #2462 This was SVN commit r15592.
This commit is contained in:
@@ -150,25 +150,25 @@ public:
|
||||
/**
|
||||
* Call the named property on the given object, with void return type and 0 arguments
|
||||
*/
|
||||
bool CallFunctionVoid(jsval val, const char* name);
|
||||
bool CallFunctionVoid(JS::HandleValue val, const char* name);
|
||||
|
||||
/**
|
||||
* Call the named property on the given object, with void return type and 1 argument
|
||||
*/
|
||||
template<typename T0>
|
||||
bool CallFunctionVoid(jsval val, const char* name, const T0& a0);
|
||||
bool CallFunctionVoid(JS::HandleValue val, const char* name, const T0& a0);
|
||||
|
||||
/**
|
||||
* Call the named property on the given object, with void return type and 2 arguments
|
||||
*/
|
||||
template<typename T0, typename T1>
|
||||
bool CallFunctionVoid(jsval val, const char* name, const T0& a0, const T1& a1);
|
||||
bool CallFunctionVoid(JS::HandleValue val, const char* name, const T0& a0, const T1& a1);
|
||||
|
||||
/**
|
||||
* Call the named property on the given object, with void return type and 3 arguments
|
||||
*/
|
||||
template<typename T0, typename T1, typename T2>
|
||||
bool CallFunctionVoid(jsval val, const char* name, const T0& a0, const T1& a1, const T2& a2);
|
||||
bool CallFunctionVoid(JS::HandleValue val, const char* name, const T0& a0, const T1& a1, const T2& a2);
|
||||
|
||||
JSObject* CreateCustomObject(const std::string & typeName);
|
||||
void DefineCustomObjectType(JSClass *clasp, JSNative constructor, uint minArgs, JSPropertySpec *ps, JSFunctionSpec *fs, JSPropertySpec *static_ps, JSFunctionSpec *static_fs);
|
||||
@@ -480,45 +480,42 @@ inline void ScriptInterface::AssignOrToJSVal<JS::Value>(JS::MutableHandleValue h
|
||||
}
|
||||
|
||||
template<typename T0>
|
||||
bool ScriptInterface::CallFunctionVoid(jsval val, const char* name, const T0& a0)
|
||||
bool ScriptInterface::CallFunctionVoid(JS::HandleValue val, const char* name, const T0& a0)
|
||||
{
|
||||
JSContext* cx = GetContext();
|
||||
JSAutoRequest rq(cx);
|
||||
JS::RootedValue jsRet(cx);
|
||||
JS::RootedValue val1(cx, val);
|
||||
JS::AutoValueVector argv(cx);
|
||||
argv.resize(1);
|
||||
AssignOrToJSVal(argv.handleAt(0), a0);
|
||||
return CallFunction_(val1, name, 1, argv.begin(), &jsRet);
|
||||
return CallFunction_(val, name, 1, argv.begin(), &jsRet);
|
||||
}
|
||||
|
||||
template<typename T0, typename T1>
|
||||
bool ScriptInterface::CallFunctionVoid(jsval val, const char* name, const T0& a0, const T1& a1)
|
||||
bool ScriptInterface::CallFunctionVoid(JS::HandleValue val, const char* name, const T0& a0, const T1& a1)
|
||||
{
|
||||
JSContext* cx = GetContext();
|
||||
JSAutoRequest rq(cx);
|
||||
JS::RootedValue jsRet(cx);
|
||||
JS::RootedValue val1(cx, val);
|
||||
JS::AutoValueVector argv(cx);
|
||||
argv.resize(2);
|
||||
AssignOrToJSVal(argv.handleAt(0), a0);
|
||||
AssignOrToJSVal(argv.handleAt(1), a1);
|
||||
return CallFunction_(val1, name, 2, argv.begin(), &jsRet);
|
||||
return CallFunction_(val, name, 2, argv.begin(), &jsRet);
|
||||
}
|
||||
|
||||
template<typename T0, typename T1, typename T2>
|
||||
bool ScriptInterface::CallFunctionVoid(jsval val, const char* name, const T0& a0, const T1& a1, const T2& a2)
|
||||
bool ScriptInterface::CallFunctionVoid(JS::HandleValue val, const char* name, const T0& a0, const T1& a1, const T2& a2)
|
||||
{
|
||||
JSContext* cx = GetContext();
|
||||
JSAutoRequest rq(cx);
|
||||
JS::RootedValue jsRet(cx);
|
||||
JS::RootedValue val1(cx, val);
|
||||
JS::AutoValueVector argv(cx);
|
||||
argv.resize(3);
|
||||
AssignOrToJSVal(argv.handleAt(0), a0);
|
||||
AssignOrToJSVal(argv.handleAt(1), a1);
|
||||
AssignOrToJSVal(argv.handleAt(2), a2);
|
||||
return CallFunction_(val1, name, 3, argv.begin(), &jsRet);
|
||||
return CallFunction_(val, name, 3, argv.begin(), &jsRet);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
|
||||
Reference in New Issue
Block a user