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

jscript: Implement persistent named items.

parent 70d8c011
...@@ -414,6 +414,15 @@ static void release_persistent_script_objs(JScript *This) ...@@ -414,6 +414,15 @@ static void release_persistent_script_objs(JScript *This)
release_named_item_script_obj(iter->named_item); release_named_item_script_obj(iter->named_item);
} }
static void release_named_item_list(JScript *This)
{
while(!list_empty(&This->ctx->named_items)) {
named_item_t *iter = LIST_ENTRY(list_head(&This->ctx->named_items), named_item_t, entry);
list_remove(&iter->entry);
release_named_item(iter);
}
}
static void exec_queued_code(JScript *This) static void exec_queued_code(JScript *This)
{ {
bytecode_t *iter; bytecode_t *iter;
...@@ -433,6 +442,8 @@ static void exec_queued_code(JScript *This) ...@@ -433,6 +442,8 @@ static void exec_queued_code(JScript *This)
static void decrease_state(JScript *This, SCRIPTSTATE state) static void decrease_state(JScript *This, SCRIPTSTATE state)
{ {
named_item_t *item, *item_next;
if(This->ctx) { if(This->ctx) {
switch(This->ctx->state) { switch(This->ctx->state) {
case SCRIPTSTATE_CONNECTED: case SCRIPTSTATE_CONNECTED:
...@@ -453,14 +464,19 @@ static void decrease_state(JScript *This, SCRIPTSTATE state) ...@@ -453,14 +464,19 @@ static void decrease_state(JScript *This, SCRIPTSTATE state)
clear_script_queue(This); clear_script_queue(This);
release_persistent_script_objs(This); release_persistent_script_objs(This);
while(!list_empty(&This->ctx->named_items)) { LIST_FOR_EACH_ENTRY_SAFE(item, item_next, &This->ctx->named_items, named_item_t, entry)
named_item_t *iter = LIST_ENTRY(list_head(&This->ctx->named_items), named_item_t, entry); {
if(item->disp)
list_remove(&iter->entry); {
if(iter->disp) IDispatch_Release(item->disp);
IDispatch_Release(iter->disp); item->disp = NULL;
release_named_item_script_obj(iter); }
release_named_item(iter); release_named_item_script_obj(item);
if(!(item->flags & SCRIPTITEM_ISPERSISTENT))
{
list_remove(&item->entry);
release_named_item(item);
}
} }
if(This->ctx->secmgr) { if(This->ctx->secmgr) {
...@@ -688,6 +704,7 @@ static HRESULT WINAPI JScript_SetScriptSite(IActiveScript *iface, ...@@ -688,6 +704,7 @@ static HRESULT WINAPI JScript_SetScriptSite(IActiveScript *iface,
IActiveScriptSite *pass) IActiveScriptSite *pass)
{ {
JScript *This = impl_from_IActiveScript(iface); JScript *This = impl_from_IActiveScript(iface);
named_item_t *item;
LCID lcid; LCID lcid;
HRESULT hres; HRESULT hres;
...@@ -732,6 +749,16 @@ static HRESULT WINAPI JScript_SetScriptSite(IActiveScript *iface, ...@@ -732,6 +749,16 @@ static HRESULT WINAPI JScript_SetScriptSite(IActiveScript *iface,
} }
} }
/* Retrieve new dispatches for persistent named items */
LIST_FOR_EACH_ENTRY(item, &This->ctx->named_items, named_item_t, entry)
{
if(!item->disp)
{
hres = retrieve_named_item_disp(pass, item);
if(FAILED(hres)) return hres;
}
}
This->site = pass; This->site = pass;
IActiveScriptSite_AddRef(This->site); IActiveScriptSite_AddRef(This->site);
...@@ -829,6 +856,7 @@ static HRESULT WINAPI JScript_Close(IActiveScript *iface) ...@@ -829,6 +856,7 @@ static HRESULT WINAPI JScript_Close(IActiveScript *iface)
decrease_state(This, SCRIPTSTATE_CLOSED); decrease_state(This, SCRIPTSTATE_CLOSED);
clear_persistent_code_list(This); clear_persistent_code_list(This);
release_named_item_list(This);
return S_OK; return S_OK;
} }
......
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