[PATCH v3 3/9] vbscript: Implement script persistence.
Gabriel Ivăncescu
gabrielopcode at gmail.com
Fri Nov 1 10:05:04 CDT 2019
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>
---
v3: Turns out it's slightly more complicated than I initially expected,
to handle all corner cases. This patch uses a flag as suggested, to keep
the ordering proper, since it is required. However, a separate list will
also be needed later to tie its lifetime to the script dispatch object.
I wasn't sure if I should have made all the BOOLs in vbscode_t struct bit
fields with this patch (like it is done in the winex11.drv for example)
since we have 3 BOOLs already, so I didn't.
dlls/vbscript/compile.c | 6 +++++-
dlls/vbscript/vbscript.c | 12 ++++++++++++
dlls/vbscript/vbscript.h | 3 +++
3 files changed, 20 insertions(+), 1 deletion(-)
diff --git a/dlls/vbscript/compile.c b/dlls/vbscript/compile.c
index f7bceeb..42aaf92 100644
--- a/dlls/vbscript/compile.c
+++ b/dlls/vbscript/compile.c
@@ -1984,6 +1984,7 @@ HRESULT compile_script(script_ctx_t *script, const WCHAR *src, const WCHAR *deli
class->next = script->classes;
script->classes = ctx.classes;
+ code->last_class = class;
}
if(TRACE_ON(vbscript_disas))
@@ -1992,6 +1993,9 @@ HRESULT compile_script(script_ctx_t *script, const WCHAR *src, const WCHAR *deli
ctx.code = NULL;
release_compiler(&ctx);
+ if(flags & SCRIPTTEXT_ISPERSISTENT)
+ code->is_persistent = TRUE;
+
list_add_tail(&script->code_list, &code->entry);
*ret = code;
return S_OK;
@@ -2003,7 +2007,7 @@ HRESULT compile_procedure(script_ctx_t *script, const WCHAR *src, const WCHAR *d
vbscode_t *code;
HRESULT hres;
- hres = compile_script(script, src, delimiter, flags, &code);
+ hres = compile_script(script, src, delimiter, flags & ~SCRIPTTEXT_ISPERSISTENT, &code);
if(FAILED(hres))
return hres;
diff --git a/dlls/vbscript/vbscript.c b/dlls/vbscript/vbscript.c
index 3174151..2ffd6fd 100644
--- a/dlls/vbscript/vbscript.c
+++ b/dlls/vbscript/vbscript.c
@@ -130,6 +130,7 @@ IDispatch *lookup_named_item(script_ctx_t *ctx, const WCHAR *name, unsigned flag
static void release_script(script_ctx_t *ctx)
{
+ vbscode_t *code, *code_next;
class_desc_t *class_desc;
UINT i;
@@ -146,6 +147,17 @@ static void release_script(script_ctx_t *ctx)
ctx->global_vars_num = 0;
ctx->global_funcs_num = 0;
+ LIST_FOR_EACH_ENTRY_SAFE(code, code_next, &ctx->code_list, vbscode_t, entry)
+ {
+ if(code->is_persistent)
+ {
+ code->pending_exec = TRUE;
+ if(code->last_class) code->last_class->next = NULL;
+ }
+ else
+ release_vbscode(code);
+ }
+
while(!list_empty(&ctx->named_items)) {
named_item_t *iter = LIST_ENTRY(list_head(&ctx->named_items), named_item_t, entry);
diff --git a/dlls/vbscript/vbscript.h b/dlls/vbscript/vbscript.h
index 38fb874..74fef1a 100644
--- a/dlls/vbscript/vbscript.h
+++ b/dlls/vbscript/vbscript.h
@@ -341,6 +341,7 @@ struct _vbscode_t {
BOOL option_explicit;
BOOL pending_exec;
+ BOOL is_persistent;
function_t main_code;
IDispatch *context;
@@ -349,6 +350,8 @@ struct _vbscode_t {
unsigned bstr_cnt;
heap_pool_t heap;
+ class_desc_t *last_class;
+
struct list entry;
};
--
2.21.0
More information about the wine-devel
mailing list