Skip to content

Commit

Permalink
Implement more missing methods on WithRuntimeDecorator
Browse files Browse the repository at this point in the history
Summary:
X-link: facebook/react-native#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
  • Loading branch information
neildhar authored and facebook-github-bot committed Jun 26, 2024
1 parent 6c859d7 commit 1af8c80
Showing 1 changed file with 49 additions and 0 deletions.
49 changes: 49 additions & 0 deletions API/jsi/jsi/decorator.h
Original file line number Diff line number Diff line change
Expand Up @@ -582,6 +582,10 @@ class WithRuntimeDecorator : public RuntimeDecorator<Plain, Base> {
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);
Expand Down Expand Up @@ -610,6 +614,10 @@ class WithRuntimeDecorator : public RuntimeDecorator<Plain, Base> {
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);
Expand All @@ -624,6 +632,31 @@ class WithRuntimeDecorator : public RuntimeDecorator<Plain, Base> {
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);
Expand All @@ -637,6 +670,11 @@ class WithRuntimeDecorator : public RuntimeDecorator<Plain, Base> {
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();
Expand Down Expand Up @@ -797,6 +835,11 @@ class WithRuntimeDecorator : public RuntimeDecorator<Plain, Base> {
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);
Expand All @@ -811,6 +854,12 @@ class WithRuntimeDecorator : public RuntimeDecorator<Plain, Base> {
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 {
Expand Down

0 comments on commit 1af8c80

Please sign in to comment.