2018-09-11 22:27:47 +00:00
|
|
|
// Copyright (c) Facebook, Inc. and its affiliates.
|
2018-05-31 22:31:03 +00:00
|
|
|
|
|
|
|
// 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 02:29:58 +00:00
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <string>
|
|
|
|
#include <vector>
|
|
|
|
|
2017-06-23 23:49:55 +00:00
|
|
|
#include <folly/Optional.h>
|
2017-05-13 00:57:12 +00:00
|
|
|
#include <folly/dynamic.h>
|
2016-05-04 02:29:58 +00: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)
|
|
|
|
: name(std::move(n))
|
|
|
|
, type(std::move(t)) {}
|
|
|
|
};
|
|
|
|
|
2017-06-23 23:49:55 +00:00
|
|
|
using MethodCallResult = folly::Optional<folly::dynamic>;
|
|
|
|
|
2016-05-04 02:29:58 +00:00
|
|
|
class NativeModule {
|
|
|
|
public:
|
|
|
|
virtual ~NativeModule() {}
|
|
|
|
virtual std::string getName() = 0;
|
|
|
|
virtual std::vector<MethodDescriptor> getMethods() = 0;
|
|
|
|
virtual folly::dynamic getConstants() = 0;
|
2017-05-13 00:57:12 +00:00
|
|
|
virtual void invoke(unsigned int reactMethodId, folly::dynamic&& params, int callId) = 0;
|
2017-04-25 12:29:45 +00:00
|
|
|
virtual MethodCallResult callSerializableNativeHook(unsigned int reactMethodId, folly::dynamic&& args) = 0;
|
2016-05-04 02:29:58 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|