From 62a52e02411bd85202d106791790a4b91eed13a8 Mon Sep 17 00:00:00 2001 From: Ryan Dahl Date: Tue, 28 Jan 2020 17:16:31 -0500 Subject: [PATCH] Do not use std::os::raw::c_int in public API (#259) --- src/inspector/channel.rs | 13 ++----------- src/inspector/client.rs | 16 ++++++++-------- src/inspector/v8_inspector.rs | 4 ++-- tests/test_api.rs | 9 +++++---- 4 files changed, 17 insertions(+), 25 deletions(-) diff --git a/src/inspector/channel.rs b/src/inspector/channel.rs index e52c7230..04cf0bd1 100644 --- a/src/inspector/channel.rs +++ b/src/inspector/channel.rs @@ -6,15 +6,6 @@ use crate::support::Opaque; use crate::support::RustVTable; use crate::support::UniquePtr; -// class Channel { -// public: -// virtual ~Channel() = default; -// virtual void sendResponse(int callId, -// std::unique_ptr message) = 0; -// virtual void sendNotification(std::unique_ptr message) = 0; -// virtual void flushProtocolNotifications() = 0; -// }; - extern "C" { fn v8_inspector__V8Inspector__Channel__BASE__CONSTRUCT( buf: &mut std::mem::MaybeUninit, @@ -66,7 +57,7 @@ pub struct Channel { impl Channel { pub fn send_response( &mut self, - call_id: int, + call_id: i32, message: UniquePtr, ) { unsafe { @@ -117,7 +108,7 @@ pub trait ChannelImpl: AsChannel { fn send_response( &mut self, - call_id: int, + call_id: i32, message: UniquePtr, ) -> (); fn send_notification(&mut self, message: UniquePtr) -> (); diff --git a/src/inspector/client.rs b/src/inspector/client.rs index 93e1e22b..d5ed16eb 100644 --- a/src/inspector/client.rs +++ b/src/inspector/client.rs @@ -86,7 +86,7 @@ pub struct V8InspectorClient { } impl V8InspectorClient { - pub fn run_message_loop_on_pause(&mut self, context_group_id: int) { + pub fn run_message_loop_on_pause(&mut self, context_group_id: i32) { unsafe { v8_inspector__V8InspectorClient__runMessageLoopOnPause( self, @@ -99,7 +99,7 @@ impl V8InspectorClient { unsafe { v8_inspector__V8InspectorClient__quitMessageLoopOnPause(self) } } - pub fn run_if_waiting_for_debugger(&mut self, context_group_id: int) { + pub fn run_if_waiting_for_debugger(&mut self, context_group_id: i32) { unsafe { v8_inspector__V8InspectorClient__runIfWaitingForDebugger( self, @@ -111,8 +111,8 @@ impl V8InspectorClient { #[allow(clippy::too_many_arguments)] pub fn console_api_message( &mut self, - context_group_id: int, - level: int, + context_group_id: i32, + level: i32, message: &StringView, url: &StringView, line_number: u32, @@ -165,15 +165,15 @@ pub trait V8InspectorClientImpl: AsV8InspectorClient { fn base(&self) -> &V8InspectorClientBase; fn base_mut(&mut self) -> &mut V8InspectorClientBase; - fn run_message_loop_on_pause(&mut self, context_group_id: int) {} + fn run_message_loop_on_pause(&mut self, context_group_id: i32) {} fn quit_message_loop_on_pause(&mut self) {} - fn run_if_waiting_for_debugger(&mut self, context_group_id: int) {} + fn run_if_waiting_for_debugger(&mut self, context_group_id: i32) {} #[allow(clippy::too_many_arguments)] fn console_api_message( &mut self, - context_group_id: int, - level: int, + context_group_id: i32, + level: i32, message: &StringView, url: &StringView, line_number: u32, diff --git a/src/inspector/v8_inspector.rs b/src/inspector/v8_inspector.rs index 2a971ac7..05718373 100644 --- a/src/inspector/v8_inspector.rs +++ b/src/inspector/v8_inspector.rs @@ -53,7 +53,7 @@ impl V8Inspector { pub fn connect( &mut self, - context_group_id: int, + context_group_id: i32, channel: &mut T, state: &StringView, ) -> UniqueRef @@ -75,7 +75,7 @@ impl V8Inspector { pub fn context_created( &mut self, mut context: Local, - context_group_id: int, + context_group_id: i32, human_readable_name: &StringView, ) { unsafe { diff --git a/tests/test_api.rs b/tests/test_api.rs index eea1b2e9..511abf02 100644 --- a/tests/test_api.rs +++ b/tests/test_api.rs @@ -2388,24 +2388,25 @@ fn inspector_schedule_pause_on_next_statement() { } } - use std::os::raw::c_int as int; - impl V8InspectorClientImpl for Client { fn base(&self) -> &V8InspectorClientBase { &self.base } + fn base_mut(&mut self) -> &mut V8InspectorClientBase { &mut self.base } - fn run_message_loop_on_pause(&mut self, context_group_id: int) { + fn run_message_loop_on_pause(&mut self, context_group_id: i32) { assert_eq!(context_group_id, 1); self.count_run_message_loop_on_pause += 1; } + fn quit_message_loop_on_pause(&mut self) { self.count_quit_message_loop_on_pause += 1; } - fn run_if_waiting_for_debugger(&mut self, context_group_id: int) { + + fn run_if_waiting_for_debugger(&mut self, context_group_id: i32) { assert_eq!(context_group_id, 1); self.count_run_message_loop_on_pause += 1; }