forked from just-js/just
-
Notifications
You must be signed in to change notification settings - Fork 0
/
just.h
127 lines (115 loc) · 3.34 KB
/
just.h
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
#ifndef JUST_H
#define JUST_H
#include <v8.h>
#include <libplatform/libplatform.h>
#include <map>
#include <unistd.h>
#include <fcntl.h>
#include <sys/mman.h>
#include <sys/utsname.h>
namespace just {
#define JUST_MICROS_PER_SEC 1e6
using v8::String;
using v8::NewStringType;
using v8::Local;
using v8::Isolate;
using v8::Context;
using v8::ObjectTemplate;
using v8::FunctionCallbackInfo;
using v8::Function;
using v8::Object;
using v8::Value;
using v8::MaybeLocal;
using v8::Module;
using v8::TryCatch;
using v8::Message;
using v8::StackTrace;
using v8::StackFrame;
using v8::HandleScope;
using v8::Integer;
using v8::BigInt;
using v8::FunctionTemplate;
using v8::ScriptOrigin;
using v8::True;
using v8::False;
using v8::ScriptCompiler;
using v8::ArrayBuffer;
using v8::Array;
using v8::Maybe;
using v8::HeapStatistics;
using v8::Float64Array;
using v8::HeapSpaceStatistics;
using v8::BigUint64Array;
using v8::Int32Array;
using v8::Exception;
using v8::FunctionCallback;
using v8::Script;
using v8::Platform;
using v8::V8;
using v8::BackingStore;
using v8::SharedArrayBuffer;
using v8::PromiseRejectMessage;
using v8::Promise;
using v8::PromiseRejectEvent;
using v8::Uint32Array;
using v8::BigUint64Array;
ssize_t process_memory_usage();
typedef void *(*register_plugin)();
struct builtin {
unsigned int size;
const char* source;
};
extern std::map<std::string, builtin*> builtins;
extern std::map<std::string, register_plugin> modules;
void builtins_add (const char* name, const char* source,
unsigned int size);
using InitializerCallback = void (*)(Isolate* isolate,
Local<ObjectTemplate> exports);
MaybeLocal<Module> OnModuleInstantiate(Local<Context> context,
Local<String> specifier, Local<Module> referrer);
int CreateIsolate(int argc, char** argv,
const char* main, unsigned int main_len,
const char* js, unsigned int js_len, struct iovec* buf, int fd);
int CreateIsolate(int argc, char** argv,
const char* main, unsigned int main_len);
void PrintStackTrace(Isolate* isolate, const TryCatch& try_catch);
void PromiseRejectCallback(PromiseRejectMessage message);
void FreeMemory(void* buf, size_t length, void* data);
void SET_METHOD(Isolate *isolate, Local<ObjectTemplate>
recv, const char *name, FunctionCallback callback);
void SET_MODULE(Isolate *isolate, Local<ObjectTemplate>
recv, const char *name, Local<ObjectTemplate> module);
void SET_VALUE(Isolate *isolate, Local<ObjectTemplate>
recv, const char *name, Local<Value> value);
void Print(const FunctionCallbackInfo<Value> &args);
void Error(const FunctionCallbackInfo<Value> &args);
void Load(const FunctionCallbackInfo<Value> &args);
void Sleep(const FunctionCallbackInfo<Value> &args);
void PID(const FunctionCallbackInfo<Value> &args);
void Exit(const FunctionCallbackInfo<Value> &args);
void Chdir(const FunctionCallbackInfo<Value> &args);
void Builtin(const FunctionCallbackInfo<Value> &args);
void MemoryUsage(const FunctionCallbackInfo<Value> &args);
/**
* Setup the target ObjectTemplate with 'just' property which holds the
* basic functions in the runtime core
* .version
* .version.just
* .version.v8
* .version.kernel
* .version.kernel.os
* .version.kernel.release
* .version.kernel.version
* .print()
* .error()
* .load()
* .pid()
* .sleep()
* .exit()
* .chdir()
* .builtin()
* .memoryUsage()
**/
void Init(Isolate* isolate, Local<ObjectTemplate> target);
}
#endif