2018-06-09 23:34:03 -04:00
|
|
|
// 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"
|
|
|
|
|
2018-06-10 08:18:15 -04:00
|
|
|
extern "C" {
|
2018-06-09 23:34:03 -04:00
|
|
|
// deno_s = Wrapped Isolate.
|
|
|
|
struct deno_s {
|
|
|
|
v8::Isolate* isolate;
|
2018-06-13 13:38:22 -04:00
|
|
|
const v8::FunctionCallbackInfo<v8::Value>* currentArgs;
|
2018-06-09 23:34:03 -04:00
|
|
|
std::string last_exception;
|
2018-06-11 13:18:53 -04:00
|
|
|
v8::Persistent<v8::Function> sub;
|
2018-06-09 23:34:03 -04:00
|
|
|
v8::Persistent<v8::Context> context;
|
2018-06-11 13:18:53 -04:00
|
|
|
deno_sub_cb cb;
|
2018-06-09 23:34:03 -04:00
|
|
|
void* data;
|
|
|
|
};
|
2018-06-10 08:18:15 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
namespace deno {
|
|
|
|
|
2018-06-12 00:36:01 -04:00
|
|
|
struct InternalFieldData {
|
|
|
|
uint32_t data;
|
|
|
|
};
|
|
|
|
|
2018-06-10 08:18:15 -04:00
|
|
|
void Print(const v8::FunctionCallbackInfo<v8::Value>& args);
|
2018-06-11 13:18:53 -04:00
|
|
|
void Sub(const v8::FunctionCallbackInfo<v8::Value>& args);
|
|
|
|
void Pub(const v8::FunctionCallbackInfo<v8::Value>& args);
|
2018-06-10 08:18:15 -04:00
|
|
|
static intptr_t external_references[] = {reinterpret_cast<intptr_t>(Print),
|
2018-06-11 13:18:53 -04:00
|
|
|
reinterpret_cast<intptr_t>(Sub),
|
|
|
|
reinterpret_cast<intptr_t>(Pub), 0};
|
2018-06-10 08:18:15 -04:00
|
|
|
|
2018-06-11 13:18:53 -04:00
|
|
|
Deno* NewFromSnapshot(void* data, deno_sub_cb cb);
|
2018-06-10 08:18:15 -04:00
|
|
|
|
2018-06-13 14:55:08 -04:00
|
|
|
void InitializeContext(v8::Isolate* isolate, v8::Local<v8::Context> context,
|
|
|
|
const char* js_filename, const char* js_source);
|
|
|
|
|
2018-06-10 08:18:15 -04:00
|
|
|
v8::StartupData MakeSnapshot(v8::StartupData* prev_natives_blob,
|
|
|
|
v8::StartupData* prev_snapshot_blob,
|
|
|
|
const char* js_filename, const char* js_source);
|
2018-06-09 23:34:03 -04:00
|
|
|
|
2018-06-10 08:18:15 -04:00
|
|
|
void AddIsolate(Deno* d, v8::Isolate* isolate);
|
2018-06-09 23:34:03 -04:00
|
|
|
|
|
|
|
} // namespace deno
|
|
|
|
#endif // DENO_INTERNAL_H_
|