Bug 1087404. Get rid of XPCQuickStubs.h/cpp. r=bholley
This commit is contained in:
@@ -27,7 +27,6 @@
|
||||
#include "nsUTF8Utils.h"
|
||||
#include "WrapperFactory.h"
|
||||
#include "xpcprivate.h"
|
||||
#include "XPCQuickStubs.h"
|
||||
#include "XrayWrapper.h"
|
||||
#include "nsPrintfCString.h"
|
||||
#include "prprf.h"
|
||||
@@ -828,7 +827,7 @@ QueryInterface(JSContext* cx, unsigned argc, JS::Value* vp)
|
||||
// Switch this to UnwrapDOMObjectToISupports once our global objects are
|
||||
// using new bindings.
|
||||
nsCOMPtr<nsISupports> native;
|
||||
UnwrapArg<nsISupports>(cx, obj, getter_AddRefs(native));
|
||||
UnwrapArg<nsISupports>(obj, getter_AddRefs(native));
|
||||
if (!native) {
|
||||
return Throw(cx, NS_ERROR_FAILURE);
|
||||
}
|
||||
@@ -843,7 +842,7 @@ QueryInterface(JSContext* cx, unsigned argc, JS::Value* vp)
|
||||
|
||||
nsCOMPtr<nsIJSID> iid;
|
||||
obj = &args[0].toObject();
|
||||
if (NS_FAILED(UnwrapArg<nsIJSID>(cx, obj, getter_AddRefs(iid)))) {
|
||||
if (NS_FAILED(UnwrapArg<nsIJSID>(obj, getter_AddRefs(iid)))) {
|
||||
return Throw(cx, NS_ERROR_XPC_BAD_CONVERT_JS);
|
||||
}
|
||||
MOZ_ASSERT(iid);
|
||||
@@ -2624,5 +2623,32 @@ CallerSubsumes(JSObject *aObject)
|
||||
return nsContentUtils::SubjectPrincipal()->Subsumes(objPrin);
|
||||
}
|
||||
|
||||
nsresult
|
||||
UnwrapArgImpl(JS::Handle<JSObject*> src,
|
||||
const nsIID &iid,
|
||||
void **ppArg)
|
||||
{
|
||||
nsISupports *iface = xpc::UnwrapReflectorToISupports(src);
|
||||
if (iface) {
|
||||
if (NS_FAILED(iface->QueryInterface(iid, ppArg))) {
|
||||
return NS_ERROR_XPC_BAD_CONVERT_JS;
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsRefPtr<nsXPCWrappedJS> wrappedJS;
|
||||
nsresult rv = nsXPCWrappedJS::GetNewOrUsed(src, iid, getter_AddRefs(wrappedJS));
|
||||
if (NS_FAILED(rv) || !wrappedJS) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
// We need to go through the QueryInterface logic to make this return
|
||||
// the right thing for the various 'special' interfaces; e.g.
|
||||
// nsIPropertyBag. We must use AggregatedQueryInterface in cases where
|
||||
// there is an outer to avoid nasty recursion.
|
||||
return wrappedJS->QueryInterface(iid, ppArg);
|
||||
}
|
||||
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
||||
|
||||
@@ -39,10 +39,6 @@
|
||||
class nsIJSID;
|
||||
class nsPIDOMWindow;
|
||||
|
||||
extern nsresult
|
||||
xpc_qsUnwrapArgImpl(JSContext* cx, JS::Handle<JSObject*> src, const nsIID& iid,
|
||||
void** ppArg);
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
template<typename DataType> class MozMap;
|
||||
@@ -56,13 +52,16 @@ struct SelfRef
|
||||
nsISupports* ptr;
|
||||
};
|
||||
|
||||
nsresult
|
||||
UnwrapArgImpl(JS::Handle<JSObject*> src, const nsIID& iid, void** ppArg);
|
||||
|
||||
/** Convert a jsval to an XPCOM pointer. */
|
||||
template <class Interface>
|
||||
inline nsresult
|
||||
UnwrapArg(JSContext* cx, JS::Handle<JSObject*> src, Interface** ppArg)
|
||||
UnwrapArg(JS::Handle<JSObject*> src, Interface** ppArg)
|
||||
{
|
||||
return xpc_qsUnwrapArgImpl(cx, src, NS_GET_TEMPLATE_IID(Interface),
|
||||
reinterpret_cast<void**>(ppArg));
|
||||
return UnwrapArgImpl(src, NS_GET_TEMPLATE_IID(Interface),
|
||||
reinterpret_cast<void**>(ppArg));
|
||||
}
|
||||
|
||||
inline const ErrNum
|
||||
|
||||
@@ -3677,7 +3677,7 @@ class CastableObjectUnwrapper():
|
||||
// want to be in that compartment for the UnwrapArg call.
|
||||
JS::Rooted<JSObject*> source(cx, ${source});
|
||||
JSAutoCompartment ac(cx, ${source});
|
||||
rv = UnwrapArg<${type}>(cx, source, getter_AddRefs(objPtr));
|
||||
rv = UnwrapArg<${type}>(source, getter_AddRefs(objPtr));
|
||||
}
|
||||
""")
|
||||
else:
|
||||
@@ -3685,7 +3685,7 @@ class CastableObjectUnwrapper():
|
||||
self.substitution["source"] = source
|
||||
xpconnectUnwrap = (
|
||||
"JS::Rooted<JSObject*> source(cx, ${source});\n"
|
||||
"nsresult rv = UnwrapArg<${type}>(cx, source, getter_AddRefs(objPtr));\n")
|
||||
"nsresult rv = UnwrapArg<${type}>(source, getter_AddRefs(objPtr));\n")
|
||||
|
||||
if descriptor.hasXPConnectImpls:
|
||||
self.substitution["codeOnFailure"] = string.Template(
|
||||
@@ -4763,7 +4763,7 @@ def getJSToNativeConversionInfo(type, descriptorProvider, failureCode=None,
|
||||
holderType = "nsRefPtr<" + typeName + ">"
|
||||
templateBody += (
|
||||
"JS::Rooted<JSObject*> source(cx, &${val}.toObject());\n" +
|
||||
"if (NS_FAILED(UnwrapArg<" + typeName + ">(cx, source, getter_AddRefs(${holderName})))) {\n")
|
||||
"if (NS_FAILED(UnwrapArg<" + typeName + ">(source, getter_AddRefs(${holderName})))) {\n")
|
||||
templateBody += CGIndenter(onFailureBadType(failureCode,
|
||||
descriptor.interface.identifier.name)).define()
|
||||
templateBody += ("}\n"
|
||||
|
||||
@@ -7,7 +7,6 @@
|
||||
#include "mozilla/dom/DOMJSProxyHandler.h"
|
||||
#include "xpcpublic.h"
|
||||
#include "xpcprivate.h"
|
||||
#include "XPCQuickStubs.h"
|
||||
#include "XPCWrapper.h"
|
||||
#include "WrapperFactory.h"
|
||||
#include "nsDOMClassInfo.h"
|
||||
|
||||
@@ -25,7 +25,6 @@
|
||||
#include "nsXMLHttpRequest.h"
|
||||
#include "WrapperFactory.h"
|
||||
#include "xpcprivate.h"
|
||||
#include "XPCQuickStubs.h"
|
||||
#include "XPCWrapper.h"
|
||||
#include "XrayWrapper.h"
|
||||
#include "mozilla/dom/BindingUtils.h"
|
||||
|
||||
@@ -1,68 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
/* vim: set ts=8 sts=4 et sw=4 tw=99: */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "jsapi.h"
|
||||
#include "jsfriendapi.h"
|
||||
#include "jsprf.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "AccessCheck.h"
|
||||
#include "WrapperFactory.h"
|
||||
#include "xpcprivate.h"
|
||||
#include "XPCInlines.h"
|
||||
#include "XPCQuickStubs.h"
|
||||
#include "mozilla/dom/BindingUtils.h"
|
||||
#include "mozilla/dom/Exceptions.h"
|
||||
|
||||
using namespace mozilla;
|
||||
using namespace JS;
|
||||
|
||||
nsresult
|
||||
xpc_qsUnwrapArgImpl(JSContext *cx,
|
||||
HandleObject src,
|
||||
const nsIID &iid,
|
||||
void **ppArg)
|
||||
{
|
||||
nsISupports *iface = xpc::UnwrapReflectorToISupports(src);
|
||||
if (iface) {
|
||||
if (NS_FAILED(iface->QueryInterface(iid, ppArg))) {
|
||||
return NS_ERROR_XPC_BAD_CONVERT_JS;
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsRefPtr<nsXPCWrappedJS> wrappedJS;
|
||||
nsresult rv = nsXPCWrappedJS::GetNewOrUsed(src, iid, getter_AddRefs(wrappedJS));
|
||||
if (NS_FAILED(rv) || !wrappedJS) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
// We need to go through the QueryInterface logic to make this return
|
||||
// the right thing for the various 'special' interfaces; e.g.
|
||||
// nsIPropertyBag. We must use AggregatedQueryInterface in cases where
|
||||
// there is an outer to avoid nasty recursion.
|
||||
return wrappedJS->QueryInterface(iid, ppArg);
|
||||
}
|
||||
|
||||
namespace xpc {
|
||||
|
||||
bool
|
||||
NonVoidStringToJsval(JSContext *cx, nsAString &str, MutableHandleValue rval)
|
||||
{
|
||||
nsStringBuffer* sharedBuffer;
|
||||
if (!XPCStringConvert::ReadableToJSVal(cx, str, &sharedBuffer, rval))
|
||||
return false;
|
||||
|
||||
if (sharedBuffer) {
|
||||
// The string was shared but ReadableToJSVal didn't addref it.
|
||||
// Move the ownership from str to jsstr.
|
||||
str.ForgetSharedBuffer();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
} // namespace xpc
|
||||
|
||||
@@ -1,18 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
/* vim: set ts=8 sts=4 et sw=4 tw=99: */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#ifndef xpcquickstubs_h___
|
||||
#define xpcquickstubs_h___
|
||||
|
||||
#include "XPCForwards.h"
|
||||
|
||||
/* XPCQuickStubs.h - Support functions used only by Web IDL bindings, for now. */
|
||||
|
||||
nsresult
|
||||
xpc_qsUnwrapArgImpl(JSContext *cx, JS::HandleObject src, const nsIID &iid,
|
||||
void **ppArg);
|
||||
|
||||
#endif /* xpcquickstubs_h___ */
|
||||
@@ -106,3 +106,22 @@ XPCStringConvert::ReadableToJSVal(JSContext *cx,
|
||||
vp.setString(str);
|
||||
return true;
|
||||
}
|
||||
|
||||
namespace xpc {
|
||||
|
||||
bool
|
||||
NonVoidStringToJsval(JSContext *cx, nsAString &str, MutableHandleValue rval)
|
||||
{
|
||||
nsStringBuffer* sharedBuffer;
|
||||
if (!XPCStringConvert::ReadableToJSVal(cx, str, &sharedBuffer, rval))
|
||||
return false;
|
||||
|
||||
if (sharedBuffer) {
|
||||
// The string was shared but ReadableToJSVal didn't addref it.
|
||||
// Move the ownership from str to jsstr.
|
||||
str.ForgetSharedBuffer();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
} // namespace xpc
|
||||
|
||||
@@ -30,7 +30,6 @@ UNIFIED_SOURCES += [
|
||||
'XPCLog.cpp',
|
||||
'XPCMaps.cpp',
|
||||
'XPCModule.cpp',
|
||||
'XPCQuickStubs.cpp',
|
||||
'XPCRuntimeService.cpp',
|
||||
'XPCShellImpl.cpp',
|
||||
'XPCString.cpp',
|
||||
|
||||
@@ -20,8 +20,6 @@
|
||||
#include "WrapperFactory.h"
|
||||
#include "AccessCheck.h"
|
||||
|
||||
#include "XPCQuickStubs.h"
|
||||
|
||||
#include "mozilla/dom/BindingUtils.h"
|
||||
#include "mozilla/dom/Exceptions.h"
|
||||
#include "mozilla/dom/PromiseBinding.h"
|
||||
|
||||
@@ -1,16 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
/* vim: set ts=8 sts=4 et sw=4 tw=99: */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
// Undefines for stupid windows macros
|
||||
#ifdef GetClassName
|
||||
#undef GetClassName
|
||||
#endif
|
||||
#ifdef CreateEvent
|
||||
#undef CreateEvent
|
||||
#endif
|
||||
#ifdef GetBinaryType
|
||||
#undef GetBinaryType
|
||||
#endif
|
||||
Reference in New Issue
Block a user