Piotr Caban : jscript: Added VBArray handling to to_object().
Alexandre Julliard
julliard at winehq.org
Mon Oct 18 13:36:57 CDT 2010
Module: wine
Branch: master
Commit: 5a787b3a7f6bd9e751d1b3f48febb8ea50b74ebb
URL: http://source.winehq.org/git/wine.git/?a=commit;h=5a787b3a7f6bd9e751d1b3f48febb8ea50b74ebb
Author: Piotr Caban <piotr at codeweavers.com>
Date: Mon Oct 18 18:48:25 2010 +0200
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 ab63bce..70b3765 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 3024f3b..f1e1564 100644
--- a/dlls/jscript/jsutils.c
+++ b/dlls/jscript/jsutils.c
@@ -633,6 +633,13 @@ HRESULT to_object(script_ctx_t *ctx, VARIANT *v, IDispatch **disp)
*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:
FIXME("unsupported vt %d\n", V_VT(v));
return E_NOTIMPL;
diff --git a/dlls/jscript/tests/api.js b/dlls/jscript/tests/api.js
index 85bd556..1334f7e 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 0366aa8..db56f81 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;
+}
More information about the wine-cvs
mailing list