jscript: Add missing port.h include for isnan.
[wine/multimedia.git] / dlls / msxml3 / dispex.c
blob23b880512158890830c82ac6fbcff4d03c43f0c3
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 #define COBJMACROS
21 #include "config.h"
23 #include <stdarg.h>
24 #ifdef HAVE_LIBXML2
25 # include <libxml/parser.h>
26 # include <libxml/xmlerror.h>
27 #endif
29 #include "windef.h"
30 #include "winbase.h"
31 #include "winuser.h"
32 #include "winnls.h"
33 #include "ole2.h"
34 #include "msxml6.h"
35 #include "wininet.h"
36 #include "urlmon.h"
37 #include "winreg.h"
38 #include "shlwapi.h"
40 #include "wine/debug.h"
41 #include "wine/list.h"
42 #include "wine/unicode.h"
44 #include "msxml_private.h"
46 WINE_DEFAULT_DEBUG_CHANNEL(msxml);
48 static CRITICAL_SECTION cs_dispex_static_data;
49 static CRITICAL_SECTION_DEBUG cs_dispex_static_data_dbg =
51 0, 0, &cs_dispex_static_data,
52 { &cs_dispex_static_data_dbg.ProcessLocksList, &cs_dispex_static_data_dbg.ProcessLocksList },
53 0, 0, { (DWORD_PTR)(__FILE__ ": dispex_static_data") }
55 static CRITICAL_SECTION cs_dispex_static_data = { &cs_dispex_static_data_dbg, -1, 0, 0, 0, 0 };
58 enum lib_version_t
60 LibXml = 0,
61 LibXml2,
62 LibXml_Last
65 typedef struct {
66 REFIID iid;
67 enum lib_version_t lib;
68 } tid_id_t;
70 typedef struct {
71 REFIID iid;
72 unsigned short major;
73 } lib_id_t;
75 typedef struct {
76 DISPID id;
77 BSTR name;
78 enum tid_t tid;
79 } func_info_t;
81 struct dispex_data_t {
82 DWORD func_cnt;
83 func_info_t *funcs;
84 func_info_t **name_table;
86 struct list entry;
89 typedef struct {
90 VARIANT var;
91 LPWSTR name;
92 } dynamic_prop_t;
94 struct dispex_dynamic_data_t {
95 DWORD buf_size;
96 DWORD prop_cnt;
97 dynamic_prop_t *props;
100 #define DISPID_DYNPROP_0 0x50000000
101 #define DISPID_DYNPROP_MAX 0x5fffffff
103 static struct list dispex_data_list = LIST_INIT(dispex_data_list);
104 static ITypeLib *typelib[LibXml_Last];
105 static ITypeInfo *typeinfos[LAST_tid];
107 /* indexed with lib_version_t values */
108 static lib_id_t lib_ids[] = {
109 { &LIBID_MSXML, 2 },
110 { &LIBID_MSXML2, 3 }
113 static tid_id_t tid_ids[] = {
114 { &IID_NULL, LibXml_Last },
115 { &IID_IXMLDOMAttribute, LibXml2 },
116 { &IID_IXMLDOMCDATASection, LibXml2 },
117 { &IID_IXMLDOMComment, LibXml2 },
118 { &IID_IXMLDOMDocument, LibXml2 },
119 { &IID_IXMLDOMDocument2, LibXml2 },
120 { &IID_IXMLDOMDocument3, LibXml2 },
121 { &IID_IXMLDOMDocumentFragment, LibXml2 },
122 { &IID_IXMLDOMDocumentType, LibXml2 },
123 { &IID_IXMLDOMElement, LibXml2 },
124 { &IID_IXMLDOMEntityReference, LibXml2 },
125 { &IID_IXMLDOMImplementation, LibXml2 },
126 { &IID_IXMLDOMNamedNodeMap, LibXml2 },
127 { &IID_IXMLDOMNode, LibXml2 },
128 { &IID_IXMLDOMNodeList, LibXml2 },
129 { &IID_IXMLDOMParseError2, LibXml2 },
130 { &IID_IXMLDOMProcessingInstruction, LibXml2 },
131 { &IID_IXMLDOMSchemaCollection, LibXml2 },
132 { &IID_IXMLDOMSchemaCollection2, LibXml2 },
133 { &IID_IXMLDOMSelection, LibXml2 },
134 { &IID_IXMLDOMText, LibXml2 },
135 { &IID_IXMLElement, LibXml },
136 { &IID_IXMLDocument, LibXml },
137 { &IID_IXMLHTTPRequest, LibXml2 },
138 { &IID_IXSLProcessor, LibXml2 },
139 { &IID_IXSLTemplate, LibXml2 },
140 { &IID_IVBSAXAttributes, LibXml2 },
141 { &IID_IVBSAXContentHandler, LibXml2 },
142 { &IID_IVBSAXDeclHandler, LibXml2 },
143 { &IID_IVBSAXDTDHandler, LibXml2 },
144 { &IID_IVBSAXEntityResolver, LibXml2 },
145 { &IID_IVBSAXErrorHandler, LibXml2 },
146 { &IID_IVBSAXLexicalHandler, LibXml2 },
147 { &IID_IVBSAXLocator, LibXml2 },
148 { &IID_IVBSAXXMLFilter, LibXml2 },
149 { &IID_IVBSAXXMLReader, LibXml2 },
150 { &IID_IMXAttributes, LibXml2 },
151 { &IID_IMXReaderControl, LibXml2 },
152 { &IID_IMXWriter, LibXml2 },
153 { &IID_IVBMXNamespaceManager, LibXml2 }
156 const IID *get_riid_from_tid(tid_t tid)
158 return tid_ids[tid].iid;
161 static inline unsigned get_libid_from_tid(tid_t tid)
163 return tid_ids[tid].lib;
166 HRESULT get_typeinfo(enum tid_t tid, ITypeInfo **typeinfo)
168 unsigned lib = get_libid_from_tid(tid);
169 HRESULT hres;
171 if(!typelib[lib]) {
172 ITypeLib *tl;
174 hres = LoadRegTypeLib(lib_ids[lib].iid, lib_ids[lib].major, 0, LOCALE_SYSTEM_DEFAULT, &tl);
175 if(FAILED(hres)) {
176 ERR("LoadRegTypeLib failed: %08x\n", hres);
177 return hres;
180 if(InterlockedCompareExchangePointer((void**)&typelib[lib], tl, NULL))
181 ITypeLib_Release(tl);
184 if(!typeinfos[tid]) {
185 ITypeInfo *ti;
187 hres = ITypeLib_GetTypeInfoOfGuid(typelib[lib], get_riid_from_tid(tid), &ti);
188 if(FAILED(hres)) {
189 /* try harder with typelib from msxml.dll */
190 hres = ITypeLib_GetTypeInfoOfGuid(typelib[LibXml], get_riid_from_tid(tid), &ti);
191 if(FAILED(hres)) {
192 ERR("GetTypeInfoOfGuid failed: %08x\n", hres);
193 return hres;
197 if(InterlockedCompareExchangePointer((void**)(typeinfos+tid), ti, NULL))
198 ITypeInfo_Release(ti);
201 *typeinfo = typeinfos[tid];
203 ITypeInfo_AddRef(typeinfos[tid]);
204 return S_OK;
207 void release_typelib(void)
209 dispex_data_t *iter;
210 unsigned i;
212 while(!list_empty(&dispex_data_list)) {
213 iter = LIST_ENTRY(list_head(&dispex_data_list), dispex_data_t, entry);
214 list_remove(&iter->entry);
216 for(i=0; i < iter->func_cnt; i++)
217 SysFreeString(iter->funcs[i].name);
219 heap_free(iter->funcs);
220 heap_free(iter->name_table);
221 heap_free(iter);
224 for(i=0; i < sizeof(typeinfos)/sizeof(*typeinfos); i++)
225 if(typeinfos[i])
226 ITypeInfo_Release(typeinfos[i]);
228 for(i=0; i < sizeof(typelib)/sizeof(*typelib); i++)
229 if(typelib[i])
230 ITypeLib_Release(typelib[i]);
232 DeleteCriticalSection(&cs_dispex_static_data);
235 static void add_func_info(dispex_data_t *data, DWORD *size, tid_t tid, DISPID id, ITypeInfo *dti)
237 HRESULT hres;
239 if(data->func_cnt && data->funcs[data->func_cnt-1].id == id)
240 return;
242 if(data->func_cnt == *size)
243 data->funcs = heap_realloc(data->funcs, (*size <<= 1)*sizeof(func_info_t));
245 hres = ITypeInfo_GetDocumentation(dti, id, &data->funcs[data->func_cnt].name, NULL, NULL, NULL);
246 if(FAILED(hres))
247 return;
249 data->funcs[data->func_cnt].id = id;
250 data->funcs[data->func_cnt].tid = tid;
252 data->func_cnt++;
255 static int dispid_cmp(const void *p1, const void *p2)
257 return ((const func_info_t*)p1)->id - ((const func_info_t*)p2)->id;
260 static int func_name_cmp(const void *p1, const void *p2)
262 return strcmpiW((*(func_info_t* const*)p1)->name, (*(func_info_t* const*)p2)->name);
265 static dispex_data_t *preprocess_dispex_data(DispatchEx *This)
267 const tid_t *tid = This->data->iface_tids;
268 FUNCDESC *funcdesc;
269 dispex_data_t *data;
270 DWORD size = 16, i;
271 ITypeInfo *ti, *dti;
272 HRESULT hres;
274 TRACE("(%p)\n", This);
276 hres = get_typeinfo(This->data->disp_tid, &dti);
277 if(FAILED(hres)) {
278 ERR("Could not get disp type info: %08x\n", hres);
279 return NULL;
282 data = heap_alloc(sizeof(dispex_data_t));
283 data->func_cnt = 0;
284 data->funcs = heap_alloc(size*sizeof(func_info_t));
285 list_add_tail(&dispex_data_list, &data->entry);
287 while(*tid) {
288 hres = get_typeinfo(*tid, &ti);
289 if(FAILED(hres))
290 break;
292 i=0;
293 while(1) {
294 hres = ITypeInfo_GetFuncDesc(ti, i++, &funcdesc);
295 if(FAILED(hres))
296 break;
298 add_func_info(data, &size, *tid, funcdesc->memid, dti);
299 ITypeInfo_ReleaseFuncDesc(ti, funcdesc);
302 ITypeInfo_Release(ti);
303 tid++;
306 if(!data->func_cnt) {
307 heap_free(data->funcs);
308 data->funcs = NULL;
309 }else if(data->func_cnt != size) {
310 data->funcs = heap_realloc(data->funcs, data->func_cnt * sizeof(func_info_t));
313 qsort(data->funcs, data->func_cnt, sizeof(func_info_t), dispid_cmp);
315 if(data->funcs) {
316 data->name_table = heap_alloc(data->func_cnt * sizeof(func_info_t*));
317 for(i=0; i < data->func_cnt; i++)
318 data->name_table[i] = data->funcs+i;
319 qsort(data->name_table, data->func_cnt, sizeof(func_info_t*), func_name_cmp);
320 }else {
321 data->name_table = NULL;
324 ITypeInfo_Release(dti);
325 return data;
328 static dispex_data_t *get_dispex_data(DispatchEx *This)
330 if(This->data->data)
331 return This->data->data;
333 EnterCriticalSection(&cs_dispex_static_data);
335 if(!This->data->data)
336 This->data->data = preprocess_dispex_data(This);
338 LeaveCriticalSection(&cs_dispex_static_data);
340 return This->data->data;
343 static inline BOOL is_dynamic_dispid(DISPID id)
345 return DISPID_DYNPROP_0 <= id && id <= DISPID_DYNPROP_MAX;
348 static inline DispatchEx *impl_from_IDispatchEx(IDispatchEx *iface)
350 return CONTAINING_RECORD(iface, DispatchEx, IDispatchEx_iface);
353 static HRESULT WINAPI DispatchEx_QueryInterface(IDispatchEx *iface, REFIID riid, void **ppv)
355 DispatchEx *This = impl_from_IDispatchEx(iface);
357 return IUnknown_QueryInterface(This->outer, riid, ppv);
360 static ULONG WINAPI DispatchEx_AddRef(IDispatchEx *iface)
362 DispatchEx *This = impl_from_IDispatchEx(iface);
364 return IUnknown_AddRef(This->outer);
367 static ULONG WINAPI DispatchEx_Release(IDispatchEx *iface)
369 DispatchEx *This = impl_from_IDispatchEx(iface);
371 return IUnknown_Release(This->outer);
374 static HRESULT WINAPI DispatchEx_GetTypeInfoCount(IDispatchEx *iface, UINT *pctinfo)
376 DispatchEx *This = impl_from_IDispatchEx(iface);
378 TRACE("(%p)->(%p)\n", This, pctinfo);
380 *pctinfo = 1;
381 return S_OK;
384 static HRESULT WINAPI DispatchEx_GetTypeInfo(IDispatchEx *iface, UINT iTInfo,
385 LCID lcid, ITypeInfo **ppTInfo)
387 DispatchEx *This = impl_from_IDispatchEx(iface);
389 TRACE("(%p)->(%u %u %p)\n", This, iTInfo, lcid, ppTInfo);
391 return get_typeinfo(This->data->disp_tid, ppTInfo);
394 static HRESULT WINAPI DispatchEx_GetIDsOfNames(IDispatchEx *iface, REFIID riid,
395 LPOLESTR *rgszNames, UINT cNames,
396 LCID lcid, DISPID *rgDispId)
398 DispatchEx *This = impl_from_IDispatchEx(iface);
399 UINT i;
400 HRESULT hres;
402 TRACE("(%p)->(%s %p %u %u %p)\n", This, debugstr_guid(riid), rgszNames, cNames,
403 lcid, rgDispId);
405 for(i=0; i < cNames; i++) {
406 hres = IDispatchEx_GetDispID(&This->IDispatchEx_iface, rgszNames[i], 0, rgDispId+i);
407 if(FAILED(hres))
408 return hres;
411 return S_OK;
414 static HRESULT WINAPI DispatchEx_Invoke(IDispatchEx *iface, DISPID dispIdMember,
415 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
416 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
418 DispatchEx *This = impl_from_IDispatchEx(iface);
420 TRACE("(%p)->(%d %s %d %d %p %p %p %p)\n", This, dispIdMember, debugstr_guid(riid),
421 lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
423 return IDispatchEx_InvokeEx(&This->IDispatchEx_iface, dispIdMember, lcid, wFlags,
424 pDispParams, pVarResult, pExcepInfo, NULL);
427 static HRESULT WINAPI DispatchEx_GetDispID(IDispatchEx *iface, BSTR bstrName, DWORD grfdex, DISPID *pid)
429 DispatchEx *This = impl_from_IDispatchEx(iface);
430 dispex_data_t *data;
431 int min, max, n, c;
433 TRACE("(%p)->(%s %x %p)\n", This, debugstr_w(bstrName), grfdex, pid);
435 if(grfdex & ~(fdexNameCaseSensitive|fdexNameEnsure|fdexNameImplicit))
436 FIXME("Unsupported grfdex %x\n", grfdex);
438 data = get_dispex_data(This);
439 if(!data)
440 return E_FAIL;
442 min = 0;
443 max = data->func_cnt-1;
445 while(min <= max) {
446 n = (min+max)/2;
448 c = strcmpiW(data->name_table[n]->name, bstrName);
449 if(!c) {
450 if((grfdex & fdexNameCaseSensitive) && strcmpW(data->name_table[n]->name, bstrName))
451 break;
453 *pid = data->name_table[n]->id;
454 return S_OK;
457 if(c > 0)
458 max = n-1;
459 else
460 min = n+1;
463 if(This->dynamic_data) {
464 unsigned i;
466 for(i=0; i < This->dynamic_data->prop_cnt; i++) {
467 if(!strcmpW(This->dynamic_data->props[i].name, bstrName)) {
468 *pid = DISPID_DYNPROP_0 + i;
469 return S_OK;
474 if(This->data->vtbl && This->data->vtbl->get_dispid) {
475 HRESULT hres;
477 hres = This->data->vtbl->get_dispid(This->outer, bstrName, grfdex, pid);
478 if(hres != DISP_E_UNKNOWNNAME)
479 return hres;
482 if(grfdex & fdexNameEnsure) {
483 dispex_dynamic_data_t *dynamic_data;
485 TRACE("creating dynamic prop %s\n", debugstr_w(bstrName));
487 if(This->dynamic_data) {
488 dynamic_data = This->dynamic_data;
489 }else {
490 dynamic_data = This->dynamic_data = heap_alloc_zero(sizeof(dispex_dynamic_data_t));
491 if(!dynamic_data)
492 return E_OUTOFMEMORY;
495 if(!dynamic_data->buf_size) {
496 dynamic_data->props = heap_alloc(sizeof(dynamic_prop_t)*4);
497 if(!dynamic_data->props)
498 return E_OUTOFMEMORY;
499 dynamic_data->buf_size = 4;
500 }else if(dynamic_data->buf_size == dynamic_data->prop_cnt) {
501 dynamic_prop_t *new_props;
503 new_props = heap_realloc(dynamic_data->props, sizeof(dynamic_prop_t)*(dynamic_data->buf_size<<1));
504 if(!new_props)
505 return E_OUTOFMEMORY;
507 dynamic_data->props = new_props;
508 dynamic_data->buf_size <<= 1;
511 dynamic_data->props[dynamic_data->prop_cnt].name = heap_strdupW(bstrName);
512 VariantInit(&dynamic_data->props[dynamic_data->prop_cnt].var);
513 *pid = DISPID_DYNPROP_0 + dynamic_data->prop_cnt++;
515 return S_OK;
518 TRACE("not found %s\n", debugstr_w(bstrName));
519 return DISP_E_UNKNOWNNAME;
522 static HRESULT WINAPI DispatchEx_InvokeEx(IDispatchEx *iface, DISPID id, LCID lcid, WORD wFlags, DISPPARAMS *pdp,
523 VARIANT *pvarRes, EXCEPINFO *pei, IServiceProvider *pspCaller)
525 DispatchEx *This = impl_from_IDispatchEx(iface);
526 IUnknown *unk;
527 ITypeInfo *ti;
528 dispex_data_t *data;
529 UINT argerr=0;
530 int min, max, n;
531 HRESULT hres;
533 TRACE("(%p)->(%x %x %x %p %p %p %p)\n", This, id, lcid, wFlags, pdp, pvarRes, pei, pspCaller);
535 if(This->data->vtbl && This->data->vtbl->invoke) {
536 hres = This->data->vtbl->invoke(This->outer, id, lcid, wFlags, pdp, pvarRes, pei);
537 if (hres != DISP_E_UNKNOWNNAME) return hres;
540 if(wFlags == DISPATCH_CONSTRUCT) {
541 FIXME("DISPATCH_CONSTRUCT not implemented\n");
542 return E_NOTIMPL;
545 if(is_dynamic_dispid(id)) {
546 DWORD idx = id - DISPID_DYNPROP_0;
547 VARIANT *var;
549 if(!This->dynamic_data || This->dynamic_data->prop_cnt <= idx)
550 return DISP_E_UNKNOWNNAME;
552 var = &This->dynamic_data->props[idx].var;
554 switch(wFlags) {
555 case INVOKE_PROPERTYGET:
556 V_VT(pvarRes) = VT_EMPTY;
557 return VariantCopy(pvarRes, var);
558 case INVOKE_PROPERTYPUT:
559 VariantClear(var);
560 return VariantCopy(var, pdp->rgvarg);
561 default:
562 FIXME("unhandled wFlags %x\n", wFlags);
563 return E_NOTIMPL;
567 data = get_dispex_data(This);
568 if(!data)
569 return E_FAIL;
571 min = 0;
572 max = data->func_cnt-1;
574 while(min <= max) {
575 n = (min+max)/2;
577 if(data->funcs[n].id == id)
578 break;
580 if(data->funcs[n].id < id)
581 min = n+1;
582 else
583 max = n-1;
586 if(min > max) {
587 WARN("invalid id %x\n", id);
588 return DISP_E_UNKNOWNNAME;
591 hres = get_typeinfo(data->funcs[n].tid, &ti);
592 if(FAILED(hres)) {
593 ERR("Could not get type info: %08x\n", hres);
594 return hres;
597 hres = IUnknown_QueryInterface(This->outer, get_riid_from_tid(data->funcs[n].tid), (void**)&unk);
598 if(FAILED(hres)) {
599 ERR("Could not get iface: %08x\n", hres);
600 return E_FAIL;
603 hres = ITypeInfo_Invoke(ti, unk, id, wFlags, pdp, pvarRes, pei, &argerr);
605 ITypeInfo_Release(ti);
606 IUnknown_Release(unk);
607 return hres;
610 static HRESULT WINAPI DispatchEx_DeleteMemberByName(IDispatchEx *iface, BSTR bstrName, DWORD grfdex)
612 DispatchEx *This = impl_from_IDispatchEx(iface);
613 TRACE("Not implemented in native msxml3 (%p)->(%s %x)\n", This, debugstr_w(bstrName), grfdex);
614 return E_NOTIMPL;
617 static HRESULT WINAPI DispatchEx_DeleteMemberByDispID(IDispatchEx *iface, DISPID id)
619 DispatchEx *This = impl_from_IDispatchEx(iface);
620 TRACE("Not implemented in native msxml3 (%p)->(%x)\n", This, id);
621 return E_NOTIMPL;
624 static HRESULT WINAPI DispatchEx_GetMemberProperties(IDispatchEx *iface, DISPID id, DWORD grfdexFetch, DWORD *pgrfdex)
626 DispatchEx *This = impl_from_IDispatchEx(iface);
627 TRACE("Not implemented in native msxml3 (%p)->(%x %x %p)\n", This, id, grfdexFetch, pgrfdex);
628 return E_NOTIMPL;
631 static HRESULT WINAPI DispatchEx_GetMemberName(IDispatchEx *iface, DISPID id, BSTR *pbstrName)
633 DispatchEx *This = impl_from_IDispatchEx(iface);
634 TRACE("Not implemented in native msxml3 (%p)->(%x %p)\n", This, id, pbstrName);
635 return E_NOTIMPL;
638 static HRESULT WINAPI DispatchEx_GetNextDispID(IDispatchEx *iface, DWORD grfdex, DISPID id, DISPID *pid)
640 DispatchEx *This = impl_from_IDispatchEx(iface);
641 TRACE(" Not implemented in native msxml3 (%p)->(%x %x %p)\n", This, grfdex, id, pid);
642 return E_NOTIMPL;
645 static HRESULT WINAPI DispatchEx_GetNameSpaceParent(IDispatchEx *iface, IUnknown **ppunk)
647 DispatchEx *This = impl_from_IDispatchEx(iface);
648 TRACE("Not implemented in native msxml3 (%p)->(%p)\n", This, ppunk);
649 return E_NOTIMPL;
652 static IDispatchExVtbl DispatchExVtbl = {
653 DispatchEx_QueryInterface,
654 DispatchEx_AddRef,
655 DispatchEx_Release,
656 DispatchEx_GetTypeInfoCount,
657 DispatchEx_GetTypeInfo,
658 DispatchEx_GetIDsOfNames,
659 DispatchEx_Invoke,
660 DispatchEx_GetDispID,
661 DispatchEx_InvokeEx,
662 DispatchEx_DeleteMemberByName,
663 DispatchEx_DeleteMemberByDispID,
664 DispatchEx_GetMemberProperties,
665 DispatchEx_GetMemberName,
666 DispatchEx_GetNextDispID,
667 DispatchEx_GetNameSpaceParent
670 BOOL dispex_query_interface(DispatchEx *This, REFIID riid, void **ppv)
672 static const IID IID_UndocumentedScriptIface =
673 {0x719c3050,0xf9d3,0x11cf,{0xa4,0x93,0x00,0x40,0x05,0x23,0xa8,0xa0}};
674 static const IID IID_IDispatchJS =
675 {0x719c3050,0xf9d3,0x11cf,{0xa4,0x93,0x00,0x40,0x05,0x23,0xa8,0xa6}};
677 if(IsEqualGUID(&IID_IDispatch, riid)) {
678 TRACE("(%p)->(IID_IDispatch %p)\n", This, ppv);
679 *ppv = &This->IDispatchEx_iface;
680 }else if(IsEqualGUID(&IID_IDispatchEx, riid)) {
681 TRACE("(%p)->(IID_IDispatchEx %p)\n", This, ppv);
682 *ppv = &This->IDispatchEx_iface;
683 }else if(IsEqualGUID(&IID_IDispatchJS, riid)) {
684 TRACE("(%p)->(IID_IDispatchJS %p) returning NULL\n", This, ppv);
685 *ppv = NULL;
686 }else if(IsEqualGUID(&IID_UndocumentedScriptIface, riid)) {
687 TRACE("(%p)->(IID_UndocumentedScriptIface %p) returning NULL\n", This, ppv);
688 *ppv = NULL;
689 }else if (IsEqualGUID(&IID_IObjectIdentity, riid)) {
690 TRACE("IID_IObjectIdentity not supported returning NULL\n");
691 *ppv = NULL;
692 }else {
693 return FALSE;
696 if(*ppv)
697 IUnknown_AddRef((IUnknown*)*ppv);
698 return TRUE;
701 void release_dispex(DispatchEx *This)
703 dynamic_prop_t *prop;
705 if(!This->dynamic_data)
706 return;
708 for(prop = This->dynamic_data->props; prop < This->dynamic_data->props + This->dynamic_data->prop_cnt; prop++) {
709 VariantClear(&prop->var);
710 heap_free(prop->name);
713 heap_free(This->dynamic_data->props);
714 heap_free(This->dynamic_data);
717 void init_dispex(DispatchEx *dispex, IUnknown *outer, dispex_static_data_t *data)
719 dispex->IDispatchEx_iface.lpVtbl = &DispatchExVtbl;
720 dispex->outer = outer;
721 dispex->data = data;
722 dispex->dynamic_data = NULL;