diff --git a/BUILD.gn b/BUILD.gn index bca1e075..d6eb5e51 100644 --- a/BUILD.gn +++ b/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", diff --git a/src/inspector/channel.rs b/src/inspector/channel.rs index 2bb55277..e52c7230 100644 --- a/src/inspector/channel.rs +++ b/src/inspector/channel.rs @@ -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; diff --git a/src/inspector/mod.rs b/src/inspector/mod.rs index 2e093f7c..bb70184c 100644 --- a/src/inspector/mod.rs +++ b/src/inspector/mod.rs @@ -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; diff --git a/src/string_buffer.cc b/src/inspector/string_buffer.cc similarity index 94% rename from src/string_buffer.cc rename to src/inspector/string_buffer.cc index 8a5a5b4b..8673c9d1 100644 --- a/src/string_buffer.cc +++ b/src/inspector/string_buffer.cc @@ -1,5 +1,4 @@ #include "v8/include/v8-inspector.h" -#include "support.h" using namespace v8_inspector; diff --git a/src/string_buffer.rs b/src/inspector/string_buffer.rs similarity index 77% rename from src/string_buffer.rs rename to src/inspector/string_buffer.rs index 2034cd80..7dc4a3e4 100644 --- a/src/string_buffer.rs +++ b/src/inspector/string_buffer.rs @@ -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); - } - } -} diff --git a/src/string_view.rs b/src/inspector/string_view.rs similarity index 92% rename from src/string_view.rs rename to src/inspector/string_view.rs index 8ce63696..9ce590c8 100644 --- a/src/string_view.rs +++ b/src/inspector/string_view.rs @@ -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); - } - } -} diff --git a/src/lib.rs b/src/lib.rs index bfb9fb9f..e0596d3d 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -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; diff --git a/tests/test_api.rs b/tests/test_api.rs index 354a2c26..c4c4ad30 100644 --- a/tests/test_api.rs +++ b/tests/test_api.rs @@ -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); + } +}