Signed-off-by: Gabriel Ivăncescu gabrielopcode@gmail.com --- dlls/msscript.ocx/msscript.c | 30 ++++++++++++++++++++++++++++-- dlls/msscript.ocx/tests/msscript.c | 16 +++++++++------- 2 files changed, 37 insertions(+), 9 deletions(-)
diff --git a/dlls/msscript.ocx/msscript.c b/dlls/msscript.ocx/msscript.c index 967b8d6..0b316af 100644 --- a/dlls/msscript.ocx/msscript.c +++ b/dlls/msscript.ocx/msscript.c @@ -123,6 +123,10 @@ typedef struct { IScriptError IScriptError_iface; IActiveScriptError *object; LONG ref; + + HRESULT number; + + BOOLEAN info_filled; } ScriptError;
struct ScriptHost { @@ -2111,6 +2115,23 @@ static const IScriptModuleCollectionVtbl ScriptModuleCollectionVtbl = { ScriptModuleCollection_Add };
+static void fill_error_info(ScriptError *error) +{ + EXCEPINFO info; + + if (error->info_filled) return; + error->info_filled = TRUE; + + if (!error->object) + return; + if (FAILED(IActiveScriptError_GetExceptionInfo(error->object, &info))) + return; + if (info.pfnDeferredFillIn) + info.pfnDeferredFillIn(&info); + + error->number = info.scode; +} + static HRESULT WINAPI ScriptError_QueryInterface(IScriptError *iface, REFIID riid, void **ppv) { ScriptError *This = impl_from_IScriptError(iface); @@ -2222,9 +2243,11 @@ static HRESULT WINAPI ScriptError_get_Number(IScriptError *iface, LONG *plNumber { ScriptError *This = impl_from_IScriptError(iface);
- FIXME("(%p)->(%p)\n", This, plNumber); + TRACE("(%p)->(%p)\n", This, plNumber);
- return E_NOTIMPL; + fill_error_info(This); + *plNumber = This->number; + return S_OK; }
static HRESULT WINAPI ScriptError_get_Source(IScriptError *iface, BSTR *pbstrSource) @@ -2302,6 +2325,9 @@ static HRESULT WINAPI ScriptError_Clear(IScriptError *iface) This->object = NULL; }
+ This->number = 0; + + This->info_filled = FALSE; return S_OK; }
diff --git a/dlls/msscript.ocx/tests/msscript.c b/dlls/msscript.ocx/tests/msscript.c index 9bbbe4c..6e94fa9 100644 --- a/dlls/msscript.ocx/tests/msscript.c +++ b/dlls/msscript.ocx/tests/msscript.c @@ -2066,8 +2066,9 @@ static void test_State(void) } }
-#define CHECK_ERROR(sc,exp_num) _check_error(sc, exp_num, __LINE__) -static void _check_error(IScriptControl *sc, LONG exp_num, int line) +#define CHECK_ERROR(sc,exp_num) _check_error(sc, exp_num, FALSE, __LINE__) +#define CHECK_ERROR_TODO(sc,exp_num) _check_error(sc, exp_num, TRUE, __LINE__) +static void _check_error(IScriptControl *sc, LONG exp_num, BOOL todo, int line) { IScriptError *script_err; LONG error_num; @@ -2077,8 +2078,9 @@ static void _check_error(IScriptControl *sc, LONG exp_num, int line) ok_(__FILE__,line)(hr == S_OK, "IScriptControl_get_Error failed: 0x%08x.\n", hr); error_num = 0xdeadbeef; hr = IScriptError_get_Number(script_err, &error_num); - todo_wine ok_(__FILE__,line)(hr == S_OK, "IScriptError_get_Number failed: 0x%08x.\n", hr); - todo_wine ok_(__FILE__,line)(error_num == exp_num, "got wrong error number: %d, expected %d.\n", + ok_(__FILE__,line)(hr == S_OK, "IScriptError_get_Number failed: 0x%08x.\n", hr); +todo_wine_if(todo == TRUE) + ok_(__FILE__,line)(error_num == exp_num, "got wrong error number: %d, expected %d.\n", error_num, exp_num); IScriptError_Release(script_err); } @@ -2157,7 +2159,7 @@ static void test_IScriptControl_Eval(void) ok(V_I4(&var) == 0xdeadbeef || broken(V_I4(&var) == 0) /* after Win8 */, "V_I4(var) = %d.\n", V_I4(&var)); SysFreeString(script_str); - CHECK_ERROR(sc, 1004); + CHECK_ERROR_TODO(sc, 1004);
script_str = SysAllocString(L"var2 = var1 + var2"); V_VT(&var) = VT_NULL; @@ -2290,7 +2292,7 @@ static void test_IScriptControl_AddCode(void) hr = IScriptControl_AddCode(sc, code_str); todo_wine ok(hr == 0x800a03ec, "IScriptControl_AddCode returned: 0x%08x.\n", hr); SysFreeString(code_str); - CHECK_ERROR(sc, 1004); + CHECK_ERROR_TODO(sc, 1004);
IScriptControl_Release(sc);
@@ -2391,7 +2393,7 @@ static void test_IScriptControl_ExecuteStatement(void) hr = IScriptControl_ExecuteStatement(sc, str); todo_wine ok(hr == 0x800a03ec, "IScriptControl_ExecuteStatement returned: 0x%08x.\n", hr); SysFreeString(str); - CHECK_ERROR(sc, 1004); + CHECK_ERROR_TODO(sc, 1004);
IScriptControl_Release(sc);