From 993f9fd8db5fe4df495b3a3454273b0e11fef489 Mon Sep 17 00:00:00 2001 From: Neil Dhar Date: Tue, 25 Jun 2024 18:11:47 -0700 Subject: [PATCH] Implement more missing methods on WithRuntimeDecorator (#45049) Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/45049 WithRuntimeDecorator is missing many methods that were added after it. Add implementations for them. The underlying issue here is that because this inherits from RuntimeDecorator, which implements all methods, there is no compilation error for this runtime when we add new methods. Changelog: [GENERAL] [FIXED] - Add missing methods to the WithRuntimeDecorator class. Reviewed By: avp Differential Revision: D58752127 fbshipit-source-id: d80b4ed1c38698ed3850d0cd961bf7ddde2449a0 --- .../ReactCommon/jsi/jsi/decorator.h | 49 +++++++++++++++++++ 1 file changed, 49 insertions(+) diff --git a/packages/react-native/ReactCommon/jsi/jsi/decorator.h b/packages/react-native/ReactCommon/jsi/jsi/decorator.h index 738804b07bdb8e..4dd955be04e4e6 100644 --- a/packages/react-native/ReactCommon/jsi/jsi/decorator.h +++ b/packages/react-native/ReactCommon/jsi/jsi/decorator.h @@ -582,6 +582,10 @@ class WithRuntimeDecorator : public RuntimeDecorator { Around around{with_}; return RD::cloneSymbol(pv); }; + Runtime::PointerValue* cloneBigInt(const Runtime::PointerValue* pv) override { + Around around{with_}; + return RD::cloneBigInt(pv); + }; Runtime::PointerValue* cloneString(const Runtime::PointerValue* pv) override { Around around{with_}; return RD::cloneString(pv); @@ -610,6 +614,10 @@ class WithRuntimeDecorator : public RuntimeDecorator { Around around{with_}; return RD::createPropNameIDFromString(str); }; + PropNameID createPropNameIDFromSymbol(const Symbol& sym) override { + Around around{with_}; + return RD::createPropNameIDFromSymbol(sym); + }; std::string utf8(const PropNameID& id) override { Around around{with_}; return RD::utf8(id); @@ -624,6 +632,31 @@ class WithRuntimeDecorator : public RuntimeDecorator { return RD::symbolToString(sym); }; + BigInt createBigIntFromInt64(int64_t i) override { + Around around{with_}; + return RD::createBigIntFromInt64(i); + }; + BigInt createBigIntFromUint64(uint64_t i) override { + Around around{with_}; + return RD::createBigIntFromUint64(i); + }; + bool bigintIsInt64(const BigInt& bi) override { + Around around{with_}; + return RD::bigintIsInt64(bi); + }; + bool bigintIsUint64(const BigInt& bi) override { + Around around{with_}; + return RD::bigintIsUint64(bi); + }; + uint64_t truncate(const BigInt& bi) override { + Around around{with_}; + return RD::truncate(bi); + }; + String bigintToString(const BigInt& bi, int i) override { + Around around{with_}; + return RD::bigintToString(bi, i); + }; + String createStringFromAscii(const char* str, size_t length) override { Around around{with_}; return RD::createStringFromAscii(str, length); @@ -637,6 +670,11 @@ class WithRuntimeDecorator : public RuntimeDecorator { return RD::utf8(s); } + Value createValueFromJsonUtf8(const uint8_t* json, size_t length) override { + Around around{with_}; + return RD::createValueFromJsonUtf8(json, length); + }; + Object createObject() override { Around around{with_}; return RD::createObject(); @@ -797,6 +835,11 @@ class WithRuntimeDecorator : public RuntimeDecorator { Around around{with_}; return RD::strictEquals(a, b); }; + bool strictEquals(const BigInt& a, const BigInt& b) const override { + Around around{with_}; + return RD::strictEquals(a, b); + }; + bool strictEquals(const String& a, const String& b) const override { Around around{with_}; return RD::strictEquals(a, b); @@ -811,6 +854,12 @@ class WithRuntimeDecorator : public RuntimeDecorator { return RD::instanceOf(o, f); }; + void setExternalMemoryPressure(const jsi::Object& obj, size_t amount) + override { + Around around{with_}; + RD::setExternalMemoryPressure(obj, amount); + }; + private: // Wrap an RAII type around With& to guarantee after always happens. struct Around {