mirror of
https://github.com/denoland/rusty_v8.git
synced 2025-01-11 08:34:01 -05:00
wip
This commit is contained in:
parent
0e86101ed9
commit
6a24523334
8 changed files with 155 additions and 34 deletions
117
.vscode/settings.json
vendored
117
.vscode/settings.json
vendored
|
@ -3,6 +3,121 @@
|
|||
"files.associations": {
|
||||
"memory": "cpp",
|
||||
"vector": "cpp",
|
||||
"cctype": "cpp"
|
||||
"cctype": "cpp",
|
||||
"algorithm": "cpp",
|
||||
"any": "cpp",
|
||||
"array": "cpp",
|
||||
"atomic": "cpp",
|
||||
"bitset": "cpp",
|
||||
"cfenv": "cpp",
|
||||
"charconv": "cpp",
|
||||
"chrono": "cpp",
|
||||
"cinttypes": "cpp",
|
||||
"clocale": "cpp",
|
||||
"cmath": "cpp",
|
||||
"codecvt": "cpp",
|
||||
"complex": "cpp",
|
||||
"condition_variable": "cpp",
|
||||
"csetjmp": "cpp",
|
||||
"csignal": "cpp",
|
||||
"cstdarg": "cpp",
|
||||
"cstddef": "cpp",
|
||||
"cstdint": "cpp",
|
||||
"cstdio": "cpp",
|
||||
"cstdlib": "cpp",
|
||||
"cstring": "cpp",
|
||||
"ctime": "cpp",
|
||||
"cuchar": "cpp",
|
||||
"cwchar": "cpp",
|
||||
"cwctype": "cpp",
|
||||
"deque": "cpp",
|
||||
"exception": "cpp",
|
||||
"filesystem": "cpp",
|
||||
"forward_list": "cpp",
|
||||
"fstream": "cpp",
|
||||
"functional": "cpp",
|
||||
"future": "cpp",
|
||||
"initializer_list": "cpp",
|
||||
"iomanip": "cpp",
|
||||
"ios": "cpp",
|
||||
"iosfwd": "cpp",
|
||||
"iostream": "cpp",
|
||||
"istream": "cpp",
|
||||
"iterator": "cpp",
|
||||
"limits": "cpp",
|
||||
"list": "cpp",
|
||||
"locale": "cpp",
|
||||
"map": "cpp",
|
||||
"mutex": "cpp",
|
||||
"new": "cpp",
|
||||
"numeric": "cpp",
|
||||
"optional": "cpp",
|
||||
"ostream": "cpp",
|
||||
"queue": "cpp",
|
||||
"random": "cpp",
|
||||
"ratio": "cpp",
|
||||
"regex": "cpp",
|
||||
"scoped_allocator": "cpp",
|
||||
"set": "cpp",
|
||||
"shared_mutex": "cpp",
|
||||
"sstream": "cpp",
|
||||
"stack": "cpp",
|
||||
"stdexcept": "cpp",
|
||||
"streambuf": "cpp",
|
||||
"string": "cpp",
|
||||
"string_view": "cpp",
|
||||
"strstream": "cpp",
|
||||
"system_error": "cpp",
|
||||
"xthread": "cpp",
|
||||
"thread": "cpp",
|
||||
"tuple": "cpp",
|
||||
"type_traits": "cpp",
|
||||
"typeindex": "cpp",
|
||||
"typeinfo": "cpp",
|
||||
"unordered_map": "cpp",
|
||||
"unordered_set": "cpp",
|
||||
"utility": "cpp",
|
||||
"valarray": "cpp",
|
||||
"variant": "cpp",
|
||||
"xfacet": "cpp",
|
||||
"xhash": "cpp",
|
||||
"xiosbase": "cpp",
|
||||
"xlocale": "cpp",
|
||||
"xlocbuf": "cpp",
|
||||
"xlocinfo": "cpp",
|
||||
"xlocmes": "cpp",
|
||||
"xlocmon": "cpp",
|
||||
"xlocnum": "cpp",
|
||||
"xloctime": "cpp",
|
||||
"xmemory": "cpp",
|
||||
"xmemory0": "cpp",
|
||||
"xstddef": "cpp",
|
||||
"xstring": "cpp",
|
||||
"xtr1common": "cpp",
|
||||
"xtree": "cpp",
|
||||
"xutility": "cpp",
|
||||
"__bit_reference": "cpp",
|
||||
"__config": "cpp",
|
||||
"__debug": "cpp",
|
||||
"__errc": "cpp",
|
||||
"__functional_base": "cpp",
|
||||
"__hash_table": "cpp",
|
||||
"__locale": "cpp",
|
||||
"__mutex_base": "cpp",
|
||||
"__node_handle": "cpp",
|
||||
"__nullptr": "cpp",
|
||||
"__split_buffer": "cpp",
|
||||
"__sso_allocator": "cpp",
|
||||
"__std_stream": "cpp",
|
||||
"__string": "cpp",
|
||||
"__threading_support": "cpp",
|
||||
"__tree": "cpp",
|
||||
"__tuple": "cpp",
|
||||
"bit": "cpp",
|
||||
"compare": "cpp",
|
||||
"coroutine": "cpp",
|
||||
"propagate_const": "cpp",
|
||||
"span": "cpp",
|
||||
"*.ipp": "cpp"
|
||||
}
|
||||
}
|
4
build.rs
4
build.rs
|
@ -5,7 +5,9 @@ fn main() {
|
|||
.cpp(true)
|
||||
.flag("-std:c++17")
|
||||
.debug(true)
|
||||
.file("src/lib.cpp")
|
||||
.file("src/v8/inspector/channel.cpp")
|
||||
.file("src/v8/inspector/client.cpp")
|
||||
.file("src/v8/string_buffer.cpp")
|
||||
.compile("v8-bindings");
|
||||
|
||||
println!("cargo:rustc-link-lib=static=v8_monolith");
|
||||
|
|
23
src/lib.cpp
23
src/lib.cpp
|
@ -1,23 +0,0 @@
|
|||
|
||||
#include <cstdint>
|
||||
#include <iostream>
|
||||
#include <memory>
|
||||
#include <new>
|
||||
#include <type_traits>
|
||||
#include <utility>
|
||||
|
||||
#include "../goog/v8/include/v8-inspector.h"
|
||||
#include "../goog/v8/include/v8.h"
|
||||
|
||||
template <class T>
|
||||
using uninit_t = typename std::aligned_storage<sizeof(T), alignof(T)>::type;
|
||||
|
||||
// In C++17, this should be backed by std::launder().
|
||||
template <class T>
|
||||
auto launder(T ptr) {
|
||||
return ptr;
|
||||
}
|
||||
|
||||
#include "v8/inspector/channel.h"
|
||||
#include "v8/inspector/client.h"
|
||||
#include "v8/string_buffer.h"
|
24
src/support.h
Normal file
24
src/support.h
Normal file
|
@ -0,0 +1,24 @@
|
|||
#ifndef SUPPORT_H_
|
||||
#define SUPPORT_H_
|
||||
|
||||
#include <cassert>
|
||||
#include <memory>
|
||||
#include <new>
|
||||
#include <type_traits>
|
||||
#include <utility>
|
||||
|
||||
// Check assumptions made in binding code.
|
||||
static_assert(sizeof(bool) == sizeof(uint8_t));
|
||||
static_assert(sizeof(std::unique_ptr<void>) == sizeof(void*));
|
||||
|
||||
namespace support {
|
||||
template <class T>
|
||||
using uninit_t = typename std::aligned_storage<sizeof(T), alignof(T)>::type;
|
||||
|
||||
template <class T, class... Args>
|
||||
void construct_in_place(uninit_t<T>& buf, Args... args) {
|
||||
new (&buf) T(std::forward<Args>(args)...);
|
||||
}
|
||||
} // namespace support
|
||||
|
||||
#endif // SUPPORT_H_
|
|
@ -1,7 +1,8 @@
|
|||
#include <memory>
|
||||
#include <utility>
|
||||
#include "../../../v8/include/v8-inspector.h"
|
||||
#include "../../support.h"
|
||||
|
||||
using namespace v8_inspector;
|
||||
using namespace support;
|
||||
|
||||
extern "C" {
|
||||
void v8_inspector__V8Inspector__Channel__BASE__sendResponse(
|
||||
|
@ -18,8 +19,6 @@ void v8_inspector__V8Inspector__Channel__BASE__flushProtocolNotifications(
|
|||
namespace v8_inspector {
|
||||
struct V8Inspector__Channel__BASE : public V8Inspector::Channel {
|
||||
using V8Inspector::Channel::Channel;
|
||||
static_assert(sizeof(std::unique_ptr<StringBuffer>) == sizeof(StringBuffer*),
|
||||
"sizeof(T*) != sizeof(unique_ptr<T>)");
|
||||
|
||||
void sendResponse(int callId,
|
||||
std::unique_ptr<StringBuffer> message) override {
|
||||
|
@ -39,7 +38,7 @@ struct V8Inspector__Channel__BASE : public V8Inspector::Channel {
|
|||
extern "C" {
|
||||
void v8_inspector__V8Inspector__Channel__BASE__CTOR(
|
||||
uninit_t<V8Inspector__Channel__BASE>& buf) {
|
||||
new (launder(&buf)) V8Inspector__Channel__BASE();
|
||||
construct_in_place<V8Inspector__Channel__BASE>(buf);
|
||||
}
|
||||
void v8_inspector__V8Inspector__Channel__DTOR(V8Inspector::Channel& self) {
|
||||
self.~Channel();
|
|
@ -1,7 +1,8 @@
|
|||
#include <memory>
|
||||
#include <utility>
|
||||
#include "../../../v8/include/v8-inspector.h"
|
||||
#include "../../support.h"
|
||||
|
||||
using namespace v8_inspector;
|
||||
using namespace support;
|
||||
|
||||
extern "C" {
|
||||
void v8_inspector__V8InspectorClient__BASE__runMessageLoopOnPause(
|
||||
|
@ -35,7 +36,7 @@ struct Client__BASE : public V8InspectorClient {
|
|||
|
||||
extern "C" {
|
||||
void v8_inspector__V8InspectorClient__BASE__CTOR(uninit_t<Client__BASE>& buf) {
|
||||
new (launder(&buf)) Client__BASE();
|
||||
construct_in_place<Client__BASE>(buf);
|
||||
}
|
||||
void v8_inspector__V8InspectorClient__DTOR(V8InspectorClient& self) {
|
||||
self.~V8InspectorClient();
|
|
@ -1,7 +1,9 @@
|
|||
#include "../../v8/include/v8-inspector.h"
|
||||
#include "../support.h"
|
||||
|
||||
extern "C" {
|
||||
using namespace v8_inspector;
|
||||
|
||||
extern "C" {
|
||||
void v8_inspector__StringBuffer__DELETE(StringBuffer& self) {
|
||||
delete &self;
|
||||
}
|
1
v8
Symbolic link
1
v8
Symbolic link
|
@ -0,0 +1 @@
|
|||
goog/v8
|
Loading…
Reference in a new issue