2018-07-23 14:46:30 -04:00
|
|
|
// Copyright 2018 the Deno authors. All rights reserved. MIT license.
|
2018-07-06 15:19:19 +08:00
|
|
|
#ifndef INTERNAL_H_
|
|
|
|
#define INTERNAL_H_
|
2018-06-10 05:34:03 +02:00
|
|
|
|
|
|
|
#include <string>
|
2018-07-06 15:19:19 +08:00
|
|
|
#include "deno.h"
|
2018-07-03 17:15:32 +09:00
|
|
|
#include "third_party/v8/include/v8.h"
|
2018-06-10 05:34:03 +02:00
|
|
|
|
2018-06-10 14:18:15 +02:00
|
|
|
extern "C" {
|
2018-06-10 05:34:03 +02:00
|
|
|
// deno_s = Wrapped Isolate.
|
|
|
|
struct deno_s {
|
|
|
|
v8::Isolate* isolate;
|
2018-06-13 19:38:22 +02:00
|
|
|
const v8::FunctionCallbackInfo<v8::Value>* currentArgs;
|
2018-06-10 05:34:03 +02:00
|
|
|
std::string last_exception;
|
2018-07-01 18:07:12 +02:00
|
|
|
v8::Persistent<v8::Function> recv;
|
2018-08-26 16:57:16 +09:00
|
|
|
v8::Persistent<v8::Function> global_error_handler;
|
2018-10-12 11:22:52 -07:00
|
|
|
v8::Persistent<v8::Function> promise_reject_handler;
|
|
|
|
v8::Persistent<v8::Function> promise_error_examiner;
|
2018-10-17 14:02:00 -04:00
|
|
|
|
|
|
|
v8::Persistent<v8::ArrayBuffer> global_import_buf;
|
|
|
|
void* global_import_buf_ptr;
|
|
|
|
|
2018-10-12 11:22:52 -07:00
|
|
|
int32_t pending_promise_events;
|
2018-06-10 05:34:03 +02:00
|
|
|
v8::Persistent<v8::Context> context;
|
2018-09-27 17:33:10 -04:00
|
|
|
v8::Persistent<v8::Map> async_data_map;
|
2018-07-01 18:07:12 +02:00
|
|
|
deno_recv_cb cb;
|
2018-09-27 17:33:10 -04:00
|
|
|
int32_t next_req_id;
|
2018-10-08 17:49:48 +02:00
|
|
|
void* user_data;
|
2018-06-10 05:34:03 +02:00
|
|
|
};
|
2018-06-10 14:18:15 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
namespace deno {
|
|
|
|
|
2018-06-12 06:36:01 +02:00
|
|
|
struct InternalFieldData {
|
|
|
|
uint32_t data;
|
|
|
|
};
|
|
|
|
|
2018-06-10 14:18:15 +02:00
|
|
|
void Print(const v8::FunctionCallbackInfo<v8::Value>& args);
|
2018-07-01 18:07:12 +02:00
|
|
|
void Recv(const v8::FunctionCallbackInfo<v8::Value>& args);
|
|
|
|
void Send(const v8::FunctionCallbackInfo<v8::Value>& args);
|
2018-08-26 16:57:16 +09:00
|
|
|
void SetGlobalErrorHandler(const v8::FunctionCallbackInfo<v8::Value>& args);
|
2018-10-12 11:22:52 -07:00
|
|
|
void SetPromiseRejectHandler(const v8::FunctionCallbackInfo<v8::Value>& args);
|
|
|
|
void SetPromiseErrorExaminer(const v8::FunctionCallbackInfo<v8::Value>& args);
|
2018-08-26 19:22:07 +02:00
|
|
|
static intptr_t external_references[] = {
|
2018-10-12 11:22:52 -07:00
|
|
|
reinterpret_cast<intptr_t>(Print),
|
|
|
|
reinterpret_cast<intptr_t>(Recv),
|
2018-08-26 19:22:07 +02:00
|
|
|
reinterpret_cast<intptr_t>(Send),
|
2018-10-12 11:22:52 -07:00
|
|
|
reinterpret_cast<intptr_t>(SetGlobalErrorHandler),
|
|
|
|
reinterpret_cast<intptr_t>(SetPromiseRejectHandler),
|
|
|
|
reinterpret_cast<intptr_t>(SetPromiseErrorExaminer),
|
|
|
|
0};
|
2018-06-10 14:18:15 +02:00
|
|
|
|
2018-10-08 17:49:48 +02:00
|
|
|
Deno* NewFromSnapshot(void* user_data, deno_recv_cb cb);
|
2018-06-10 14:18:15 +02:00
|
|
|
|
2018-06-13 20:55:08 +02:00
|
|
|
void InitializeContext(v8::Isolate* isolate, v8::Local<v8::Context> context,
|
2018-08-02 13:13:32 -04:00
|
|
|
const char* js_filename, const std::string& js_source,
|
|
|
|
const std::string* source_map);
|
2018-06-13 20:55:08 +02:00
|
|
|
|
2018-06-10 14:18:15 +02:00
|
|
|
void AddIsolate(Deno* d, v8::Isolate* isolate);
|
2018-06-10 05:34:03 +02:00
|
|
|
|
|
|
|
} // namespace deno
|
2018-07-06 15:19:19 +08:00
|
|
|
#endif // INTERNAL_H_
|