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
From: Jason Millard jsm174@gmail.com
--- dlls/vbscript/global.c | 19 +++++++++++++++++++ dlls/vbscript/tests/api.vbs | 4 ++++ dlls/vbscript/vbregexp.c | 8 ++++++-- 3 files changed, 29 insertions(+), 2 deletions(-)
diff --git a/dlls/vbscript/global.c b/dlls/vbscript/global.c index 1abfff9b4fe..78cd4617726 100644 --- a/dlls/vbscript/global.c +++ b/dlls/vbscript/global.c @@ -2450,6 +2450,9 @@ 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; + HRESULT hres; + TRACE("(%s)\n", debugstr_variant(arg));
assert(args_cnt == 1); @@ -2482,6 +2485,22 @@ 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))) + { + BSTR name = NULL; + + hres = ITypeInfo_GetDocumentation(typeinfo, MEMBERID_NIL, &name, NULL, NULL, NULL); + ITypeInfo_Release(typeinfo); + if (SUCCEEDED(hres) && name && *name) + { + hres = return_string(res, name); + SysFreeString(name); + return hres; + } + 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=126121
Your paranoid android.
=== debian11 (32 bit report) ===
d3d9: d3d9ex.c:3196: Test failed: Expected message 0x5 for window 0, but didn't receive it, i=0. d3d9ex.c:3202: Test failed: Got unexpected WINDOWPOS hwnd=00000000, x=0, y=0, cx=0, cy=0, flags=0
Jacek Caban (@jacek) commented about dlls/vbscript/global.c:
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)))
{
BSTR name = NULL;
hres = ITypeInfo_GetDocumentation(typeinfo, MEMBERID_NIL, &name, NULL, NULL, NULL);
ITypeInfo_Release(typeinfo);
if (SUCCEEDED(hres) && name && *name)
{
hres = return_string(res, name);
`return_string()` is convenient when we need to alloc a BSTR, but since name is already a BSTR here, I think it would be better to avoid extra allocation and open code setting res here.
On Mon Nov 14 10:46:54 2022 +0000, Jacek Caban wrote:
`return_string()` is convenient when we need to alloc a BSTR, but since name is already a BSTR here, I think it would be better to avoid extra allocation and open code setting res here.
Actually, we already have `return_bstr()` for that.