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

jscript: Retrieve the item's dispatch in a helper function.

parent 8fac69ba
......@@ -129,36 +129,45 @@ static void release_named_item_script_obj(named_item_t *item)
item->script_obj = NULL;
}
named_item_t *lookup_named_item(script_ctx_t *ctx, const WCHAR *item_name, unsigned flags)
static HRESULT retrieve_named_item_disp(IActiveScriptSite *site, named_item_t *item)
{
named_item_t *item;
HRESULT hr;
LIST_FOR_EACH_ENTRY(item, &ctx->named_items, named_item_t, entry) {
if((item->flags & flags) == flags && !wcscmp(item->name, item_name)) {
if(!item->script_obj && !(item->flags & SCRIPTITEM_GLOBALMEMBERS)) {
hr = create_named_item_script_obj(ctx, item);
if(FAILED(hr)) return NULL;
}
if(!item->disp && (flags || !(item->flags & SCRIPTITEM_CODEONLY))) {
IUnknown *unk;
HRESULT hr;
if(!ctx->site)
return NULL;
if(!site)
return E_UNEXPECTED;
hr = IActiveScriptSite_GetItemInfo(ctx->site, item_name,
SCRIPTINFO_IUNKNOWN, &unk, NULL);
hr = IActiveScriptSite_GetItemInfo(site, item->name, SCRIPTINFO_IUNKNOWN, &unk, NULL);
if(FAILED(hr)) {
WARN("GetItemInfo failed: %08x\n", hr);
continue;
return hr;
}
hr = IUnknown_QueryInterface(unk, &IID_IDispatch, (void**)&item->disp);
IUnknown_Release(unk);
if(FAILED(hr)) {
WARN("object does not implement IDispatch\n");
continue;
return hr;
}
return S_OK;
}
named_item_t *lookup_named_item(script_ctx_t *ctx, const WCHAR *item_name, unsigned flags)
{
named_item_t *item;
HRESULT hr;
LIST_FOR_EACH_ENTRY(item, &ctx->named_items, named_item_t, entry) {
if((item->flags & flags) == flags && !wcscmp(item->name, item_name)) {
if(!item->script_obj && !(item->flags & SCRIPTITEM_GLOBALMEMBERS)) {
hr = create_named_item_script_obj(ctx, item);
if(FAILED(hr)) return NULL;
}
if(!item->disp && (flags || !(item->flags & SCRIPTITEM_CODEONLY))) {
hr = retrieve_named_item_disp(ctx->site, item);
if(FAILED(hr)) continue;
}
return item;
......
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