mirror of
https://github.com/status-im/react-native.git
synced 2025-02-26 16:10:58 +00:00
Use new hybrid inheritance for NativeArray and descendants
Reviewed By: @andreicoman11 Differential Revision: D2523619 fb-gh-sync-id: 62382c16cbbeceec12763b3786676ecff783b651
This commit is contained in:
parent
998ab1b1a4
commit
fffae394c7
@ -8,29 +8,22 @@
|
||||
namespace facebook {
|
||||
namespace react {
|
||||
|
||||
struct NativeArray : public jni::HybridClass<NativeArray> {
|
||||
class NativeArray : public jni::HybridClass<NativeArray> {
|
||||
public:
|
||||
static constexpr const char* kJavaDescriptor = "Lcom/facebook/react/bridge/NativeArray;";
|
||||
|
||||
static jni::local_ref<jhybriddata> initHybrid(jni::alias_ref<jhybridobject>) {
|
||||
return makeCxxInstance();
|
||||
}
|
||||
|
||||
// Whether this array has been added to another array or map and no longer has a valid array value
|
||||
// Whether this array has been added to another array or map and no longer
|
||||
// has a valid array value.
|
||||
bool isConsumed = false;
|
||||
folly::dynamic array = {};
|
||||
folly::dynamic array;
|
||||
|
||||
jstring toString();
|
||||
|
||||
static void registerNatives() {
|
||||
registerHybrid({
|
||||
makeNativeMethod("initHybrid", NativeArray::initHybrid),
|
||||
makeNativeMethod("toString", NativeArray::toString),
|
||||
});
|
||||
}
|
||||
static void registerNatives();
|
||||
|
||||
protected:
|
||||
friend HybridBase;
|
||||
explicit NativeArray(folly::dynamic array);
|
||||
};
|
||||
|
||||
__attribute__((visibility("default")))
|
||||
jni::local_ref<NativeArray::jhybridobject>
|
||||
createReadableNativeArrayWithContents(folly::dynamic array);
|
||||
|
||||
}}
|
||||
|
35
ReactAndroid/src/main/jni/react/jni/ReadableNativeArray.h
Normal file
35
ReactAndroid/src/main/jni/react/jni/ReadableNativeArray.h
Normal file
@ -0,0 +1,35 @@
|
||||
// Copyright 2004-present Facebook. All Rights Reserved.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "NativeArray.h"
|
||||
|
||||
namespace facebook {
|
||||
namespace react {
|
||||
|
||||
class ReadableNativeArray : public jni::HybridClass<ReadableNativeArray, NativeArray> {
|
||||
protected:
|
||||
friend HybridBase;
|
||||
explicit ReadableNativeArray(folly::dynamic array);
|
||||
|
||||
public:
|
||||
static constexpr const char* kJavaDescriptor = "Lcom/facebook/react/bridge/ReadableNativeArray;";
|
||||
|
||||
static void mapException(const std::exception& ex);
|
||||
jint getSize();
|
||||
jboolean isNull(jint index);
|
||||
jboolean getBoolean(jint index);
|
||||
jint getInt(jint index);
|
||||
jdouble getDouble(jint index);
|
||||
// The lifetime of the const char* is the same as the underlying dynamic
|
||||
// array. This is fine for converting back to Java, but other uses should be
|
||||
// careful.
|
||||
const char* getString(jint index);
|
||||
jni::local_ref<jhybridobject> getArray(jint index);
|
||||
jobject getMap(jint index);
|
||||
jobject getType(jint index);
|
||||
|
||||
static void registerNatives();
|
||||
};
|
||||
|
||||
}}
|
Loading…
x
Reference in New Issue
Block a user