Jacek Caban : vbscript: Add LBound function implementation.
Alexandre Julliard
julliard at winehq.org
Wed Oct 23 15:31:31 CDT 2019
Module: wine
Branch: master
Commit: 872d33f29cf3fd885c4bb58bd13410a097996f5c
URL: https://source.winehq.org/git/wine.git/?a=commit;h=872d33f29cf3fd885c4bb58bd13410a097996f5c
Author: Jacek Caban <jacek at codeweavers.com>
Date: Wed Oct 23 15:11:14 2019 +0200
vbscript: Add LBound function implementation.
Signed-off-by: Jacek Caban <jacek at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
dlls/vbscript/global.c | 38 +++++++++++++++++++++++++++++++++++---
dlls/vbscript/tests/api.vbs | 3 +++
2 files changed, 38 insertions(+), 3 deletions(-)
diff --git a/dlls/vbscript/global.c b/dlls/vbscript/global.c
index 0de1559592..6e0dfc6938 100644
--- a/dlls/vbscript/global.c
+++ b/dlls/vbscript/global.c
@@ -1082,8 +1082,40 @@ static HRESULT Global_Timer(BuiltinDisp *This, VARIANT *arg, unsigned args_cnt,
static HRESULT Global_LBound(BuiltinDisp *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
{
- FIXME("\n");
- return E_NOTIMPL;
+ SAFEARRAY *sa;
+ HRESULT hres;
+ LONG ubound;
+ int dim;
+
+ assert(args_cnt == 1 || args_cnt == 2);
+
+ TRACE("%s %s\n", debugstr_variant(arg), args_cnt == 2 ? debugstr_variant(arg + 1) : "1");
+
+ switch(V_VT(arg)) {
+ case VT_VARIANT|VT_ARRAY:
+ sa = V_ARRAY(arg);
+ break;
+ case VT_VARIANT|VT_ARRAY|VT_BYREF:
+ sa = *V_ARRAYREF(arg);
+ break;
+ default:
+ FIXME("arg %s not supported\n", debugstr_variant(arg));
+ return E_NOTIMPL;
+ }
+
+ if(args_cnt == 2) {
+ hres = to_int(arg + 1, &dim);
+ if(FAILED(hres))
+ return hres;
+ }else {
+ dim = 1;
+ }
+
+ hres = SafeArrayGetLBound(sa, dim, &ubound);
+ if(FAILED(hres))
+ return hres;
+
+ return return_int(res, ubound);
}
static HRESULT Global_UBound(BuiltinDisp *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
@@ -2597,7 +2629,7 @@ static const builtin_prop_t global_props[] = {
{L"IsNumeric", Global_IsNumeric, 0, 1},
{L"IsObject", Global_IsObject, 0, 1},
{L"Join", Global_Join, 0, 1, 2},
- {L"LBound", Global_LBound, 0, 1},
+ {L"LBound", Global_LBound, 0, 1, 2},
{L"LCase", Global_LCase, 0, 1},
{L"Left", Global_Left, 0, 2},
{L"LeftB", Global_LeftB, 0, 2},
diff --git a/dlls/vbscript/tests/api.vbs b/dlls/vbscript/tests/api.vbs
index 5c9e219d60..afa0c2bb1f 100644
--- a/dlls/vbscript/tests/api.vbs
+++ b/dlls/vbscript/tests/api.vbs
@@ -247,6 +247,9 @@ Dim arr2(2, 4)
Call ok(UBound(arr2) = 2, "UBound(x) = " & UBound(x))
Call ok(UBound(arr2, 1) = 2, "UBound(x) = " & UBound(x))
Call ok(UBound(arr2, 2) = 4, "UBound(x) = " & UBound(x))
+Call ok(Lbound(arr2) = 0, "Lbound(x) = " & Lbound(x))
+Call ok(Lbound(arr2, 1) = 0, "Lbound(x) = " & Lbound(x))
+Call ok(Lbound(arr2, 2) = 0, "Lbound(x) = " & Lbound(x))
sub testUBoundError()
on error resume next
More information about the wine-cvs
mailing list