From 52f335ef5e7b6123be58ee7efa7974c869737de6 Mon Sep 17 00:00:00 2001 From: nicejs-is-cool Date: Tue, 2 Jun 2026 10:21:53 -0300 Subject: [PATCH] finish implementing methods used in nativebindings test program --- src/native/main.cpp | 38 ++++++++++++++++++++++++++++++++++---- 1 file changed, 34 insertions(+), 4 deletions(-) diff --git a/src/native/main.cpp b/src/native/main.cpp index 0454b66..937f011 100644 --- a/src/native/main.cpp +++ b/src/native/main.cpp @@ -209,13 +209,43 @@ JNIEXPORT jobject JNICALL Java_org_neoflock_NeoNucleus_NativeBindings_nn_1addSup (JNIEnv * env, jclass, jobject computer, jobject arch) { nn_Computer* nnPC = (nn_Computer*) Carbon::PointerBacked::GetPointer(env, computer); nn_Architecture* nnArch = (nn_Architecture*) Carbon::PointerBacked::GetPointer(env, arch); - NULLPTR_CHECKNR(nnPC, nn_Computer); - NULLPTR_CHECKNR(nnArch, nn_Architecture); + NULLPTR_CHECK(nnPC, nn_Computer); + NULLPTR_CHECK(nnArch, nn_Architecture); nn_addSupportedArchitecture(nnPC, nnArch); } JNIEXPORT jobject JNICALL Java_org_neoflock_NeoNucleus_NativeBindings_nn_1setTmpAddress - (JNIEnv *, jclass, jobject computer, jstring address) { + (JNIEnv * env, jclass, jobject computer, jstring address) { // TODO -} \ No newline at end of file + nn_Computer* nnPC = (nn_Computer*) Carbon::PointerBacked::GetPointer(env, computer); + NULLPTR_CHECK(nnPC, nn_Computer); + if (address == NULL) { + return Carbon::Map::To_nn_Exit(env, nn_setTmpAddress(nnPC, NULL)); + } + const char * str = env->GetStringUTFChars(address, NULL); + nn_Exit exitCode = nn_setTmpAddress(nnPC, str); + env->ReleaseStringUTFChars(address, str); + return Carbon::Map::To_nn_Exit(env, exitCode); +} + +JNIEXPORT jobject JNICALL Java_org_neoflock_NeoNucleus_NativeBindings_nn_1tick + (JNIEnv * env, jclass, jobject computer) { + nn_Computer* nnPC = (nn_Computer*) Carbon::PointerBacked::GetPointer(env, computer); + NULLPTR_CHECK(nnPC, nn_Computer); + return Carbon::Map::To_nn_Exit(env, nn_tick(nnPC)); +} + +JNIEXPORT jobject JNICALL Java_org_neoflock_NeoNucleus_NativeBindings_nn_1tickSynchronized + (JNIEnv * env, jclass, jobject computer) { + nn_Computer* nnPC = (nn_Computer*) Carbon::PointerBacked::GetPointer(env, computer); + NULLPTR_CHECK(nnPC, nn_Computer); + return Carbon::Map::To_nn_Exit(env, nn_tickSynchronized(nnPC)); +} + +JNIEXPORT jobject JNICALL Java_org_neoflock_NeoNucleus_NativeBindings_nn_1getComputerState + (JNIEnv * env, jclass, jobject computer) { + nn_Computer* nnPC = (nn_Computer*) Carbon::PointerBacked::GetPointer(env, computer); + NULLPTR_CHECK(nnPC, nn_Computer); + return Carbon::Map::To_nn_ComputerState(env, nn_getComputerState(nnPC)); +}