mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 705320 - Use IDL for xpcIJSWeakReference.get; r=bholley
This commit is contained in:
parent
9713252f34
commit
7ff45c8468
@ -36,7 +36,7 @@
|
|||||||
|
|
||||||
#include "nsISupports.idl"
|
#include "nsISupports.idl"
|
||||||
|
|
||||||
[scriptable, uuid(5b776cd4-952b-45a2-b363-84e99e8fe608)]
|
[scriptable, uuid(75767928-ecb1-4e6c-9f55-c118b297fcef)]
|
||||||
interface xpcIJSWeakReference : nsISupports
|
interface xpcIJSWeakReference : nsISupports
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
@ -45,5 +45,5 @@ interface xpcIJSWeakReference : nsISupports
|
|||||||
* Returns the referenced JS object or null if the JS object has
|
* Returns the referenced JS object or null if the JS object has
|
||||||
* been garbage collected.
|
* been garbage collected.
|
||||||
*/
|
*/
|
||||||
void /* JSObject */ get();
|
[implicit_jscontext] jsval get();
|
||||||
};
|
};
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||||
/* ***** BEGIN LICENSE BLOCK *****
|
/* ***** BEGIN LICENSE BLOCK *****
|
||||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||||
*
|
*
|
||||||
@ -93,50 +93,34 @@ nsresult xpcJSWeakReference::Init()
|
|||||||
}
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
xpcJSWeakReference::Get()
|
xpcJSWeakReference::Get(JSContext* aCx, JS::Value* aRetval)
|
||||||
{
|
{
|
||||||
nsresult rv;
|
*aRetval = JSVAL_NULL;
|
||||||
|
|
||||||
nsXPConnect* xpc = nsXPConnect::GetXPConnect();
|
if (!mWrappedJSObject) {
|
||||||
if (!xpc)
|
return NS_OK;
|
||||||
return NS_ERROR_UNEXPECTED;
|
|
||||||
|
|
||||||
nsAXPCNativeCallContext* cc = nsnull;
|
|
||||||
rv = xpc->GetCurrentNativeCallContext(&cc);
|
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
|
||||||
|
|
||||||
JSContext *cx;
|
|
||||||
cc->GetJSContext(&cx);
|
|
||||||
if (!cx)
|
|
||||||
return NS_ERROR_UNEXPECTED;
|
|
||||||
|
|
||||||
jsval *retval = nsnull;
|
|
||||||
cc->GetRetValPtr(&retval);
|
|
||||||
if (!retval)
|
|
||||||
return NS_ERROR_UNEXPECTED;
|
|
||||||
*retval = JSVAL_NULL;
|
|
||||||
|
|
||||||
nsCOMPtr<nsIXPConnectWrappedJS> wrappedObj;
|
|
||||||
|
|
||||||
if (mWrappedJSObject &&
|
|
||||||
NS_SUCCEEDED(mWrappedJSObject->QueryReferent(NS_GET_IID(nsIXPConnectWrappedJS), getter_AddRefs(wrappedObj))) &&
|
|
||||||
wrappedObj) {
|
|
||||||
JSObject *obj;
|
|
||||||
wrappedObj->GetJSObject(&obj);
|
|
||||||
if (obj) {
|
|
||||||
// Most users of XPCWrappedJS don't need to worry about
|
|
||||||
// re-wrapping because things are implicitly rewrapped by
|
|
||||||
// xpcconvert. However, because we're doing this directly
|
|
||||||
// through the native call context, we need to call
|
|
||||||
// JS_WrapObject().
|
|
||||||
|
|
||||||
if (!JS_WrapObject(cx, &obj)) {
|
|
||||||
return NS_ERROR_FAILURE;
|
|
||||||
}
|
|
||||||
|
|
||||||
*retval = OBJECT_TO_JSVAL(obj);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
nsCOMPtr<nsIXPConnectWrappedJS> wrappedObj = do_QueryReferent(mWrappedJSObject);
|
||||||
|
if (!wrappedObj) {
|
||||||
|
return NS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
JSObject *obj;
|
||||||
|
wrappedObj->GetJSObject(&obj);
|
||||||
|
if (!obj) {
|
||||||
|
return NS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Most users of XPCWrappedJS don't need to worry about
|
||||||
|
// re-wrapping because things are implicitly rewrapped by
|
||||||
|
// xpcconvert. However, because we're doing this directly
|
||||||
|
// through the native call context, we need to call
|
||||||
|
// JS_WrapObject().
|
||||||
|
if (!JS_WrapObject(aCx, &obj)) {
|
||||||
|
return NS_ERROR_FAILURE;
|
||||||
|
}
|
||||||
|
|
||||||
|
*aRetval = OBJECT_TO_JSVAL(obj);
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user