mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-12-02 18:08:58 +00:00
Implemented equals and hashCode for NodeList and DOMImplementation
This commit is contained in:
parent
625eae3670
commit
47e90b1ee0
@ -25,7 +25,21 @@ public class DOMImplementationImpl implements DOMImplementation {
|
||||
// instantiated from JNI only
|
||||
private DOMImplementationImpl() {}
|
||||
|
||||
public boolean equals(Object o) {
|
||||
if (!(o instanceof NodeListImpl))
|
||||
return false;
|
||||
else
|
||||
return (XPCOM_equals(o));
|
||||
}
|
||||
|
||||
public int hashCode(){
|
||||
return XPCOM_hashCode();
|
||||
}
|
||||
|
||||
public native boolean hasFeature(String feature, String version);
|
||||
|
||||
protected native void finalize();
|
||||
|
||||
private native boolean XPCOM_equals(Object o);
|
||||
private native int XPCOM_hashCode();
|
||||
}
|
||||
|
@ -26,8 +26,22 @@ public class NodeListImpl implements NodeList {
|
||||
// instantiated from JNI or Document.createAttribute()
|
||||
private NodeListImpl() {}
|
||||
|
||||
public boolean equals(Object o) {
|
||||
if (!(o instanceof NodeListImpl))
|
||||
return false;
|
||||
else
|
||||
return (XPCOM_equals(o));
|
||||
}
|
||||
|
||||
public int hashCode(){
|
||||
return XPCOM_hashCode();
|
||||
}
|
||||
|
||||
public native int getLength();
|
||||
public native Node item(int index);
|
||||
|
||||
protected native void finalize();
|
||||
|
||||
private native boolean XPCOM_equals(Object o);
|
||||
private native int XPCOM_hashCode();
|
||||
}
|
||||
|
@ -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
|
||||
|
@ -7,6 +7,14 @@
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
/*
|
||||
* Class: org_mozilla_dom_DOMImplementationImpl
|
||||
* Method: hasFeature
|
||||
* Signature: (Ljava/lang/String;Ljava/lang/String;)Z
|
||||
*/
|
||||
JNIEXPORT jboolean JNICALL Java_org_mozilla_dom_DOMImplementationImpl_hasFeature
|
||||
(JNIEnv *, jobject, jstring, jstring);
|
||||
|
||||
/*
|
||||
* Class: org_mozilla_dom_DOMImplementationImpl
|
||||
* Method: finalize
|
||||
@ -17,11 +25,19 @@ JNIEXPORT void JNICALL Java_org_mozilla_dom_DOMImplementationImpl_finalize
|
||||
|
||||
/*
|
||||
* Class: org_mozilla_dom_DOMImplementationImpl
|
||||
* Method: hasFeature
|
||||
* Signature: (Ljava/lang/String;Ljava/lang/String;)Z
|
||||
* Method: XPCOM_equals
|
||||
* Signature: (Ljava/lang/Object;)Z
|
||||
*/
|
||||
JNIEXPORT jboolean JNICALL Java_org_mozilla_dom_DOMImplementationImpl_hasFeature
|
||||
(JNIEnv *, jobject, jstring, jstring);
|
||||
JNIEXPORT jboolean JNICALL Java_org_mozilla_dom_DOMImplementationImpl_XPCOM_1equals
|
||||
(JNIEnv *, jobject, jobject);
|
||||
|
||||
/*
|
||||
* Class: org_mozilla_dom_DOMImplementationImpl
|
||||
* Method: XPCOM_hashCode
|
||||
* Signature: ()I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL Java_org_mozilla_dom_DOMImplementationImpl_XPCOM_1hashCode
|
||||
(JNIEnv *, jobject);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
@ -20,6 +20,92 @@ Inc. All Rights Reserved.
|
||||
#include "javaDOMGlobals.h"
|
||||
#include "org_mozilla_dom_NodeListImpl.h"
|
||||
|
||||
static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
|
||||
|
||||
/*
|
||||
* Class: org_mozilla_dom_NodeListImpl
|
||||
* Method: XPCOM_equals
|
||||
* Signature: (Ljava/lang/Object;)Z
|
||||
*/
|
||||
JNIEXPORT jboolean JNICALL Java_org_mozilla_dom_NodeListImpl_XPCOM_1equals
|
||||
(JNIEnv *env, jobject jthis, jobject jarg)
|
||||
{
|
||||
jboolean b_retFlag = JNI_FALSE;
|
||||
|
||||
nsIDOMNodeList* p_this =
|
||||
(nsIDOMNodeList*) env->GetLongField(jthis, JavaDOMGlobals::nodeListPtrFID);
|
||||
if (!p_this) {
|
||||
PR_LOG(JavaDOMGlobals::log, PR_LOG_WARNING,
|
||||
("NodeList.equals: NULL pointer\n"));
|
||||
return b_retFlag;
|
||||
}
|
||||
|
||||
nsIDOMNodeList* p_arg =
|
||||
(nsIDOMNodeList*) env->GetLongField(jarg, JavaDOMGlobals::nodeListPtrFID);
|
||||
if (!p_arg) {
|
||||
PR_LOG(JavaDOMGlobals::log, PR_LOG_WARNING,
|
||||
("NodeList.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,
|
||||
("NodeList.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,
|
||||
("NodeList.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_NodeListImpl
|
||||
* Method: XPCOM_hashCode
|
||||
* Signature: ()I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL Java_org_mozilla_dom_NodeListImpl_XPCOM_1hashCode
|
||||
(JNIEnv *env, jobject jthis)
|
||||
{
|
||||
nsIDOMNodeList* p_this =
|
||||
(nsIDOMNodeList*) env->GetLongField(jthis, JavaDOMGlobals::nodeListPtrFID);
|
||||
if (!p_this) {
|
||||
PR_LOG(JavaDOMGlobals::log, PR_LOG_WARNING,
|
||||
("NodeList.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,
|
||||
("NodeList.hashCode: QueryInterface failed (%x)\n", rvThis));
|
||||
return (jint) 0;
|
||||
}
|
||||
|
||||
thisSupports->Release();
|
||||
return (jint) thisSupports;
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: org_mozilla_dom_NodeListImpl
|
||||
* Method: finalize
|
||||
|
@ -7,14 +7,6 @@
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
/*
|
||||
* Class: org_mozilla_dom_NodeListImpl
|
||||
* Method: finalize
|
||||
* Signature: ()V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_org_mozilla_dom_NodeListImpl_finalize
|
||||
(JNIEnv *, jobject);
|
||||
|
||||
/*
|
||||
* Class: org_mozilla_dom_NodeListImpl
|
||||
* Method: getLength
|
||||
@ -31,6 +23,30 @@ JNIEXPORT jint JNICALL Java_org_mozilla_dom_NodeListImpl_getLength
|
||||
JNIEXPORT jobject JNICALL Java_org_mozilla_dom_NodeListImpl_item
|
||||
(JNIEnv *, jobject, jint);
|
||||
|
||||
/*
|
||||
* Class: org_mozilla_dom_NodeListImpl
|
||||
* Method: finalize
|
||||
* Signature: ()V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_org_mozilla_dom_NodeListImpl_finalize
|
||||
(JNIEnv *, jobject);
|
||||
|
||||
/*
|
||||
* Class: org_mozilla_dom_NodeListImpl
|
||||
* Method: XPCOM_equals
|
||||
* Signature: (Ljava/lang/Object;)Z
|
||||
*/
|
||||
JNIEXPORT jboolean JNICALL Java_org_mozilla_dom_NodeListImpl_XPCOM_1equals
|
||||
(JNIEnv *, jobject, jobject);
|
||||
|
||||
/*
|
||||
* Class: org_mozilla_dom_NodeListImpl
|
||||
* Method: XPCOM_hashCode
|
||||
* Signature: ()I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL Java_org_mozilla_dom_NodeListImpl_XPCOM_1hashCode
|
||||
(JNIEnv *, jobject);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user