From 5a787b3a7f6bd9e751d1b3f48febb8ea50b74ebb Mon Sep 17 00:00:00 2001 From: Piotr Caban Date: Mon, 18 Oct 2010 18:48:25 +0200 Subject: [PATCH] jscript: Added VBArray handling to to_object(). --- dlls/jscript/jscript.h | 1 + dlls/jscript/jsutils.c | 7 +++++++ dlls/jscript/tests/api.js | 6 +++--- dlls/jscript/vbarray.c | 15 +++++++++++++++ 4 files changed, 26 insertions(+), 3 deletions(-) diff --git a/dlls/jscript/jscript.h b/dlls/jscript/jscript.h index ab63bced813..70b37657542 100644 --- a/dlls/jscript/jscript.h +++ b/dlls/jscript/jscript.h @@ -243,6 +243,7 @@ HRESULT create_regexp_var(script_ctx_t*,VARIANT*,VARIANT*,jsdisp_t**); HRESULT create_string(script_ctx_t*,const WCHAR*,DWORD,jsdisp_t**); HRESULT create_bool(script_ctx_t*,VARIANT_BOOL,jsdisp_t**); HRESULT create_number(script_ctx_t*,VARIANT*,jsdisp_t**); +HRESULT create_vbarray(script_ctx_t*,SAFEARRAY*,jsdisp_t**); typedef enum { NO_HINT, diff --git a/dlls/jscript/jsutils.c b/dlls/jscript/jsutils.c index 3024f3b0d08..f1e15644383 100644 --- a/dlls/jscript/jsutils.c +++ b/dlls/jscript/jsutils.c @@ -631,6 +631,13 @@ HRESULT to_object(script_ctx_t *ctx, VARIANT *v, IDispatch **disp) if(FAILED(hres)) return hres; + *disp = to_disp(dispex); + break; + case VT_ARRAY|VT_VARIANT: + hres = create_vbarray(ctx, V_ARRAY(v), &dispex); + if(FAILED(hres)) + return hres; + *disp = to_disp(dispex); break; default: diff --git a/dlls/jscript/tests/api.js b/dlls/jscript/tests/api.js index 85bd556f1a5..1334f7e1d0b 100644 --- a/dlls/jscript/tests/api.js +++ b/dlls/jscript/tests/api.js @@ -1901,11 +1901,11 @@ exception_test(function() {new null;}, "TypeError", -2146823281); exception_test(function() {new nullDisp;}, "TypeError", -2146827850); exception_test(function() {new VBArray();}, "TypeError", -2146823275); exception_test(function() {new VBArray(new VBArray(createArray()));}, "TypeError", -2146823275); -exception_test(function() {(new VBArray(createArray())).lbound("aaa");}, "RangeError", -2146828279); -exception_test(function() {(new VBArray(createArray())).lbound(3);}, "RangeError", -2146828279); +exception_test(function() {createArray().lbound("aaa");}, "RangeError", -2146828279); +exception_test(function() {createArray().lbound(3);}, "RangeError", -2146828279); exception_test(function() {tmp = new Object(); tmp.lb = VBArray.prototype.lbound; tmp.lb();}, "TypeError", -2146823275); exception_test(function() {tmp = new Object(); tmp.lb = VBArray.prototype.lbound; tmp.lb();}, "TypeError", -2146823275); -exception_test(function() {(new VBArray(createArray())).getItem(3);}, "RangeError", -2146828279); +exception_test(function() {createArray().getItem(3);}, "RangeError", -2146828279); function testThisExcept(func, number) { exception_test(function() {func.call(new Object())}, "TypeError", number); diff --git a/dlls/jscript/vbarray.c b/dlls/jscript/vbarray.c index 0366aa88ab6..db56f81047c 100644 --- a/dlls/jscript/vbarray.c +++ b/dlls/jscript/vbarray.c @@ -325,3 +325,18 @@ HRESULT create_vbarray_constr(script_ctx_t *ctx, jsdisp_t *object_prototype, jsd jsdisp_release(&vbarray->dispex); return hres; } + +HRESULT create_vbarray(script_ctx_t *ctx, SAFEARRAY *sa, jsdisp_t **ret) +{ + VBArrayInstance *vbarray; + HRESULT hres; + + hres = alloc_vbarray(ctx, NULL, &vbarray); + if(FAILED(hres)) + return hres; + + SafeArrayCopy(sa, &vbarray->safearray); + + *ret = &vbarray->dispex; + return S_OK; +}