0
0
Fork 0
mirror of https://github.com/denoland/rusty_v8.git synced 2024-12-24 08:09:16 -05:00

Fix some issues with v8::StartupData (#178)

This commit is contained in:
Bert Belder 2020-01-04 01:17:48 +01:00
parent 2d77996467
commit e0b8f2d02c
No known key found for this signature in database
GPG key ID: 7A77887B2E2ED461
3 changed files with 10 additions and 7 deletions

View file

@ -397,9 +397,12 @@ impl CreateParams {
/// - Compression of the startup blob might be useful, but needs to
/// handled entirely on the embedders' side.
/// - The call will abort if the data is invalid.
pub fn set_snapshot_blob(&mut self, snapshot_blob: &mut StartupData) {
pub fn set_snapshot_blob(&mut self, snapshot_blob: &StartupData) {
unsafe {
v8__Isolate__CreateParams__SET__snapshot_blob(self, snapshot_blob)
v8__Isolate__CreateParams__SET__snapshot_blob(
self,
snapshot_blob as *const _ as *mut StartupData,
)
};
}
}

View file

@ -41,7 +41,7 @@ pub struct StartupData<'a> {
impl<'a> StartupData<'a> {
pub fn new<D>(data: &'a D) -> Self
where
D: Borrow<[u8]>,
D: Borrow<[u8]> + ?Sized,
{
let data = data.borrow();
Self {

View file

@ -1494,7 +1494,7 @@ fn snapshot_creator() {
let g = setup();
// First we create the snapshot, there is a single global variable 'a' set to
// the value 3.
let mut startup_data = {
let startup_data = {
let mut snapshot_creator = v8::SnapshotCreator::new(None);
let isolate = snapshot_creator.get_isolate();
let mut locker = v8::Locker::new(&isolate);
@ -1524,7 +1524,7 @@ fn snapshot_creator() {
{
let mut params = v8::Isolate::create_params();
params.set_array_buffer_allocator(v8::new_default_allocator());
params.set_snapshot_blob(&mut startup_data);
params.set_snapshot_blob(&startup_data);
let isolate = v8::Isolate::new(params);
let mut locker = v8::Locker::new(&isolate);
{
@ -1560,7 +1560,7 @@ fn external_references() {
let g = setup();
// First we create the snapshot, there is a single global variable 'a' set to
// the value 3.
let mut startup_data = {
let startup_data = {
let mut snapshot_creator =
v8::SnapshotCreator::new(Some(&EXTERNAL_REFERENCES));
let isolate = snapshot_creator.get_isolate();
@ -1595,7 +1595,7 @@ fn external_references() {
{
let mut params = v8::Isolate::create_params();
params.set_array_buffer_allocator(v8::new_default_allocator());
params.set_snapshot_blob(&mut startup_data);
params.set_snapshot_blob(&startup_data);
params.set_external_references(&EXTERNAL_REFERENCES);
let isolate = v8::Isolate::new(params);
let mut locker = v8::Locker::new(&isolate);