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
6fa76841ce
commit
96e202505f
8 changed files with 40 additions and 36 deletions
4
.vscode/settings.json
vendored
4
.vscode/settings.json
vendored
|
@ -119,5 +119,7 @@
|
|||
"propagate_const": "cpp",
|
||||
"span": "cpp",
|
||||
"*.ipp": "cpp"
|
||||
}
|
||||
},
|
||||
"rust.cfg_test": true,
|
||||
"rust.clippy_preference": "on"
|
||||
}
|
|
@ -1,3 +1,4 @@
|
|||
#![warn(clippy::all)]
|
||||
#![allow(dead_code)]
|
||||
#![allow(non_snake_case)]
|
||||
|
||||
|
|
|
@ -63,7 +63,9 @@ where
|
|||
T: Delete,
|
||||
{
|
||||
fn drop(&mut self) {
|
||||
self.0.take().map(Delete::delete);
|
||||
if let Some(v) = self.0.take() {
|
||||
Delete::delete(v)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -39,7 +39,7 @@ pub unsafe extern "C" fn v8_inspector__V8Inspector__Channel__BASE__sendResponse(
|
|||
this: &mut Channel,
|
||||
callId: int,
|
||||
message: UniquePtr<StringBuffer>,
|
||||
) -> () {
|
||||
) {
|
||||
ChannelBase::dispatch_mut(this).sendResponse(callId, message)
|
||||
}
|
||||
|
||||
|
@ -47,14 +47,14 @@ pub unsafe extern "C" fn v8_inspector__V8Inspector__Channel__BASE__sendResponse(
|
|||
pub unsafe extern "C" fn v8_inspector__V8Inspector__Channel__BASE__sendNotification(
|
||||
this: &mut Channel,
|
||||
message: UniquePtr<StringBuffer>,
|
||||
) -> () {
|
||||
) {
|
||||
ChannelBase::dispatch_mut(this).sendNotification(message)
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub unsafe extern "C" fn v8_inspector__V8Inspector__Channel__BASE__flushProtocolNotifications(
|
||||
this: &mut Channel,
|
||||
) -> () {
|
||||
) {
|
||||
ChannelBase::dispatch_mut(this).flushProtocolNotifications()
|
||||
}
|
||||
|
||||
|
@ -68,17 +68,17 @@ impl Channel {
|
|||
&mut self,
|
||||
callId: int,
|
||||
message: UniquePtr<StringBuffer>,
|
||||
) -> () {
|
||||
) {
|
||||
unsafe {
|
||||
v8_inspector__V8Inspector__Channel__sendResponse(self, callId, message)
|
||||
}
|
||||
}
|
||||
pub fn sendNotification(&mut self, message: UniquePtr<StringBuffer>) -> () {
|
||||
pub fn sendNotification(&mut self, message: UniquePtr<StringBuffer>) {
|
||||
unsafe {
|
||||
v8_inspector__V8Inspector__Channel__sendNotification(self, message)
|
||||
}
|
||||
}
|
||||
pub fn flushProtocolNotifications(&mut self) -> () {
|
||||
pub fn flushProtocolNotifications(&mut self) {
|
||||
unsafe {
|
||||
v8_inspector__V8Inspector__Channel__flushProtocolNotifications(self)
|
||||
}
|
||||
|
|
|
@ -88,14 +88,14 @@ extern "C" {
|
|||
pub unsafe extern "C" fn v8_inspector__V8InspectorClient__BASE__runMessageLoopOnPause(
|
||||
this: &mut Client,
|
||||
contextGroupId: int,
|
||||
) -> () {
|
||||
) {
|
||||
ClientBase::dispatch_mut(this).runMessageLoopOnPause(contextGroupId)
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub unsafe extern "C" fn v8_inspector__V8InspectorClient__BASE__quitMessageLoopOnPause(
|
||||
this: &mut Client,
|
||||
) -> () {
|
||||
) {
|
||||
ClientBase::dispatch_mut(this).quitMessageLoopOnPause()
|
||||
}
|
||||
|
||||
|
@ -103,7 +103,7 @@ pub unsafe extern "C" fn v8_inspector__V8InspectorClient__BASE__quitMessageLoopO
|
|||
pub unsafe extern "C" fn v8_inspector__V8InspectorClient__BASE__runIfWaitingForDebugger(
|
||||
this: &mut Client,
|
||||
contextGroupId: int,
|
||||
) -> () {
|
||||
) {
|
||||
ClientBase::dispatch_mut(this).runIfWaitingForDebugger(contextGroupId)
|
||||
}
|
||||
|
||||
|
@ -113,7 +113,7 @@ pub struct Client {
|
|||
}
|
||||
|
||||
impl Client {
|
||||
pub fn runMessageLoopOnPause(&mut self, contextGroupId: int) -> () {
|
||||
pub fn runMessageLoopOnPause(&mut self, contextGroupId: int) {
|
||||
unsafe {
|
||||
v8_inspector__V8InspectorClient__runMessageLoopOnPause(
|
||||
self,
|
||||
|
@ -121,10 +121,10 @@ impl Client {
|
|||
)
|
||||
}
|
||||
}
|
||||
pub fn quitMessageLoopOnPause(&mut self) -> () {
|
||||
pub fn quitMessageLoopOnPause(&mut self) {
|
||||
unsafe { v8_inspector__V8InspectorClient__quitMessageLoopOnPause(self) }
|
||||
}
|
||||
pub fn runIfWaitingForDebugger(&mut self, contextGroupId: int) -> () {
|
||||
pub fn runIfWaitingForDebugger(&mut self, contextGroupId: int) {
|
||||
unsafe {
|
||||
v8_inspector__V8InspectorClient__runIfWaitingForDebugger(
|
||||
self,
|
||||
|
@ -165,9 +165,9 @@ pub trait ClientImpl: AsClient {
|
|||
fn base(&self) -> &ClientBase;
|
||||
fn base_mut(&mut self) -> &mut ClientBase;
|
||||
|
||||
fn runMessageLoopOnPause(&mut self, contextGroupId: int) -> () {}
|
||||
fn quitMessageLoopOnPause(&mut self) -> () {}
|
||||
fn runIfWaitingForDebugger(&mut self, contextGroupId: int) -> () {}
|
||||
fn runMessageLoopOnPause(&mut self, contextGroupId: int) {}
|
||||
fn quitMessageLoopOnPause(&mut self) {}
|
||||
fn runIfWaitingForDebugger(&mut self, contextGroupId: int) {}
|
||||
}
|
||||
|
||||
pub struct ClientBase {
|
||||
|
|
|
@ -21,12 +21,12 @@ extern "C" {
|
|||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub unsafe extern "C" fn v8__Task__BASE__DELETE(this: &mut Task) -> () {
|
||||
pub unsafe extern "C" fn v8__Task__BASE__DELETE(this: &mut Task) {
|
||||
drop(TaskBase::dispatch_box(this))
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub unsafe extern "C" fn v8__Task__BASE__Run(this: &mut Task) -> () {
|
||||
pub unsafe extern "C" fn v8__Task__BASE__Run(this: &mut Task) {
|
||||
TaskBase::dispatch_mut(this).Run()
|
||||
}
|
||||
|
||||
|
@ -36,7 +36,7 @@ pub struct Task {
|
|||
}
|
||||
|
||||
impl Task {
|
||||
pub fn Run(&mut self) -> () {
|
||||
pub fn Run(&mut self) {
|
||||
unsafe { v8__Task__Run(self) }
|
||||
}
|
||||
}
|
||||
|
@ -161,6 +161,7 @@ impl TaskBase {
|
|||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use std::sync::atomic::AtomicUsize;
|
||||
|
@ -172,7 +173,7 @@ mod tests {
|
|||
// Using repr(C) to preserve field ordering and test that everything works
|
||||
// when the TaskBase field is not the first element of the struct.
|
||||
#[repr(C)]
|
||||
pub struct TestTask {
|
||||
struct TestTask {
|
||||
field1: i32,
|
||||
base: TaskBase,
|
||||
field2: f64,
|
||||
|
@ -195,7 +196,7 @@ mod tests {
|
|||
fn base_mut(&mut self) -> &mut TaskBase {
|
||||
&mut self.base
|
||||
}
|
||||
fn Run(&mut self) -> () {
|
||||
fn Run(&mut self) {
|
||||
RUN_COUNT.fetch_add(1, SeqCst);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -44,6 +44,7 @@ impl Delete for StringBuffer {
|
|||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
|
@ -51,17 +52,15 @@ mod tests {
|
|||
fn test_string_buffer() {
|
||||
let chars = b"Hello Venus!";
|
||||
let mut buf = {
|
||||
let view1 = StringView::from(&chars[..]);
|
||||
StringBuffer::create(&view1)
|
||||
let src_view = StringView::from(&chars[..]);
|
||||
StringBuffer::create(&src_view)
|
||||
};
|
||||
let view2 = buf.as_mut().unwrap().string();
|
||||
let view = buf.as_mut().unwrap().string();
|
||||
|
||||
let mut count = 0usize;
|
||||
for (c1, c2) in chars.iter().copied().map(|c| c as u16).zip(view2) {
|
||||
assert_eq!(chars.len(), view.into_iter().len());
|
||||
assert_eq!(chars.len(), view.length());
|
||||
for (c1, c2) in chars.iter().copied().map(u16::from).zip(view) {
|
||||
assert_eq!(c1, c2);
|
||||
count += 1;
|
||||
}
|
||||
assert_eq!(count, chars.len());
|
||||
assert_eq!(count, view2.length());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -176,7 +176,7 @@ impl<'a: 'b, 'b> Iterator for StringViewIterator<'a, 'b> {
|
|||
fn next(&mut self) -> Option<Self::Item> {
|
||||
let result = Some(match self.view {
|
||||
StringView::U16(v) => v.get_at(self.pos)?,
|
||||
StringView::U8(v) => v.get_at(self.pos)? as u16,
|
||||
StringView::U8(v) => u16::from(v.get_at(self.pos)?),
|
||||
});
|
||||
self.pos += 1;
|
||||
result
|
||||
|
@ -189,6 +189,7 @@ impl<'a: 'b, 'b> ExactSizeIterator for StringViewIterator<'a, 'b> {
|
|||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
|
@ -197,12 +198,10 @@ mod tests {
|
|||
let chars = b"Hello world!";
|
||||
let view = StringView::from(&chars[..]);
|
||||
|
||||
let mut count = 0usize;
|
||||
for (c1, c2) in chars.iter().copied().map(|c| c as u16).zip(&view) {
|
||||
assert_eq!(chars.len(), view.into_iter().len());
|
||||
assert_eq!(chars.len(), view.length());
|
||||
for (c1, c2) in chars.iter().copied().map(u16::from).zip(&view) {
|
||||
assert_eq!(c1, c2);
|
||||
count += 1;
|
||||
}
|
||||
assert_eq!(count, chars.len());
|
||||
assert_eq!(count, view.length());
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue