msscript.ocx: Implement parse_script_text on top of modules.
Signed-off-by: Gabriel Ivăncescu <gabrielopcode@gmail.com> Signed-off-by: Jacek Caban <jacek@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
e61a2a2fc0
commit
e285c6e929
|
@ -291,15 +291,15 @@ static HRESULT add_script_object(ScriptHost *host, BSTR name, IDispatch *object,
|
||||||
return hr;
|
return hr;
|
||||||
}
|
}
|
||||||
|
|
||||||
static HRESULT parse_script_text(ScriptHost *host, BSTR script_text, DWORD flag, VARIANT *res)
|
static HRESULT parse_script_text(ScriptModule *module, BSTR script_text, DWORD flag, VARIANT *res)
|
||||||
{
|
{
|
||||||
EXCEPINFO excepinfo;
|
EXCEPINFO excepinfo;
|
||||||
HRESULT hr;
|
HRESULT hr;
|
||||||
|
|
||||||
hr = start_script(host);
|
hr = start_script(module->host);
|
||||||
if (FAILED(hr)) return hr;
|
if (FAILED(hr)) return hr;
|
||||||
|
|
||||||
hr = IActiveScriptParse_ParseScriptText(host->parse, script_text, NULL,
|
hr = IActiveScriptParse_ParseScriptText(module->host->parse, script_text, module->name,
|
||||||
NULL, NULL, 0, 1, flag, res, &excepinfo);
|
NULL, NULL, 0, 1, flag, res, &excepinfo);
|
||||||
/* FIXME: more error handling */
|
/* FIXME: more error handling */
|
||||||
return hr;
|
return hr;
|
||||||
|
@ -783,27 +783,39 @@ static HRESULT WINAPI ScriptModule_AddCode(IScriptModule *iface, BSTR code)
|
||||||
{
|
{
|
||||||
ScriptModule *This = impl_from_IScriptModule(iface);
|
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->host)
|
||||||
|
return E_FAIL;
|
||||||
|
|
||||||
|
return parse_script_text(This, code, SCRIPTTEXT_ISVISIBLE, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
static HRESULT WINAPI ScriptModule_Eval(IScriptModule *iface, BSTR expression, VARIANT *res)
|
static HRESULT WINAPI ScriptModule_Eval(IScriptModule *iface, BSTR expression, VARIANT *res)
|
||||||
{
|
{
|
||||||
ScriptModule *This = impl_from_IScriptModule(iface);
|
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->host)
|
||||||
|
return E_FAIL;
|
||||||
|
|
||||||
|
return parse_script_text(This, expression, SCRIPTTEXT_ISEXPRESSION, res);
|
||||||
}
|
}
|
||||||
|
|
||||||
static HRESULT WINAPI ScriptModule_ExecuteStatement(IScriptModule *iface, BSTR statement)
|
static HRESULT WINAPI ScriptModule_ExecuteStatement(IScriptModule *iface, BSTR statement)
|
||||||
{
|
{
|
||||||
ScriptModule *This = impl_from_IScriptModule(iface);
|
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->host)
|
||||||
|
return E_FAIL;
|
||||||
|
|
||||||
|
return parse_script_text(This, statement, 0, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
static HRESULT WINAPI ScriptModule_Run(IScriptModule *iface, BSTR procedure_name, SAFEARRAY **parameters, VARIANT *res)
|
static HRESULT WINAPI ScriptModule_Run(IScriptModule *iface, BSTR procedure_name, SAFEARRAY **parameters, VARIANT *res)
|
||||||
|
@ -1578,7 +1590,7 @@ static HRESULT WINAPI ScriptControl_AddCode(IScriptControl *iface, BSTR code)
|
||||||
if (!This->host)
|
if (!This->host)
|
||||||
return E_FAIL;
|
return E_FAIL;
|
||||||
|
|
||||||
return parse_script_text(This->host, code, SCRIPTTEXT_ISVISIBLE, NULL);
|
return parse_script_text(This->modules[0], code, SCRIPTTEXT_ISVISIBLE, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
static HRESULT WINAPI ScriptControl_Eval(IScriptControl *iface, BSTR expression, VARIANT *res)
|
static HRESULT WINAPI ScriptControl_Eval(IScriptControl *iface, BSTR expression, VARIANT *res)
|
||||||
|
@ -1593,7 +1605,7 @@ static HRESULT WINAPI ScriptControl_Eval(IScriptControl *iface, BSTR expression,
|
||||||
if (!This->host)
|
if (!This->host)
|
||||||
return E_FAIL;
|
return E_FAIL;
|
||||||
|
|
||||||
return parse_script_text(This->host, expression, SCRIPTTEXT_ISEXPRESSION, res);
|
return parse_script_text(This->modules[0], expression, SCRIPTTEXT_ISEXPRESSION, res);
|
||||||
}
|
}
|
||||||
|
|
||||||
static HRESULT WINAPI ScriptControl_ExecuteStatement(IScriptControl *iface, BSTR statement)
|
static HRESULT WINAPI ScriptControl_ExecuteStatement(IScriptControl *iface, BSTR statement)
|
||||||
|
@ -1605,7 +1617,7 @@ static HRESULT WINAPI ScriptControl_ExecuteStatement(IScriptControl *iface, BSTR
|
||||||
if (!This->host)
|
if (!This->host)
|
||||||
return E_FAIL;
|
return E_FAIL;
|
||||||
|
|
||||||
return parse_script_text(This->host, statement, 0, NULL);
|
return parse_script_text(This->modules[0], statement, 0, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
static HRESULT WINAPI ScriptControl_Run(IScriptControl *iface, BSTR procedure_name, SAFEARRAY **parameters, VARIANT *res)
|
static HRESULT WINAPI ScriptControl_Run(IScriptControl *iface, BSTR procedure_name, SAFEARRAY **parameters, VARIANT *res)
|
||||||
|
|
|
@ -2398,7 +2398,7 @@ static void test_IScriptControl_get_Modules(void)
|
||||||
SysFreeString(str);
|
SysFreeString(str);
|
||||||
str = SysAllocString(L"function add(a, b) { return a + b; }\n");
|
str = SysAllocString(L"function add(a, b) { return a + b; }\n");
|
||||||
hr = IScriptModule_AddCode(mod, str);
|
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);
|
IScriptModule_Release(mod);
|
||||||
SysFreeString(str);
|
SysFreeString(str);
|
||||||
|
|
||||||
|
@ -2424,15 +2424,15 @@ static void test_IScriptControl_get_Modules(void)
|
||||||
SysFreeString(str);
|
SysFreeString(str);
|
||||||
str = SysAllocString(L"function sub(a, b) { return a - b; }\n");
|
str = SysAllocString(L"function sub(a, b) { return a - b; }\n");
|
||||||
hr = IScriptModule_AddCode(mod, str);
|
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);
|
IScriptModule_Release(mod);
|
||||||
SysFreeString(str);
|
SysFreeString(str);
|
||||||
|
|
||||||
/* The 'Global' module is the same as the script control */
|
/* The 'Global' module is the same as the script control */
|
||||||
str = SysAllocString(L"add(10, 5)");
|
str = SysAllocString(L"add(10, 5)");
|
||||||
hr = IScriptControl_Eval(sc, str, &var);
|
hr = IScriptControl_Eval(sc, str, &var);
|
||||||
todo_wine ok(hr == S_OK, "IScriptControl_Eval failed: 0x%08x.\n", hr);
|
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(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);
|
SysFreeString(str);
|
||||||
str = SysAllocString(L"sub(10, 5)");
|
str = SysAllocString(L"sub(10, 5)");
|
||||||
hr = IScriptControl_Eval(sc, str, &var);
|
hr = IScriptControl_Eval(sc, str, &var);
|
||||||
|
@ -2457,11 +2457,11 @@ static void test_IScriptControl_get_Modules(void)
|
||||||
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");
|
str = SysAllocString(L"function closed() { }\n");
|
||||||
hr = IScriptModule_AddCode(mod, str);
|
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);
|
SysFreeString(str);
|
||||||
str = SysAllocString(L"sub closed\nend sub");
|
str = SysAllocString(L"sub closed\nend sub");
|
||||||
hr = IScriptModule_AddCode(mod, str);
|
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);
|
IScriptModule_Release(mod);
|
||||||
SysFreeString(str);
|
SysFreeString(str);
|
||||||
|
|
||||||
|
@ -2568,9 +2568,9 @@ static void test_IScriptControl_get_Modules(void)
|
||||||
parse_flags = SCRIPTTEXT_ISVISIBLE;
|
parse_flags = SCRIPTTEXT_ISVISIBLE;
|
||||||
code_str = SysAllocString(L"some code");
|
code_str = SysAllocString(L"some code");
|
||||||
hr = IScriptModule_AddCode(mod, code_str);
|
hr = IScriptModule_AddCode(mod, code_str);
|
||||||
todo_wine ok(hr == S_OK, "IScriptControl_AddCode failed: 0x%08x.\n", hr);
|
ok(hr == S_OK, "IScriptControl_AddCode failed: 0x%08x.\n", hr);
|
||||||
todo_wine CHECK_CALLED(SetScriptState_STARTED);
|
CHECK_CALLED(SetScriptState_STARTED);
|
||||||
todo_wine CHECK_CALLED(ParseScriptText);
|
CHECK_CALLED(ParseScriptText);
|
||||||
SysFreeString(code_str);
|
SysFreeString(code_str);
|
||||||
SysFreeString(str);
|
SysFreeString(str);
|
||||||
|
|
||||||
|
@ -2631,9 +2631,9 @@ static void test_IScriptControl_get_Modules(void)
|
||||||
parse_flags = SCRIPTTEXT_ISVISIBLE;
|
parse_flags = SCRIPTTEXT_ISVISIBLE;
|
||||||
code_str = SysAllocString(L"code after close");
|
code_str = SysAllocString(L"code after close");
|
||||||
hr = IScriptModule_AddCode(mod, code_str);
|
hr = IScriptModule_AddCode(mod, code_str);
|
||||||
todo_wine ok(hr == S_OK, "IScriptControl_AddCode failed: 0x%08x.\n", hr);
|
ok(hr == S_OK, "IScriptControl_AddCode failed: 0x%08x.\n", hr);
|
||||||
todo_wine CHECK_CALLED(SetScriptState_STARTED);
|
CHECK_CALLED(SetScriptState_STARTED);
|
||||||
todo_wine CHECK_CALLED(ParseScriptText);
|
CHECK_CALLED(ParseScriptText);
|
||||||
SysFreeString(code_str);
|
SysFreeString(code_str);
|
||||||
SysFreeString(str);
|
SysFreeString(str);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue