2019-10-16 20:03:47 +03:00
|
|
|
/*
|
|
|
|
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
|
|
*
|
|
|
|
* This source code is licensed under the MIT license found in the
|
|
|
|
* LICENSE file in the root directory of this source tree.
|
|
|
|
*/
|
2016-05-04 05:29:58 +03:00
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <string>
|
|
|
|
#include <vector>
|
|
|
|
|
2017-06-24 02:49:55 +03:00
|
|
|
#include <folly/Optional.h>
|
2017-05-13 03:57:12 +03:00
|
|
|
#include <folly/dynamic.h>
|
2016-05-04 05:29:58 +03:00
|
|
|
|
|
|
|
namespace facebook {
|
|
|
|
namespace react {
|
|
|
|
|
|
|
|
struct MethodDescriptor {
|
|
|
|
std::string name;
|
|
|
|
// type is one of js MessageQueue.MethodTypes
|
|
|
|
std::string type;
|
|
|
|
|
|
|
|
MethodDescriptor(std::string n, std::string t)
|
2020-02-26 06:50:31 +03:00
|
|
|
: name(std::move(n)), type(std::move(t)) {}
|
2016-05-04 05:29:58 +03:00
|
|
|
};
|
|
|
|
|
2020-02-26 06:50:31 +03:00
|
|
|
using MethodCallResult = folly::Optional<folly::dynamic>;
|
2017-06-24 02:49:55 +03:00
|
|
|
|
2016-05-04 05:29:58 +03:00
|
|
|
class NativeModule {
|
|
|
|
public:
|
|
|
|
virtual ~NativeModule() {}
|
|
|
|
virtual std::string getName() = 0;
|
2020-05-14 06:24:37 +03:00
|
|
|
virtual std::string getSyncMethodName(unsigned int methodId) = 0;
|
2016-05-04 05:29:58 +03:00
|
|
|
virtual std::vector<MethodDescriptor> getMethods() = 0;
|
|
|
|
virtual folly::dynamic getConstants() = 0;
|
2020-02-26 06:50:31 +03:00
|
|
|
virtual void
|
|
|
|
invoke(unsigned int reactMethodId, folly::dynamic &¶ms, int callId) = 0;
|
|
|
|
virtual MethodCallResult callSerializableNativeHook(
|
|
|
|
unsigned int reactMethodId,
|
|
|
|
folly::dynamic &&args) = 0;
|
2016-05-04 05:29:58 +03:00
|
|
|
};
|
|
|
|
|
2020-02-26 06:50:31 +03:00
|
|
|
} // namespace react
|
|
|
|
} // namespace facebook
|