From c26753b13999d4279138d53fceb0d1b902f99da9 Mon Sep 17 00:00:00 2001 From: Boris Zbarsky Date: Wed, 22 Oct 2014 11:40:50 -0400 Subject: [PATCH] Bug 1019191 part 17. Make some of the remaining quickstub unwrap methods static. r=peterv Note that we know that we always call UnwrapArg with an object, so xpc_qsUnwrapArgImpl knows v is always an object. --- js/xpconnect/src/XPCQuickStubs.cpp | 15 +++++-------- js/xpconnect/src/XPCQuickStubs.h | 35 ------------------------------ 2 files changed, 5 insertions(+), 45 deletions(-) diff --git a/js/xpconnect/src/XPCQuickStubs.cpp b/js/xpconnect/src/XPCQuickStubs.cpp index 2ceacdec9a66..6bf5641a8f4c 100644 --- a/js/xpconnect/src/XPCQuickStubs.cpp +++ b/js/xpconnect/src/XPCQuickStubs.cpp @@ -48,7 +48,7 @@ getNativeFromWrapper(JSContext *cx, } -nsresult +static nsresult getWrapper(JSContext *cx, JSObject *obj, XPCWrappedNative **wrapper, @@ -106,7 +106,7 @@ getWrapper(JSContext *cx, return NS_OK; } -nsresult +static nsresult castNative(JSContext *cx, XPCWrappedNative *wrapper, JSObject *curArg, @@ -147,18 +147,13 @@ xpc_qsUnwrapArgImpl(JSContext *cx, nsISupports **ppArgRef, MutableHandleValue vp) { - nsresult rv; - RootedObject src(cx, xpc_qsUnwrapObj(v, ppArgRef, &rv)); - if (!src) { - *ppArg = nullptr; - - return rv; - } + MOZ_ASSERT(v.isObject()); + RootedObject src(cx, &v.toObject()); XPCWrappedNative *wrapper; XPCWrappedNativeTearOff *tearoff; JSObject *obj2; - rv = getWrapper(cx, src, &wrapper, &obj2, &tearoff); + nsresult rv = getWrapper(cx, src, &wrapper, &obj2, &tearoff); NS_ENSURE_SUCCESS(rv, rv); if (wrapper || obj2) { diff --git a/js/xpconnect/src/XPCQuickStubs.h b/js/xpconnect/src/XPCQuickStubs.h index 3ea26e97472d..6aed858c08ff 100644 --- a/js/xpconnect/src/XPCQuickStubs.h +++ b/js/xpconnect/src/XPCQuickStubs.h @@ -11,41 +11,6 @@ /* XPCQuickStubs.h - Support functions used only by Web IDL bindings, for now. */ -nsresult -getWrapper(JSContext *cx, - JSObject *obj, - XPCWrappedNative **wrapper, - JSObject **cur, - XPCWrappedNativeTearOff **tearoff); - -nsresult -castNative(JSContext *cx, - XPCWrappedNative *wrapper, - JSObject *cur, - XPCWrappedNativeTearOff *tearoff, - const nsIID &iid, - void **ppThis, - nsISupports **ppThisRef, - JS::MutableHandleValue vp); - -MOZ_ALWAYS_INLINE JSObject* -xpc_qsUnwrapObj(jsval v, nsISupports **ppArgRef, nsresult *rv) -{ - *rv = NS_OK; - if (v.isObject()) { - return &v.toObject(); - } - - if (!v.isNullOrUndefined()) { - *rv = ((v.isInt32() && v.toInt32() == 0) - ? NS_ERROR_XPC_BAD_CONVERT_JS_ZERO_ISNOT_NULL - : NS_ERROR_XPC_BAD_CONVERT_JS); - } - - *ppArgRef = nullptr; - return nullptr; -} - nsresult xpc_qsUnwrapArgImpl(JSContext *cx, JS::HandleValue v, const nsIID &iid, void **ppArg, nsISupports **ppArgRef, JS::MutableHandleValue vp);