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