From 6b0533faab439aaf9fafe628e95ea3fbef510080 Mon Sep 17 00:00:00 2001
From: squid233 <60126026+squid233@users.noreply.github.com>
Date: Fri, 29 Dec 2023 19:03:16 +0800
Subject: [PATCH] [Core] Renamed CStdlib to MemoryUtil; [GLFW] Updated to GLFW
3.3.9
---
build.gradle.kts | 3 +-
doc/notes/0.x/0.1.0.md | 3 +-
gradle.properties | 2 +
modules/overrungl.core/build.gradle.kts | 5 +
.../src/main/java/module-info.java | 2 +-
.../java/overrungl/FunctionDescriptors.java | 6 +-
.../src/main/java/overrungl/OverrunGL.java | 2 +-
.../overrungl/internal/RuntimeHelper.java | 10 +-
.../main/java/overrungl/os/Architecture.java | 63 ------
.../src/main/java/overrungl/os/Platform.java | 202 ------------------
.../main/java/overrungl/util/CheckUtil.java | 4 +-
.../java/overrungl/util/DebugAllocator.java | 4 +-
.../main/java/overrungl/util/MemoryStack.java | 8 +-
.../util/{CStdlib.java => MemoryUtil.java} | 27 ++-
.../java/overrungl/util/StackWalkUtil.java | 2 +-
modules/overrungl.glfw/build.gradle.kts | 0
.../src/main/java/overrungl/glfw/GLFW.java | 60 ++++--
.../src/main/java/overrungl/joml/Matrixn.java | 22 +-
.../src/main/java/overrungl/joml/Vectorn.java | 20 +-
modules/overrungl.nfd/build.gradle.kts | 5 +
.../src/main/java/module-info.java | 1 +
.../src/main/java/overrungl/nfd/NFD.java | 4 +-
modules/overrungl.stb/build.gradle.kts | 0
.../overrungl/demo/mem/MemoryUtilTest.java | 10 +-
24 files changed, 116 insertions(+), 349 deletions(-)
delete mode 100644 modules/overrungl.core/src/main/java/overrungl/os/Architecture.java
delete mode 100644 modules/overrungl.core/src/main/java/overrungl/os/Platform.java
rename modules/overrungl.core/src/main/java/overrungl/util/{CStdlib.java => MemoryUtil.java} (95%)
delete mode 100644 modules/overrungl.glfw/build.gradle.kts
delete mode 100644 modules/overrungl.stb/build.gradle.kts
diff --git a/build.gradle.kts b/build.gradle.kts
index f6afbbbe..f25c37f6 100644
--- a/build.gradle.kts
+++ b/build.gradle.kts
@@ -17,6 +17,7 @@ val projName: String by project
val projVersion: String by project
val projVcs: String by project
val projBranch: String by project
+val projLicenseYear: String by project
val orgName: String by project
val orgUrl: String by project
val developers: String by project
@@ -269,7 +270,7 @@ allprojects {
)
bottom = "Report a bug or suggest an enhancement
" +
- "Copyright © 2022-2023 Overrun Organization
" +
+ "Copyright © 2022-$projLicenseYear Overrun Organization
" +
"$projVersion"
}
}
diff --git a/doc/notes/0.x/0.1.0.md b/doc/notes/0.x/0.1.0.md
index 628bc076..737df0db 100644
--- a/doc/notes/0.x/0.1.0.md
+++ b/doc/notes/0.x/0.1.0.md
@@ -4,8 +4,9 @@ _Not Released Yet_
This version includes the following features:
-- GLFW 3.3.8
+- GLFW 3.3.9
- OpenGL 1.0 ~ 4.6 functions and constants
+- OpenGL extension functions
- OpenGL Loader
- STB Image, perlin noise, easy font
- C memory function
diff --git a/gradle.properties b/gradle.properties
index 480434e8..b4872f92 100644
--- a/gradle.properties
+++ b/gradle.properties
@@ -7,6 +7,7 @@ projName=overrungl
projVersion=0.1.0-SNAPSHOT
projVcs=Over-Run/overrungl
projBranch=main
+projLicenseYear=2023
# Organization
orgName=Overrun Organization
@@ -18,3 +19,4 @@ jdkEnablePreview=true
kotlinTargetJdkVersion=21
projModules=core, glfw, nfd, joml, opengl, stb
+overrunPlatformVersion=1.0.0
diff --git a/modules/overrungl.core/build.gradle.kts b/modules/overrungl.core/build.gradle.kts
index e69de29b..0a130665 100644
--- a/modules/overrungl.core/build.gradle.kts
+++ b/modules/overrungl.core/build.gradle.kts
@@ -0,0 +1,5 @@
+val overrunPlatformVersion: String by rootProject
+
+dependencies {
+ implementation("io.github.over-run:platform:$overrunPlatformVersion")
+}
diff --git a/modules/overrungl.core/src/main/java/module-info.java b/modules/overrungl.core/src/main/java/module-info.java
index 2b187b9c..67406362 100644
--- a/modules/overrungl.core/src/main/java/module-info.java
+++ b/modules/overrungl.core/src/main/java/module-info.java
@@ -22,7 +22,6 @@
*/
module overrungl.core {
exports overrungl;
- exports overrungl.os;
exports overrungl.util;
exports overrungl.util.value;
exports overrungl.internal
@@ -31,5 +30,6 @@
overrungl.opengl,
overrungl.stb;
+ requires io.github.overrun.platform;
requires static org.jetbrains.annotations;
}
diff --git a/modules/overrungl.core/src/main/java/overrungl/FunctionDescriptors.java b/modules/overrungl.core/src/main/java/overrungl/FunctionDescriptors.java
index 7287b1be..8a8ba594 100644
--- a/modules/overrungl.core/src/main/java/overrungl/FunctionDescriptors.java
+++ b/modules/overrungl.core/src/main/java/overrungl/FunctionDescriptors.java
@@ -17,7 +17,7 @@
package overrungl;
import overrungl.internal.Exceptions;
-import overrungl.util.CStdlib;
+import overrungl.util.MemoryUtil;
import java.lang.foreign.FunctionDescriptor;
import java.lang.foreign.ValueLayout;
@@ -38,7 +38,7 @@
* case 'F' -> JAVA_FLOAT;
* case 'D' -> JAVA_DOUBLE;
* case 'P' -> ADDRESS;
- * case 'p' -> CStdlib.ADDRESS_UNBOUNDED;
+ * case 'p' -> MemoryUtil.ADDRESS_UNBOUNDED;
* default -> throw new IllegalArgumentException();
* }}
*
@@ -123,7 +123,7 @@ public static ValueLayout ofValue(char c) throws IllegalArgumentException {
case 'F' -> JAVA_FLOAT;
case 'D' -> JAVA_DOUBLE;
case 'P' -> ADDRESS;
- case 'p' -> CStdlib.ADDRESS_UNBOUNDED;
+ case 'p' -> MemoryUtil.ADDRESS_UNBOUNDED;
default ->
throw Exceptions.IAE. "Invalid argument c: expected one of B, S, I, J, C, Z, F, D, P or p; got '\{ c }'" ;
};
diff --git a/modules/overrungl.core/src/main/java/overrungl/OverrunGL.java b/modules/overrungl.core/src/main/java/overrungl/OverrunGL.java
index dc117b58..f7a005e0 100644
--- a/modules/overrungl.core/src/main/java/overrungl/OverrunGL.java
+++ b/modules/overrungl.core/src/main/java/overrungl/OverrunGL.java
@@ -33,7 +33,7 @@ public final class OverrunGL {
/**
* The version of GLFW native libraries.
*/
- public static final String GLFW_VERSION = "3.3.8.0";
+ public static final String GLFW_VERSION = "3.3.9.0";
/**
* The version of NFD native libraries.
*/
diff --git a/modules/overrungl.core/src/main/java/overrungl/internal/RuntimeHelper.java b/modules/overrungl.core/src/main/java/overrungl/internal/RuntimeHelper.java
index eae0bdbd..4b3356aa 100644
--- a/modules/overrungl.core/src/main/java/overrungl/internal/RuntimeHelper.java
+++ b/modules/overrungl.core/src/main/java/overrungl/internal/RuntimeHelper.java
@@ -16,11 +16,11 @@
package overrungl.internal;
+import io.github.overrun.platform.Architecture;
+import io.github.overrun.platform.Platform;
import org.jetbrains.annotations.Nullable;
import overrungl.FunctionDescriptors;
-import overrungl.os.Architecture;
-import overrungl.os.Platform;
-import overrungl.util.CStdlib;
+import overrungl.util.MemoryUtil;
import java.io.File;
import java.lang.foreign.*;
@@ -50,7 +50,7 @@ public final class RuntimeHelper {
/**
* An unbounded address layout.
*/
- public static final AddressLayout ADDRESS_UNBOUNDED = CStdlib.ADDRESS_UNBOUNDED;
+ public static final AddressLayout ADDRESS_UNBOUNDED = MemoryUtil.ADDRESS_UNBOUNDED;
private static final StackWalker STACK_WALKER = StackWalker.getInstance(StackWalker.Option.RETAIN_CLASS_REFERENCE);
/**
@@ -194,7 +194,7 @@ public static SymbolLookup load(String module, String basename, String version)
* @param segment the segment.
*/
public static boolean isNullptr(@Nullable MemorySegment segment) {
- return CStdlib.isNullptr(segment);
+ return MemoryUtil.isNullptr(segment);
}
/**
diff --git a/modules/overrungl.core/src/main/java/overrungl/os/Architecture.java b/modules/overrungl.core/src/main/java/overrungl/os/Architecture.java
deleted file mode 100644
index a29af38a..00000000
--- a/modules/overrungl.core/src/main/java/overrungl/os/Architecture.java
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- * MIT License
- *
- * Copyright (c) 2023 Overrun Organization
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in all
- * copies or substantial portions of the Software.
- */
-
-package overrungl.os;
-
-import overrungl.internal.Exceptions;
-
-import java.util.Locale;
-
-/**
- * The architecture of the {@link Platform}.
- *
- * @author squid233
- * @since 0.1.0
- */
-public enum Architecture {
- X64,
- ARM64,
- ARM32;
-
- private final String toStringValue = name().toLowerCase(Locale.ROOT);
-
- /**
- * {@return the current architecture of the current {@linkplain Platform platform}}
- */
- public static Architecture current() {
- class Holder {
- private static final Architecture CURRENT;
-
- static {
- final Platform platform = Platform.current();
- final String arch = System.getProperty("os.arch").toLowerCase(Locale.ROOT);
- CURRENT = switch (platform) {
- case Platform.Linux _ -> arch.startsWith("arm") || arch.startsWith("aarch64") ?
- (arch.contains("64") || arch.startsWith("armv8") ? ARM64 : ARM32) :
- X64;
- case Platform.MacOSX _ -> arch.startsWith("aarch64") ? ARM64 : X64;
- case Platform.Windows _ when arch.contains("64") -> arch.startsWith("aarch64") ? ARM64 : X64;
- default -> throw Exceptions.ISE. "Unrecognized or unsupported architecture: \{ arch }" ;
- };
- }
- }
- return Holder.CURRENT;
- }
-
- @Override
- public String toString() {
- return toStringValue;
- }
-}
diff --git a/modules/overrungl.core/src/main/java/overrungl/os/Platform.java b/modules/overrungl.core/src/main/java/overrungl/os/Platform.java
deleted file mode 100644
index 72183c55..00000000
--- a/modules/overrungl.core/src/main/java/overrungl/os/Platform.java
+++ /dev/null
@@ -1,202 +0,0 @@
-/*
- * MIT License
- *
- * Copyright (c) 2023 Overrun Organization
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in all
- * copies or substantial portions of the Software.
- */
-
-package overrungl.os;
-
-import overrungl.internal.Exceptions;
-
-/**
- * The native platform, identifying the operating system and the architecture.
- *
- * @author squid233
- * @since 0.1.0
- */
-public sealed interface Platform {
- /**
- * {@return the current native platform}
- */
- static Platform current() {
- class Holder {
- private static final Platform CURRENT;
-
- static {
- final String os = System.getProperty("os.name");
- if (os.startsWith("Linux") || os.startsWith("FreeBSD") || os.startsWith("SunOS") || os.startsWith("Unit"))
- CURRENT = Linux.INSTANCE;
- else if (os.startsWith("Mac OS X") || os.startsWith("Darwin"))
- CURRENT = MacOSX.INSTANCE;
- else if (os.startsWith("Windows"))
- CURRENT = Windows.INSTANCE;
- else throw Exceptions.ISE. "Unrecognized or unsupported platform: \{ os }" ;
- }
- }
- return Holder.CURRENT;
- }
-
- /**
- * {@return the family name of this platform}
- */
- String familyName();
-
- /**
- * {@return the suffix of shared library on this platform, including dot}
- */
- String sharedLibrarySuffix();
-
- /**
- * Converts the given library name for this platform.
- *
- * @param libraryName the original library name.
- * @return the processed library name.
- */
- String sharedLibraryName(String libraryName);
-
- /**
- * Linux
- *
- * @author squid233
- * @since 0.1.0
- */
- final class Linux implements Platform {
- private static final Linux INSTANCE = new Linux();
-
- @Override
- public String familyName() {
- return "linux";
- }
-
- @Override
- public String sharedLibrarySuffix() {
- return ".so";
- }
-
- @Override
- public String sharedLibraryName(String libraryName) {
- return Platform.unixSharedLibraryName(libraryName, sharedLibrarySuffix());
- }
-
- @Override
- public String toString() {
- return familyName();
- }
- }
-
- /**
- * Mac OS X
- *
- * @author squid233
- * @since 0.1.0
- */
- final class MacOSX implements Platform {
- private static final MacOSX INSTANCE = new MacOSX();
-
- @Override
- public String familyName() {
- return "macos";
- }
-
- @Override
- public String sharedLibrarySuffix() {
- return ".dylib";
- }
-
- @Override
- public String sharedLibraryName(String libraryName) {
- return Platform.unixSharedLibraryName(libraryName, sharedLibrarySuffix());
- }
-
- @Override
- public String toString() {
- return familyName();
- }
- }
-
- /**
- * Windows
- *
- * @author squid233
- * @since 0.1.0
- */
- final class Windows implements Platform {
- private static final Windows INSTANCE = new Windows();
-
- @Override
- public String familyName() {
- return "windows";
- }
-
- @Override
- public String sharedLibrarySuffix() {
- return ".dll";
- }
-
- @Override
- public String sharedLibraryName(String libraryName) {
- return Platform.withExtension(libraryName, sharedLibrarySuffix());
- }
-
- @Override
- public String toString() {
- return familyName();
- }
- }
-
- private static String unixSharedLibraryName(String libraryName, String suffix) {
- if (libraryName.endsWith(suffix)) {
- return libraryName;
- }
- int pos = libraryName.lastIndexOf('/');
- if (pos >= 0) {
- return STR. "\{ libraryName.substring(0, pos + 1) }lib\{ libraryName.substring(pos + 1) }\{ suffix }" ;
- }
- return STR. "lib\{ libraryName }\{ suffix }" ;
- }
-
- /**
- * Returns a representation of the file path with an alternate extension. If the file path has no extension,
- * then the provided extension is simply concatenated. If the file path has an extension, the extension is
- * stripped and replaced with the provided extension.
- *
- * e.g. with a provided extension of ".bar"
- * foo -> foo.bar
- * foo.baz -> foo.bar
- *
- * @param filePath the file path to transform
- * @param extension the extension to use in the transformed path
- * @return the transformed path
- */
- private static String withExtension(String filePath, String extension) {
- if (filePath.toLowerCase().endsWith(extension)) {
- return filePath;
- }
- return removeExtension(filePath) + extension;
- }
-
- /**
- * Removes the extension (if any) from the file path. If the file path has no extension, then it returns the same string.
- *
- * @return the file path without an extension
- */
- private static String removeExtension(String filePath) {
- int fileNameStart = Math.max(filePath.lastIndexOf('/'), filePath.lastIndexOf('\\'));
- int extensionPos = filePath.lastIndexOf('.');
-
- if (extensionPos > fileNameStart) {
- return filePath.substring(0, extensionPos);
- }
- return filePath;
- }
-}
diff --git a/modules/overrungl.core/src/main/java/overrungl/util/CheckUtil.java b/modules/overrungl.core/src/main/java/overrungl/util/CheckUtil.java
index 7b694e62..41743db4 100644
--- a/modules/overrungl.core/src/main/java/overrungl/util/CheckUtil.java
+++ b/modules/overrungl.core/src/main/java/overrungl/util/CheckUtil.java
@@ -92,7 +92,7 @@ public static void checkNotNullptr(MemorySegment segment) throws IllegalStateExc
* @see #checkNotNullptr(MemorySegment, String)
*/
public static void checkNotNullptr(MemorySegment segment, Supplier
* This is incremented when a bug fix release is made that does not contain any API changes.
*/
- public static final int VERSION_REVISION = 8;
+ public static final int VERSION_REVISION = 9;
/**
* One.
@@ -794,6 +793,9 @@ public final class GLFW {
public static final int EGL_CONTEXT_API = 0x00036002;
public static final int OSMESA_CONTEXT_API = 0x00036003;
+ public static final int WAYLAND_PREFER_LIBDECOR = 0x00038001;
+ public static final int WAYLAND_DISABLE_LIBDECOR = 0x00038002;
+
/**
* The regular arrow cursor.
*/
@@ -839,6 +841,14 @@ public final class GLFW {
*/
public static final int COCOA_CHDIR_RESOURCES = 0x00051001,
COCOA_MENUBAR = 0x00051002;
+ /**
+ * Wayland specific init hint.
+ *
+ * {@link #WAYLAND_LIBDECOR} specifies whether to use libdecor for window decorations where available.
+ * Possible values are {@link #WAYLAND_PREFER_LIBDECOR} and {@link #WAYLAND_DISABLE_LIBDECOR}.
+ * This is ignored on other platforms.
+ */
+ public static final int WAYLAND_LIBDECOR = 0x00053001;
/**
* Don't care value.
@@ -4098,8 +4108,8 @@ public static boolean rawMouseMotionSupported() {
* @param key The key to query, or {@link #KEY_UNKNOWN}.
* @param scancode The scancode of the key to query.
* @return The UTF-8 encoded, layout-specific name of the key, or {@link MemorySegment#NULL NULL}.
- * @glfw.errors Possible errors include {@link #NOT_INITIALIZED} and
- * {@link #PLATFORM_ERROR}.
+ * @glfw.errors Possible errors include {@link #NOT_INITIALIZED}, {@link #INVALID_VALUE},
+ * {@link #INVALID_ENUM} and {@link #PLATFORM_ERROR}.
* @glfw.remark The contents of the returned string may change when a keyboard
* layout change event is received.
* @glfw.pointer_lifetime The returned string is allocated and freed by GLFW. You
@@ -4133,14 +4143,16 @@ public static String getKeyName(int key, int scancode) {
*
* This function returns the platform-specific scancode of the specified key.
*
- * If the key is {@code KEY_UNKNOWN} or does not exist on the keyboard this
- * method will return {@code -1}.
+ * If the specified key token corresponds to a physical key not
+ * supported on the current platform then this method will return {@code -1}.
+ * Calling this function with anything other than a key token will return {@code -1}
+ * and generate a {@link #INVALID_ENUM} error.
*
- * @param key Any named key.
- * @return The platform-specific scancode for the key, or {@code -1} if an
- * error occurred.
- * @glfw.errors Possible errors include {@link #NOT_INITIALIZED},
- * {@link #INVALID_ENUM} and {@link #PLATFORM_ERROR}.
+ * @param key Any key token.
+ * @return The platform-specific scancode for the key, or {@code -1} if the key is
+ * not supported on the current platform
+ * or an error occurred.
+ * @glfw.errors Possible errors include {@link #NOT_INITIALIZED} and {@link #INVALID_ENUM}.
* @glfw.thread_safety This function may be called from any thread.
*/
public static int getKeyScancode(int key) {
@@ -4478,9 +4490,9 @@ public static void setCursor(MemorySegment window, MemorySegment cursor) {
* use the {@link #nsetCharCallback(MemorySegment, MemorySegment) character callback} instead.
*
* When a window loses input focus, it will generate synthetic key release
- * events for all pressed keys. You can tell these events from user-generated
- * events by the fact that the synthetic ones are generated after the focus
- * loss event has been processed, i.e. after the
+ * events for all pressed keys with associated key tokens. You can tell these
+ * events from user-generated events by the fact that the synthetic ones are
+ * generated after the focus loss event has been processed, i.e. after the
* {@link #nsetWindowFocusCallback(MemorySegment, MemorySegment) window focus callback}
* has been called.
*
@@ -5556,12 +5568,16 @@ public static long getTimerFrequency() {
* thread.
*
* This function makes the OpenGL or OpenGL ES context of the specified window
- * current on the calling thread. A context must only be made current on
- * a single thread at a time and each thread can have only a single current
- * context at a time.
+ * current on the calling thread.
+ * It can also detach the current context from
+ * the calling thread without making a new one current by passing in {@code NULL}.
*
- * When moving a context between threads, you must make it non-current on the
- * old thread before making it current on the new one.
+ * A context must only be made current on a single thread at a time and each
+ * thread can have only a single current context at a time. Making a context
+ * current detaches any previously current context on the calling thread.
+ *
+ * When moving a context between threads, you must detach it (make it
+ * non-current) on the old thread before making it current on the new one.
*
* By default, making a context non-current implicitly forces a pipeline flush.
* On machines that support {@code GL_KHR_context_flush_control}, you can control
@@ -5569,12 +5585,16 @@ public static long getTimerFrequency() {
* {@link #CONTEXT_RELEASE_BEHAVIOR}
* hint.
*
- * The specified window must have an OpenGL or OpenGL ES context. Specifying
+ * The specified window must have an OpenGL or OpenGL ES context.
+ * Specifying
* a window without a context will generate a {@link #NO_WINDOW_CONTEXT}
* error.
*
* @param window The window whose context to make current, or {@link MemorySegment#NULL NULL} to
* detach the current context.
+ * @glfw.remark If the previously current context was created via a different
+ * context creation API than the one passed to this function, GLFW will still
+ * detach the previous one from its API before making the new one current.
* @glfw.errors Possible errors include {@link #NOT_INITIALIZED},
* {@link #NO_WINDOW_CONTEXT} and {@link #PLATFORM_ERROR}.
* @glfw.thread_safety This function may be called from any thread.
diff --git a/modules/overrungl.joml/src/main/java/overrungl/joml/Matrixn.java b/modules/overrungl.joml/src/main/java/overrungl/joml/Matrixn.java
index 34d4bb71..e3223f02 100644
--- a/modules/overrungl.joml/src/main/java/overrungl/joml/Matrixn.java
+++ b/modules/overrungl.joml/src/main/java/overrungl/joml/Matrixn.java
@@ -18,7 +18,7 @@
import org.joml.*;
import overrungl.util.MemoryStack;
-import overrungl.util.CStdlib;
+import overrungl.util.MemoryUtil;
import java.lang.foreign.MemoryLayout;
import java.lang.foreign.MemorySegment;
@@ -197,7 +197,7 @@ public static MemorySegment allocate(SegmentAllocator allocator, Matrix4dc mat)
* @return the memory address
*/
public static MemorySegment malloc(Matrix2fc mat) {
- return put(mat, CStdlib.malloc(MAT2F));
+ return put(mat, MemoryUtil.malloc(MAT2F));
}
/**
@@ -207,7 +207,7 @@ public static MemorySegment malloc(Matrix2fc mat) {
* @return the memory address
*/
public static MemorySegment malloc(Matrix2dc mat) {
- return put(mat, CStdlib.malloc(MAT2D));
+ return put(mat, MemoryUtil.malloc(MAT2D));
}
/**
@@ -217,7 +217,7 @@ public static MemorySegment malloc(Matrix2dc mat) {
* @return the memory address
*/
public static MemorySegment malloc(Matrix3x2fc mat) {
- return put(mat, CStdlib.malloc(MAT3X2F));
+ return put(mat, MemoryUtil.malloc(MAT3X2F));
}
/**
@@ -227,7 +227,7 @@ public static MemorySegment malloc(Matrix3x2fc mat) {
* @return the memory address
*/
public static MemorySegment malloc(Matrix3x2dc mat) {
- return put(mat, CStdlib.malloc(MAT3X2D));
+ return put(mat, MemoryUtil.malloc(MAT3X2D));
}
/**
@@ -237,7 +237,7 @@ public static MemorySegment malloc(Matrix3x2dc mat) {
* @return the memory address
*/
public static MemorySegment malloc(Matrix3fc mat) {
- return put(mat, CStdlib.malloc(MAT3F));
+ return put(mat, MemoryUtil.malloc(MAT3F));
}
/**
@@ -247,7 +247,7 @@ public static MemorySegment malloc(Matrix3fc mat) {
* @return the memory address
*/
public static MemorySegment malloc(Matrix3dc mat) {
- return put(mat, CStdlib.malloc(MAT3D));
+ return put(mat, MemoryUtil.malloc(MAT3D));
}
/**
@@ -257,7 +257,7 @@ public static MemorySegment malloc(Matrix3dc mat) {
* @return the memory address
*/
public static MemorySegment malloc(Matrix4x3fc mat) {
- return put(mat, CStdlib.malloc(MAT4X3F));
+ return put(mat, MemoryUtil.malloc(MAT4X3F));
}
/**
@@ -267,7 +267,7 @@ public static MemorySegment malloc(Matrix4x3fc mat) {
* @return the memory address
*/
public static MemorySegment malloc(Matrix4x3dc mat) {
- return put(mat, CStdlib.malloc(MAT4X3D));
+ return put(mat, MemoryUtil.malloc(MAT4X3D));
}
/**
@@ -277,7 +277,7 @@ public static MemorySegment malloc(Matrix4x3dc mat) {
* @return the memory address
*/
public static MemorySegment malloc(Matrix4fc mat) {
- return put(mat, CStdlib.malloc(MAT4F));
+ return put(mat, MemoryUtil.malloc(MAT4F));
}
/**
@@ -287,7 +287,7 @@ public static MemorySegment malloc(Matrix4fc mat) {
* @return the memory address
*/
public static MemorySegment malloc(Matrix4dc mat) {
- return put(mat, CStdlib.malloc(MAT4D));
+ return put(mat, MemoryUtil.malloc(MAT4D));
}
/**
diff --git a/modules/overrungl.joml/src/main/java/overrungl/joml/Vectorn.java b/modules/overrungl.joml/src/main/java/overrungl/joml/Vectorn.java
index 53f597fe..d0406bfc 100644
--- a/modules/overrungl.joml/src/main/java/overrungl/joml/Vectorn.java
+++ b/modules/overrungl.joml/src/main/java/overrungl/joml/Vectorn.java
@@ -18,7 +18,7 @@
import org.joml.*;
import overrungl.util.MemoryStack;
-import overrungl.util.CStdlib;
+import overrungl.util.MemoryUtil;
import java.lang.foreign.MemoryLayout;
import java.lang.foreign.MemorySegment;
@@ -181,7 +181,7 @@ public static MemorySegment allocate(SegmentAllocator allocator, Vector4dc vec)
* @return the memory address
*/
public static MemorySegment malloc(Vector2ic vec) {
- return put(vec, CStdlib.malloc(VEC2I));
+ return put(vec, MemoryUtil.malloc(VEC2I));
}
/**
@@ -191,7 +191,7 @@ public static MemorySegment malloc(Vector2ic vec) {
* @return the memory address
*/
public static MemorySegment malloc(Vector2fc vec) {
- return put(vec, CStdlib.malloc(VEC2F));
+ return put(vec, MemoryUtil.malloc(VEC2F));
}
/**
@@ -201,7 +201,7 @@ public static MemorySegment malloc(Vector2fc vec) {
* @return the memory address
*/
public static MemorySegment malloc(Vector2dc vec) {
- return put(vec, CStdlib.malloc(VEC2D));
+ return put(vec, MemoryUtil.malloc(VEC2D));
}
/**
@@ -211,7 +211,7 @@ public static MemorySegment malloc(Vector2dc vec) {
* @return the memory address
*/
public static MemorySegment malloc(Vector3ic vec) {
- return put(vec, CStdlib.malloc(VEC3I));
+ return put(vec, MemoryUtil.malloc(VEC3I));
}
/**
@@ -221,7 +221,7 @@ public static MemorySegment malloc(Vector3ic vec) {
* @return the memory address
*/
public static MemorySegment malloc(Vector3fc vec) {
- return put(vec, CStdlib.malloc(VEC3F));
+ return put(vec, MemoryUtil.malloc(VEC3F));
}
/**
@@ -231,7 +231,7 @@ public static MemorySegment malloc(Vector3fc vec) {
* @return the memory address
*/
public static MemorySegment malloc(Vector3dc vec) {
- return put(vec, CStdlib.malloc(VEC3D));
+ return put(vec, MemoryUtil.malloc(VEC3D));
}
/**
@@ -241,7 +241,7 @@ public static MemorySegment malloc(Vector3dc vec) {
* @return the memory address
*/
public static MemorySegment malloc(Vector4ic vec) {
- return put(vec, CStdlib.malloc(VEC4I));
+ return put(vec, MemoryUtil.malloc(VEC4I));
}
/**
@@ -251,7 +251,7 @@ public static MemorySegment malloc(Vector4ic vec) {
* @return the memory address
*/
public static MemorySegment malloc(Vector4fc vec) {
- return put(vec, CStdlib.malloc(VEC4F));
+ return put(vec, MemoryUtil.malloc(VEC4F));
}
/**
@@ -261,7 +261,7 @@ public static MemorySegment malloc(Vector4fc vec) {
* @return the memory address
*/
public static MemorySegment malloc(Vector4dc vec) {
- return put(vec, CStdlib.malloc(VEC4D));
+ return put(vec, MemoryUtil.malloc(VEC4D));
}
/**
diff --git a/modules/overrungl.nfd/build.gradle.kts b/modules/overrungl.nfd/build.gradle.kts
index e69de29b..0a130665 100644
--- a/modules/overrungl.nfd/build.gradle.kts
+++ b/modules/overrungl.nfd/build.gradle.kts
@@ -0,0 +1,5 @@
+val overrunPlatformVersion: String by rootProject
+
+dependencies {
+ implementation("io.github.over-run:platform:$overrunPlatformVersion")
+}
diff --git a/modules/overrungl.nfd/src/main/java/module-info.java b/modules/overrungl.nfd/src/main/java/module-info.java
index 26166dd6..15bfe095 100644
--- a/modules/overrungl.nfd/src/main/java/module-info.java
+++ b/modules/overrungl.nfd/src/main/java/module-info.java
@@ -24,5 +24,6 @@
exports overrungl.nfd;
requires overrungl.core;
+ requires io.github.overrun.platform;
requires static org.jetbrains.annotations;
}
diff --git a/modules/overrungl.nfd/src/main/java/overrungl/nfd/NFD.java b/modules/overrungl.nfd/src/main/java/overrungl/nfd/NFD.java
index cc0d0182..0b111880 100644
--- a/modules/overrungl.nfd/src/main/java/overrungl/nfd/NFD.java
+++ b/modules/overrungl.nfd/src/main/java/overrungl/nfd/NFD.java
@@ -16,12 +16,12 @@
package overrungl.nfd;
+import io.github.overrun.platform.Platform;
import overrungl.Configurations;
import overrungl.FunctionDescriptors;
import overrungl.NativeType;
import overrungl.OverrunGL;
import overrungl.internal.RuntimeHelper;
-import overrungl.os.Platform;
import overrungl.util.MemoryStack;
import overrungl.util.value.Tuple2;
@@ -131,7 +131,7 @@ public final class NFD {
private static final Platform os = Platform.current();
private static final boolean isOsWin = os instanceof Platform.Windows;
- private static final boolean isOsWinOrApple = isOsWin || os instanceof Platform.MacOSX;
+ private static final boolean isOsWinOrApple = isOsWin || os instanceof Platform.MacOS;
/**
* The type of the path-set size ({@code long} for Windows and Mac OS X, {@code int} for others).
*/
diff --git a/modules/overrungl.stb/build.gradle.kts b/modules/overrungl.stb/build.gradle.kts
deleted file mode 100644
index e69de29b..00000000
diff --git a/modules/samples/src/jmh/java/overrungl/demo/mem/MemoryUtilTest.java b/modules/samples/src/jmh/java/overrungl/demo/mem/MemoryUtilTest.java
index a6ea1303..d518eff7 100644
--- a/modules/samples/src/jmh/java/overrungl/demo/mem/MemoryUtilTest.java
+++ b/modules/samples/src/jmh/java/overrungl/demo/mem/MemoryUtilTest.java
@@ -25,7 +25,7 @@
import org.openjdk.jmh.runner.Runner;
import org.openjdk.jmh.runner.RunnerException;
import org.openjdk.jmh.runner.options.OptionsBuilder;
-import overrungl.util.CStdlib;
+import overrungl.util.MemoryUtil;
/**
* Tests memory util
@@ -66,10 +66,10 @@ public MemorySegment testArenaOutside() {
public MemorySegment memoryUtilMalloc() {
MemorySegment seg = null;
try {
- seg = CStdlib.malloc(size);
+ seg = MemoryUtil.malloc(size);
return seg;
} finally {
- CStdlib.free(seg);
+ MemoryUtil.free(seg);
}
}
@@ -77,10 +77,10 @@ public MemorySegment memoryUtilMalloc() {
public MemorySegment memoryUtilCalloc() {
MemorySegment seg = null;
try {
- seg = CStdlib.calloc(1, size);
+ seg = MemoryUtil.calloc(1, size);
return seg;
} finally {
- CStdlib.free(seg);
+ MemoryUtil.free(seg);
}
}