-
-
Notifications
You must be signed in to change notification settings - Fork 51
/
Copy pathtypes.ts
156 lines (147 loc) · 4.84 KB
/
types.ts
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
import * as JSValue from "./js-value.js";
export type ref = number;
export type pointer = number;
export type bool = number;
export type JavaScriptValueKind = number;
export type JavaScriptValueKindAndFlags = number;
export interface ExportedFunctions {
swjs_library_version(): number;
swjs_library_features(): number;
swjs_prepare_host_function_call(size: number): pointer;
swjs_cleanup_host_function_call(argv: pointer): void;
swjs_call_host_function(
host_func_id: number,
argv: pointer,
argc: number,
callback_func_ref: ref
): bool;
swjs_free_host_function(host_func_id: number): void;
swjs_enqueue_main_job_from_worker(unowned_job: number): void;
swjs_wake_worker_thread(): void;
swjs_receive_response(object: ref, transferring: pointer): void;
swjs_receive_error(error: ref, context: number): void;
}
export interface ImportedFunctions {
swjs_set_prop(
ref: number,
name: number,
kind: JSValue.Kind,
payload1: number,
payload2: number
): void;
swjs_get_prop(
ref: number,
name: number,
payload1_ptr: pointer,
payload2_ptr: pointer
): JavaScriptValueKind;
swjs_set_subscript(
ref: number,
index: number,
kind: JSValue.Kind,
payload1: number,
payload2: number
): void;
swjs_get_subscript(
ref: number,
index: number,
payload1_ptr: pointer,
payload2_ptr: pointer
): JavaScriptValueKind;
swjs_encode_string(ref: number, bytes_ptr_result: pointer): number;
swjs_decode_string(bytes_ptr: pointer, length: number): number;
swjs_load_string(ref: number, buffer: pointer): void;
swjs_call_function(
ref: number,
argv: pointer,
argc: number,
payload1_ptr: pointer,
payload2_ptr: pointer
): JavaScriptValueKindAndFlags;
swjs_call_function_no_catch(
ref: number,
argv: pointer,
argc: number,
payload1_ptr: pointer,
payload2_ptr: pointer
): JavaScriptValueKindAndFlags;
swjs_call_function_with_this(
obj_ref: ref,
func_ref: ref,
argv: pointer,
argc: number,
payload1_ptr: pointer,
payload2_ptr: pointer
): JavaScriptValueKindAndFlags;
swjs_call_function_with_this_no_catch(
obj_ref: ref,
func_ref: ref,
argv: pointer,
argc: number,
payload1_ptr: pointer,
payload2_ptr: pointer
): JavaScriptValueKindAndFlags;
swjs_call_new(ref: number, argv: pointer, argc: number): number;
swjs_call_throwing_new(
ref: number,
argv: pointer,
argc: number,
exception_kind_ptr: pointer,
exception_payload1_ptr: pointer,
exception_payload2_ptr: pointer
): number;
swjs_instanceof(obj_ref: ref, constructor_ref: ref): boolean;
swjs_value_equals(lhs_ref: ref, rhs_ref: ref): boolean;
swjs_create_function(host_func_id: number, line: number, file: ref): number;
swjs_create_typed_array(
constructor_ref: ref,
elementsPtr: pointer,
length: number
): number;
swjs_load_typed_array(ref: ref, buffer: pointer): void;
swjs_release(ref: number): void;
swjs_release_remote(tid: number, ref: number): void;
swjs_i64_to_bigint(value: bigint, signed: bool): ref;
swjs_bigint_to_i64(ref: ref, signed: bool): bigint;
swjs_i64_to_bigint_slow(lower: number, upper: number, signed: bool): ref;
swjs_unsafe_event_loop_yield: () => void;
swjs_send_job_to_main_thread: (unowned_job: number) => void;
swjs_listen_message_from_main_thread: () => void;
swjs_wake_up_worker_thread: (tid: number) => void;
swjs_listen_message_from_worker_thread: (tid: number) => void;
swjs_terminate_worker_thread: (tid: number) => void;
swjs_get_worker_thread_id: () => number;
swjs_request_sending_object: (
sending_object: ref,
transferring_objects: pointer,
transferring_objects_count: number,
object_source_tid: number,
sending_context: pointer,
) => void;
swjs_request_sending_objects: (
sending_objects: pointer,
sending_objects_count: number,
transferring_objects: pointer,
transferring_objects_count: number,
object_source_tid: number,
sending_context: pointer,
) => void;
}
export const enum LibraryFeatures {
WeakRefs = 1 << 0,
}
export type TypedArray =
| Int8ArrayConstructor
| Uint8ArrayConstructor
| Int16ArrayConstructor
| Uint16ArrayConstructor
| Int32ArrayConstructor
| Uint32ArrayConstructor
| BigInt64ArrayConstructor
| BigUint64ArrayConstructor
| Float32ArrayConstructor
| Float64ArrayConstructor;
export function assertNever(x: never, message: string) {
throw new Error(message);
}
export const MAIN_THREAD_TID = -1;