mirror of
https://github.com/denoland/rusty_v8.git
synced 2024-11-21 15:04:33 -05:00
wip
This commit is contained in:
parent
1e3f137cc2
commit
0e86101ed9
13 changed files with 46 additions and 45 deletions
3
.vscode/settings.json
vendored
3
.vscode/settings.json
vendored
|
@ -2,6 +2,7 @@
|
||||||
"C_Cpp.clang_format_style": "Chromium",
|
"C_Cpp.clang_format_style": "Chromium",
|
||||||
"files.associations": {
|
"files.associations": {
|
||||||
"memory": "cpp",
|
"memory": "cpp",
|
||||||
"vector": "cpp"
|
"vector": "cpp",
|
||||||
|
"cctype": "cpp"
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -7,6 +7,7 @@
|
||||||
#include <utility>
|
#include <utility>
|
||||||
|
|
||||||
#include "../goog/v8/include/v8-inspector.h"
|
#include "../goog/v8/include/v8-inspector.h"
|
||||||
|
#include "../goog/v8/include/v8.h"
|
||||||
|
|
||||||
template <class T>
|
template <class T>
|
||||||
using uninit_t = typename std::aligned_storage<sizeof(T), alignof(T)>::type;
|
using uninit_t = typename std::aligned_storage<sizeof(T), alignof(T)>::type;
|
||||||
|
@ -17,6 +18,6 @@ auto launder(T ptr) {
|
||||||
return ptr;
|
return ptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
#include "v8_inspector/channel.h"
|
#include "v8/inspector/channel.h"
|
||||||
#include "v8_inspector/client.h"
|
#include "v8/inspector/client.h"
|
||||||
#include "v8_inspector/string_buffer.h"
|
#include "v8/string_buffer.h"
|
||||||
|
|
22
src/main.rs
22
src/main.rs
|
@ -1,26 +1,26 @@
|
||||||
#![allow(dead_code)]
|
#![allow(dead_code)]
|
||||||
#![allow(non_snake_case)]
|
#![allow(non_snake_case)]
|
||||||
|
|
||||||
mod cxx_util;
|
mod support;
|
||||||
mod v8_inspector;
|
mod v8;
|
||||||
|
|
||||||
mod example {
|
mod example {
|
||||||
use crate::cxx_util::UniquePtr;
|
use crate::support::UniquePtr;
|
||||||
use crate::v8_inspector::channel::*;
|
use crate::v8::inspector::channel::*;
|
||||||
use crate::v8_inspector::*;
|
use crate::v8::*;
|
||||||
|
|
||||||
pub struct Example {
|
pub struct Example {
|
||||||
a: i32,
|
a: i32,
|
||||||
channel_extender: ChannelBase,
|
channel_base: ChannelBase,
|
||||||
b: i32,
|
b: i32,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ChannelImpl for Example {
|
impl ChannelImpl for Example {
|
||||||
fn base(&self) -> &ChannelBase {
|
fn base(&self) -> &ChannelBase {
|
||||||
&self.channel_extender
|
&self.channel_base
|
||||||
}
|
}
|
||||||
fn base_mut(&mut self) -> &mut ChannelBase {
|
fn base_mut(&mut self) -> &mut ChannelBase {
|
||||||
&mut self.channel_extender
|
&mut self.channel_base
|
||||||
}
|
}
|
||||||
fn sendResponse(
|
fn sendResponse(
|
||||||
&mut self,
|
&mut self,
|
||||||
|
@ -40,7 +40,7 @@ mod example {
|
||||||
impl Example {
|
impl Example {
|
||||||
pub fn new() -> Self {
|
pub fn new() -> Self {
|
||||||
Self {
|
Self {
|
||||||
channel_extender: ChannelBase::new::<Self>(),
|
channel_base: ChannelBase::new::<Self>(),
|
||||||
a: 2,
|
a: 2,
|
||||||
b: 3,
|
b: 3,
|
||||||
}
|
}
|
||||||
|
@ -49,8 +49,8 @@ mod example {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
use crate::v8_inspector::channel::*;
|
use crate::v8::inspector::channel::*;
|
||||||
use crate::v8_inspector::*;
|
use crate::v8::*;
|
||||||
use example::*;
|
use example::*;
|
||||||
let mut ex = Example::new();
|
let mut ex = Example::new();
|
||||||
let chan = ex.as_channel_mut();
|
let chan = ex.as_channel_mut();
|
||||||
|
|
|
@ -96,6 +96,7 @@ pub struct FieldOffset<F>(usize, PhantomData<F>);
|
||||||
|
|
||||||
unsafe impl<F> Send for FieldOffset<F> where F: Send {}
|
unsafe impl<F> Send for FieldOffset<F> where F: Send {}
|
||||||
unsafe impl<F> Sync for FieldOffset<F> where F: Sync {}
|
unsafe impl<F> Sync for FieldOffset<F> where F: Sync {}
|
||||||
|
|
||||||
impl<F> Copy for FieldOffset<F> {}
|
impl<F> Copy for FieldOffset<F> {}
|
||||||
|
|
||||||
impl<F> Clone for FieldOffset<F> {
|
impl<F> Clone for FieldOffset<F> {
|
|
@ -1,11 +1,10 @@
|
||||||
use crate::cxx_util::int;
|
use crate::support::int;
|
||||||
use crate::cxx_util::CxxVTable;
|
use crate::support::CxxVTable;
|
||||||
use crate::cxx_util::FieldOffset;
|
use crate::support::FieldOffset;
|
||||||
use crate::cxx_util::Opaque;
|
use crate::support::Opaque;
|
||||||
use crate::cxx_util::RustVTable;
|
use crate::support::RustVTable;
|
||||||
use crate::cxx_util::UniquePtr;
|
use crate::support::UniquePtr;
|
||||||
|
use crate::v8::StringBuffer;
|
||||||
use super::StringBuffer;
|
|
||||||
|
|
||||||
// class Channel {
|
// class Channel {
|
||||||
// public:
|
// public:
|
|
@ -1,8 +1,8 @@
|
||||||
use crate::cxx_util::int;
|
use crate::support::int;
|
||||||
use crate::cxx_util::CxxVTable;
|
use crate::support::CxxVTable;
|
||||||
use crate::cxx_util::FieldOffset;
|
use crate::support::FieldOffset;
|
||||||
use crate::cxx_util::Opaque;
|
use crate::support::Opaque;
|
||||||
use crate::cxx_util::RustVTable;
|
use crate::support::RustVTable;
|
||||||
|
|
||||||
// class V8InspectorClient {
|
// class V8InspectorClient {
|
||||||
// public:
|
// public:
|
5
src/v8/inspector/mod.rs
Normal file
5
src/v8/inspector/mod.rs
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
pub mod channel;
|
||||||
|
pub mod client;
|
||||||
|
|
||||||
|
pub use channel::Channel;
|
||||||
|
pub use client::Client;
|
|
@ -1,9 +1,6 @@
|
||||||
pub mod channel;
|
pub mod inspector;
|
||||||
pub mod client;
|
|
||||||
pub mod string_buffer;
|
pub mod string_buffer;
|
||||||
pub mod string_view;
|
pub mod string_view;
|
||||||
|
|
||||||
pub use channel::Channel;
|
|
||||||
pub use client::Client;
|
|
||||||
pub use string_buffer::StringBuffer;
|
pub use string_buffer::StringBuffer;
|
||||||
pub use string_view::StringView;
|
pub use string_view::StringView;
|
|
@ -1,10 +1,9 @@
|
||||||
use crate::cxx_util::CxxVTable;
|
use crate::support::CxxVTable;
|
||||||
use crate::cxx_util::Delete;
|
use crate::support::Delete;
|
||||||
use crate::cxx_util::UniquePtr;
|
use crate::support::UniquePtr;
|
||||||
|
use crate::v8::StringView;
|
||||||
|
|
||||||
use super::StringView;
|
// class StringBuffer {
|
||||||
|
|
||||||
// class V8_EXPORT StringBuffer {
|
|
||||||
// public:
|
// public:
|
||||||
// virtual ~StringBuffer() = default;
|
// virtual ~StringBuffer() = default;
|
||||||
// virtual const StringView& string() = 0;
|
// virtual const StringView& string() = 0;
|
|
@ -4,12 +4,6 @@ use std::ptr::null;
|
||||||
use std::ptr::NonNull;
|
use std::ptr::NonNull;
|
||||||
use std::slice;
|
use std::slice;
|
||||||
|
|
||||||
// Notes:
|
|
||||||
// * This class is ported, not wrapped using bindings.
|
|
||||||
// * Since Rust `repr(bool)` is not allowed, assume `bool` and `u8` have the
|
|
||||||
// same size. TODO: find/open upstream issue to allow #[repr(bool)] support.
|
|
||||||
|
|
||||||
// ```cpp
|
|
||||||
// class StringView {
|
// class StringView {
|
||||||
// public:
|
// public:
|
||||||
// StringView() : m_is8Bit(true), m_length(0), m_characters8(nullptr) {}
|
// StringView() : m_is8Bit(true), m_length(0), m_characters8(nullptr) {}
|
||||||
|
@ -34,7 +28,11 @@ use std::slice;
|
||||||
// const uint16_t* m_characters16;
|
// const uint16_t* m_characters16;
|
||||||
// };
|
// };
|
||||||
// };
|
// };
|
||||||
// ```
|
|
||||||
|
// Notes:
|
||||||
|
// * This class is ported, not wrapped using bindings.
|
||||||
|
// * Since Rust `repr(bool)` is not allowed, assume `bool` and `u8` have the
|
||||||
|
// same size. TODO: find/open upstream issue to allow #[repr(bool)] support.
|
||||||
|
|
||||||
#[repr(u8)]
|
#[repr(u8)]
|
||||||
#[derive(Copy, Clone, Debug)]
|
#[derive(Copy, Clone, Debug)]
|
Loading…
Reference in a new issue