0
0
Fork 0
mirror of https://github.com/denoland/rusty_v8.git synced 2024-11-21 15:04:33 -05:00

Move StringBuffer and StringView into inspector namespace

This commit is contained in:
Ryan Dahl 2019-12-04 10:31:54 -05:00 committed by Ry Dahl
parent 3925b8122c
commit d94117882a
8 changed files with 38 additions and 51 deletions

View file

@ -8,13 +8,13 @@ v8_static_library("rusty_v8") {
"src/handle_scope.cc", "src/handle_scope.cc",
"src/inspector/channel.cc", "src/inspector/channel.cc",
"src/inspector/client.cc", "src/inspector/client.cc",
"src/inspector/string_buffer.cc",
"src/isolate.cc", "src/isolate.cc",
"src/locker.cc", "src/locker.cc",
"src/number.cc", "src/number.cc",
"src/platform/mod.cc", "src/platform/mod.cc",
"src/platform/task.cc", "src/platform/task.cc",
"src/string.cc", "src/string.cc",
"src/string_buffer.cc",
] ]
deps = [ deps = [
":v8", ":v8",

View file

@ -1,10 +1,10 @@
use super::*;
use crate::support::int; use crate::support::int;
use crate::support::CxxVTable; use crate::support::CxxVTable;
use crate::support::FieldOffset; use crate::support::FieldOffset;
use crate::support::Opaque; use crate::support::Opaque;
use crate::support::RustVTable; use crate::support::RustVTable;
use crate::support::UniquePtr; use crate::support::UniquePtr;
use crate::StringBuffer;
// class Channel { // class Channel {
// public: // public:
@ -196,8 +196,6 @@ impl ChannelBase {
mod tests { mod tests {
use super::*; use super::*;
use crate::support::UniquePtr; use crate::support::UniquePtr;
use crate::StringView;
use crate::*;
use std::sync::atomic::AtomicUsize; use std::sync::atomic::AtomicUsize;
use std::sync::atomic::Ordering::SeqCst; use std::sync::atomic::Ordering::SeqCst;

View file

@ -1,5 +1,9 @@
pub mod channel; mod channel;
pub mod client; mod client;
mod string_buffer;
mod string_view;
pub use channel::Channel; pub use channel::Channel;
pub use client::Client; pub use client::Client;
pub use string_buffer::StringBuffer;
pub use string_view::StringView;

View file

@ -1,5 +1,4 @@
#include "v8/include/v8-inspector.h" #include "v8/include/v8-inspector.h"
#include "support.h"
using namespace v8_inspector; using namespace v8_inspector;

View file

@ -1,7 +1,7 @@
use super::string_view::StringView;
use crate::support::CxxVTable; use crate::support::CxxVTable;
use crate::support::Delete; use crate::support::Delete;
use crate::support::UniquePtr; use crate::support::UniquePtr;
use crate::StringView;
// class StringBuffer { // class StringBuffer {
// public: // public:
@ -53,24 +53,3 @@ impl Delete for StringBuffer {
unsafe { v8_inspector__StringBuffer__DELETE(self) } unsafe { v8_inspector__StringBuffer__DELETE(self) }
} }
} }
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_string_buffer() {
let chars = b"Hello Venus!";
let mut buf = {
let src_view = StringView::from(&chars[..]);
StringBuffer::create(&src_view)
};
let view = buf.as_mut().unwrap().string();
assert_eq!(chars.len(), view.into_iter().len());
assert_eq!(chars.len(), view.len());
for (c1, c2) in chars.iter().copied().map(u16::from).zip(view) {
assert_eq!(c1, c2);
}
}
}

View file

@ -197,20 +197,3 @@ impl<'a: 'b, 'b> ExactSizeIterator for StringViewIterator<'a, 'b> {
self.view.len() self.view.len()
} }
} }
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_string_view() {
let chars = b"Hello world!";
let view = StringView::from(&chars[..]);
assert_eq!(chars.len(), view.into_iter().len());
assert_eq!(chars.len(), view.len());
for (c1, c2) in chars.iter().copied().map(u16::from).zip(&view) {
assert_eq!(c1, c2);
}
}
}

View file

@ -12,17 +12,15 @@ extern crate lazy_static;
extern crate libc; extern crate libc;
mod handle_scope; mod handle_scope;
mod inspector;
mod isolate; mod isolate;
mod local; mod local;
mod locker; mod locker;
mod number; mod number;
mod string; mod string;
mod string_buffer;
mod string_view;
mod support; mod support;
pub mod array_buffer; pub mod array_buffer;
pub mod inspector;
pub mod platform; pub mod platform;
// This module is intentionally named "V8" rather than "v8" to match the // This module is intentionally named "V8" rather than "v8" to match the
// C++ namespace "v8::V8". // C++ namespace "v8::V8".
@ -36,5 +34,3 @@ pub use locker::Locker;
pub use number::{Integer, Number}; pub use number::{Integer, Number};
pub use string::NewStringType; pub use string::NewStringType;
pub use string::String; pub use string::String;
pub use string_buffer::StringBuffer;
pub use string_view::StringView;

View file

@ -121,3 +121,31 @@ fn set_flags_from_command_line() {
vec!["binaryname".to_string(), "--should-be-ignored".to_string()] vec!["binaryname".to_string(), "--should-be-ignored".to_string()]
); );
} }
#[test]
fn inspector_string_view() {
let chars = b"Hello world!";
let view = v8::inspector::StringView::from(&chars[..]);
assert_eq!(chars.len(), view.into_iter().len());
assert_eq!(chars.len(), view.len());
for (c1, c2) in chars.iter().copied().map(u16::from).zip(&view) {
assert_eq!(c1, c2);
}
}
#[test]
fn inspector_string_buffer() {
let chars = b"Hello Venus!";
let mut buf = {
let src_view = v8::inspector::StringView::from(&chars[..]);
v8::inspector::StringBuffer::create(&src_view)
};
let view = buf.as_mut().unwrap().string();
assert_eq!(chars.len(), view.into_iter().len());
assert_eq!(chars.len(), view.len());
for (c1, c2) in chars.iter().copied().map(u16::from).zip(view) {
assert_eq!(c1, c2);
}
}