This repository has been archived by the owner on Nov 12, 2022. It is now read-only.
/
glue.rs
388 lines (377 loc) · 23.5 KB
/
glue.rs
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
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
use jsapi::*;
use std::os::raw::{c_char, c_void};
pub enum Action { }
unsafe impl Sync for ProxyTraps { }
/* automatically generated by rust-bindgen */
#[repr(C)]
#[derive(Copy, Clone)]
pub struct JobQueueTraps {
pub getIncumbentGlobal: ::std::option::Option<
unsafe extern "C" fn(queue: *const c_void, cx: *mut JSContext) -> *mut JSObject>,
pub enqueuePromiseJob: ::std::option::Option<
unsafe extern "C" fn(queue: *const c_void, cx: *mut JSContext, promise: HandleObject,
job: HandleObject, allocationSite: HandleObject,
incumbentGlobal: HandleObject) -> bool>,
pub empty: ::std::option::Option<unsafe extern "C" fn(queue: *const c_void) -> bool>,
}
impl ::std::default::Default for JobQueueTraps {
fn default() -> JobQueueTraps { unsafe { ::std::mem::zeroed() } }
}
#[repr(C)]
#[derive(Copy, Clone, Default)]
pub struct ReadableStreamUnderlyingSourceTraps {
pub requestData: ::std::option::Option<
unsafe extern "C" fn(source: *const c_void, cx: *mut JSContext, stream: HandleObject,
desiredSize: usize)>,
pub writeIntoReadRequestBuffer: ::std::option::Option<
unsafe extern "C" fn(source: *const c_void, cx: *mut JSContext, stream: HandleObject,
buffer: *mut c_void, length: usize, bytesWritten: *mut usize)>,
pub cancel: ::std::option::Option<
unsafe extern "C" fn(source: *const c_void, cx: *mut JSContext, stream: HandleObject,
reason: HandleValue, resolve_to: *mut JS::Value)>,
pub onClosed: ::std::option::Option<
unsafe extern "C" fn(source: *const c_void, cx: *mut JSContext, stream: HandleObject)>,
pub onErrored: ::std::option::Option<
unsafe extern "C" fn(source: *const c_void, cx: *mut JSContext, stream: HandleObject,
reason: HandleValue)>,
pub finalize: ::std::option::Option<
unsafe extern "C" fn(source: *mut JS::ReadableStreamUnderlyingSource)>,
}
#[repr(C)]
#[derive(Copy, Clone)]
pub struct ProxyTraps {
pub enter: ::std::option::Option<unsafe extern "C" fn
(cx: *mut JSContext,
proxy: HandleObject, id: HandleId,
action: Action, bp: *mut bool) -> bool>,
pub getOwnPropertyDescriptor: ::std::option::Option<unsafe extern "C" fn
(cx:
*mut JSContext,
proxy:
HandleObject,
id: HandleId,
desc:
MutableHandle<PropertyDescriptor>)
-> bool>,
pub defineProperty: ::std::option::Option<unsafe extern "C" fn
(cx: *mut JSContext,
proxy: HandleObject,
id: HandleId,
desc:
Handle<PropertyDescriptor>,
result:
*mut ObjectOpResult)
-> bool>,
pub ownPropertyKeys: ::std::option::Option<unsafe extern "C" fn
(cx: *mut JSContext,
proxy: HandleObject,
props: MutableHandleIdVector)
-> bool>,
pub delete_: ::std::option::Option<unsafe extern "C" fn
(cx: *mut JSContext,
proxy: HandleObject, id: HandleId,
result: *mut ObjectOpResult)
-> bool>,
pub enumerate: ::std::option::Option<unsafe extern "C" fn
(cx: *mut JSContext,
proxy: HandleObject,
props: MutableHandleIdVector)
-> bool>,
pub getPrototypeIfOrdinary: ::std::option::Option<unsafe extern "C" fn
(cx: *mut JSContext,
proxy: HandleObject,
isOrdinary: *mut bool,
protop: MutableHandleObject)
-> bool>,
pub preventExtensions: ::std::option::Option<unsafe extern "C" fn
(cx: *mut JSContext,
proxy: HandleObject,
result:
*mut ObjectOpResult)
-> bool>,
pub isExtensible: ::std::option::Option<unsafe extern "C" fn
(cx: *mut JSContext,
proxy: HandleObject,
succeeded: *mut bool) -> bool>,
pub has: ::std::option::Option<unsafe extern "C" fn
(cx: *mut JSContext,
proxy: HandleObject, id: HandleId,
bp: *mut bool) -> bool>,
pub get: ::std::option::Option<unsafe extern "C" fn
(cx: *mut JSContext,
proxy: HandleObject,
receiver: HandleValue, id: HandleId,
vp: MutableHandleValue) -> bool>,
pub set: ::std::option::Option<unsafe extern "C" fn
(cx: *mut JSContext,
proxy: HandleObject,
id: HandleId, v: HandleValue,
receiver: HandleValue,
result: *mut ObjectOpResult) -> bool>,
pub call: ::std::option::Option<unsafe extern "C" fn
(cx: *mut JSContext,
proxy: HandleObject,
args: *const CallArgs) -> bool>,
pub construct: ::std::option::Option<unsafe extern "C" fn
(cx: *mut JSContext,
proxy: HandleObject,
args: *const CallArgs) -> bool>,
pub hasOwn: ::std::option::Option<unsafe extern "C" fn
(cx: *mut JSContext,
proxy: HandleObject, id: HandleId,
bp: *mut bool) -> bool>,
pub getOwnEnumerablePropertyKeys: ::std::option::Option<unsafe extern "C" fn
(cx:
*mut JSContext,
proxy:
HandleObject,
props:
MutableHandleIdVector)
-> bool>,
pub nativeCall: ::std::option::Option<unsafe extern "C" fn
(cx: *mut JSContext,
test: IsAcceptableThis,
_impl: NativeImpl,
args: CallArgs) -> bool>,
pub hasInstance: ::std::option::Option<unsafe extern "C" fn
(cx: *mut JSContext,
proxy: HandleObject,
v: MutableHandleValue,
bp: *mut bool) -> bool>,
pub objectClassIs: ::std::option::Option<unsafe extern "C" fn
(obj: HandleObject,
classValue: ESClass,
cx: *mut JSContext) -> bool>,
pub className: ::std::option::Option<unsafe extern "C" fn
(cx: *mut JSContext,
proxy: HandleObject)
-> *const i8>,
pub fun_toString: ::std::option::Option<unsafe extern "C" fn
(cx: *mut JSContext,
proxy: HandleObject,
isToString: bool)
-> *mut JSString>,
pub boxedValue_unbox: ::std::option::Option<unsafe extern "C" fn
(cx: *mut JSContext,
proxy: HandleObject,
vp: MutableHandleValue)
-> bool>,
pub defaultValue: ::std::option::Option<unsafe extern "C" fn
(cx: *mut JSContext,
obj: HandleObject,
hint: JSType,
vp: MutableHandleValue)
-> bool>,
pub trace: ::std::option::Option<unsafe extern "C" fn
(trc: *mut JSTracer,
proxy: *mut JSObject)>,
pub finalize: ::std::option::Option<unsafe extern "C" fn
(fop: *mut JSFreeOp,
proxy: *mut JSObject)>,
pub objectMoved: ::std::option::Option<unsafe extern "C" fn
(proxy: *mut JSObject,
old: *mut JSObject)
-> usize>,
pub isCallable: ::std::option::Option<unsafe extern "C" fn
(obj: *mut JSObject) -> bool>,
pub isConstructor: ::std::option::Option<unsafe extern "C" fn
(obj: *mut JSObject) -> bool>,
}
impl ::std::default::Default for ProxyTraps {
fn default() -> ProxyTraps { unsafe { ::std::mem::zeroed() } }
}
#[repr(C)]
#[derive(Copy, Clone)]
pub struct WrapperProxyHandler {
pub mTraps: ProxyTraps,
}
impl ::std::default::Default for WrapperProxyHandler {
fn default() -> WrapperProxyHandler { unsafe { ::std::mem::zeroed() } }
}
#[repr(C)]
#[derive(Copy, Clone)]
pub struct ForwardingProxyHandler {
pub mTraps: ProxyTraps,
pub mExtra: *const ::libc::c_void,
}
impl ::std::default::Default for ForwardingProxyHandler {
fn default() -> ForwardingProxyHandler { unsafe { ::std::mem::zeroed() } }
}
extern "C" {
pub fn InvokeGetOwnPropertyDescriptor(handler: *const ::libc::c_void,
cx: *mut JSContext,
proxy: HandleObject, id: HandleId,
desc:
MutableHandle<PropertyDescriptor>)
-> bool;
pub fn InvokeHasOwn(handler: *const ::libc::c_void,
cx: *mut JSContext, proxy: HandleObject,
id: HandleId, bp: *mut bool) -> bool;
pub fn RUST_JS_NumberValue(d: f64, dest: *mut JS::Value);
pub fn RUST_FUNCTION_VALUE_TO_JITINFO(v: Value) -> *const JSJitInfo;
pub fn CreateCallArgsFromVp(argc: u32, v: *mut Value) -> CallArgs;
pub fn CallJitGetterOp(info: *const JSJitInfo, cx: *mut JSContext,
thisObj: HandleObject,
specializedThis: *mut ::libc::c_void, argc: u32,
vp: *mut Value) -> bool;
pub fn CallJitSetterOp(info: *const JSJitInfo, cx: *mut JSContext,
thisObj: HandleObject,
specializedThis: *mut ::libc::c_void, argc: u32,
vp: *mut Value) -> bool;
pub fn CallJitMethodOp(info: *const JSJitInfo, cx: *mut JSContext,
thisObj: HandleObject,
specializedThis: *mut ::libc::c_void, argc: u32,
vp: *mut Value) -> bool;
pub fn CreateProxyHandler(aTraps: *const ProxyTraps,
aExtra: *const ::libc::c_void)
-> *const ::libc::c_void;
pub fn CreateWrapperProxyHandler(aTraps: *const ProxyTraps)
-> *const ::libc::c_void;
pub fn GetCrossCompartmentWrapper() -> *const ::libc::c_void;
pub fn GetSecurityWrapper() -> *const ::libc::c_void;
pub fn NewCompileOptions(aCx: *mut JSContext, aFile: *const ::libc::c_char,
aLine: u32) -> *mut ReadOnlyCompileOptions;
pub fn DeleteCompileOptions(aOpts: *mut ReadOnlyCompileOptions);
pub fn NewProxyObject(aCx: *mut JSContext,
aHandler: *const ::libc::c_void, aPriv: HandleValue,
proto: *mut JSObject)
-> *mut JSObject;
pub fn WrapperNew(aCx: *mut JSContext, aObj: HandleObject,
aHandler: *const ::libc::c_void, aClass: *const JSClass,
aSingleton: bool)
-> *mut JSObject;
pub fn NewWindowProxy(aCx: *mut JSContext, aObj: HandleObject,
aHandler: *const ::libc::c_void)
-> *mut JSObject;
pub fn GetWindowProxyClass() -> *const JSClass;
pub fn GetProxyReservedSlot(obj: *mut JSObject, slot: u32, dest: *mut JS::Value);
pub fn GetProxyPrivate(obj: *mut JSObject, dest: *mut JS::Value);
pub fn SetProxyReservedSlot(obj: *mut JSObject, slot: u32, val: *const JS::Value);
pub fn SetProxyPrivate(obj: *mut JSObject, expando: *const JS::Value);
pub fn RUST_JSID_IS_INT(id: HandleId) -> bool;
pub fn RUST_JSID_TO_INT(id: HandleId) -> i32;
pub fn int_to_jsid(i: i32, id: MutableHandleId);
pub fn RUST_JSID_IS_STRING(id: HandleId) -> bool;
pub fn RUST_JSID_TO_STRING(id: HandleId) -> *mut JSString;
pub fn RUST_SYMBOL_TO_JSID(sym: *mut Symbol, id: MutableHandleId);
pub fn RUST_JSID_IS_VOID(id: HandleId) -> bool;
pub fn SetBuildId(buildId: *mut JS::BuildIdCharVector, chars: *const u8, len: usize) -> bool;
pub fn RUST_SET_JITINFO(func: *mut JSFunction, info: *const JSJitInfo);
pub fn RUST_INTERNED_STRING_TO_JSID(cx: *mut JSContext,
str: *mut JSString,
id: MutableHandleId);
pub fn RUST_js_GetErrorMessage(userRef: *mut ::libc::c_void,
errorNumber: u32)
-> *const JSErrorFormatString;
pub fn IsProxyHandlerFamily(obj: *mut JSObject) -> u8;
pub fn GetProxyHandlerExtra(obj: *mut JSObject) -> *const ::libc::c_void;
pub fn GetProxyHandler(obj: *mut JSObject) -> *const ::libc::c_void;
pub fn ReportError(aCx: *mut JSContext, aError: *const i8);
pub fn IsWrapper(obj: *mut JSObject) -> bool;
pub fn UnwrapObjectStatic(obj: *mut JSObject) -> *mut JSObject;
pub fn UnwrapObjectDynamic(obj: *mut JSObject, cx: *mut JSContext, stopAtOuter: u8) -> *mut JSObject;
pub fn UncheckedUnwrapObject(obj: *mut JSObject, stopAtOuter: u8) -> *mut JSObject;
pub fn CreateRootedIdVector(cx: *mut JSContext) -> *mut PersistentRootedIdVector;
pub fn GetIdVectorAddress(v: *mut PersistentRootedIdVector) -> *mut ::libc::c_void;
pub fn SliceRootedIdVector(v: *const PersistentRootedIdVector, length: *mut usize) -> *const jsid;
pub fn AppendToIdVector(v: MutableHandleIdVector, id: HandleId) -> bool;
pub fn DestroyRootedIdVector(v: *mut PersistentRootedIdVector);
pub fn CreateRootedObjectVector(aCx: *mut JSContext)
-> *mut PersistentRootedObjectVector;
pub fn AppendToRootedObjectVector(v: *mut PersistentRootedObjectVector,
obj: *mut JSObject) -> bool;
pub fn GetObjectVectorAddress(v: *mut PersistentRootedObjectVector) -> *mut ::libc::c_void;
pub fn DeleteRootedObjectVector(v: *mut PersistentRootedObjectVector);
pub fn CollectServoSizes(cx: *mut JSContext, sizes: *mut ServoSizes, get_size: Option<unsafe extern "C" fn (obj: *mut JSObject) -> usize>) -> bool;
pub fn InitializeMemoryReporter(want_to_measure: Option<unsafe extern "C" fn (obj: *mut JSObject) -> bool>);
pub fn CallIdTracer(trc: *mut JSTracer, idp: *mut Heap<jsid>,
name: *const ::libc::c_char);
pub fn CallValueTracer(trc: *mut JSTracer, valuep: *mut Heap<Value>,
name: *const ::libc::c_char);
pub fn CallObjectTracer(trc: *mut JSTracer,
objp: *mut Heap<*mut JSObject>,
name: *const ::libc::c_char);
pub fn CallStringTracer(trc: *mut JSTracer,
strp: *mut Heap<*mut JSString>,
name: *const ::libc::c_char);
pub fn CallScriptTracer(trc: *mut JSTracer,
scriptp: *mut Heap<*mut JSScript>,
name: *const ::libc::c_char);
pub fn CallFunctionTracer(trc: *mut JSTracer,
funp: *mut Heap<*mut JSFunction>,
name: *const ::libc::c_char);
pub fn CallUnbarrieredObjectTracer(trc: *mut JSTracer,
objp: *mut *mut JSObject,
name: *const ::libc::c_char);
pub fn CallObjectRootTracer(trc: *mut JSTracer,
objp: *mut *mut JSObject,
name: *const ::libc::c_char);
pub fn CallValueRootTracer(trc: *mut JSTracer,
valp: *mut Value,
name: *const ::libc::c_char);
pub fn GetProxyHandlerFamily() -> *const c_void;
pub fn GetInt8ArrayLengthAndData(obj: *mut JSObject,
length: *mut u32,
isSharedMemory: *mut bool,
data: *mut *mut i8);
pub fn GetUint8ArrayLengthAndData(obj: *mut JSObject,
length: *mut u32,
isSharedMemory: *mut bool,
data: *mut *mut u8);
pub fn GetUint8ClampedArrayLengthAndData(obj: *mut JSObject,
length: *mut u32,
isSharedMemory: *mut bool,
data: *mut *mut u8);
pub fn GetInt16ArrayLengthAndData(obj: *mut JSObject,
length: *mut u32,
isSharedMemory: *mut bool,
data: *mut *mut i16);
pub fn GetUint16ArrayLengthAndData(obj: *mut JSObject,
length: *mut u32,
isSharedMemory: *mut bool,
data: *mut *mut u16);
pub fn GetInt32ArrayLengthAndData(obj: *mut JSObject,
length: *mut u32,
isSharedMemory: *mut bool,
data: *mut *mut i32);
pub fn GetUint32ArrayLengthAndData(obj: *mut JSObject,
length: *mut u32,
isSharedMemory: *mut bool,
data: *mut *mut u32);
pub fn GetFloat32ArrayLengthAndData(obj: *mut JSObject,
length: *mut u32,
isSharedMemory: *mut bool,
data: *mut *mut f32);
pub fn GetFloat64ArrayLengthAndData(obj: *mut JSObject,
length: *mut u32,
isSharedMemory: *mut bool,
data: *mut *mut f64);
pub fn NewJSAutoStructuredCloneBuffer(scope: JS::StructuredCloneScope,
callbacks: *const JSStructuredCloneCallbacks) ->
*mut JSAutoStructuredCloneBuffer;
pub fn DeleteJSAutoStructuredCloneBuffer(buf: *mut JSAutoStructuredCloneBuffer);
pub fn GetLengthOfJSStructuredCloneData(data: *mut JSStructuredCloneData) -> usize;
pub fn CopyJSStructuredCloneData(src: *const JSStructuredCloneData, dest: *mut u8);
pub fn WriteBytesToJSStructuredCloneData(src: *const u8, len: usize, dest: *mut JSStructuredCloneData);
pub fn JS_ComputeThis (cx: *mut JSContext , vp: *mut JS::Value, dest: *mut JS::Value);
pub fn JS_GetModuleHostDefinedField (module: *mut JSObject, dest: *mut JS::Value);
pub fn JS_GetPromiseResult (promise: JS::HandleObject, dest: JS::MutableHandleValue);
pub fn JS_GetScriptPrivate(script: *mut JSScript, dest: JS::MutableHandleValue);
pub fn JS_GetModulePrivate(module: *mut JSObject, dest: JS::MutableHandleValue);
pub fn JS_THIS (cx: *mut JSContext , vp: *mut JS::Value, dest: *mut JS::Value);
pub fn JS_GetNaNValue (cx: *mut JSContext, dest: *mut JS::Value);
pub fn JS_GetPositiveInfinityValue (cx: *mut JSContext, dest: *mut JS::Value);
pub fn JS_GetEmptyStringValue (cx: *mut JSContext, dest: *mut JS::Value);
pub fn JS_GetReservedSlot (obj: *mut JSObject , index: u32, dest: *mut JS::Value);
pub fn EncodeStringToUTF8(cx: *mut JSContext, str: JS::HandleString, cb: fn(*const c_char));
pub fn CreateJobQueue(traps: *const JobQueueTraps, queue: *const c_void) -> *mut JS::JobQueue;
pub fn DeleteJobQueue(queue: *mut JS::JobQueue);
pub fn CreateReadableStreamUnderlyingSource(traps: *const ReadableStreamUnderlyingSourceTraps, source: *const c_void) -> *mut JS::ReadableStreamUnderlyingSource;
pub fn DeleteReadableStreamUnderlyingSource(source: *mut JS::ReadableStreamUnderlyingSource);
pub fn DispatchableRun(cx: *mut JSContext, ptr: *mut JS::Dispatchable, mb: JS::Dispatchable_MaybeShuttingDown);
pub fn StreamConsumerConsumeChunk(sc: *mut JS::StreamConsumer, begin: *const u8, length: usize) -> bool;
pub fn StreamConsumerStreamEnd(cx: *mut JS::StreamConsumer);
pub fn StreamConsumerStreamError(cx: *mut JS::StreamConsumer, errorCode: usize);
pub fn StreamConsumerNoteResponseURLs(sc: *mut JS::StreamConsumer, maybeUrl: *const c_char, maybeSourceMapUrl: *const c_char);
pub fn DescribeScriptedCaller(cx: *mut JSContext, buffer: *mut u8, buflen: usize, line: *mut u32, col: *mut u32) -> bool;
}