1 #![allow(
2 dead_code,
3 non_snake_case,
4 non_camel_case_types,
5 non_upper_case_globals
6 )]
7
8 #[repr(C)]
9 #[derive(Copy, Clone, Debug, Default, Eq, Hash, Ord, PartialEq, PartialOrd)]
10 pub struct __BindgenBitfieldUnit<Storage> {
11 storage: Storage,
12 }
13 impl<Storage> __BindgenBitfieldUnit<Storage> {
14 #[inline]
new(storage: Storage) -> Self15 pub const fn new(storage: Storage) -> Self {
16 Self { storage }
17 }
18 }
19 impl<Storage> __BindgenBitfieldUnit<Storage>
20 where
21 Storage: AsRef<[u8]> + AsMut<[u8]>,
22 {
23 #[inline]
get_bit(&self, index: usize) -> bool24 pub fn get_bit(&self, index: usize) -> bool {
25 debug_assert!(index / 8 < self.storage.as_ref().len());
26 let byte_index = index / 8;
27 let byte = self.storage.as_ref()[byte_index];
28 let bit_index = if cfg!(target_endian = "big") {
29 7 - (index % 8)
30 } else {
31 index % 8
32 };
33 let mask = 1 << bit_index;
34 byte & mask == mask
35 }
36 #[inline]
set_bit(&mut self, index: usize, val: bool)37 pub fn set_bit(&mut self, index: usize, val: bool) {
38 debug_assert!(index / 8 < self.storage.as_ref().len());
39 let byte_index = index / 8;
40 let byte = &mut self.storage.as_mut()[byte_index];
41 let bit_index = if cfg!(target_endian = "big") {
42 7 - (index % 8)
43 } else {
44 index % 8
45 };
46 let mask = 1 << bit_index;
47 if val {
48 *byte |= mask;
49 } else {
50 *byte &= !mask;
51 }
52 }
53 #[inline]
get(&self, bit_offset: usize, bit_width: u8) -> u6454 pub fn get(&self, bit_offset: usize, bit_width: u8) -> u64 {
55 debug_assert!(bit_width <= 64);
56 debug_assert!(bit_offset / 8 < self.storage.as_ref().len());
57 debug_assert!(
58 (bit_offset + (bit_width as usize)) / 8 <=
59 self.storage.as_ref().len()
60 );
61 let mut val = 0;
62 for i in 0..(bit_width as usize) {
63 if self.get_bit(i + bit_offset) {
64 let index = if cfg!(target_endian = "big") {
65 bit_width as usize - 1 - i
66 } else {
67 i
68 };
69 val |= 1 << index;
70 }
71 }
72 val
73 }
74 #[inline]
set(&mut self, bit_offset: usize, bit_width: u8, val: u64)75 pub fn set(&mut self, bit_offset: usize, bit_width: u8, val: u64) {
76 debug_assert!(bit_width <= 64);
77 debug_assert!(bit_offset / 8 < self.storage.as_ref().len());
78 debug_assert!(
79 (bit_offset + (bit_width as usize)) / 8 <=
80 self.storage.as_ref().len()
81 );
82 for i in 0..(bit_width as usize) {
83 let mask = 1 << i;
84 let val_bit_is_set = val & mask == mask;
85 let index = if cfg!(target_endian = "big") {
86 bit_width as usize - 1 - i
87 } else {
88 i
89 };
90 self.set_bit(index + bit_offset, val_bit_is_set);
91 }
92 }
93 }
94 pub const JSVAL_TAG_SHIFT: u32 = 47;
95 pub const JSVAL_PAYLOAD_MASK: u64 = 140737488355327;
96 pub const JSVAL_TAG_MASK: i64 = -140737488355328;
97 #[repr(u8)]
98 #[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
99 pub enum JSValueType {
100 JSVAL_TYPE_DOUBLE = 0,
101 JSVAL_TYPE_INT32 = 1,
102 JSVAL_TYPE_UNDEFINED = 2,
103 JSVAL_TYPE_BOOLEAN = 3,
104 JSVAL_TYPE_MAGIC = 4,
105 JSVAL_TYPE_STRING = 5,
106 JSVAL_TYPE_SYMBOL = 6,
107 JSVAL_TYPE_NULL = 7,
108 JSVAL_TYPE_OBJECT = 8,
109 JSVAL_TYPE_UNKNOWN = 32,
110 JSVAL_TYPE_MISSING = 33,
111 }
112 #[repr(u32)]
113 #[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
114 pub enum JSValueTag {
115 JSVAL_TAG_MAX_DOUBLE = 131056,
116 JSVAL_TAG_INT32 = 131057,
117 JSVAL_TAG_UNDEFINED = 131058,
118 JSVAL_TAG_STRING = 131061,
119 JSVAL_TAG_SYMBOL = 131062,
120 JSVAL_TAG_BOOLEAN = 131059,
121 JSVAL_TAG_MAGIC = 131060,
122 JSVAL_TAG_NULL = 131063,
123 JSVAL_TAG_OBJECT = 131064,
124 }
125 #[repr(u64)]
126 #[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
127 pub enum JSValueShiftedTag {
128 JSVAL_SHIFTED_TAG_MAX_DOUBLE = 18444492278190833663,
129 JSVAL_SHIFTED_TAG_INT32 = 18444633011384221696,
130 JSVAL_SHIFTED_TAG_UNDEFINED = 18444773748872577024,
131 JSVAL_SHIFTED_TAG_STRING = 18445195961337643008,
132 JSVAL_SHIFTED_TAG_SYMBOL = 18445336698825998336,
133 JSVAL_SHIFTED_TAG_BOOLEAN = 18444914486360932352,
134 JSVAL_SHIFTED_TAG_MAGIC = 18445055223849287680,
135 JSVAL_SHIFTED_TAG_NULL = 18445477436314353664,
136 JSVAL_SHIFTED_TAG_OBJECT = 18445618173802708992,
137 }
138 #[repr(u32)]
139 #[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
140 pub enum JSWhyMagic {
141 /// a hole in a native object's elements
142 JS_ELEMENTS_HOLE = 0,
143 /// there is not a pending iterator value
144 JS_NO_ITER_VALUE = 1,
145 /// exception value thrown when closing a generator
146 JS_GENERATOR_CLOSING = 2,
147 /// compiler sentinel value
148 JS_NO_CONSTANT = 3,
149 /// used in debug builds to catch tracing errors
150 JS_THIS_POISON = 4,
151 /// used in debug builds to catch tracing errors
152 JS_ARG_POISON = 5,
153 /// an empty subnode in the AST serializer
154 JS_SERIALIZE_NO_NODE = 6,
155 /// lazy arguments value on the stack
156 JS_LAZY_ARGUMENTS = 7,
157 /// optimized-away 'arguments' value
158 JS_OPTIMIZED_ARGUMENTS = 8,
159 /// magic value passed to natives to indicate construction
160 JS_IS_CONSTRUCTING = 9,
161 /// arguments.callee has been overwritten
162 JS_OVERWRITTEN_CALLEE = 10,
163 /// value of static block object slot
164 JS_BLOCK_NEEDS_CLONE = 11,
165 /// see class js::HashableValue
166 JS_HASH_KEY_EMPTY = 12,
167 /// error while running Ion code
168 JS_ION_ERROR = 13,
169 /// missing recover instruction result
170 JS_ION_BAILOUT = 14,
171 /// optimized out slot
172 JS_OPTIMIZED_OUT = 15,
173 /// uninitialized lexical bindings that produce ReferenceError on touch.
174 JS_UNINITIALIZED_LEXICAL = 16,
175 /// for local use
176 JS_GENERIC_MAGIC = 17,
177 /// for local use
178 JS_WHY_MAGIC_COUNT = 18,
179 }
180 #[repr(C)]
181 #[derive(Copy, Clone)]
182 pub union jsval_layout {
183 pub asBits: u64,
184 pub debugView: jsval_layout__bindgen_ty_1,
185 pub s: jsval_layout__bindgen_ty_2,
186 pub asDouble: f64,
187 pub asPtr: *mut ::std::os::raw::c_void,
188 pub asWord: usize,
189 pub asUIntPtr: usize,
190 }
191 #[repr(C)]
192 #[repr(align(8))]
193 #[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
194 pub struct jsval_layout__bindgen_ty_1 {
195 pub _bitfield_align_1: [u64; 0],
196 pub _bitfield_1: __BindgenBitfieldUnit<[u8; 8usize]>,
197 }
198 #[test]
bindgen_test_layout_jsval_layout__bindgen_ty_1()199 fn bindgen_test_layout_jsval_layout__bindgen_ty_1() {
200 assert_eq!(
201 ::std::mem::size_of::<jsval_layout__bindgen_ty_1>(),
202 8usize,
203 concat!("Size of: ", stringify!(jsval_layout__bindgen_ty_1))
204 );
205 assert_eq!(
206 ::std::mem::align_of::<jsval_layout__bindgen_ty_1>(),
207 8usize,
208 concat!("Alignment of ", stringify!(jsval_layout__bindgen_ty_1))
209 );
210 }
211 impl Default for jsval_layout__bindgen_ty_1 {
default() -> Self212 fn default() -> Self {
213 let mut s = ::std::mem::MaybeUninit::<Self>::uninit();
214 unsafe {
215 ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
216 s.assume_init()
217 }
218 }
219 }
220 impl jsval_layout__bindgen_ty_1 {
221 #[inline]
payload47(&self) -> u64222 pub fn payload47(&self) -> u64 {
223 unsafe {
224 ::std::mem::transmute(self._bitfield_1.get(0usize, 47u8) as u64)
225 }
226 }
227 #[inline]
set_payload47(&mut self, val: u64)228 pub fn set_payload47(&mut self, val: u64) {
229 unsafe {
230 let val: u64 = ::std::mem::transmute(val);
231 self._bitfield_1.set(0usize, 47u8, val as u64)
232 }
233 }
234 #[inline]
tag(&self) -> JSValueTag235 pub fn tag(&self) -> JSValueTag {
236 unsafe {
237 ::std::mem::transmute(self._bitfield_1.get(47usize, 17u8) as u32)
238 }
239 }
240 #[inline]
set_tag(&mut self, val: JSValueTag)241 pub fn set_tag(&mut self, val: JSValueTag) {
242 unsafe {
243 let val: u32 = ::std::mem::transmute(val);
244 self._bitfield_1.set(47usize, 17u8, val as u64)
245 }
246 }
247 #[inline]
new_bitfield_1( payload47: u64, tag: JSValueTag, ) -> __BindgenBitfieldUnit<[u8; 8usize]>248 pub fn new_bitfield_1(
249 payload47: u64,
250 tag: JSValueTag,
251 ) -> __BindgenBitfieldUnit<[u8; 8usize]> {
252 let mut __bindgen_bitfield_unit: __BindgenBitfieldUnit<[u8; 8usize]> =
253 Default::default();
254 __bindgen_bitfield_unit.set(0usize, 47u8, {
255 let payload47: u64 = unsafe { ::std::mem::transmute(payload47) };
256 payload47 as u64
257 });
258 __bindgen_bitfield_unit.set(47usize, 17u8, {
259 let tag: u32 = unsafe { ::std::mem::transmute(tag) };
260 tag as u64
261 });
262 __bindgen_bitfield_unit
263 }
264 }
265 #[repr(C)]
266 #[derive(Copy, Clone)]
267 pub struct jsval_layout__bindgen_ty_2 {
268 pub payload: jsval_layout__bindgen_ty_2__bindgen_ty_1,
269 }
270 #[repr(C)]
271 #[derive(Copy, Clone)]
272 pub union jsval_layout__bindgen_ty_2__bindgen_ty_1 {
273 pub i32_: i32,
274 pub u32_: u32,
275 pub why: JSWhyMagic,
276 }
277 #[test]
bindgen_test_layout_jsval_layout__bindgen_ty_2__bindgen_ty_1()278 fn bindgen_test_layout_jsval_layout__bindgen_ty_2__bindgen_ty_1() {
279 const UNINIT: ::std::mem::MaybeUninit<
280 jsval_layout__bindgen_ty_2__bindgen_ty_1,
281 > = ::std::mem::MaybeUninit::uninit();
282 let ptr = UNINIT.as_ptr();
283 assert_eq!(
284 ::std::mem::size_of::<jsval_layout__bindgen_ty_2__bindgen_ty_1>(),
285 4usize,
286 concat!(
287 "Size of: ",
288 stringify!(jsval_layout__bindgen_ty_2__bindgen_ty_1)
289 )
290 );
291 assert_eq!(
292 ::std::mem::align_of::<jsval_layout__bindgen_ty_2__bindgen_ty_1>(),
293 4usize,
294 concat!(
295 "Alignment of ",
296 stringify!(jsval_layout__bindgen_ty_2__bindgen_ty_1)
297 )
298 );
299 assert_eq!(
300 unsafe { ::std::ptr::addr_of!((*ptr).i32_) as usize - ptr as usize },
301 0usize,
302 concat!(
303 "Offset of field: ",
304 stringify!(jsval_layout__bindgen_ty_2__bindgen_ty_1),
305 "::",
306 stringify!(i32_)
307 )
308 );
309 assert_eq!(
310 unsafe { ::std::ptr::addr_of!((*ptr).u32_) as usize - ptr as usize },
311 0usize,
312 concat!(
313 "Offset of field: ",
314 stringify!(jsval_layout__bindgen_ty_2__bindgen_ty_1),
315 "::",
316 stringify!(u32_)
317 )
318 );
319 assert_eq!(
320 unsafe { ::std::ptr::addr_of!((*ptr).why) as usize - ptr as usize },
321 0usize,
322 concat!(
323 "Offset of field: ",
324 stringify!(jsval_layout__bindgen_ty_2__bindgen_ty_1),
325 "::",
326 stringify!(why)
327 )
328 );
329 }
330 impl Default for jsval_layout__bindgen_ty_2__bindgen_ty_1 {
default() -> Self331 fn default() -> Self {
332 let mut s = ::std::mem::MaybeUninit::<Self>::uninit();
333 unsafe {
334 ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
335 s.assume_init()
336 }
337 }
338 }
339 #[test]
bindgen_test_layout_jsval_layout__bindgen_ty_2()340 fn bindgen_test_layout_jsval_layout__bindgen_ty_2() {
341 const UNINIT: ::std::mem::MaybeUninit<jsval_layout__bindgen_ty_2> =
342 ::std::mem::MaybeUninit::uninit();
343 let ptr = UNINIT.as_ptr();
344 assert_eq!(
345 ::std::mem::size_of::<jsval_layout__bindgen_ty_2>(),
346 4usize,
347 concat!("Size of: ", stringify!(jsval_layout__bindgen_ty_2))
348 );
349 assert_eq!(
350 ::std::mem::align_of::<jsval_layout__bindgen_ty_2>(),
351 4usize,
352 concat!("Alignment of ", stringify!(jsval_layout__bindgen_ty_2))
353 );
354 assert_eq!(
355 unsafe { ::std::ptr::addr_of!((*ptr).payload) as usize - ptr as usize },
356 0usize,
357 concat!(
358 "Offset of field: ",
359 stringify!(jsval_layout__bindgen_ty_2),
360 "::",
361 stringify!(payload)
362 )
363 );
364 }
365 impl Default for jsval_layout__bindgen_ty_2 {
default() -> Self366 fn default() -> Self {
367 let mut s = ::std::mem::MaybeUninit::<Self>::uninit();
368 unsafe {
369 ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
370 s.assume_init()
371 }
372 }
373 }
374 #[test]
bindgen_test_layout_jsval_layout()375 fn bindgen_test_layout_jsval_layout() {
376 const UNINIT: ::std::mem::MaybeUninit<jsval_layout> =
377 ::std::mem::MaybeUninit::uninit();
378 let ptr = UNINIT.as_ptr();
379 assert_eq!(
380 ::std::mem::size_of::<jsval_layout>(),
381 8usize,
382 concat!("Size of: ", stringify!(jsval_layout))
383 );
384 assert_eq!(
385 ::std::mem::align_of::<jsval_layout>(),
386 8usize,
387 concat!("Alignment of ", stringify!(jsval_layout))
388 );
389 assert_eq!(
390 unsafe { ::std::ptr::addr_of!((*ptr).asBits) as usize - ptr as usize },
391 0usize,
392 concat!(
393 "Offset of field: ",
394 stringify!(jsval_layout),
395 "::",
396 stringify!(asBits)
397 )
398 );
399 assert_eq!(
400 unsafe {
401 ::std::ptr::addr_of!((*ptr).debugView) as usize - ptr as usize
402 },
403 0usize,
404 concat!(
405 "Offset of field: ",
406 stringify!(jsval_layout),
407 "::",
408 stringify!(debugView)
409 )
410 );
411 assert_eq!(
412 unsafe { ::std::ptr::addr_of!((*ptr).s) as usize - ptr as usize },
413 0usize,
414 concat!(
415 "Offset of field: ",
416 stringify!(jsval_layout),
417 "::",
418 stringify!(s)
419 )
420 );
421 assert_eq!(
422 unsafe {
423 ::std::ptr::addr_of!((*ptr).asDouble) as usize - ptr as usize
424 },
425 0usize,
426 concat!(
427 "Offset of field: ",
428 stringify!(jsval_layout),
429 "::",
430 stringify!(asDouble)
431 )
432 );
433 assert_eq!(
434 unsafe { ::std::ptr::addr_of!((*ptr).asPtr) as usize - ptr as usize },
435 0usize,
436 concat!(
437 "Offset of field: ",
438 stringify!(jsval_layout),
439 "::",
440 stringify!(asPtr)
441 )
442 );
443 assert_eq!(
444 unsafe { ::std::ptr::addr_of!((*ptr).asWord) as usize - ptr as usize },
445 0usize,
446 concat!(
447 "Offset of field: ",
448 stringify!(jsval_layout),
449 "::",
450 stringify!(asWord)
451 )
452 );
453 assert_eq!(
454 unsafe {
455 ::std::ptr::addr_of!((*ptr).asUIntPtr) as usize - ptr as usize
456 },
457 0usize,
458 concat!(
459 "Offset of field: ",
460 stringify!(jsval_layout),
461 "::",
462 stringify!(asUIntPtr)
463 )
464 );
465 }
466 impl Default for jsval_layout {
default() -> Self467 fn default() -> Self {
468 let mut s = ::std::mem::MaybeUninit::<Self>::uninit();
469 unsafe {
470 ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
471 s.assume_init()
472 }
473 }
474 }
475 #[repr(C)]
476 #[derive(Copy, Clone)]
477 pub struct Value {
478 pub data: jsval_layout,
479 }
480 #[test]
bindgen_test_layout_Value()481 fn bindgen_test_layout_Value() {
482 const UNINIT: ::std::mem::MaybeUninit<Value> =
483 ::std::mem::MaybeUninit::uninit();
484 let ptr = UNINIT.as_ptr();
485 assert_eq!(
486 ::std::mem::size_of::<Value>(),
487 8usize,
488 concat!("Size of: ", stringify!(Value))
489 );
490 assert_eq!(
491 ::std::mem::align_of::<Value>(),
492 8usize,
493 concat!("Alignment of ", stringify!(Value))
494 );
495 assert_eq!(
496 unsafe { ::std::ptr::addr_of!((*ptr).data) as usize - ptr as usize },
497 0usize,
498 concat!(
499 "Offset of field: ",
500 stringify!(Value),
501 "::",
502 stringify!(data)
503 )
504 );
505 }
506 impl Default for Value {
default() -> Self507 fn default() -> Self {
508 let mut s = ::std::mem::MaybeUninit::<Self>::uninit();
509 unsafe {
510 ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
511 s.assume_init()
512 }
513 }
514 }
515