Commit e285c6e9 authored by Gabriel Ivăncescu's avatar Gabriel Ivăncescu Committed by Alexandre Julliard

msscript.ocx: Implement parse_script_text on top of modules.

parent e61a2a2f
......@@ -291,15 +291,15 @@ static HRESULT add_script_object(ScriptHost *host, BSTR name, IDispatch *object,
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;
HRESULT hr;
hr = start_script(host);
hr = start_script(module->host);
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);
/* FIXME: more error handling */
return hr;
......@@ -783,27 +783,39 @@ 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->host)
return E_FAIL;
return parse_script_text(This, 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->host)
return E_FAIL;
return parse_script_text(This, 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));
if (!This->host)
return E_FAIL;
return E_NOTIMPL;
return parse_script_text(This, statement, 0, NULL);
}
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)
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)
......@@ -1593,7 +1605,7 @@ static HRESULT WINAPI ScriptControl_Eval(IScriptControl *iface, BSTR expression,
if (!This->host)
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)
......@@ -1605,7 +1617,7 @@ static HRESULT WINAPI ScriptControl_ExecuteStatement(IScriptControl *iface, BSTR
if (!This->host)
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)
......
......@@ -2398,7 +2398,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);
......@@ -2424,15 +2424,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);
......@@ -2457,11 +2457,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);
......@@ -2568,9 +2568,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);
......@@ -2631,9 +2631,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);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment