[PATCH v3 07/11] msscript.ocx: Implement IScriptModule::get_Name.
Gabriel Ivăncescu
gabrielopcode at gmail.com
Tue Jun 2 07:55:53 CDT 2020
Signed-off-by: Gabriel Ivăncescu <gabrielopcode at gmail.com>
---
dlls/msscript.ocx/msscript.c | 11 +++++++++--
dlls/msscript.ocx/tests/msscript.c | 19 +++++++++++--------
2 files changed, 20 insertions(+), 10 deletions(-)
diff --git a/dlls/msscript.ocx/msscript.c b/dlls/msscript.ocx/msscript.c
index 8df8c64..cd0a21b 100644
--- a/dlls/msscript.ocx/msscript.c
+++ b/dlls/msscript.ocx/msscript.c
@@ -772,10 +772,17 @@ static HRESULT WINAPI ScriptModule_Invoke(IScriptModule *iface, DISPID dispIdMem
static HRESULT WINAPI ScriptModule_get_Name(IScriptModule *iface, BSTR *pbstrName)
{
ScriptModule *This = impl_from_IScriptModule(iface);
+ BSTR module_name;
- FIXME("(%p)->(%p)\n", This, pbstrName);
+ TRACE("(%p)->(%p)\n", This, pbstrName);
- return E_NOTIMPL;
+ if (!pbstrName) return E_POINTER;
+ if (!This->control) return E_FAIL;
+
+ module_name = This->control->modules[This->idx].name;
+
+ *pbstrName = SysAllocString(module_name ? module_name : L"Global");
+ return *pbstrName ? S_OK : E_OUTOFMEMORY;
}
static HRESULT WINAPI ScriptModule_get_CodeObject(IScriptModule *iface, IDispatch **ppdispObject)
diff --git a/dlls/msscript.ocx/tests/msscript.c b/dlls/msscript.ocx/tests/msscript.c
index ad2f490..c5e7695 100644
--- a/dlls/msscript.ocx/tests/msscript.c
+++ b/dlls/msscript.ocx/tests/msscript.c
@@ -2219,10 +2219,11 @@ static void test_IScriptControl_get_Modules(void)
hr = IScriptModuleCollection_get_Item(mods, var, &mod);
ok(hr == S_OK, "IScriptModuleCollection_get_Item failed: 0x%08x.\n", hr);
hr = IScriptModule_get_Name(mod, NULL);
- todo_wine ok(hr == E_POINTER, "IScriptModule_get_Name returned: 0x%08x.\n", hr);
+ ok(hr == E_POINTER, "IScriptModule_get_Name returned: 0x%08x.\n", hr);
hr = IScriptModule_get_Name(mod, &str);
- todo_wine ok(hr == S_OK, "IScriptModule_get_Name failed: 0x%08x.\n", hr);
- if (hr == S_OK) SysFreeString(str);
+ ok(hr == S_OK, "IScriptModule_get_Name failed: 0x%08x.\n", hr);
+ ok(!lstrcmpW(str, L"Global"), "got %s.\n", wine_dbgstr_w(str));
+ SysFreeString(str);
str = SysAllocString(L"function add(a, b) { return a + b; }\n");
hr = IScriptModule_AddCode(mod, str);
todo_wine ok(hr == S_OK, "IScriptModule_AddCode failed: 0x%08x.\n", hr);
@@ -2236,17 +2237,19 @@ static void test_IScriptControl_get_Modules(void)
ok(V_VT(&var) == VT_BSTR, "var type not BSTR, got %d.\n", V_VT(&var));
VariantClear(&var);
hr = IScriptModule_get_Name(mod, &str);
- todo_wine ok(hr == S_OK, "IScriptModule_get_Name failed: 0x%08x.\n", hr);
+ ok(hr == S_OK, "IScriptModule_get_Name failed: 0x%08x.\n", hr);
+ ok(!lstrcmpW(str, L"some other Module"), "got %s.\n", wine_dbgstr_w(str));
IScriptModule_Release(mod);
- if (hr == S_OK) SysFreeString(str);
+ SysFreeString(str);
V_VT(&var) = VT_R8;
V_R8(&var) = 2.0;
hr = IScriptModuleCollection_get_Item(mods, var, &mod);
ok(hr == S_OK, "IScriptModuleCollection_get_Item failed: 0x%08x.\n", hr);
hr = IScriptModule_get_Name(mod, &str);
- todo_wine ok(hr == S_OK, "IScriptModule_get_Name failed: 0x%08x.\n", hr);
- if (hr == S_OK) SysFreeString(str);
+ ok(hr == S_OK, "IScriptModule_get_Name failed: 0x%08x.\n", hr);
+ ok(!lstrcmpW(str, L"foobar"), "got %s.\n", wine_dbgstr_w(str));
+ SysFreeString(str);
str = SysAllocString(L"function sub(a, b) { return a - b; }\n");
hr = IScriptModule_AddCode(mod, str);
todo_wine ok(hr == S_OK, "IScriptModule_AddCode failed: 0x%08x.\n", hr);
@@ -2279,7 +2282,7 @@ static void test_IScriptControl_get_Modules(void)
ok(hr == S_OK, "IScriptModuleCollection_get_Count failed: 0x%08x.\n", hr);
ok(count == 1, "count is not 1, got %d.\n", count);
hr = IScriptModule_get_Name(mod, &str);
- todo_wine ok(hr == E_FAIL, "IScriptModule_get_Name returned: 0x%08x.\n", hr);
+ ok(hr == E_FAIL, "IScriptModule_get_Name returned: 0x%08x.\n", hr);
str = SysAllocString(L"function closed() { }\n");
hr = IScriptModule_AddCode(mod, str);
todo_wine ok(hr == E_FAIL, "IScriptModule_AddCode failed: 0x%08x.\n", hr);
--
2.21.0
More information about the wine-devel
mailing list