mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
fix: long not implemented on native side (#48017)
Summary: Handling `long` values is not implemented in Writables. I added it on the native side. ## Changelog: <!-- Help reviewers and the release process by writing your own changelog entry. Pick one each for the category and type tags: [ANDROID|GENERAL|IOS|INTERNAL] [BREAKING|ADDED|CHANGED|DEPRECATED|REMOVED|FIXED|SECURITY] - Message For more details, see: https://reactnative.dev/contributing/changelogs-in-pull-requests --> [ANDROID] [FIXED] - Support Long values in WritableMap and WritableArray Pull Request resolved: https://github.com/facebook/react-native/pull/48017 Test Plan: Run https://github.com/WoLewicki/reproducer-react-native/tree/%40wolewicki/long-in-writeable-map and see it doesn't work without those changes. Reviewed By: javache Differential Revision: D66754194 Pulled By: cortinico fbshipit-source-id: 7f8d4eb3c4069f890460525ddffdf9f4324550b0
This commit is contained in:
committed by
Facebook GitHub Bot
parent
8aac234ce2
commit
e7f943de2f
@@ -47,6 +47,11 @@ void WritableNativeArray::pushInt(jint value) {
|
||||
array_.push_back(value);
|
||||
}
|
||||
|
||||
void WritableNativeArray::pushLong(jlong value) {
|
||||
throwIfConsumed();
|
||||
array_.push_back(value);
|
||||
}
|
||||
|
||||
void WritableNativeArray::pushString(jstring value) {
|
||||
if (value == NULL) {
|
||||
pushNull();
|
||||
@@ -81,6 +86,7 @@ void WritableNativeArray::registerNatives() {
|
||||
makeNativeMethod("pushBoolean", WritableNativeArray::pushBoolean),
|
||||
makeNativeMethod("pushDouble", WritableNativeArray::pushDouble),
|
||||
makeNativeMethod("pushInt", WritableNativeArray::pushInt),
|
||||
makeNativeMethod("pushLong", WritableNativeArray::pushLong),
|
||||
makeNativeMethod("pushString", WritableNativeArray::pushString),
|
||||
makeNativeMethod("pushNativeArray", WritableNativeArray::pushNativeArray),
|
||||
makeNativeMethod("pushNativeMap", WritableNativeArray::pushNativeMap),
|
||||
|
||||
@@ -36,6 +36,7 @@ struct WritableNativeArray
|
||||
void pushBoolean(jboolean value);
|
||||
void pushDouble(jdouble value);
|
||||
void pushInt(jint value);
|
||||
void pushLong(jlong value);
|
||||
void pushString(jstring value);
|
||||
void pushNativeArray(ReadableNativeArray* otherArray);
|
||||
void pushNativeMap(ReadableNativeMap* map);
|
||||
|
||||
@@ -44,6 +44,11 @@ void WritableNativeMap::putInt(std::string key, int val) {
|
||||
map_.insert(std::move(key), val);
|
||||
}
|
||||
|
||||
void WritableNativeMap::putLong(std::string key, jlong val) {
|
||||
throwIfConsumed();
|
||||
map_.insert(std::move(key), val);
|
||||
}
|
||||
|
||||
void WritableNativeMap::putString(std::string key, alias_ref<jstring> val) {
|
||||
if (!val) {
|
||||
putNull(std::move(key));
|
||||
@@ -90,6 +95,7 @@ void WritableNativeMap::registerNatives() {
|
||||
makeNativeMethod("putBoolean", WritableNativeMap::putBoolean),
|
||||
makeNativeMethod("putDouble", WritableNativeMap::putDouble),
|
||||
makeNativeMethod("putInt", WritableNativeMap::putInt),
|
||||
makeNativeMethod("putLong", WritableNativeMap::putLong),
|
||||
makeNativeMethod("putString", WritableNativeMap::putString),
|
||||
makeNativeMethod("putNativeArray", WritableNativeMap::putNativeArray),
|
||||
makeNativeMethod("putNativeMap", WritableNativeMap::putNativeMap),
|
||||
|
||||
@@ -35,6 +35,7 @@ struct WritableNativeMap
|
||||
void putBoolean(std::string key, bool val);
|
||||
void putDouble(std::string key, double val);
|
||||
void putInt(std::string key, int val);
|
||||
void putLong(std::string key, jlong val);
|
||||
void putString(std::string key, jni::alias_ref<jstring> val);
|
||||
void putNativeArray(std::string key, ReadableNativeArray* val);
|
||||
void putNativeMap(std::string key, ReadableNativeMap* val);
|
||||
|
||||
Reference in New Issue
Block a user