• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 #![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)]
2 #[repr(C)]
3 #[derive(Copy, Clone, Debug, Default, Eq, Hash, Ord, PartialEq, PartialOrd)]
4 pub struct __BindgenBitfieldUnit<Storage> {
5     storage: Storage,
6 }
7 impl<Storage> __BindgenBitfieldUnit<Storage> {
8     #[inline]
new(storage: Storage) -> Self9     pub const fn new(storage: Storage) -> Self {
10         Self { storage }
11     }
12 }
13 impl<Storage> __BindgenBitfieldUnit<Storage>
14 where
15     Storage: AsRef<[u8]> + AsMut<[u8]>,
16 {
17     #[inline]
get_bit(&self, index: usize) -> bool18     pub fn get_bit(&self, index: usize) -> bool {
19         debug_assert!(index / 8 < self.storage.as_ref().len());
20         let byte_index = index / 8;
21         let byte = self.storage.as_ref()[byte_index];
22         let bit_index = if cfg!(target_endian = "big") {
23             7 - (index % 8)
24         } else {
25             index % 8
26         };
27         let mask = 1 << bit_index;
28         byte & mask == mask
29     }
30     #[inline]
set_bit(&mut self, index: usize, val: bool)31     pub fn set_bit(&mut self, index: usize, val: bool) {
32         debug_assert!(index / 8 < self.storage.as_ref().len());
33         let byte_index = index / 8;
34         let byte = &mut self.storage.as_mut()[byte_index];
35         let bit_index = if cfg!(target_endian = "big") {
36             7 - (index % 8)
37         } else {
38             index % 8
39         };
40         let mask = 1 << bit_index;
41         if val {
42             *byte |= mask;
43         } else {
44             *byte &= !mask;
45         }
46     }
47     #[inline]
get(&self, bit_offset: usize, bit_width: u8) -> u6448     pub fn get(&self, bit_offset: usize, bit_width: u8) -> u64 {
49         debug_assert!(bit_width <= 64);
50         debug_assert!(bit_offset / 8 < self.storage.as_ref().len());
51         debug_assert!(
52             (bit_offset + (bit_width as usize)) / 8 <= self.storage.as_ref().len(),
53         );
54         let mut val = 0;
55         for i in 0..(bit_width as usize) {
56             if self.get_bit(i + bit_offset) {
57                 let index = if cfg!(target_endian = "big") {
58                     bit_width as usize - 1 - i
59                 } else {
60                     i
61                 };
62                 val |= 1 << index;
63             }
64         }
65         val
66     }
67     #[inline]
set(&mut self, bit_offset: usize, bit_width: u8, val: u64)68     pub fn set(&mut self, bit_offset: usize, bit_width: u8, val: u64) {
69         debug_assert!(bit_width <= 64);
70         debug_assert!(bit_offset / 8 < self.storage.as_ref().len());
71         debug_assert!(
72             (bit_offset + (bit_width as usize)) / 8 <= self.storage.as_ref().len(),
73         );
74         for i in 0..(bit_width as usize) {
75             let mask = 1 << i;
76             let val_bit_is_set = val & mask == mask;
77             let index = if cfg!(target_endian = "big") {
78                 bit_width as usize - 1 - i
79             } else {
80                 i
81             };
82             self.set_bit(index + bit_offset, val_bit_is_set);
83         }
84     }
85 }
86 pub const JSVAL_TAG_SHIFT: u32 = 47;
87 pub const JSVAL_PAYLOAD_MASK: u64 = 140737488355327;
88 pub const JSVAL_TAG_MASK: i64 = -140737488355328;
89 #[repr(u8)]
90 #[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
91 pub enum JSValueType {
92     JSVAL_TYPE_DOUBLE = 0,
93     JSVAL_TYPE_INT32 = 1,
94     JSVAL_TYPE_UNDEFINED = 2,
95     JSVAL_TYPE_BOOLEAN = 3,
96     JSVAL_TYPE_MAGIC = 4,
97     JSVAL_TYPE_STRING = 5,
98     JSVAL_TYPE_SYMBOL = 6,
99     JSVAL_TYPE_NULL = 7,
100     JSVAL_TYPE_OBJECT = 8,
101     JSVAL_TYPE_UNKNOWN = 32,
102     JSVAL_TYPE_MISSING = 33,
103 }
104 #[repr(u32)]
105 #[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
106 pub enum JSValueTag {
107     JSVAL_TAG_MAX_DOUBLE = 131056,
108     JSVAL_TAG_INT32 = 131057,
109     JSVAL_TAG_UNDEFINED = 131058,
110     JSVAL_TAG_STRING = 131061,
111     JSVAL_TAG_SYMBOL = 131062,
112     JSVAL_TAG_BOOLEAN = 131059,
113     JSVAL_TAG_MAGIC = 131060,
114     JSVAL_TAG_NULL = 131063,
115     JSVAL_TAG_OBJECT = 131064,
116 }
117 #[repr(u64)]
118 #[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
119 pub enum JSValueShiftedTag {
120     JSVAL_SHIFTED_TAG_MAX_DOUBLE = 18444492278190833663,
121     JSVAL_SHIFTED_TAG_INT32 = 18444633011384221696,
122     JSVAL_SHIFTED_TAG_UNDEFINED = 18444773748872577024,
123     JSVAL_SHIFTED_TAG_STRING = 18445195961337643008,
124     JSVAL_SHIFTED_TAG_SYMBOL = 18445336698825998336,
125     JSVAL_SHIFTED_TAG_BOOLEAN = 18444914486360932352,
126     JSVAL_SHIFTED_TAG_MAGIC = 18445055223849287680,
127     JSVAL_SHIFTED_TAG_NULL = 18445477436314353664,
128     JSVAL_SHIFTED_TAG_OBJECT = 18445618173802708992,
129 }
130 #[repr(u32)]
131 #[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
132 pub enum JSWhyMagic {
133     /// a hole in a native object's elements
134     JS_ELEMENTS_HOLE = 0,
135     /// there is not a pending iterator value
136     JS_NO_ITER_VALUE = 1,
137     /// exception value thrown when closing a generator
138     JS_GENERATOR_CLOSING = 2,
139     /// compiler sentinel value
140     JS_NO_CONSTANT = 3,
141     /// used in debug builds to catch tracing errors
142     JS_THIS_POISON = 4,
143     /// used in debug builds to catch tracing errors
144     JS_ARG_POISON = 5,
145     /// an empty subnode in the AST serializer
146     JS_SERIALIZE_NO_NODE = 6,
147     /// lazy arguments value on the stack
148     JS_LAZY_ARGUMENTS = 7,
149     /// optimized-away 'arguments' value
150     JS_OPTIMIZED_ARGUMENTS = 8,
151     /// magic value passed to natives to indicate construction
152     JS_IS_CONSTRUCTING = 9,
153     /// arguments.callee has been overwritten
154     JS_OVERWRITTEN_CALLEE = 10,
155     /// value of static block object slot
156     JS_BLOCK_NEEDS_CLONE = 11,
157     /// see class js::HashableValue
158     JS_HASH_KEY_EMPTY = 12,
159     /// error while running Ion code
160     JS_ION_ERROR = 13,
161     /// missing recover instruction result
162     JS_ION_BAILOUT = 14,
163     /// optimized out slot
164     JS_OPTIMIZED_OUT = 15,
165     /// uninitialized lexical bindings that produce ReferenceError on touch.
166     JS_UNINITIALIZED_LEXICAL = 16,
167     /// for local use
168     JS_GENERIC_MAGIC = 17,
169     /// for local use
170     JS_WHY_MAGIC_COUNT = 18,
171 }
172 #[repr(C)]
173 #[derive(Copy, Clone)]
174 pub union jsval_layout {
175     pub asBits: u64,
176     pub debugView: jsval_layout__bindgen_ty_1,
177     pub s: jsval_layout__bindgen_ty_2,
178     pub asDouble: f64,
179     pub asPtr: *mut ::std::os::raw::c_void,
180     pub asWord: usize,
181     pub asUIntPtr: usize,
182 }
183 #[repr(C)]
184 #[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
185 pub struct jsval_layout__bindgen_ty_1 {
186     pub _bitfield_align_1: [u64; 0],
187     pub _bitfield_1: __BindgenBitfieldUnit<[u8; 8usize]>,
188 }
189 #[allow(clippy::unnecessary_operation, clippy::identity_op)]
190 const _: () = {
191     [
192         "Size of jsval_layout__bindgen_ty_1",
193     ][::std::mem::size_of::<jsval_layout__bindgen_ty_1>() - 8usize];
194     [
195         "Alignment of jsval_layout__bindgen_ty_1",
196     ][::std::mem::align_of::<jsval_layout__bindgen_ty_1>() - 8usize];
197 };
198 impl Default for jsval_layout__bindgen_ty_1 {
default() -> Self199     fn default() -> Self {
200         let mut s = ::std::mem::MaybeUninit::<Self>::uninit();
201         unsafe {
202             ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
203             s.assume_init()
204         }
205     }
206 }
207 impl jsval_layout__bindgen_ty_1 {
208     #[inline]
payload47(&self) -> u64209     pub fn payload47(&self) -> u64 {
210         unsafe { ::std::mem::transmute(self._bitfield_1.get(0usize, 47u8) as u64) }
211     }
212     #[inline]
set_payload47(&mut self, val: u64)213     pub fn set_payload47(&mut self, val: u64) {
214         unsafe {
215             let val: u64 = ::std::mem::transmute(val);
216             self._bitfield_1.set(0usize, 47u8, val as u64)
217         }
218     }
219     #[inline]
tag(&self) -> JSValueTag220     pub fn tag(&self) -> JSValueTag {
221         unsafe { ::std::mem::transmute(self._bitfield_1.get(47usize, 17u8) as u32) }
222     }
223     #[inline]
set_tag(&mut self, val: JSValueTag)224     pub fn set_tag(&mut self, val: JSValueTag) {
225         unsafe {
226             let val: u32 = ::std::mem::transmute(val);
227             self._bitfield_1.set(47usize, 17u8, val as u64)
228         }
229     }
230     #[inline]
new_bitfield_1( payload47: u64, tag: JSValueTag, ) -> __BindgenBitfieldUnit<[u8; 8usize]>231     pub fn new_bitfield_1(
232         payload47: u64,
233         tag: JSValueTag,
234     ) -> __BindgenBitfieldUnit<[u8; 8usize]> {
235         let mut __bindgen_bitfield_unit: __BindgenBitfieldUnit<[u8; 8usize]> = Default::default();
236         __bindgen_bitfield_unit
237             .set(
238                 0usize,
239                 47u8,
240                 {
241                     let payload47: u64 = unsafe { ::std::mem::transmute(payload47) };
242                     payload47 as u64
243                 },
244             );
245         __bindgen_bitfield_unit
246             .set(
247                 47usize,
248                 17u8,
249                 {
250                     let tag: u32 = unsafe { ::std::mem::transmute(tag) };
251                     tag as u64
252                 },
253             );
254         __bindgen_bitfield_unit
255     }
256 }
257 #[repr(C)]
258 #[derive(Copy, Clone)]
259 pub struct jsval_layout__bindgen_ty_2 {
260     pub payload: jsval_layout__bindgen_ty_2__bindgen_ty_1,
261 }
262 #[repr(C)]
263 #[derive(Copy, Clone)]
264 pub union jsval_layout__bindgen_ty_2__bindgen_ty_1 {
265     pub i32_: i32,
266     pub u32_: u32,
267     pub why: JSWhyMagic,
268 }
269 #[allow(clippy::unnecessary_operation, clippy::identity_op)]
270 const _: () = {
271     [
272         "Size of jsval_layout__bindgen_ty_2__bindgen_ty_1",
273     ][::std::mem::size_of::<jsval_layout__bindgen_ty_2__bindgen_ty_1>() - 4usize];
274     [
275         "Alignment of jsval_layout__bindgen_ty_2__bindgen_ty_1",
276     ][::std::mem::align_of::<jsval_layout__bindgen_ty_2__bindgen_ty_1>() - 4usize];
277     [
278         "Offset of field: jsval_layout__bindgen_ty_2__bindgen_ty_1::i32_",
279     ][::std::mem::offset_of!(jsval_layout__bindgen_ty_2__bindgen_ty_1, i32_) - 0usize];
280     [
281         "Offset of field: jsval_layout__bindgen_ty_2__bindgen_ty_1::u32_",
282     ][::std::mem::offset_of!(jsval_layout__bindgen_ty_2__bindgen_ty_1, u32_) - 0usize];
283     [
284         "Offset of field: jsval_layout__bindgen_ty_2__bindgen_ty_1::why",
285     ][::std::mem::offset_of!(jsval_layout__bindgen_ty_2__bindgen_ty_1, why) - 0usize];
286 };
287 impl Default for jsval_layout__bindgen_ty_2__bindgen_ty_1 {
default() -> Self288     fn default() -> Self {
289         let mut s = ::std::mem::MaybeUninit::<Self>::uninit();
290         unsafe {
291             ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
292             s.assume_init()
293         }
294     }
295 }
296 #[allow(clippy::unnecessary_operation, clippy::identity_op)]
297 const _: () = {
298     [
299         "Size of jsval_layout__bindgen_ty_2",
300     ][::std::mem::size_of::<jsval_layout__bindgen_ty_2>() - 4usize];
301     [
302         "Alignment of jsval_layout__bindgen_ty_2",
303     ][::std::mem::align_of::<jsval_layout__bindgen_ty_2>() - 4usize];
304     [
305         "Offset of field: jsval_layout__bindgen_ty_2::payload",
306     ][::std::mem::offset_of!(jsval_layout__bindgen_ty_2, payload) - 0usize];
307 };
308 impl Default for jsval_layout__bindgen_ty_2 {
default() -> Self309     fn default() -> Self {
310         let mut s = ::std::mem::MaybeUninit::<Self>::uninit();
311         unsafe {
312             ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
313             s.assume_init()
314         }
315     }
316 }
317 #[allow(clippy::unnecessary_operation, clippy::identity_op)]
318 const _: () = {
319     ["Size of jsval_layout"][::std::mem::size_of::<jsval_layout>() - 8usize];
320     ["Alignment of jsval_layout"][::std::mem::align_of::<jsval_layout>() - 8usize];
321     [
322         "Offset of field: jsval_layout::asBits",
323     ][::std::mem::offset_of!(jsval_layout, asBits) - 0usize];
324     [
325         "Offset of field: jsval_layout::debugView",
326     ][::std::mem::offset_of!(jsval_layout, debugView) - 0usize];
327     [
328         "Offset of field: jsval_layout::s",
329     ][::std::mem::offset_of!(jsval_layout, s) - 0usize];
330     [
331         "Offset of field: jsval_layout::asDouble",
332     ][::std::mem::offset_of!(jsval_layout, asDouble) - 0usize];
333     [
334         "Offset of field: jsval_layout::asPtr",
335     ][::std::mem::offset_of!(jsval_layout, asPtr) - 0usize];
336     [
337         "Offset of field: jsval_layout::asWord",
338     ][::std::mem::offset_of!(jsval_layout, asWord) - 0usize];
339     [
340         "Offset of field: jsval_layout::asUIntPtr",
341     ][::std::mem::offset_of!(jsval_layout, asUIntPtr) - 0usize];
342 };
343 impl Default for jsval_layout {
default() -> Self344     fn default() -> Self {
345         let mut s = ::std::mem::MaybeUninit::<Self>::uninit();
346         unsafe {
347             ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
348             s.assume_init()
349         }
350     }
351 }
352 #[repr(C)]
353 #[derive(Copy, Clone)]
354 pub struct Value {
355     pub data: jsval_layout,
356 }
357 #[allow(clippy::unnecessary_operation, clippy::identity_op)]
358 const _: () = {
359     ["Size of Value"][::std::mem::size_of::<Value>() - 8usize];
360     ["Alignment of Value"][::std::mem::align_of::<Value>() - 8usize];
361     ["Offset of field: Value::data"][::std::mem::offset_of!(Value, data) - 0usize];
362 };
363 impl Default for Value {
default() -> Self364     fn default() -> Self {
365         let mut s = ::std::mem::MaybeUninit::<Self>::uninit();
366         unsafe {
367             ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
368             s.assume_init()
369         }
370     }
371 }
372