Skip to content

Commit 31d15c5

Browse files
committed
in the generate code convert MemorySegment of orderBy function to long because MemorySegment was elemite by the jit
1 parent 27c956b commit 31d15c5

3 files changed

Lines changed: 14 additions & 14 deletions

File tree

src/main/generated/com/github/elebras1/flecs/ecs_order_by_action_t.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,15 +27,15 @@ private ecs_order_by_action_t() {
2727
* The function pointer signature, expressed as a functional interface
2828
*/
2929
public interface Function {
30-
int apply(long e1, MemorySegment ptr1, long e2, MemorySegment ptr2);
30+
int apply(long e1, long ptr1, long e2, long ptr2);
3131
}
3232

3333
private static final FunctionDescriptor $DESC = FunctionDescriptor.of(
3434
flecs_h.C_INT,
3535
flecs_h.C_LONG,
36-
flecs_h.C_POINTER,
3736
flecs_h.C_LONG,
38-
flecs_h.C_POINTER
37+
flecs_h.C_LONG,
38+
flecs_h.C_LONG
3939
);
4040

4141
/**
@@ -60,7 +60,7 @@ public static MemorySegment allocate(ecs_order_by_action_t.Function fi, Arena ar
6060
/**
6161
* Invoke the upcall stub {@code funcPtr}, with given parameters
6262
*/
63-
public static int invoke(MemorySegment funcPtr, long e1, MemorySegment ptr1, long e2, MemorySegment ptr2) {
63+
public static int invoke(MemorySegment funcPtr, long e1, long ptr1, long e2, long ptr2) {
6464
try {
6565
return (int) DOWN$MH.invokeExact(funcPtr, e1, ptr1, e2, ptr2);
6666
} catch (Error | RuntimeException ex) {

src/main/java/com/github/elebras1/flecs/QueryBuilder.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -237,20 +237,20 @@ public QueryBuilder orderBy(long componentId, ComparatorId comparator) {
237237

238238
public <T> QueryBuilder orderBy(long componentId, ComparatorComponent<T> comparator) {
239239
Component<T> component = this.world.componentRegistry().getComponentById(componentId);
240-
MemorySegment callbackStub = ecs_order_by_action_t.allocate((_, componentASeg, _, componentBSeg) ->
241-
comparator.compare(component.read(componentASeg, 0), component.read(componentBSeg, 0)), this.world.arena());
240+
MemorySegment callbackStub = ecs_order_by_action_t.allocate((_, componentAdressA, _, componentAdressB) ->
241+
comparator.compare(component.read(MemorySegment.ofAddress(componentAdressA), 0), component.read(MemorySegment.ofAddress(componentAdressB), 0)), this.world.arena());
242242
ecs_query_desc_t.order_by_callback(this.desc, callbackStub);
243243
return this.orderBy(componentId);
244244
}
245245

246246
@SuppressWarnings("unchecked")
247247
public <V extends ComponentView> QueryBuilder orderBy(long componentId, ComparatorComponentView<V> comparator) {
248248
Class<?> componentClass = this.world.componentRegistry().getComponentClassById(componentId);
249-
MemorySegment callbackStub = ecs_order_by_action_t.allocate((_, componentASeg, _, componentBSeg) -> {
249+
MemorySegment callbackStub = ecs_order_by_action_t.allocate((_, componentAdressA, _, componentAdressB) -> {
250250
V componentViewA = (V) this.world.viewCache().getComponentView(componentClass);
251-
componentViewA.setBaseAddress(componentASeg.address());
251+
componentViewA.setBaseAddress(componentAdressA);
252252
V componentViewB = (V) this.world.viewCache().getComponentView(componentClass);
253-
componentViewB.setBaseAddress(componentBSeg.address());
253+
componentViewB.setBaseAddress(componentAdressB);
254254
return comparator.compare(componentViewA, componentViewB);
255255
}, this.world.arena());
256256
ecs_query_desc_t.order_by_callback(this.desc, callbackStub);

src/main/java/com/github/elebras1/flecs/SystemBuilder.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -275,8 +275,8 @@ public SystemBuilder orderBy(long componentId, ComparatorId comparator) {
275275

276276
public <T> SystemBuilder orderBy(long componentId, ComparatorComponent<T> comparator) {
277277
Component<T> component = this.world.componentRegistry().getComponentById(componentId);
278-
MemorySegment callbackStub = ecs_order_by_action_t.allocate((_, componentASeg, _, componentBSeg) ->
279-
comparator.compare(component.read(componentASeg, 0), component.read(componentBSeg, 0)), this.world.arena());
278+
MemorySegment callbackStub = ecs_order_by_action_t.allocate((_, componentAdressA, _, componentAdressB) ->
279+
comparator.compare(component.read(MemorySegment.ofAddress(componentAdressA), 0), component.read(MemorySegment.ofAddress(componentAdressB), 0)), this.world.arena());
280280

281281
MemorySegment queryDescSeg = ecs_system_desc_t.query(this.desc);
282282
ecs_query_desc_t.order_by_callback(queryDescSeg, callbackStub);
@@ -287,11 +287,11 @@ public <T> SystemBuilder orderBy(long componentId, ComparatorComponent<T> compar
287287
@SuppressWarnings("unchecked")
288288
public <V extends ComponentView> SystemBuilder orderBy(long componentId, ComparatorComponentView<V> comparator) {
289289
Class<?> componentClass = this.world.componentRegistry().getComponentClassById(componentId);
290-
MemorySegment callbackStub = ecs_order_by_action_t.allocate((_, componentASeg, _, componentBSeg) -> {
290+
MemorySegment callbackStub = ecs_order_by_action_t.allocate((_, componentAdressA, _, componentAdressB) -> {
291291
V componentViewA = (V) this.world.viewCache().getComponentView(componentClass);
292-
componentViewA.setBaseAddress(componentASeg.address());
292+
componentViewA.setBaseAddress(componentAdressA);
293293
V componentViewB = (V) this.world.viewCache().getComponentView(componentClass);
294-
componentViewB.setBaseAddress(componentBSeg.address());
294+
componentViewB.setBaseAddress(componentAdressB);
295295
return comparator.compare(componentViewA, componentViewB);
296296
}, this.world.arena());
297297

0 commit comments

Comments
 (0)