wininet: Complicated cookie value set/get tests.
[wine/hacks.git] / dlls / mshtml / dispex.c
bloba3a9595cdad4bd17d4d10e4d497a4504e6061193
1 /*
2 * Copyright 2008 Jacek Caban for CodeWeavers
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
19 #include <stdarg.h>
21 #define COBJMACROS
23 #include "windef.h"
24 #include "winbase.h"
25 #include "winuser.h"
26 #include "ole2.h"
28 #include "wine/debug.h"
30 #include "mshtml_private.h"
32 WINE_DEFAULT_DEBUG_CHANNEL(mshtml);
34 typedef struct {
35 DISPID id;
36 BSTR name;
37 tid_t tid;
38 } func_info_t;
40 struct dispex_data_t {
41 DWORD func_cnt;
42 func_info_t *funcs;
43 func_info_t **name_table;
45 struct list entry;
48 typedef struct {
49 VARIANT var;
50 LPWSTR name;
51 } dynamic_prop_t;
53 struct dispex_dynamic_data_t {
54 DWORD buf_size;
55 DWORD prop_cnt;
56 dynamic_prop_t *props;
59 #define DISPID_DYNPROP_0 0x50000000
60 #define DISPID_DYNPROP_MAX 0x5fffffff
62 static ITypeLib *typelib;
63 static ITypeInfo *typeinfos[LAST_tid];
64 static struct list dispex_data_list = LIST_INIT(dispex_data_list);
66 static REFIID tid_ids[] = {
67 &IID_NULL,
68 &DIID_DispCEventObj,
69 &DIID_DispDOMChildrenCollection,
70 &DIID_DispHTMLBody,
71 &DIID_DispHTMLCommentElement,
72 &DIID_DispHTMLCurrentStyle,
73 &DIID_DispHTMLDocument,
74 &DIID_DispHTMLDOMTextNode,
75 &DIID_DispHTMLElementCollection,
76 &DIID_DispHTMLGenericElement,
77 &DIID_DispHTMLIFrame,
78 &DIID_DispHTMLImg,
79 &DIID_DispHTMLInputElement,
80 &DIID_DispHTMLOptionElement,
81 &DIID_DispHTMLSelectElement,
82 &DIID_DispHTMLStyle,
83 &DIID_DispHTMLTable,
84 &DIID_DispHTMLTableRow,
85 &DIID_DispHTMLUnknownElement,
86 &DIID_DispHTMLWindow2,
87 &IID_IHTMLBodyElement,
88 &IID_IHTMLBodyElement2,
89 &IID_IHTMLCommentElement,
90 &IID_IHTMLCurrentStyle,
91 &IID_IHTMLDocument2,
92 &IID_IHTMLDocument3,
93 &IID_IHTMLDocument4,
94 &IID_IHTMLDocument5,
95 &IID_IHTMLDOMChildrenCollection,
96 &IID_IHTMLDOMNode,
97 &IID_IHTMLDOMNode2,
98 &IID_IHTMLDOMTextNode,
99 &IID_IHTMLElement,
100 &IID_IHTMLElement2,
101 &IID_IHTMLElement3,
102 &IID_IHTMLElement4,
103 &IID_IHTMLElementCollection,
104 &IID_IHTMLEventObj,
105 &IID_IHTMLFrameBase2,
106 &IID_IHTMLGenericElement,
107 &IID_IHTMLImgElement,
108 &IID_IHTMLInputElement,
109 &IID_IHTMLLocation,
110 &IID_IHTMLOptionElement,
111 &IID_IHTMLSelectElement,
112 &IID_IHTMLStyle,
113 &IID_IHTMLStyle2,
114 &IID_IHTMLTable,
115 &IID_IHTMLTableRow,
116 &IID_IHTMLTextContainer,
117 &IID_IHTMLUniqueName,
118 &IID_IHTMLWindow2,
119 &IID_IHTMLWindow3,
120 &IID_IOmNavigator
123 static HRESULT get_typeinfo(tid_t tid, ITypeInfo **typeinfo)
125 HRESULT hres;
127 if(!typelib) {
128 ITypeLib *tl;
130 hres = LoadRegTypeLib(&LIBID_MSHTML, 4, 0, LOCALE_SYSTEM_DEFAULT, &tl);
131 if(FAILED(hres)) {
132 ERR("LoadRegTypeLib failed: %08x\n", hres);
133 return hres;
136 if(InterlockedCompareExchangePointer((void**)&typelib, tl, NULL))
137 ITypeLib_Release(tl);
140 if(!typeinfos[tid]) {
141 ITypeInfo *typeinfo;
143 hres = ITypeLib_GetTypeInfoOfGuid(typelib, tid_ids[tid], &typeinfo);
144 if(FAILED(hres)) {
145 ERR("GetTypeInfoOfGuid(%s) failed: %08x\n", debugstr_guid(tid_ids[tid]), hres);
146 return hres;
149 if(InterlockedCompareExchangePointer((void**)(typeinfos+tid), typeinfo, NULL))
150 ITypeInfo_Release(typeinfo);
153 *typeinfo = typeinfos[tid];
154 return S_OK;
157 void release_typelib(void)
159 dispex_data_t *iter;
160 unsigned i;
162 while(!list_empty(&dispex_data_list)) {
163 iter = LIST_ENTRY(list_head(&dispex_data_list), dispex_data_t, entry);
164 list_remove(&iter->entry);
166 for(i=0; i < iter->func_cnt; i++)
167 SysFreeString(iter->funcs[i].name);
169 heap_free(iter->funcs);
170 heap_free(iter->name_table);
171 heap_free(iter);
174 if(!typelib)
175 return;
177 for(i=0; i < sizeof(typeinfos)/sizeof(*typeinfos); i++)
178 if(typeinfos[i])
179 ITypeInfo_Release(typeinfos[i]);
181 ITypeLib_Release(typelib);
184 static void add_func_info(dispex_data_t *data, DWORD *size, tid_t tid, DISPID id, ITypeInfo *dti)
186 HRESULT hres;
188 if(data->func_cnt && data->funcs[data->func_cnt-1].id == id)
189 return;
191 if(data->func_cnt == *size)
192 data->funcs = heap_realloc(data->funcs, (*size <<= 1)*sizeof(func_info_t));
194 hres = ITypeInfo_GetDocumentation(dti, id, &data->funcs[data->func_cnt].name, NULL, NULL, NULL);
195 if(FAILED(hres))
196 return;
198 data->funcs[data->func_cnt].id = id;
199 data->funcs[data->func_cnt].tid = tid;
201 data->func_cnt++;
204 static int dispid_cmp(const void *p1, const void *p2)
206 return ((func_info_t*)p1)->id - ((func_info_t*)p2)->id;
209 static int func_name_cmp(const void *p1, const void *p2)
211 return strcmpiW((*(func_info_t**)p1)->name, (*(func_info_t**)p2)->name);
214 static dispex_data_t *preprocess_dispex_data(DispatchEx *This)
216 const tid_t *tid = This->data->iface_tids;
217 FUNCDESC *funcdesc;
218 dispex_data_t *data;
219 DWORD size = 16, i;
220 ITypeInfo *ti, *dti;
221 HRESULT hres;
223 TRACE("(%p)\n", This);
225 hres = get_typeinfo(This->data->disp_tid, &dti);
226 if(FAILED(hres)) {
227 ERR("Could not get disp type info: %08x\n", hres);
228 return NULL;
231 data = heap_alloc(sizeof(dispex_data_t));
232 data->func_cnt = 0;
233 data->funcs = heap_alloc(size*sizeof(func_info_t));
234 list_add_tail(&dispex_data_list, &data->entry);
236 while(*tid) {
237 hres = get_typeinfo(*tid, &ti);
238 if(FAILED(hres))
239 break;
241 i=7;
242 while(1) {
243 hres = ITypeInfo_GetFuncDesc(ti, i++, &funcdesc);
244 if(FAILED(hres))
245 break;
247 add_func_info(data, &size, *tid, funcdesc->memid, dti);
248 ITypeInfo_ReleaseFuncDesc(ti, funcdesc);
251 tid++;
254 if(!data->func_cnt) {
255 heap_free(data->funcs);
256 data->funcs = NULL;
257 }else if(data->func_cnt != size) {
258 data->funcs = heap_realloc(data->funcs, data->func_cnt * sizeof(func_info_t));
261 qsort(data->funcs, data->func_cnt, sizeof(func_info_t), dispid_cmp);
263 if(data->funcs) {
264 data->name_table = heap_alloc(data->func_cnt * sizeof(func_info_t*));
265 for(i=0; i < data->func_cnt; i++)
266 data->name_table[i] = data->funcs+i;
267 qsort(data->name_table, data->func_cnt, sizeof(func_info_t*), func_name_cmp);
268 }else {
269 data->name_table = NULL;
272 return data;
275 static CRITICAL_SECTION cs_dispex_static_data;
276 static CRITICAL_SECTION_DEBUG cs_dispex_static_data_dbg =
278 0, 0, &cs_dispex_static_data,
279 { &cs_dispex_static_data_dbg.ProcessLocksList, &cs_dispex_static_data_dbg.ProcessLocksList },
280 0, 0, { (DWORD_PTR)(__FILE__ ": dispex_static_data") }
282 static CRITICAL_SECTION cs_dispex_static_data = { &cs_dispex_static_data_dbg, -1, 0, 0, 0, 0 };
285 static dispex_data_t *get_dispex_data(DispatchEx *This)
287 if(This->data->data)
288 return This->data->data;
290 EnterCriticalSection(&cs_dispex_static_data);
292 if(!This->data->data)
293 This->data->data = preprocess_dispex_data(This);
295 LeaveCriticalSection(&cs_dispex_static_data);
297 return This->data->data;
300 void call_disp_func(HTMLDocument *doc, IDispatch *disp, IDispatch *this_obj)
302 DISPID named_arg = DISPID_THIS;
303 VARIANTARG arg;
304 DISPPARAMS params = {&arg, &named_arg, 1, 1};
305 EXCEPINFO ei;
306 IDispatchEx *dispex;
307 VARIANT res;
308 HRESULT hres;
310 hres = IDispatch_QueryInterface(disp, &IID_IDispatchEx, (void**)&dispex);
311 if(FAILED(hres)) {
312 FIXME("Could not get IDispatchEx interface: %08x\n", hres);
313 return;
316 V_VT(&arg) = VT_DISPATCH;
317 V_DISPATCH(&arg) = this_obj;
318 VariantInit(&res);
319 memset(&ei, 0, sizeof(ei));
321 hres = IDispatchEx_InvokeEx(dispex, 0, GetUserDefaultLCID(), DISPATCH_METHOD, &params, &res, &ei, NULL);
322 IDispatchEx_Release(dispex);
324 TRACE("%p returned %08x\n", disp, hres);
326 VariantClear(&res);
329 static inline BOOL is_custom_dispid(DISPID id)
331 return MSHTML_DISPID_CUSTOM_MIN <= id && id <= MSHTML_DISPID_CUSTOM_MAX;
334 static inline BOOL is_dynamic_dispid(DISPID id)
336 return DISPID_DYNPROP_0 <= id && id <= DISPID_DYNPROP_MAX;
339 static HRESULT get_dynamic_prop(DispatchEx *This, const WCHAR *name, BOOL alloc, dynamic_prop_t **ret)
341 dispex_dynamic_data_t *data = This->dynamic_data;
343 if(data) {
344 unsigned i;
346 for(i=0; i < data->prop_cnt; i++) {
347 if(!strcmpW(data->props[i].name, name)) {
348 *ret = data->props+i;
349 return S_OK;
354 if(alloc) {
355 TRACE("creating dynamic prop %s\n", debugstr_w(name));
357 if(!data) {
358 data = This->dynamic_data = heap_alloc_zero(sizeof(dispex_dynamic_data_t));
359 if(!data)
360 return E_OUTOFMEMORY;
363 if(!data->buf_size) {
364 data->props = heap_alloc(sizeof(dynamic_prop_t)*4);
365 if(!data->props)
366 return E_OUTOFMEMORY;
367 data->buf_size = 4;
368 }else if(data->buf_size == data->prop_cnt) {
369 dynamic_prop_t *new_props;
371 new_props = heap_realloc(data->props, sizeof(dynamic_prop_t)*(data->buf_size<<1));
372 if(!new_props)
373 return E_OUTOFMEMORY;
375 data->props = new_props;
376 data->buf_size <<= 1;
379 data->props[data->prop_cnt].name = heap_strdupW(name);
380 VariantInit(&data->props[data->prop_cnt].var);
381 *ret = data->props + data->prop_cnt++;
383 return S_OK;
386 TRACE("not found %s\n", debugstr_w(name));
387 return DISP_E_UNKNOWNNAME;
390 HRESULT dispex_get_dprop_ref(DispatchEx *This, const WCHAR *name, BOOL alloc, VARIANT **ret)
392 dynamic_prop_t *prop;
393 HRESULT hres;
395 hres = get_dynamic_prop(This, name, alloc, &prop);
396 if(FAILED(hres))
397 return hres;
399 *ret = &prop->var;
400 return S_OK;
403 #define DISPATCHEX_THIS(iface) DEFINE_THIS(DispatchEx, IDispatchEx, iface)
405 static HRESULT WINAPI DispatchEx_QueryInterface(IDispatchEx *iface, REFIID riid, void **ppv)
407 DispatchEx *This = DISPATCHEX_THIS(iface);
409 return IUnknown_QueryInterface(This->outer, riid, ppv);
412 static ULONG WINAPI DispatchEx_AddRef(IDispatchEx *iface)
414 DispatchEx *This = DISPATCHEX_THIS(iface);
416 return IUnknown_AddRef(This->outer);
419 static ULONG WINAPI DispatchEx_Release(IDispatchEx *iface)
421 DispatchEx *This = DISPATCHEX_THIS(iface);
423 return IUnknown_Release(This->outer);
426 static HRESULT WINAPI DispatchEx_GetTypeInfoCount(IDispatchEx *iface, UINT *pctinfo)
428 DispatchEx *This = DISPATCHEX_THIS(iface);
430 TRACE("(%p)->(%p)\n", This, pctinfo);
432 *pctinfo = 1;
433 return S_OK;
436 static HRESULT WINAPI DispatchEx_GetTypeInfo(IDispatchEx *iface, UINT iTInfo,
437 LCID lcid, ITypeInfo **ppTInfo)
439 DispatchEx *This = DISPATCHEX_THIS(iface);
440 HRESULT hres;
442 TRACE("(%p)->(%u %u %p)\n", This, iTInfo, lcid, ppTInfo);
444 hres = get_typeinfo(This->data->disp_tid, ppTInfo);
445 if(FAILED(hres))
446 return hres;
448 ITypeInfo_AddRef(*ppTInfo);
449 return S_OK;
452 static HRESULT WINAPI DispatchEx_GetIDsOfNames(IDispatchEx *iface, REFIID riid,
453 LPOLESTR *rgszNames, UINT cNames,
454 LCID lcid, DISPID *rgDispId)
456 DispatchEx *This = DISPATCHEX_THIS(iface);
457 UINT i;
458 HRESULT hres;
460 TRACE("(%p)->(%s %p %u %u %p)\n", This, debugstr_guid(riid), rgszNames, cNames,
461 lcid, rgDispId);
463 for(i=0; i < cNames; i++) {
464 hres = IDispatchEx_GetDispID(DISPATCHEX(This), rgszNames[i], 0, rgDispId+i);
465 if(FAILED(hres))
466 return hres;
469 return S_OK;
472 static HRESULT WINAPI DispatchEx_Invoke(IDispatchEx *iface, DISPID dispIdMember,
473 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
474 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
476 DispatchEx *This = DISPATCHEX_THIS(iface);
478 TRACE("(%p)->(%d %s %d %d %p %p %p %p)\n", This, dispIdMember, debugstr_guid(riid),
479 lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
481 return IDispatchEx_InvokeEx(DISPATCHEX(This), dispIdMember, lcid, wFlags,
482 pDispParams, pVarResult, pExcepInfo, NULL);
485 static HRESULT WINAPI DispatchEx_GetDispID(IDispatchEx *iface, BSTR bstrName, DWORD grfdex, DISPID *pid)
487 DispatchEx *This = DISPATCHEX_THIS(iface);
488 dynamic_prop_t *dprop;
489 dispex_data_t *data;
490 int min, max, n, c;
491 HRESULT hres;
493 TRACE("(%p)->(%s %x %p)\n", This, debugstr_w(bstrName), grfdex, pid);
495 if(grfdex & ~(fdexNameCaseSensitive|fdexNameEnsure|fdexNameImplicit))
496 FIXME("Unsupported grfdex %x\n", grfdex);
498 data = get_dispex_data(This);
499 if(!data)
500 return E_FAIL;
502 min = 0;
503 max = data->func_cnt-1;
505 while(min <= max) {
506 n = (min+max)/2;
508 c = strcmpiW(data->name_table[n]->name, bstrName);
509 if(!c) {
510 if((grfdex & fdexNameCaseSensitive) && strcmpW(data->name_table[n]->name, bstrName))
511 break;
513 *pid = data->name_table[n]->id;
514 return S_OK;
517 if(c > 0)
518 max = n-1;
519 else
520 min = n+1;
523 if(This->data->vtbl && This->data->vtbl->get_dispid) {
524 HRESULT hres;
526 hres = This->data->vtbl->get_dispid(This->outer, bstrName, grfdex, pid);
527 if(hres != DISP_E_UNKNOWNNAME)
528 return hres;
531 hres = get_dynamic_prop(This, bstrName, grfdex&fdexNameEnsure, &dprop);
532 if(FAILED(hres))
533 return hres;
535 *pid = DISPID_DYNPROP_0 + (dprop - This->dynamic_data->props);
536 return S_OK;
539 static HRESULT WINAPI DispatchEx_InvokeEx(IDispatchEx *iface, DISPID id, LCID lcid, WORD wFlags, DISPPARAMS *pdp,
540 VARIANT *pvarRes, EXCEPINFO *pei, IServiceProvider *pspCaller)
542 DispatchEx *This = DISPATCHEX_THIS(iface);
543 IUnknown *unk;
544 ITypeInfo *ti;
545 dispex_data_t *data;
546 UINT argerr=0;
547 int min, max, n;
548 HRESULT hres;
550 TRACE("(%p)->(%x %x %x %p %p %p %p)\n", This, id, lcid, wFlags, pdp, pvarRes, pei, pspCaller);
552 if(is_custom_dispid(id) && This->data->vtbl && This->data->vtbl->invoke)
553 return This->data->vtbl->invoke(This->outer, id, lcid, wFlags, pdp, pvarRes, pei, pspCaller);
555 if(wFlags == DISPATCH_CONSTRUCT) {
556 FIXME("DISPATCH_CONSTRUCT not implemented\n");
557 return E_NOTIMPL;
560 if(is_dynamic_dispid(id)) {
561 DWORD idx = id - DISPID_DYNPROP_0;
562 VARIANT *var;
564 if(!This->dynamic_data || This->dynamic_data->prop_cnt <= idx)
565 return DISP_E_UNKNOWNNAME;
567 var = &This->dynamic_data->props[idx].var;
569 switch(wFlags) {
570 case INVOKE_FUNC: {
571 DISPID named_arg = DISPID_THIS;
572 DISPPARAMS dp = {NULL, &named_arg, 0, 1};
573 IDispatchEx *dispex;
575 if(V_VT(var) != VT_DISPATCH) {
576 FIXME("invoke vt %d\n", V_VT(var));
577 return E_NOTIMPL;
580 if(pdp->cNamedArgs) {
581 FIXME("named args not supported\n");
582 return E_NOTIMPL;
585 dp.rgvarg = heap_alloc((pdp->cArgs+1)*sizeof(VARIANTARG));
586 if(!dp.rgvarg)
587 return E_OUTOFMEMORY;
589 dp.cArgs = pdp->cArgs+1;
590 memcpy(dp.rgvarg+1, pdp->rgvarg, pdp->cArgs*sizeof(VARIANTARG));
592 V_VT(dp.rgvarg) = VT_DISPATCH;
593 V_DISPATCH(dp.rgvarg) = (IDispatch*)DISPATCHEX(This);
595 hres = IDispatch_QueryInterface(V_DISPATCH(var), &IID_IDispatchEx, (void**)&dispex);
596 TRACE("%s call\n", debugstr_w(This->dynamic_data->props[idx].name));
597 if(SUCCEEDED(hres)) {
598 hres = IDispatchEx_InvokeEx(dispex, DISPID_VALUE, lcid, wFlags, &dp, pvarRes, pei, pspCaller);
599 IDispatchEx_Release(dispex);
600 }else {
601 ULONG err = 0;
602 hres = IDispatch_Invoke(V_DISPATCH(var), DISPID_VALUE, &IID_NULL, lcid, wFlags, pdp, pvarRes, pei, &err);
604 TRACE("%s ret %08x\n", debugstr_w(This->dynamic_data->props[idx].name), hres);
606 heap_free(dp.rgvarg);
607 return hres;
609 case INVOKE_PROPERTYGET:
610 return VariantCopy(pvarRes, var);
611 case INVOKE_PROPERTYPUT:
612 VariantClear(var);
613 return VariantCopy(var, pdp->rgvarg);
614 default:
615 FIXME("unhandled wFlags %x\n", wFlags);
616 return E_NOTIMPL;
620 data = get_dispex_data(This);
621 if(!data)
622 return E_FAIL;
624 min = 0;
625 max = data->func_cnt-1;
627 while(min <= max) {
628 n = (min+max)/2;
630 if(data->funcs[n].id == id)
631 break;
633 if(data->funcs[n].id < id)
634 min = n+1;
635 else
636 max = n-1;
639 if(min > max) {
640 WARN("invalid id %x\n", id);
641 return DISP_E_UNKNOWNNAME;
644 hres = get_typeinfo(data->funcs[n].tid, &ti);
645 if(FAILED(hres)) {
646 ERR("Could not get type info: %08x\n", hres);
647 return hres;
650 hres = IUnknown_QueryInterface(This->outer, tid_ids[data->funcs[n].tid], (void**)&unk);
651 if(FAILED(hres)) {
652 ERR("Could not get iface %s: %08x\n", debugstr_guid(tid_ids[data->funcs[n].tid]), hres);
653 return E_FAIL;
656 hres = ITypeInfo_Invoke(ti, unk, id, wFlags, pdp, pvarRes, pei, &argerr);
658 IUnknown_Release(unk);
659 return hres;
662 static HRESULT WINAPI DispatchEx_DeleteMemberByName(IDispatchEx *iface, BSTR bstrName, DWORD grfdex)
664 DispatchEx *This = DISPATCHEX_THIS(iface);
665 FIXME("(%p)->(%s %x)\n", This, debugstr_w(bstrName), grfdex);
666 return E_NOTIMPL;
669 static HRESULT WINAPI DispatchEx_DeleteMemberByDispID(IDispatchEx *iface, DISPID id)
671 DispatchEx *This = DISPATCHEX_THIS(iface);
672 FIXME("(%p)->(%x)\n", This, id);
673 return E_NOTIMPL;
676 static HRESULT WINAPI DispatchEx_GetMemberProperties(IDispatchEx *iface, DISPID id, DWORD grfdexFetch, DWORD *pgrfdex)
678 DispatchEx *This = DISPATCHEX_THIS(iface);
679 FIXME("(%p)->(%x %x %p)\n", This, id, grfdexFetch, pgrfdex);
680 return E_NOTIMPL;
683 static HRESULT WINAPI DispatchEx_GetMemberName(IDispatchEx *iface, DISPID id, BSTR *pbstrName)
685 DispatchEx *This = DISPATCHEX_THIS(iface);
686 FIXME("(%p)->(%x %p)\n", This, id, pbstrName);
687 return E_NOTIMPL;
690 static HRESULT WINAPI DispatchEx_GetNextDispID(IDispatchEx *iface, DWORD grfdex, DISPID id, DISPID *pid)
692 DispatchEx *This = DISPATCHEX_THIS(iface);
693 FIXME("(%p)->(%x %x %p)\n", This, grfdex, id, pid);
694 return E_NOTIMPL;
697 static HRESULT WINAPI DispatchEx_GetNameSpaceParent(IDispatchEx *iface, IUnknown **ppunk)
699 DispatchEx *This = DISPATCHEX_THIS(iface);
700 FIXME("(%p)->(%p)\n", This, ppunk);
701 return E_NOTIMPL;
704 #undef DISPATCHEX_THIS
706 static IDispatchExVtbl DispatchExVtbl = {
707 DispatchEx_QueryInterface,
708 DispatchEx_AddRef,
709 DispatchEx_Release,
710 DispatchEx_GetTypeInfoCount,
711 DispatchEx_GetTypeInfo,
712 DispatchEx_GetIDsOfNames,
713 DispatchEx_Invoke,
714 DispatchEx_GetDispID,
715 DispatchEx_InvokeEx,
716 DispatchEx_DeleteMemberByName,
717 DispatchEx_DeleteMemberByDispID,
718 DispatchEx_GetMemberProperties,
719 DispatchEx_GetMemberName,
720 DispatchEx_GetNextDispID,
721 DispatchEx_GetNameSpaceParent
724 BOOL dispex_query_interface(DispatchEx *This, REFIID riid, void **ppv)
726 static const IID IID_UndocumentedScriptIface =
727 {0x719c3050,0xf9d3,0x11cf,{0xa4,0x93,0x00,0x40,0x05,0x23,0xa8,0xa0}};
728 static const IID IID_IDispatchJS =
729 {0x719c3050,0xf9d3,0x11cf,{0xa4,0x93,0x00,0x40,0x05,0x23,0xa8,0xa6}};
731 if(IsEqualGUID(&IID_IDispatch, riid)) {
732 TRACE("(%p)->(IID_IDispatch %p)\n", This, ppv);
733 *ppv = DISPATCHEX(This);
734 }else if(IsEqualGUID(&IID_IDispatchEx, riid)) {
735 TRACE("(%p)->(IID_IDispatchEx %p)\n", This, ppv);
736 *ppv = DISPATCHEX(This);
737 }else if(IsEqualGUID(&IID_IDispatchJS, riid)) {
738 TRACE("(%p)->(IID_IDispatchJS %p) returning NULL\n", This, ppv);
739 *ppv = NULL;
740 }else if(IsEqualGUID(&IID_UndocumentedScriptIface, riid)) {
741 TRACE("(%p)->(IID_UndocumentedScriptIface %p) returning NULL\n", This, ppv);
742 *ppv = NULL;
743 }else {
744 return FALSE;
747 if(*ppv)
748 IUnknown_AddRef((IUnknown*)*ppv);
749 return TRUE;
752 void init_dispex(DispatchEx *dispex, IUnknown *outer, dispex_static_data_t *data)
754 dispex->lpIDispatchExVtbl = &DispatchExVtbl;
755 dispex->outer = outer;
756 dispex->data = data;