Hi Piotr,
+(tmp = new VBArray(createArray())).f = Object.prototype.toString; +ok(tmp.f() === "[object Object]", "tmp.f() = " + tmp.f());
We have Function.call implemented now, you can use String.prototype.toString.call(new VBArray ...).
+ case DISPATCH_METHOD: + if(arg_cnt(dp)<1 || V_VT((arg = get_arg(dp, 0)))!=(VT_ARRAY|VT_VARIANT)) + return throw_type_error(ctx, ei, IDS_NOT_VBARRAY, NULL); + + VariantCopy(retv, arg);
Please add error handling. Also a test would be nice, at least something like getVT(createArray()).
+ case DISPATCH_CONSTRUCT: + if(arg_cnt(dp)<1 || V_VT((arg = get_arg(dp, 0)))!=(VT_ARRAY|VT_VARIANT)) + return throw_type_error(ctx, ei, IDS_NOT_VBARRAY, NULL); + + hres = alloc_vbarray(ctx, NULL,&vbarray); + if(FAILED(hres)) + return hres; + SafeArrayCopy(V_ARRAY(arg),&vbarray->safearray);
Error handling.
(From 'PATCH 4/8] jscript: Added VBArray.ubound() implementation'):
+ if(retv) + num_set_val(retv, dim);
num_set_val is for DOUBLE and eventually abused for integers out of VT_I4 range. You can set value directly here to avoid conversions. It might be a good idea to introduce something like var_set_int helper given that we could use it in quite a few places.
(From '[PATCH 6/8] jscript: Added VBArray.getItem() implementation'):
+ size = arg_cnt(dp); + if(size< SafeArrayGetDim(vbarray->safearray)) + return throw_range_error(ctx, ei, IDS_SUBSCRIPT_OUT_OF_RANGE, NULL); + + indexes = heap_alloc(sizeof(int)*size);
Error handling.
(From '[PATCH 8/8] jscript: Added VBArray handling to to_object()'):
-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);
There is no reason to change these tests, esp. that they were better before the change. Please add proper to_object tests, for example by calling Object() function or doing proper call on explicitly converted object.
+ SafeArrayCopy(sa,&vbarray->safearray);
Error handling.
Jacek