Files
react-native/ReactCommon/hermes/inspector/chrome/MessageInterfaces.h
T
cpojer d7f5153cd8 Add Hermes support to React Native on Android (#25613)
Summary:
Yesterday we shipped hermesengine.dev as part of the current 0.60 release. This PR brings those changes to master.

## Changelog

[General] [Added] - Added support for Hermes
Pull Request resolved: https://github.com/facebook/react-native/pull/25613

Test Plan:
* CI is green both on GitHub and at FB
* Creating a new app from source can use Hermes on Android

Reviewed By: cpojer

Differential Revision: D16221777

Pulled By: willholen

fbshipit-source-id: aa6be10537863039cb666292465ba2e1d44b64ef
2019-07-25 23:05:53 -07:00

70 lines
1.7 KiB
C++

// Copyright 2004-present Facebook. All Rights Reserved.
#pragma once
#include <memory>
#include <string>
#include <unordered_map>
#include <folly/Try.h>
#include <folly/dynamic.h>
#include <folly/json.h>
namespace facebook {
namespace hermes {
namespace inspector {
namespace chrome {
namespace message {
struct RequestHandler;
/// Serializable is an interface for objects that can be serialized to and from
/// JSON.
struct Serializable {
virtual ~Serializable() = default;
virtual folly::dynamic toDynamic() const = 0;
std::string toJson() const {
return folly::toJson(toDynamic());
}
};
/// Requests are sent from the debugger to the target.
struct Request : public Serializable {
static std::unique_ptr<Request> fromJsonThrowOnError(const std::string &str);
static folly::Try<std::unique_ptr<Request>> fromJson(const std::string &str);
Request() = default;
explicit Request(std::string method) : method(method) {}
// accept dispatches to the appropriate handler method in RequestHandler based
// on the type of the request.
virtual void accept(RequestHandler &handler) const = 0;
int id = 0;
std::string method;
};
/// Responses are sent from the target to the debugger in response to a Request.
struct Response : public Serializable {
Response() = default;
int id = 0;
};
/// Notifications are sent from the target to the debugger. This is used to
/// notify the debugger about events that occur in the target, e.g. stopping
/// at a breakpoint.
struct Notification : public Serializable {
Notification() = default;
explicit Notification(std::string method) : method(method) {}
std::string method;
};
} // namespace message
} // namespace chrome
} // namespace inspector
} // namespace hermes
} // namespace facebook