Jacek Caban : jscript: Added Math.PI implementation.
Alexandre Julliard
julliard at winehq.org
Thu Dec 11 07:50:48 CST 2008
Module: wine
Branch: master
Commit: 0e8bcbd9de6d2f824bc47662f4891ee0f241b7d8
URL: http://source.winehq.org/git/wine.git/?a=commit;h=0e8bcbd9de6d2f824bc47662f4891ee0f241b7d8
Author: Jacek Caban <jacek at codeweavers.com>
Date: Thu Dec 11 12:27:39 2008 +0100
jscript: Added Math.PI implementation.
---
dlls/jscript/math.c | 20 ++++++++++++++++++--
dlls/jscript/tests/api.js | 5 +++++
2 files changed, 23 insertions(+), 2 deletions(-)
diff --git a/dlls/jscript/math.c b/dlls/jscript/math.c
index e6b7202..ceabc36 100644
--- a/dlls/jscript/math.c
+++ b/dlls/jscript/math.c
@@ -54,6 +54,21 @@ static const WCHAR sinW[] = {'s','i','n',0};
static const WCHAR sqrtW[] = {'s','q','r','t',0};
static const WCHAR tanW[] = {'t','a','n',0};
+static HRESULT math_constant(DOUBLE val, WORD flags, VARIANT *retv)
+{
+ switch(flags) {
+ case DISPATCH_PROPERTYGET:
+ V_VT(retv) = VT_R8;
+ V_R8(retv) = val;
+ return S_OK;
+ case DISPATCH_PROPERTYPUT:
+ return S_OK;
+ }
+
+ FIXME("unhandled flags %x\n", flags);
+ return E_NOTIMPL;
+}
+
static HRESULT Math_E(DispatchEx *dispex, LCID lcid, WORD flags, DISPPARAMS *dp,
VARIANT *retv, jsexcept_t *ei, IServiceProvider *sp)
{
@@ -89,11 +104,12 @@ static HRESULT Math_LN10(DispatchEx *dispex, LCID lcid, WORD flags, DISPPARAMS *
return E_NOTIMPL;
}
+/* ECMA-262 3rd Edition 15.8.1.6 */
static HRESULT Math_PI(DispatchEx *dispex, LCID lcid, WORD flags, DISPPARAMS *dp,
VARIANT *retv, jsexcept_t *ei, IServiceProvider *sp)
{
- FIXME("\n");
- return E_NOTIMPL;
+ TRACE("\n");
+ return math_constant(M_PI, flags, retv);
}
static HRESULT Math_SQRT2(DispatchEx *dispex, LCID lcid, WORD flags, DISPPARAMS *dp,
diff --git a/dlls/jscript/tests/api.js b/dlls/jscript/tests/api.js
index 2868c0f..7381612 100644
--- a/dlls/jscript/tests/api.js
+++ b/dlls/jscript/tests/api.js
@@ -609,4 +609,9 @@ date = new Date(100);
ok(date.getTime() === 100, "date.getTime() = " + date.getTime());
ok(Date.prototype.getTime() === 0, "date.prototype.getTime() = " + Date.prototype.getTime());
+ok(typeof(Math.PI) === "number", "typeof(Math.PI) = " + typeof(Math.PI));
+ok(Math.floor(Math.PI*100) === 314, "Math.PI = " + Math.PI);
+Math.PI = "test";
+ok(Math.floor(Math.PI*100) === 314, "modified Math.PI = " + Math.PI);
+
reportSuccess();
More information about the wine-cvs
mailing list