explicit LooseEqualityData(JSContext* cx) : qNaN(cx), sNaN(cx), d42(cx), i42(cx), undef(cx), null(cx), obj(cx), poszero(cx), negzero(cx) { qNaN = JS::CanonicalizedDoubleValue(numeric_limits<double>::quiet_NaN()); sNaN = JS::CanonicalizedDoubleValue(numeric_limits<double>::signaling_NaN()); d42 = JS::DoubleValue(42.0); i42 = JS::Int32Value(42); undef = JS::UndefinedValue(); null = JS::NullValue(); obj = JS::ObjectOrNullValue(JS::CurrentGlobalOrNull(cx)); poszero = JS::DoubleValue(0.0); negzero = JS::DoubleValue(-0.0); #ifdef XP_WIN # define copysign _copysign #endif MOZ_RELEASE_ASSERT(copysign(1.0, poszero.toDouble()) == 1.0); MOZ_RELEASE_ASSERT(copysign(1.0, negzero.toDouble()) == -1.0); #ifdef XP_WIN # undef copysign #endif }
explicit LooseEqualityData(JSContext *cx) : qNaN(cx), sNaN(cx), d42(cx), i42(cx), undef(cx), null(cx), obj(cx), poszero(cx), negzero(cx) { qNaN = DOUBLE_TO_JSVAL(numeric_limits<double>::quiet_NaN()); sNaN = DOUBLE_TO_JSVAL(numeric_limits<double>::signaling_NaN()); d42 = DOUBLE_TO_JSVAL(42.0); i42 = INT_TO_JSVAL(42); undef = JSVAL_VOID; null = JSVAL_NULL; obj = OBJECT_TO_JSVAL(JS::CurrentGlobalOrNull(cx)); poszero = DOUBLE_TO_JSVAL(0.0); negzero = DOUBLE_TO_JSVAL(-0.0); #ifdef XP_WIN # define copysign _copysign #endif JS_ASSERT(copysign(1.0, poszero.toDouble()) == 1.0); JS_ASSERT(copysign(1.0, negzero.toDouble()) == -1.0); #ifdef XP_WIN # undef copysign #endif }
JSBool JSI_GUIMouse::construct(JSContext* cx, uint argc, jsval* vp) { JSObject* obj = JS_NewObject(cx, &JSI_GUIMouse::JSI_class, NULL, NULL); if (argc == 3) { JS::RootedValue v0(cx, JS_ARGV(cx, vp)[0]); JS::RootedValue v1(cx, JS_ARGV(cx, vp)[1]); JS::RootedValue v2(cx, JS_ARGV(cx, vp)[2]); JS_SetProperty(cx, obj, "x", v0.address()); JS_SetProperty(cx, obj, "y", v1.address()); JS_SetProperty(cx, obj, "buttons", v2.address()); } else { JS::RootedValue zero (cx, JS::NumberValue(0)); JS_SetProperty(cx, obj, "x", zero.address()); JS_SetProperty(cx, obj, "y", zero.address()); JS_SetProperty(cx, obj, "buttons", zero.address()); } JS_SET_RVAL(cx, vp, OBJECT_TO_JSVAL(obj)); return JS_TRUE; }