diff --git a/js/xpconnect/src/XPCWrappedNativeInfo.cpp b/js/xpconnect/src/XPCWrappedNativeInfo.cpp index 01dc4eca29fa..f5cd2d792aea 100644 --- a/js/xpconnect/src/XPCWrappedNativeInfo.cpp +++ b/js/xpconnect/src/XPCWrappedNativeInfo.cpp @@ -26,11 +26,12 @@ XPCNativeMember::GetCallInfo(JSObject* funobj, XPCNativeMember** pMember) { funobj = js::UncheckedUnwrap(funobj); - jsval ifaceVal = js::GetFunctionNativeReserved(funobj, 0); - jsval memberVal = js::GetFunctionNativeReserved(funobj, 1); + jsval memberVal = + js::GetFunctionNativeReserved(funobj, + XPC_FUNCTION_NATIVE_MEMBER_SLOT); - *pInterface = (XPCNativeInterface*) ifaceVal.toPrivate(); - *pMember = (XPCNativeMember*) memberVal.toPrivate(); + *pMember = static_cast(memberVal.toPrivate()); + *pInterface = (*pMember)->GetInterface(); return true; } @@ -92,8 +93,8 @@ XPCNativeMember::Resolve(XPCCallContext& ccx, XPCNativeInterface* iface, if (!funobj) return false; - js::SetFunctionNativeReserved(funobj, 0, PRIVATE_TO_JSVAL(iface)); - js::SetFunctionNativeReserved(funobj, 1, PRIVATE_TO_JSVAL(this)); + js::SetFunctionNativeReserved(funobj, XPC_FUNCTION_NATIVE_MEMBER_SLOT, + PrivateValue(this)); *vp = OBJECT_TO_JSVAL(funobj); diff --git a/js/xpconnect/src/xpcprivate.h b/js/xpconnect/src/xpcprivate.h index 69f3214bd248..91439f9e4bd7 100644 --- a/js/xpconnect/src/xpcprivate.h +++ b/js/xpconnect/src/xpcprivate.h @@ -1250,6 +1250,10 @@ private: bool mUseContentXBLScope; }; +/***************************************************************************/ +// Slots we use for our functions +#define XPC_FUNCTION_NATIVE_MEMBER_SLOT 0 + /***************************************************************************/ // XPCNativeMember represents a single idl declared method, attribute or // constant.