-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Load NativeApi instances using services (#4)
- Loading branch information
1 parent
d78ad8f
commit 8ab70c3
Showing
31 changed files
with
522 additions
and
520 deletions.
There are no files selected for viewing
48 changes: 48 additions & 0 deletions
48
...tils-bootstrap/src/main/java/coursier/bootstrap/launcher/jniutils/BootstrapNativeApi.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
package coursier.bootstrap.launcher.jniutils; | ||
|
||
import coursier.jniutils.LoadWindowsLibrary; | ||
import coursier.jniutils.NativeApi; | ||
|
||
public final class BootstrapNativeApi extends NativeApi { | ||
|
||
static native String terminalSizeNative(); | ||
|
||
static native String enableAnsiOutputNative(); | ||
|
||
static native byte[] GetUserEnvironmentVariableNative(byte[] key); | ||
static native byte[] SetUserEnvironmentVariableNative(byte[] key, byte[] value); | ||
static native byte[] DeleteUserEnvironmentVariableNative(byte[] key); | ||
|
||
static native String GetKnownFolderPathNative(String rfid); | ||
|
||
|
||
public String terminalSize() { | ||
return terminalSizeNative(); | ||
} | ||
|
||
public String enableAnsiOutput() { | ||
return enableAnsiOutputNative(); | ||
} | ||
|
||
public byte[] GetUserEnvironmentVariable(byte[] key) { | ||
return GetUserEnvironmentVariableNative(key); | ||
} | ||
public byte[] SetUserEnvironmentVariable(byte[] key, byte[] value) { | ||
return SetUserEnvironmentVariableNative(key, value); | ||
} | ||
public byte[] DeleteUserEnvironmentVariable(byte[] key) { | ||
return DeleteUserEnvironmentVariableNative(key); | ||
} | ||
|
||
public String GetKnownFolderPath(String rfid) { | ||
return GetKnownFolderPathNative(rfid); | ||
} | ||
|
||
static { | ||
LoadWindowsLibrary.ensureInitialized(); | ||
} | ||
|
||
public static void setup() { | ||
NativeApi.set(new BootstrapNativeApi()); | ||
} | ||
} |
46 changes: 0 additions & 46 deletions
46
...s-jni-utils-bootstrap/src/main/java/coursier/bootstrap/launcher/jniutils/NativeCalls.java
This file was deleted.
Oops, something went wrong.
1 change: 1 addition & 0 deletions
1
windows-jni-utils-bootstrap/src/main/resources/META-INF/services/coursier.jniutils.NativeApi
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
coursier.bootstrap.launcher.jniutils.BootstrapNativeApi |
48 changes: 48 additions & 0 deletions
48
...i-utils-coursierapi/src/main/java/coursierapi/internal/jniutils/ApiInternalNativeApi.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
package coursierapi.internal.jniutils; | ||
|
||
import coursier.jniutils.LoadWindowsLibrary; | ||
import coursier.jniutils.NativeApi; | ||
|
||
public final class ApiInternalNativeApi extends NativeApi { | ||
|
||
static native String terminalSizeNative(); | ||
|
||
static native String enableAnsiOutputNative(); | ||
|
||
static native byte[] GetUserEnvironmentVariableNative(byte[] key); | ||
static native byte[] SetUserEnvironmentVariableNative(byte[] key, byte[] value); | ||
static native byte[] DeleteUserEnvironmentVariableNative(byte[] key); | ||
|
||
static native String GetKnownFolderPathNative(String rfid); | ||
|
||
|
||
public String terminalSize() { | ||
return terminalSizeNative(); | ||
} | ||
|
||
public String enableAnsiOutput() { | ||
return enableAnsiOutputNative(); | ||
} | ||
|
||
public byte[] GetUserEnvironmentVariable(byte[] key) { | ||
return GetUserEnvironmentVariableNative(key); | ||
} | ||
public byte[] SetUserEnvironmentVariable(byte[] key, byte[] value) { | ||
return SetUserEnvironmentVariableNative(key, value); | ||
} | ||
public byte[] DeleteUserEnvironmentVariable(byte[] key) { | ||
return DeleteUserEnvironmentVariableNative(key); | ||
} | ||
|
||
public String GetKnownFolderPath(String rfid) { | ||
return GetKnownFolderPathNative(rfid); | ||
} | ||
|
||
static { | ||
LoadWindowsLibrary.ensureInitialized(); | ||
} | ||
|
||
public static void setup() { | ||
NativeApi.set(new ApiInternalNativeApi()); | ||
} | ||
} |
46 changes: 0 additions & 46 deletions
46
windows-jni-utils-coursierapi/src/main/java/coursierapi/internal/jniutils/NativeCalls.java
This file was deleted.
Oops, something went wrong.
1 change: 1 addition & 0 deletions
1
...ws-jni-utils-coursierapi/src/main/resources/META-INF/services/coursier.jniutils.NativeApi
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
coursierapi.internal.jniutils.ApiInternalNativeApi |
48 changes: 48 additions & 0 deletions
48
windows-jni-utils-lmcoursier/src/main/java/lmcoursier/internal/jniutils/LmNativeApi.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
package lmcoursier.internal.jniutils; | ||
|
||
import coursier.jniutils.LoadWindowsLibrary; | ||
import coursier.jniutils.NativeApi; | ||
|
||
public final class LmNativeApi extends NativeApi { | ||
|
||
static native String terminalSizeNative(); | ||
|
||
static native String enableAnsiOutputNative(); | ||
|
||
static native byte[] GetUserEnvironmentVariableNative(byte[] key); | ||
static native byte[] SetUserEnvironmentVariableNative(byte[] key, byte[] value); | ||
static native byte[] DeleteUserEnvironmentVariableNative(byte[] key); | ||
|
||
static native String GetKnownFolderPathNative(String rfid); | ||
|
||
|
||
public String terminalSize() { | ||
return terminalSizeNative(); | ||
} | ||
|
||
public String enableAnsiOutput() { | ||
return enableAnsiOutputNative(); | ||
} | ||
|
||
public byte[] GetUserEnvironmentVariable(byte[] key) { | ||
return GetUserEnvironmentVariableNative(key); | ||
} | ||
public byte[] SetUserEnvironmentVariable(byte[] key, byte[] value) { | ||
return SetUserEnvironmentVariableNative(key, value); | ||
} | ||
public byte[] DeleteUserEnvironmentVariable(byte[] key) { | ||
return DeleteUserEnvironmentVariableNative(key); | ||
} | ||
|
||
public String GetKnownFolderPath(String rfid) { | ||
return GetKnownFolderPathNative(rfid); | ||
} | ||
|
||
static { | ||
LoadWindowsLibrary.ensureInitialized(); | ||
} | ||
|
||
public static void setup() { | ||
NativeApi.set(new LmNativeApi()); | ||
} | ||
} |
46 changes: 0 additions & 46 deletions
46
windows-jni-utils-lmcoursier/src/main/java/lmcoursier/internal/jniutils/NativeCalls.java
This file was deleted.
Oops, something went wrong.
1 change: 1 addition & 0 deletions
1
...ows-jni-utils-lmcoursier/src/main/resources/META-INF/services/coursier.jniutils.NativeApi
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
lmcoursier.internal.jniutils.LmNativeApi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
windows-jni-utils/src/main/c/coursier_bootstrap_launcher_jniutils_BootstrapNativeApi.c
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
#include "coursier_bootstrap_launcher_jniutils_BootstrapNativeApi.h" | ||
#include "coursier_jniutils_DefaultNativeApi.h" | ||
|
||
JNIEXPORT jstring JNICALL Java_coursier_bootstrap_launcher_jniutils_BootstrapNativeApi_terminalSizeNative | ||
(JNIEnv *env, jclass class) { | ||
return Java_coursier_jniutils_DefaultNativeApi_terminalSizeNative(env, class); | ||
} | ||
|
||
JNIEXPORT jstring JNICALL Java_coursier_bootstrap_launcher_jniutils_BootstrapNativeApi_enableAnsiOutputNative | ||
(JNIEnv *env, jclass class) { | ||
return Java_coursier_jniutils_DefaultNativeApi_enableAnsiOutputNative(env, class); | ||
} | ||
|
||
JNIEXPORT jbyteArray JNICALL Java_coursier_bootstrap_launcher_jniutils_BootstrapNativeApi_GetUserEnvironmentVariableNative | ||
(JNIEnv *env, jclass class, jbyteArray key) { | ||
return Java_coursier_jniutils_DefaultNativeApi_GetUserEnvironmentVariableNative(env, class, key); | ||
} | ||
|
||
JNIEXPORT jbyteArray JNICALL Java_coursier_bootstrap_launcher_jniutils_BootstrapNativeApi_SetUserEnvironmentVariableNative | ||
(JNIEnv *env, jclass class, jbyteArray key, jbyteArray value) { | ||
return Java_coursier_jniutils_DefaultNativeApi_SetUserEnvironmentVariableNative(env, class, key, value); | ||
} | ||
|
||
JNIEXPORT jbyteArray JNICALL Java_coursier_bootstrap_launcher_jniutils_BootstrapNativeApi_DeleteUserEnvironmentVariableNative | ||
(JNIEnv *env, jclass class, jbyteArray key) { | ||
return Java_coursier_jniutils_DefaultNativeApi_DeleteUserEnvironmentVariableNative(env, class, key); | ||
} | ||
|
||
JNIEXPORT jstring JNICALL Java_coursier_bootstrap_launcher_jniutils_BootstrapNativeApi_GetKnownFolderPathNative | ||
(JNIEnv *env, jclass class, jstring rfid) { | ||
return Java_coursier_jniutils_DefaultNativeApi_GetKnownFolderPathNative(env, class, rfid); | ||
} |
Oops, something went wrong.