diff options
author | Ryan Dahl <ry@tinyclouds.org> | 2018-06-10 05:34:03 +0200 |
---|---|---|
committer | Ryan Dahl <ry@tinyclouds.org> | 2018-06-10 05:34:03 +0200 |
commit | ff48eca5403140b134a3e6a772ffb6f8905fae3e (patch) | |
tree | 95935ed417348820b781061a51547722526f3913 /deno2/deno.cc | |
parent | 3062039ffe5563cab1f80b2d7da2d9c7e468c462 (diff) |
Expose deno::from_snapshot() constructor
Diffstat (limited to 'deno2/deno.cc')
-rw-r--r-- | deno2/deno.cc | 39 |
1 files changed, 1 insertions, 38 deletions
diff --git a/deno2/deno.cc b/deno2/deno.cc index 4618b5480..eb9b05a7f 100644 --- a/deno2/deno.cc +++ b/deno2/deno.cc @@ -28,24 +28,13 @@ IN THE SOFTWARE. #include "v8/include/libplatform/libplatform.h" #include "v8/include/v8.h" +#include "deno_internal.h" #include "include/deno.h" #define CHECK(x) assert(x) // TODO(ry) use V8's CHECK. namespace deno { -// deno_s = Wrapped Isolate. -struct deno_s { - v8::Isolate* isolate; - std::string last_exception; - v8::Persistent<v8::Function> recv; - v8::Persistent<v8::Context> context; - RecvCallback cb; - void* data; -}; - -void deno_add_isolate(Deno* d, v8::Isolate* isolate); - // Extracts a C string from a v8::V8 Utf8Value. const char* ToCString(const v8::String::Utf8Value& value) { return *value ? *value : "<string conversion failed>"; @@ -170,10 +159,6 @@ void Send(const v8::FunctionCallbackInfo<v8::Value>& args) { } } -intptr_t external_references[] = {reinterpret_cast<intptr_t>(Print), - reinterpret_cast<intptr_t>(Recv), - reinterpret_cast<intptr_t>(Send), 0}; - const char* v8_version() { return v8::V8::GetVersion(); } void v8_set_flags(int* argc, char** argv) { @@ -261,28 +246,6 @@ void v8_init() { v8::V8::Initialize(); } -Deno* deno_from_snapshot(v8::StartupData* blob, void* data, RecvCallback cb) { - Deno* d = new Deno; - d->cb = cb; - d->data = data; - v8::Isolate::CreateParams params; - params.snapshot_blob = blob; - params.array_buffer_allocator = - v8::ArrayBuffer::Allocator::NewDefaultAllocator(); - params.external_references = external_references; - v8::Isolate* isolate = v8::Isolate::New(params); - deno_add_isolate(d, isolate); - - v8::Isolate::Scope isolate_scope(isolate); - { - v8::HandleScope handle_scope(isolate); - auto context = v8::Context::New(isolate); - d->context.Reset(d->isolate, context); - } - - return d; -} - void deno_add_isolate(Deno* d, v8::Isolate* isolate) { d->isolate = isolate; // Leaving this code here because it will probably be useful later on, but |