mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 506721 - Convert JSVAL_TO_INT and INT_TO_JSVAL to functions. r=Waldo.
This commit is contained in:
parent
7470eaa57b
commit
08c6a1c780
@ -234,15 +234,25 @@ STRING_TO_JSVAL(JSString *str)
|
||||
#define JSVAL_INT_MAX (JSVAL_INT_POW2(30) - 1)
|
||||
|
||||
/* Not a function, because we have static asserts that use it */
|
||||
#define INT_FITS_IN_JSVAL(i) ((jsuint)(i) - (jsuint)JSVAL_INT_MIN <= \
|
||||
#define INT_FITS_IN_JSVAL(i) ((jsuint)(i) - (jsuint)JSVAL_INT_MIN <= \
|
||||
(jsuint)(JSVAL_INT_MAX - JSVAL_INT_MIN))
|
||||
/* Not a function, because we have static asserts that use it */
|
||||
/* FIXME: Bug 506721, since that means we can't assert JSVAL_IS_INT(v) */
|
||||
#define JSVAL_TO_INT(v) ((jsint)(v) >> 1)
|
||||
|
||||
static JS_ALWAYS_INLINE jsint
|
||||
JSVAL_TO_INT(jsval v)
|
||||
{
|
||||
JS_ASSERT(JSVAL_IS_INT(v));
|
||||
return (jsint) v >> 1;
|
||||
}
|
||||
|
||||
/* Not a function, because we have static asserts that use it */
|
||||
/* FIXME: Bug 506721, since that means we can't assert INT_FITS_IN_JSVAL(i) */
|
||||
#define INT_TO_JSVAL(i) (((jsval)(i) << 1) | JSVAL_INT)
|
||||
#define INT_TO_JSVAL_CONSTEXPR(i) (((jsval)(i) << 1) | JSVAL_INT)
|
||||
|
||||
static JS_ALWAYS_INLINE jsval
|
||||
INT_TO_JSVAL(jsint i)
|
||||
{
|
||||
JS_ASSERT(INT_FITS_IN_JSVAL(i));
|
||||
return INT_TO_JSVAL_CONSTEXPR(i);
|
||||
}
|
||||
|
||||
/* Convert between boolean and jsval, asserting that inputs are valid. */
|
||||
static JS_ALWAYS_INLINE JSBool
|
||||
|
@ -623,7 +623,7 @@ args_resolve(JSContext *cx, JSObject *obj, jsval idval, uintN flags,
|
||||
if (str == ATOM_TO_STRING(atom)) {
|
||||
if (TEST_OVERRIDE_BIT(fp, ARGS_CALLEE))
|
||||
return true;
|
||||
v = INT_TO_JSVAL(fp->callee);
|
||||
v = INT_TO_JSVAL(reinterpret_cast<jsint>(fp->callee));
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
|
@ -2436,8 +2436,8 @@ js_DumpOpMeters()
|
||||
#define CAN_DO_FAST_INC_DEC(v) (((((v) << 1) ^ v) & 0x80000001) == 1)
|
||||
|
||||
JS_STATIC_ASSERT(JSVAL_INT == 1);
|
||||
JS_STATIC_ASSERT(!CAN_DO_FAST_INC_DEC(INT_TO_JSVAL(JSVAL_INT_MIN)));
|
||||
JS_STATIC_ASSERT(!CAN_DO_FAST_INC_DEC(INT_TO_JSVAL(JSVAL_INT_MAX)));
|
||||
JS_STATIC_ASSERT(!CAN_DO_FAST_INC_DEC(INT_TO_JSVAL_CONSTEXPR(JSVAL_INT_MIN)));
|
||||
JS_STATIC_ASSERT(!CAN_DO_FAST_INC_DEC(INT_TO_JSVAL_CONSTEXPR(JSVAL_INT_MAX)));
|
||||
|
||||
/*
|
||||
* Conditional assert to detect failure to clear a pending exception that is
|
||||
|
Loading…
Reference in New Issue
Block a user