mirror of
git://source.winehq.org/git/wine.git
synced 2024-07-21 12:14:10 +00:00
jscript: Lookup the named item using a helper function.
Signed-off-by: Gabriel Ivăncescu <gabrielopcode@gmail.com> Signed-off-by: Jacek Caban <jacek@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
f6a4dda977
commit
0242ae52e6
|
@ -662,34 +662,12 @@ static HRESULT identifier_eval(script_ctx_t *ctx, BSTR identifier, exprval_t *re
|
|||
return S_OK;
|
||||
}
|
||||
|
||||
for(item = ctx->named_items; item; item = item->next) {
|
||||
if((item->flags & SCRIPTITEM_ISVISIBLE) && !wcscmp(item->name, identifier)) {
|
||||
if(!item->disp) {
|
||||
IUnknown *unk;
|
||||
|
||||
if(!ctx->site)
|
||||
break;
|
||||
|
||||
hres = IActiveScriptSite_GetItemInfo(ctx->site, identifier,
|
||||
SCRIPTINFO_IUNKNOWN, &unk, NULL);
|
||||
if(FAILED(hres)) {
|
||||
WARN("GetItemInfo failed: %08x\n", hres);
|
||||
break;
|
||||
}
|
||||
|
||||
hres = IUnknown_QueryInterface(unk, &IID_IDispatch, (void**)&item->disp);
|
||||
IUnknown_Release(unk);
|
||||
if(FAILED(hres)) {
|
||||
WARN("object does not implement IDispatch\n");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
IDispatch_AddRef(item->disp);
|
||||
ret->type = EXPRVAL_JSVAL;
|
||||
ret->u.val = jsval_disp(item->disp);
|
||||
return S_OK;
|
||||
}
|
||||
item = lookup_named_item(ctx, identifier, SCRIPTITEM_ISVISIBLE);
|
||||
if(item) {
|
||||
IDispatch_AddRef(item->disp);
|
||||
ret->type = EXPRVAL_JSVAL;
|
||||
ret->u.val = jsval_disp(item->disp);
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
if(lookup_global_members(ctx, identifier, ret))
|
||||
|
|
|
@ -108,6 +108,41 @@ static inline BOOL is_started(script_ctx_t *ctx)
|
|||
|| ctx->state == SCRIPTSTATE_DISCONNECTED;
|
||||
}
|
||||
|
||||
named_item_t *lookup_named_item(script_ctx_t *ctx, const WCHAR *item_name, unsigned flags)
|
||||
{
|
||||
named_item_t *item;
|
||||
HRESULT hr;
|
||||
|
||||
for(item = ctx->named_items; item; item = item->next) {
|
||||
if((item->flags & flags) == flags && !wcscmp(item->name, item_name)) {
|
||||
if(!item->disp) {
|
||||
IUnknown *unk;
|
||||
|
||||
if(!ctx->site)
|
||||
return NULL;
|
||||
|
||||
hr = IActiveScriptSite_GetItemInfo(ctx->site, item_name,
|
||||
SCRIPTINFO_IUNKNOWN, &unk, NULL);
|
||||
if(FAILED(hr)) {
|
||||
WARN("GetItemInfo failed: %08x\n", hr);
|
||||
continue;
|
||||
}
|
||||
|
||||
hr = IUnknown_QueryInterface(unk, &IID_IDispatch, (void**)&item->disp);
|
||||
IUnknown_Release(unk);
|
||||
if(FAILED(hr)) {
|
||||
WARN("object does not implement IDispatch\n");
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
return item;
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static inline JScriptError *impl_from_IActiveScriptError(IActiveScriptError *iface)
|
||||
{
|
||||
return CONTAINING_RECORD(iface, JScriptError, IActiveScriptError_iface);
|
||||
|
|
|
@ -212,6 +212,8 @@ typedef struct named_item_t {
|
|||
struct named_item_t *next;
|
||||
} named_item_t;
|
||||
|
||||
named_item_t *lookup_named_item(script_ctx_t*,const WCHAR*,unsigned) DECLSPEC_HIDDEN;
|
||||
|
||||
typedef struct {
|
||||
const WCHAR *name;
|
||||
builtin_invoke_t invoke;
|
||||
|
|
Loading…
Reference in a new issue