Implemented equals and hashCode for NodeList and DOMImplementation
git-svn-id: svn://10.0.0.236/trunk@44423 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
@@ -19,6 +19,95 @@ Inc. All Rights Reserved.
|
||||
#include "javaDOMGlobals.h"
|
||||
#include "org_mozilla_dom_DOMImplementationImpl.h"
|
||||
|
||||
static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
|
||||
|
||||
/*
|
||||
* Class: org_mozilla_dom_DOMImplementationImpl
|
||||
* Method: XPCOM_equals
|
||||
* Signature: (Ljava/lang/Object;)Z
|
||||
*/
|
||||
JNIEXPORT jboolean JNICALL Java_org_mozilla_dom_DOMImplementationImpl_XPCOM_1equals
|
||||
(JNIEnv *env, jobject jthis, jobject jarg)
|
||||
{
|
||||
jboolean b_retFlag = JNI_FALSE;
|
||||
|
||||
nsIDOMDOMImplementation* p_this = (nsIDOMDOMImplementation*)
|
||||
env->GetLongField(jthis, JavaDOMGlobals::domImplementationPtrFID);
|
||||
if (!p_this) {
|
||||
PR_LOG(JavaDOMGlobals::log, PR_LOG_WARNING,
|
||||
("DOMImplementation.equals: NULL pointer\n"));
|
||||
return b_retFlag;
|
||||
}
|
||||
|
||||
nsIDOMDOMImplementation* p_arg = (nsIDOMDOMImplementation*)
|
||||
env->GetLongField(jarg, JavaDOMGlobals::domImplementationPtrFID);
|
||||
if (!p_arg) {
|
||||
PR_LOG(JavaDOMGlobals::log, PR_LOG_WARNING,
|
||||
("DOMImplementation.equals: NULL arg pointer\n"));
|
||||
return b_retFlag;
|
||||
}
|
||||
|
||||
nsISupports* thisSupports = nsnull;
|
||||
nsISupports* argSupports = nsnull;
|
||||
|
||||
nsresult rvThis =
|
||||
p_this->QueryInterface(kISupportsIID, (void**)(&thisSupports));
|
||||
if (NS_FAILED(rvThis) || !thisSupports) {
|
||||
PR_LOG(JavaDOMGlobals::log, PR_LOG_ERROR,
|
||||
("DOMImplementation.equals: this->QueryInterface failed (%x)\n",
|
||||
rvThis));
|
||||
return b_retFlag;
|
||||
}
|
||||
|
||||
nsresult rvArg =
|
||||
p_arg->QueryInterface(kISupportsIID, (void**)(&argSupports));
|
||||
if (NS_FAILED(rvArg) || !argSupports) {
|
||||
PR_LOG(JavaDOMGlobals::log, PR_LOG_ERROR,
|
||||
("DOMImplementation.equals: arg->QueryInterface failed (%x)\n",
|
||||
rvArg));
|
||||
thisSupports->Release();
|
||||
return b_retFlag;
|
||||
}
|
||||
|
||||
if (thisSupports == argSupports)
|
||||
b_retFlag = JNI_TRUE;
|
||||
|
||||
thisSupports->Release();
|
||||
argSupports->Release();
|
||||
|
||||
return b_retFlag;
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: org_mozilla_dom_DOMImplementationImpl
|
||||
* Method: XPCOM_hashCode
|
||||
* Signature: ()I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL Java_org_mozilla_dom_DOMImplementationImpl_XPCOM_1hashCode
|
||||
(JNIEnv *env, jobject jthis)
|
||||
{
|
||||
nsIDOMDOMImplementation* p_this = (nsIDOMDOMImplementation*)
|
||||
env->GetLongField(jthis, JavaDOMGlobals::domImplementationPtrFID);
|
||||
if (!p_this) {
|
||||
PR_LOG(JavaDOMGlobals::log, PR_LOG_WARNING,
|
||||
("DOMImplementation.hashCode: NULL pointer\n"));
|
||||
return (jint) 0;
|
||||
}
|
||||
|
||||
nsISupports* thisSupports = nsnull;
|
||||
nsresult rvThis =
|
||||
p_this->QueryInterface(kISupportsIID, (void**)(&thisSupports));
|
||||
if (NS_FAILED(rvThis) || !thisSupports) {
|
||||
PR_LOG(JavaDOMGlobals::log, PR_LOG_ERROR,
|
||||
("DOMImplementation.hashCode: QueryInterface failed (%x)\n",
|
||||
rvThis));
|
||||
return (jint) 0;
|
||||
}
|
||||
|
||||
thisSupports->Release();
|
||||
return (jint) thisSupports;
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: org_mozilla_dom_DOMImplementationImpl
|
||||
* Method: finalize
|
||||
|
||||
Reference in New Issue
Block a user