Jacek Caban : jscript: Added Object function invocation implementation.
Alexandre Julliard
julliard at winehq.org
Thu Sep 17 13:52:55 CDT 2009
Module: wine
Branch: master
Commit: dcaf066936a6718c2084a05a495ad609b55cb5db
URL: http://source.winehq.org/git/wine.git/?a=commit;h=dcaf066936a6718c2084a05a495ad609b55cb5db
Author: Jacek Caban <jacek at codeweavers.com>
Date: Thu Sep 17 01:05:55 2009 +0200
jscript: Added Object function invocation implementation.
---
dlls/jscript/object.c | 23 ++++++++++++++++++++++-
dlls/jscript/tests/api.js | 12 ++++++++++++
2 files changed, 34 insertions(+), 1 deletions(-)
diff --git a/dlls/jscript/object.c b/dlls/jscript/object.c
index 8170e71..66e4b53 100644
--- a/dlls/jscript/object.c
+++ b/dlls/jscript/object.c
@@ -163,13 +163,34 @@ static const builtin_info_t Object_info = {
};
static HRESULT ObjectConstr_value(DispatchEx *dispex, LCID lcid, WORD flags, DISPPARAMS *dp,
- VARIANT *retv, jsexcept_t *ei, IServiceProvider *sp)
+ VARIANT *retv, jsexcept_t *ei, IServiceProvider *caller)
{
HRESULT hres;
TRACE("\n");
switch(flags) {
+ case DISPATCH_METHOD:
+ if(arg_cnt(dp)) {
+ VARIANT *arg = get_arg(dp,0);
+
+ if(V_VT(arg) != VT_EMPTY && V_VT(arg) != VT_NULL) {
+ IDispatch *disp;
+
+ hres = to_object(dispex->ctx, arg, &disp);
+ if(FAILED(hres))
+ return hres;
+
+ if(retv) {
+ V_VT(retv) = VT_DISPATCH;
+ V_DISPATCH(retv) = disp;
+ }else {
+ IDispatch_Release(disp);
+ }
+ return S_OK;
+ }
+ }
+ /* fall through */
case DISPATCH_CONSTRUCT: {
DispatchEx *obj;
diff --git a/dlls/jscript/tests/api.js b/dlls/jscript/tests/api.js
index d3e08c8..291154c 100644
--- a/dlls/jscript/tests/api.js
+++ b/dlls/jscript/tests/api.js
@@ -88,6 +88,17 @@ ok(tmp.f() === "[object RegExp]", "tmp.f() = " + tmp.f());
(tmp = new String).f = Object.prototype.toString;
ok(tmp.f() === "[object String]", "tmp.f() = " + tmp.f());
+ok(Object(1) instanceof Number, "Object(1) is not instance of Number");
+ok(Object("") instanceof String, "Object('') is not instance of String");
+ok(Object(false) instanceof Boolean, "Object(false) is not instance of Boolean");
+
+obj = new Object();
+ok(Object(obj) === obj, "Object(obj) !== obj");
+
+ok(typeof(Object()) === "object", "typeof(Object()) !== 'object'");
+ok(typeof(Object(undefined)) === "object", "typeof(Object(undefined)) !== 'object'");
+ok(typeof(Object(null)) === "object", "typeof(Object(null)) !== 'object'");
+
var obj = new Object();
obj.toString = function (x) {
ok(arguments.length === 0, "arguments.length = " + arguments.length);
@@ -95,6 +106,7 @@ obj.toString = function (x) {
};
ok((tmp = obj.toLocaleString()) === "test", "obj.toLocaleString() = " + tmp);
ok((tmp = obj.toLocaleString(1)) === "test", "obj.toLocaleString(1) = " + tmp);
+ok(obj === obj.valueOf(), "obj !== obj.valueOf");
ok("".length === 0, "\"\".length = " + "".length);
ok(getVT("".length) == "VT_I4", "\"\".length = " + "".length);
More information about the wine-cvs
mailing list