jscript: Added VBArray handling to to_object().

This commit is contained in:
Piotr Caban 2010-10-18 18:48:25 +02:00 committed by Alexandre Julliard
parent 29cdb21218
commit 5a787b3a7f
4 changed files with 26 additions and 3 deletions

View File

@ -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,

View File

@ -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:

View File

@ -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);

View File

@ -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;
}