From 6025367c7244e3af9ed10c4818261d8b1a05fd30 Mon Sep 17 00:00:00 2001 From: Marc Rousavy Date: Tue, 23 Nov 2021 15:48:07 +0100 Subject: [PATCH] fix: Fix duplicate `JHashMap` definition by moving to custom namespace (#610) Technically `JHashMap` is duplicated now, but in separate namespaces. If I were to remove my `JHashMap` (and `JArrayList`) definitions, the user is forced to use fbjni v3. --- android/src/main/cpp/JSIJNIConversion.cpp | 6 +++--- android/src/main/cpp/java-bindings/JHashMap.cpp | 8 ++++---- android/src/main/cpp/java-bindings/JHashMap.h | 8 ++++---- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/android/src/main/cpp/JSIJNIConversion.cpp b/android/src/main/cpp/JSIJNIConversion.cpp index e85a6f7..4fcb7e6 100644 --- a/android/src/main/cpp/JSIJNIConversion.cpp +++ b/android/src/main/cpp/JSIJNIConversion.cpp @@ -156,10 +156,10 @@ jsi::Value JSIJNIConversion::convertJNIObjectToJSIValue(jsi::Runtime &runtime, c auto array = toArrayListFunc(object.get()); return convertJNIObjectToJSIValue(runtime, array); - } else if (object->isInstanceOf(jni::JHashMap::javaClassStatic())) { + } else if (object->isInstanceOf(JHashMap::javaClassStatic())) { // HashMap - auto map = static_ref_cast>(object); + auto map = static_ref_cast>(object); auto result = jsi::Object(runtime); for (const auto& entry : *map) { @@ -173,7 +173,7 @@ jsi::Value JSIJNIConversion::convertJNIObjectToJSIValue(jsi::Runtime &runtime, c } else if (object->isInstanceOf(react::ReadableMap::javaClassStatic())) { // ReadableMap - static const auto toHashMapFunc = react::ReadableMap::javaClassLocal()->getMethod()>("toHashMap"); + static const auto toHashMapFunc = react::ReadableMap::javaClassLocal()->getMethod()>("toHashMap"); // call recursive, this time HashMap auto hashMap = toHashMapFunc(object.get()); diff --git a/android/src/main/cpp/java-bindings/JHashMap.cpp b/android/src/main/cpp/java-bindings/JHashMap.cpp index c2ca243..affd464 100644 --- a/android/src/main/cpp/java-bindings/JHashMap.cpp +++ b/android/src/main/cpp/java-bindings/JHashMap.cpp @@ -7,14 +7,14 @@ #include #include +namespace vision { -namespace facebook { -namespace jni { +using namespace facebook; +using namespace jni; template local_ref> JHashMap::create() { return JHashMap::newInstance(); } -} // namespace jni -} // namespace facebook +} // namespace vision diff --git a/android/src/main/cpp/java-bindings/JHashMap.h b/android/src/main/cpp/java-bindings/JHashMap.h index c3df327..b11d3c8 100644 --- a/android/src/main/cpp/java-bindings/JHashMap.h +++ b/android/src/main/cpp/java-bindings/JHashMap.h @@ -7,9 +7,10 @@ #include #include +namespace vision { -namespace facebook { -namespace jni { +using namespace facebook; +using namespace jni; // TODO: Remove when fbjni 0.2.3 releases. template @@ -19,5 +20,4 @@ struct JHashMap : JavaClass, JMap> { static local_ref> create(); }; -} // namespace jni -} // namespace facebook +} // namespace vision