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

~ [ 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.