-
Notifications
You must be signed in to change notification settings - Fork 87
/
v8_wrap.h
357 lines (228 loc) · 8.85 KB
/
v8_wrap.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
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
#ifndef _V8_WARP_H_
#define _V8_WARP_H_
#include <stdint.h>
#include <stdlib.h>
#ifdef __cplusplus
extern "C" {
#endif
typedef enum {
OTP_Context = 0,
OTP_Getter,
OTP_Setter,
OTP_Query,
OTP_Deleter,
OTP_Enumerator,
OTP_Data,
OTP_Num
} PropertyDataEnum;
typedef enum {
OTA_Context = 0,
OTA_Getter,
OTA_Setter,
OTA_KeyString,
OTA_KeyLength,
OTA_Data,
OTA_Num
} AccessorDataEnum;
typedef struct {
void* engine;
void* info;
void* setValue;
const char* key;
int key_length;
void* data;
void* callback;
void* returnValue;
} V8_AccessorCallbackInfo;
typedef struct {
void* engine;
void* info;
void* callback;
void* setValue;
void* data;
char* key;
uint32_t index;
void* returnValue;
} V8_PropertyCallbackInfo;
/*
V8
*/
extern const char* V8_GetVersion();
extern void V8_SetFlagsFromString(const char* str, int length);
extern void* V8_SetArrayBufferAllocator(void* raw, void* ac, void* fc);
extern void V8_Dispose_Allocator(void* raw);
extern void V8_AddMessageListener(void* callback, void* data, int simple);
extern void V8_SetCaptureStackTraceForUncaughtExceptions(int capture, int frame_limit);
/*
engine
*/
extern void* V8_NewEngine();
extern void V8_DisposeEngine(void* engine);
extern void* V8_ParseJSON(void* context, const char* json, int json_length);
/*
context
*/
extern void* V8_NewContext(void* engine, void* global_template);
extern void V8_DisposeContext(void* context);
extern void V8_Context_Enter(void* context);
extern void V8_Context_Exit(void* context);
extern void V8_Context_Scope(void* context, void* context_ptr, void* callback);
extern void* V8_Context_Global(void* context);
extern void V8_Context_ThrowException(void* context, const char* err, int err_length);
extern char* V8_Context_TryCatch(void* context, void* callback, int simple);
/*
script
*/
extern void* V8_Compile(void* engine, const char* code, int length, void* script_origin, void* script_data);
extern void V8_DisposeScript(void* script);
extern void* V8_Script_Run(void* script);
/*
script data
*/
extern void* V8_PreCompile(void* engine, const char* code, int length);
extern void* V8_NewScriptData(const char* data, int length);
extern void V8_DisposeScriptData(void* script_data);
extern int V8_ScriptData_Length(void* script_data);
extern const char* V8_ScriptData_Data(void* script_data);
extern int V8_ScriptData_HasError(void* script_data);
/*
script origin
*/
extern void* V8_NewScriptOrigin(void* engine, const char* name, int name_length, int line_offset, int column_offset);
extern void V8_DisposeScriptOrigin(void* script_origin);
/*
value
*/
extern void V8_DisposeValue(void* value);
extern int V8_Value_IsUndefined(void* value);
extern int V8_Value_IsNull(void* value);
extern int V8_Value_IsTrue(void* value);
extern int V8_Value_IsFalse(void* value);
extern int V8_Value_IsString(void* value);
extern int V8_Value_IsFunction(void* value);
extern int V8_Value_IsArray(void* value);
extern int V8_Value_IsObject(void* value);
extern int V8_Value_IsBoolean(void* value);
extern int V8_Value_IsNumber(void* value);
extern int V8_Value_IsExternal(void* value);
extern int V8_Value_IsInt32(void* value);
extern int V8_Value_IsUint32(void* value);
extern int V8_Value_IsDate(void* value);
extern int V8_Value_IsBooleanObject(void* value);
extern int V8_Value_IsNumberObject(void* value);
extern int V8_Value_IsStringObject(void* value);
extern int V8_Value_IsNativeError(void* value);
extern int V8_Value_IsRegExp(void* value);
extern int V8_Value_ToBoolean(void* value);
extern double V8_Value_ToNumber(void* value);
extern int64_t V8_Value_ToInteger(void* value);
extern uint32_t V8_Value_ToUint32(void* value);
extern int32_t V8_Value_ToInt32(void* value);
extern char* V8_Value_ToString(void* value);
extern void* V8_Undefined(void* engine);
extern void* V8_Null(void* engine);
extern void* V8_True(void* engine);
extern void* V8_False(void* engine);
extern void* V8_NewNumber(void* context, double val);
extern void* V8_NewString(void* context, const char* val, int val_length);
extern void* V8_NewExternal(void* context, void* data);
/*
object
*/
extern void* V8_NewObject(void* context);
extern int V8_Object_SetProperty(void* value, const char* key, int key_length, void* prop_value, int attribs);
extern void* V8_Object_GetProperty(void* value, const char* key, int key_length);
extern int V8_Object_SetElement(void* value, uint32_t index, void* elem_value);
extern void* V8_Object_GetElement(void* value, uint32_t index);
extern int V8_Object_GetPropertyAttributes(void *value, const char* key, int key_length);
extern int V8_Object_ForceSetProperty(void* value, const char* key, int key_length, void* prop_value, int attribs);
extern int V8_Object_HasProperty(void *value, const char* key, int key_length);
extern int V8_Object_DeleteProperty(void *value, const char* key, int key_length);
extern int V8_Object_ForceDeleteProperty(void *value, const char* key, int key_length);
extern int V8_Object_HasElement(void* value, uint32_t index);
extern int V8_Object_DeleteElement(void* value, uint32_t index);
extern void* V8_Object_GetPropertyNames(void *value);
extern void* V8_Object_GetOwnPropertyNames(void *value);
extern void* V8_Object_GetPrototype(void *value);
extern int V8_Object_SetPrototype(void *value, void *proto);
extern void V8_Object_SetAccessor(void *value, const char* key, int key_length, void* getter, void* setter, void* data, int attribs);
extern int V8_Object_InternalFieldCount(void* value);
extern void* V8_Object_GetInternalField(void* value, int index);
extern void V8_Object_SetInternalField(void* value, int index, void* data);
extern void* V8_AccessorCallbackInfo_This(void *info, AccessorDataEnum type);
extern void* V8_AccessorCallbackInfo_Holder(void *info, AccessorDataEnum type);
extern void* V8_AccessorCallbackInfo_ReturnValue(void *info, AccessorDataEnum typ);
extern void* V8_PropertyCallbackInfo_This(void *info, PropertyDataEnum typ );
extern void* V8_PropertyCallbackInfo_Holder(void *info, PropertyDataEnum typ );
extern void* V8_PropertyCallbackInfo_ReturnValue(void *info, PropertyDataEnum typ );
/*
array
*/
extern void* V8_NewArray(void* context, int length);
extern int V8_Array_Length(void* value);
/*
regexp
*/
extern void* V8_NewRegExp(void* context, const char* pattern, int length, int flags);
extern char* V8_RegExp_Pattern(void* value);
extern int V8_RegExp_Flags(void* value);
/*
return value
*/
extern void V8_ReturnValue_Set(void* rv, void* result);
extern void V8_ReturnValue_SetBoolean(void* rv, int v);
extern void V8_ReturnValue_SetNumber(void* rv, double v);
extern void V8_ReturnValue_SetInt32(void* rv, int32_t v);
extern void V8_ReturnValue_SetUint32(void* rv, uint32_t v);
extern void V8_ReturnValue_SetString(void* rv, const char* str, int str_length);
extern void V8_ReturnValue_SetNull(void* rv);
extern void V8_ReturnValue_SetUndefined(void* rv);
/*
function
*/
extern void* V8_Function_Call(void* value, int argc, void* argv);
extern void* V8_FunctionCallbackInfo_Get(void* info, int i);
extern int V8_FunctionCallbackInfo_Length(void* info);
extern void* V8_FunctionCallbackInfo_Callee(void* info);
extern void* V8_FunctionCallbackInfo_This(void* info);
extern void* V8_FunctionCallbackInfo_Holder(void* info);
extern void* V8_FunctionCallbackInfo_ReturnValue(void* info);
/*
object template
*/
extern void* V8_NewObjectTemplate(void* engine);
extern void V8_DisposeObjectTemplate(void* tpl);
extern void V8_ObjectTemplate_SetProperty(void* tpl, const char* key, int key_length, void* prop_value, int attribs);
extern void* V8_ObjectTemplate_NewObject(void* tpl);
extern void V8_ObjectTemplate_SetAccessor(void *tpl, const char* key, int key_length, void* getter, void* setter, void* data, int attribs);
extern void V8_ObjectTemplate_SetNamedPropertyHandler(
void* tpl,
void* getter,
void* setter,
void* query,
void* deleter,
void* enumerator,
void* data
);
extern void V8_ObjectTemplate_SetIndexedPropertyHandler(
void* tpl,
void* getter,
void* setter,
void* query,
void* deleter,
void* enumerator,
void* data
);
extern void V8_ObjectTemplate_SetInternalFieldCount(void *tpl, int count);
/*
function template
*/
extern void* V8_NewFunctionTemplate(void* engine, void* callback, void* data);
extern void V8_DisposeFunctionTemplate(void* tpl);
extern void* V8_FunctionTemplate_GetFunction(void* tpl);
extern void V8_FunctionTemplate_SetClassName(void* tpl, const char* name, int name_length);
extern void* V8_FunctionTemplate_InstanceTemplate(void* tpl);
#ifdef __cplusplus
} // extern "C"
#endif
#endif