-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathV8Context.h
78 lines (57 loc) · 1.9 KB
/
V8Context.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
#ifndef V8CONTEXT_H_
#define V8CONTEXT_H_
#include <v8.h>
#include "pl_config.h"
#include "pl_v8.h"
#define V8_OPT_NAME_GATHER_STATS "gather_stats"
#define V8_OPT_NAME_SAVE_MESSAGES "save_messages"
#define V8_OPT_NAME_MAX_MEMORY_BYTES "max_memory_bytes"
#define V8_OPT_NAME_MAX_TIMEOUT_US "max_timeout_us"
#define V8_OPT_FLAG_GATHER_STATS 0x01
#define V8_OPT_FLAG_SAVE_MESSAGES 0x02
#define V8_OPT_FLAG_MAX_MEMORY_BYTES 0x04
#define V8_OPT_FLAG_MAX_TIMEOUT_US 0x08
using namespace v8;
class V8Context {
public:
V8Context(HV* opt);
~V8Context();
void reset();
SV* get(const char* name);
SV* exists(const char* name);
SV* typeof(const char* name);
SV* instanceof(const char* oname, const char* cname);
void set(const char* name, SV* value);
void remove(const char* name);
SV* eval(const char* code, const char* file = 0);
SV* dispatch_function_in_event_loop(const char* func);
SV* global_objects();
int run_gc();
HV* get_version_info();
HV* get_stats();
void reset_stats();
HV* get_msgs();
void reset_msgs();
Isolate* isolate;
Persistent<Context>* persistent_context;
Persistent<ObjectTemplate>* persistent_template;
uint64_t flags;
HV* version;
HV* stats;
HV* msgs;
long pagesize_bytes;
size_t max_allocated_bytes; /* unused for now */
double max_timeout_us; /* unused for now */
static uint64_t GetTypeFlags(const Local<Value>& v);
private:
int inited;
Isolate::CreateParams create_params;
static void initialize_v8();
static void terminate_v8();
static int instance_count;
static std::unique_ptr<Platform> platform;
void set_up();
void tear_down();
void GetVersionInfo();
};
#endif