jscript: Added Object function invocation implementation.
authorJacek Caban <jacek@codeweavers.com>
Wed, 16 Sep 2009 23:05:55 +0000 (01:05 +0200)
committerAlexandre Julliard <julliard@winehq.org>
Thu, 17 Sep 2009 15:08:08 +0000 (10:08 -0500)
dlls/jscript/object.c
dlls/jscript/tests/api.js

index 8170e714c37c37dca664d625f9a3166e35e93762..66e4b532d618dcbbaa73605af974302a32989db4 100644 (file)
@@ -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;
 
index d3e08c85cf75bea97bccbac5beac340ffe78cc3b..291154cd491f37f8eebcf36805006598543e63ee 100644 (file)
@@ -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);