mirror of
https://gitea.wildfiregames.com/0ad/0ad.git
synced 2026-10-14 06:58:07 +00:00
Changes our JSNative functions to use JS::CallReceiver/JS::CallArgs.
This is the new way for working with arguments in JSNative functions. JS_THIS_VALUE, JS_ARGV, JS_SET_RVAL and direct access to vp or argc are deprecated and will probably be removed in future versions of SpiderMonkey. CallArgs also takes care of proper rooting and you can get the values as Handles or MutableHandles. The interface changes a little bit for ESR 31, but commiting this now still makes it easier and the changes shout be straigtforward (search and replace more or less). Refs #2462 Refs #2415 This was SVN commit r15516.
This commit is contained in:
@@ -92,12 +92,12 @@ struct ScriptInterface_NativeMethodWrapper<void, TC> {
|
||||
#define OVERLOADS(z, i, data) \
|
||||
template <typename R, TYPENAME_T0_HEAD(z,i) R (*fptr) ( ScriptInterface::CxPrivate* T0_TAIL(z,i) )> \
|
||||
JSBool ScriptInterface::call(JSContext* cx, uint argc, jsval* vp) { \
|
||||
UNUSED2(argc); \
|
||||
JS::CallArgs args = JS::CallArgsFromVp(argc, vp); \
|
||||
SCRIPT_PROFILE \
|
||||
BOOST_PP_REPEAT_##z (i, CONVERT_ARG, ~) \
|
||||
jsval rval = JSVAL_VOID; \
|
||||
ScriptInterface_NativeWrapper<R>::call(cx, rval, fptr A0_TAIL(z,i)); \
|
||||
JS_SET_RVAL(cx, vp, rval); \
|
||||
args.rval().set(rval); \
|
||||
return !ScriptInterface::IsExceptionPending(cx); \
|
||||
}
|
||||
BOOST_PP_REPEAT(SCRIPT_INTERFACE_MAX_ARGS, OVERLOADS, ~)
|
||||
@@ -107,7 +107,7 @@ BOOST_PP_REPEAT(SCRIPT_INTERFACE_MAX_ARGS, OVERLOADS, ~)
|
||||
#define OVERLOADS(z, i, data) \
|
||||
template <typename R, TYPENAME_T0_HEAD(z,i) JSClass* CLS, typename TC, R (TC::*fptr) ( T0(z,i) )> \
|
||||
JSBool ScriptInterface::callMethod(JSContext* cx, uint argc, jsval* vp) { \
|
||||
UNUSED2(argc); \
|
||||
JS::CallArgs args = JS::CallArgsFromVp(argc, vp); \
|
||||
SCRIPT_PROFILE \
|
||||
if (ScriptInterface::GetClass(JS_THIS_OBJECT(cx, vp)) != CLS) return false; \
|
||||
TC* c = static_cast<TC*>(ScriptInterface::GetPrivate(JS_THIS_OBJECT(cx, vp))); \
|
||||
@@ -115,7 +115,7 @@ BOOST_PP_REPEAT(SCRIPT_INTERFACE_MAX_ARGS, OVERLOADS, ~)
|
||||
BOOST_PP_REPEAT_##z (i, CONVERT_ARG, ~) \
|
||||
jsval rval = JSVAL_VOID; \
|
||||
ScriptInterface_NativeMethodWrapper<R, TC>::call(cx, rval, c, fptr A0_TAIL(z,i)); \
|
||||
JS_SET_RVAL(cx, vp, rval); \
|
||||
args.rval().set(rval); \
|
||||
return !ScriptInterface::IsExceptionPending(cx); \
|
||||
}
|
||||
BOOST_PP_REPEAT(SCRIPT_INTERFACE_MAX_ARGS, OVERLOADS, ~)
|
||||
|
||||
Reference in New Issue
Block a user