Skip to content

Commit a57e900

Browse files
lavenzgfacebook-github-bot
authored andcommitted
getSHUnitCreator() to IHermes (#53419)
Summary: By default, this function returns nullptr. User can pass a preprocessor definition "-DHERMES_SH_UNIT_FN=sh_export_<unit_name>" (where <unit_name> is the name passed to shermesc when compiling the JS input), so that this function returns the function pointer, which can be passed to `evaluateSHUnit` for evaluation. Differential Revision: D80747463
1 parent 6e45dec commit a57e900

File tree

1 file changed

+21
-1
lines changed
  • packages/react-native/ReactCommon/jsi/jsi

1 file changed

+21
-1
lines changed

packages/react-native/ReactCommon/jsi/jsi/hermes.h

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
struct SHUnit;
1313
struct SHRuntime;
14+
using SHUnitCreator = SHUnit* (*)();
1415
namespace hermes::vm {
1516
class GCExecTrace;
1617
}
@@ -131,7 +132,7 @@ class IHermes : public jsi::ICast {
131132
/// Associate the SHUnit returned by \p shUnitCreator with this runtime and
132133
/// run its initialization code. The unit will be freed when the runtime is
133134
/// destroyed.
134-
virtual jsi::Value evaluateSHUnit(SHUnit* (*shUnitCreator)()) = 0;
135+
virtual jsi::Value evaluateSHUnit(SHUnitCreator shUnitCreator) = 0;
135136

136137
/// Retrieve the underlying SHRuntime.
137138
virtual SHRuntime* getSHRuntime() noexcept = 0;
@@ -145,4 +146,23 @@ class IHermes : public jsi::ICast {
145146
protected:
146147
~IHermes() = default;
147148
};
149+
150+
/// Interface for provide Hermes backend specific methods.
151+
class IHermesSHUnit : public jsi::ICast {
152+
public:
153+
static constexpr jsi::UUID uuid{
154+
0x52a2d522,
155+
0xcbc6,
156+
0x4236,
157+
0x8d5d,
158+
0x2636c320ed65,
159+
};
160+
161+
/// Get the unit creating function pointer which can be passed to
162+
/// evaluateSHUnit() for evaluation.
163+
virtual SHUnitCreator getSHUnitCreator() const = 0;
164+
165+
protected:
166+
~IHermesSHUnit() = default;
167+
};
148168
} // namespace facebook::hermes

0 commit comments

Comments
 (0)