Skip to content

Commit

Permalink
Delete JNI_OnLoad
Browse files Browse the repository at this point in the history
  • Loading branch information
eyr1n committed Jul 3, 2023
1 parent 20eb386 commit 19eec33
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 13 deletions.
2 changes: 1 addition & 1 deletion rclmodoki/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ afterEvaluate {
from components.release
groupId = 'jp.eyrin'
artifactId = 'rclmodoki'
version = '0.0.1'
version = '0.0.2'
}
}
}
Expand Down
15 changes: 3 additions & 12 deletions rclmodoki/src/main/cpp/include/rclmodoki/rclmodoki.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,16 +65,7 @@ jint subscription_get_publisher_count(JNIEnv *env, jobject thiz, jlong subscript
return subscription->get_publisher_count();
}

} // namespace rclmodoki

extern "C" JNIEXPORT jint JNI_OnLoad(JavaVM *vm, void *reserved) {
using namespace rclmodoki;

JNIEnv *env;
if (vm->GetEnv(reinterpret_cast<void **>(&env), JNI_VERSION_1_6) != JNI_OK) {
return JNI_ERR;
}

void rclmodoki_init(JNIEnv *env) {
// Init MessageTypes
for (auto &message_type : message_types) {
message_type.second.jni_class = new JNIClass(env, env->FindClass(message_type.first.c_str()));
Expand Down Expand Up @@ -111,6 +102,6 @@ extern "C" JNIEXPORT jint JNI_OnLoad(JavaVM *vm, void *reserved) {
};
env->RegisterNatives(subscription_class, subscription_methods,
sizeof(subscription_methods) / sizeof(JNINativeMethod));

return JNI_VERSION_1_6;
}

} // namespace rclmodoki
2 changes: 2 additions & 0 deletions rclmodoki/src/main/cpp/include/rclmodoki/rclmodoki.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ using MessageTypes = std::unordered_map<std::string, MessageType>;

extern MessageTypes message_types;

void rclmodoki_init(JNIEnv *env);

inline std::string from_jstring(JNIEnv *env, jstring s) {
const char *s_ = env->GetStringUTFChars(s, nullptr);
std::string res{s_};
Expand Down

0 comments on commit 19eec33

Please sign in to comment.