Skip to content

Commit 7818034

Browse files
committed
feat: Upgrade to optimized jnigen 3.1-SNAPSHOT
1 parent c4c5ae7 commit 7818034

File tree

80 files changed

+5096
-2069
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

80 files changed

+5096
-2069
lines changed

build.gradle.kts

+5-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import kotlin.io.path.createTempDirectory
55

66
plugins {
77
id("java-library")
8-
id("com.badlogicgames.jnigen.jnigen-gradle") version "3.0.0"
8+
id("com.badlogicgames.jnigen.jnigen-gradle") version "3.0.1-SNAPSHOT"
99
}
1010

1111
val isReleaseBuild: Boolean
@@ -189,6 +189,10 @@ jnigen {
189189
addMac(x64, x86)
190190

191191
addAndroid {
192+
// TODO: TEMP fix for compiling for x86, fix later
193+
cFlags += arrayOf("-malign-double")
194+
cppFlags += arrayOf("-malign-double")
195+
192196
libraries = arrayOf()
193197
androidApplicationMk += arrayOf("APP_PLATFORM := android-21",
194198
"APP_STRIP_MODE := none",

gdx-box2d-utils/src/main/java/com/badlogic/gdx/box2d/utils/Box2dDebugRenderer.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
import com.badlogic.gdx.graphics.Color;
99
import com.badlogic.gdx.graphics.glutils.ShapeRenderer;
1010
import com.badlogic.gdx.jnigen.runtime.closure.ClosureObject;
11-
import com.badlogic.gdx.jnigen.runtime.pointer.CSizedIntPointer;
1211
import com.badlogic.gdx.jnigen.runtime.pointer.VoidPointer;
12+
import com.badlogic.gdx.jnigen.runtime.pointer.integer.BytePointer;
1313
import com.badlogic.gdx.math.Matrix4;
1414
import com.badlogic.gdx.utils.Disposable;
1515

@@ -141,7 +141,7 @@ private void drawPoint(b2Vec2 p, float size, b2HexColor color, VoidPointer conte
141141
renderer.circle(p.x(), p.y(), size);
142142
}
143143

144-
private void drawString(b2Vec2 p, CSizedIntPointer s, b2HexColor color, VoidPointer context) {
144+
private void drawString(b2Vec2 p, BytePointer s, b2HexColor color, VoidPointer context) {
145145
// TODO: Implement
146146
}
147147

gdx-box2d-utils/src/main/java/com/badlogic/gdx/box2d/utils/Box2dWorldTaskSystem.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ private Box2dWorldTaskSystem(int numWorkers, Box2dWorldTaskSystemDeathHandler de
103103
start = end;
104104
}
105105

106-
VoidPointer taskIndex = new VoidPointer(taskCount + 1, false);
106+
VoidPointer taskIndex = new VoidPointer((long) taskCount + 1, false);
107107
taskCount++;
108108
return taskIndex;
109109
} else {

gradle.properties

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
group=com.badlogicgames.gdx
22
version=0.1
33

4-
jnigen.version=3.0.0
4+
jnigen.version=3.0.1-SNAPSHOT
55
gdx.version=1.13.1
66

77
POM_NAME=gdx-box2d

src/main/java/com/badlogic/gdx/box2d/Box2d.java

+472-475
Large diffs are not rendered by default.

src/main/java/com/badlogic/gdx/box2d/Box2d_Internal.java

+155-165
Large diffs are not rendered by default.

src/main/java/com/badlogic/gdx/box2d/FFITypes.java

+2,369-95
Large diffs are not rendered by default.

src/main/java/com/badlogic/gdx/box2d/enums/b2BodyType.java

+34-11
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import com.badlogic.gdx.jnigen.runtime.pointer.EnumPointer;
44
import com.badlogic.gdx.jnigen.runtime.c.CEnum;
5+
import com.badlogic.gdx.jnigen.runtime.CHandler;
56

67
/**
78
* The body simulation type.
@@ -27,6 +28,8 @@ public enum b2BodyType implements CEnum {
2728
*/
2829
b2_bodyTypeCount(3);
2930

31+
private static final int __size = 4;
32+
3033
private final int index;
3134

3235
b2BodyType(int index) {
@@ -37,33 +40,53 @@ public int getIndex() {
3740
return index;
3841
}
3942

40-
public static b2BodyType getByIndex(int index) {
41-
return _values[index];
43+
public int getSize() {
44+
return __size;
4245
}
4346

44-
private final static b2BodyType[] _values = { b2_staticBody, b2_kinematicBody, b2_dynamicBody, b2_bodyTypeCount };
47+
public static b2BodyType getByIndex(int index) {
48+
switch(index) {
49+
case 0:
50+
return b2_staticBody;
51+
case 1:
52+
return b2_kinematicBody;
53+
case 2:
54+
return b2_dynamicBody;
55+
case 3:
56+
return b2_bodyTypeCount;
57+
default:
58+
throw new IllegalArgumentException("Index " + index + " does not exist.");
59+
}
60+
}
4561

4662
public static final class b2BodyTypePointer extends EnumPointer<b2BodyType> {
4763

4864
public b2BodyTypePointer(long pointer, boolean freeOnGC) {
4965
super(pointer, freeOnGC);
5066
}
5167

68+
public b2BodyTypePointer(long pointer, boolean freeOnGC, int capacity) {
69+
super(pointer, freeOnGC, capacity * __size);
70+
}
71+
5272
public b2BodyTypePointer() {
53-
this(1, true, true);
73+
this(1, true);
74+
}
75+
76+
public b2BodyTypePointer(int count, boolean freeOnGC) {
77+
super(count * __size, freeOnGC);
5478
}
5579

56-
public b2BodyTypePointer(int count, boolean freeOnGC, boolean guard) {
57-
super(count, freeOnGC, guard);
80+
public b2BodyType getEnumValue(int index) {
81+
return getByIndex((int) getBufPtr().getUInt(index * __size));
5882
}
5983

60-
public b2BodyType.b2BodyTypePointer guardCount(long count) {
61-
super.guardCount(count);
62-
return this;
84+
public void setEnumValue(b2BodyType value, int index) {
85+
getBufPtr().setUInt(index * __size, value.getIndex());
6386
}
6487

65-
protected b2BodyType getEnum(int index) {
66-
return getByIndex(index);
88+
public int getSize() {
89+
return __size;
6790
}
6891
}
6992
}

0 commit comments

Comments
 (0)