From 3c22821499e0b8b01ada09e2795a5bcb3f2548f7 Mon Sep 17 00:00:00 2001 From: Ryan Dahl Date: Tue, 15 Jun 2021 12:05:53 -0400 Subject: [PATCH] CreateParams cleanup (#701) --- src/isolate_create_params.rs | 45 ++++++++---------------------------- 1 file changed, 10 insertions(+), 35 deletions(-) diff --git a/src/isolate_create_params.rs b/src/isolate_create_params.rs index e9fcbbfe..e2d54a4b 100644 --- a/src/isolate_create_params.rs +++ b/src/isolate_create_params.rs @@ -143,15 +143,10 @@ impl CreateParams { self } - fn set_fallback_defaults(mut self) -> Self { + pub(crate) fn finalize(mut self) -> (raw::CreateParams, Box) { if self.raw.array_buffer_allocator_shared.is_null() { self = self.array_buffer_allocator(array_buffer::new_default_allocator()); } - self - } - - pub(crate) fn finalize(mut self) -> (raw::CreateParams, Box) { - self = self.set_fallback_defaults(); let Self { raw, allocations } = self; (raw, Box::new(allocations)) } @@ -168,12 +163,17 @@ struct CreateParamAllocations { external_references: Option>, } +#[test] +fn create_param_defaults() { + let params = CreateParams::default(); + assert_eq!(params.raw.embedder_wrapper_type_index, -1); + assert_eq!(params.raw.embedder_wrapper_object_index, -1); + assert_eq!(params.raw.only_terminate_in_safe_scope, false); + assert_eq!(params.raw.allow_atomics_wait, true); +} + pub(crate) mod raw { use super::*; - use crate::support::long; - use crate::support::Shared; - use crate::support::SharedPtrBase; - use crate::support::UniquePtr; #[repr(C)] #[derive(Debug)] @@ -191,7 +191,6 @@ pub(crate) mod raw { pub only_terminate_in_safe_scope: bool, pub embedder_wrapper_type_index: int, pub embedder_wrapper_object_index: int, - pub cpp_heap_params: SharedPtr, // NOTE(bartlomieju): this field is deprecated in V8 API. // This is an std::vector. It's usually no bigger // than three or four words but let's take a generous upper bound. @@ -265,28 +264,4 @@ pub(crate) mod raw { }; } } - - #[repr(C)] - #[derive(Debug)] - pub(crate) struct CppHeapCreateParams(Opaque); - - impl Shared for CppHeapCreateParams { - fn clone(_: &SharedPtrBase) -> SharedPtrBase { - todo!() - } - - fn from_unique_ptr(_: UniquePtr) -> SharedPtrBase { - todo!() - } - - fn get(_: &SharedPtrBase) -> *const Self { - todo!() - } - - fn reset(_: &mut SharedPtrBase) {} - - fn use_count(_: &SharedPtrBase) -> long { - 0 - } - } }