-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Return
JMap
instead of JHashMap
in typed map converter (`Rec…
…ord<string, T>`) (#518) * chore: Add Map in struct tests (`Record<string, T>` inside a plain struct/object) * feat: Add `extractMap(mapWrapper)` test * Update HybridTestObjectSwift.swift * fix: Return `JMap` instead of `JHashMap` in record converter
- Loading branch information
Showing
23 changed files
with
491 additions
and
152 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
67 changes: 67 additions & 0 deletions
67
packages/react-native-nitro-image/nitrogen/generated/android/c++/JMapWrapper.hpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
/// | ||
/// JMapWrapper.hpp | ||
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE. | ||
/// https://github.com/mrousavy/nitro | ||
/// Copyright © 2025 Marc Rousavy @ Margelo | ||
/// | ||
|
||
#pragma once | ||
|
||
#include <fbjni/fbjni.h> | ||
#include "MapWrapper.hpp" | ||
|
||
#include <string> | ||
#include <unordered_map> | ||
|
||
namespace margelo::nitro::image { | ||
|
||
using namespace facebook; | ||
|
||
/** | ||
* The C++ JNI bridge between the C++ struct "MapWrapper" and the the Kotlin data class "MapWrapper". | ||
*/ | ||
struct JMapWrapper final: public jni::JavaClass<JMapWrapper> { | ||
public: | ||
static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/image/MapWrapper;"; | ||
|
||
public: | ||
/** | ||
* Convert this Java/Kotlin-based struct to the C++ struct MapWrapper by copying all values to C++. | ||
*/ | ||
[[maybe_unused]] | ||
[[nodiscard]] | ||
MapWrapper toCpp() const { | ||
static const auto clazz = javaClassStatic(); | ||
static const auto fieldMap = clazz->getField<jni::JMap<jni::JString, jni::JString>>("map"); | ||
jni::local_ref<jni::JMap<jni::JString, jni::JString>> map = this->getFieldValue(fieldMap); | ||
return MapWrapper( | ||
[&]() { | ||
std::unordered_map<std::string, std::string> __map; | ||
__map.reserve(map->size()); | ||
for (const auto& __entry : *map) { | ||
__map.emplace(__entry.first->toStdString(), __entry.second->toStdString()); | ||
} | ||
return __map; | ||
}() | ||
); | ||
} | ||
|
||
public: | ||
/** | ||
* Create a Java/Kotlin-based struct by copying all values from the given C++ struct to Java. | ||
*/ | ||
[[maybe_unused]] | ||
static jni::local_ref<JMapWrapper::javaobject> fromCpp(const MapWrapper& value) { | ||
return newInstance( | ||
[&]() -> jni::local_ref<jni::JMap<jni::JString, jni::JString>> { | ||
auto __map = jni::JHashMap<jni::JString, jni::JString>::create(value.map.size()); | ||
for (const auto& __entry : value.map) { | ||
__map->put(jni::make_jstring(__entry.first), jni::make_jstring(__entry.second)); | ||
} | ||
return __map; | ||
}() | ||
); | ||
} | ||
}; | ||
|
||
} // namespace margelo::nitro::image |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
...ative-nitro-image/nitrogen/generated/android/kotlin/com/margelo/nitro/image/MapWrapper.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
/// | ||
/// MapWrapper.kt | ||
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE. | ||
/// https://github.com/mrousavy/nitro | ||
/// Copyright © 2025 Marc Rousavy @ Margelo | ||
/// | ||
|
||
package com.margelo.nitro.image | ||
|
||
import androidx.annotation.Keep | ||
import com.facebook.proguard.annotations.DoNotStrip | ||
import com.margelo.nitro.core.* | ||
|
||
/** | ||
* Represents the JavaScript object/struct "MapWrapper". | ||
*/ | ||
@DoNotStrip | ||
@Keep | ||
data class MapWrapper | ||
@DoNotStrip | ||
@Keep | ||
constructor( | ||
val map: Map<String, String> | ||
) { | ||
/* main constructor */ | ||
} |
Oops, something went wrong.