mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1066020: Add JSConstIntegerSpec to jsapi; r=till
This commit is contained in:
parent
5abe73887c
commit
30e7733f10
@ -3218,8 +3218,20 @@ JS_DefineObject(JSContext *cx, HandleObject obj, const char *name, const JSClass
|
||||
return nobj;
|
||||
}
|
||||
|
||||
JS_PUBLIC_API(bool)
|
||||
JS_DefineConstDoubles(JSContext *cx, HandleObject obj, const JSConstDoubleSpec *cds)
|
||||
static inline Value
|
||||
ValueFromScalar(double x)
|
||||
{
|
||||
return DoubleValue(x);
|
||||
}
|
||||
static inline Value
|
||||
ValueFromScalar(int32_t x)
|
||||
{
|
||||
return Int32Value(x);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
static bool
|
||||
DefineConstScalar(JSContext *cx, HandleObject obj, const JSConstScalarSpec<T> *cds)
|
||||
{
|
||||
bool ok;
|
||||
unsigned attrs;
|
||||
@ -3229,7 +3241,7 @@ JS_DefineConstDoubles(JSContext *cx, HandleObject obj, const JSConstDoubleSpec *
|
||||
JSPropertyOpWrapper noget = GetterWrapper(nullptr);
|
||||
JSStrictPropertyOpWrapper noset = SetterWrapper(nullptr);
|
||||
for (ok = true; cds->name; cds++) {
|
||||
RootedValue value(cx, DoubleValue(cds->dval));
|
||||
RootedValue value(cx, ValueFromScalar(cds->val));
|
||||
attrs = cds->flags;
|
||||
if (!attrs)
|
||||
attrs = JSPROP_READONLY | JSPROP_PERMANENT;
|
||||
@ -3240,6 +3252,17 @@ JS_DefineConstDoubles(JSContext *cx, HandleObject obj, const JSConstDoubleSpec *
|
||||
return ok;
|
||||
}
|
||||
|
||||
JS_PUBLIC_API(bool)
|
||||
JS_DefineConstDoubles(JSContext *cx, HandleObject obj, const JSConstDoubleSpec *cds)
|
||||
{
|
||||
return DefineConstScalar(cx, obj, cds);
|
||||
}
|
||||
JS_PUBLIC_API(bool)
|
||||
JS_DefineConstIntegers(JSContext *cx, HandleObject obj, const JSConstIntegerSpec *cis)
|
||||
{
|
||||
return DefineConstScalar(cx, obj, cis);
|
||||
}
|
||||
|
||||
JS_PUBLIC_API(bool)
|
||||
JS_DefineProperties(JSContext *cx, HandleObject obj, const JSPropertySpec *ps)
|
||||
{
|
||||
|
@ -2303,13 +2303,17 @@ extern JS_PUBLIC_API(bool)
|
||||
JS_ConvertStub(JSContext *cx, JS::HandleObject obj, JSType type,
|
||||
JS::MutableHandleValue vp);
|
||||
|
||||
struct JSConstDoubleSpec {
|
||||
double dval;
|
||||
template<typename T>
|
||||
struct JSConstScalarSpec {
|
||||
T val;
|
||||
const char *name;
|
||||
uint8_t flags;
|
||||
uint8_t spare[3];
|
||||
};
|
||||
|
||||
typedef JSConstScalarSpec<double> JSConstDoubleSpec;
|
||||
typedef JSConstScalarSpec<int32_t> JSConstIntegerSpec;
|
||||
|
||||
struct JSJitInfo;
|
||||
|
||||
/*
|
||||
@ -2766,6 +2770,9 @@ JS_DefineObject(JSContext *cx, JS::HandleObject obj, const char *name,
|
||||
extern JS_PUBLIC_API(bool)
|
||||
JS_DefineConstDoubles(JSContext *cx, JS::HandleObject obj, const JSConstDoubleSpec *cds);
|
||||
|
||||
extern JS_PUBLIC_API(bool)
|
||||
JS_DefineConstIntegers(JSContext *cx, JS::HandleObject obj, const JSConstIntegerSpec *cis);
|
||||
|
||||
extern JS_PUBLIC_API(bool)
|
||||
JS_DefineProperties(JSContext *cx, JS::HandleObject obj, const JSPropertySpec *ps);
|
||||
|
||||
|
@ -1101,12 +1101,12 @@ js::InitRuntimeNumberState(JSRuntime *rt)
|
||||
* Our NaN must be one particular canonical value, because we rely on NaN
|
||||
* encoding for our value representation. See Value.h.
|
||||
*/
|
||||
number_constants[NC_NaN].dval = GenericNaN();
|
||||
number_constants[NC_NaN].val = GenericNaN();
|
||||
|
||||
number_constants[NC_POSITIVE_INFINITY].dval = mozilla::PositiveInfinity<double>();
|
||||
number_constants[NC_NEGATIVE_INFINITY].dval = mozilla::NegativeInfinity<double>();
|
||||
number_constants[NC_POSITIVE_INFINITY].val = mozilla::PositiveInfinity<double>();
|
||||
number_constants[NC_NEGATIVE_INFINITY].val = mozilla::NegativeInfinity<double>();
|
||||
|
||||
number_constants[NC_MIN_VALUE].dval = MinNumberValue<double>();
|
||||
number_constants[NC_MIN_VALUE].val = MinNumberValue<double>();
|
||||
|
||||
// XXX If EXPOSE_INTL_API becomes true all the time at some point,
|
||||
// js::InitRuntimeNumberState is no longer fallible, and we should
|
||||
|
@ -124,7 +124,6 @@ enum JSGCTraceKind {
|
||||
/* Struct forward declarations. */
|
||||
struct JSClass;
|
||||
struct JSCompartment;
|
||||
struct JSConstDoubleSpec;
|
||||
struct JSCrossCompartmentCall;
|
||||
struct JSErrorReport;
|
||||
struct JSExceptionState;
|
||||
@ -148,6 +147,10 @@ class JSFlatString;
|
||||
typedef struct PRCallOnceType JSCallOnceType;
|
||||
typedef bool (*JSInitCallback)(void);
|
||||
|
||||
template<typename T> struct JSConstScalarSpec;
|
||||
typedef JSConstScalarSpec<double> JSConstDoubleSpec;
|
||||
typedef JSConstScalarSpec<int32_t> JSConstIntegerSpec;
|
||||
|
||||
/*
|
||||
* Generic trace operation that calls JS_CallTracer on each traceable thing
|
||||
* stored in data.
|
||||
|
Loading…
Reference in New Issue
Block a user