From 56b76dbd0e5b13b76ec315c480140ec15121a67b Mon Sep 17 00:00:00 2001 From: Kudo Chien Date: Sun, 2 Jul 2023 10:37:30 +0800 Subject: [PATCH] add react-native 0.72 support (#182) # 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 --- .github/workflows/android.yml | 2 +- src/v8runtime/V8Runtime.cpp | 16 ++++++++++++++++ src/v8runtime/V8Runtime.h | 23 +++++++++++++++++++++++ 3 files changed, 40 insertions(+), 1 deletion(-) diff --git a/.github/workflows/android.yml b/.github/workflows/android.yml index 2086af7..801c938 100644 --- a/.github/workflows/android.yml +++ b/.github/workflows/android.yml @@ -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: diff --git a/src/v8runtime/V8Runtime.cpp b/src/v8runtime/V8Runtime.cpp index ce6e48e..53e635e 100644 --- a/src/v8runtime/V8Runtime.cpp +++ b/src/v8runtime/V8Runtime.cpp @@ -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_); @@ -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_); @@ -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_); @@ -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_); diff --git a/src/v8runtime/V8Runtime.h b/src/v8runtime/V8Runtime.h index 490f9ab..d20238c 100644 --- a/src/v8runtime/V8Runtime.h +++ b/src/v8runtime/V8Runtime.h @@ -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, @@ -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; @@ -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( @@ -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,