1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-12-04 17:18:23 -05:00
denoland-deno/libdeno/internal.h

64 lines
2 KiB
C
Raw Normal View History

// Copyright 2018 the Deno authors. All rights reserved. MIT license.
#ifndef INTERNAL_H_
#define INTERNAL_H_
#include <map>
#include <string>
#include "deno.h"
2018-07-03 04:15:32 -04:00
#include "third_party/v8/include/v8.h"
2018-06-10 08:18:15 -04:00
extern "C" {
// deno_s = Wrapped Isolate.
struct deno_s {
v8::Isolate* isolate;
const v8::FunctionCallbackInfo<v8::Value>* currentArgs;
std::string last_exception;
v8::Persistent<v8::Function> recv;
v8::Persistent<v8::Function> global_error_handler;
2018-10-12 14:22:52 -04:00
v8::Persistent<v8::Function> promise_reject_handler;
v8::Persistent<v8::Function> promise_error_examiner;
v8::Persistent<v8::ArrayBuffer> global_import_buf;
void* global_import_buf_ptr;
2018-10-12 14:22:52 -04:00
int32_t pending_promise_events;
v8::Persistent<v8::Context> context;
std::map<int32_t, v8::Persistent<v8::Value>> async_data_map;
deno_recv_cb cb;
int32_t next_req_id;
void* user_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);
void Recv(const v8::FunctionCallbackInfo<v8::Value>& args);
void Send(const v8::FunctionCallbackInfo<v8::Value>& args);
void SetGlobalErrorHandler(const v8::FunctionCallbackInfo<v8::Value>& args);
2018-10-12 14:22:52 -04:00
void SetPromiseRejectHandler(const v8::FunctionCallbackInfo<v8::Value>& args);
void SetPromiseErrorExaminer(const v8::FunctionCallbackInfo<v8::Value>& args);
2018-08-26 13:22:07 -04:00
static intptr_t external_references[] = {
2018-10-12 14:22:52 -04:00
reinterpret_cast<intptr_t>(Print),
reinterpret_cast<intptr_t>(Recv),
2018-08-26 13:22:07 -04:00
reinterpret_cast<intptr_t>(Send),
2018-10-12 14:22:52 -04:00
reinterpret_cast<intptr_t>(SetGlobalErrorHandler),
reinterpret_cast<intptr_t>(SetPromiseRejectHandler),
reinterpret_cast<intptr_t>(SetPromiseErrorExaminer),
0};
2018-06-10 08:18:15 -04:00
Deno* NewFromSnapshot(void* user_data, deno_recv_cb cb);
2018-06-10 08:18:15 -04:00
void InitializeContext(v8::Isolate* isolate, v8::Local<v8::Context> context,
const char* js_filename, const std::string& js_source,
const std::string* source_map);
2018-06-10 08:18:15 -04:00
void AddIsolate(Deno* d, v8::Isolate* isolate);
} // namespace deno
#endif // INTERNAL_H_