aboutsummaryrefslogtreecommitdiffstats
path: root/src/java
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2023-08-04 11:13:33 +0200
committerSven Gothel <[email protected]>2023-08-04 11:13:33 +0200
commit3ad38748d7ef50a3631506eabcd3ae3417faa84d (patch)
treefac3ea1f1ff1a68c90df0076088908e196908489 /src/java
parent1250d960d8bf2ee9ab8726a18a837115d6930815 (diff)
JavaCallbackEmitter.emitJavaKeyClass(): Use directBufferAddress for compound types in equals and hashCode, i.e. use memory identitypulled
Use case is having a compound-type as userParam, which also acts as key, see MessageCallback13, Test4JavaCallback.chapter13(). The Java compound instance is re-created using the actual identical native memory (address), which has been stored or passed in the native toolkit.
Diffstat (limited to 'src/java')
-rw-r--r--src/java/com/jogamp/gluegen/JavaCallbackEmitter.java6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/java/com/jogamp/gluegen/JavaCallbackEmitter.java b/src/java/com/jogamp/gluegen/JavaCallbackEmitter.java
index 5e83016..01ffe8f 100644
--- a/src/java/com/jogamp/gluegen/JavaCallbackEmitter.java
+++ b/src/java/com/jogamp/gluegen/JavaCallbackEmitter.java
@@ -386,7 +386,9 @@ public final class JavaCallbackEmitter {
unit.emitln(" &&");
unit.emit (" ");
}
- if( jType.isPrimitive() || idx == info.setFuncUserParamIdx ) {
+ if( jType.isCompoundTypeWrapper() ) {
+ unit.emit(name+".getDirectBufferAddress() == o2."+name+".getDirectBufferAddress()");
+ } else if( jType.isPrimitive() || idx == info.setFuncUserParamIdx ) {
unit.emit(name+" == o2."+name);
} else {
unit.emit(name+".equals( o2."+name+" )");
@@ -419,6 +421,8 @@ public final class JavaCallbackEmitter {
} else {
unit.emitln(name+";");
}
+ } else if( jType.isCompoundTypeWrapper() ) {
+ unit.emitln("HashUtil.getAddrHash32_EqualDist( "+name+".getDirectBufferAddress() );");
} else {
if( idx == info.setFuncUserParamIdx ) {
unit.emitln("System.identityHashCode( "+name+" );");