1 /* 2 * Copyright (c) Meta Platforms, Inc. and affiliates. 3 * 4 * This source code is licensed under the MIT license found in the 5 * LICENSE file in the root directory of this source tree. 6 */ 7 8 #pragma once 9 10 #include <string> 11 #include <vector> 12 13 #include <folly/Optional.h> 14 #include <folly/dynamic.h> 15 16 namespace ABI47_0_0facebook { 17 namespace ABI47_0_0React { 18 19 struct MethodDescriptor { 20 std::string name; 21 // type is one of js MessageQueue.MethodTypes 22 std::string type; 23 MethodDescriptorMethodDescriptor24 MethodDescriptor(std::string n, std::string t) 25 : name(std::move(n)), type(std::move(t)) {} 26 }; 27 28 using MethodCallResult = folly::Optional<folly::dynamic>; 29 30 class NativeModule { 31 public: ~NativeModule()32 virtual ~NativeModule() {} 33 virtual std::string getName() = 0; 34 virtual std::string getSyncMethodName(unsigned int methodId) = 0; 35 virtual std::vector<MethodDescriptor> getMethods() = 0; 36 virtual folly::dynamic getConstants() = 0; 37 virtual void 38 invoke(unsigned int ABI47_0_0ReactMethodId, folly::dynamic &¶ms, int callId) = 0; 39 virtual MethodCallResult callSerializableNativeHook( 40 unsigned int ABI47_0_0ReactMethodId, 41 folly::dynamic &&args) = 0; 42 }; 43 44 } // namespace ABI47_0_0React 45 } // namespace ABI47_0_0facebook 46