Skip to content

Commit

Permalink
add react-native 0.72 support (#182)
Browse files Browse the repository at this point in the history
# Why

Add react-native 0.72 support

# How

- [ci] add react-native 0.72 test
- [v8runtime] fix jsi interface changes from 0.72

---------

Co-authored-by: Ollie <niu15076177821@hotmail.com>
  • Loading branch information
Kudo and NiuGuohui authored Jul 2, 2023
1 parent c6367c7 commit 56b76db
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .github/workflows/android.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
runs-on: macos-latest
strategy:
matrix:
rn-version: ['0.71']
rn-version: ['0.72', '0.71']
v8-android-variant:
[v8-android-jit, v8-android-jit-nointl, v8-android, v8-android-nointl]
# include:
Expand Down
16 changes: 16 additions & 0 deletions src/v8runtime/V8Runtime.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1076,7 +1076,11 @@ bool V8Runtime::hasProperty(
}

void V8Runtime::setPropertyValue(
#if REACT_NATIVE_TARGET_VERSION >= 72
const jsi::Object &object,
#else
jsi::Object &object,
#endif
const jsi::PropNameID &name,
const jsi::Value &value) {
v8::Locker locker(isolate_);
Expand All @@ -1098,7 +1102,11 @@ void V8Runtime::setPropertyValue(
}

void V8Runtime::setPropertyValue(
#if REACT_NATIVE_TARGET_VERSION >= 72
const jsi::Object &object,
#else
jsi::Object &object,
#endif
const jsi::String &name,
const jsi::Value &value) {
v8::Locker locker(isolate_);
Expand Down Expand Up @@ -1220,7 +1228,11 @@ jsi::WeakObject V8Runtime::createWeakObject(const jsi::Object &weakObject) {
new V8PointerValue(isolate_, std::move(weakRef)));
}

#if REACT_NATIVE_TARGET_VERSION >= 72
jsi::Value V8Runtime::lockWeakObject(const jsi::WeakObject &weakObject) {
#else
jsi::Value V8Runtime::lockWeakObject(jsi::WeakObject &weakObject) {
#endif
v8::Locker locker(isolate_);
v8::Isolate::Scope scopedIsolate(isolate_);
v8::HandleScope scopedHandle(isolate_);
Expand Down Expand Up @@ -1302,7 +1314,11 @@ jsi::Value V8Runtime::getValueAtIndex(const jsi::Array &array, size_t i) {
}

void V8Runtime::setValueAtIndexImpl(
#if REACT_NATIVE_TARGET_VERSION >= 72
const jsi::Array &array,
#else
jsi::Array &array,
#endif
size_t i,
const jsi::Value &value) {
v8::Locker locker(isolate_);
Expand Down
23 changes: 23 additions & 0 deletions src/v8runtime/V8Runtime.h
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,16 @@ class V8Runtime : public facebook::jsi::Runtime {
bool hasProperty(
const facebook::jsi::Object &,
const facebook::jsi::String &name) override;
#if REACT_NATIVE_TARGET_VERSION >= 72
void setPropertyValue(
const facebook::jsi::Object &,
const facebook::jsi::PropNameID &name,
const facebook::jsi::Value &value) override;
void setPropertyValue(
const facebook::jsi::Object &,
const facebook::jsi::String &name,
const facebook::jsi::Value &value) override;
#else
void setPropertyValue(
facebook::jsi::Object &,
const facebook::jsi::PropNameID &name,
Expand All @@ -158,6 +168,7 @@ class V8Runtime : public facebook::jsi::Runtime {
facebook::jsi::Object &,
const facebook::jsi::String &name,
const facebook::jsi::Value &value) override;
#endif

bool isArray(const facebook::jsi::Object &) const override;
bool isArrayBuffer(const facebook::jsi::Object &) const override;
Expand All @@ -168,7 +179,12 @@ class V8Runtime : public facebook::jsi::Runtime {

facebook::jsi::WeakObject createWeakObject(
const facebook::jsi::Object &) override;
#if REACT_NATIVE_TARGET_VERSION >= 72
facebook::jsi::Value lockWeakObject(
const facebook::jsi::WeakObject &) override;
#else
facebook::jsi::Value lockWeakObject(facebook::jsi::WeakObject &) override;
#endif

facebook::jsi::Array createArray(size_t length) override;
facebook::jsi::ArrayBuffer createArrayBuffer(
Expand All @@ -178,10 +194,17 @@ class V8Runtime : public facebook::jsi::Runtime {
uint8_t *data(const facebook::jsi::ArrayBuffer &) override;
facebook::jsi::Value getValueAtIndex(const facebook::jsi::Array &, size_t i)
override;
#if REACT_NATIVE_TARGET_VERSION >= 72
void setValueAtIndexImpl(
const facebook::jsi::Array &,
size_t i,
const facebook::jsi::Value &value) override;
#else
void setValueAtIndexImpl(
facebook::jsi::Array &,
size_t i,
const facebook::jsi::Value &value) override;
#endif

facebook::jsi::Function createFunctionFromHostFunction(
const facebook::jsi::PropNameID &name,
Expand Down

0 comments on commit 56b76db

Please sign in to comment.