jscript: Use generic properties for NaN and Infinity implementation.

This commit is contained in:
Jacek Caban 2010-08-02 11:08:57 +02:00 committed by Alexandre Julliard
parent 9ca80347e3
commit f824a1656d
2 changed files with 22 additions and 43 deletions

View File

@ -118,42 +118,6 @@ static HRESULT constructor_call(DispatchEx *constr, WORD flags, DISPPARAMS *dp,
return S_OK;
}
static HRESULT JSGlobal_NaN(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DISPPARAMS *dp,
VARIANT *retv, jsexcept_t *ei, IServiceProvider *sp)
{
TRACE("\n");
switch(flags) {
case DISPATCH_PROPERTYGET:
num_set_nan(retv);
break;
default:
FIXME("unimplemented flags %x\n", flags);
return E_NOTIMPL;
}
return S_OK;
}
static HRESULT JSGlobal_Infinity(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DISPPARAMS *dp,
VARIANT *retv, jsexcept_t *ei, IServiceProvider *sp)
{
TRACE("\n");
switch(flags) {
case DISPATCH_PROPERTYGET:
num_set_inf(retv, TRUE);
break;
default:
FIXME("unimplemented flags %x\n", flags);
return E_NOTIMPL;
}
return S_OK;
}
static HRESULT JSGlobal_Array(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DISPPARAMS *dp,
VARIANT *retv, jsexcept_t *ei, IServiceProvider *sp)
{
@ -1063,9 +1027,6 @@ static const builtin_prop_t JSGlobal_props[] = {
{EvalErrorW, JSGlobal_EvalError, PROPF_CONSTR|1},
{FunctionW, JSGlobal_Function, PROPF_CONSTR|1},
{_GetObjectW, JSGlobal_GetObject, PROPF_METHOD|2},
{InfinityW, JSGlobal_Infinity, 0},
/* {MathW, JSGlobal_Math, 0}, */
{NaNW, JSGlobal_NaN, 0},
{NumberW, JSGlobal_Number, PROPF_CONSTR|1},
{ObjectW, JSGlobal_Object, PROPF_CONSTR|1},
{RangeErrorW, JSGlobal_RangeError, PROPF_CONSTR|1},
@ -1175,15 +1136,24 @@ HRESULT init_global(script_ctx_t *ctx)
if(FAILED(hres))
return hres;
V_VT(&var) = VT_DISPATCH;
V_DISPATCH(&var) = (IDispatch*)_IDispatchEx_(math);
hres = jsdisp_propput_name(ctx->global, MathW, &var, NULL/*FIXME*/, NULL/*FIXME*/);
jsdisp_release(math);
if(FAILED(hres))
return hres;
V_VT(&var) = VT_EMPTY;
hres = jsdisp_propput_name(ctx->global, undefinedW, &var, NULL/*FIXME*/, NULL/*FIXME*/);
if(FAILED(hres))
return hres;
V_VT(&var) = VT_DISPATCH;
V_DISPATCH(&var) = (IDispatch*)_IDispatchEx_(math);
hres = jsdisp_propput_name(ctx->global, MathW, &var, NULL/*FIXME*/, NULL/*FIXME*/);
jsdisp_release(math);
num_set_nan(&var);
hres = jsdisp_propput_name(ctx->global, NaNW, &var, NULL/*FIXME*/, NULL/*FIXME*/);
if(FAILED(hres))
return hres;
num_set_inf(&var, TRUE);
hres = jsdisp_propput_name(ctx->global, InfinityW, &var, NULL/*FIXME*/, NULL/*FIXME*/);
return hres;
}

View File

@ -1044,4 +1044,13 @@ obj = {undefined: 3};
undefined = 6;
ok(undefined === 6, "undefined = " + undefined);
NaN = 6;
ok(NaN === 6, "NaN !== 6");
Infinity = 6;
ok(Infinity === 6, "Infinity !== 6");
Math = 6;
ok(Math === 6, "NaN !== 6");
reportSuccess();