summaryrefslogtreecommitdiff
path: root/deno2/deno_internal.h
blob: 92f891af38f128ecdc7dc5383a952e231090f3fe (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
// Copyright 2018 Ryan Dahl <ry@tinyclouds.org>
// All rights reserved. MIT License.
#ifndef DENO_INTERNAL_H_
#define DENO_INTERNAL_H_

#include <string>
#include "include/deno.h"
#include "v8/include/v8.h"

extern "C" {

// 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;
};
}

namespace deno {

void Print(const v8::FunctionCallbackInfo<v8::Value>& args);
void Recv(const v8::FunctionCallbackInfo<v8::Value>& args);
void Send(const v8::FunctionCallbackInfo<v8::Value>& args);
static intptr_t external_references[] = {reinterpret_cast<intptr_t>(Print),
                                         reinterpret_cast<intptr_t>(Recv),
                                         reinterpret_cast<intptr_t>(Send), 0};

Deno* NewFromSnapshot(void* data, RecvCallback cb);

v8::StartupData MakeSnapshot(v8::StartupData* prev_natives_blob,
                             v8::StartupData* prev_snapshot_blob,
                             const char* js_filename, const char* js_source);

void AddIsolate(Deno* d, v8::Isolate* isolate);

}  // namespace deno
#endif  // DENO_INTERNAL_H_