Skip to content

Commit

Permalink
Load NativeApi instances using services (#4)
Browse files Browse the repository at this point in the history
  • Loading branch information
alexarchambault authored Apr 27, 2021
1 parent d78ad8f commit 8ab70c3
Show file tree
Hide file tree
Showing 31 changed files with 522 additions and 520 deletions.
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());
}
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
coursier.bootstrap.launcher.jniutils.BootstrapNativeApi
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());
}
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
coursierapi.internal.jniutils.ApiInternalNativeApi
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());
}
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
lmcoursier.internal.jniutils.LmNativeApi
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,17 @@ object WindowsKnownFoldersTests extends TestSuite {
}

test("bootstrap") synchronized {
coursier.bootstrap.launcher.jniutils.NativeCalls.setup()
coursier.bootstrap.launcher.jniutils.BootstrapNativeApi.setup()
WindowsKnownFolders.knownFolderPath("{3EB685DB-65F9-4CF6-A03A-E3EF65729F3D}")
}

test("lmcoursier") synchronized {
lmcoursier.internal.jniutils.NativeCalls.setup()
lmcoursier.internal.jniutils.LmNativeApi.setup()
WindowsKnownFolders.knownFolderPath("{3EB685DB-65F9-4CF6-A03A-E3EF65729F3D}")
}

test("coursierapi") synchronized {
coursierapi.internal.jniutils.NativeCalls.setup()
coursierapi.internal.jniutils.ApiInternalNativeApi.setup()
WindowsKnownFolders.knownFolderPath("{3EB685DB-65F9-4CF6-A03A-E3EF65729F3D}")
}
}
Expand Down
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);
}
Loading

0 comments on commit 8ab70c3

Please sign in to comment.