Added nsJSUtils::nsConvertJSValtoXPCObject to handle 'in xpidl' parameters.
git-svn-id: svn://10.0.0.236/trunk@29380 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
@@ -219,6 +219,42 @@ nsJSUtils::nsConvertJSValToObject(nsISupports** aSupports,
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
NS_EXPORT PRBool
|
||||
nsJSUtils::nsConvertJSValToXPCObject(nsISupports** aSupports,
|
||||
REFNSIID aIID,
|
||||
JSContext* aContext,
|
||||
jsval aValue)
|
||||
{
|
||||
*aSupports = nsnull;
|
||||
if (JSVAL_IS_NULL(aValue)) {
|
||||
return JS_TRUE;
|
||||
}
|
||||
else if (JSVAL_IS_OBJECT(aValue)) {
|
||||
nsresult rv;
|
||||
NS_WITH_SERVICE(nsIXPConnect, xpc, kXPConnectCID, &rv);
|
||||
if (NS_FAILED(rv)) return JS_FALSE;
|
||||
|
||||
nsIXPConnectWrappedNative* wrapper;
|
||||
rv = xpc->GetWrappedNativeOfJSObject(aContext, JSVAL_TO_OBJECT(aValue), &wrapper);
|
||||
if (NS_FAILED(rv)) return JS_FALSE;
|
||||
|
||||
nsISupports* native;
|
||||
rv = wrapper->GetNative(&native);
|
||||
NS_RELEASE(wrapper);
|
||||
if (NS_FAILED(rv)) return JS_FALSE;
|
||||
|
||||
rv = native->QueryInterface(aIID, (void**) aSupports);
|
||||
NS_RELEASE(native);
|
||||
if (NS_FAILED(rv)) return JS_FALSE;
|
||||
|
||||
return JS_TRUE;
|
||||
}
|
||||
else {
|
||||
return JS_FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
NS_EXPORT void
|
||||
nsJSUtils::nsConvertJSValToString(nsString& aString,
|
||||
JSContext* aContext,
|
||||
|
||||
@@ -68,6 +68,11 @@ public:
|
||||
JSContext* aContext,
|
||||
jsval aValue);
|
||||
|
||||
static NS_EXPORT PRBool nsConvertJSValToXPCObject(nsISupports** aSupports,
|
||||
REFNSIID aIID,
|
||||
JSContext* aContext,
|
||||
jsval aValue);
|
||||
|
||||
static NS_EXPORT void nsConvertJSValToString(nsString& aString,
|
||||
JSContext* aContext,
|
||||
jsval aValue);
|
||||
|
||||
Reference in New Issue
Block a user