Signed-off-by: Gabriel Ivăncescu gabrielopcode@gmail.com --- dlls/msscript.ocx/msscript.c | 39 +++++++++++++++++++++--------- dlls/msscript.ocx/tests/msscript.c | 24 +++++++++--------- 2 files changed, 40 insertions(+), 23 deletions(-)
diff --git a/dlls/msscript.ocx/msscript.c b/dlls/msscript.ocx/msscript.c index 01df485..ab8c551 100644 --- a/dlls/msscript.ocx/msscript.c +++ b/dlls/msscript.ocx/msscript.c @@ -299,7 +299,8 @@ static HRESULT add_script_object(ScriptHost *host, BSTR name, IDispatch *object, return hr; }
-static HRESULT parse_script_text(ScriptControl *control, BSTR script_text, DWORD flag, VARIANT *res) +static HRESULT parse_script_text(ScriptControl *control, struct module *module, BSTR script_text, + DWORD flag, VARIANT *res) { EXCEPINFO excepinfo; HRESULT hr; @@ -307,7 +308,7 @@ static HRESULT parse_script_text(ScriptControl *control, BSTR script_text, DWORD hr = start_script(control); if (FAILED(hr)) return hr;
- hr = IActiveScriptParse_ParseScriptText(control->host->parse, script_text, NULL, + hr = IActiveScriptParse_ParseScriptText(control->host->parse, script_text, module->name, NULL, NULL, 0, 1, flag, res, &excepinfo); /* FIXME: more error handling */ return hr; @@ -821,27 +822,37 @@ static HRESULT WINAPI ScriptModule_AddCode(IScriptModule *iface, BSTR code) { ScriptModule *This = impl_from_IScriptModule(iface);
- FIXME("(%p)->(%s)\n", This, debugstr_w(code)); + TRACE("(%p)->(%s)\n", This, debugstr_w(code));
- return E_NOTIMPL; + if (!This->control) + return E_FAIL; + return parse_script_text(This->control, &This->control->modules[This->idx], code, SCRIPTTEXT_ISVISIBLE, NULL); }
static HRESULT WINAPI ScriptModule_Eval(IScriptModule *iface, BSTR expression, VARIANT *res) { ScriptModule *This = impl_from_IScriptModule(iface);
- FIXME("(%p)->(%s, %p)\n", This, debugstr_w(expression), res); + TRACE("(%p)->(%s, %p)\n", This, debugstr_w(expression), res);
- return E_NOTIMPL; + if (!res) + return E_POINTER; + V_VT(res) = VT_EMPTY; + + if (!This->control) + return E_FAIL; + return parse_script_text(This->control, &This->control->modules[This->idx], expression, SCRIPTTEXT_ISEXPRESSION, res); }
static HRESULT WINAPI ScriptModule_ExecuteStatement(IScriptModule *iface, BSTR statement) { ScriptModule *This = impl_from_IScriptModule(iface);
- FIXME("(%p)->(%s)\n", This, debugstr_w(statement)); + TRACE("(%p)->(%s)\n", This, debugstr_w(statement));
- return E_NOTIMPL; + if (!This->control) + return E_FAIL; + return parse_script_text(This->control, &This->control->modules[This->idx], statement, 0, NULL); }
static HRESULT WINAPI ScriptModule_Run(IScriptModule *iface, BSTR procedure_name, SAFEARRAY **parameters, VARIANT *res) @@ -1558,7 +1569,9 @@ static HRESULT WINAPI ScriptControl_AddCode(IScriptControl *iface, BSTR code)
TRACE("(%p)->(%s).\n", This, debugstr_w(code));
- return parse_script_text(This, code, SCRIPTTEXT_ISVISIBLE, NULL); + if (!This->modules) + return E_FAIL; + return parse_script_text(This, &This->modules[0], code, SCRIPTTEXT_ISVISIBLE, NULL); }
static HRESULT WINAPI ScriptControl_Eval(IScriptControl *iface, BSTR expression, VARIANT *res) @@ -1571,7 +1584,9 @@ static HRESULT WINAPI ScriptControl_Eval(IScriptControl *iface, BSTR expression, return E_POINTER; V_VT(res) = VT_EMPTY;
- return parse_script_text(This, expression, SCRIPTTEXT_ISEXPRESSION, res); + if (!This->modules) + return E_FAIL; + return parse_script_text(This, &This->modules[0], expression, SCRIPTTEXT_ISEXPRESSION, res); }
static HRESULT WINAPI ScriptControl_ExecuteStatement(IScriptControl *iface, BSTR statement) @@ -1580,7 +1595,9 @@ static HRESULT WINAPI ScriptControl_ExecuteStatement(IScriptControl *iface, BSTR
TRACE("(%p)->(%s)\n", This, debugstr_w(statement));
- return parse_script_text(This, statement, 0, NULL); + if (!This->modules) + return E_FAIL; + return parse_script_text(This, &This->modules[0], statement, 0, NULL); }
static HRESULT WINAPI ScriptControl_Run(IScriptControl *iface, BSTR procedure_name, SAFEARRAY **parameters, VARIANT *res) diff --git a/dlls/msscript.ocx/tests/msscript.c b/dlls/msscript.ocx/tests/msscript.c index c5e7695..8d2c1b8 100644 --- a/dlls/msscript.ocx/tests/msscript.c +++ b/dlls/msscript.ocx/tests/msscript.c @@ -2226,7 +2226,7 @@ static void test_IScriptControl_get_Modules(void) 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); + ok(hr == S_OK, "IScriptModule_AddCode failed: 0x%08x.\n", hr); IScriptModule_Release(mod); SysFreeString(str);
@@ -2252,15 +2252,15 @@ static void test_IScriptControl_get_Modules(void) 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); + ok(hr == S_OK, "IScriptModule_AddCode failed: 0x%08x.\n", hr); IScriptModule_Release(mod); SysFreeString(str);
/* The 'Global' module is the same as the script control */ str = SysAllocString(L"add(10, 5)"); hr = IScriptControl_Eval(sc, str, &var); - todo_wine ok(hr == S_OK, "IScriptControl_Eval failed: 0x%08x.\n", hr); - todo_wine ok(V_VT(&var) == VT_I4 && V_I4(&var) == 15, "V_VT(var) = %d, V_I4(var) = %d.\n", V_VT(&var), V_I4(&var)); + ok(hr == S_OK, "IScriptControl_Eval failed: 0x%08x.\n", hr); + ok(V_VT(&var) == VT_I4 && V_I4(&var) == 15, "V_VT(var) = %d, V_I4(var) = %d.\n", V_VT(&var), V_I4(&var)); SysFreeString(str); str = SysAllocString(L"sub(10, 5)"); hr = IScriptControl_Eval(sc, str, &var); @@ -2285,11 +2285,11 @@ static void test_IScriptControl_get_Modules(void) 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); + ok(hr == E_FAIL, "IScriptModule_AddCode failed: 0x%08x.\n", hr); SysFreeString(str); str = SysAllocString(L"sub closed\nend sub"); hr = IScriptModule_AddCode(mod, str); - todo_wine ok(hr == E_FAIL, "IScriptModule_AddCode failed: 0x%08x.\n", hr); + ok(hr == E_FAIL, "IScriptModule_AddCode failed: 0x%08x.\n", hr); IScriptModule_Release(mod); SysFreeString(str);
@@ -2377,9 +2377,9 @@ static void test_IScriptControl_get_Modules(void) parse_flags = SCRIPTTEXT_ISVISIBLE; code_str = SysAllocString(L"some code"); hr = IScriptModule_AddCode(mod, code_str); - todo_wine ok(hr == S_OK, "IScriptControl_AddCode failed: 0x%08x.\n", hr); - todo_wine CHECK_CALLED(SetScriptState_STARTED); - todo_wine CHECK_CALLED(ParseScriptText); + ok(hr == S_OK, "IScriptControl_AddCode failed: 0x%08x.\n", hr); + CHECK_CALLED(SetScriptState_STARTED); + CHECK_CALLED(ParseScriptText); SysFreeString(code_str); SysFreeString(str);
@@ -2440,9 +2440,9 @@ static void test_IScriptControl_get_Modules(void) parse_flags = SCRIPTTEXT_ISVISIBLE; code_str = SysAllocString(L"code after close"); hr = IScriptModule_AddCode(mod, code_str); - todo_wine ok(hr == S_OK, "IScriptControl_AddCode failed: 0x%08x.\n", hr); - todo_wine CHECK_CALLED(SetScriptState_STARTED); - todo_wine CHECK_CALLED(ParseScriptText); + ok(hr == S_OK, "IScriptControl_AddCode failed: 0x%08x.\n", hr); + CHECK_CALLED(SetScriptState_STARTED); + CHECK_CALLED(ParseScriptText); SysFreeString(code_str); SysFreeString(str);