mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Add jsi::HostObject example to rn-tester (#36909)
Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/36909 Changelog: [Internal] Reviewed By: javache Differential Revision: D44978689 fbshipit-source-id: 0e31b5c37a7890744694706994ea672c3e619341
This commit is contained in:
committed by
Facebook GitHub Bot
parent
adb210306d
commit
f5c0606185
@@ -73,6 +73,30 @@ struct Bridging<CustomEnumInt> {
|
||||
}
|
||||
};
|
||||
|
||||
#pragma mark - jsi::HostObjects
|
||||
template <typename T>
|
||||
class HostObjectWrapper : public jsi::HostObject {
|
||||
public:
|
||||
HostObjectWrapper(std::shared_ptr<T> value) : value_(std::move(value)) {}
|
||||
|
||||
std::shared_ptr<T> getValue() const {
|
||||
return value_;
|
||||
}
|
||||
|
||||
~HostObjectWrapper() override = default;
|
||||
|
||||
private:
|
||||
std::shared_ptr<T> value_;
|
||||
};
|
||||
|
||||
struct CustomHostObjectRef {
|
||||
CustomHostObjectRef(std::string a, int32_t b) : a_(a), b_(b) {}
|
||||
std::string a_;
|
||||
int32_t b_;
|
||||
};
|
||||
|
||||
using CustomHostObject = HostObjectWrapper<CustomHostObjectRef>;
|
||||
|
||||
#pragma mark - implementation
|
||||
class NativeCxxModuleExample
|
||||
: public NativeCxxModuleExampleCxxSpec<NativeCxxModuleExample> {
|
||||
@@ -93,6 +117,12 @@ class NativeCxxModuleExample
|
||||
|
||||
CustomEnumInt getCustomEnum(jsi::Runtime &rt, CustomEnumInt arg);
|
||||
|
||||
std::shared_ptr<CustomHostObject> getCustomHostObject(jsi::Runtime &rt);
|
||||
|
||||
std::string consumeCustomHostObject(
|
||||
jsi::Runtime &rt,
|
||||
std::shared_ptr<CustomHostObject> arg);
|
||||
|
||||
NativeCxxModuleExampleCxxEnumFloat getNumEnum(
|
||||
jsi::Runtime &rt,
|
||||
NativeCxxModuleExampleCxxEnumInt arg);
|
||||
|
||||
Reference in New Issue
Block a user