The error object has to be separate from the control, as it can be referenced while the control is released. It is also available even without a script host, and in fact the same object will be used (same address) when a host is instantiated.
Signed-off-by: Gabriel Ivăncescu gabrielopcode@gmail.com --- dlls/msscript.ocx/msscript.c | 240 ++++++++++++++++++++++++++++- dlls/msscript.ocx/tests/msscript.c | 39 +++-- 2 files changed, 256 insertions(+), 23 deletions(-)
diff --git a/dlls/msscript.ocx/msscript.c b/dlls/msscript.ocx/msscript.c index d493065..c92a86a 100644 --- a/dlls/msscript.ocx/msscript.c +++ b/dlls/msscript.ocx/msscript.c @@ -119,6 +119,11 @@ struct procedure_enum { ScriptProcedureCollection *procedures; };
+typedef struct { + IScriptError IScriptError_iface; + LONG ref; +} ScriptError; + struct ScriptHost { IActiveScriptSite IActiveScriptSite_iface; IActiveScriptSiteWindow IActiveScriptSiteWindow_iface; @@ -164,12 +169,14 @@ struct ScriptControl { IScriptModuleCollection IScriptModuleCollection_iface;
ScriptHost *host; + ScriptError *error; };
static HINSTANCE msscript_instance;
typedef enum tid_t { IScriptControl_tid, + IScriptError_tid, IScriptModuleCollection_tid, IScriptModule_tid, IScriptProcedureCollection_tid, @@ -182,6 +189,7 @@ static ITypeInfo *typeinfos[LAST_tid];
static REFIID tid_ids[] = { &IID_IScriptControl, + &IID_IScriptError, &IID_IScriptModuleCollection, &IID_IScriptModule, &IID_IScriptProcedureCollection, @@ -516,6 +524,11 @@ static inline ScriptModule *impl_from_IScriptModule(IScriptModule *iface) return CONTAINING_RECORD(iface, ScriptModule, IScriptModule_iface); }
+static inline ScriptError *impl_from_IScriptError(IScriptError *iface) +{ + return CONTAINING_RECORD(iface, ScriptError, IScriptError_iface); +} + static inline ConnectionPoint *impl_from_IConnectionPoint(IConnectionPoint *iface) { return CONTAINING_RECORD(iface, ConnectionPoint, IConnectionPoint_iface); @@ -2086,6 +2099,212 @@ static const IScriptModuleCollectionVtbl ScriptModuleCollectionVtbl = { ScriptModuleCollection_Add };
+static HRESULT WINAPI ScriptError_QueryInterface(IScriptError *iface, REFIID riid, void **ppv) +{ + ScriptError *This = impl_from_IScriptError(iface); + + if (IsEqualGUID(&IID_IDispatch, riid) || IsEqualGUID(&IID_IUnknown, riid) || + IsEqualGUID(&IID_IScriptError, riid)) + { + *ppv = &This->IScriptError_iface; + } + else + { + WARN("unsupported interface: (%p)->(%s %p)\n", This, debugstr_guid(riid), ppv); + *ppv = NULL; + return E_NOINTERFACE; + } + + IUnknown_AddRef((IUnknown*)*ppv); + return S_OK; +} + +static ULONG WINAPI ScriptError_AddRef(IScriptError *iface) +{ + ScriptError *This = impl_from_IScriptError(iface); + LONG ref = InterlockedIncrement(&This->ref); + + TRACE("(%p) ref=%d\n", This, ref); + + return ref; +} + +static ULONG WINAPI ScriptError_Release(IScriptError *iface) +{ + ScriptError *This = impl_from_IScriptError(iface); + LONG ref = InterlockedDecrement(&This->ref); + + TRACE("(%p) ref=%d\n", This, ref); + + if (!ref) + { + heap_free(This); + } + + return ref; +} + +static HRESULT WINAPI ScriptError_GetTypeInfoCount(IScriptError *iface, UINT *pctinfo) +{ + ScriptError *This = impl_from_IScriptError(iface); + + TRACE("(%p)->(%p)\n", This, pctinfo); + + *pctinfo = 1; + return S_OK; +} + +static HRESULT WINAPI ScriptError_GetTypeInfo(IScriptError *iface, UINT iTInfo, + LCID lcid, ITypeInfo **ppTInfo) +{ + ScriptError *This = impl_from_IScriptError(iface); + + TRACE("(%p)->(%u %u %p)\n", This, iTInfo, lcid, ppTInfo); + + return get_typeinfo(IScriptError_tid, ppTInfo); +} + +static HRESULT WINAPI ScriptError_GetIDsOfNames(IScriptError *iface, REFIID riid, + LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId) +{ + ScriptError *This = impl_from_IScriptError(iface); + ITypeInfo *typeinfo; + HRESULT hr; + + TRACE("(%p)->(%s %p %u %u %p)\n", This, debugstr_guid(riid), rgszNames, cNames, lcid, rgDispId); + + hr = get_typeinfo(IScriptError_tid, &typeinfo); + if (SUCCEEDED(hr)) + { + hr = ITypeInfo_GetIDsOfNames(typeinfo, rgszNames, cNames, rgDispId); + ITypeInfo_Release(typeinfo); + } + + return hr; +} + +static HRESULT WINAPI ScriptError_Invoke(IScriptError *iface, DISPID dispIdMember, + REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult, + EXCEPINFO *pExcepInfo, UINT *puArgErr) +{ + ScriptError *This = impl_from_IScriptError(iface); + ITypeInfo *typeinfo; + HRESULT hr; + + TRACE("(%p)->(%d %s %d %d %p %p %p %p)\n", This, dispIdMember, debugstr_guid(riid), + lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr); + + hr = get_typeinfo(IScriptError_tid, &typeinfo); + if(SUCCEEDED(hr)) + { + hr = ITypeInfo_Invoke(typeinfo, iface, dispIdMember, wFlags, + pDispParams, pVarResult, pExcepInfo, puArgErr); + ITypeInfo_Release(typeinfo); + } + + return hr; +} + +static HRESULT WINAPI ScriptError_get_Number(IScriptError *iface, LONG *plNumber) +{ + ScriptError *This = impl_from_IScriptError(iface); + + FIXME("(%p)->(%p)\n", This, plNumber); + + return E_NOTIMPL; +} + +static HRESULT WINAPI ScriptError_get_Source(IScriptError *iface, BSTR *pbstrSource) +{ + ScriptError *This = impl_from_IScriptError(iface); + + FIXME("(%p)->(%p)\n", This, pbstrSource); + + return E_NOTIMPL; +} + +static HRESULT WINAPI ScriptError_get_Description(IScriptError *iface, BSTR *pbstrDescription) +{ + ScriptError *This = impl_from_IScriptError(iface); + + FIXME("(%p)->(%p)\n", This, pbstrDescription); + + return E_NOTIMPL; +} + +static HRESULT WINAPI ScriptError_get_HelpFile(IScriptError *iface, BSTR *pbstrHelpFile) +{ + ScriptError *This = impl_from_IScriptError(iface); + + FIXME("(%p)->(%p)\n", This, pbstrHelpFile); + + return E_NOTIMPL; +} + +static HRESULT WINAPI ScriptError_get_HelpContext(IScriptError *iface, LONG *plHelpContext) +{ + ScriptError *This = impl_from_IScriptError(iface); + + FIXME("(%p)->(%p)\n", This, plHelpContext); + + return E_NOTIMPL; +} + +static HRESULT WINAPI ScriptError_get_Text(IScriptError *iface, BSTR *pbstrText) +{ + ScriptError *This = impl_from_IScriptError(iface); + + FIXME("(%p)->(%p)\n", This, pbstrText); + + return E_NOTIMPL; +} + +static HRESULT WINAPI ScriptError_get_Line(IScriptError *iface, LONG *plLine) +{ + ScriptError *This = impl_from_IScriptError(iface); + + FIXME("(%p)->(%p)\n", This, plLine); + + return E_NOTIMPL; +} + +static HRESULT WINAPI ScriptError_get_Column(IScriptError *iface, LONG *plColumn) +{ + ScriptError *This = impl_from_IScriptError(iface); + + FIXME("(%p)->(%p)\n", This, plColumn); + + return E_NOTIMPL; +} + +static HRESULT WINAPI ScriptError_Clear(IScriptError *iface) +{ + ScriptError *This = impl_from_IScriptError(iface); + + FIXME("(%p)->()\n", This); + + return E_NOTIMPL; +} + +static const IScriptErrorVtbl ScriptErrorVtbl = { + ScriptError_QueryInterface, + ScriptError_AddRef, + ScriptError_Release, + ScriptError_GetTypeInfoCount, + ScriptError_GetTypeInfo, + ScriptError_GetIDsOfNames, + ScriptError_Invoke, + ScriptError_get_Number, + ScriptError_get_Source, + ScriptError_get_Description, + ScriptError_get_HelpFile, + ScriptError_get_HelpContext, + ScriptError_get_Text, + ScriptError_get_Line, + ScriptError_get_Column, + ScriptError_Clear +}; + static HRESULT init_script_host(const CLSID *clsid, ScriptHost **ret) { IObjectSafety *objsafety; @@ -2233,6 +2452,7 @@ static ULONG WINAPI ScriptControl_Release(IScriptControl *iface) release_modules(This, FALSE); IActiveScriptSite_Release(&This->host->IActiveScriptSite_iface); } + IScriptError_Release(&This->error->IScriptError_iface); heap_free(This); }
@@ -2513,8 +2733,14 @@ static HRESULT WINAPI ScriptControl_get_Modules(IScriptControl *iface, IScriptMo static HRESULT WINAPI ScriptControl_get_Error(IScriptControl *iface, IScriptError **p) { ScriptControl *This = impl_from_IScriptControl(iface); - FIXME("(%p)->(%p)\n", This, p); - return E_NOTIMPL; + + TRACE("(%p)->(%p)\n", This, p); + + if (!p) return E_POINTER; + + *p = &This->error->IScriptError_iface; + IScriptError_AddRef(*p); + return S_OK; }
static HRESULT WINAPI ScriptControl_get_CodeObject(IScriptControl *iface, IDispatch **p) @@ -3543,6 +3769,13 @@ static HRESULT WINAPI ScriptControl_CreateInstance(IClassFactory *iface, IUnknow if(!script_control) return E_OUTOFMEMORY;
+ script_control->error = heap_alloc_zero(sizeof(*script_control->error)); + if(!script_control->error) + { + heap_free(script_control); + return E_OUTOFMEMORY; + } + script_control->IScriptControl_iface.lpVtbl = &ScriptControlVtbl; script_control->IPersistStreamInit_iface.lpVtbl = &PersistStreamInitVtbl; script_control->IOleObject_iface.lpVtbl = &OleObjectVtbl; @@ -3557,6 +3790,9 @@ static HRESULT WINAPI ScriptControl_CreateInstance(IClassFactory *iface, IUnknow script_control->allow_ui = VARIANT_TRUE; script_control->use_safe_subset = VARIANT_FALSE;
+ script_control->error->IScriptError_iface.lpVtbl = &ScriptErrorVtbl; + script_control->error->ref = 1; + ConnectionPoint_Init(&script_control->cp_scsource, script_control, &DIID_DScriptControlSource); ConnectionPoint_Init(&script_control->cp_propnotif, script_control, &IID_IPropertyNotifySink);
diff --git a/dlls/msscript.ocx/tests/msscript.c b/dlls/msscript.ocx/tests/msscript.c index 085913a..9bbbe4c 100644 --- a/dlls/msscript.ocx/tests/msscript.c +++ b/dlls/msscript.ocx/tests/msscript.c @@ -2075,15 +2075,12 @@ static void _check_error(IScriptControl *sc, LONG exp_num, int line)
hr = IScriptControl_get_Error(sc, &script_err); ok_(__FILE__,line)(hr == S_OK, "IScriptControl_get_Error failed: 0x%08x.\n", hr); - if (SUCCEEDED(hr)) - { - error_num = 0xdeadbeef; - hr = IScriptError_get_Number(script_err, &error_num); - ok_(__FILE__,line)(hr == S_OK, "IScriptError_get_Number failed: 0x%08x.\n", hr); - ok_(__FILE__,line)(error_num == exp_num, "got wrong error number: %d, expected %d.\n", - error_num, exp_num); - IScriptError_Release(script_err); - } + 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", + error_num, exp_num); + IScriptError_Release(script_err); }
static void test_IScriptControl_Eval(void) @@ -2112,7 +2109,7 @@ static void test_IScriptControl_Eval(void) ok(hr == E_FAIL, "IScriptControl_Eval returned: 0x%08x.\n", hr); ok((V_VT(&var) == VT_EMPTY) && (V_I4(&var) == 0xdeadbeef), "V_VT(var) = %d, V_I4(var) = %d.\n", V_VT(&var), V_I4(&var)); - todo_wine CHECK_ERROR(sc, 0); + CHECK_ERROR(sc, 0);
script_str = SysAllocString(L"1 + 1"); V_VT(&var) = VT_NULL; @@ -2160,7 +2157,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); - todo_wine CHECK_ERROR(sc, 1004); + CHECK_ERROR(sc, 1004);
script_str = SysAllocString(L"var2 = var1 + var2"); V_VT(&var) = VT_NULL; @@ -2287,13 +2284,13 @@ static void test_IScriptControl_AddCode(void) hr = IScriptControl_AddCode(sc, code_str); ok(hr == S_OK, "IScriptControl_AddCode failed: 0x%08x.\n", hr); SysFreeString(code_str); - todo_wine CHECK_ERROR(sc, 0); + CHECK_ERROR(sc, 0);
code_str = SysAllocString(L"invalid syntax"); hr = IScriptControl_AddCode(sc, code_str); todo_wine ok(hr == 0x800a03ec, "IScriptControl_AddCode returned: 0x%08x.\n", hr); SysFreeString(code_str); - todo_wine CHECK_ERROR(sc, 1004); + CHECK_ERROR(sc, 1004);
IScriptControl_Release(sc);
@@ -2388,13 +2385,13 @@ static void test_IScriptControl_ExecuteStatement(void) hr = IScriptControl_ExecuteStatement(sc, str); ok(hr == S_OK, "IScriptControl_ExecuteStatement failed: 0x%08x.\n", hr); SysFreeString(str); - todo_wine CHECK_ERROR(sc, 0); + CHECK_ERROR(sc, 0);
str = SysAllocString(L"invalid syntax"); hr = IScriptControl_ExecuteStatement(sc, str); todo_wine ok(hr == 0x800a03ec, "IScriptControl_ExecuteStatement returned: 0x%08x.\n", hr); SysFreeString(str); - todo_wine CHECK_ERROR(sc, 1004); + CHECK_ERROR(sc, 1004);
IScriptControl_Release(sc);
@@ -2500,13 +2497,13 @@ static void test_IScriptControl_Run(void) str = SysAllocString(L"foobar"); hr = IScriptControl_Run(sc, str, ¶ms, &var); ok(hr == DISP_E_UNKNOWNNAME, "IScriptControl_Run failed: 0x%08x.\n", hr); - todo_wine CHECK_ERROR(sc, 0); + CHECK_ERROR(sc, 0); SysFreeString(str);
str = SysAllocString(L"function subtract(a, b) { return a - b; }\n"); hr = IScriptControl_AddCode(sc, str); ok(hr == S_OK, "IScriptControl_AddCode failed: 0x%08x.\n", hr); - todo_wine CHECK_ERROR(sc, 0); + CHECK_ERROR(sc, 0); SysFreeString(str);
str = SysAllocString(L"Subtract"); @@ -2517,12 +2514,12 @@ static void test_IScriptControl_Run(void) str = SysAllocString(L"subtract"); hr = IScriptControl_Run(sc, str, ¶ms, NULL); ok(hr == E_POINTER, "IScriptControl_Run failed: 0x%08x.\n", hr); - todo_wine CHECK_ERROR(sc, 0); + CHECK_ERROR(sc, 0);
hr = IScriptControl_Run(sc, str, ¶ms, &var); ok(hr == S_OK, "IScriptControl_Run failed: 0x%08x.\n", hr); ok((V_VT(&var) == VT_I4) && (V_I4(&var) == 7), "V_VT(var) = %d, V_I4(var) = %d.\n", V_VT(&var), V_I4(&var)); - todo_wine CHECK_ERROR(sc, 0); + CHECK_ERROR(sc, 0); SafeArrayDestroy(params);
/* The array's other dimensions are ignored */ @@ -3340,7 +3337,7 @@ static void test_IScriptControl_get_Procedures(void) ); hr = IScriptControl_AddCode(sc, str); ok(hr == S_OK, "IScriptControl_AddCode failed: 0x%08x.\n", hr); - todo_wine CHECK_ERROR(sc, 0); + CHECK_ERROR(sc, 0); SysFreeString(str);
hr = IScriptProcedureCollection_get_Count(procs, &count); @@ -3480,7 +3477,7 @@ static void test_IScriptControl_get_Procedures(void) hr = IScriptControl_AddCode(sc, str); ok(hr == S_OK, "IScriptControl_AddCode failed: 0x%08x.\n", hr); SysFreeString(str); - todo_wine CHECK_ERROR(sc, 0); + CHECK_ERROR(sc, 0); CHECK_CALLED(ParseScriptText);
GetScriptDispatch_expected_name = NULL;
Signed-off-by: Gabriel Ivăncescu gabrielopcode@gmail.com --- dlls/msscript.ocx/msscript.c | 33 +++++++++++++++++++++++++++------ 1 file changed, 27 insertions(+), 6 deletions(-)
diff --git a/dlls/msscript.ocx/msscript.c b/dlls/msscript.ocx/msscript.c index c92a86a..967b8d6 100644 --- a/dlls/msscript.ocx/msscript.c +++ b/dlls/msscript.ocx/msscript.c @@ -121,6 +121,7 @@ struct procedure_enum {
typedef struct { IScriptError IScriptError_iface; + IActiveScriptError *object; LONG ref; } ScriptError;
@@ -132,6 +133,7 @@ struct ScriptHost {
IActiveScript *script; IActiveScriptParse *parse; + ScriptError *error; SCRIPTSTATE script_state; CLSID clsid;
@@ -676,9 +678,15 @@ static HRESULT WINAPI ActiveScriptSite_OnScriptError(IActiveScriptSite *iface, I { ScriptHost *This = impl_from_IActiveScriptSite(iface);
- FIXME("(%p, %p)\n", This, script_error); + TRACE("(%p, %p)\n", This, script_error);
- return E_NOTIMPL; + if (This->error) + { + IScriptError_Clear(&This->error->IScriptError_iface); + IActiveScriptError_AddRef(script_error); + This->error->object = script_error; + } + return S_FALSE; }
static HRESULT WINAPI ActiveScriptSite_OnEnterScript(IActiveScriptSite *iface) @@ -1438,7 +1446,11 @@ static void detach_script_host(ScriptHost *host) if (host->parse) IActiveScriptParse_Release(host->parse);
+ if (host->error) + IScriptError_Release(&host->error->IScriptError_iface); + host->parse = NULL; + host->error = NULL; host->script = NULL; }
@@ -2138,6 +2150,7 @@ static ULONG WINAPI ScriptError_Release(IScriptError *iface)
if (!ref) { + IScriptError_Clear(&This->IScriptError_iface); heap_free(This); }
@@ -2281,9 +2294,15 @@ static HRESULT WINAPI ScriptError_Clear(IScriptError *iface) { ScriptError *This = impl_from_IScriptError(iface);
- FIXME("(%p)->()\n", This); + TRACE("(%p)->()\n", This);
- return E_NOTIMPL; + if (This->object) + { + IActiveScriptError_Release(This->object); + This->object = NULL; + } + + return S_OK; }
static const IScriptErrorVtbl ScriptErrorVtbl = { @@ -2305,7 +2324,7 @@ static const IScriptErrorVtbl ScriptErrorVtbl = { ScriptError_Clear };
-static HRESULT init_script_host(const CLSID *clsid, ScriptHost **ret) +static HRESULT init_script_host(ScriptControl *control, const CLSID *clsid, ScriptHost **ret) { IObjectSafety *objsafety; ScriptHost *host; @@ -2365,6 +2384,8 @@ static HRESULT init_script_host(const CLSID *clsid, ScriptHost **ret) goto failed; } host->script_state = SCRIPTSTATE_INITIALIZED; + host->error = control->error; + IScriptError_AddRef(&host->error->IScriptError_iface);
*ret = host; return S_OK; @@ -2559,7 +2580,7 @@ static HRESULT WINAPI ScriptControl_put_Language(IScriptControl *iface, BSTR lan if (!language) return S_OK;
- hres = init_script_host(&clsid, &This->host); + hres = init_script_host(This, &clsid, &This->host); if (FAILED(hres)) return hres;
Signed-off-by: Jacek Caban jacek@codeweavers.com
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);
Signed-off-by: Jacek Caban jacek@codeweavers.com
Signed-off-by: Gabriel Ivăncescu gabrielopcode@gmail.com --- dlls/msscript.ocx/tests/msscript.c | 281 +++++++++++++++++++++++++++++ 1 file changed, 281 insertions(+)
diff --git a/dlls/msscript.ocx/tests/msscript.c b/dlls/msscript.ocx/tests/msscript.c index 6e94fa9..4a88520 100644 --- a/dlls/msscript.ocx/tests/msscript.c +++ b/dlls/msscript.ocx/tests/msscript.c @@ -106,6 +106,10 @@ DEFINE_EXPECT(GetTypeInfo); DEFINE_EXPECT(GetIDsOfNames); DEFINE_EXPECT(Invoke); DEFINE_EXPECT(InvokeEx); +DEFINE_EXPECT(DeferredFillIn); +DEFINE_EXPECT(GetExceptionInfo); +DEFINE_EXPECT(GetSourcePosition); +DEFINE_EXPECT(GetSourceLineText); DEFINE_EXPECT(SetScriptSite); DEFINE_EXPECT(QI_IActiveScriptParse); DEFINE_EXPECT(GetScriptState); @@ -955,6 +959,94 @@ static const IActiveScriptVtbl ActiveScriptVtbl = {
static IActiveScript ActiveScript = { &ActiveScriptVtbl };
+static HRESULT WINAPI ActiveScriptError_QueryInterface(IActiveScriptError *iface, REFIID riid, void **ppv) +{ + *ppv = NULL; + + if(IsEqualGUID(&IID_IUnknown, riid) || IsEqualGUID(&IID_IActiveScriptError, riid)) { + *ppv = iface; + return S_OK; + } + + ok(0, "unexpected riid %s\n", wine_dbgstr_guid(riid)); + return E_NOINTERFACE; +} + +static ULONG WINAPI ActiveScriptError_AddRef(IActiveScriptError *iface) +{ + return 2; +} + +static ULONG WINAPI ActiveScriptError_Release(IActiveScriptError *iface) +{ + return 1; +} + +static unsigned ActiveScriptError_stage = 0; + +static HRESULT WINAPI ActiveScriptError_DeferredFillIn(EXCEPINFO *pexcepinfo) +{ + CHECK_EXPECT(DeferredFillIn); + + pexcepinfo->bstrSource = SysAllocString(L"foobar"); + pexcepinfo->bstrDescription = SysAllocString(L"barfoo"); + + /* Failure is ignored */ + return E_FAIL; +} + +static HRESULT WINAPI ActiveScriptError_GetExceptionInfo(IActiveScriptError *iface, EXCEPINFO *pexcepinfo) +{ + CHECK_EXPECT(GetExceptionInfo); + + memset(pexcepinfo, 0, sizeof(*pexcepinfo)); + pexcepinfo->wCode = 0xdead; + pexcepinfo->pfnDeferredFillIn = ActiveScriptError_DeferredFillIn; + + if (ActiveScriptError_stage == 0) return E_FAIL; + if (ActiveScriptError_stage == 2) + { + pexcepinfo->wCode = 0; + pexcepinfo->scode = 0xbeef; + pexcepinfo->bstrSource = SysAllocString(L"source"); + pexcepinfo->pfnDeferredFillIn = NULL; + } + return S_OK; +} + +static HRESULT WINAPI ActiveScriptError_GetSourcePosition(IActiveScriptError *iface, DWORD *pdwSourceContext, + ULONG *pulLineNumber, LONG *pichCharPosition) +{ + CHECK_EXPECT(GetSourcePosition); + + *pdwSourceContext = 0xdeadbeef; + *pulLineNumber = 42; + *pichCharPosition = 10; + + return (ActiveScriptError_stage == 0) ? E_FAIL : S_OK; +} + +static HRESULT WINAPI ActiveScriptError_GetSourceLineText(IActiveScriptError *iface, BSTR *pbstrSourceLine) +{ + CHECK_EXPECT(GetSourceLineText); + + *pbstrSourceLine = SysAllocString(L"source line"); + + /* Failure is ignored */ + return E_FAIL; +} + +static const IActiveScriptErrorVtbl ActiveScriptErrorVtbl = { + ActiveScriptError_QueryInterface, + ActiveScriptError_AddRef, + ActiveScriptError_Release, + ActiveScriptError_GetExceptionInfo, + ActiveScriptError_GetSourcePosition, + ActiveScriptError_GetSourceLineText +}; + +static IActiveScriptError ActiveScriptError = { &ActiveScriptErrorVtbl }; + static HRESULT WINAPI ClassFactory_QueryInterface(IClassFactory *iface, REFIID riid, void **ppv) { *ppv = NULL; @@ -3223,6 +3315,194 @@ static void test_IScriptControl_get_Modules(void) } }
+static void test_IScriptControl_get_Error(void) +{ + IScriptError *error, *error2; + IScriptControl *sc; + HRESULT hr; + BSTR str; + LONG x; + + hr = CoCreateInstance(&CLSID_ScriptControl, NULL, CLSCTX_INPROC_SERVER | CLSCTX_INPROC_HANDLER, + &IID_IScriptControl, (void**)&sc); + ok(hr == S_OK, "Failed to create IScriptControl interface: 0x%08x.\n", hr); + + hr = IScriptControl_get_Error(sc, NULL); + ok(hr == E_POINTER, "IScriptControl_get_Error returned: 0x%08x.\n", hr); + hr = IScriptControl_get_Error(sc, &error); + ok(hr == S_OK, "IScriptControl_get_Error failed: 0x%08x.\n", hr); + + x = 0xdeadbeef; + hr = IScriptError_get_Number(error, &x); + ok(hr == S_OK, "IScriptError_get_Number failed: 0x%08x.\n", hr); + ok(x == 0, "Error Number is not 0, got %d.\n", x); + + str = SysAllocString(L"jscript"); + hr = IScriptControl_put_Language(sc, str); + ok(hr == S_OK, "IScriptControl_put_Language failed: 0x%08x.\n", hr); + SysFreeString(str); + + str = SysAllocString(L"" + "var valid_var = 1;\n" + "// comment\n" + "this is an invalid line\n"); + hr = IScriptControl_AddCode(sc, str); + ok(FAILED(hr), "IScriptControl_AddCode succeeded: 0x%08x.\n", hr); + SysFreeString(str); + + x = 0xdeadbeef; + hr = IScriptError_get_Number(error, &x); + ok(hr == S_OK, "IScriptError_get_Number failed: 0x%08x.\n", hr); + todo_wine ok(x > 1000, "Error Number is wrong, got %d.\n", x); + + hr = IScriptError_Clear(error); + ok(hr == S_OK, "IScriptError_Clear failed: 0x%08x.\n", hr); + x = 0xdeadbeef; + hr = IScriptError_get_Number(error, &x); + ok(hr == S_OK, "IScriptError_get_Number failed: 0x%08x.\n", hr); + ok(x == 0, "Error Number is not 0, got %d.\n", x); + + hr = IScriptControl_get_Error(sc, &error2); + ok(hr == S_OK, "IScriptControl_get_Error failed: 0x%08x.\n", hr); + ok(error == error2, "Error objects are not the same (%p vs %p).\n", error, error2); + IScriptError_Release(error2); + + IScriptError_Release(error); + IScriptControl_Release(sc); + + /* custom script engine */ + if (have_custom_engine) + { + hr = CoCreateInstance(&CLSID_ScriptControl, NULL, CLSCTX_INPROC_SERVER | CLSCTX_INPROC_HANDLER, + &IID_IScriptControl, (void**)&sc); + ok(hr == S_OK, "Failed to create IScriptControl interface: 0x%08x.\n", hr); + + SET_EXPECT(CreateInstance); + SET_EXPECT(SetInterfaceSafetyOptions); + SET_EXPECT(SetScriptSite); + SET_EXPECT(QI_IActiveScriptParse); + SET_EXPECT(InitNew); + str = SysAllocString(L"testscript"); + hr = IScriptControl_put_Language(sc, str); + ok(hr == S_OK, "IScriptControl_put_Language failed: 0x%08x.\n", hr); + SysFreeString(str); + CHECK_CALLED(CreateInstance); + CHECK_CALLED(SetInterfaceSafetyOptions); + CHECK_CALLED(SetScriptSite); + CHECK_CALLED(QI_IActiveScriptParse); + CHECK_CALLED(InitNew); + + hr = IScriptControl_get_Error(sc, &error); + ok(hr == S_OK, "IScriptControl_get_Error failed: 0x%08x.\n", hr); + + x = 0xdeadbeef; + hr = IScriptError_get_Number(error, &x); + ok(hr == S_OK, "IScriptError_get_Number failed: 0x%08x.\n", hr); + ok(x == 0, "Error Number is not 0, got %d.\n", x); + + /* The calls are cached even if they fail */ + ActiveScriptError_stage = 0; + hr = IActiveScriptSite_OnScriptError(site, &ActiveScriptError); + ok(hr == S_FALSE, "IActiveScriptSite_OnScriptError returned: 0x%08x.\n", hr); + + SET_EXPECT(GetExceptionInfo); + x = 0xdeadbeef; + hr = IScriptError_get_Number(error, &x); + ok(hr == S_OK, "IScriptError_get_Number failed: 0x%08x.\n", hr); + ok(x == 0, "Error Number is not 0, got %d.\n", x); + CHECK_CALLED(GetExceptionInfo); + + SET_EXPECT(GetSourceLineText); + hr = IScriptError_get_Text(error, &str); + todo_wine ok(hr == S_OK, "IScriptError_get_Text failed: 0x%08x.\n", hr); + if (SUCCEEDED(hr)) SysFreeString(str); + todo_wine CHECK_CALLED(GetSourceLineText); + + SET_EXPECT(GetSourcePosition); + hr = IScriptError_get_Line(error, &x); + todo_wine ok(hr == S_OK, "IScriptError_get_Line failed: 0x%08x.\n", hr); + todo_wine CHECK_CALLED(GetSourcePosition); + hr = IScriptError_get_Column(error, &x); + todo_wine ok(hr == S_OK, "IScriptError_get_Column failed: 0x%08x.\n", hr); + + /* Check with deferred fill-in */ + ActiveScriptError_stage = 1; + hr = IActiveScriptSite_OnScriptError(site, &ActiveScriptError); + ok(hr == S_FALSE, "IActiveScriptSite_OnScriptError returned: 0x%08x.\n", hr); + + SET_EXPECT(GetExceptionInfo); + SET_EXPECT(DeferredFillIn); + x = 0xdeadbeef; + hr = IScriptError_get_Number(error, &x); + ok(hr == S_OK, "IScriptError_get_Number failed: 0x%08x.\n", hr); + ok(x == 0, "Error Number is not 0, got %d.\n", x); + CHECK_CALLED(GetExceptionInfo); + CHECK_CALLED(DeferredFillIn); + hr = IScriptError_get_Source(error, &str); + todo_wine ok(hr == S_OK, "IScriptError_get_Source failed: 0x%08x.\n", hr); + if (SUCCEEDED(hr)) SysFreeString(str); + hr = IScriptError_get_Description(error, &str); + todo_wine ok(hr == S_OK, "IScriptError_get_Description failed: 0x%08x.\n", hr); + if (SUCCEEDED(hr)) SysFreeString(str); + + SET_EXPECT(GetSourceLineText); + hr = IScriptError_get_Text(error, &str); + todo_wine ok(hr == S_OK, "IScriptError_get_Text failed: 0x%08x.\n", hr); + if (SUCCEEDED(hr)) SysFreeString(str); + todo_wine CHECK_CALLED(GetSourceLineText); + + SET_EXPECT(GetSourcePosition); + hr = IScriptError_get_Line(error, &x); + todo_wine ok(hr == S_OK, "IScriptError_get_Line failed: 0x%08x.\n", hr); + todo_wine ok(x == 42, "Error Line is not 42, got %d.\n", x); + todo_wine CHECK_CALLED(GetSourcePosition); + hr = IScriptError_get_Column(error, &x); + todo_wine ok(hr == S_OK, "IScriptError_get_Column failed: 0x%08x.\n", hr); + todo_wine ok(x == 10, "Error Column is not 10, got %d.\n", x); + + /* Check without deferred fill-in, but using scode */ + ActiveScriptError_stage = 2; + hr = IActiveScriptSite_OnScriptError(site, &ActiveScriptError); + ok(hr == S_FALSE, "IActiveScriptSite_OnScriptError returned: 0x%08x.\n", hr); + + SET_EXPECT(GetExceptionInfo); + x = 0xdeadbeef; + hr = IScriptError_get_Number(error, &x); + ok(hr == S_OK, "IScriptError_get_Number failed: 0x%08x.\n", hr); + ok(x == 0xbeef, "Error Number is not 0xbeef, got 0x%04x.\n", x); + CHECK_CALLED(GetExceptionInfo); + hr = IScriptError_get_Source(error, &str); + todo_wine ok(hr == S_OK, "IScriptError_get_Source failed: 0x%08x.\n", hr); + if (SUCCEEDED(hr)) SysFreeString(str); + hr = IScriptError_get_Description(error, &str); + todo_wine ok(hr == S_OK, "IScriptError_get_Description failed: 0x%08x.\n", hr); + if (SUCCEEDED(hr)) SysFreeString(str); + + SET_EXPECT(GetSourceLineText); + hr = IScriptError_get_Text(error, &str); + todo_wine ok(hr == S_OK, "IScriptError_get_Text failed: 0x%08x.\n", hr); + if (SUCCEEDED(hr)) SysFreeString(str); + todo_wine CHECK_CALLED(GetSourceLineText); + + SET_EXPECT(GetSourcePosition); + hr = IScriptError_get_Line(error, &x); + todo_wine ok(hr == S_OK, "IScriptError_get_Line failed: 0x%08x.\n", hr); + todo_wine ok(x == 42, "Error Line is not 42, got %d.\n", x); + todo_wine CHECK_CALLED(GetSourcePosition); + hr = IScriptError_get_Column(error, &x); + todo_wine ok(hr == S_OK, "IScriptError_get_Column failed: 0x%08x.\n", hr); + todo_wine ok(x == 10, "Error Column is not 10, got %d.\n", x); + + IActiveScriptSite_Release(site); + + SET_EXPECT(Close); + IScriptControl_Release(sc); + CHECK_CALLED(Close); + + IScriptError_Release(error); + } +} + static void test_IScriptControl_get_CodeObject(void) { IScriptControl *sc; @@ -3727,6 +4007,7 @@ START_TEST(msscript) test_IScriptControl_ExecuteStatement(); test_IScriptControl_Run(); test_IScriptControl_get_Modules(); + test_IScriptControl_get_Error(); test_IScriptControl_get_CodeObject(); test_IScriptControl_get_Procedures();
Signed-off-by: Jacek Caban jacek@codeweavers.com
Signed-off-by: Gabriel Ivăncescu gabrielopcode@gmail.com --- dlls/msscript.ocx/msscript.c | 10 ++++++++-- dlls/msscript.ocx/tests/msscript.c | 23 +++++++++++++++++++---- 2 files changed, 27 insertions(+), 6 deletions(-)
diff --git a/dlls/msscript.ocx/msscript.c b/dlls/msscript.ocx/msscript.c index 0b316af..30125af 100644 --- a/dlls/msscript.ocx/msscript.c +++ b/dlls/msscript.ocx/msscript.c @@ -125,6 +125,7 @@ typedef struct { LONG ref;
HRESULT number; + BSTR source;
BOOLEAN info_filled; } ScriptError; @@ -2130,6 +2131,7 @@ static void fill_error_info(ScriptError *error) info.pfnDeferredFillIn(&info);
error->number = info.scode; + error->source = info.bstrSource; }
static HRESULT WINAPI ScriptError_QueryInterface(IScriptError *iface, REFIID riid, void **ppv) @@ -2254,9 +2256,11 @@ static HRESULT WINAPI ScriptError_get_Source(IScriptError *iface, BSTR *pbstrSou { ScriptError *This = impl_from_IScriptError(iface);
- FIXME("(%p)->(%p)\n", This, pbstrSource); + TRACE("(%p)->(%p)\n", This, pbstrSource);
- return E_NOTIMPL; + fill_error_info(This); + *pbstrSource = SysAllocString(This->source); + return S_OK; }
static HRESULT WINAPI ScriptError_get_Description(IScriptError *iface, BSTR *pbstrDescription) @@ -2324,8 +2328,10 @@ static HRESULT WINAPI ScriptError_Clear(IScriptError *iface) IActiveScriptError_Release(This->object); This->object = NULL; } + SysFreeString(This->source);
This->number = 0; + This->source = NULL;
This->info_filled = FALSE; return S_OK; diff --git a/dlls/msscript.ocx/tests/msscript.c b/dlls/msscript.ocx/tests/msscript.c index 4a88520..d42ce9e 100644 --- a/dlls/msscript.ocx/tests/msscript.c +++ b/dlls/msscript.ocx/tests/msscript.c @@ -3336,6 +3336,9 @@ static void test_IScriptControl_get_Error(void) hr = IScriptError_get_Number(error, &x); ok(hr == S_OK, "IScriptError_get_Number failed: 0x%08x.\n", hr); ok(x == 0, "Error Number is not 0, got %d.\n", x); + hr = IScriptError_get_Source(error, &str); + ok(hr == S_OK, "IScriptError_get_Source failed: 0x%08x.\n", hr); + ok(str == NULL, "Error Source is not (null), got %s.\n", wine_dbgstr_w(str));
str = SysAllocString(L"jscript"); hr = IScriptControl_put_Language(sc, str); @@ -3354,6 +3357,10 @@ static void test_IScriptControl_get_Error(void) hr = IScriptError_get_Number(error, &x); ok(hr == S_OK, "IScriptError_get_Number failed: 0x%08x.\n", hr); todo_wine ok(x > 1000, "Error Number is wrong, got %d.\n", x); + hr = IScriptError_get_Source(error, &str); + ok(hr == S_OK, "IScriptError_get_Source failed: 0x%08x.\n", hr); + ok(str != NULL, "Error Source is (null).\n"); + SysFreeString(str);
hr = IScriptError_Clear(error); ok(hr == S_OK, "IScriptError_Clear failed: 0x%08x.\n", hr); @@ -3361,6 +3368,9 @@ static void test_IScriptControl_get_Error(void) hr = IScriptError_get_Number(error, &x); ok(hr == S_OK, "IScriptError_get_Number failed: 0x%08x.\n", hr); ok(x == 0, "Error Number is not 0, got %d.\n", x); + hr = IScriptError_get_Source(error, &str); + ok(hr == S_OK, "IScriptError_get_Source failed: 0x%08x.\n", hr); + ok(str == NULL, "Error Source is not (null), got %s.\n", wine_dbgstr_w(str));
hr = IScriptControl_get_Error(sc, &error2); ok(hr == S_OK, "IScriptControl_get_Error failed: 0x%08x.\n", hr); @@ -3411,6 +3421,9 @@ static void test_IScriptControl_get_Error(void) ok(hr == S_OK, "IScriptError_get_Number failed: 0x%08x.\n", hr); ok(x == 0, "Error Number is not 0, got %d.\n", x); CHECK_CALLED(GetExceptionInfo); + hr = IScriptError_get_Source(error, &str); + ok(hr == S_OK, "IScriptError_get_Source failed: 0x%08x.\n", hr); + ok(str == NULL, "Error Source is not (null), got %s.\n", wine_dbgstr_w(str));
SET_EXPECT(GetSourceLineText); hr = IScriptError_get_Text(error, &str); @@ -3439,8 +3452,9 @@ static void test_IScriptControl_get_Error(void) CHECK_CALLED(GetExceptionInfo); CHECK_CALLED(DeferredFillIn); hr = IScriptError_get_Source(error, &str); - todo_wine ok(hr == S_OK, "IScriptError_get_Source failed: 0x%08x.\n", hr); - if (SUCCEEDED(hr)) SysFreeString(str); + ok(hr == S_OK, "IScriptError_get_Source failed: 0x%08x.\n", hr); + ok(!lstrcmpW(str, L"foobar"), "Error Source is wrong, got %s.\n", wine_dbgstr_w(str)); + SysFreeString(str); hr = IScriptError_get_Description(error, &str); todo_wine ok(hr == S_OK, "IScriptError_get_Description failed: 0x%08x.\n", hr); if (SUCCEEDED(hr)) SysFreeString(str); @@ -3472,8 +3486,9 @@ static void test_IScriptControl_get_Error(void) ok(x == 0xbeef, "Error Number is not 0xbeef, got 0x%04x.\n", x); CHECK_CALLED(GetExceptionInfo); hr = IScriptError_get_Source(error, &str); - todo_wine ok(hr == S_OK, "IScriptError_get_Source failed: 0x%08x.\n", hr); - if (SUCCEEDED(hr)) SysFreeString(str); + ok(hr == S_OK, "IScriptError_get_Source failed: 0x%08x.\n", hr); + ok(!lstrcmpW(str, L"source"), "Error Source is wrong, got %s.\n", wine_dbgstr_w(str)); + SysFreeString(str); hr = IScriptError_get_Description(error, &str); todo_wine ok(hr == S_OK, "IScriptError_get_Description failed: 0x%08x.\n", hr); if (SUCCEEDED(hr)) SysFreeString(str);
Signed-off-by: Jacek Caban jacek@codeweavers.com
Signed-off-by: Gabriel Ivăncescu gabrielopcode@gmail.com --- dlls/msscript.ocx/msscript.c | 10 ++++++++-- dlls/msscript.ocx/tests/msscript.c | 22 ++++++++++++++++++---- 2 files changed, 26 insertions(+), 6 deletions(-)
diff --git a/dlls/msscript.ocx/msscript.c b/dlls/msscript.ocx/msscript.c index 30125af..288056b 100644 --- a/dlls/msscript.ocx/msscript.c +++ b/dlls/msscript.ocx/msscript.c @@ -126,6 +126,7 @@ typedef struct {
HRESULT number; BSTR source; + BSTR desc;
BOOLEAN info_filled; } ScriptError; @@ -2132,6 +2133,7 @@ static void fill_error_info(ScriptError *error)
error->number = info.scode; error->source = info.bstrSource; + error->desc = info.bstrDescription; }
static HRESULT WINAPI ScriptError_QueryInterface(IScriptError *iface, REFIID riid, void **ppv) @@ -2267,9 +2269,11 @@ static HRESULT WINAPI ScriptError_get_Description(IScriptError *iface, BSTR *pbs { ScriptError *This = impl_from_IScriptError(iface);
- FIXME("(%p)->(%p)\n", This, pbstrDescription); + TRACE("(%p)->(%p)\n", This, pbstrDescription);
- return E_NOTIMPL; + fill_error_info(This); + *pbstrDescription = SysAllocString(This->desc); + return S_OK; }
static HRESULT WINAPI ScriptError_get_HelpFile(IScriptError *iface, BSTR *pbstrHelpFile) @@ -2329,9 +2333,11 @@ static HRESULT WINAPI ScriptError_Clear(IScriptError *iface) This->object = NULL; } SysFreeString(This->source); + SysFreeString(This->desc);
This->number = 0; This->source = NULL; + This->desc = NULL;
This->info_filled = FALSE; return S_OK; diff --git a/dlls/msscript.ocx/tests/msscript.c b/dlls/msscript.ocx/tests/msscript.c index d42ce9e..46463c6 100644 --- a/dlls/msscript.ocx/tests/msscript.c +++ b/dlls/msscript.ocx/tests/msscript.c @@ -3339,6 +3339,9 @@ static void test_IScriptControl_get_Error(void) hr = IScriptError_get_Source(error, &str); ok(hr == S_OK, "IScriptError_get_Source failed: 0x%08x.\n", hr); ok(str == NULL, "Error Source is not (null), got %s.\n", wine_dbgstr_w(str)); + hr = IScriptError_get_Description(error, &str); + ok(hr == S_OK, "IScriptError_get_Description failed: 0x%08x.\n", hr); + ok(str == NULL, "Error Description is not (null), got %s.\n", wine_dbgstr_w(str));
str = SysAllocString(L"jscript"); hr = IScriptControl_put_Language(sc, str); @@ -3361,6 +3364,10 @@ static void test_IScriptControl_get_Error(void) ok(hr == S_OK, "IScriptError_get_Source failed: 0x%08x.\n", hr); ok(str != NULL, "Error Source is (null).\n"); SysFreeString(str); + hr = IScriptError_get_Description(error, &str); + ok(hr == S_OK, "IScriptError_get_Description failed: 0x%08x.\n", hr); + ok(str != NULL, "Error Description is (null).\n"); + SysFreeString(str);
hr = IScriptError_Clear(error); ok(hr == S_OK, "IScriptError_Clear failed: 0x%08x.\n", hr); @@ -3371,6 +3378,9 @@ static void test_IScriptControl_get_Error(void) hr = IScriptError_get_Source(error, &str); ok(hr == S_OK, "IScriptError_get_Source failed: 0x%08x.\n", hr); ok(str == NULL, "Error Source is not (null), got %s.\n", wine_dbgstr_w(str)); + hr = IScriptError_get_Description(error, &str); + ok(hr == S_OK, "IScriptError_get_Description failed: 0x%08x.\n", hr); + ok(str == NULL, "Error Description is not (null), got %s.\n", wine_dbgstr_w(str));
hr = IScriptControl_get_Error(sc, &error2); ok(hr == S_OK, "IScriptControl_get_Error failed: 0x%08x.\n", hr); @@ -3424,6 +3434,9 @@ static void test_IScriptControl_get_Error(void) hr = IScriptError_get_Source(error, &str); ok(hr == S_OK, "IScriptError_get_Source failed: 0x%08x.\n", hr); ok(str == NULL, "Error Source is not (null), got %s.\n", wine_dbgstr_w(str)); + hr = IScriptError_get_Description(error, &str); + ok(hr == S_OK, "IScriptError_get_Description failed: 0x%08x.\n", hr); + ok(str == NULL, "Error Description is not (null), got %s.\n", wine_dbgstr_w(str));
SET_EXPECT(GetSourceLineText); hr = IScriptError_get_Text(error, &str); @@ -3456,8 +3469,9 @@ static void test_IScriptControl_get_Error(void) ok(!lstrcmpW(str, L"foobar"), "Error Source is wrong, got %s.\n", wine_dbgstr_w(str)); SysFreeString(str); hr = IScriptError_get_Description(error, &str); - todo_wine ok(hr == S_OK, "IScriptError_get_Description failed: 0x%08x.\n", hr); - if (SUCCEEDED(hr)) SysFreeString(str); + ok(hr == S_OK, "IScriptError_get_Description failed: 0x%08x.\n", hr); + ok(!lstrcmpW(str, L"barfoo"), "Error Description is wrong, got %s.\n", wine_dbgstr_w(str)); + SysFreeString(str);
SET_EXPECT(GetSourceLineText); hr = IScriptError_get_Text(error, &str); @@ -3490,8 +3504,8 @@ static void test_IScriptControl_get_Error(void) ok(!lstrcmpW(str, L"source"), "Error Source is wrong, got %s.\n", wine_dbgstr_w(str)); SysFreeString(str); hr = IScriptError_get_Description(error, &str); - todo_wine ok(hr == S_OK, "IScriptError_get_Description failed: 0x%08x.\n", hr); - if (SUCCEEDED(hr)) SysFreeString(str); + ok(hr == S_OK, "IScriptError_get_Description failed: 0x%08x.\n", hr); + ok(str == NULL, "Error Description is not (null), got %s.\n", wine_dbgstr_w(str));
SET_EXPECT(GetSourceLineText); hr = IScriptError_get_Text(error, &str);
Signed-off-by: Jacek Caban jacek@codeweavers.com
Signed-off-by: Gabriel Ivăncescu gabrielopcode@gmail.com --- dlls/msscript.ocx/msscript.c | 10 ++++++++-- dlls/msscript.ocx/tests/msscript.c | 9 +++++++++ 2 files changed, 17 insertions(+), 2 deletions(-)
diff --git a/dlls/msscript.ocx/msscript.c b/dlls/msscript.ocx/msscript.c index 288056b..dcea967 100644 --- a/dlls/msscript.ocx/msscript.c +++ b/dlls/msscript.ocx/msscript.c @@ -127,6 +127,7 @@ typedef struct { HRESULT number; BSTR source; BSTR desc; + BSTR help_file;
BOOLEAN info_filled; } ScriptError; @@ -2134,6 +2135,7 @@ static void fill_error_info(ScriptError *error) error->number = info.scode; error->source = info.bstrSource; error->desc = info.bstrDescription; + error->help_file = info.bstrHelpFile; }
static HRESULT WINAPI ScriptError_QueryInterface(IScriptError *iface, REFIID riid, void **ppv) @@ -2280,9 +2282,11 @@ static HRESULT WINAPI ScriptError_get_HelpFile(IScriptError *iface, BSTR *pbstrH { ScriptError *This = impl_from_IScriptError(iface);
- FIXME("(%p)->(%p)\n", This, pbstrHelpFile); + TRACE("(%p)->(%p)\n", This, pbstrHelpFile);
- return E_NOTIMPL; + fill_error_info(This); + *pbstrHelpFile = SysAllocString(This->help_file); + return S_OK; }
static HRESULT WINAPI ScriptError_get_HelpContext(IScriptError *iface, LONG *plHelpContext) @@ -2334,10 +2338,12 @@ static HRESULT WINAPI ScriptError_Clear(IScriptError *iface) } SysFreeString(This->source); SysFreeString(This->desc); + SysFreeString(This->help_file);
This->number = 0; This->source = NULL; This->desc = NULL; + This->help_file = NULL;
This->info_filled = FALSE; return S_OK; diff --git a/dlls/msscript.ocx/tests/msscript.c b/dlls/msscript.ocx/tests/msscript.c index 46463c6..aa0c31e 100644 --- a/dlls/msscript.ocx/tests/msscript.c +++ b/dlls/msscript.ocx/tests/msscript.c @@ -3342,6 +3342,9 @@ static void test_IScriptControl_get_Error(void) hr = IScriptError_get_Description(error, &str); ok(hr == S_OK, "IScriptError_get_Description failed: 0x%08x.\n", hr); ok(str == NULL, "Error Description is not (null), got %s.\n", wine_dbgstr_w(str)); + hr = IScriptError_get_HelpFile(error, &str); + ok(hr == S_OK, "IScriptError_get_HelpFile failed: 0x%08x.\n", hr); + ok(str == NULL, "Error HelpFile is not (null), got %s.\n", wine_dbgstr_w(str));
str = SysAllocString(L"jscript"); hr = IScriptControl_put_Language(sc, str); @@ -3381,6 +3384,9 @@ static void test_IScriptControl_get_Error(void) hr = IScriptError_get_Description(error, &str); ok(hr == S_OK, "IScriptError_get_Description failed: 0x%08x.\n", hr); ok(str == NULL, "Error Description is not (null), got %s.\n", wine_dbgstr_w(str)); + hr = IScriptError_get_HelpFile(error, &str); + ok(hr == S_OK, "IScriptError_get_HelpFile failed: 0x%08x.\n", hr); + ok(str == NULL, "Error HelpFile is not (null), got %s.\n", wine_dbgstr_w(str));
hr = IScriptControl_get_Error(sc, &error2); ok(hr == S_OK, "IScriptControl_get_Error failed: 0x%08x.\n", hr); @@ -3437,6 +3443,9 @@ static void test_IScriptControl_get_Error(void) hr = IScriptError_get_Description(error, &str); ok(hr == S_OK, "IScriptError_get_Description failed: 0x%08x.\n", hr); ok(str == NULL, "Error Description is not (null), got %s.\n", wine_dbgstr_w(str)); + hr = IScriptError_get_HelpFile(error, &str); + ok(hr == S_OK, "IScriptError_get_HelpFile failed: 0x%08x.\n", hr); + ok(str == NULL, "Error HelpFile is not (null), got %s.\n", wine_dbgstr_w(str));
SET_EXPECT(GetSourceLineText); hr = IScriptError_get_Text(error, &str);
Signed-off-by: Jacek Caban jacek@codeweavers.com
Signed-off-by: Gabriel Ivăncescu gabrielopcode@gmail.com --- dlls/msscript.ocx/msscript.c | 9 +++++++-- dlls/msscript.ocx/tests/msscript.c | 9 +++++++++ 2 files changed, 16 insertions(+), 2 deletions(-)
diff --git a/dlls/msscript.ocx/msscript.c b/dlls/msscript.ocx/msscript.c index dcea967..05e6121 100644 --- a/dlls/msscript.ocx/msscript.c +++ b/dlls/msscript.ocx/msscript.c @@ -128,6 +128,7 @@ typedef struct { BSTR source; BSTR desc; BSTR help_file; + DWORD help_context;
BOOLEAN info_filled; } ScriptError; @@ -2136,6 +2137,7 @@ static void fill_error_info(ScriptError *error) error->source = info.bstrSource; error->desc = info.bstrDescription; error->help_file = info.bstrHelpFile; + error->help_context = info.dwHelpContext; }
static HRESULT WINAPI ScriptError_QueryInterface(IScriptError *iface, REFIID riid, void **ppv) @@ -2293,9 +2295,11 @@ static HRESULT WINAPI ScriptError_get_HelpContext(IScriptError *iface, LONG *plH { ScriptError *This = impl_from_IScriptError(iface);
- FIXME("(%p)->(%p)\n", This, plHelpContext); + TRACE("(%p)->(%p)\n", This, plHelpContext);
- return E_NOTIMPL; + fill_error_info(This); + *plHelpContext = This->help_context; + return S_OK; }
static HRESULT WINAPI ScriptError_get_Text(IScriptError *iface, BSTR *pbstrText) @@ -2344,6 +2348,7 @@ static HRESULT WINAPI ScriptError_Clear(IScriptError *iface) This->source = NULL; This->desc = NULL; This->help_file = NULL; + This->help_context = 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 aa0c31e..702fbb1 100644 --- a/dlls/msscript.ocx/tests/msscript.c +++ b/dlls/msscript.ocx/tests/msscript.c @@ -3345,6 +3345,9 @@ static void test_IScriptControl_get_Error(void) hr = IScriptError_get_HelpFile(error, &str); ok(hr == S_OK, "IScriptError_get_HelpFile failed: 0x%08x.\n", hr); ok(str == NULL, "Error HelpFile is not (null), got %s.\n", wine_dbgstr_w(str)); + hr = IScriptError_get_HelpContext(error, &x); + ok(hr == S_OK, "IScriptError_get_HelpContext failed: 0x%08x.\n", hr); + ok(x == 0, "Error HelpContext is not 0, got %d.\n", x);
str = SysAllocString(L"jscript"); hr = IScriptControl_put_Language(sc, str); @@ -3387,6 +3390,9 @@ static void test_IScriptControl_get_Error(void) hr = IScriptError_get_HelpFile(error, &str); ok(hr == S_OK, "IScriptError_get_HelpFile failed: 0x%08x.\n", hr); ok(str == NULL, "Error HelpFile is not (null), got %s.\n", wine_dbgstr_w(str)); + hr = IScriptError_get_HelpContext(error, &x); + ok(hr == S_OK, "IScriptError_get_HelpContext failed: 0x%08x.\n", hr); + ok(x == 0, "Error HelpContext is not 0, got %d.\n", x);
hr = IScriptControl_get_Error(sc, &error2); ok(hr == S_OK, "IScriptControl_get_Error failed: 0x%08x.\n", hr); @@ -3446,6 +3452,9 @@ static void test_IScriptControl_get_Error(void) hr = IScriptError_get_HelpFile(error, &str); ok(hr == S_OK, "IScriptError_get_HelpFile failed: 0x%08x.\n", hr); ok(str == NULL, "Error HelpFile is not (null), got %s.\n", wine_dbgstr_w(str)); + hr = IScriptError_get_HelpContext(error, &x); + ok(hr == S_OK, "IScriptError_get_HelpContext failed: 0x%08x.\n", hr); + ok(x == 0, "Error HelpContext is not 0, got %d.\n", x);
SET_EXPECT(GetSourceLineText); hr = IScriptError_get_Text(error, &str);
Signed-off-by: Jacek Caban jacek@codeweavers.com
Signed-off-by: Gabriel Ivăncescu gabrielopcode@gmail.com --- dlls/msscript.ocx/msscript.c | 20 +++++++++++++++++-- dlls/msscript.ocx/tests/msscript.c | 31 +++++++++++++++++++++--------- 2 files changed, 40 insertions(+), 11 deletions(-)
diff --git a/dlls/msscript.ocx/msscript.c b/dlls/msscript.ocx/msscript.c index 05e6121..89a18a0 100644 --- a/dlls/msscript.ocx/msscript.c +++ b/dlls/msscript.ocx/msscript.c @@ -125,12 +125,14 @@ typedef struct { LONG ref;
HRESULT number; + BSTR text; BSTR source; BSTR desc; BSTR help_file; DWORD help_context;
BOOLEAN info_filled; + BOOLEAN text_filled; } ScriptError;
struct ScriptHost { @@ -2140,6 +2142,15 @@ static void fill_error_info(ScriptError *error) error->help_context = info.dwHelpContext; }
+static void fill_error_text(ScriptError *error) +{ + if (error->text_filled) return; + error->text_filled = TRUE; + + if (error->object) + IActiveScriptError_GetSourceLineText(error->object, &error->text); +} + static HRESULT WINAPI ScriptError_QueryInterface(IScriptError *iface, REFIID riid, void **ppv) { ScriptError *This = impl_from_IScriptError(iface); @@ -2306,9 +2317,11 @@ static HRESULT WINAPI ScriptError_get_Text(IScriptError *iface, BSTR *pbstrText) { ScriptError *This = impl_from_IScriptError(iface);
- FIXME("(%p)->(%p)\n", This, pbstrText); + TRACE("(%p)->(%p)\n", This, pbstrText);
- return E_NOTIMPL; + fill_error_text(This); + *pbstrText = SysAllocString(This->text); + return S_OK; }
static HRESULT WINAPI ScriptError_get_Line(IScriptError *iface, LONG *plLine) @@ -2340,17 +2353,20 @@ static HRESULT WINAPI ScriptError_Clear(IScriptError *iface) IActiveScriptError_Release(This->object); This->object = NULL; } + SysFreeString(This->text); SysFreeString(This->source); SysFreeString(This->desc); SysFreeString(This->help_file);
This->number = 0; + This->text = NULL; This->source = NULL; This->desc = NULL; This->help_file = NULL; This->help_context = 0;
This->info_filled = FALSE; + This->text_filled = FALSE; return S_OK; }
diff --git a/dlls/msscript.ocx/tests/msscript.c b/dlls/msscript.ocx/tests/msscript.c index 702fbb1..bcd669f 100644 --- a/dlls/msscript.ocx/tests/msscript.c +++ b/dlls/msscript.ocx/tests/msscript.c @@ -3348,6 +3348,9 @@ static void test_IScriptControl_get_Error(void) hr = IScriptError_get_HelpContext(error, &x); ok(hr == S_OK, "IScriptError_get_HelpContext failed: 0x%08x.\n", hr); ok(x == 0, "Error HelpContext is not 0, got %d.\n", x); + hr = IScriptError_get_Text(error, &str); + ok(hr == S_OK, "IScriptError_get_Text failed: 0x%08x.\n", hr); + ok(str == NULL, "Error Text is not (null), got %s.\n", wine_dbgstr_w(str));
str = SysAllocString(L"jscript"); hr = IScriptControl_put_Language(sc, str); @@ -3374,6 +3377,10 @@ static void test_IScriptControl_get_Error(void) ok(hr == S_OK, "IScriptError_get_Description failed: 0x%08x.\n", hr); ok(str != NULL, "Error Description is (null).\n"); SysFreeString(str); + hr = IScriptError_get_Text(error, &str); + ok(hr == S_OK, "IScriptError_get_Text failed: 0x%08x.\n", hr); + ok(!lstrcmpW(str, L"this is an invalid line"), "Error Text is wrong, got %s.\n", wine_dbgstr_w(str)); + SysFreeString(str);
hr = IScriptError_Clear(error); ok(hr == S_OK, "IScriptError_Clear failed: 0x%08x.\n", hr); @@ -3393,6 +3400,9 @@ static void test_IScriptControl_get_Error(void) hr = IScriptError_get_HelpContext(error, &x); ok(hr == S_OK, "IScriptError_get_HelpContext failed: 0x%08x.\n", hr); ok(x == 0, "Error HelpContext is not 0, got %d.\n", x); + hr = IScriptError_get_Text(error, &str); + ok(hr == S_OK, "IScriptError_get_Text failed: 0x%08x.\n", hr); + ok(str == NULL, "Error Text is not (null), got %s.\n", wine_dbgstr_w(str));
hr = IScriptControl_get_Error(sc, &error2); ok(hr == S_OK, "IScriptControl_get_Error failed: 0x%08x.\n", hr); @@ -3458,9 +3468,10 @@ static void test_IScriptControl_get_Error(void)
SET_EXPECT(GetSourceLineText); hr = IScriptError_get_Text(error, &str); - todo_wine ok(hr == S_OK, "IScriptError_get_Text failed: 0x%08x.\n", hr); - if (SUCCEEDED(hr)) SysFreeString(str); - todo_wine CHECK_CALLED(GetSourceLineText); + ok(hr == S_OK, "IScriptError_get_Text failed: 0x%08x.\n", hr); + ok(!lstrcmpW(str, L"source line"), "Error Text is wrong, got %s.\n", wine_dbgstr_w(str)); + SysFreeString(str); + CHECK_CALLED(GetSourceLineText);
SET_EXPECT(GetSourcePosition); hr = IScriptError_get_Line(error, &x); @@ -3493,9 +3504,10 @@ static void test_IScriptControl_get_Error(void)
SET_EXPECT(GetSourceLineText); hr = IScriptError_get_Text(error, &str); - todo_wine ok(hr == S_OK, "IScriptError_get_Text failed: 0x%08x.\n", hr); - if (SUCCEEDED(hr)) SysFreeString(str); - todo_wine CHECK_CALLED(GetSourceLineText); + ok(hr == S_OK, "IScriptError_get_Text failed: 0x%08x.\n", hr); + ok(!lstrcmpW(str, L"source line"), "Error Text is wrong, got %s.\n", wine_dbgstr_w(str)); + SysFreeString(str); + CHECK_CALLED(GetSourceLineText);
SET_EXPECT(GetSourcePosition); hr = IScriptError_get_Line(error, &x); @@ -3527,9 +3539,10 @@ static void test_IScriptControl_get_Error(void)
SET_EXPECT(GetSourceLineText); hr = IScriptError_get_Text(error, &str); - todo_wine ok(hr == S_OK, "IScriptError_get_Text failed: 0x%08x.\n", hr); - if (SUCCEEDED(hr)) SysFreeString(str); - todo_wine CHECK_CALLED(GetSourceLineText); + ok(hr == S_OK, "IScriptError_get_Text failed: 0x%08x.\n", hr); + ok(!lstrcmpW(str, L"source line"), "Error Text is wrong, got %s.\n", wine_dbgstr_w(str)); + SysFreeString(str); + CHECK_CALLED(GetSourceLineText);
SET_EXPECT(GetSourcePosition); hr = IScriptError_get_Line(error, &x);
Signed-off-by: Jacek Caban jacek@codeweavers.com
Signed-off-by: Jacek Caban jacek@codeweavers.com
Signed-off-by: Gabriel Ivăncescu gabrielopcode@gmail.com --- dlls/msscript.ocx/msscript.c | 27 +++++++++++++++++++++++++-- dlls/msscript.ocx/tests/msscript.c | 26 ++++++++++++++++++-------- 2 files changed, 43 insertions(+), 10 deletions(-)
diff --git a/dlls/msscript.ocx/msscript.c b/dlls/msscript.ocx/msscript.c index 89a18a0..3bf9009 100644 --- a/dlls/msscript.ocx/msscript.c +++ b/dlls/msscript.ocx/msscript.c @@ -130,9 +130,11 @@ typedef struct { BSTR desc; BSTR help_file; DWORD help_context; + ULONG line;
BOOLEAN info_filled; BOOLEAN text_filled; + BOOLEAN pos_filled; } ScriptError;
struct ScriptHost { @@ -2151,6 +2153,23 @@ static void fill_error_text(ScriptError *error) IActiveScriptError_GetSourceLineText(error->object, &error->text); }
+static void fill_error_pos(ScriptError *error) +{ + DWORD context; + LONG column; + ULONG line; + + if (error->pos_filled) return; + error->pos_filled = TRUE; + + if (!error->object) + return; + if (FAILED(IActiveScriptError_GetSourcePosition(error->object, &context, &line, &column))) + return; + + error->line = line; +} + static HRESULT WINAPI ScriptError_QueryInterface(IScriptError *iface, REFIID riid, void **ppv) { ScriptError *This = impl_from_IScriptError(iface); @@ -2328,9 +2347,11 @@ static HRESULT WINAPI ScriptError_get_Line(IScriptError *iface, LONG *plLine) { ScriptError *This = impl_from_IScriptError(iface);
- FIXME("(%p)->(%p)\n", This, plLine); + TRACE("(%p)->(%p)\n", This, plLine);
- return E_NOTIMPL; + fill_error_pos(This); + *plLine = This->line; + return S_OK; }
static HRESULT WINAPI ScriptError_get_Column(IScriptError *iface, LONG *plColumn) @@ -2364,9 +2385,11 @@ static HRESULT WINAPI ScriptError_Clear(IScriptError *iface) This->desc = NULL; This->help_file = NULL; This->help_context = 0; + This->line = 0;
This->info_filled = FALSE; This->text_filled = FALSE; + This->pos_filled = FALSE; return S_OK; }
diff --git a/dlls/msscript.ocx/tests/msscript.c b/dlls/msscript.ocx/tests/msscript.c index bcd669f..5e1ae16 100644 --- a/dlls/msscript.ocx/tests/msscript.c +++ b/dlls/msscript.ocx/tests/msscript.c @@ -3351,6 +3351,9 @@ static void test_IScriptControl_get_Error(void) hr = IScriptError_get_Text(error, &str); ok(hr == S_OK, "IScriptError_get_Text failed: 0x%08x.\n", hr); ok(str == NULL, "Error Text is not (null), got %s.\n", wine_dbgstr_w(str)); + hr = IScriptError_get_Line(error, &x); + ok(hr == S_OK, "IScriptError_get_Line failed: 0x%08x.\n", hr); + ok(x == 0, "Error Line is not 0, got %d.\n", x);
str = SysAllocString(L"jscript"); hr = IScriptControl_put_Language(sc, str); @@ -3381,6 +3384,9 @@ static void test_IScriptControl_get_Error(void) ok(hr == S_OK, "IScriptError_get_Text failed: 0x%08x.\n", hr); ok(!lstrcmpW(str, L"this is an invalid line"), "Error Text is wrong, got %s.\n", wine_dbgstr_w(str)); SysFreeString(str); + hr = IScriptError_get_Line(error, &x); + ok(hr == S_OK, "IScriptError_get_Line failed: 0x%08x.\n", hr); + ok(x == 3, "Error Line is not 3, got %d.\n", x);
hr = IScriptError_Clear(error); ok(hr == S_OK, "IScriptError_Clear failed: 0x%08x.\n", hr); @@ -3403,6 +3409,9 @@ static void test_IScriptControl_get_Error(void) hr = IScriptError_get_Text(error, &str); ok(hr == S_OK, "IScriptError_get_Text failed: 0x%08x.\n", hr); ok(str == NULL, "Error Text is not (null), got %s.\n", wine_dbgstr_w(str)); + hr = IScriptError_get_Line(error, &x); + ok(hr == S_OK, "IScriptError_get_Line failed: 0x%08x.\n", hr); + ok(x == 0, "Error Line is not 0, got %d.\n", x);
hr = IScriptControl_get_Error(sc, &error2); ok(hr == S_OK, "IScriptControl_get_Error failed: 0x%08x.\n", hr); @@ -3475,8 +3484,9 @@ static void test_IScriptControl_get_Error(void)
SET_EXPECT(GetSourcePosition); hr = IScriptError_get_Line(error, &x); - todo_wine ok(hr == S_OK, "IScriptError_get_Line failed: 0x%08x.\n", hr); - todo_wine CHECK_CALLED(GetSourcePosition); + ok(hr == S_OK, "IScriptError_get_Line failed: 0x%08x.\n", hr); + ok(x == 0, "Error Line is not 0, got %d.\n", x); + CHECK_CALLED(GetSourcePosition); hr = IScriptError_get_Column(error, &x); todo_wine ok(hr == S_OK, "IScriptError_get_Column failed: 0x%08x.\n", hr);
@@ -3511,9 +3521,9 @@ static void test_IScriptControl_get_Error(void)
SET_EXPECT(GetSourcePosition); hr = IScriptError_get_Line(error, &x); - todo_wine ok(hr == S_OK, "IScriptError_get_Line failed: 0x%08x.\n", hr); - todo_wine ok(x == 42, "Error Line is not 42, got %d.\n", x); - todo_wine CHECK_CALLED(GetSourcePosition); + ok(hr == S_OK, "IScriptError_get_Line failed: 0x%08x.\n", hr); + ok(x == 42, "Error Line is not 42, got %d.\n", x); + CHECK_CALLED(GetSourcePosition); hr = IScriptError_get_Column(error, &x); todo_wine ok(hr == S_OK, "IScriptError_get_Column failed: 0x%08x.\n", hr); todo_wine ok(x == 10, "Error Column is not 10, got %d.\n", x); @@ -3546,9 +3556,9 @@ static void test_IScriptControl_get_Error(void)
SET_EXPECT(GetSourcePosition); hr = IScriptError_get_Line(error, &x); - todo_wine ok(hr == S_OK, "IScriptError_get_Line failed: 0x%08x.\n", hr); - todo_wine ok(x == 42, "Error Line is not 42, got %d.\n", x); - todo_wine CHECK_CALLED(GetSourcePosition); + ok(hr == S_OK, "IScriptError_get_Line failed: 0x%08x.\n", hr); + ok(x == 42, "Error Line is not 42, got %d.\n", x); + CHECK_CALLED(GetSourcePosition); hr = IScriptError_get_Column(error, &x); todo_wine ok(hr == S_OK, "IScriptError_get_Column failed: 0x%08x.\n", hr); todo_wine ok(x == 10, "Error Column is not 10, got %d.\n", x);
Signed-off-by: Jacek Caban jacek@codeweavers.com
Signed-off-by: Gabriel Ivăncescu gabrielopcode@gmail.com --- dlls/msscript.ocx/msscript.c | 9 +++++++-- dlls/msscript.ocx/tests/msscript.c | 20 +++++++++++++++----- 2 files changed, 22 insertions(+), 7 deletions(-)
diff --git a/dlls/msscript.ocx/msscript.c b/dlls/msscript.ocx/msscript.c index 3bf9009..112403a 100644 --- a/dlls/msscript.ocx/msscript.c +++ b/dlls/msscript.ocx/msscript.c @@ -131,6 +131,7 @@ typedef struct { BSTR help_file; DWORD help_context; ULONG line; + LONG column;
BOOLEAN info_filled; BOOLEAN text_filled; @@ -2168,6 +2169,7 @@ static void fill_error_pos(ScriptError *error) return;
error->line = line; + error->column = column; }
static HRESULT WINAPI ScriptError_QueryInterface(IScriptError *iface, REFIID riid, void **ppv) @@ -2358,9 +2360,11 @@ static HRESULT WINAPI ScriptError_get_Column(IScriptError *iface, LONG *plColumn { ScriptError *This = impl_from_IScriptError(iface);
- FIXME("(%p)->(%p)\n", This, plColumn); + TRACE("(%p)->(%p)\n", This, plColumn);
- return E_NOTIMPL; + fill_error_pos(This); + *plColumn = This->column; + return S_OK; }
static HRESULT WINAPI ScriptError_Clear(IScriptError *iface) @@ -2386,6 +2390,7 @@ static HRESULT WINAPI ScriptError_Clear(IScriptError *iface) This->help_file = NULL; This->help_context = 0; This->line = 0; + This->column = 0;
This->info_filled = FALSE; This->text_filled = FALSE; diff --git a/dlls/msscript.ocx/tests/msscript.c b/dlls/msscript.ocx/tests/msscript.c index 5e1ae16..5b95863 100644 --- a/dlls/msscript.ocx/tests/msscript.c +++ b/dlls/msscript.ocx/tests/msscript.c @@ -3354,6 +3354,9 @@ static void test_IScriptControl_get_Error(void) hr = IScriptError_get_Line(error, &x); ok(hr == S_OK, "IScriptError_get_Line failed: 0x%08x.\n", hr); ok(x == 0, "Error Line is not 0, got %d.\n", x); + hr = IScriptError_get_Column(error, &x); + ok(hr == S_OK, "IScriptError_get_Column failed: 0x%08x.\n", hr); + ok(x == 0, "Error Column is not 0, got %d.\n", x);
str = SysAllocString(L"jscript"); hr = IScriptControl_put_Language(sc, str); @@ -3387,6 +3390,9 @@ static void test_IScriptControl_get_Error(void) hr = IScriptError_get_Line(error, &x); ok(hr == S_OK, "IScriptError_get_Line failed: 0x%08x.\n", hr); ok(x == 3, "Error Line is not 3, got %d.\n", x); + hr = IScriptError_get_Column(error, &x); + ok(hr == S_OK, "IScriptError_get_Column failed: 0x%08x.\n", hr); + ok(x == 5, "Error Column is not 5, got %d.\n", x);
hr = IScriptError_Clear(error); ok(hr == S_OK, "IScriptError_Clear failed: 0x%08x.\n", hr); @@ -3412,6 +3418,9 @@ static void test_IScriptControl_get_Error(void) hr = IScriptError_get_Line(error, &x); ok(hr == S_OK, "IScriptError_get_Line failed: 0x%08x.\n", hr); ok(x == 0, "Error Line is not 0, got %d.\n", x); + hr = IScriptError_get_Column(error, &x); + ok(hr == S_OK, "IScriptError_get_Column failed: 0x%08x.\n", hr); + ok(x == 0, "Error Column is not 0, got %d.\n", x);
hr = IScriptControl_get_Error(sc, &error2); ok(hr == S_OK, "IScriptControl_get_Error failed: 0x%08x.\n", hr); @@ -3488,7 +3497,8 @@ static void test_IScriptControl_get_Error(void) ok(x == 0, "Error Line is not 0, got %d.\n", x); CHECK_CALLED(GetSourcePosition); hr = IScriptError_get_Column(error, &x); - todo_wine ok(hr == S_OK, "IScriptError_get_Column failed: 0x%08x.\n", hr); + ok(hr == S_OK, "IScriptError_get_Column failed: 0x%08x.\n", hr); + ok(x == 0, "Error Column is not 0, got %d.\n", x);
/* Check with deferred fill-in */ ActiveScriptError_stage = 1; @@ -3525,8 +3535,8 @@ static void test_IScriptControl_get_Error(void) ok(x == 42, "Error Line is not 42, got %d.\n", x); CHECK_CALLED(GetSourcePosition); hr = IScriptError_get_Column(error, &x); - todo_wine ok(hr == S_OK, "IScriptError_get_Column failed: 0x%08x.\n", hr); - todo_wine ok(x == 10, "Error Column is not 10, got %d.\n", x); + ok(hr == S_OK, "IScriptError_get_Column failed: 0x%08x.\n", hr); + ok(x == 10, "Error Column is not 10, got %d.\n", x);
/* Check without deferred fill-in, but using scode */ ActiveScriptError_stage = 2; @@ -3560,8 +3570,8 @@ static void test_IScriptControl_get_Error(void) ok(x == 42, "Error Line is not 42, got %d.\n", x); CHECK_CALLED(GetSourcePosition); hr = IScriptError_get_Column(error, &x); - todo_wine ok(hr == S_OK, "IScriptError_get_Column failed: 0x%08x.\n", hr); - todo_wine ok(x == 10, "Error Column is not 10, got %d.\n", x); + ok(hr == S_OK, "IScriptError_get_Column failed: 0x%08x.\n", hr); + ok(x == 10, "Error Column is not 10, got %d.\n", x);
IActiveScriptSite_Release(site);
Signed-off-by: Jacek Caban jacek@codeweavers.com