~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

Wine Cross Reference
wine/dlls/msxml3/dispex.c

Version: ~ [ wine-1.5.30 ] ~ [ wine-1.5.29 ] ~ [ wine-1.5.28 ] ~ [ wine-1.5.27 ] ~ [ wine-1.5.26 ] ~ [ wine-1.5.25 ] ~ [ wine-1.5.24 ] ~ [ wine-1.5.23 ] ~ [ wine-1.5.22 ] ~ [ wine-1.5.21 ] ~ [ wine-1.5.20 ] ~ [ wine-1.5.19 ] ~ [ wine-1.5.18 ] ~ [ wine-1.5.17 ] ~ [ wine-1.5.16 ] ~ [ wine-1.5.15 ] ~ [ wine-1.5.14 ] ~ [ wine-1.5.13 ] ~ [ wine-1.5.12 ] ~ [ wine-1.5.11 ] ~ [ wine-1.5.10 ] ~ [ wine-1.5.9 ] ~ [ wine-1.5.8 ] ~ [ wine-1.5.7 ] ~ [ wine-1.4.1 ] ~ [ wine-1.5.6 ] ~ [ wine-1.5.5 ] ~ [ wine-1.5.4 ] ~ [ wine-1.5.3 ] ~ [ wine-1.5.2 ] ~ [ wine-1.5.1 ] ~ [ wine-1.5.0 ] ~ [ wine-1.4 ] ~ [ wine-1.4-rc6 ] ~ [ wine-1.4-rc5 ] ~ [ wine-1.4-rc4 ] ~ [ wine-1.4-rc3 ] ~ [ wine-1.4-rc2 ] ~ [ wine-1.4-rc1 ] ~ [ wine-1.3.37 ] ~ [ wine-1.3.36 ] ~ [ wine-1.3.35 ] ~ [ wine-1.3.34 ] ~ [ wine-1.3.33 ] ~ [ wine-1.3.32 ] ~ [ wine-1.3.31 ] ~ [ wine-1.3.30 ] ~ [ wine-1.3.29 ] ~ [ wine-1.3.28 ] ~ [ wine-1.3.27 ] ~ [ wine-1.3.26 ] ~ [ wine-1.3.25 ] ~ [ wine-1.3.24 ] ~ [ wine-1.3.23 ] ~ [ wine-1.3.22 ] ~ [ wine-1.3.21 ] ~ [ wine-1.3.20 ] ~ [ wine-1.3.19 ] ~ [ wine-1.3.18 ] ~ [ wine-1.2.3 ] ~ [ wine-1.3.17 ] ~ [ wine-1.3.16 ] ~ [ wine-1.3.15 ] ~ [ wine-1.3.14 ] ~ [ wine-1.3.13 ] ~ [ wine-1.3.12 ] ~ [ wine-1.3.11 ] ~ [ wine-1.3.10 ] ~ [ wine-1.3.9 ] ~ [ wine-1.2.2 ] ~ [ wine-1.3.8 ] ~ [ wine-1.3.7 ] ~ [ wine-1.3.6 ] ~ [ wine-1.3.5 ] ~ [ wine-1.2.1 ] ~ [ wine-1.3.4 ] ~ [ wine-1.3.3 ] ~ [ wine-1.3.2 ] ~ [ wine-1.3.1 ] ~ [ wine-1.3.0 ] ~ [ wine-1.2 ] ~ [ wine-1.2-rc7 ] ~ [ wine-1.2-rc6 ] ~ [ wine-1.2-rc5 ] ~ [ wine-1.2-rc4 ] ~ [ wine-1.2-rc3 ] ~ [ wine-1.2-rc2 ] ~ [ wine-1.2-rc1 ] ~ [ wine-1.1.44 ] ~ [ wine-1.1.43 ] ~ [ wine-1.1.42 ] ~ [ wine-1.1.41 ] ~ [ wine-1.1.40 ] ~ [ wine-1.1.39 ] ~ [ wine-1.1.38 ] ~ [ wine-1.1.37 ] ~ [ wine-1.1.36 ] ~ [ wine-1.1.35 ] ~ [ wine-1.1.34 ] ~ [ wine-1.1.33 ] ~ [ wine-1.1.32 ] ~ [ wine-1.1.31 ] ~ [ wine-1.1.30 ] ~ [ wine-1.1.29 ] ~ [ wine-1.1.28 ] ~ [ wine-1.1.27 ] ~ [ wine-1.1.26 ] ~ [ wine-1.1.25 ] ~ [ wine-1.1.24 ] ~ [ wine-1.1.23 ] ~ [ wine-1.1.22 ] ~ [ wine-1.1.21 ] ~ [ wine-1.1.20 ] ~ [ wine-1.1.19 ] ~ [ wine-1.1.18 ] ~ [ wine-1.1.17 ] ~ [ wine-1.1.16 ] ~ [ wine-1.1.15 ] ~ [ wine-1.1.14 ] ~ [ wine-1.1.13 ] ~ [ wine-1.1.12 ] ~ [ wine-1.1.11 ] ~ [ wine-1.1.10 ] ~ [ wine-1.1.9 ] ~ [ wine-1.1.8 ] ~ [ wine-1.1.7 ] ~ [ wine-1.0.1 ] ~ [ wine-1.1.6 ] ~ [ wine-1.1.5 ] ~ [ wine-1.1.4 ] ~ [ wine-1.1.3 ] ~ [ wine-1.1.2 ] ~ [ wine-1.1.1 ] ~ [ wine-1.1.0 ] ~ [ wine-1.0 ] ~

  1 /*
  2  * Copyright 2008 Jacek Caban for CodeWeavers
  3  *
  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.
  8  *
  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.
 13  *
 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
 17  */
 18 
 19 #define COBJMACROS
 20 
 21 #include "config.h"
 22 
 23 #include <stdarg.h>
 24 #include <assert.h>
 25 #include "windef.h"
 26 #include "winbase.h"
 27 #include "winuser.h"
 28 #include "winnls.h"
 29 #include "ole2.h"
 30 #include "msxml2.h"
 31 #include "wininet.h"
 32 #include "urlmon.h"
 33 #include "winreg.h"
 34 #include "shlwapi.h"
 35 
 36 #include "wine/debug.h"
 37 #include "wine/list.h"
 38 #include "wine/unicode.h"
 39 
 40 #include "msxml_private.h"
 41 
 42 WINE_DEFAULT_DEBUG_CHANNEL(msxml);
 43 
 44 #define DISPATCHEX(x)  ((IDispatchEx*)  &(x)->lpIDispatchExVtbl)
 45 
 46 typedef struct {
 47     DISPID id;
 48     BSTR name;
 49     enum tid_t tid;
 50 } func_info_t;
 51 
 52 struct dispex_data_t {
 53     DWORD func_cnt;
 54     func_info_t *funcs;
 55     func_info_t **name_table;
 56 
 57     struct list entry;
 58 };
 59 
 60 typedef struct {
 61     VARIANT var;
 62     LPWSTR name;
 63 } dynamic_prop_t;
 64 
 65 struct dispex_dynamic_data_t {
 66     DWORD buf_size;
 67     DWORD prop_cnt;
 68     dynamic_prop_t *props;
 69 };
 70 
 71 #define DISPID_DYNPROP_0    0x50000000
 72 #define DISPID_DYNPROP_MAX  0x5fffffff
 73 
 74 static struct list dispex_data_list = LIST_INIT(dispex_data_list);
 75 static ITypeLib *typelib;
 76 static ITypeInfo *typeinfos[LAST_tid];
 77 
 78 static REFIID tid_ids[] = {
 79     &IID_IXMLDOMAttribute,
 80     &IID_IXMLDOMCDATASection,
 81     &IID_IXMLDOMComment,
 82     &IID_IXMLDOMDocument,
 83     &IID_IXMLDOMDocument2,
 84     &IID_IXMLDOMDocumentFragment,
 85     &IID_IXMLDOMElement,
 86     &IID_IXMLDOMEntityReference,
 87     &IID_IXMLDOMImplementation,
 88     &IID_IXMLDOMNamedNodeMap,
 89     &IID_IXMLDOMNode,
 90     &IID_IXMLDOMNodeList,
 91     &IID_IXMLDOMParseError,
 92     &IID_IXMLDOMProcessingInstruction,
 93     &IID_IXMLDOMSchemaCollection,
 94     &IID_IXMLDOMText,
 95     &IID_IXMLElement,
 96     &IID_IXMLDOMDocument,
 97     &IID_IXMLHTTPRequest,
 98     &IID_IVBSAXAttributes,
 99     &IID_IVBSAXContentHandler,
100     &IID_IVBSAXDeclHandler,
101     &IID_IVBSAXDTDHandler,
102     &IID_IVBSAXEntityResolver,
103     &IID_IVBSAXErrorHandler,
104     &IID_IVBSAXLexicalHandler,
105     &IID_IVBSAXLocator,
106     &IID_IVBSAXXMLFilter,
107     &IID_IVBSAXXMLReader,
108     &IID_IMXAttributes,
109     &IID_IMXReaderControl,
110     &IID_IMXWriter,
111 };
112 
113 HRESULT get_typeinfo(enum tid_t tid, ITypeInfo **typeinfo)
114 {
115     HRESULT hres;
116 
117     if(!typelib) {
118         ITypeLib *tl;
119 
120         hres = LoadRegTypeLib(&LIBID_MSXML2, 3, 0, LOCALE_SYSTEM_DEFAULT, &tl);
121         if(FAILED(hres)) {
122             ERR("LoadRegTypeLib failed: %08x\n", hres);
123             return hres;
124         }
125 
126         if(InterlockedCompareExchangePointer((void**)&typelib, tl, NULL))
127             ITypeLib_Release(tl);
128     }
129 
130     if(!typeinfos[tid]) {
131         ITypeInfo *typeinfo;
132 
133         hres = ITypeLib_GetTypeInfoOfGuid(typelib, tid_ids[tid], &typeinfo);
134         if(FAILED(hres)) {
135             ERR("GetTypeInfoOfGuid failed: %08x\n", hres);
136             return hres;
137         }
138 
139         if(InterlockedCompareExchangePointer((void**)(typeinfos+tid), typeinfo, NULL))
140             ITypeInfo_Release(typeinfo);
141     }
142 
143     *typeinfo = typeinfos[tid];
144 
145     ITypeInfo_AddRef(typeinfos[tid]);
146     return S_OK;
147 }
148 
149 void release_typelib(void)
150 {
151     dispex_data_t *iter;
152     unsigned i;
153 
154     while(!list_empty(&dispex_data_list)) {
155         iter = LIST_ENTRY(list_head(&dispex_data_list), dispex_data_t, entry);
156         list_remove(&iter->entry);
157 
158         for(i=0; i < iter->func_cnt; i++)
159             SysFreeString(iter->funcs[i].name);
160 
161         heap_free(iter->funcs);
162         heap_free(iter->name_table);
163         heap_free(iter);
164     }
165 
166     if(!typelib)
167         return;
168 
169     for(i=0; i < sizeof(typeinfos)/sizeof(*typeinfos); i++)
170         if(typeinfos[i])
171             ITypeInfo_Release(typeinfos[i]);
172 
173     ITypeLib_Release(typelib);
174 }
175 
176 static void add_func_info(dispex_data_t *data, DWORD *size, tid_t tid, DISPID id, ITypeInfo *dti)
177 {
178     HRESULT hres;
179 
180     if(data->func_cnt && data->funcs[data->func_cnt-1].id == id)
181         return;
182 
183     if(data->func_cnt == *size)
184         data->funcs = heap_realloc(data->funcs, (*size <<= 1)*sizeof(func_info_t));
185 
186     hres = ITypeInfo_GetDocumentation(dti, id, &data->funcs[data->func_cnt].name, NULL, NULL, NULL);
187     if(FAILED(hres))
188         return;
189 
190     data->funcs[data->func_cnt].id = id;
191     data->funcs[data->func_cnt].tid = tid;
192 
193     data->func_cnt++;
194 }
195 
196 static int dispid_cmp(const void *p1, const void *p2)
197 {
198     return ((func_info_t*)p1)->id - ((func_info_t*)p2)->id;
199 }
200 
201 static int func_name_cmp(const void *p1, const void *p2)
202 {
203     return strcmpiW((*(func_info_t**)p1)->name, (*(func_info_t**)p2)->name);
204 }
205 
206 static dispex_data_t *preprocess_dispex_data(DispatchEx *This)
207 {
208     const tid_t *tid = This->data->iface_tids;
209     FUNCDESC *funcdesc;
210     dispex_data_t *data;
211     DWORD size = 16, i;
212     ITypeInfo *ti, *dti;
213     HRESULT hres;
214 
215     TRACE("(%p)\n", This);
216 
217     hres = get_typeinfo(This->data->disp_tid, &dti);
218     if(FAILED(hres)) {
219         ERR("Could not get disp type info: %08x\n", hres);
220         return NULL;
221     }
222 
223     data = heap_alloc(sizeof(dispex_data_t));
224     data->func_cnt = 0;
225     data->funcs = heap_alloc(size*sizeof(func_info_t));
226     list_add_tail(&dispex_data_list, &data->entry);
227 
228     while(*tid) {
229         hres = get_typeinfo(*tid, &ti);
230         if(FAILED(hres))
231             break;
232 
233         i=0;
234         while(1) {
235             hres = ITypeInfo_GetFuncDesc(ti, i++, &funcdesc);
236             if(FAILED(hres))
237                 break;
238 
239             add_func_info(data, &size, *tid, funcdesc->memid, dti);
240             ITypeInfo_ReleaseFuncDesc(ti, funcdesc);
241         }
242 
243         ITypeInfo_Release(ti);
244         tid++;
245     }
246 
247     if(!data->func_cnt) {
248         heap_free(data->funcs);
249         data->funcs = NULL;
250     }else if(data->func_cnt != size) {
251         data->funcs = heap_realloc(data->funcs, data->func_cnt * sizeof(func_info_t));
252     }
253 
254     qsort(data->funcs, data->func_cnt, sizeof(func_info_t), dispid_cmp);
255 
256     if(data->funcs) {
257         data->name_table = heap_alloc(data->func_cnt * sizeof(func_info_t*));
258         for(i=0; i < data->func_cnt; i++)
259             data->name_table[i] = data->funcs+i;
260         qsort(data->name_table, data->func_cnt, sizeof(func_info_t*), func_name_cmp);
261     }else {
262         data->name_table = NULL;
263     }
264 
265     ITypeInfo_Release(dti);
266     return data;
267 }
268 
269 static CRITICAL_SECTION cs_dispex_static_data;
270 static CRITICAL_SECTION_DEBUG cs_dispex_static_data_dbg =
271 {
272     0, 0, &cs_dispex_static_data,
273     { &cs_dispex_static_data_dbg.ProcessLocksList, &cs_dispex_static_data_dbg.ProcessLocksList },
274       0, 0, { (DWORD_PTR)(__FILE__ ": dispex_static_data") }
275 };
276 static CRITICAL_SECTION cs_dispex_static_data = { &cs_dispex_static_data_dbg, -1, 0, 0, 0, 0 };
277 
278 
279 static dispex_data_t *get_dispex_data(DispatchEx *This)
280 {
281     if(This->data->data)
282         return This->data->data;
283 
284     EnterCriticalSection(&cs_dispex_static_data);
285 
286     if(!This->data->data)
287         This->data->data = preprocess_dispex_data(This);
288 
289     LeaveCriticalSection(&cs_dispex_static_data);
290 
291     return This->data->data;
292 }
293 
294 static inline BOOL is_custom_dispid(DISPID id)
295 {
296     return MSXML_DISPID_CUSTOM_MIN <= id && id <= MSXML_DISPID_CUSTOM_MAX;
297 }
298 
299 static inline BOOL is_dynamic_dispid(DISPID id)
300 {
301     return DISPID_DYNPROP_0 <= id && id <= DISPID_DYNPROP_MAX;
302 }
303 
304 static inline DispatchEx *impl_from_IDispatchEx(IDispatchEx *iface)
305 {
306     return (DispatchEx*)((char*)iface - FIELD_OFFSET(DispatchEx, lpIDispatchExVtbl));
307 }
308 
309 static HRESULT WINAPI DispatchEx_QueryInterface(IDispatchEx *iface, REFIID riid, void **ppv)
310 {
311     DispatchEx *This = impl_from_IDispatchEx(iface);
312 
313     return IUnknown_QueryInterface(This->outer, riid, ppv);
314 }
315 
316 static ULONG WINAPI DispatchEx_AddRef(IDispatchEx *iface)
317 {
318     DispatchEx *This = impl_from_IDispatchEx(iface);
319 
320     return IUnknown_AddRef(This->outer);
321 }
322 
323 static ULONG WINAPI DispatchEx_Release(IDispatchEx *iface)
324 {
325     DispatchEx *This = impl_from_IDispatchEx(iface);
326 
327     return IUnknown_Release(This->outer);
328 }
329 
330 static HRESULT WINAPI DispatchEx_GetTypeInfoCount(IDispatchEx *iface, UINT *pctinfo)
331 {
332     DispatchEx *This = impl_from_IDispatchEx(iface);
333 
334     TRACE("(%p)->(%p)\n", This, pctinfo);
335 
336     *pctinfo = 1;
337     return S_OK;
338 }
339 
340 static HRESULT WINAPI DispatchEx_GetTypeInfo(IDispatchEx *iface, UINT iTInfo,
341                                               LCID lcid, ITypeInfo **ppTInfo)
342 {
343     DispatchEx *This = impl_from_IDispatchEx(iface);
344 
345     TRACE("(%p)->(%u %u %p)\n", This, iTInfo, lcid, ppTInfo);
346 
347     return get_typeinfo(This->data->disp_tid, ppTInfo);
348 }
349 
350 static HRESULT WINAPI DispatchEx_GetIDsOfNames(IDispatchEx *iface, REFIID riid,
351                                                 LPOLESTR *rgszNames, UINT cNames,
352                                                 LCID lcid, DISPID *rgDispId)
353 {
354     DispatchEx *This = impl_from_IDispatchEx(iface);
355     UINT i;
356     HRESULT hres;
357 
358     TRACE("(%p)->(%s %p %u %u %p)\n", This, debugstr_guid(riid), rgszNames, cNames,
359           lcid, rgDispId);
360 
361     for(i=0; i < cNames; i++) {
362         hres = IDispatchEx_GetDispID(DISPATCHEX(This), rgszNames[i], 0, rgDispId+i);
363         if(FAILED(hres))
364             return hres;
365     }
366 
367     return S_OK;
368 }
369 
370 static HRESULT WINAPI DispatchEx_Invoke(IDispatchEx *iface, DISPID dispIdMember,
371                             REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
372                             VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
373 {
374     DispatchEx *This = impl_from_IDispatchEx(iface);
375 
376     TRACE("(%p)->(%d %s %d %d %p %p %p %p)\n", This, dispIdMember, debugstr_guid(riid),
377           lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
378 
379     return IDispatchEx_InvokeEx(DISPATCHEX(This), dispIdMember, lcid, wFlags,
380                                 pDispParams, pVarResult, pExcepInfo, NULL);
381 }
382 
383 static HRESULT WINAPI DispatchEx_GetDispID(IDispatchEx *iface, BSTR bstrName, DWORD grfdex, DISPID *pid)
384 {
385     DispatchEx *This = impl_from_IDispatchEx(iface);
386     dispex_data_t *data;
387     int min, max, n, c;
388 
389     TRACE("(%p)->(%s %x %p)\n", This, debugstr_w(bstrName), grfdex, pid);
390 
391     if(grfdex & ~(fdexNameCaseSensitive|fdexNameEnsure|fdexNameImplicit))
392         FIXME("Unsupported grfdex %x\n", grfdex);
393 
394     data = get_dispex_data(This);
395     if(!data)
396         return E_FAIL;
397 
398     min = 0;
399     max = data->func_cnt-1;
400 
401     while(min <= max) {
402         n = (min+max)/2;
403 
404         c = strcmpiW(data->name_table[n]->name, bstrName);
405         if(!c) {
406             if((grfdex & fdexNameCaseSensitive) && strcmpW(data->name_table[n]->name, bstrName))
407                 break;
408 
409             *pid = data->name_table[n]->id;
410             return S_OK;
411         }
412 
413         if(c > 0)
414             max = n-1;
415         else
416             min = n+1;
417     }
418 
419     if(This->dynamic_data) {
420         unsigned i;
421 
422         for(i=0; i < This->dynamic_data->prop_cnt; i++) {
423             if(!strcmpW(This->dynamic_data->props[i].name, bstrName)) {
424                 *pid = DISPID_DYNPROP_0 + i;
425                 return S_OK;
426             }
427         }
428     }
429 
430     if(This->data->vtbl && This->data->vtbl->get_dispid) {
431         HRESULT hres;
432 
433         hres = This->data->vtbl->get_dispid(This->outer, bstrName, grfdex, pid);
434         if(hres != DISP_E_UNKNOWNNAME)
435             return hres;
436     }
437 
438     if(grfdex & fdexNameEnsure) {
439         dispex_dynamic_data_t *dynamic_data;
440 
441         TRACE("creating dynamic prop %s\n", debugstr_w(bstrName));
442 
443         if(This->dynamic_data) {
444             dynamic_data = This->dynamic_data;
445         }else {
446             dynamic_data = This->dynamic_data = heap_alloc_zero(sizeof(dispex_dynamic_data_t));
447             if(!dynamic_data)
448                 return E_OUTOFMEMORY;
449         }
450 
451         if(!dynamic_data->buf_size) {
452             dynamic_data->props = heap_alloc(sizeof(dynamic_prop_t)*4);
453             if(!dynamic_data->props)
454                 return E_OUTOFMEMORY;
455             dynamic_data->buf_size = 4;
456         }else if(dynamic_data->buf_size == dynamic_data->prop_cnt) {
457             dynamic_prop_t *new_props;
458 
459             new_props = heap_realloc(dynamic_data->props, sizeof(dynamic_prop_t)*(dynamic_data->buf_size<<1));
460             if(!new_props)
461                 return E_OUTOFMEMORY;
462 
463             dynamic_data->props = new_props;
464             dynamic_data->buf_size <<= 1;
465         }
466 
467         dynamic_data->props[dynamic_data->prop_cnt].name = heap_strdupW(bstrName);
468         VariantInit(&dynamic_data->props[dynamic_data->prop_cnt].var);
469         *pid = DISPID_DYNPROP_0 + dynamic_data->prop_cnt++;
470 
471         return S_OK;
472     }
473 
474     TRACE("not found %s\n", debugstr_w(bstrName));
475     return DISP_E_UNKNOWNNAME;
476 }
477 
478 static HRESULT WINAPI DispatchEx_InvokeEx(IDispatchEx *iface, DISPID id, LCID lcid, WORD wFlags, DISPPARAMS *pdp,
479         VARIANT *pvarRes, EXCEPINFO *pei, IServiceProvider *pspCaller)
480 {
481     DispatchEx *This = impl_from_IDispatchEx(iface);
482     IUnknown *unk;
483     ITypeInfo *ti;
484     dispex_data_t *data;
485     UINT argerr=0;
486     int min, max, n;
487     HRESULT hres;
488 
489     TRACE("(%p)->(%x %x %x %p %p %p %p)\n", This, id, lcid, wFlags, pdp, pvarRes, pei, pspCaller);
490 
491     if(is_custom_dispid(id) && This->data->vtbl && This->data->vtbl->invoke)
492         return This->data->vtbl->invoke(This->outer, id, lcid, wFlags, pdp, pvarRes, pei);
493 
494     if(wFlags == DISPATCH_CONSTRUCT) {
495         FIXME("DISPATCH_CONSTRUCT not implemented\n");
496         return E_NOTIMPL;
497     }
498 
499     if(is_dynamic_dispid(id)) {
500         DWORD idx = id - DISPID_DYNPROP_0;
501         VARIANT *var;
502 
503         if(!This->dynamic_data || This->dynamic_data->prop_cnt <= idx)
504             return DISP_E_UNKNOWNNAME;
505 
506         var = &This->dynamic_data->props[idx].var;
507 
508         switch(wFlags) {
509         case INVOKE_PROPERTYGET:
510             return VariantCopy(pvarRes, var);
511         case INVOKE_PROPERTYPUT:
512             VariantClear(var);
513             return VariantCopy(var, pdp->rgvarg);
514         default:
515             FIXME("unhandled wFlags %x\n", wFlags);
516             return E_NOTIMPL;
517         }
518     }
519 
520     data = get_dispex_data(This);
521     if(!data)
522         return E_FAIL;
523 
524     min = 0;
525     max = data->func_cnt-1;
526 
527     while(min <= max) {
528         n = (min+max)/2;
529 
530         if(data->funcs[n].id == id)
531             break;
532 
533         if(data->funcs[n].id < id)
534             min = n+1;
535         else
536             max = n-1;
537     }
538 
539     if(min > max) {
540         WARN("invalid id %x\n", id);
541         return DISP_E_UNKNOWNNAME;
542     }
543 
544     hres = get_typeinfo(data->funcs[n].tid, &ti);
545     if(FAILED(hres)) {
546         ERR("Could not get type info: %08x\n", hres);
547         return hres;
548     }
549 
550     hres = IUnknown_QueryInterface(This->outer, tid_ids[data->funcs[n].tid], (void**)&unk);
551     if(FAILED(hres)) {
552         ERR("Could not get iface: %08x\n", hres);
553         return E_FAIL;
554     }
555 
556     hres = ITypeInfo_Invoke(ti, unk, id, wFlags, pdp, pvarRes, pei, &argerr);
557 
558     ITypeInfo_Release(ti);
559     IUnknown_Release(unk);
560     return hres;
561 }
562 
563 static HRESULT WINAPI DispatchEx_DeleteMemberByName(IDispatchEx *iface, BSTR bstrName, DWORD grfdex)
564 {
565     DispatchEx *This = impl_from_IDispatchEx(iface);
566     TRACE("Not implemented in native msxml3 (%p)->(%s %x)\n", This, debugstr_w(bstrName), grfdex);
567     return E_NOTIMPL;
568 }
569 
570 static HRESULT WINAPI DispatchEx_DeleteMemberByDispID(IDispatchEx *iface, DISPID id)
571 {
572     DispatchEx *This = impl_from_IDispatchEx(iface);
573     TRACE("Not implemented in native msxml3 (%p)->(%x)\n", This, id);
574     return E_NOTIMPL;
575 }
576 
577 static HRESULT WINAPI DispatchEx_GetMemberProperties(IDispatchEx *iface, DISPID id, DWORD grfdexFetch, DWORD *pgrfdex)
578 {
579     DispatchEx *This = impl_from_IDispatchEx(iface);
580     TRACE("Not implemented in native msxml3 (%p)->(%x %x %p)\n", This, id, grfdexFetch, pgrfdex);
581     return E_NOTIMPL;
582 }
583 
584 static HRESULT WINAPI DispatchEx_GetMemberName(IDispatchEx *iface, DISPID id, BSTR *pbstrName)
585 {
586     DispatchEx *This = impl_from_IDispatchEx(iface);
587     TRACE("Not implemented in native msxml3 (%p)->(%x %p)\n", This, id, pbstrName);
588     return E_NOTIMPL;
589 }
590 
591 static HRESULT WINAPI DispatchEx_GetNextDispID(IDispatchEx *iface, DWORD grfdex, DISPID id, DISPID *pid)
592 {
593     DispatchEx *This = impl_from_IDispatchEx(iface);
594     TRACE(" Not implemented in native msxml3 (%p)->(%x %x %p)\n", This, grfdex, id, pid);
595     return E_NOTIMPL;
596 }
597 
598 static HRESULT WINAPI DispatchEx_GetNameSpaceParent(IDispatchEx *iface, IUnknown **ppunk)
599 {
600     DispatchEx *This = impl_from_IDispatchEx(iface);
601     TRACE("Not implemented in native msxml3 (%p)->(%p)\n", This, ppunk);
602     return E_NOTIMPL;
603 }
604 
605 static IDispatchExVtbl DispatchExVtbl = {
606     DispatchEx_QueryInterface,
607     DispatchEx_AddRef,
608     DispatchEx_Release,
609     DispatchEx_GetTypeInfoCount,
610     DispatchEx_GetTypeInfo,
611     DispatchEx_GetIDsOfNames,
612     DispatchEx_Invoke,
613     DispatchEx_GetDispID,
614     DispatchEx_InvokeEx,
615     DispatchEx_DeleteMemberByName,
616     DispatchEx_DeleteMemberByDispID,
617     DispatchEx_GetMemberProperties,
618     DispatchEx_GetMemberName,
619     DispatchEx_GetNextDispID,
620     DispatchEx_GetNameSpaceParent
621 };
622 
623 BOOL dispex_query_interface(DispatchEx *This, REFIID riid, void **ppv)
624 {
625     static const IID IID_UndocumentedScriptIface =
626         {0x719c3050,0xf9d3,0x11cf,{0xa4,0x93,0x00,0x40,0x05,0x23,0xa8,0xa0}};
627 
628     if(IsEqualGUID(&IID_IDispatch, riid)) {
629         TRACE("(%p)->(IID_IDispatch %p)\n", This, ppv);
630         *ppv = DISPATCHEX(This);
631     }else if(IsEqualGUID(&IID_IDispatchEx, riid)) {
632         TRACE("(%p)->(IID_IDispatchEx %p)\n", This, ppv);
633         *ppv = DISPATCHEX(This);
634     }else if(IsEqualGUID(&IID_UndocumentedScriptIface, riid)) {
635         TRACE("(%p)->(IID_UndocumentedScriptIface %p) returning NULL\n", This, ppv);
636         *ppv = NULL;
637     }else {
638         return FALSE;
639     }
640 
641     if(*ppv)
642         IUnknown_AddRef((IUnknown*)*ppv);
643     return TRUE;
644 }
645 
646 void init_dispex(DispatchEx *dispex, IUnknown *outer, dispex_static_data_t *data)
647 {
648     dispex->lpIDispatchExVtbl = &DispatchExVtbl;
649     dispex->outer = outer;
650     dispex->data = data;
651 }
652 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

This page was automatically generated by the LXR engine.
Visit the LXR main site for more information.