This adds support for returning the type name for VT_DISPATCH variants.
Fixes https://bugs.winehq.org/show_bug.cgi?id=53868
Combined effort from myself and Nikolay Sivov
-- v5: vbscript: add support for VT_DISPATCH in Global_TypeName
From: Jason Millard jsm174@gmail.com
--- dlls/vbscript/global.c | 16 ++++++++++++++++ dlls/vbscript/tests/api.vbs | 4 ++++ dlls/vbscript/vbregexp.c | 8 ++++++-- 3 files changed, 26 insertions(+), 2 deletions(-)
diff --git a/dlls/vbscript/global.c b/dlls/vbscript/global.c index 1abfff9b4fe..51c92f6a8a0 100644 --- a/dlls/vbscript/global.c +++ b/dlls/vbscript/global.c @@ -2450,6 +2450,10 @@ static HRESULT Global_DatePart(BuiltinDisp *This, VARIANT *arg, unsigned args_cn
static HRESULT Global_TypeName(BuiltinDisp *This, VARIANT *arg, unsigned args_cnt, VARIANT *res) { + ITypeInfo *typeinfo; + BSTR name = NULL; + HRESULT hres; + TRACE("(%s)\n", debugstr_variant(arg));
assert(args_cnt == 1); @@ -2482,6 +2486,18 @@ static HRESULT Global_TypeName(BuiltinDisp *This, VARIANT *arg, unsigned args_cn return return_string(res, L"Empty"); case VT_NULL: return return_string(res, L"Null"); + case VT_DISPATCH: + if (SUCCEEDED(IDispatch_GetTypeInfo(V_DISPATCH(arg), 0, GetUserDefaultLCID(), &typeinfo))) + { + hres = ITypeInfo_GetDocumentation(typeinfo, MEMBERID_NIL, &name, NULL, NULL, NULL); + ITypeInfo_Release(typeinfo); + + if (SUCCEEDED(hres) && name && *name) + return return_bstr(res, name); + + SysFreeString(name); + } + return return_string(res, L"Object"); default: FIXME("arg %s not supported\n", debugstr_variant(arg)); return E_NOTIMPL; diff --git a/dlls/vbscript/tests/api.vbs b/dlls/vbscript/tests/api.vbs index 5f7f2aac3bf..0e47f428d09 100644 --- a/dlls/vbscript/tests/api.vbs +++ b/dlls/vbscript/tests/api.vbs @@ -1555,6 +1555,10 @@ Call ok(TypeName(True) = "Boolean", "TypeName(True) = " & TypeName(True)) Call ok(getVT(TypeName(True)) = "VT_BSTR", "getVT(TypeName(True)) = " & getVT(TypeName(True))) Call ok(TypeName(arr) = "Variant()", "TypeName(arr) = " & TypeName(arr)) Call ok(getVT(TypeName(arr)) = "VT_BSTR", "getVT(TypeName(arr)) = " & getVT(TypeName(arr))) +Call ok(TypeName(collectionObj) = "Object", "TypeName(collectionObj) = " & TypeName(collectionObj)) +Dim regex +set regex = new RegExp +Call ok(TypeName(regex) = "IRegExp2", "TypeName(regex) = " & TypeName(regex))
Call ok(VarType(Empty) = vbEmpty, "VarType(Empty) = " & VarType(Empty)) Call ok(getVT(VarType(Empty)) = "VT_I2", "getVT(VarType(Empty)) = " & getVT(VarType(Empty))) diff --git a/dlls/vbscript/vbregexp.c b/dlls/vbscript/vbregexp.c index 24ce243c645..7232773a3c3 100644 --- a/dlls/vbscript/vbregexp.c +++ b/dlls/vbscript/vbregexp.c @@ -1140,8 +1140,12 @@ static HRESULT WINAPI RegExp2_GetTypeInfo(IRegExp2 *iface, UINT iTInfo, LCID lcid, ITypeInfo **ppTInfo) { RegExp2 *This = impl_from_IRegExp2(iface); - FIXME("(%p)->(%u %lu %p)\n", This, iTInfo, lcid, ppTInfo); - return E_NOTIMPL; + + TRACE("(%p)->(%u %lu %p)\n", This, iTInfo, lcid, ppTInfo); + + *ppTInfo = typeinfos[RegExp2_tid]; + ITypeInfo_AddRef(*ppTInfo); + return S_OK; }
static HRESULT WINAPI RegExp2_GetIDsOfNames(IRegExp2 *iface, REFIID riid,
Hi,
It looks like your patch introduced the new failures shown below. Please investigate and fix them before resubmitting your patch. If they are not new, fixing them anyway would help a lot. Otherwise please ask for the known failures list to be updated.
The tests also ran into some preexisting test failures. If you know how to fix them that would be helpful. See the TestBot job for the details:
The full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=126144
Your paranoid android.
=== debian11 (32 bit report) ===
crypt32: cert.c:4191: Test failed: success cert.c:4192: Test failed: got 00000000 cert.c:4193: Test failed: got 00000000
On Mon Nov 14 12:48:26 2022 +0000, Jason Millard wrote:
changed this line in [version 5 of the diff](/wine/wine/-/merge_requests/1347/diffs?diff_id=18466&start_sha=4285d2ec40ca37841fff828990042d346643df3f#f705ff2124202b08096a71599eedf1d31dff92a3_2496_2496)
oh wow. Apologies, going too fast this morning.
This merge request was approved by Jacek Caban.