Commit aa5b68ac authored by Jacek Caban's avatar Jacek Caban Committed by Alexandre Julliard

vbscript: Split named item lookup into a helper function.

parent f94d0e7b
......@@ -99,6 +99,7 @@ static HRESULT lookup_identifier(exec_ctx_t *ctx, BSTR name, vbdisp_invoke_type_
{
named_item_t *item;
function_t *func;
IDispatch *disp;
unsigned i;
DISPID id;
HRESULT hres;
......@@ -178,30 +179,12 @@ static HRESULT lookup_identifier(exec_ctx_t *ctx, BSTR name, vbdisp_invoke_type_
return S_OK;
}
LIST_FOR_EACH_ENTRY(item, &ctx->script->named_items, named_item_t, entry) {
if((item->flags & SCRIPTITEM_ISVISIBLE) && !strcmpiW(item->name, name)) {
if(!item->disp) {
IUnknown *unk;
hres = IActiveScriptSite_GetItemInfo(ctx->script->site, item->name, SCRIPTINFO_IUNKNOWN, &unk, NULL);
if(FAILED(hres)) {
WARN("GetItemInfo failed: %08x\n", hres);
continue;
}
hres = IUnknown_QueryInterface(unk, &IID_IDispatch, (void**)&item->disp);
IUnknown_Release(unk);
if(FAILED(hres)) {
WARN("object does not implement IDispatch\n");
continue;
}
}
disp = lookup_named_item(ctx->script, name, SCRIPTITEM_ISVISIBLE);
if(disp) {
ref->type = REF_OBJ;
ref->u.obj = item->disp;
ref->u.obj = disp;
return S_OK;
}
}
LIST_FOR_EACH_ENTRY(item, &ctx->script->named_items, named_item_t, entry) {
if((item->flags & SCRIPTITEM_GLOBALMEMBERS)) {
......
......@@ -96,6 +96,38 @@ static void exec_queued_code(script_ctx_t *ctx)
}
}
IDispatch *lookup_named_item(script_ctx_t *ctx, const WCHAR *name, unsigned flags)
{
named_item_t *item;
HRESULT hres;
LIST_FOR_EACH_ENTRY(item, &ctx->named_items, named_item_t, entry) {
if((item->flags & flags) == flags && !strcmpiW(item->name, name)) {
if(!item->disp) {
IUnknown *unk;
hres = IActiveScriptSite_GetItemInfo(ctx->site, item->name,
SCRIPTINFO_IUNKNOWN, &unk, NULL);
if(FAILED(hres)) {
WARN("GetItemInfo failed: %08x\n", hres);
continue;
}
hres = IUnknown_QueryInterface(unk, &IID_IDispatch, (void**)&item->disp);
IUnknown_Release(unk);
if(FAILED(hres)) {
WARN("object does not implement IDispatch\n");
continue;
}
}
return item->disp;
}
}
return NULL;
}
static HRESULT set_ctx_site(VBScript *This)
{
HRESULT hres;
......
......@@ -355,6 +355,7 @@ void release_vbscode(vbscode_t*) DECLSPEC_HIDDEN;
HRESULT compile_script(script_ctx_t*,const WCHAR*,const WCHAR*,vbscode_t**) DECLSPEC_HIDDEN;
HRESULT exec_script(script_ctx_t*,function_t*,vbdisp_t*,DISPPARAMS*,VARIANT*) DECLSPEC_HIDDEN;
void release_dynamic_vars(dynamic_var_t*) DECLSPEC_HIDDEN;
IDispatch *lookup_named_item(script_ctx_t*,const WCHAR*,unsigned) DECLSPEC_HIDDEN;
typedef struct {
UINT16 len;
......
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