diff --git a/src/binding.cc b/src/binding.cc index 4be1f46a..6e8dbdb3 100644 --- a/src/binding.cc +++ b/src/binding.cc @@ -1914,6 +1914,8 @@ void v8_inspector__V8Inspector__Channel__flushProtocolNotifications( self->flushProtocolNotifications(); } +int64_t v8_inspector__V8InspectorClient__BASE__generateUniqueId( + v8_inspector::V8InspectorClient* self); void v8_inspector__V8InspectorClient__BASE__runMessageLoopOnPause( v8_inspector::V8InspectorClient* self, int contextGroupId); void v8_inspector__V8InspectorClient__BASE__quitMessageLoopOnPause( @@ -1932,6 +1934,9 @@ struct v8_inspector__V8InspectorClient__BASE : public v8_inspector::V8InspectorClient { using v8_inspector::V8InspectorClient::V8InspectorClient; + int64_t generateUniqueId() override { + return v8_inspector__V8InspectorClient__BASE__generateUniqueId(this); + } void runMessageLoopOnPause(int contextGroupId) override { v8_inspector__V8InspectorClient__BASE__runMessageLoopOnPause( this, contextGroupId); @@ -1961,6 +1966,11 @@ void v8_inspector__V8InspectorClient__BASE__CONSTRUCT( construct_in_place(buf); } +int64_t v8_inspector__V8InspectorClient__generateUniqueId( + v8_inspector::V8InspectorClient* self) { + return self->generateUniqueId(); +} + void v8_inspector__V8InspectorClient__runMessageLoopOnPause( v8_inspector::V8InspectorClient* self, int contextGroupId) { self->runMessageLoopOnPause(contextGroupId); diff --git a/src/inspector.rs b/src/inspector.rs index 5735c5fc..f8127361 100644 --- a/src/inspector.rs +++ b/src/inspector.rs @@ -47,6 +47,9 @@ extern "C" { buf: &mut std::mem::MaybeUninit, ); + fn v8_inspector__V8InspectorClient__generateUniqueId( + this: &mut V8InspectorClient, + ) -> i64; fn v8_inspector__V8InspectorClient__runMessageLoopOnPause( this: &mut V8InspectorClient, context_group_id: int, @@ -129,6 +132,13 @@ pub unsafe extern "C" fn v8_inspector__V8Inspector__Channel__BASE__flushProtocol ChannelBase::dispatch_mut(this).flush_protocol_notifications() } +#[no_mangle] +pub unsafe extern "C" fn v8_inspector__V8InspectorClient__BASE__generateUniqueId( + this: &mut V8InspectorClient, +) -> i64 { + V8InspectorClientBase::dispatch_mut(this).generate_unique_id() +} + #[no_mangle] pub unsafe extern "C" fn v8_inspector__V8InspectorClient__BASE__runMessageLoopOnPause( this: &mut V8InspectorClient, @@ -443,6 +453,10 @@ impl V8InspectorClient { ) } } + + pub fn generate_unique_id(&mut self) -> i64 { + unsafe { v8_inspector__V8InspectorClient__generateUniqueId(self) } + } } pub trait AsV8InspectorClient { @@ -480,6 +494,10 @@ pub trait V8InspectorClientImpl: AsV8InspectorClient { fn quit_message_loop_on_pause(&mut self) {} fn run_if_waiting_for_debugger(&mut self, context_group_id: i32) {} + fn generate_unique_id(&mut self) -> i64 { + 0 // 0 = let V8 pick a unique id itself + } + #[allow(clippy::too_many_arguments)] fn console_api_message( &mut self, diff --git a/tests/test_api.rs b/tests/test_api.rs index 3f239f3a..3092081b 100644 --- a/tests/test_api.rs +++ b/tests/test_api.rs @@ -3179,6 +3179,7 @@ struct ClientCounter { count_run_message_loop_on_pause: usize, count_quit_message_loop_on_pause: usize, count_run_if_waiting_for_debugger: usize, + count_generate_unique_id: i64, } impl ClientCounter { @@ -3188,6 +3189,7 @@ impl ClientCounter { count_run_message_loop_on_pause: 0, count_quit_message_loop_on_pause: 0, count_run_if_waiting_for_debugger: 0, + count_generate_unique_id: 0, } } } @@ -3214,6 +3216,11 @@ impl v8::inspector::V8InspectorClientImpl for ClientCounter { assert_eq!(context_group_id, 1); self.count_run_message_loop_on_pause += 1; } + + fn generate_unique_id(&mut self) -> i64 { + self.count_generate_unique_id += 1; + self.count_generate_unique_id + } } struct ChannelCounter { @@ -3354,6 +3361,7 @@ fn inspector_schedule_pause_on_next_statement() { assert_eq!(client.count_run_message_loop_on_pause, 1); assert_eq!(client.count_quit_message_loop_on_pause, 0); assert_eq!(client.count_run_if_waiting_for_debugger, 0); + assert_ne!(client.count_generate_unique_id, 0); } #[test]