diff --git a/rclmodoki/build.gradle b/rclmodoki/build.gradle index af485fc..1e0a364 100644 --- a/rclmodoki/build.gradle +++ b/rclmodoki/build.gradle @@ -65,7 +65,7 @@ afterEvaluate { from components.release groupId = 'jp.eyrin' artifactId = 'rclmodoki' - version = '0.0.2' + version = '0.0.3' } } } diff --git a/rclmodoki/src/main/cpp/include/rclmodoki/rclmodoki.cpp b/rclmodoki/src/main/cpp/include/rclmodoki/rclmodoki.cpp index a58ce00..a4de4f5 100644 --- a/rclmodoki/src/main/cpp/include/rclmodoki/rclmodoki.cpp +++ b/rclmodoki/src/main/cpp/include/rclmodoki/rclmodoki.cpp @@ -7,6 +7,8 @@ namespace rclmodoki { +static MessageTypes message_types; + // Node jlong node_create_node(JNIEnv *env, jobject thiz, jint domain_id) { return reinterpret_cast(new Node(domain_id)); @@ -65,8 +67,9 @@ jint subscription_get_publisher_count(JNIEnv *env, jobject thiz, jlong subscript return subscription->get_publisher_count(); } -void rclmodoki_init(JNIEnv *env) { +void rclmodoki_init(JNIEnv *env, const MessageTypes &types) { // Init MessageTypes + message_types = types; for (auto &message_type : message_types) { message_type.second.jni_class = new JNIClass(env, env->FindClass(message_type.first.c_str())); } diff --git a/rclmodoki/src/main/cpp/include/rclmodoki/rclmodoki.hpp b/rclmodoki/src/main/cpp/include/rclmodoki/rclmodoki.hpp index cb775f8..43d158a 100644 --- a/rclmodoki/src/main/cpp/include/rclmodoki/rclmodoki.hpp +++ b/rclmodoki/src/main/cpp/include/rclmodoki/rclmodoki.hpp @@ -27,9 +27,7 @@ class MessageType { using MessageTypes = std::unordered_map; -extern MessageTypes message_types; - -void rclmodoki_init(JNIEnv *env); +void rclmodoki_init(JNIEnv *env, const MessageTypes &types); inline std::string from_jstring(JNIEnv *env, jstring s) { const char *s_ = env->GetStringUTFChars(s, nullptr);