jscript: Add GetSourcePosition implementation.

Signed-off-by: Jacek Caban <jacek@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Jacek Caban 2020-02-03 14:48:07 +01:00 committed by Alexandre Julliard
parent ed3e5404dd
commit 348eef2e02
2 changed files with 21 additions and 7 deletions

View File

@ -178,15 +178,32 @@ static HRESULT WINAPI JScriptError_GetExceptionInfo(IActiveScriptError *iface, E
static HRESULT WINAPI JScriptError_GetSourcePosition(IActiveScriptError *iface, DWORD *source_context, ULONG *line, LONG *character)
{
JScriptError *This = impl_from_IActiveScriptError(iface);
bytecode_t *code = This->ei.code;
const WCHAR *nl, *p;
unsigned l;
FIXME("(%p)->(%p %p %p)\n", This, source_context, line, character);
TRACE("(%p)->(%p %p %p)\n", This, source_context, line, character);
if(!This->ei.code) {
FIXME("unknown position\n");
return E_FAIL;
}
if(source_context)
*source_context = 0;
*source_context = This->ei.code->source_context;
if(!line && !character)
return S_OK;
l = code->start_line;
for(nl = p = code->source; p < code->source + This->ei.loc; p++) {
if(*p != '\n') continue;
l++;
nl = p + 1;
}
if(line)
*line = 0;
*line = l;
if(character)
*character = 0;
*character = code->source + This->ei.loc - nl;
return S_OK;
}

View File

@ -2285,19 +2285,16 @@ static void test_error_reports(void)
source_context = 0xdeadbeef;
hres = IActiveScriptError_GetSourcePosition(script_error, &source_context, NULL, NULL);
ok(hres == S_OK, "GetSourcePosition failed0x%08x\n", hres);
todo_wine
ok(source_context == 10, "source_context = %x\n", source_context);
line_number = 0xdeadbeef;
hres = IActiveScriptError_GetSourcePosition(script_error, NULL, &line_number, NULL);
ok(hres == S_OK, "GetSourcePosition failed%08x\n", hres);
todo_wine_if(tests[i].line)
ok(line_number == tests[i].line, "[%u] line = %u expected %u\n", i, line_number, tests[i].line);
character = 0xdeadbeef;
hres = IActiveScriptError_GetSourcePosition(script_error, NULL, NULL, &character);
ok(hres == S_OK, "GetSourcePosition failed: %08x\n", hres);
todo_wine_if(tests[i].character)
ok(character == tests[i].character, "[%u] character = %u expected %u\n", i, character, tests[i].character);
hres = IActiveScriptError_GetSourceLineText(script_error, NULL);