Exact stack rooting for GetClass and GetPrivate.

Refs #2415

This was SVN commit r15606.
This commit is contained in:
Yves 2014-08-03 17:53:21 +00:00
parent 169174824f
commit f4d62152e7
3 changed files with 7 additions and 6 deletions

View File

@ -113,8 +113,9 @@ BOOST_PP_REPEAT(SCRIPT_INTERFACE_MAX_ARGS, OVERLOADS, ~)
JS::CallArgs args = JS::CallArgsFromVp(argc, vp); \
JSAutoRequest rq(cx); \
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))); \
JS::RootedObject thisObj(cx, JS_THIS_OBJECT(cx, vp)); \
if (ScriptInterface::GetClass(thisObj) != CLS) return false; \
TC* c = static_cast<TC*>(ScriptInterface::GetPrivate(thisObj)); \
if (! c) return false; \
BOOST_PP_REPEAT_##z (i, CONVERT_ARG, ~) \
JS::RootedValue rval(cx); \

View File

@ -1375,12 +1375,12 @@ bool ScriptInterface::IsExceptionPending(JSContext* cx)
return JS_IsExceptionPending(cx) ? true : false;
}
JSClass* ScriptInterface::GetClass(JSObject* obj)
JSClass* ScriptInterface::GetClass(JS::HandleObject obj)
{
return JS_GetClass(obj);
}
void* ScriptInterface::GetPrivate(JSObject* obj)
void* ScriptInterface::GetPrivate(JS::HandleObject obj)
{
// TODO: use JS_GetInstancePrivate
return JS_GetPrivate(obj);

View File

@ -414,8 +414,8 @@ private:
bool GetProperty_(JS::HandleValue obj, const char* name, JS::MutableHandleValue out);
bool GetPropertyInt_(JS::HandleValue obj, int name, JS::MutableHandleValue value);
static bool IsExceptionPending(JSContext* cx);
static JSClass* GetClass(JSObject* obj);
static void* GetPrivate(JSObject* obj);
static JSClass* GetClass(JS::HandleObject obj);
static void* GetPrivate(JS::HandleObject obj);
class CustomType
{