-
Notifications
You must be signed in to change notification settings - Fork 0
/
jv.h
66 lines (55 loc) · 1.14 KB
/
jv.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
typedef enum
{
JV_VALUE_UNDEFINED, /* must be 0 */
JV_VALUE_BOOLEAN,
JV_VALUE_NULL,
JV_VALUE_STRING,
JV_VALUE_NUMBER,
JV_VALUE_ARRAY,
JV_VALUE_OBJECT,
JV_VALUE_FUNCTION
} JVValueType;
typedef union JV JV;
typedef struct {
JVValueType type;
} JVValueBase;
typedef struct {
JVValueBase base;
int value;
} JVValueBoolean;
typedef struct {
JVValueBase base;
double value;
} JVValueNumber;
typedef struct {
JVValueBase base;
JS_String *string;
} JVValueString;
extern JVValueString jv_value_empty_string;
typedef struct {
JVValueBase base;
JVObjectPrototype *prototype;
JVObjectFuncs funcs;
void *func_data;
} JVValueObject;
typedef enum {
JV_INVOCATION_THREW,
JV_INVOCATION_RETURNED
} JVInvocationResultType;
typedef struct {
JVInvocationResultType type;
JV *rv;
} JVInvocationResult;
typedef struct {
JVValueObject base;
JVInvocationResult (*invoke)(size_t n_args, JV **args, void *func_data);
} JVValueFunction;
union JV {
JVValueType type;
JVValueBoolean v_boolean;
JVValueString v_string;
JVValueNumber v_number;
JVValueArray v_array;
JVValueObject v_object;
JVValueFunction v_function;
};