mirror of
https://github.com/denoland/rusty_v8.git
synced 2024-12-25 08:39:15 -05:00
Move StringBuffer and StringView into inspector namespace
This commit is contained in:
parent
3925b8122c
commit
d94117882a
8 changed files with 38 additions and 51 deletions
2
BUILD.gn
2
BUILD.gn
|
@ -8,13 +8,13 @@ v8_static_library("rusty_v8") {
|
|||
"src/handle_scope.cc",
|
||||
"src/inspector/channel.cc",
|
||||
"src/inspector/client.cc",
|
||||
"src/inspector/string_buffer.cc",
|
||||
"src/isolate.cc",
|
||||
"src/locker.cc",
|
||||
"src/number.cc",
|
||||
"src/platform/mod.cc",
|
||||
"src/platform/task.cc",
|
||||
"src/string.cc",
|
||||
"src/string_buffer.cc",
|
||||
]
|
||||
deps = [
|
||||
":v8",
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
use super::*;
|
||||
use crate::support::int;
|
||||
use crate::support::CxxVTable;
|
||||
use crate::support::FieldOffset;
|
||||
use crate::support::Opaque;
|
||||
use crate::support::RustVTable;
|
||||
use crate::support::UniquePtr;
|
||||
use crate::StringBuffer;
|
||||
|
||||
// class Channel {
|
||||
// public:
|
||||
|
@ -196,8 +196,6 @@ impl ChannelBase {
|
|||
mod tests {
|
||||
use super::*;
|
||||
use crate::support::UniquePtr;
|
||||
use crate::StringView;
|
||||
use crate::*;
|
||||
use std::sync::atomic::AtomicUsize;
|
||||
use std::sync::atomic::Ordering::SeqCst;
|
||||
|
||||
|
|
|
@ -1,5 +1,9 @@
|
|||
pub mod channel;
|
||||
pub mod client;
|
||||
mod channel;
|
||||
mod client;
|
||||
mod string_buffer;
|
||||
mod string_view;
|
||||
|
||||
pub use channel::Channel;
|
||||
pub use client::Client;
|
||||
pub use string_buffer::StringBuffer;
|
||||
pub use string_view::StringView;
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
#include "v8/include/v8-inspector.h"
|
||||
#include "support.h"
|
||||
|
||||
using namespace v8_inspector;
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
use super::string_view::StringView;
|
||||
use crate::support::CxxVTable;
|
||||
use crate::support::Delete;
|
||||
use crate::support::UniquePtr;
|
||||
use crate::StringView;
|
||||
|
||||
// class StringBuffer {
|
||||
// public:
|
||||
|
@ -53,24 +53,3 @@ impl Delete for StringBuffer {
|
|||
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);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -197,20 +197,3 @@ impl<'a: 'b, 'b> ExactSizeIterator for StringViewIterator<'a, 'b> {
|
|||
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);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -12,17 +12,15 @@ extern crate lazy_static;
|
|||
extern crate libc;
|
||||
|
||||
mod handle_scope;
|
||||
mod inspector;
|
||||
mod isolate;
|
||||
mod local;
|
||||
mod locker;
|
||||
mod number;
|
||||
mod string;
|
||||
mod string_buffer;
|
||||
mod string_view;
|
||||
mod support;
|
||||
|
||||
pub mod array_buffer;
|
||||
pub mod inspector;
|
||||
pub mod platform;
|
||||
// This module is intentionally named "V8" rather than "v8" to match the
|
||||
// C++ namespace "v8::V8".
|
||||
|
@ -36,5 +34,3 @@ pub use locker::Locker;
|
|||
pub use number::{Integer, Number};
|
||||
pub use string::NewStringType;
|
||||
pub use string::String;
|
||||
pub use string_buffer::StringBuffer;
|
||||
pub use string_view::StringView;
|
||||
|
|
|
@ -121,3 +121,31 @@ fn set_flags_from_command_line() {
|
|||
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);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue