Skip to content

Commit

Permalink
Replace overrun.marshal.MemoryStack with io.github.overrun.memstack.M…
Browse files Browse the repository at this point in the history
…emoryStack
  • Loading branch information
squid233 committed Aug 29, 2024
1 parent 2e33658 commit b8762e2
Show file tree
Hide file tree
Showing 30 changed files with 328 additions and 537 deletions.
2 changes: 2 additions & 0 deletions modules/overrungl.core/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ val targetJavaVersion = jdkVersion.toInt()
dependencies {
api("io.github.over-run:marshal:$overrunMarshalVersion")
api("io.github.over-run:platform:$overrunPlatformVersion")
//TODO
api("io.github.over-run:memstack:0.2.0")
}

tasks.register("assembleJavadocArgs") {
Expand Down
1 change: 1 addition & 0 deletions modules/overrungl.core/src/main/java/module-info.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
overrungl.vulkan;

requires transitive io.github.overrun.marshal;
requires transitive io.github.overrun.memstack;
requires transitive io.github.overrun.platform;
requires static org.jetbrains.annotations;
}
1 change: 1 addition & 0 deletions modules/overrungl.glfw/src/main/java/module-info.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,5 @@

requires transitive overrungl.core;
requires static org.jetbrains.annotations;
requires io.github.overrun.memstack;
}
106 changes: 53 additions & 53 deletions modules/overrungl.glfw/src/main/java/overrungl/glfw/GLFW.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@

package overrungl.glfw;

import io.github.overrun.memstack.MemoryStack;
import org.jetbrains.annotations.Nullable;
import overrun.marshal.DirectAccess;
import overrun.marshal.Downcall;
import overrun.marshal.MemoryStack;
import overrun.marshal.Unmarshal;
import overrun.marshal.gen.*;
import overrungl.internal.RuntimeHelper;
Expand Down Expand Up @@ -1360,10 +1360,10 @@ static String getPlatformString(int platformCode) {
*/
@Skip
default Triplet.OfInt getVersion() {
try (MemoryStack stack = MemoryStack.stackPush()) {
var pMajor = stack.ints(0);
var pMinor = stack.ints(0);
var pRev = stack.ints(0);
try (MemoryStack stack = MemoryStack.pushLocal()) {
var pMajor = stack.allocate(JAVA_INT);
var pMinor = stack.allocate(JAVA_INT);
var pRev = stack.allocate(JAVA_INT);
ngetVersion(pMajor, pMinor, pRev);
return new Triplet.OfInt(pMajor.get(JAVA_INT, 0),
pMinor.get(JAVA_INT, 0),
Expand Down Expand Up @@ -1448,7 +1448,7 @@ default Triplet.OfInt getVersion() {
*/
@Skip
default Tuple2.OfObjInt<String> getError() {
try (MemoryStack stack = MemoryStack.stackPush()) {
try (MemoryStack stack = MemoryStack.pushLocal()) {
final MemorySegment seg = stack.allocate(ADDRESS);
final int err = ngetError(seg);
return new Tuple2.OfObjInt<>(Unmarshal.unmarshalStringPointer(seg), err);
Expand Down Expand Up @@ -1561,8 +1561,8 @@ default MemorySegment setErrorCallback(@Nullable GLFWErrorFun callback) {
*/
@Skip
default MemorySegment @Nullable [] getMonitors() {
try (MemoryStack stack = MemoryStack.stackPush()) {
var pCount = stack.ints(0);
try (MemoryStack stack = MemoryStack.pushLocal()) {
var pCount = stack.allocate(JAVA_INT);
var pMonitors = ngetMonitors(pCount);
return Unmarshal.unmarshalAsAddressArray(pMonitors.reinterpret(ADDRESS.scale(0L, pCount.get(JAVA_INT, 0L))));
}
Expand Down Expand Up @@ -1624,9 +1624,9 @@ default MemorySegment setErrorCallback(@Nullable GLFWErrorFun callback) {
*/
@Skip
default Pair.OfInt getMonitorPos(MemorySegment monitor) {
try (MemoryStack stack = MemoryStack.stackPush()) {
var px = stack.ints(0);
var py = stack.ints(0);
try (MemoryStack stack = MemoryStack.pushLocal()) {
var px = stack.allocate(JAVA_INT);
var py = stack.allocate(JAVA_INT);
ngetMonitorPos(monitor, px, py);
return new Pair.OfInt(px.get(JAVA_INT, 0), py.get(JAVA_INT, 0));
}
Expand Down Expand Up @@ -1679,11 +1679,11 @@ default Pair.OfInt getMonitorPos(MemorySegment monitor) {
*/
@Skip
default Quad.OfInt getMonitorWorkarea(MemorySegment monitor) {
try (MemoryStack stack = MemoryStack.stackPush()) {
var px = stack.ints(0);
var py = stack.ints(0);
var pw = stack.ints(0);
var ph = stack.ints(0);
try (MemoryStack stack = MemoryStack.pushLocal()) {
var px = stack.allocate(JAVA_INT);
var py = stack.allocate(JAVA_INT);
var pw = stack.allocate(JAVA_INT);
var ph = stack.allocate(JAVA_INT);
ngetMonitorWorkarea(monitor, px, py, pw, ph);
return new Quad.OfInt(px.get(JAVA_INT, 0),
py.get(JAVA_INT, 0),
Expand Down Expand Up @@ -1741,9 +1741,9 @@ default Quad.OfInt getMonitorWorkarea(MemorySegment monitor) {
*/
@Skip
default Pair.OfInt getMonitorPhysicalSize(MemorySegment monitor) {
try (MemoryStack stack = MemoryStack.stackPush()) {
var pw = stack.ints(0);
var ph = stack.ints(0);
try (MemoryStack stack = MemoryStack.pushLocal()) {
var pw = stack.allocate(JAVA_INT);
var ph = stack.allocate(JAVA_INT);
ngetMonitorPhysicalSize(monitor, pw, ph);
return new Pair.OfInt(pw.get(JAVA_INT, 0), ph.get(JAVA_INT, 0));
}
Expand Down Expand Up @@ -1797,9 +1797,9 @@ default Pair.OfInt getMonitorPhysicalSize(MemorySegment monitor) {
*/
@Skip
default Pair.OfFloat getMonitorContentScale(MemorySegment monitor) {
try (MemoryStack stack = MemoryStack.stackPush()) {
var px = stack.floats(0F);
var py = stack.floats(0F);
try (MemoryStack stack = MemoryStack.pushLocal()) {
var px = stack.allocate(JAVA_FLOAT);
var py = stack.allocate(JAVA_FLOAT);
ngetMonitorContentScale(monitor, px, py);
return new Pair.OfFloat(px.get(JAVA_FLOAT, 0), py.get(JAVA_FLOAT, 0));
}
Expand Down Expand Up @@ -1945,8 +1945,8 @@ default MemorySegment setMonitorCallback(@Nullable GLFWMonitorFun callback) {
*/
@Skip
default @Nullable GLFWVidMode getVideoModes(MemorySegment monitor) {
try (MemoryStack stack = MemoryStack.stackPush()) {
var pCount = stack.ints(0);
try (MemoryStack stack = MemoryStack.pushLocal()) {
var pCount = stack.allocate(JAVA_INT);
var pModes = ngetVideoModes(monitor, pCount);
if (Unmarshal.isNullPointer(pModes)) {
return null;
Expand Down Expand Up @@ -2596,9 +2596,9 @@ default void setWindowIcon(MemorySegment window, @Nullable GLFWImage images) {
*/
@Skip
default Pair.OfInt getWindowPos(MemorySegment window) {
try (MemoryStack stack = MemoryStack.stackPush()) {
var px = stack.ints(0);
var py = stack.ints(0);
try (MemoryStack stack = MemoryStack.pushLocal()) {
var px = stack.allocate(JAVA_INT);
var py = stack.allocate(JAVA_INT);
ngetWindowPos(window, px, py);
return new Pair.OfInt(px.get(JAVA_INT, 0), py.get(JAVA_INT, 0));
}
Expand Down Expand Up @@ -2677,9 +2677,9 @@ default Pair.OfInt getWindowPos(MemorySegment window) {
*/
@Skip
default Pair.OfInt getWindowSize(MemorySegment window) {
try (MemoryStack stack = MemoryStack.stackPush()) {
var pw = stack.ints(0);
var ph = stack.ints(0);
try (MemoryStack stack = MemoryStack.pushLocal()) {
var pw = stack.allocate(JAVA_INT);
var ph = stack.allocate(JAVA_INT);
ngetWindowSize(window, pw, ph);
return new Pair.OfInt(pw.get(JAVA_INT, 0), ph.get(JAVA_INT, 0));
}
Expand Down Expand Up @@ -2834,9 +2834,9 @@ default Pair.OfInt getWindowSize(MemorySegment window) {
*/
@Skip
default Pair.OfInt getFramebufferSize(MemorySegment window) {
try (MemoryStack stack = MemoryStack.stackPush()) {
var pw = stack.ints(0);
var ph = stack.ints(0);
try (MemoryStack stack = MemoryStack.pushLocal()) {
var pw = stack.allocate(JAVA_INT);
var ph = stack.allocate(JAVA_INT);
ngetFramebufferSize(window, pw, ph);
return new Pair.OfInt(pw.get(JAVA_INT, 0), ph.get(JAVA_INT, 0));
}
Expand Down Expand Up @@ -2901,11 +2901,11 @@ default Pair.OfInt getFramebufferSize(MemorySegment window) {
*/
@Skip
default Quad.OfInt getWindowFrameSize(MemorySegment window) {
try (MemoryStack stack = MemoryStack.stackPush()) {
var pl = stack.ints(0);
var pt = stack.ints(0);
var pr = stack.ints(0);
var pb = stack.ints(0);
try (MemoryStack stack = MemoryStack.pushLocal()) {
var pl = stack.allocate(JAVA_INT);
var pt = stack.allocate(JAVA_INT);
var pr = stack.allocate(JAVA_INT);
var pb = stack.allocate(JAVA_INT);
ngetWindowFrameSize(window, pl, pt, pr, pb);
return new Quad.OfInt(pl.get(JAVA_INT, 0),
pt.get(JAVA_INT, 0),
Expand Down Expand Up @@ -2961,9 +2961,9 @@ default Quad.OfInt getWindowFrameSize(MemorySegment window) {
*/
@Skip
default Pair.OfFloat getWindowContentScale(MemorySegment window) {
try (MemoryStack stack = MemoryStack.stackPush()) {
var px = stack.floats(0F);
var py = stack.floats(0F);
try (MemoryStack stack = MemoryStack.pushLocal()) {
var px = stack.allocate(JAVA_FLOAT);
var py = stack.allocate(JAVA_FLOAT);
ngetWindowContentScale(window, px, py);
return new Pair.OfFloat(px.get(JAVA_FLOAT, 0), py.get(JAVA_FLOAT, 0));
}
Expand Down Expand Up @@ -4113,9 +4113,9 @@ default MemorySegment setWindowContentScaleCallback(MemorySegment window, @Nulla
*/
@Skip
default Pair.OfDouble getCursorPos(MemorySegment window) {
try (MemoryStack stack = MemoryStack.stackPush()) {
var px = stack.doubles(0D);
var py = stack.doubles(0D);
try (MemoryStack stack = MemoryStack.pushLocal()) {
var px = stack.allocate(JAVA_DOUBLE);
var py = stack.allocate(JAVA_DOUBLE);
ngetCursorPos(window, px, py);
return new Pair.OfDouble(px.get(JAVA_DOUBLE, 0), py.get(JAVA_DOUBLE, 0));
}
Expand Down Expand Up @@ -4635,8 +4635,8 @@ default MemorySegment setDropCallback(MemorySegment window, @Nullable GLFWDropFu
*/
@Skip
default float @Nullable [] getJoystickAxes(int jid) {
try (MemoryStack stack = MemoryStack.stackPush()) {
var pCount = stack.ints(0);
try (MemoryStack stack = MemoryStack.pushLocal()) {
var pCount = stack.allocate(JAVA_INT);
MemorySegment pAxes = ngetJoystickAxes(jid, pCount);
final int count = pCount.get(JAVA_INT, 0);
if (count == 0) return null;
Expand Down Expand Up @@ -4687,8 +4687,8 @@ default MemorySegment setDropCallback(MemorySegment window, @Nullable GLFWDropFu
*/
@Skip
default int @Nullable [] getJoystickButtons(int jid) {
try (MemoryStack stack = MemoryStack.stackPush()) {
var pCount = stack.ints(0);
try (MemoryStack stack = MemoryStack.pushLocal()) {
var pCount = stack.allocate(JAVA_INT);
MemorySegment pButtons = ngetJoystickButtons(jid, pCount);
final int count = pCount.get(JAVA_INT, 0);
if (count == 0) return null;
Expand Down Expand Up @@ -4755,8 +4755,8 @@ default MemorySegment setDropCallback(MemorySegment window, @Nullable GLFWDropFu
*/
@Skip
default byte[] getJoystickHats(int jid) {
try (MemoryStack stack = MemoryStack.stackPush()) {
var pCount = stack.ints(0);
try (MemoryStack stack = MemoryStack.pushLocal()) {
var pCount = stack.allocate(JAVA_INT);
var pHats = ngetJoystickHats(jid, pCount);
return Unmarshal.unmarshalAsByteArray(pHats.reinterpret(JAVA_BYTE.scale(0L, pCount.get(JAVA_INT, 0))));
}
Expand Down Expand Up @@ -5122,7 +5122,7 @@ default void nsetClipboardString(MemorySegment string) {
*/
@Skip
default void setClipboardString(String string) {
try (MemoryStack stack = MemoryStack.stackPush()) {
try (MemoryStack stack = MemoryStack.pushLocal()) {
nsetClipboardString(stack.allocateFrom(string));
}
}
Expand Down Expand Up @@ -5545,8 +5545,8 @@ default String getClipboardString() {
*/
@Skip
default String @Nullable [] getRequiredInstanceExtensions() {
try (MemoryStack stack = MemoryStack.stackPush()) {
var pCount = stack.ints(0);
try (MemoryStack stack = MemoryStack.pushLocal()) {
var pCount = stack.allocate(JAVA_INT);
MemorySegment pExt = ngetRequiredInstanceExtensions(pCount);
final int count = pCount.get(JAVA_INT, 0);
if (count == 0) return null;
Expand Down
1 change: 1 addition & 0 deletions modules/overrungl.joml/src/main/java/module-info.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,5 @@

requires transitive overrungl.core;
requires transitive org.joml;
requires io.github.overrun.memstack;
}
Loading

0 comments on commit b8762e2

Please sign in to comment.