Skip to content

Commit

Permalink
Update rclmodoki_init()
Browse files Browse the repository at this point in the history
  • Loading branch information
eyr1n committed Jul 4, 2023
1 parent 19eec33 commit 41a9c5a
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 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.2'
version = '0.0.3'
}
}
}
Expand Down
5 changes: 4 additions & 1 deletion rclmodoki/src/main/cpp/include/rclmodoki/rclmodoki.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<jlong>(new Node(domain_id));
Expand Down Expand Up @@ -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()));
}
Expand Down
4 changes: 1 addition & 3 deletions rclmodoki/src/main/cpp/include/rclmodoki/rclmodoki.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,7 @@ class MessageType {

using MessageTypes = std::unordered_map<std::string, MessageType>;

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);
Expand Down

0 comments on commit 41a9c5a

Please sign in to comment.