-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathv8wrap.h
83 lines (55 loc) · 2.43 KB
/
v8wrap.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
#ifndef V8WRAP_H
#define V8WRAP_H
#include <stdbool.h>
#ifdef __cplusplus
extern "C" {
#endif
typedef void *IsolatePtr;
typedef void *ContextPtr;
typedef void *PersistentValuePtr;
typedef void *PlatformPtr;
typedef void *SnapshotPtr;
typedef void *UnlockerPtr;
extern PlatformPtr v8_init();
extern IsolatePtr v8_create_isolate();
extern IsolatePtr v8_create_isolate_with_snapshot(SnapshotPtr snapshot);
extern void v8_release_isolate(IsolatePtr isolate);
extern SnapshotPtr v8_create_snapshot(const char *snapshot_js);
extern void v8_release_snapshot(SnapshotPtr snapshot);
extern ContextPtr v8_create_context(IsolatePtr isolate);
extern void v8_release_context(ContextPtr ctx);
extern char *v8_execute(ContextPtr ctx, char *str, char *debugFilename);
extern PersistentValuePtr v8_eval(ContextPtr ctx, char *str,
char *debugFilename);
extern PersistentValuePtr v8_apply(ContextPtr ctx, PersistentValuePtr func,
PersistentValuePtr self, int argc,
PersistentValuePtr *argv);
extern char *PersistentToJSON(ContextPtr ctx, PersistentValuePtr persistent);
struct KeyValuePair {
char *keyName;
PersistentValuePtr value;
};
// Returns NULL on errors, otherwise allocates an array of KeyValuePairs
// and sets out_numkeys to the length.
// For some reason, cgo barfs if the return type is KeyValuePair*, so we
// return a void* and it's cast back to KeyValuePair* on the other side.
extern void *v8_BurstPersistent(ContextPtr ctx, PersistentValuePtr persistent,
int *out_numKeys);
// Returns a constant error string on errors, otherwise a NULL. The error msg
// should NOT be freed by the caller.
extern const char *v8_setPersistentField(ContextPtr ctx,
PersistentValuePtr persistent,
const char *field,
PersistentValuePtr value);
extern void v8_release_persistent(ContextPtr ctx,
PersistentValuePtr persistent);
extern char *v8_error(ContextPtr ctx);
extern bool v8_context_has_terminated(ContextPtr ctx);
extern void v8_throw(ContextPtr ctx, char *errmsg);
extern void v8_terminate(IsolatePtr iso);
extern UnlockerPtr v8_create_unlocker(IsolatePtr isolate);
extern void v8_release_unlocker(UnlockerPtr unlocker);
#ifdef __cplusplus
}
#endif
#endif // !defined(V8WRAP_H)