diff --git a/src/V8.rs b/src/V8.rs index 4c5029e6..d79d48a7 100644 --- a/src/V8.rs +++ b/src/V8.rs @@ -79,6 +79,7 @@ pub fn set_flags_from_command_line(args: Vec) -> Vec { .collect() } +#[test] fn test_set_flags_from_command_line() { let r = set_flags_from_command_line(vec![ "binaryname".to_string(), @@ -106,6 +107,8 @@ fn test_get_version() { // TODO: V8::InitializePlatform does not actually take a UniquePtr but rather // a raw pointer. This means that the Platform object is not released when // V8::ShutdownPlatform is called. +/// Sets the v8::Platform to use. This should be invoked before V8 is +/// initialized. pub fn initialize_platform(platform: UniquePtr) { let mut global_state_guard = GLOBAL_STATE.lock().unwrap(); assert_eq!(*global_state_guard, Uninitialized); @@ -142,6 +145,8 @@ pub unsafe fn dispose() -> bool { true } +/// Clears all references to the v8::Platform. This should be invoked after +/// V8 was disposed. pub fn shutdown_platform() { let mut global_state_guard = GLOBAL_STATE.lock().unwrap(); assert_eq!(*global_state_guard, Disposed); diff --git a/src/isolate.rs b/src/isolate.rs index 0d507ba7..bc4e9a3c 100644 --- a/src/isolate.rs +++ b/src/isolate.rs @@ -4,7 +4,6 @@ use crate::array_buffer::Allocator; use crate::support::Delete; use crate::support::Opaque; use crate::support::UniqueRef; -use crate::V8::assert_initialized; extern "C" { fn v8__Isolate__New(params: *mut CreateParams) -> &'static mut CxxIsolate; @@ -31,7 +30,7 @@ pub struct Isolate(&'static mut CxxIsolate); impl Isolate { pub fn new(params: UniqueRef) -> Self { // TODO: support CreateParams. - assert_initialized(); + crate::V8::assert_initialized(); Self(unsafe { v8__Isolate__New(params.into_raw()) }) } }