Jacek Caban : jscript: Use generic properties for NaN and Infinity implementation.
Alexandre Julliard
julliard at winehq.org
Mon Aug 2 11:03:55 CDT 2010
Module: wine
Branch: master
Commit: f824a1656d1830267b03aacc8484ee24eba5afcf
URL: http://source.winehq.org/git/wine.git/?a=commit;h=f824a1656d1830267b03aacc8484ee24eba5afcf
Author: Jacek Caban <jacek at codeweavers.com>
Date: Mon Aug 2 11:08:57 2010 +0200
jscript: Use generic properties for NaN and Infinity implementation.
---
dlls/jscript/global.c | 56 ++++++++++---------------------------------
dlls/jscript/tests/lang.js | 9 +++++++
2 files changed, 22 insertions(+), 43 deletions(-)
diff --git a/dlls/jscript/global.c b/dlls/jscript/global.c
index 92a0cbe..2acd92b 100644
--- a/dlls/jscript/global.c
+++ b/dlls/jscript/global.c
@@ -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;
}
diff --git a/dlls/jscript/tests/lang.js b/dlls/jscript/tests/lang.js
index c3059be..bdf039a 100644
--- a/dlls/jscript/tests/lang.js
+++ b/dlls/jscript/tests/lang.js
@@ -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();
More information about the wine-cvs
mailing list