Skip to content

Commit

Permalink
Perform a few minor fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
iddm committed Sep 4, 2023
1 parent 19fd711 commit a1995ee
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 30 deletions.
2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
//! assert_eq!(res_utf8.as_str(), "2");
//! ```

#![warn(missing_docs)]
//#![warn(missing_docs)]

/// The module contains the rust-idiomatic data structures and functions.
pub mod v8;
Expand Down
27 changes: 15 additions & 12 deletions src/v8/inspector/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
//! In case the `"debug-server"` feature isn't enabled, the user of the
//! crate must manually provide a way to receive and send messages over
//! the network and feed the [Inspector] with data.
use std::{ops::Deref, sync::Arc};
use std::{ops::Deref, ptr::NonNull, sync::Arc};

pub mod messages;
#[cfg(feature = "debug-server")]
Expand All @@ -43,7 +43,7 @@ use super::{isolate::V8Isolate, v8_context_scope::V8ContextScope};
/// API. An inspector is tied to the [V8Isolate] it was created for.
#[derive(Debug)]
pub struct RawInspector {
raw: *mut crate::v8_c_raw::bindings::v8_inspector_c_wrapper,
raw: NonNull<crate::v8_c_raw::bindings::v8_inspector_c_wrapper>,
}

impl RawInspector {
Expand All @@ -52,21 +52,22 @@ impl RawInspector {
pub fn new(context_scope: &V8ContextScope<'_, '_>) -> Self {
let raw_context = context_scope.get_inner();
let raw = unsafe {
crate::v8_c_raw::bindings::v8_InspectorCreate(
NonNull::new_unchecked(crate::v8_c_raw::bindings::v8_InspectorCreate(
raw_context,
None,
std::ptr::null_mut(),
None,
std::ptr::null_mut(),
)
))
};
Self { raw }
}

/// Returns the isolate this inspector is bound to. The isolate
/// returned won't be released automatically.
pub fn get_isolate(&self) -> V8Isolate {
let isolate = unsafe { crate::v8_c_raw::bindings::v8_InspectorGetIsolate(self.raw) };
let isolate =
unsafe { crate::v8_c_raw::bindings::v8_InspectorGetIsolate(self.raw.as_ptr()) };
V8Isolate {
inner_isolate: isolate,
no_release: true,
Expand All @@ -77,7 +78,7 @@ impl RawInspector {
/// [`crate::v8::v8_context_scope::V8ContextScope`] of this
/// inspector.
pub fn get_context_scope_ptr(&self) -> *mut v8_context_ref {
unsafe { crate::v8_c_raw::bindings::v8_InspectorGetContext(self.raw) }
unsafe { crate::v8_c_raw::bindings::v8_InspectorGetContext(self.raw.as_ptr()) }
}

/// Dispatches the Chrome Developer Tools (CDT) protocol message.
Expand All @@ -93,7 +94,7 @@ impl RawInspector {
};
unsafe {
crate::v8_c_raw::bindings::v8_InspectorDispatchProtocolMessage(
self.raw,
self.raw.as_ptr(),
string.as_ptr(),
)
}
Expand All @@ -109,7 +110,7 @@ impl RawInspector {
};
unsafe {
crate::v8_c_raw::bindings::v8_InspectorSchedulePauseOnNextStatement(
self.raw,
self.raw.as_ptr(),
string.as_ptr(),
)
}
Expand All @@ -120,14 +121,16 @@ impl RawInspector {
/// but may also be called from here to wait for a certain event
/// on the client side.
pub fn wait_frontend_message_on_pause(&self) {
unsafe { crate::v8_c_raw::bindings::v8_InspectorWaitFrontendMessageOnPause(self.raw) }
unsafe {
crate::v8_c_raw::bindings::v8_InspectorWaitFrontendMessageOnPause(self.raw.as_ptr())
}
}
}

impl Drop for RawInspector {
fn drop(&mut self) {
unsafe {
crate::v8_c_raw::bindings::v8_FreeInspector(self.raw as *mut _);
crate::v8_c_raw::bindings::v8_FreeInspector(self.raw.as_ptr());
}
}
}
Expand Down Expand Up @@ -252,7 +255,7 @@ impl Inspector {

unsafe {
crate::v8_c_raw::bindings::v8_InspectorSetOnResponseCallback(
raw.raw,
raw.raw.as_ptr(),
Some(on_response),
on_response_callback as _,
);
Expand All @@ -274,7 +277,7 @@ impl Inspector {

unsafe {
crate::v8_c_raw::bindings::v8_InspectorSetOnWaitFrontendMessageOnPauseCallback(
raw.raw,
raw.raw.as_ptr(),
Some(on_wait_frontend_message_on_pause),
on_wait_frontend_message_on_pause_callback as _,
);
Expand Down
5 changes: 0 additions & 5 deletions src/v8/isolate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -255,11 +255,6 @@ impl V8Isolate {
unsafe { v8_CancelTerminateExecution(self.inner_isolate) }
}

/// Returns a raw pointer to a [v8_isolate].
pub(crate) fn get_raw(&self) -> *mut v8_isolate {
self.inner_isolate
}

/// Returns the unique ID of this isolate.
pub(crate) fn get_id(&self) -> Option<IsolateId> {
let raw_id = unsafe { v8_GetIsolateId(self.inner_isolate) };
Expand Down
8 changes: 0 additions & 8 deletions src/v8/isolate_scope.rs
Original file line number Diff line number Diff line change
Expand Up @@ -125,14 +125,6 @@ impl<'isolate> V8IsolateScope<'isolate> {
V8Context::new(self.isolate, globals)
}

/// Returns a [V8ContextScope] if it has already been entered and
/// created for this isolate and isolate scope.
pub(crate) fn get_current_context_scope<'isolate_scope>(
&'isolate_scope self,
) -> Option<V8ContextScope<'isolate_scope, 'isolate>> {
V8ContextScope::get_current_for_isolate(self)
}

/// Raise an exception with the given local generic value.
pub fn raise_exception(&self, exception: V8LocalValue) {
unsafe { v8_IsolateRaiseException(self.isolate.inner_isolate, exception.inner_val) };
Expand Down
2 changes: 1 addition & 1 deletion src/v8/v8_module.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ use crate::v8::v8_context_scope::V8ContextScope;
use crate::v8::v8_string::V8LocalString;
use crate::v8::v8_value::V8LocalValue;
use std::os::raw::c_int;
use std::ptr::{self, NonNull};
use std::ptr;

/// JS script object
pub struct V8LocalModule<'isolate_scope, 'isolate> {
Expand Down
4 changes: 1 addition & 3 deletions src/v8/v8_native_function_template.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@ use crate::v8::v8_native_function::V8LocalNativeFunction;
use crate::v8::v8_object::V8LocalObject;
use crate::v8::v8_value::V8LocalValue;

use super::v8_context::V8Context;

/// Native function template object
pub struct V8LocalNativeFunctionTemplate<'isolate_scope, 'isolate> {
pub(crate) inner_func: *mut v8_local_native_function_template,
Expand Down Expand Up @@ -154,7 +152,7 @@ impl<'isolate_scope, 'isolate> V8LocalNativeFunctionArgs<'isolate_scope, 'isolat
V8LocalNativeFunctionArgsIter {
args: self,
index: 0,
ctx_scope: ctx_scope,
ctx_scope,
}
}
}
Expand Down

0 comments on commit a1995ee

Please sign in to comment.