Bug 877261 - Stop using XPCCallContext for XPCConvert. r=Ms2ger

This commit is contained in:
Bobby Holley 2013-06-04 21:11:19 -07:00
Родитель e5c61adafd
Коммит 638227a746
9 изменённых файлов: 93 добавлений и 143 удалений

Просмотреть файл

@ -584,8 +584,7 @@ NativeInterface2JSObjectAndThrowIfFailed(JSContext* aCx,
bool aAllowNativeWrapper)
{
nsresult rv;
XPCLazyCallContext lccx(JS_CALLER, aCx, aScope);
if (!XPCConvert::NativeInterface2JSObject(lccx, aRetval, NULL, aHelper, aIID,
if (!XPCConvert::NativeInterface2JSObject(aRetval, NULL, aHelper, aIID,
NULL, aAllowNativeWrapper, &rv)) {
// I can't tell if NativeInterface2JSObject throws JS exceptions
// or not. This is a sloppy stab at the right semantics; the
@ -655,8 +654,7 @@ VariantToJsval(JSContext* aCx, JS::Handle<JSObject*> aScope,
nsIVariant* aVariant, JS::Value* aRetval)
{
nsresult rv;
XPCLazyCallContext lccx(JS_CALLER, aCx, aScope);
if (!XPCVariant::VariantDataToJS(lccx, aVariant, &rv, aRetval)) {
if (!XPCVariant::VariantDataToJS(aVariant, &rv, aRetval)) {
// Does it throw? Who knows
if (!JS_IsExceptionPending(aCx)) {
Throw<true>(aCx, NS_FAILED(rv) ? rv : NS_ERROR_UNEXPECTED);

Просмотреть файл

@ -84,13 +84,13 @@ XPCConvert::GetISupportsFromJSObject(JSObject* obj, nsISupports** iface)
// static
JSBool
XPCConvert::NativeData2JS(XPCLazyCallContext& lccx, jsval* d, const void* s,
XPCConvert::NativeData2JS(jsval* d, const void* s,
const nsXPTType& type, const nsID* iid, nsresult* pErr)
{
NS_PRECONDITION(s, "bad param");
NS_PRECONDITION(d, "bad param");
JSContext* cx = lccx.GetJSContext();
AutoJSContext cx;
if (pErr)
*pErr = NS_ERROR_XPC_BAD_CONVERT_NATIVE;
@ -311,12 +311,12 @@ XPCConvert::NativeData2JS(XPCLazyCallContext& lccx, jsval* d, const void* s,
if (!variant)
return false;
return XPCVariant::VariantDataToJS(lccx, variant,
return XPCVariant::VariantDataToJS(variant,
pErr, d);
}
// else...
xpcObjectHelper helper(iface);
if (!NativeInterface2JSObject(lccx, d, nullptr, helper, iid,
if (!NativeInterface2JSObject(d, nullptr, helper, iid,
nullptr, true, pErr))
return false;
@ -365,7 +365,7 @@ bool ConvertToPrimitive(JSContext *cx, HandleValue v, T *retval)
// static
JSBool
XPCConvert::JSData2Native(JSContext* cx, void* d, HandleValue s,
XPCConvert::JSData2Native(void* d, HandleValue s,
const nsXPTType& type,
JSBool useAllocator, const nsID* iid,
nsresult* pErr)
@ -374,6 +374,7 @@ XPCConvert::JSData2Native(JSContext* cx, void* d, HandleValue s,
JSBool isDOMString = true;
AutoJSContext cx;
if (pErr)
*pErr = NS_ERROR_XPC_BAD_CONVERT_JS;
@ -749,7 +750,7 @@ XPCConvert::JSData2Native(JSContext* cx, void* d, HandleValue s,
}
RootedObject src(cx, &s.toObject());
return JSObject2NativeInterface(cx, (void**)d, src, iid, nullptr, pErr);
return JSObject2NativeInterface((void**)d, src, iid, nullptr, pErr);
}
default:
NS_ERROR("bad type");
@ -759,7 +760,7 @@ XPCConvert::JSData2Native(JSContext* cx, void* d, HandleValue s,
}
inline JSBool
CreateHolderIfNeeded(XPCCallContext& ccx, HandleObject obj, jsval* d,
CreateHolderIfNeeded(HandleObject obj, jsval* d,
nsIXPConnectJSObjectHolder** dest)
{
if (dest) {
@ -778,8 +779,7 @@ CreateHolderIfNeeded(XPCCallContext& ccx, HandleObject obj, jsval* d,
/***************************************************************************/
// static
JSBool
XPCConvert::NativeInterface2JSObject(XPCLazyCallContext& lccx,
jsval* d,
XPCConvert::NativeInterface2JSObject(jsval* d,
nsIXPConnectJSObjectHolder** dest,
xpcObjectHelper& aHelper,
const nsID* iid,
@ -806,7 +806,7 @@ XPCConvert::NativeInterface2JSObject(XPCLazyCallContext& lccx,
// (that means an XPCWrappedNative around an nsXPCWrappedJS). This isn't
// optimal -- we could detect this and roll the functionality into a
// single wrapper, but the current solution is good enough for now.
JSContext* cx = lccx.GetJSContext();
AutoJSContext cx;
XPCWrappedNativeScope* xpcscope = GetObjectScope(JS_GetGlobalForScopeChain(cx));
if (!xpcscope)
return false;
@ -824,9 +824,6 @@ XPCConvert::NativeInterface2JSObject(XPCLazyCallContext& lccx,
if (cache) {
flat = cache->GetWrapper();
if (cache->IsDOMBinding()) {
XPCCallContext &ccx = lccx.GetXPCCallContext();
if (!ccx.IsValid())
return false;
if (!flat) {
JS::Rooted<JSObject*> global(cx, xpcscope->GetGlobalJSObject());
@ -836,10 +833,10 @@ XPCConvert::NativeInterface2JSObject(XPCLazyCallContext& lccx,
}
if (flat) {
if (allowNativeWrapper && !JS_WrapObject(ccx, flat.address()))
if (allowNativeWrapper && !JS_WrapObject(cx, flat.address()))
return false;
return CreateHolderIfNeeded(ccx, flat, d, dest);
return CreateHolderIfNeeded(flat, d, dest);
}
}
@ -876,16 +873,12 @@ XPCConvert::NativeInterface2JSObject(XPCLazyCallContext& lccx,
flat = cache->GetWrapper();
}
XPCCallContext &ccx = lccx.GetXPCCallContext();
if (!ccx.IsValid())
return false;
// We can't simply construct a slim wrapper. Go ahead and create an
// XPCWrappedNative for this object. At this point, |flat| could be
// non-null, meaning that either we already have a wrapped native from
// the cache (which might need to be QI'd to the new interface) or that
// we found a slim wrapper that we'll have to morph.
AutoMarkingNativeInterfacePtr iface(ccx);
AutoMarkingNativeInterfacePtr iface(cx);
if (iid) {
if (Interface)
iface = *Interface;
@ -919,9 +912,6 @@ XPCConvert::NativeInterface2JSObject(XPCLazyCallContext& lccx,
// rooted in that case).
if (dest)
strongWrapper = wrapper;
// If iface is not null we know lccx.GetXPCCallContext() returns
// a valid XPCCallContext because we checked when calling Init on
// iface.
if (iface)
wrapper->FindTearOff(iface, false, &rv);
else
@ -962,7 +952,7 @@ XPCConvert::NativeInterface2JSObject(XPCLazyCallContext& lccx,
// The call to wrap here handles both cross-compartment and same-compartment
// security wrappers.
RootedObject original(cx, flat);
if (!JS_WrapObject(ccx, flat.address()))
if (!JS_WrapObject(cx, flat.address()))
return false;
*d = OBJECT_TO_JSVAL(flat);
@ -991,8 +981,7 @@ XPCConvert::NativeInterface2JSObject(XPCLazyCallContext& lccx,
// static
JSBool
XPCConvert::JSObject2NativeInterface(JSContext* cx,
void** dest, HandleObject src,
XPCConvert::JSObject2NativeInterface(void** dest, HandleObject src,
const nsID* iid,
nsISupports* aOuter,
nsresult* pErr)
@ -1001,6 +990,7 @@ XPCConvert::JSObject2NativeInterface(JSContext* cx,
NS_ASSERTION(src, "bad param");
NS_ASSERTION(iid, "bad param");
AutoJSContext cx;
JSAutoCompartment ac(cx, src);
*dest = nullptr;
@ -1144,13 +1134,12 @@ private:
// static
nsresult
XPCConvert::JSValToXPCException(XPCCallContext& ccx,
jsval sArg,
XPCConvert::JSValToXPCException(jsval sArg,
const char* ifaceName,
const char* methodName,
nsIException** exceptn)
{
JSContext* cx = ccx.GetJSContext();
AutoJSContext cx;
RootedValue s(cx, sArg);
AutoExceptionRestorer aer(cx, s);
@ -1195,7 +1184,7 @@ XPCConvert::JSValToXPCException(XPCCallContext& ccx,
JSString* str;
if (nullptr != (str = JS_ValueToString(cx, s)))
message.encodeLatin1(cx, str);
return JSErrorToXPCException(ccx, message.ptr(), ifaceName,
return JSErrorToXPCException(message.ptr(), ifaceName,
methodName, report, exceptn);
}
@ -1214,8 +1203,7 @@ XPCConvert::JSValToXPCException(XPCCallContext& ccx,
// lets try to build a wrapper around the JSObject
nsXPCWrappedJS* jswrapper;
nsresult rv =
nsXPCWrappedJS::GetNewOrUsed(ccx, obj,
NS_GET_IID(nsIException),
nsXPCWrappedJS::GetNewOrUsed(cx, obj, NS_GET_IID(nsIException),
nullptr, &jswrapper);
if (NS_FAILED(rv))
return rv;
@ -1319,13 +1307,13 @@ XPCConvert::JSValToXPCException(XPCCallContext& ccx,
// static
nsresult
XPCConvert::JSErrorToXPCException(XPCCallContext& ccx,
const char* message,
XPCConvert::JSErrorToXPCException(const char* message,
const char* ifaceName,
const char* methodName,
const JSErrorReport* report,
nsIException** exceptn)
{
AutoJSContext cx;
nsresult rv = NS_ERROR_FAILURE;
nsRefPtr<nsScriptError> data;
if (report) {
@ -1349,7 +1337,7 @@ XPCConvert::JSErrorToXPCException(XPCCallContext& ccx,
report->lineno,
report->uctokenptr - report->uclinebuf, report->flags,
"XPConnect JavaScript",
nsJSUtils::GetCurrentlyRunningCodeInnerWindowID(ccx.GetJSContext()));
nsJSUtils::GetCurrentlyRunningCodeInnerWindowID(cx));
}
if (data) {
@ -1378,19 +1366,14 @@ XPCConvert::JSErrorToXPCException(XPCCallContext& ccx,
// static
JSBool
XPCConvert::NativeArray2JS(XPCLazyCallContext& lccx,
jsval* d, const void** s,
XPCConvert::NativeArray2JS(jsval* d, const void** s,
const nsXPTType& type, const nsID* iid,
uint32_t count, nsresult* pErr)
{
NS_PRECONDITION(s, "bad param");
NS_PRECONDITION(d, "bad param");
XPCCallContext& ccx = lccx.GetXPCCallContext();
if (!ccx.IsValid())
return false;
JSContext* cx = ccx.GetJSContext();
AutoJSContext cx;
// XXX add support for putting chars in a string rather than an array
@ -1409,7 +1392,7 @@ XPCConvert::NativeArray2JS(XPCLazyCallContext& lccx,
#define POPULATE(_t) \
PR_BEGIN_MACRO \
for (i = 0; i < count; i++) { \
if (!NativeData2JS(ccx, current.address(), ((_t*)*s)+i, type, iid, pErr) || \
if (!NativeData2JS(current.address(), ((_t*)*s)+i, type, iid, pErr) || \
!JS_SetElement(cx, array, i, current.address())) \
goto failure; \
} \
@ -1613,12 +1596,14 @@ XPCConvert::JSTypedArray2Native(void** d,
// static
JSBool
XPCConvert::JSArray2Native(JSContext* cx, void** d, JS::Value s,
XPCConvert::JSArray2Native(void** d, JS::Value s,
uint32_t count, const nsXPTType& type,
const nsID* iid, nsresult* pErr)
{
NS_ABORT_IF_FALSE(d, "bad param");
AutoJSContext cx;
// XXX add support for getting chars from strings
// XXX add support to indicate *which* array element was not convertable
@ -1675,7 +1660,7 @@ XPCConvert::JSArray2Native(JSContext* cx, void** d, JS::Value s,
} \
for (initedCount = 0; initedCount < count; initedCount++) { \
if (!JS_GetElement(cx, jsarray, initedCount, current.address()) || \
!JSData2Native(cx, ((_t*)array)+initedCount, current, type, \
!JSData2Native(((_t*)array)+initedCount, current, type, \
true, iid, pErr)) \
goto failure; \
} \
@ -1751,8 +1736,7 @@ failure:
// static
JSBool
XPCConvert::NativeStringWithSize2JS(JSContext* cx,
jsval* d, const void* s,
XPCConvert::NativeStringWithSize2JS(jsval* d, const void* s,
const nsXPTType& type,
uint32_t count,
nsresult* pErr)
@ -1760,6 +1744,7 @@ XPCConvert::NativeStringWithSize2JS(JSContext* cx,
NS_PRECONDITION(s, "bad param");
NS_PRECONDITION(d, "bad param");
AutoJSContext cx;
if (pErr)
*pErr = NS_ERROR_XPC_BAD_CONVERT_NATIVE;
@ -1795,15 +1780,14 @@ XPCConvert::NativeStringWithSize2JS(JSContext* cx,
// static
JSBool
XPCConvert::JSStringWithSize2Native(XPCCallContext& ccx, void* d, jsval s,
XPCConvert::JSStringWithSize2Native(void* d, jsval s,
uint32_t count, const nsXPTType& type,
nsresult* pErr)
{
NS_PRECONDITION(!JSVAL_IS_NULL(s), "bad param");
NS_PRECONDITION(d, "bad param");
JSContext* cx = ccx.GetJSContext();
AutoJSContext cx;
uint32_t len;
if (pErr)

Просмотреть файл

@ -911,7 +911,7 @@ xpc_qsXPCOMObjectToJsval(XPCLazyCallContext &lccx, qsObjectHelper &aHelper,
JSContext *cx = lccx.GetJSContext();
nsresult rv;
if (!XPCConvert::NativeInterface2JSObject(lccx, rval, nullptr,
if (!XPCConvert::NativeInterface2JSObject(rval, nullptr,
aHelper, iid, iface,
true, &rv)) {
// I can't tell if NativeInterface2JSObject throws JS exceptions
@ -941,7 +941,7 @@ xpc_qsVariantToJsval(XPCLazyCallContext &lccx,
// Error handling is in XPCWrappedNative::CallMethod.
if (p) {
nsresult rv;
JSBool ok = XPCVariant::VariantDataToJS(lccx, p, &rv, rval);
JSBool ok = XPCVariant::VariantDataToJS(p, &rv, rval);
if (!ok)
xpc_qsThrow(lccx.GetJSContext(), rv);
return ok;

Просмотреть файл

@ -8,10 +8,12 @@
#include "xpcprivate.h"
#include "XPCWrapper.h"
#include "nsCxPusher.h"
#include "jsfriendapi.h"
using namespace JS;
using namespace mozilla;
NS_IMPL_CLASSINFO(XPCVariant, NULL, 0, XPCVARIANT_CID)
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(XPCVariant)
@ -335,7 +337,7 @@ JSBool XPCVariant::InitializeData(JSContext* cx)
if (!XPCArrayHomogenizer::GetTypeForArray(cx, jsobj, len, &type, &id))
return false;
if (!XPCConvert::JSArray2Native(cx, &mData.u.array.mArrayValue,
if (!XPCConvert::JSArray2Native(&mData.u.array.mArrayValue,
val, len, type, &id, nullptr))
return false;
@ -369,8 +371,7 @@ XPCVariant::GetAsJSVal(jsval* result)
// static
JSBool
XPCVariant::VariantDataToJS(XPCLazyCallContext& lccx,
nsIVariant* variant,
XPCVariant::VariantDataToJS(nsIVariant* variant,
nsresult* pErr, jsval* pJSVal)
{
// Get the type early because we might need to spoof it below.
@ -378,7 +379,7 @@ XPCVariant::VariantDataToJS(XPCLazyCallContext& lccx,
if (NS_FAILED(variant->GetDataType(&type)))
return false;
JSContext *cx = lccx.GetJSContext();
AutoJSContext cx;
RootedValue realVal(cx);
nsresult rv = variant->GetAsJSVal(realVal.address());
@ -448,21 +449,21 @@ XPCVariant::VariantDataToJS(XPCLazyCallContext& lccx,
char c;
if (NS_FAILED(variant->GetAsChar(&c)))
return false;
return XPCConvert::NativeData2JS(lccx, pJSVal, (const void*)&c, TD_CHAR, &iid, pErr);
return XPCConvert::NativeData2JS(pJSVal, (const void*)&c, TD_CHAR, &iid, pErr);
}
case nsIDataType::VTYPE_WCHAR:
{
PRUnichar wc;
if (NS_FAILED(variant->GetAsWChar(&wc)))
return false;
return XPCConvert::NativeData2JS(lccx, pJSVal, (const void*)&wc, TD_WCHAR, &iid, pErr);
return XPCConvert::NativeData2JS(pJSVal, (const void*)&wc, TD_WCHAR, &iid, pErr);
}
case nsIDataType::VTYPE_ID:
{
if (NS_FAILED(variant->GetAsID(&iid)))
return false;
nsID *v = &iid;
return XPCConvert::NativeData2JS(lccx, pJSVal, (const void*)&v, TD_PNSIID, &iid, pErr);
return XPCConvert::NativeData2JS(pJSVal, (const void*)&v, TD_PNSIID, &iid, pErr);
}
case nsIDataType::VTYPE_ASTRING:
{
@ -470,7 +471,7 @@ XPCVariant::VariantDataToJS(XPCLazyCallContext& lccx,
if (NS_FAILED(variant->GetAsAString(astring)))
return false;
nsAutoString *v = &astring;
return XPCConvert::NativeData2JS(lccx, pJSVal, (const void*)&v, TD_ASTRING, &iid, pErr);
return XPCConvert::NativeData2JS(pJSVal, (const void*)&v, TD_ASTRING, &iid, pErr);
}
case nsIDataType::VTYPE_DOMSTRING:
{
@ -478,7 +479,7 @@ XPCVariant::VariantDataToJS(XPCLazyCallContext& lccx,
if (NS_FAILED(variant->GetAsAString(astring)))
return false;
nsAutoString *v = &astring;
return XPCConvert::NativeData2JS(lccx, pJSVal, (const void*)&v,
return XPCConvert::NativeData2JS(pJSVal, (const void*)&v,
TD_DOMSTRING, &iid, pErr);
}
case nsIDataType::VTYPE_CSTRING:
@ -487,7 +488,7 @@ XPCVariant::VariantDataToJS(XPCLazyCallContext& lccx,
if (NS_FAILED(variant->GetAsACString(cString)))
return false;
nsAutoCString *v = &cString;
return XPCConvert::NativeData2JS(lccx, pJSVal, (const void*)&v,
return XPCConvert::NativeData2JS(pJSVal, (const void*)&v,
TD_CSTRING, &iid, pErr);
}
case nsIDataType::VTYPE_UTF8STRING:
@ -496,7 +497,7 @@ XPCVariant::VariantDataToJS(XPCLazyCallContext& lccx,
if (NS_FAILED(variant->GetAsAUTF8String(utf8String)))
return false;
nsUTF8String *v = &utf8String;
return XPCConvert::NativeData2JS(lccx, pJSVal, (const void*)&v,
return XPCConvert::NativeData2JS(pJSVal, (const void*)&v,
TD_UTF8STRING, &iid, pErr);
}
case nsIDataType::VTYPE_CHAR_STR:
@ -504,7 +505,7 @@ XPCVariant::VariantDataToJS(XPCLazyCallContext& lccx,
char *pc;
if (NS_FAILED(variant->GetAsString(&pc)))
return false;
bool success = XPCConvert::NativeData2JS(lccx, pJSVal, (const void*)&pc,
bool success = XPCConvert::NativeData2JS(pJSVal, (const void*)&pc,
TD_PSTRING, &iid, pErr);
nsMemory::Free(pc);
return success;
@ -515,7 +516,7 @@ XPCVariant::VariantDataToJS(XPCLazyCallContext& lccx,
uint32_t size;
if (NS_FAILED(variant->GetAsStringWithSize(&size, &pc)))
return false;
bool success = XPCConvert::NativeStringWithSize2JS(cx, pJSVal, (const void*)&pc,
bool success = XPCConvert::NativeStringWithSize2JS(pJSVal, (const void*)&pc,
TD_PSTRING_SIZE_IS, size, pErr);
nsMemory::Free(pc);
return success;
@ -525,7 +526,7 @@ XPCVariant::VariantDataToJS(XPCLazyCallContext& lccx,
PRUnichar *pwc;
if (NS_FAILED(variant->GetAsWString(&pwc)))
return false;
bool success = XPCConvert::NativeData2JS(lccx, pJSVal, (const void*)&pwc,
bool success = XPCConvert::NativeData2JS(pJSVal, (const void*)&pwc,
TD_PSTRING, &iid, pErr);
nsMemory::Free(pwc);
return success;
@ -536,7 +537,7 @@ XPCVariant::VariantDataToJS(XPCLazyCallContext& lccx,
uint32_t size;
if (NS_FAILED(variant->GetAsWStringWithSize(&size, &pwc)))
return false;
bool success = XPCConvert::NativeStringWithSize2JS(cx, pJSVal, (const void*)&pwc,
bool success = XPCConvert::NativeStringWithSize2JS(pJSVal, (const void*)&pwc,
TD_PWSTRING_SIZE_IS, size, pErr);
nsMemory::Free(pwc);
return success;
@ -552,7 +553,7 @@ XPCVariant::VariantDataToJS(XPCLazyCallContext& lccx,
iid = *piid;
nsMemory::Free((char*)piid);
bool success = XPCConvert::NativeData2JS(lccx, pJSVal, (const void*)&pi,
bool success = XPCConvert::NativeData2JS(pJSVal, (const void*)&pi,
TD_INTERFACE_IS_TYPE, &iid, pErr);
if (pi)
pi->Release();
@ -629,7 +630,7 @@ XPCVariant::VariantDataToJS(XPCLazyCallContext& lccx,
}
success =
XPCConvert::NativeArray2JS(lccx, pJSVal,
XPCConvert::NativeArray2JS(pJSVal,
(const void**)&du.u.array.mArrayValue,
conversionType, pid,
du.u.array.mArrayCount, pErr);

Просмотреть файл

@ -333,7 +333,7 @@ GetNamedPropertyAsVariantRaw(XPCCallContext& ccx,
// Note that this always takes the T_INTERFACE path through
// JSData2Native, so the value passed for useAllocator
// doesn't really matter. We pass true for consistency.
XPCConvert::JSData2Native(ccx, aResult, val, type, true,
XPCConvert::JSData2Native(aResult, val, type, true,
&NS_GET_IID(nsIVariant), pErr);
}
@ -816,7 +816,7 @@ xpcWrappedJSErrorReporter(JSContext *cx, const char *message,
return;
nsCOMPtr<nsIException> e;
XPCConvert::JSErrorToXPCException(ccx, message, nullptr, nullptr, report,
XPCConvert::JSErrorToXPCException(message, nullptr, nullptr, report,
getter_AddRefs(e));
if (e)
ccx.GetXPCContext()->SetException(e);
@ -967,7 +967,7 @@ nsXPCWrappedJSClass::CheckForException(XPCCallContext & ccx,
/* JS might throw an expection whether the reporter was called or not */
if (is_js_exception) {
if (!xpc_exception)
XPCConvert::JSValToXPCException(ccx, js_exception, anInterfaceName,
XPCConvert::JSValToXPCException(js_exception, anInterfaceName,
aPropertyName,
getter_AddRefs(xpc_exception));
@ -1240,7 +1240,7 @@ nsXPCWrappedJSClass::CallMethod(nsXPCWrappedJS* wrapper, uint16_t methodIndex,
xpcObjectHelper helper(newThis);
JSBool ok =
XPCConvert::NativeInterface2JSObject(
ccx, v.address(), nullptr, helper, nullptr,
v.address(), nullptr, helper, nullptr,
nullptr, false, nullptr);
if (!ok) {
goto pre_call_clean_up;
@ -1328,19 +1328,19 @@ nsXPCWrappedJSClass::CallMethod(nsXPCWrappedJS* wrapper, uint16_t methodIndex,
if (isArray) {
XPCLazyCallContext lccx(ccx);
if (!XPCConvert::NativeArray2JS(lccx, val.address(),
if (!XPCConvert::NativeArray2JS(val.address(),
(const void**)&pv->val,
datum_type, &param_iid,
array_count, nullptr))
goto pre_call_clean_up;
} else if (isSizedString) {
if (!XPCConvert::NativeStringWithSize2JS(ccx, val.address(),
if (!XPCConvert::NativeStringWithSize2JS(val.address(),
(const void*)&pv->val,
datum_type,
array_count, nullptr))
goto pre_call_clean_up;
} else {
if (!XPCConvert::NativeData2JS(ccx, val.address(), &pv->val, type,
if (!XPCConvert::NativeData2JS(val.address(), &pv->val, type,
&param_iid, nullptr))
goto pre_call_clean_up;
}
@ -1517,7 +1517,7 @@ pre_call_clean_up:
break;
}
if (!XPCConvert::JSData2Native(ccx, &pv->val, val, type,
if (!XPCConvert::JSData2Native(&pv->val, val, type,
!param.IsDipper(), &param_iid, nullptr))
break;
}
@ -1576,18 +1576,17 @@ pre_call_clean_up:
if (isArray) {
if (array_count &&
!XPCConvert::JSArray2Native(ccx, (void**)&pv->val, val,
!XPCConvert::JSArray2Native((void**)&pv->val, val,
array_count, datum_type,
&param_iid, nullptr))
break;
} else if (isSizedString) {
if (!XPCConvert::JSStringWithSize2Native(ccx,
(void*)&pv->val, val,
if (!XPCConvert::JSStringWithSize2Native((void*)&pv->val, val,
array_count, datum_type,
nullptr))
break;
} else {
if (!XPCConvert::JSData2Native(ccx, &pv->val, val, type,
if (!XPCConvert::JSData2Native(&pv->val, val, type,
true, &param_iid,
nullptr))
break;

Просмотреть файл

@ -2457,7 +2457,7 @@ CallMethodHelper::GatherAndConvertResults()
nsresult err;
if (isArray) {
XPCLazyCallContext lccx(mCallContext);
if (!XPCConvert::NativeArray2JS(lccx, v.address(), (const void**)&dp->val,
if (!XPCConvert::NativeArray2JS(v.address(), (const void**)&dp->val,
datum_type, &param_iid,
array_count, &err)) {
// XXX need exception scheme for arrays to indicate bad element
@ -2465,7 +2465,7 @@ CallMethodHelper::GatherAndConvertResults()
return false;
}
} else if (isSizedString) {
if (!XPCConvert::NativeStringWithSize2JS(mCallContext, v.address(),
if (!XPCConvert::NativeStringWithSize2JS(v.address(),
(const void*)&dp->val,
datum_type,
array_count, &err)) {
@ -2473,7 +2473,7 @@ CallMethodHelper::GatherAndConvertResults()
return false;
}
} else {
if (!XPCConvert::NativeData2JS(mCallContext, v.address(), &dp->val, datum_type,
if (!XPCConvert::NativeData2JS(v.address(), &dp->val, datum_type,
&param_iid, &err)) {
ThrowBadParam(err, i, mCallContext);
return false;
@ -2536,7 +2536,7 @@ CallMethodHelper::QueryInterfaceFastPath() const
RootedValue v(mCallContext, NullValue());
nsresult err;
JSBool success =
XPCConvert::NativeData2JS(mCallContext, v.address(), &qiresult,
XPCConvert::NativeData2JS(v.address(), &qiresult,
nsXPTType::T_INTERFACE_IS,
iid, &err);
NS_IF_RELEASE(qiresult);
@ -2701,8 +2701,7 @@ CallMethodHelper::ConvertIndependentParam(uint8_t i)
}
nsresult err;
if (!XPCConvert::JSData2Native(mCallContext, &dp->val, src, type,
true, &param_iid, &err)) {
if (!XPCConvert::JSData2Native(&dp->val, src, type, true, &param_iid, &err)) {
ThrowBadParam(err, i, mCallContext);
return false;
}
@ -2806,7 +2805,7 @@ CallMethodHelper::ConvertDependentParam(uint8_t i)
if (isArray) {
if (array_count &&
!XPCConvert::JSArray2Native(mCallContext, (void**)&dp->val, src,
!XPCConvert::JSArray2Native((void**)&dp->val, src,
array_count, datum_type, &param_iid,
&err)) {
// XXX need exception scheme for arrays to indicate bad element
@ -2815,8 +2814,7 @@ CallMethodHelper::ConvertDependentParam(uint8_t i)
}
} else // if (isSizedString)
{
if (!XPCConvert::JSStringWithSize2Native(mCallContext,
(void*)&dp->val,
if (!XPCConvert::JSStringWithSize2Native((void*)&dp->val,
src, array_count,
datum_type, &err)) {
ThrowBadParam(err, i, mCallContext);
@ -2824,8 +2822,8 @@ CallMethodHelper::ConvertDependentParam(uint8_t i)
}
}
} else {
if (!XPCConvert::JSData2Native(mCallContext, &dp->val, src, type,
true, &param_iid, &err)) {
if (!XPCConvert::JSData2Native(&dp->val, src, type, true,
&param_iid, &err)) {
ThrowBadParam(err, i, mCallContext);
return false;
}

Просмотреть файл

@ -64,7 +64,7 @@ XPCNativeMember::Resolve(XPCCallContext& ccx, XPCNativeInterface* iface,
RootedValue resultVal(ccx);
if (!XPCConvert::NativeData2JS(ccx, resultVal.address(), &v.val, v.type,
if (!XPCConvert::NativeData2JS(resultVal.address(), &v.val, v.type,
nullptr, nullptr))
return false;

Просмотреть файл

@ -1117,7 +1117,7 @@ NativeInterface2JSObject(XPCLazyCallContext & lccx,
nsresult rv;
xpcObjectHelper helper(aCOMObj, aCache);
if (!XPCConvert::NativeInterface2JSObject(lccx, aVal, aHolder, helper, aIID,
if (!XPCConvert::NativeInterface2JSObject(aVal, aHolder, helper, aIID,
nullptr, aAllowWrapping, &rv))
return rv;
@ -1200,7 +1200,7 @@ nsXPConnect::WrapJS(JSContext * aJSContext,
JSAutoCompartment ac(ccx, aJSObj);
nsresult rv = NS_ERROR_UNEXPECTED;
if (!XPCConvert::JSObject2NativeInterface(ccx, result, aJSObj,
if (!XPCConvert::JSObject2NativeInterface(result, aJSObj,
&aIID, nullptr, &rv))
return rv;
return NS_OK;
@ -1246,7 +1246,7 @@ nsXPConnect::WrapJSAggregatedToNative(nsISupports *aOuter,
return UnexpectedFailure(NS_ERROR_FAILURE);
nsresult rv;
if (!XPCConvert::JSObject2NativeInterface(ccx, result, aJSObj,
if (!XPCConvert::JSObject2NativeInterface(result, aJSObj,
&aIID, aOuter, &rv))
return rv;
return NS_OK;
@ -1771,7 +1771,7 @@ nsXPConnect::VariantToJS(JSContext* ctx, JSObject* scopeArg, nsIVariant* value,
MOZ_ASSERT(js::IsObjectInContextCompartment(scope, ctx));
nsresult rv = NS_OK;
if (!XPCVariant::VariantDataToJS(lccx, value, &rv, _retval)) {
if (!XPCVariant::VariantDataToJS(value, &rv, _retval)) {
if (NS_FAILED(rv))
return rv;

Просмотреть файл

@ -3199,19 +3199,11 @@ public:
* @param pErr [out] relevant error code, if any.
*/
static JSBool NativeData2JS(XPCCallContext& ccx, jsval* d, const void* s,
const nsXPTType& type, const nsID* iid,
nsresult* pErr)
{
XPCLazyCallContext lccx(ccx);
return NativeData2JS(lccx, d, s, type, iid, pErr);
}
static JSBool NativeData2JS(XPCLazyCallContext& lccx, jsval* d,
static JSBool NativeData2JS(jsval* d,
const void* s, const nsXPTType& type,
const nsID* iid, nsresult* pErr);
static JSBool JSData2Native(JSContext* cx, void* d, JS::HandleValue s,
static JSBool JSData2Native(void* d, JS::HandleValue s,
const nsXPTType& type,
JSBool useAllocator, const nsID* iid,
nsresult* pErr);
@ -3232,21 +3224,7 @@ public:
* @param src_is_identity optional performance hint. Set to true only
* if src is the identity pointer.
*/
static JSBool NativeInterface2JSObject(XPCCallContext& ccx,
jsval* d,
nsIXPConnectJSObjectHolder** dest,
xpcObjectHelper& aHelper,
const nsID* iid,
XPCNativeInterface** Interface,
bool allowNativeWrapper,
nsresult* pErr)
{
XPCLazyCallContext lccx(ccx);
return NativeInterface2JSObject(lccx, d, dest, aHelper, iid, Interface,
allowNativeWrapper, pErr);
}
static JSBool NativeInterface2JSObject(XPCLazyCallContext& lccx,
jsval* d,
static JSBool NativeInterface2JSObject(jsval* d,
nsIXPConnectJSObjectHolder** dest,
xpcObjectHelper& aHelper,
const nsID* iid,
@ -3254,12 +3232,10 @@ public:
bool allowNativeWrapper,
nsresult* pErr);
static JSBool GetNativeInterfaceFromJSObject(XPCCallContext& ccx,
void** dest, JSObject* src,
static JSBool GetNativeInterfaceFromJSObject(void** dest, JSObject* src,
const nsID* iid,
nsresult* pErr);
static JSBool JSObject2NativeInterface(JSContext* cx,
void** dest, JS::HandleObject src,
static JSBool JSObject2NativeInterface(void** dest, JS::HandleObject src,
const nsID* iid,
nsISupports* aOuter,
nsresult* pErr);
@ -3268,7 +3244,6 @@ public:
/**
* Convert a native array into a jsval.
*
* @param ccx the context for the whole procedure
* @param d [out] the resulting jsval
* @param s the native array we're working with
* @param type the type of objects in the array
@ -3277,12 +3252,11 @@ public:
* @param scope the default scope to put on the new JSObjects' parent chain
* @param pErr [out] relevant error code, if any.
*/
static JSBool NativeArray2JS(XPCLazyCallContext& ccx,
jsval* d, const void** s,
static JSBool NativeArray2JS(jsval* d, const void** s,
const nsXPTType& type, const nsID* iid,
uint32_t count, nsresult* pErr);
static JSBool JSArray2Native(JSContext* cx, void** d, jsval s,
static JSBool JSArray2Native(void** d, jsval s,
uint32_t count, const nsXPTType& type,
const nsID* iid, nsresult* pErr);
@ -3292,24 +3266,21 @@ public:
const nsXPTType& type,
nsresult* pErr);
static JSBool NativeStringWithSize2JS(JSContext* cx,
jsval* d, const void* s,
static JSBool NativeStringWithSize2JS(jsval* d, const void* s,
const nsXPTType& type,
uint32_t count,
nsresult* pErr);
static JSBool JSStringWithSize2Native(XPCCallContext& ccx, void* d, jsval s,
static JSBool JSStringWithSize2Native(void* d, jsval s,
uint32_t count, const nsXPTType& type,
nsresult* pErr);
static nsresult JSValToXPCException(XPCCallContext& ccx,
jsval s,
static nsresult JSValToXPCException(jsval s,
const char* ifaceName,
const char* methodName,
nsIException** exception);
static nsresult JSErrorToXPCException(XPCCallContext& ccx,
const char* message,
static nsresult JSErrorToXPCException(const char* message,
const char* ifaceName,
const char* methodName,
const JSErrorReport* report,
@ -3950,8 +3921,7 @@ public:
* @param pErr [out] relevant error code, if any.
* @param pJSVal [out] the resulting jsval.
*/
static JSBool VariantDataToJS(XPCLazyCallContext& lccx,
nsIVariant* variant,
static JSBool VariantDataToJS(nsIVariant* variant,
nsresult* pErr, jsval* pJSVal);
bool IsPurple()