Skip to content

Commit

Permalink
Merge pull request #39 from Over-Run/update-dep
Browse files Browse the repository at this point in the history
Update stuff
  • Loading branch information
squid233 authored Nov 22, 2023
2 parents 9c068e2 + 526c14a commit 792fa25
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 5 deletions.
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ subprojects {
val compileOnly by configurations
val implementation by configurations
dependencies {
compileOnly("org.jetbrains:annotations:24.0.1")
compileOnly("org.jetbrains:annotations:24.1.0")
if (project.name != "core") {
implementation(project(":core"))
}
Expand Down
12 changes: 12 additions & 0 deletions modules/overrungl.core/src/main/java/overrungl/OverrunGL.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,18 @@ public final class OverrunGL {
* The version of OverrunGL.
*/
public static final String VERSION = "0.1.0";
/**
* The version of GLFW native libraries.
*/
public static final String GLFW_VERSION = "3.3.8.0";
/**
* The version of NFD native libraries.
*/
public static final String NFD_VERSION = "0.1.0.0";
/**
* The version of STB native libraries.
*/
public static final String STB_VERSION = "0.1.0.0";
private static final Consumer<String> DEFAULT_LOGGER = System.err::println;
private static Consumer<String> apiLogger = DEFAULT_LOGGER;

Expand Down
17 changes: 17 additions & 0 deletions modules/overrungl.core/src/main/java/overrungl/util/CStdlib.java
Original file line number Diff line number Diff line change
Expand Up @@ -326,4 +326,21 @@ public static MemorySegment memset(MemorySegment dest, int c, long count) {
throw new AssertionError("should not reach here", e);
}
}

/**
* Allocates a string with {@link CStdlib}.
*
* @param s the string.
* @return the memory segment of the allocated string. <b>MUST</b> be released by {@link #free(MemorySegment)}.
*/
public static MemorySegment newString(String s) {
class Holder {
private static final SegmentAllocator ALLOCATOR = (byteSize, byteAlignment) -> {
checkByteSize(byteSize);
checkAlignment(byteAlignment);
return calloc(1, byteSize);
};
}
return Holder.ALLOCATOR.allocateUtf8String(s);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

import overrungl.Configurations;
import overrungl.FunctionDescriptors;
import overrungl.OverrunGL;
import overrungl.internal.RuntimeHelper;

import java.lang.foreign.FunctionDescriptor;
Expand All @@ -40,8 +41,7 @@ final class Handles {
private static final SymbolLookup lookup;

static {
final Supplier<SymbolLookup> lib = () -> RuntimeHelper.load("glfw", "glfw3",
STR. "\{ GLFW.VERSION_MAJOR }.\{ GLFW.VERSION_MINOR }.\{ GLFW.VERSION_REVISION }" );
final Supplier<SymbolLookup> lib = () -> RuntimeHelper.load("glfw", "glfw3", OverrunGL.GLFW_VERSION);
final var function = Configurations.GLFW_SYMBOL_LOOKUP.get();
lookup = function != null ? function.apply(lib) : lib.get();
}
Expand Down
3 changes: 2 additions & 1 deletion modules/overrungl.nfd/src/main/java/overrungl/nfd/NFD.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import overrungl.Configurations;
import overrungl.FunctionDescriptors;
import overrungl.NativeType;
import overrungl.OverrunGL;
import overrungl.internal.RuntimeHelper;
import overrungl.os.Platform;
import overrungl.util.MemoryStack;
Expand Down Expand Up @@ -123,7 +124,7 @@ public final class NFD {
private static final SymbolLookup LOOKUP;

static {
final Supplier<SymbolLookup> lib = () -> RuntimeHelper.load("nfd", "nfd", "0.1.0.0");
final Supplier<SymbolLookup> lib = () -> RuntimeHelper.load("nfd", "nfd", OverrunGL.NFD_VERSION);
final var function = Configurations.NFD_SYMBOL_LOOKUP.get();
LOOKUP = function != null ? function.apply(lib) : lib.get();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

import overrungl.Configurations;
import overrungl.FunctionDescriptors;
import overrungl.OverrunGL;
import overrungl.internal.RuntimeHelper;

import java.lang.foreign.Linker;
Expand All @@ -35,7 +36,7 @@ final class Handles {
private static final SymbolLookup lookup;

static {
final Supplier<SymbolLookup> lib = () -> RuntimeHelper.load("stb", "stb", "0.1.0.0");
final Supplier<SymbolLookup> lib = () -> RuntimeHelper.load("stb", "stb", OverrunGL.STB_VERSION);
final var function = Configurations.STB_SYMBOL_LOOKUP.get();
lookup = function != null ? function.apply(lib) : lib.get();
}
Expand Down

0 comments on commit 792fa25

Please sign in to comment.