Skip to content

Commit

Permalink
Removed Unnecessary Macro
Browse files Browse the repository at this point in the history
  • Loading branch information
Redfire75369 committed Sep 11, 2023
1 parent 7b4238d commit 260aa5e
Showing 1 changed file with 18 additions and 34 deletions.
52 changes: 18 additions & 34 deletions mozjs/src/jsval.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,43 +30,27 @@ const JSVAL_TAG_MAX_DOUBLE: u32 = 0x1FFF0;
#[cfg(target_pointer_width = "32")]
const JSVAL_TAG_CLEAR: u32 = 0xFFFFFF80;

const CELL_ALIGN_MASK: u64 = (1 << 3) - 1;
#[cfg(target_pointer_width = "64")]
const JSVAL_TAG_BOX: u32 = JSVAL_TAG_MAX_DOUBLE;

macro_rules! value_tag {
(enum $name:ident { $($variant:ident = $value_type:path,)* }) => {
#[cfg(target_pointer_width = "64")]
#[repr(u32)]
#[allow(dead_code)]
enum $name {
$(
$variant = JSVAL_TAG_MAX_DOUBLE | ($value_type as u32),
)*
}
#[cfg(target_pointer_width = "32")]
const JSVAL_TAG_BOX: u32 = JSVAL_TAG_CLEAR;

#[cfg(target_pointer_width = "32")]
#[repr(u32)]
#[allow(dead_code)]
enum $name {
$(
$variant = JSVAL_TAG_CLEAR | ($value_type as u32),
)*
}
};
}
const CELL_ALIGN_MASK: u64 = (1 << 3) - 1;

value_tag! {
enum ValueTag {
INT32 = JSValueType::JSVAL_TYPE_INT32,
UNDEFINED = JSValueType::JSVAL_TYPE_UNDEFINED,
NULL = JSValueType::JSVAL_TYPE_NULL,
BOOLEAN = JSValueType::JSVAL_TYPE_BOOLEAN,
MAGIC = JSValueType::JSVAL_TYPE_MAGIC,
STRING = JSValueType::JSVAL_TYPE_STRING,
SYMBOL = JSValueType::JSVAL_TYPE_SYMBOL,
PRIVATE_GCTHING = JSValueType::JSVAL_TYPE_PRIVATE_GCTHING,
BIGINT = JSValueType::JSVAL_TYPE_BIGINT,
OBJECT = JSValueType::JSVAL_TYPE_OBJECT,
}
#[repr(u32)]
#[allow(dead_code)]
enum ValueTag {
INT32 = JSVAL_TAG_BOX | (JSValueType::JSVAL_TYPE_INT32 as u32),
UNDEFINED = JSVAL_TAG_BOX | (JSValueType::JSVAL_TYPE_UNDEFINED as u32),
NULL = JSVAL_TAG_BOX | (JSValueType::JSVAL_TYPE_NULL as u32),
BOOLEAN = JSVAL_TAG_BOX | (JSValueType::JSVAL_TYPE_BOOLEAN as u32),
MAGIC = JSVAL_TAG_BOX | (JSValueType::JSVAL_TYPE_MAGIC as u32),
STRING = JSVAL_TAG_BOX | (JSValueType::JSVAL_TYPE_STRING as u32),
SYMBOL = JSVAL_TAG_BOX | (JSValueType::JSVAL_TYPE_SYMBOL as u32),
PRIVATE_GCTHING = JSVAL_TAG_BOX | (JSValueType::JSVAL_TYPE_PRIVATE_GCTHING as u32),
BIGINT = JSVAL_TAG_BOX | (JSValueType::JSVAL_TYPE_BIGINT as u32),
OBJECT = JSVAL_TAG_BOX | (JSValueType::JSVAL_TYPE_OBJECT as u32),
}

#[repr(u64)]
Expand Down

0 comments on commit 260aa5e

Please sign in to comment.