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
-- v4: 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..ea3704a4ec8 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_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=126142
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
vbscript: run.c:1206: Test failed: api.vbs: L"TypeName(regex) = Object"
=== debian11 (32 bit ar:MA report) ===
vbscript: run.c:1206: Test failed: api.vbs: L"TypeName(regex) = Object"
=== debian11 (32 bit de report) ===
vbscript: run.c:1206: Test failed: api.vbs: L"TypeName(regex) = Object"
=== debian11 (32 bit fr report) ===
vbscript: run.c:1206: Test failed: api.vbs: L"TypeName(regex) = Object"
=== debian11 (32 bit he:IL report) ===
vbscript: run.c:1206: Test failed: api.vbs: L"TypeName(regex) = Object"
=== debian11 (32 bit hi:IN report) ===
vbscript: run.c:1206: Test failed: api.vbs: L"TypeName(regex) = Object"
=== debian11 (32 bit ja:JP report) ===
vbscript: run.c:1206: Test failed: api.vbs: L"TypeName(regex) = Object"
=== debian11 (32 bit zh:CN report) ===
vbscript: run.c:1206: Test failed: api.vbs: L"TypeName(regex) = Object"
=== debian11b (32 bit WoW report) ===
vbscript: run.c:1206: Test failed: api.vbs: L"TypeName(regex) = Object"
=== debian11b (64 bit WoW report) ===
vbscript: run.c:1206: Test failed: api.vbs: L"TypeName(regex) = Object"
On Mon Nov 14 12:04:40 2022 +0000, Jacek Caban wrote:
If name is an empty string, it will be leaked. Also please squash those changes into a single commit.
Sorry, just learning the system here.. squashed the commits. SysFreeString checks ignores null so I didn't put the extra if around it.
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)))
{
hres = ITypeInfo_GetDocumentation(typeinfo, MEMBERID_NIL, &name, NULL, NULL, NULL);
ITypeInfo_Release(typeinfo);
if (SUCCEEDED(hres) && name && *name)
return_bstr(res, name);
You're missing return, I think you meant: `return return_bstr(res, name);`
On Mon Nov 14 12:22:38 2022 +0000, Jason Millard wrote:
Sorry, just learning the system here.. squashed the commits. SysFreeString checks ignores null so I didn't put the extra if around it.
It should've been "return return_bstr();". You'll get test failures as well.