Gabriel Ivăncescu : jscript: Implement script persistence.
Alexandre Julliard
julliard at winehq.org
Thu Nov 7 16:16:04 CST 2019
Module: wine
Branch: master
Commit: a42666f5905834e0ece351f1845b9ef0f3d34983
URL: https://source.winehq.org/git/wine.git/?a=commit;h=a42666f5905834e0ece351f1845b9ef0f3d34983
Author: Gabriel Ivăncescu <gabrielopcode at gmail.com>
Date: Thu Nov 7 18:17:13 2019 +0100
jscript: Implement script persistence.
Persistent code has to be re-executed if the script is uninitialized and
then reinitialized and restarted.
Signed-off-by: Gabriel Ivăncescu <gabrielopcode at gmail.com>
Signed-off-by: Jacek Caban <jacek at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
dlls/jscript/engine.h | 1 +
dlls/jscript/jscript.c | 27 ++++++++++++++++++++++++++-
2 files changed, 27 insertions(+), 1 deletion(-)
diff --git a/dlls/jscript/engine.h b/dlls/jscript/engine.h
index 1d76cf8f2f..955c315ff9 100644
--- a/dlls/jscript/engine.h
+++ b/dlls/jscript/engine.h
@@ -169,6 +169,7 @@ local_ref_t *lookup_local(const function_code_t*,const WCHAR*) DECLSPEC_HIDDEN;
typedef struct _bytecode_t {
LONG ref;
+ BOOL is_persistent;
instr_t *instrs;
heap_pool_t heap;
diff --git a/dlls/jscript/jscript.c b/dlls/jscript/jscript.c
index 9a03f36b26..60711fce10 100644
--- a/dlls/jscript/jscript.c
+++ b/dlls/jscript/jscript.c
@@ -60,6 +60,7 @@ typedef struct {
IActiveScriptSite *site;
+ struct list persistent_code;
struct list queued_code;
} JScript;
@@ -120,6 +121,19 @@ static void clear_script_queue(JScript *This)
{
bytecode_t *iter = LIST_ENTRY(list_head(&This->queued_code), bytecode_t, entry);
list_remove(&iter->entry);
+ if (iter->is_persistent)
+ list_add_tail(&This->persistent_code, &iter->entry);
+ else
+ release_bytecode(iter);
+ }
+}
+
+static void clear_persistent_code_list(JScript *This)
+{
+ while(!list_empty(&This->queued_code))
+ {
+ bytecode_t *iter = LIST_ENTRY(list_head(&This->persistent_code), bytecode_t, entry);
+ list_remove(&iter->entry);
release_bytecode(iter);
}
}
@@ -209,6 +223,7 @@ static void decrease_state(JScript *This, SCRIPTSTATE state)
/* FALLTHROUGH */
case SCRIPTSTATE_UNINITIALIZED:
change_state(This, state);
+ clear_script_queue(This);
break;
default:
assert(0);
@@ -463,6 +478,7 @@ static HRESULT WINAPI JScript_SetScriptState(IActiveScript *iface, SCRIPTSTATE s
return E_UNEXPECTED;
decrease_state(This, SCRIPTSTATE_UNINITIALIZED);
+ list_move_tail(&This->queued_code, &This->persistent_code);
return S_OK;
}
@@ -515,6 +531,7 @@ static HRESULT WINAPI JScript_Close(IActiveScript *iface)
return E_UNEXPECTED;
decrease_state(This, SCRIPTSTATE_CLOSED);
+ clear_persistent_code_list(This);
return S_OK;
}
@@ -779,6 +796,8 @@ static HRESULT WINAPI JScriptParse_ParseScriptText(IActiveScriptParse *iface,
return hres;
}
+ code->is_persistent = (dwFlags & SCRIPTTEXT_ISPERSISTENT) != 0;
+
/*
* Although pvarResult is not really used without SCRIPTTEXT_ISEXPRESSION flag, if it's not NULL,
* script is executed immediately, even if it's not in started state yet.
@@ -789,7 +808,12 @@ static HRESULT WINAPI JScriptParse_ParseScriptText(IActiveScriptParse *iface,
}
hres = exec_global_code(This, code);
- release_bytecode(code);
+
+ if(code->is_persistent)
+ list_add_tail(&This->persistent_code, &code->entry);
+ else
+ release_bytecode(code);
+
if(FAILED(hres))
return hres;
@@ -1077,6 +1101,7 @@ HRESULT create_jscript_object(BOOL is_encode, REFIID riid, void **ppv)
ret->ref = 1;
ret->safeopt = INTERFACE_USES_DISPEX;
ret->is_encode = is_encode;
+ list_init(&ret->persistent_code);
list_init(&ret->queued_code);
hres = IActiveScript_QueryInterface(&ret->IActiveScript_iface, riid, ppv);
More information about the wine-cvs
mailing list