Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement more missing methods on WithRuntimeDecorator #45049

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
63 changes: 63 additions & 0 deletions packages/react-native/ReactCommon/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 All @@ -654,6 +692,20 @@ class WithRuntimeDecorator : public RuntimeDecorator<Plain, Base> {
return RD::getHostFunction(f);
};

bool hasNativeState(const Object& o) override {
Around around{with_};
return RD::hasNativeState(o);
};
std::shared_ptr<NativeState> getNativeState(const Object& o) override {
Around around{with_};
return RD::getNativeState(o);
};
void setNativeState(const Object& o, std::shared_ptr<NativeState> state)
override {
Around around{with_};
RD::setNativeState(o, state);
};

Value getProperty(const Object& o, const PropNameID& name) override {
Around around{with_};
return RD::getProperty(o, name);
Expand Down Expand Up @@ -783,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 @@ -797,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
Loading