diff --git a/Common/cpp/LayoutAnimations/LayoutAnimationsManager.cpp b/Common/cpp/LayoutAnimations/LayoutAnimationsManager.cpp index 7bec48e950f..8addb05a332 100644 --- a/Common/cpp/LayoutAnimations/LayoutAnimationsManager.cpp +++ b/Common/cpp/LayoutAnimations/LayoutAnimationsManager.cpp @@ -126,7 +126,7 @@ void LayoutAnimationsManager::startLayoutAnimation( jsi::Value(tag), jsi::Value(static_cast(type)), values, - config->getJSValue(rt)); + config->toJSValue(rt)); } void LayoutAnimationsManager::cancelLayoutAnimation( diff --git a/Common/cpp/ReanimatedRuntime/WorkletRuntime.cpp b/Common/cpp/ReanimatedRuntime/WorkletRuntime.cpp index 652e3158dd0..af766ca4eec 100644 --- a/Common/cpp/ReanimatedRuntime/WorkletRuntime.cpp +++ b/Common/cpp/ReanimatedRuntime/WorkletRuntime.cpp @@ -97,7 +97,7 @@ jsi::Value WorkletRuntime::executeSync( auto result = runGuarded(shareableWorklet); auto shareableResult = extractShareableOrThrow(uiRuntime, result); lock.unlock(); - return shareableResult->getJSValue(rt); + return shareableResult->toJSValue(rt); } jsi::Value WorkletRuntime::get( diff --git a/Common/cpp/ReanimatedRuntime/WorkletRuntime.h b/Common/cpp/ReanimatedRuntime/WorkletRuntime.h index 2131b956ebe..f3a02be004a 100644 --- a/Common/cpp/ReanimatedRuntime/WorkletRuntime.h +++ b/Common/cpp/ReanimatedRuntime/WorkletRuntime.h @@ -39,7 +39,7 @@ class WorkletRuntime : public jsi::HostObject, Args &&...args) const { jsi::Runtime &rt = *runtime_; return runOnRuntimeGuarded( - rt, shareableWorklet->getJSValue(rt), std::forward(args)...); + rt, shareableWorklet->toJSValue(rt), std::forward(args)...); } void runAsyncGuarded( diff --git a/Common/cpp/ReanimatedRuntime/WorkletRuntimeDecorator.cpp b/Common/cpp/ReanimatedRuntime/WorkletRuntimeDecorator.cpp index cf1a33cd254..ccf91720de4 100644 --- a/Common/cpp/ReanimatedRuntime/WorkletRuntimeDecorator.cpp +++ b/Common/cpp/ReanimatedRuntime/WorkletRuntimeDecorator.cpp @@ -102,13 +102,13 @@ void WorkletRuntimeDecorator::decorate( : extractShareableOrThrow( rt, argsValue, "[Reanimated] Args must be an array."); jsScheduler->scheduleOnJS([=](jsi::Runtime &rt) { - auto remoteFun = shareableRemoteFun->getJSValue(rt); + auto remoteFun = shareableRemoteFun->toJSValue(rt); if (shareableArgs == nullptr) { // fast path for remote function w/o arguments remoteFun.asObject(rt).asFunction(rt).call(rt); } else { auto argsArray = - shareableArgs->getJSValue(rt).asObject(rt).asArray(rt); + shareableArgs->toJSValue(rt).asObject(rt).asArray(rt); auto argsSize = argsArray.size(rt); // number of arguments is typically relatively small so it is ok to // to use VLAs here, hence disabling the lint rule diff --git a/Common/cpp/SharedItems/Shareables.cpp b/Common/cpp/SharedItems/Shareables.cpp index 1d542933e80..ae3a6109bf5 100644 --- a/Common/cpp/SharedItems/Shareables.cpp +++ b/Common/cpp/SharedItems/Shareables.cpp @@ -135,7 +135,7 @@ std::shared_ptr Shareable::undefined() { } template -jsi::Value RetainingShareable::getJSValue(jsi::Runtime &rt) { +jsi::Value RetainingShareable::toJSValue(jsi::Runtime &rt) { if (&rt == primaryRuntime_) { // TODO: it is suboptimal to generate new object every time getJS is // called on host runtime – the objects we are generating already exists @@ -172,7 +172,7 @@ jsi::Value ShareableArray::toJSValue(jsi::Runtime &rt) { auto size = data_.size(); auto ary = jsi::Array(rt, size); for (size_t i = 0; i < size; i++) { - ary.setValueAtIndex(rt, i, data_[i]->getJSValue(rt)); + ary.setValueAtIndex(rt, i, data_[i]->toJSValue(rt)); } return ary; } @@ -218,7 +218,7 @@ jsi::Value ShareableObject::toJSValue(jsi::Runtime &rt) { auto obj = jsi::Object(rt); for (size_t i = 0, size = data_.size(); i < size; i++) { obj.setProperty( - rt, data_[i].first.c_str(), data_[i].second->getJSValue(rt)); + rt, data_[i].first.c_str(), data_[i].second->toJSValue(rt)); } if (nativeState_ != nullptr) { obj.setNativeState(rt, nativeState_); @@ -265,7 +265,7 @@ jsi::Value ShareableRemoteFunction::toJSValue(jsi::Runtime &rt) { jsi::Value ShareableHandle::toJSValue(jsi::Runtime &rt) { if (remoteValue_ == nullptr) { - auto initObj = initializer_->getJSValue(rt); + auto initObj = initializer_->toJSValue(rt); auto value = std::make_unique(getValueUnpacker(rt).call( rt, initObj, jsi::String::createFromAscii(rt, "Handle"))); diff --git a/Common/cpp/SharedItems/Shareables.h b/Common/cpp/SharedItems/Shareables.h index 46b06720f0e..18deb29693d 100644 --- a/Common/cpp/SharedItems/Shareables.h +++ b/Common/cpp/SharedItems/Shareables.h @@ -62,10 +62,9 @@ inline void cleanupIfRuntimeExists( } class Shareable { - protected: + public: virtual jsi::Value toJSValue(jsi::Runtime &rt) = 0; - public: virtual ~Shareable(); enum ValueType { @@ -88,10 +87,6 @@ class Shareable { explicit Shareable(ValueType valueType) : valueType_(valueType) {} - virtual jsi::Value getJSValue(jsi::Runtime &rt) { - return toJSValue(rt); - } - inline ValueType valueType() const { return valueType_; } @@ -114,7 +109,7 @@ class RetainingShareable : virtual public BaseClass { explicit RetainingShareable(jsi::Runtime &rt, Args &&...args) : BaseClass(rt, std::forward(args)...), primaryRuntime_(&rt) {} - jsi::Value getJSValue(jsi::Runtime &rt); + jsi::Value toJSValue(jsi::Runtime &rt); ~RetainingShareable() { cleanupIfRuntimeExists(secondaryRuntime_, secondaryValue_);