-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add the V8 Inspector api #49
Conversation
Adds a module called "inspector.rs" with corresponding relevant structures. 1. Changes ordinary comments to be doc-comments on the C bindings. 2. Corrects the naming of C binding functions to follow the convention. 3. Makes the tests work and pass. 4. Uses the logging facility. 5. Updates the dependencies. 6. Removes comments. 7. Refactors the code a little.
Split into more stages: building the server, accepting the first connection and the main loop.
8cac4a3
to
7612f7e
Compare
/// Returns a raw pointer to the isolate. | ||
pub fn get_raw_isolate(&self) -> *mut v8_isolate { | ||
self.isolate.get_raw() | ||
} | ||
|
||
/// Creates a new [V8IsolateScope] (or "restores it") with an | ||
/// already existing storage for the scopes. | ||
/// The storage provided must have been created precisely for the | ||
/// isolate passed. | ||
pub fn restore(isolate: &'isolate V8Isolate, storage: V8IsolateScopeStorage) -> Option<Self> { | ||
if !storage.is_same_isolate(isolate) { | ||
None | ||
} else { | ||
Some(Self { isolate, storage }) | ||
} | ||
} | ||
|
||
/// Forgets about the isolate and handlers scopes, so that those | ||
/// aren't deleted in destructor. Returns the storage object created | ||
/// for this [V8IsolateScope], so that it is still possible to | ||
/// restore later. | ||
pub fn forget(&mut self) -> V8IsolateScopeStorage { | ||
std::mem::take(&mut self.storage) | ||
} | ||
|
||
/// Returns `true` if the scopes are left uninitialised. | ||
pub fn is_forgotten(&self) -> bool { | ||
self.storage.is_uninitialised() | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These were useful in some places, but now probably aren't. @MeirShpilraien what do you think?
impl<'isolate_scope, 'isolate> From<&V8LocalString<'isolate_scope, 'isolate>> for String { | ||
fn from(value: &V8LocalString<'isolate_scope, 'isolate>) -> Self { | ||
let mut string = String::default(); | ||
let string_ptr = &mut string as *mut String as _; | ||
unsafe { | ||
crate::v8_c_raw::bindings::v8_GetStringValueWithCallback( | ||
value.inner_string, | ||
Some(convert_c_string_to_rust), | ||
string_ptr, | ||
) | ||
}; | ||
string | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TODO: there, IIRC, was another, easier way to do that. @MeirShpilraien Can you remind me, please?
Cargo.toml
Outdated
@@ -7,9 +7,14 @@ license = "Redis Source Available License 2.0 (RSALv2) or the Server Side Public | |||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html | |||
|
|||
[dependencies] | |||
tungstenite = { version = "0.20", optional = true } | |||
log = "0.4" | |||
serde = { version = "1", features = ["derive"] } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lets pin serde version?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indeed, will do!
#[cfg(test)] | ||
mod json_path_tests { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you explain all those tests changes? Are those just cosmetic or is there any fundamental change here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just purely cosmetic, we discussed these changes two months ago in slack :-)
/// The error subset of dispatch codes of the v8 inspector protocol. A | ||
/// copy from the "dispatch.h" header file. | ||
#[derive(Debug, Copy, Clone)] | ||
pub enum ErrorCode { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can this be auto generated somehow? Otherwise we will need to maintain it each time it changes, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Surely we can use (probably, if it works well enough) bindgen for this. However, we would need the source code of V8, too, cuz this header isn't a part of the distributed headers of V8.
We decided to split this into smaller PRs. The first one: #50 |
Adds the Inspector API and the tools helpful to work with it.