From fec1880ad5286c9fadd7a77bbe725f83a7fed604 Mon Sep 17 00:00:00 2001 From: Kevin Dewald Date: Mon, 28 Apr 2025 23:52:37 -0700 Subject: [PATCH] Removed unused files --- simplejavable/cpp/CMakeLists.txt | 1 - simplejavable/cpp/src/utils.cpp | 54 -------------------------------- simplejavable/cpp/src/utils.h | 18 ----------- 3 files changed, 73 deletions(-) delete mode 100644 simplejavable/cpp/src/utils.cpp delete mode 100644 simplejavable/cpp/src/utils.h diff --git a/simplejavable/cpp/CMakeLists.txt b/simplejavable/cpp/CMakeLists.txt index 463670d..0b73fa7 100644 --- a/simplejavable/cpp/CMakeLists.txt +++ b/simplejavable/cpp/CMakeLists.txt @@ -34,7 +34,6 @@ add_library( src/java/lang/Iterator.cpp src/java/lang/ArrayList.cpp src/simplejavable.cpp - src/utils.cpp ) set_target_properties( diff --git a/simplejavable/cpp/src/utils.cpp b/simplejavable/cpp/src/utils.cpp deleted file mode 100644 index 0272e5a..0000000 --- a/simplejavable/cpp/src/utils.cpp +++ /dev/null @@ -1,54 +0,0 @@ -#include "utils.h" - -#include - -void log_error(const std::string& msg) {} -void log_info(const std::string& msg) {} -void log_debug(const std::string& msg) {} - -jstring to_jstring(JNIEnv* env, const std::string& str) { return env->NewStringUTF(str.c_str()); } - -std::string from_jstring(JNIEnv* env, jstring str) { - const char* c_str = env->GetStringUTFChars(str, nullptr); - std::string result(c_str); - env->ReleaseStringUTFChars(str, c_str); - return result; -} - -jbyteArray to_jbyteArray(JNIEnv* env, const std::string& data) { - jbyteArray result = env->NewByteArray(data.size()); - env->SetByteArrayRegion(result, 0, data.size(), reinterpret_cast(data.data())); - - jsize length = env->GetArrayLength(result); - jbyte* bytes = env->GetByteArrayElements(result, NULL); - - std::string arrayOut = "Array: "; - for (jsize i = 0; i < length; i++) { - arrayOut += fmt::format("{:02x} ", bytes[i]); - } - log_debug(arrayOut); - - env->ReleaseByteArrayElements(result, bytes, JNI_ABORT); - - return result; -} - -jobject jarraylist_new(JNIEnv* env) { - jclass arrayListClass = env->FindClass("java/util/ArrayList"); - jmethodID arrayListConstructor = env->GetMethodID(arrayListClass, "", "()V"); - jobject arrayList = env->NewObject(arrayListClass, arrayListConstructor); - return arrayList; -} - -void jarraylist_add(JNIEnv* env, jobject arrayList, jobject element) { - jclass arrayListClass = env->GetObjectClass(arrayList); - jmethodID arrayListAdd = env->GetMethodID(arrayListClass, "add", "(Ljava/lang/Object;)Z"); - env->CallBooleanMethod(arrayList, arrayListAdd, element); -} - -void throw_exception(JNIEnv* env, const std::string& msg) { - log_error(fmt::format("Throwing exception: {}", msg)); - - jclass Exception = env->FindClass("java/lang/Exception"); - env->ThrowNew(Exception, msg.c_str()); -} \ No newline at end of file diff --git a/simplejavable/cpp/src/utils.h b/simplejavable/cpp/src/utils.h deleted file mode 100644 index 2e6de46..0000000 --- a/simplejavable/cpp/src/utils.h +++ /dev/null @@ -1,18 +0,0 @@ -#pragma once - -#include -#include - -void log_error(const std::string& msg); -void log_info(const std::string& msg); -void log_debug(const std::string& msg); - -jstring to_jstring(JNIEnv* env, const std::string& str); -std::string from_jstring(JNIEnv* env, jstring str); - -jbyteArray to_jbyteArray(JNIEnv* env, const std::string& data); - -jobject jarraylist_new(JNIEnv* env); -void jarraylist_add(JNIEnv* env, jobject arrayList, jobject element); - -void throw_exception(JNIEnv* env, const std::string& msg); \ No newline at end of file