Jacek Caban : jscript: Add GetSourcePosition implementation.

Alexandre Julliard julliard at winehq.org
Mon Feb 3 15:06:07 CST 2020


Module: wine
Branch: master
Commit: 348eef2e02eb3d9fcbbf6a0eb2aa473c816c08c9
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=348eef2e02eb3d9fcbbf6a0eb2aa473c816c08c9

Author: Jacek Caban <jacek at codeweavers.com>
Date:   Mon Feb  3 14:48:07 2020 +0100

jscript: Add GetSourcePosition implementation.

Signed-off-by: Jacek Caban <jacek at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/jscript/jscript.c   | 25 +++++++++++++++++++++----
 dlls/jscript/tests/run.c |  3 ---
 2 files changed, 21 insertions(+), 7 deletions(-)

diff --git a/dlls/jscript/jscript.c b/dlls/jscript/jscript.c
index 8f79ea4bd4..860fb01cf5 100644
--- a/dlls/jscript/jscript.c
+++ b/dlls/jscript/jscript.c
@@ -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;
 }
 
diff --git a/dlls/jscript/tests/run.c b/dlls/jscript/tests/run.c
index 1d11e00f44..6e2250882d 100644
--- a/dlls/jscript/tests/run.c
+++ b/dlls/jscript/tests/run.c
@@ -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);




More information about the wine-cvs mailing list