1*fe5cfb17STomasz Sapeta #include "NativeReanimatedModuleSpec.h"
2*fe5cfb17STomasz Sapeta
3*fe5cfb17STomasz Sapeta #include <utility>
4*fe5cfb17STomasz Sapeta
5*fe5cfb17STomasz Sapeta #define SPEC_PREFIX(FN_NAME) __hostFunction_NativeReanimatedModuleSpec_##FN_NAME
6*fe5cfb17STomasz Sapeta
7*fe5cfb17STomasz Sapeta namespace ABI48_0_0reanimated {
8*fe5cfb17STomasz Sapeta
SPEC_PREFIX(installCoreFunctions)9*fe5cfb17STomasz Sapeta static jsi::Value SPEC_PREFIX(installCoreFunctions)(
10*fe5cfb17STomasz Sapeta jsi::Runtime &rt,
11*fe5cfb17STomasz Sapeta TurboModule &turboModule,
12*fe5cfb17STomasz Sapeta const jsi::Value *args,
13*fe5cfb17STomasz Sapeta size_t count) {
14*fe5cfb17STomasz Sapeta static_cast<NativeReanimatedModuleSpec *>(&turboModule)
15*fe5cfb17STomasz Sapeta ->installCoreFunctions(rt, std::move(args[0]));
16*fe5cfb17STomasz Sapeta return jsi::Value::undefined();
17*fe5cfb17STomasz Sapeta }
18*fe5cfb17STomasz Sapeta
19*fe5cfb17STomasz Sapeta // SharedValue
20*fe5cfb17STomasz Sapeta
SPEC_PREFIX(makeShareable)21*fe5cfb17STomasz Sapeta static jsi::Value SPEC_PREFIX(makeShareable)(
22*fe5cfb17STomasz Sapeta jsi::Runtime &rt,
23*fe5cfb17STomasz Sapeta TurboModule &turboModule,
24*fe5cfb17STomasz Sapeta const jsi::Value *args,
25*fe5cfb17STomasz Sapeta size_t count) {
26*fe5cfb17STomasz Sapeta return static_cast<NativeReanimatedModuleSpec *>(&turboModule)
27*fe5cfb17STomasz Sapeta ->makeShareable(rt, std::move(args[0]));
28*fe5cfb17STomasz Sapeta }
29*fe5cfb17STomasz Sapeta
SPEC_PREFIX(makeMutable)30*fe5cfb17STomasz Sapeta static jsi::Value SPEC_PREFIX(makeMutable)(
31*fe5cfb17STomasz Sapeta jsi::Runtime &rt,
32*fe5cfb17STomasz Sapeta TurboModule &turboModule,
33*fe5cfb17STomasz Sapeta const jsi::Value *args,
34*fe5cfb17STomasz Sapeta size_t count) {
35*fe5cfb17STomasz Sapeta return static_cast<NativeReanimatedModuleSpec *>(&turboModule)
36*fe5cfb17STomasz Sapeta ->makeMutable(rt, std::move(args[0]));
37*fe5cfb17STomasz Sapeta }
38*fe5cfb17STomasz Sapeta
SPEC_PREFIX(makeRemote)39*fe5cfb17STomasz Sapeta static jsi::Value SPEC_PREFIX(makeRemote)(
40*fe5cfb17STomasz Sapeta jsi::Runtime &rt,
41*fe5cfb17STomasz Sapeta TurboModule &turboModule,
42*fe5cfb17STomasz Sapeta const jsi::Value *args,
43*fe5cfb17STomasz Sapeta size_t count) {
44*fe5cfb17STomasz Sapeta return static_cast<NativeReanimatedModuleSpec *>(&turboModule)
45*fe5cfb17STomasz Sapeta ->makeRemote(rt, std::move(args[0]));
46*fe5cfb17STomasz Sapeta }
47*fe5cfb17STomasz Sapeta
SPEC_PREFIX(startMapper)48*fe5cfb17STomasz Sapeta static jsi::Value SPEC_PREFIX(startMapper)(
49*fe5cfb17STomasz Sapeta jsi::Runtime &rt,
50*fe5cfb17STomasz Sapeta TurboModule &turboModule,
51*fe5cfb17STomasz Sapeta const jsi::Value *args,
52*fe5cfb17STomasz Sapeta size_t count) {
53*fe5cfb17STomasz Sapeta return static_cast<NativeReanimatedModuleSpec *>(&turboModule)
54*fe5cfb17STomasz Sapeta ->startMapper(
55*fe5cfb17STomasz Sapeta rt,
56*fe5cfb17STomasz Sapeta std::move(args[0]),
57*fe5cfb17STomasz Sapeta std::move(args[1]),
58*fe5cfb17STomasz Sapeta std::move(args[2]),
59*fe5cfb17STomasz Sapeta std::move(args[3]),
60*fe5cfb17STomasz Sapeta std::move(args[4]));
61*fe5cfb17STomasz Sapeta }
62*fe5cfb17STomasz Sapeta
SPEC_PREFIX(stopMapper)63*fe5cfb17STomasz Sapeta static jsi::Value SPEC_PREFIX(stopMapper)(
64*fe5cfb17STomasz Sapeta jsi::Runtime &rt,
65*fe5cfb17STomasz Sapeta TurboModule &turboModule,
66*fe5cfb17STomasz Sapeta const jsi::Value *args,
67*fe5cfb17STomasz Sapeta size_t count) {
68*fe5cfb17STomasz Sapeta static_cast<NativeReanimatedModuleSpec *>(&turboModule)
69*fe5cfb17STomasz Sapeta ->stopMapper(rt, std::move(args[0]));
70*fe5cfb17STomasz Sapeta return jsi::Value::undefined();
71*fe5cfb17STomasz Sapeta }
72*fe5cfb17STomasz Sapeta
SPEC_PREFIX(registerEventHandler)73*fe5cfb17STomasz Sapeta static jsi::Value SPEC_PREFIX(registerEventHandler)(
74*fe5cfb17STomasz Sapeta jsi::Runtime &rt,
75*fe5cfb17STomasz Sapeta TurboModule &turboModule,
76*fe5cfb17STomasz Sapeta const jsi::Value *args,
77*fe5cfb17STomasz Sapeta size_t count) {
78*fe5cfb17STomasz Sapeta return static_cast<NativeReanimatedModuleSpec *>(&turboModule)
79*fe5cfb17STomasz Sapeta ->registerEventHandler(rt, std::move(args[0]), std::move(args[1]));
80*fe5cfb17STomasz Sapeta }
81*fe5cfb17STomasz Sapeta
SPEC_PREFIX(unregisterEventHandler)82*fe5cfb17STomasz Sapeta static jsi::Value SPEC_PREFIX(unregisterEventHandler)(
83*fe5cfb17STomasz Sapeta jsi::Runtime &rt,
84*fe5cfb17STomasz Sapeta TurboModule &turboModule,
85*fe5cfb17STomasz Sapeta const jsi::Value *args,
86*fe5cfb17STomasz Sapeta size_t count) {
87*fe5cfb17STomasz Sapeta static_cast<NativeReanimatedModuleSpec *>(&turboModule)
88*fe5cfb17STomasz Sapeta ->unregisterEventHandler(rt, std::move(args[0]));
89*fe5cfb17STomasz Sapeta return jsi::Value::undefined();
90*fe5cfb17STomasz Sapeta }
91*fe5cfb17STomasz Sapeta
SPEC_PREFIX(getViewProp)92*fe5cfb17STomasz Sapeta static jsi::Value SPEC_PREFIX(getViewProp)(
93*fe5cfb17STomasz Sapeta jsi::Runtime &rt,
94*fe5cfb17STomasz Sapeta TurboModule &turboModule,
95*fe5cfb17STomasz Sapeta const jsi::Value *args,
96*fe5cfb17STomasz Sapeta size_t count) {
97*fe5cfb17STomasz Sapeta static_cast<NativeReanimatedModuleSpec *>(&turboModule)
98*fe5cfb17STomasz Sapeta ->getViewProp(
99*fe5cfb17STomasz Sapeta rt, std::move(args[0]), std::move(args[1]), std::move(args[2]));
100*fe5cfb17STomasz Sapeta return jsi::Value::undefined();
101*fe5cfb17STomasz Sapeta }
102*fe5cfb17STomasz Sapeta
SPEC_PREFIX(enableLayoutAnimations)103*fe5cfb17STomasz Sapeta static jsi::Value SPEC_PREFIX(enableLayoutAnimations)(
104*fe5cfb17STomasz Sapeta jsi::Runtime &rt,
105*fe5cfb17STomasz Sapeta TurboModule &turboModule,
106*fe5cfb17STomasz Sapeta const jsi::Value *args,
107*fe5cfb17STomasz Sapeta size_t count) {
108*fe5cfb17STomasz Sapeta static_cast<NativeReanimatedModuleSpec *>(&turboModule)
109*fe5cfb17STomasz Sapeta ->enableLayoutAnimations(rt, std::move(args[0]));
110*fe5cfb17STomasz Sapeta return jsi::Value::undefined();
111*fe5cfb17STomasz Sapeta }
112*fe5cfb17STomasz Sapeta
SPEC_PREFIX(registerSensor)113*fe5cfb17STomasz Sapeta static jsi::Value SPEC_PREFIX(registerSensor)(
114*fe5cfb17STomasz Sapeta jsi::Runtime &rt,
115*fe5cfb17STomasz Sapeta TurboModule &turboModule,
116*fe5cfb17STomasz Sapeta const jsi::Value *args,
117*fe5cfb17STomasz Sapeta size_t count) {
118*fe5cfb17STomasz Sapeta return static_cast<NativeReanimatedModuleSpec *>(&turboModule)
119*fe5cfb17STomasz Sapeta ->registerSensor(
120*fe5cfb17STomasz Sapeta rt, std::move(args[0]), std::move(args[1]), std::move(args[2]));
121*fe5cfb17STomasz Sapeta }
122*fe5cfb17STomasz Sapeta
SPEC_PREFIX(unregisterSensor)123*fe5cfb17STomasz Sapeta static jsi::Value SPEC_PREFIX(unregisterSensor)(
124*fe5cfb17STomasz Sapeta jsi::Runtime &rt,
125*fe5cfb17STomasz Sapeta TurboModule &turboModule,
126*fe5cfb17STomasz Sapeta const jsi::Value *args,
127*fe5cfb17STomasz Sapeta size_t count) {
128*fe5cfb17STomasz Sapeta static_cast<NativeReanimatedModuleSpec *>(&turboModule)
129*fe5cfb17STomasz Sapeta ->unregisterSensor(rt, std::move(args[0]));
130*fe5cfb17STomasz Sapeta return jsi::Value::undefined();
131*fe5cfb17STomasz Sapeta }
132*fe5cfb17STomasz Sapeta
SPEC_PREFIX(configureProps)133*fe5cfb17STomasz Sapeta static jsi::Value SPEC_PREFIX(configureProps)(
134*fe5cfb17STomasz Sapeta jsi::Runtime &rt,
135*fe5cfb17STomasz Sapeta TurboModule &turboModule,
136*fe5cfb17STomasz Sapeta const jsi::Value *args,
137*fe5cfb17STomasz Sapeta size_t count) {
138*fe5cfb17STomasz Sapeta static_cast<NativeReanimatedModuleSpec *>(&turboModule)
139*fe5cfb17STomasz Sapeta ->configureProps(rt, std::move(args[0]), std::move(args[1]));
140*fe5cfb17STomasz Sapeta return jsi::Value::undefined();
141*fe5cfb17STomasz Sapeta }
142*fe5cfb17STomasz Sapeta
SPEC_PREFIX(subscribeForKeyboardEvents)143*fe5cfb17STomasz Sapeta static jsi::Value SPEC_PREFIX(subscribeForKeyboardEvents)(
144*fe5cfb17STomasz Sapeta jsi::Runtime &rt,
145*fe5cfb17STomasz Sapeta TurboModule &turboModule,
146*fe5cfb17STomasz Sapeta const jsi::Value *args,
147*fe5cfb17STomasz Sapeta size_t count) {
148*fe5cfb17STomasz Sapeta return static_cast<NativeReanimatedModuleSpec *>(&turboModule)
149*fe5cfb17STomasz Sapeta ->subscribeForKeyboardEvents(rt, std::move(args[0]));
150*fe5cfb17STomasz Sapeta }
151*fe5cfb17STomasz Sapeta
SPEC_PREFIX(unsubscribeFromKeyboardEvents)152*fe5cfb17STomasz Sapeta static jsi::Value SPEC_PREFIX(unsubscribeFromKeyboardEvents)(
153*fe5cfb17STomasz Sapeta jsi::Runtime &rt,
154*fe5cfb17STomasz Sapeta TurboModule &turboModule,
155*fe5cfb17STomasz Sapeta const jsi::Value *args,
156*fe5cfb17STomasz Sapeta size_t count) {
157*fe5cfb17STomasz Sapeta static_cast<NativeReanimatedModuleSpec *>(&turboModule)
158*fe5cfb17STomasz Sapeta ->unsubscribeFromKeyboardEvents(rt, std::move(args[0]));
159*fe5cfb17STomasz Sapeta return jsi::Value::undefined();
160*fe5cfb17STomasz Sapeta }
161*fe5cfb17STomasz Sapeta
NativeReanimatedModuleSpec(std::shared_ptr<CallInvoker> jsInvoker)162*fe5cfb17STomasz Sapeta NativeReanimatedModuleSpec::NativeReanimatedModuleSpec(
163*fe5cfb17STomasz Sapeta std::shared_ptr<CallInvoker> jsInvoker)
164*fe5cfb17STomasz Sapeta : TurboModule("NativeReanimated", jsInvoker) {
165*fe5cfb17STomasz Sapeta methodMap_["installCoreFunctions"] =
166*fe5cfb17STomasz Sapeta MethodMetadata{1, SPEC_PREFIX(installCoreFunctions)};
167*fe5cfb17STomasz Sapeta
168*fe5cfb17STomasz Sapeta methodMap_["makeShareable"] = MethodMetadata{1, SPEC_PREFIX(makeShareable)};
169*fe5cfb17STomasz Sapeta methodMap_["makeMutable"] = MethodMetadata{1, SPEC_PREFIX(makeMutable)};
170*fe5cfb17STomasz Sapeta methodMap_["makeRemote"] = MethodMetadata{1, SPEC_PREFIX(makeRemote)};
171*fe5cfb17STomasz Sapeta
172*fe5cfb17STomasz Sapeta methodMap_["startMapper"] = MethodMetadata{5, SPEC_PREFIX(startMapper)};
173*fe5cfb17STomasz Sapeta methodMap_["stopMapper"] = MethodMetadata{1, SPEC_PREFIX(stopMapper)};
174*fe5cfb17STomasz Sapeta
175*fe5cfb17STomasz Sapeta methodMap_["registerEventHandler"] =
176*fe5cfb17STomasz Sapeta MethodMetadata{2, SPEC_PREFIX(registerEventHandler)};
177*fe5cfb17STomasz Sapeta methodMap_["unregisterEventHandler"] =
178*fe5cfb17STomasz Sapeta MethodMetadata{1, SPEC_PREFIX(unregisterEventHandler)};
179*fe5cfb17STomasz Sapeta
180*fe5cfb17STomasz Sapeta methodMap_["getViewProp"] = MethodMetadata{3, SPEC_PREFIX(getViewProp)};
181*fe5cfb17STomasz Sapeta methodMap_["enableLayoutAnimations"] =
182*fe5cfb17STomasz Sapeta MethodMetadata{2, SPEC_PREFIX(enableLayoutAnimations)};
183*fe5cfb17STomasz Sapeta methodMap_["registerSensor"] = MethodMetadata{3, SPEC_PREFIX(registerSensor)};
184*fe5cfb17STomasz Sapeta methodMap_["unregisterSensor"] =
185*fe5cfb17STomasz Sapeta MethodMetadata{1, SPEC_PREFIX(unregisterSensor)};
186*fe5cfb17STomasz Sapeta methodMap_["configureProps"] = MethodMetadata{2, SPEC_PREFIX(configureProps)};
187*fe5cfb17STomasz Sapeta methodMap_["subscribeForKeyboardEvents"] =
188*fe5cfb17STomasz Sapeta MethodMetadata{1, SPEC_PREFIX(subscribeForKeyboardEvents)};
189*fe5cfb17STomasz Sapeta methodMap_["unsubscribeFromKeyboardEvents"] =
190*fe5cfb17STomasz Sapeta MethodMetadata{1, SPEC_PREFIX(unsubscribeFromKeyboardEvents)};
191*fe5cfb17STomasz Sapeta }
192*fe5cfb17STomasz Sapeta } // namespace reanimated
193