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

Fix "Not implemented" exception with macros #6137

Merged
merged 5 commits into from
Jul 1, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,22 @@ jsi::Value makeShareableClone(
} else {
if (shouldRetainRemote.isBool() && shouldRetainRemote.getBool()) {
shareable = std::make_shared<RetainingShareable<ShareableObject>>(
rt, object, nativeStateSource);
rt,
object
#if defined(USE_HERMES) || REACT_NATIVE_MINOR_VERSION >= 74
,
nativeStateSource
#endif // defined(USE_HERMES) || REACT_NATIVE_MINOR_VERSION >= 74
);
} else {
shareable =
std::make_shared<ShareableObject>(rt, object, nativeStateSource);
shareable = std::make_shared<ShareableObject>(
rt,
object
#if defined(USE_HERMES) || REACT_NATIVE_MINOR_VERSION >= 74
,
nativeStateSource
#endif // defined(USE_HERMES) || REACT_NATIVE_MINOR_VERSION >= 74
);
}
}
} else if (value.isString()) {
Expand Down Expand Up @@ -198,11 +210,14 @@ ShareableObject::ShareableObject(jsi::Runtime &rt, const jsi::Object &object)
auto value = extractShareableOrThrow(rt, object.getProperty(rt, key));
data_.emplace_back(key.utf8(rt), value);
}
#if defined(USE_HERMES) || REACT_NATIVE_MINOR_VERSION >= 74
if (object.hasNativeState(rt)) {
nativeState_ = object.getNativeState(rt);
}
#endif // defined(USE_HERMES) || REACT_NATIVE_MINOR_VERSION >= 74
}

#if defined(USE_HERMES) || REACT_NATIVE_MINOR_VERSION >= 74
ShareableObject::ShareableObject(
jsi::Runtime &rt,
const jsi::Object &object,
Expand All @@ -213,16 +228,19 @@ ShareableObject::ShareableObject(
nativeState_ = nativeStateSource.asObject(rt).getNativeState(rt);
}
}
#endif // defined(USE_HERMES) || REACT_NATIVE_MINOR_VERSION >= 74

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));
}
#if defined(USE_HERMES) || REACT_NATIVE_MINOR_VERSION >= 74
if (nativeState_ != nullptr) {
obj.setNativeState(rt, nativeState_);
}
#endif // defined(USE_HERMES) || REACT_NATIVE_MINOR_VERSION >= 74
return obj;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -183,16 +183,20 @@ class ShareableObject : public Shareable {
public:
ShareableObject(jsi::Runtime &rt, const jsi::Object &object);

#if defined(USE_HERMES) || REACT_NATIVE_MINOR_VERSION >= 74
tomekzaw marked this conversation as resolved.
Show resolved Hide resolved
ShareableObject(
jsi::Runtime &rt,
const jsi::Object &object,
const jsi::Value &nativeStateSource);
#endif // defined(USE_HERMES) || REACT_NATIVE_MINOR_VERSION >= 74

jsi::Value toJSValue(jsi::Runtime &rt) override;

protected:
std::vector<std::pair<std::string, std::shared_ptr<Shareable>>> data_;
#if defined(USE_HERMES) || REACT_NATIVE_MINOR_VERSION >= 74
std::shared_ptr<jsi::NativeState> nativeState_;
#endif // defined(USE_HERMES) || REACT_NATIVE_MINOR_VERSION >= 74
};

class ShareableHostObject : public Shareable {
Expand Down
Loading