33 */
44package volucris .bindings .jolt ;
55
6- import edu .umd .cs .findbugs .annotations .Nullable ;
76import java .lang .foreign .Arena ;
87import java .lang .foreign .FunctionDescriptor ;
98import java .lang .foreign .Linker ;
@@ -46,8 +45,8 @@ public abstract class BodyActivationListener {
4645 CACHE = new HashMap <>();
4746
4847 LAYOUT = MemoryLayout .structLayout (
49- UNBOUNDED_ADDRESS .withName ("onBodyActivated " ),
50- UNBOUNDED_ADDRESS .withName ("onBodyDeactivated " )
48+ UNBOUNDED_ADDRESS .withName ("OnBodyActivated " ),
49+ UNBOUNDED_ADDRESS .withName ("OnBodyDeactivated " )
5150 ).withName ("JPH_BodyActivationListener_Procs" ).withByteAlignment (8 );
5251
5352 JPH_BODY_ACTIVATION_LISTENER_SET_PROCS = downcallHandleVoid ("JPH_BodyActivationListener_SetProcs" , UNBOUNDED_ADDRESS );
@@ -59,32 +58,32 @@ public abstract class BodyActivationListener {
5958
6059 Arena arena = Arena .global ();
6160
62- PROCS = Arena . global () .allocate (LAYOUT );
61+ PROCS = arena .allocate (LAYOUT );
6362
6463 try {
6564 ON_BODY_ACTIVATED_DESCRIPTION = FunctionDescriptor .ofVoid (
66- UNBOUNDED_ADDRESS ,
67- JAVA_INT ,
65+ UNBOUNDED_ADDRESS ,
66+ JAVA_INT ,
6867 JAVA_LONG
6968 );
7069
7170 ON_BODY_ACTIVATED_HANDLE = lookup .findStatic (BodyActivationListener .class , "onBodyActivated" , ON_BODY_ACTIVATED_DESCRIPTION .toMethodType ());
7271
7372 ON_BODY_ACTIVATED_ADDRESS = linker .upcallStub (ON_BODY_ACTIVATED_HANDLE , ON_BODY_ACTIVATED_DESCRIPTION , arena );
7473
75- PROCS .set (UNBOUNDED_ADDRESS , LAYOUT .byteOffset (PathElement .groupElement ("onBodyActivated " )), ON_BODY_ACTIVATED_ADDRESS );
74+ PROCS .set (UNBOUNDED_ADDRESS , LAYOUT .byteOffset (PathElement .groupElement ("OnBodyActivated " )), ON_BODY_ACTIVATED_ADDRESS );
7675
7776 ON_BODY_DEACTIVATED_DESCRIPTION = FunctionDescriptor .ofVoid (
78- UNBOUNDED_ADDRESS ,
79- JAVA_INT ,
77+ UNBOUNDED_ADDRESS ,
78+ JAVA_INT ,
8079 JAVA_LONG
8180 );
8281
8382 ON_BODY_DEACTIVATED_HANDLE = lookup .findStatic (BodyActivationListener .class , "onBodyDeactivated" , ON_BODY_DEACTIVATED_DESCRIPTION .toMethodType ());
8483
8584 ON_BODY_DEACTIVATED_ADDRESS = linker .upcallStub (ON_BODY_DEACTIVATED_HANDLE , ON_BODY_DEACTIVATED_DESCRIPTION , arena );
8685
87- PROCS .set (UNBOUNDED_ADDRESS , LAYOUT .byteOffset (PathElement .groupElement ("onBodyDeactivated " )), ON_BODY_DEACTIVATED_ADDRESS );
86+ PROCS .set (UNBOUNDED_ADDRESS , LAYOUT .byteOffset (PathElement .groupElement ("OnBodyDeactivated " )), ON_BODY_DEACTIVATED_ADDRESS );
8887
8988 } catch (Exception e ) {
9089 throw new RuntimeException (e );
@@ -105,43 +104,46 @@ public BodyActivationListener(Arena arena) {
105104 CACHE .put (identifier .address (), new WeakReference <>(this ));
106105 }
107106
107+
108108 public static void setProcs (
109- MemorySegment procs
109+ MemorySegment procs
110110 ) {
111- MethodHandle method = JPH_BODY_ACTIVATION_LISTENER_SET_PROCS .get ();
112- try {
113- method .invokeExact (
114- procs
115- );
116- } catch (Throwable e ) {
117- throw new RuntimeException (e );
118- }
111+ MethodHandle method = JPH_BODY_ACTIVATION_LISTENER_SET_PROCS .get ();
112+ try {
113+ method .invokeExact (
114+ procs
115+ );
116+ } catch (Throwable e ) {
117+ throw new RuntimeException (e );
118+ }
119119 }
120120
121+
121122 public static MemorySegment create (
122- MemorySegment userData
123+ MemorySegment userData
123124 ) {
124- MethodHandle method = JPH_BODY_ACTIVATION_LISTENER_CREATE .get ();
125- try {
126- return (MemorySegment ) method .invokeExact (
127- userData
128- );
129- } catch (Throwable e ) {
130- throw new RuntimeException (e );
131- }
125+ MethodHandle method = JPH_BODY_ACTIVATION_LISTENER_CREATE .get ();
126+ try {
127+ return (MemorySegment ) method .invokeExact (
128+ userData
129+ );
130+ } catch (Throwable e ) {
131+ throw new RuntimeException (e );
132+ }
132133 }
133134
135+
134136 public static void destroy (
135- MemorySegment listener
137+ MemorySegment listener
136138 ) {
137- MethodHandle method = JPH_BODY_ACTIVATION_LISTENER_DESTROY .get ();
138- try {
139- method .invokeExact (
140- listener
141- );
142- } catch (Throwable e ) {
143- throw new RuntimeException (e );
144- }
139+ MethodHandle method = JPH_BODY_ACTIVATION_LISTENER_DESTROY .get ();
140+ try {
141+ method .invokeExact (
142+ listener
143+ );
144+ } catch (Throwable e ) {
145+ throw new RuntimeException (e );
146+ }
145147 }
146148
147149 public MemorySegment memorySegment () {
@@ -163,11 +165,11 @@ public static void onBodyActivated(
163165 }
164166
165167 public void onBodyActivated (
166- int bodyID ,
168+ int bodyID ,
167169 long bodyUserData
168170 ) {
169171 throw new UnsupportedOperationException (
170- "Override either the typed or raw callback method for onBodyActivated ."
172+ "Override either the typed or raw callback method in BodyActivationListener ."
171173 );
172174 }
173175
@@ -185,11 +187,11 @@ public static void onBodyDeactivated(
185187 }
186188
187189 public void onBodyDeactivated (
188- int bodyID ,
190+ int bodyID ,
189191 long bodyUserData
190192 ) {
191193 throw new UnsupportedOperationException (
192- "Override either the typed or raw callback method for onBodyDeactivated ."
194+ "Override either the typed or raw callback method in BodyActivationListener ."
193195 );
194196 }
195197
0 commit comments