mirror of
https://github.com/denoland/rusty_v8.git
synced 2025-03-09 21:47:00 -04:00
37 lines
1.1 KiB
C++
37 lines
1.1 KiB
C++
#include "v8/include/v8.h"
|
|
|
|
using namespace v8;
|
|
|
|
extern "C" {
|
|
// This function consumes the Isolate::CreateParams object. The Isolate takes
|
|
// ownership of the ArrayBuffer::Allocator referenced by the params object.
|
|
Isolate* v8__Isolate__New(Isolate::CreateParams& params) {
|
|
auto isolate = Isolate::New(params);
|
|
delete ¶ms;
|
|
return isolate;
|
|
}
|
|
|
|
void v8__Isolate__Dispose(Isolate& isolate) {
|
|
auto allocator = isolate.GetArrayBufferAllocator();
|
|
isolate.Dispose();
|
|
delete allocator;
|
|
}
|
|
|
|
Isolate::CreateParams* v8__Isolate__CreateParams__NEW() {
|
|
return new Isolate::CreateParams();
|
|
}
|
|
|
|
// This function is only called if the Isolate::CreateParams object is *not*
|
|
// consumed by Isolate::New().
|
|
void v8__Isolate__CreateParams__DELETE(Isolate::CreateParams& self) {
|
|
delete self.array_buffer_allocator;
|
|
delete &self;
|
|
}
|
|
|
|
// This function takes ownership of the ArrayBuffer::Allocator.
|
|
void v8__Isolate__CreateParams__SET__array_buffer_allocator(
|
|
Isolate::CreateParams& self, ArrayBuffer::Allocator* value) {
|
|
delete self.array_buffer_allocator;
|
|
self.array_buffer_allocator = value;
|
|
}
|
|
}
|