static void exec_queued_code(JScript *This) { bytecode_t *iter; for(iter = This->queue_head; iter; iter = iter->next) exec_global_code(This, iter); clear_script_queue(This); }
static void decrease_state(JScript *This, SCRIPTSTATE state) { if(This->ctx) { switch(This->ctx->state) { case SCRIPTSTATE_CONNECTED: change_state(This, SCRIPTSTATE_DISCONNECTED); if(state == SCRIPTSTATE_DISCONNECTED) return; /* FALLTHROUGH */ case SCRIPTSTATE_STARTED: case SCRIPTSTATE_DISCONNECTED: clear_script_queue(This); if(This->ctx->state == SCRIPTSTATE_DISCONNECTED) change_state(This, SCRIPTSTATE_INITIALIZED); if(state == SCRIPTSTATE_INITIALIZED) return; /* FALLTHROUGH */ case SCRIPTSTATE_INITIALIZED: if(This->ctx->host_global) { IDispatch_Release(This->ctx->host_global); This->ctx->host_global = NULL; } if(This->ctx->named_items) { named_item_t *iter, *iter2; iter = This->ctx->named_items; while(iter) { iter2 = iter->next; if(iter->disp) IDispatch_Release(iter->disp); heap_free(iter->name); heap_free(iter); iter = iter2; } This->ctx->named_items = NULL; } if(This->ctx->secmgr) { IInternetHostSecurityManager_Release(This->ctx->secmgr); This->ctx->secmgr = NULL; } if(This->ctx->site) { IActiveScriptSite_Release(This->ctx->site); This->ctx->site = NULL; } if(This->ctx->global) { jsdisp_release(This->ctx->global); This->ctx->global = NULL; } /* FALLTHROUGH */ case SCRIPTSTATE_UNINITIALIZED: change_state(This, state); break; default: assert(0); } change_state(This, state); }else if(state == SCRIPTSTATE_UNINITIALIZED) { if(This->site) IActiveScriptSite_OnStateChange(This->site, state); }else { FIXME("NULL ctx\n"); } if(state == SCRIPTSTATE_UNINITIALIZED) This->thread_id = 0; if(This->site) { IActiveScriptSite_Release(This->site); This->site = NULL; } }
static HRESULT WINAPI JScript_Close(IActiveScript *iface) { JScript *This = ACTSCRIPT_THIS(iface); TRACE("(%p)->()\n", This); if(This->thread_id != GetCurrentThreadId()) return E_UNEXPECTED; if(This->ctx) { if(This->ctx->state == SCRIPTSTATE_CONNECTED) change_state(This, SCRIPTSTATE_DISCONNECTED); clear_script_queue(This); if(This->ctx->state == SCRIPTSTATE_DISCONNECTED) change_state(This, SCRIPTSTATE_INITIALIZED); if(This->ctx->host_global) { IDispatch_Release(This->ctx->host_global); This->ctx->host_global = NULL; } if(This->ctx->named_items) { named_item_t *iter, *iter2; iter = This->ctx->named_items; while(iter) { iter2 = iter->next; if(iter->disp) IDispatch_Release(iter->disp); heap_free(iter->name); heap_free(iter); iter = iter2; } This->ctx->named_items = NULL; } if(This->ctx->secmgr) { IInternetHostSecurityManager_Release(This->ctx->secmgr); This->ctx->secmgr = NULL; } if(This->ctx->site) { IActiveScriptSite_Release(This->ctx->site); This->ctx->site = NULL; } if (This->site) change_state(This, SCRIPTSTATE_CLOSED); if(This->ctx->global) { jsdisp_release(This->ctx->global); This->ctx->global = NULL; } } if(This->site) { IActiveScriptSite_Release(This->site); This->site = NULL; } return S_OK; }