Jacek Caban : jscript: Added constructor invokation from Function object support.

Alexandre Julliard julliard at winehq.org
Thu Sep 11 08:00:54 CDT 2008


Module: wine
Branch: master
Commit: e4e47c01498ae4c1d4e96da5ede061e2b7bc2000
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=e4e47c01498ae4c1d4e96da5ede061e2b7bc2000

Author: Jacek Caban <jacek at codeweavers.com>
Date:   Wed Sep 10 21:08:26 2008 +0200

jscript: Added constructor invokation from Function object support.

---

 dlls/jscript/function.c    |   28 ++++++++++++++++++++++++++++
 dlls/jscript/tests/lang.js |    3 +++
 2 files changed, 31 insertions(+), 0 deletions(-)

diff --git a/dlls/jscript/function.c b/dlls/jscript/function.c
index 615e7ce..d4a3b62 100644
--- a/dlls/jscript/function.c
+++ b/dlls/jscript/function.c
@@ -185,6 +185,28 @@ static HRESULT invoke_function(FunctionInstance *function, LCID lcid, DISPPARAMS
     return invoke_source(function, this_obj, lcid, dp, retv, ei, caller);
 }
 
+static HRESULT invoke_constructor(FunctionInstance *function, LCID lcid, DISPPARAMS *dp,
+        VARIANT *retv, jsexcept_t *ei, IServiceProvider *caller)
+{
+    DispatchEx *this_obj;
+    VARIANT var;
+    HRESULT hres;
+
+    hres = create_object(function->dispex.ctx, &function->dispex, &this_obj);
+    if(FAILED(hres))
+        return hres;
+
+    hres = invoke_source(function, (IDispatch*)_IDispatchEx_(this_obj), lcid, dp, retv, ei, caller);
+    jsdisp_release(this_obj);
+    if(FAILED(hres))
+        return hres;
+
+    VariantClear(&var);
+    V_VT(retv) = VT_DISPATCH;
+    V_DISPATCH(retv) = (IDispatch*)_IDispatchEx_(this_obj);
+    return S_OK;
+}
+
 static HRESULT invoke_value_proc(FunctionInstance *function, LCID lcid, WORD flags, DISPPARAMS *dp,
         VARIANT *retv, jsexcept_t *ei, IServiceProvider *caller)
 {
@@ -301,6 +323,12 @@ static HRESULT Function_value(DispatchEx *dispex, LCID lcid, WORD flags, DISPPAR
 
         return invoke_function(function, lcid, dp, retv, ei, caller);
 
+    case DISPATCH_CONSTRUCT:
+        if(function->value_proc)
+            return invoke_value_proc(function, lcid, flags, dp, retv, ei, caller);
+
+        return invoke_constructor(function, lcid, dp, retv, ei, caller);
+
     default:
         FIXME("not implemented flags %x\n", flags);
         return E_NOTIMPL;
diff --git a/dlls/jscript/tests/lang.js b/dlls/jscript/tests/lang.js
index dca0771..4e76b21 100644
--- a/dlls/jscript/tests/lang.js
+++ b/dlls/jscript/tests/lang.js
@@ -79,4 +79,7 @@ ok(typeof(this) === "object", "typeof(this) is not object");
 
 ok(testFunc1(true, "test") === true, "testFunc1 not returned true");
 
+var obj1 = new Object();
+ok(typeof(obj1) === "object", "typeof(obj1) is not object");
+
 reportSuccess();




More information about the wine-cvs mailing list