2008-08-21 23:37:48 +02:00
|
|
|
/*
|
|
|
|
* Copyright 2008 Jacek Caban for CodeWeavers
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
|
|
|
*/
|
|
|
|
|
|
|
|
#define COBJMACROS
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
|
|
|
#include <stdarg.h>
|
2011-02-24 13:11:53 +01:00
|
|
|
#ifdef HAVE_LIBXML2
|
|
|
|
# include <libxml/parser.h>
|
|
|
|
# include <libxml/xmlerror.h>
|
|
|
|
#endif
|
|
|
|
|
2008-08-21 23:37:48 +02:00
|
|
|
#include "windef.h"
|
|
|
|
#include "winbase.h"
|
|
|
|
#include "winuser.h"
|
|
|
|
#include "winnls.h"
|
|
|
|
#include "ole2.h"
|
2010-08-29 23:31:49 +02:00
|
|
|
#include "msxml6.h"
|
2008-08-21 23:37:48 +02:00
|
|
|
#include "wininet.h"
|
|
|
|
#include "urlmon.h"
|
|
|
|
#include "winreg.h"
|
|
|
|
#include "shlwapi.h"
|
|
|
|
|
|
|
|
#include "wine/debug.h"
|
|
|
|
#include "wine/unicode.h"
|
|
|
|
|
|
|
|
#include "msxml_private.h"
|
|
|
|
|
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(msxml);
|
|
|
|
|
2011-11-17 09:53:01 +01:00
|
|
|
static CRITICAL_SECTION cs_dispex_static_data;
|
|
|
|
static CRITICAL_SECTION_DEBUG cs_dispex_static_data_dbg =
|
|
|
|
{
|
|
|
|
0, 0, &cs_dispex_static_data,
|
|
|
|
{ &cs_dispex_static_data_dbg.ProcessLocksList, &cs_dispex_static_data_dbg.ProcessLocksList },
|
|
|
|
0, 0, { (DWORD_PTR)(__FILE__ ": dispex_static_data") }
|
|
|
|
};
|
|
|
|
static CRITICAL_SECTION cs_dispex_static_data = { &cs_dispex_static_data_dbg, -1, 0, 0, 0, 0 };
|
|
|
|
|
|
|
|
|
2011-11-04 09:46:45 +01:00
|
|
|
enum lib_version_t
|
|
|
|
{
|
|
|
|
LibXml = 0,
|
|
|
|
LibXml2,
|
|
|
|
LibXml_Last
|
|
|
|
};
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
REFIID iid;
|
|
|
|
enum lib_version_t lib;
|
|
|
|
} tid_id_t;
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
REFIID iid;
|
|
|
|
unsigned short major;
|
|
|
|
} lib_id_t;
|
|
|
|
|
2008-08-21 23:37:48 +02:00
|
|
|
typedef struct {
|
|
|
|
DISPID id;
|
|
|
|
BSTR name;
|
|
|
|
enum tid_t tid;
|
|
|
|
} func_info_t;
|
|
|
|
|
|
|
|
struct dispex_data_t {
|
|
|
|
DWORD func_cnt;
|
|
|
|
func_info_t *funcs;
|
|
|
|
func_info_t **name_table;
|
|
|
|
|
|
|
|
struct list entry;
|
|
|
|
};
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
VARIANT var;
|
|
|
|
LPWSTR name;
|
|
|
|
} dynamic_prop_t;
|
|
|
|
|
|
|
|
struct dispex_dynamic_data_t {
|
|
|
|
DWORD buf_size;
|
|
|
|
DWORD prop_cnt;
|
|
|
|
dynamic_prop_t *props;
|
|
|
|
};
|
|
|
|
|
|
|
|
#define DISPID_DYNPROP_0 0x50000000
|
|
|
|
#define DISPID_DYNPROP_MAX 0x5fffffff
|
|
|
|
|
|
|
|
static struct list dispex_data_list = LIST_INIT(dispex_data_list);
|
2011-11-04 09:46:45 +01:00
|
|
|
static ITypeLib *typelib[LibXml_Last];
|
2008-08-21 23:37:48 +02:00
|
|
|
static ITypeInfo *typeinfos[LAST_tid];
|
|
|
|
|
2011-11-04 09:46:45 +01:00
|
|
|
/* indexed with lib_version_t values */
|
|
|
|
static lib_id_t lib_ids[] = {
|
|
|
|
{ &LIBID_MSXML, 2 },
|
|
|
|
{ &LIBID_MSXML2, 3 }
|
|
|
|
};
|
|
|
|
|
|
|
|
static tid_id_t tid_ids[] = {
|
|
|
|
{ &IID_NULL, LibXml_Last },
|
|
|
|
{ &IID_IXMLDOMAttribute, LibXml2 },
|
|
|
|
{ &IID_IXMLDOMCDATASection, LibXml2 },
|
|
|
|
{ &IID_IXMLDOMComment, LibXml2 },
|
|
|
|
{ &IID_IXMLDOMDocument, LibXml2 },
|
|
|
|
{ &IID_IXMLDOMDocument2, LibXml2 },
|
2011-11-19 15:00:24 +01:00
|
|
|
{ &IID_IXMLDOMDocument3, LibXml2 },
|
2011-11-04 09:46:45 +01:00
|
|
|
{ &IID_IXMLDOMDocumentFragment, LibXml2 },
|
|
|
|
{ &IID_IXMLDOMDocumentType, LibXml2 },
|
|
|
|
{ &IID_IXMLDOMElement, LibXml2 },
|
|
|
|
{ &IID_IXMLDOMEntityReference, LibXml2 },
|
|
|
|
{ &IID_IXMLDOMImplementation, LibXml2 },
|
|
|
|
{ &IID_IXMLDOMNamedNodeMap, LibXml2 },
|
|
|
|
{ &IID_IXMLDOMNode, LibXml2 },
|
|
|
|
{ &IID_IXMLDOMNodeList, LibXml2 },
|
2011-12-14 13:42:23 +01:00
|
|
|
{ &IID_IXMLDOMParseError2, LibXml2 },
|
2011-11-04 09:46:45 +01:00
|
|
|
{ &IID_IXMLDOMProcessingInstruction, LibXml2 },
|
|
|
|
{ &IID_IXMLDOMSchemaCollection, LibXml2 },
|
2011-12-11 11:58:24 +01:00
|
|
|
{ &IID_IXMLDOMSchemaCollection2, LibXml2 },
|
2011-11-04 09:46:45 +01:00
|
|
|
{ &IID_IXMLDOMSelection, LibXml2 },
|
|
|
|
{ &IID_IXMLDOMText, LibXml2 },
|
|
|
|
{ &IID_IXMLElement, LibXml },
|
|
|
|
{ &IID_IXMLDocument, LibXml },
|
|
|
|
{ &IID_IXMLHTTPRequest, LibXml2 },
|
|
|
|
{ &IID_IXSLProcessor, LibXml2 },
|
|
|
|
{ &IID_IXSLTemplate, LibXml2 },
|
|
|
|
{ &IID_IVBSAXAttributes, LibXml2 },
|
|
|
|
{ &IID_IVBSAXContentHandler, LibXml2 },
|
|
|
|
{ &IID_IVBSAXDeclHandler, LibXml2 },
|
|
|
|
{ &IID_IVBSAXDTDHandler, LibXml2 },
|
|
|
|
{ &IID_IVBSAXEntityResolver, LibXml2 },
|
|
|
|
{ &IID_IVBSAXErrorHandler, LibXml2 },
|
|
|
|
{ &IID_IVBSAXLexicalHandler, LibXml2 },
|
|
|
|
{ &IID_IVBSAXLocator, LibXml2 },
|
|
|
|
{ &IID_IVBSAXXMLFilter, LibXml2 },
|
|
|
|
{ &IID_IVBSAXXMLReader, LibXml2 },
|
|
|
|
{ &IID_IMXAttributes, LibXml2 },
|
|
|
|
{ &IID_IMXReaderControl, LibXml2 },
|
|
|
|
{ &IID_IMXWriter, LibXml2 },
|
2012-05-19 09:35:16 +02:00
|
|
|
{ &IID_IVBMXNamespaceManager, LibXml2 },
|
|
|
|
{ &IID_IServerXMLHTTPRequest, LibXml2 }
|
2008-08-21 23:37:48 +02:00
|
|
|
};
|
|
|
|
|
2011-11-22 18:19:31 +01:00
|
|
|
const IID *get_riid_from_tid(tid_t tid)
|
2011-11-19 14:33:10 +01:00
|
|
|
{
|
|
|
|
return tid_ids[tid].iid;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline unsigned get_libid_from_tid(tid_t tid)
|
|
|
|
{
|
|
|
|
return tid_ids[tid].lib;
|
|
|
|
}
|
|
|
|
|
2008-08-21 23:37:48 +02:00
|
|
|
HRESULT get_typeinfo(enum tid_t tid, ITypeInfo **typeinfo)
|
|
|
|
{
|
2011-11-19 14:33:10 +01:00
|
|
|
unsigned lib = get_libid_from_tid(tid);
|
2008-08-21 23:37:48 +02:00
|
|
|
HRESULT hres;
|
|
|
|
|
2011-11-04 09:46:45 +01:00
|
|
|
if(!typelib[lib]) {
|
2008-08-21 23:37:48 +02:00
|
|
|
ITypeLib *tl;
|
|
|
|
|
2011-11-04 09:46:45 +01:00
|
|
|
hres = LoadRegTypeLib(lib_ids[lib].iid, lib_ids[lib].major, 0, LOCALE_SYSTEM_DEFAULT, &tl);
|
2008-08-21 23:37:48 +02:00
|
|
|
if(FAILED(hres)) {
|
|
|
|
ERR("LoadRegTypeLib failed: %08x\n", hres);
|
|
|
|
return hres;
|
|
|
|
}
|
|
|
|
|
2011-11-04 09:46:45 +01:00
|
|
|
if(InterlockedCompareExchangePointer((void**)&typelib[lib], tl, NULL))
|
2008-08-21 23:37:48 +02:00
|
|
|
ITypeLib_Release(tl);
|
|
|
|
}
|
|
|
|
|
|
|
|
if(!typeinfos[tid]) {
|
2011-03-09 10:07:56 +01:00
|
|
|
ITypeInfo *ti;
|
2008-08-21 23:37:48 +02:00
|
|
|
|
2011-11-19 14:33:10 +01:00
|
|
|
hres = ITypeLib_GetTypeInfoOfGuid(typelib[lib], get_riid_from_tid(tid), &ti);
|
2008-08-21 23:37:48 +02:00
|
|
|
if(FAILED(hres)) {
|
2011-11-04 09:46:45 +01:00
|
|
|
/* try harder with typelib from msxml.dll */
|
2011-11-19 14:33:10 +01:00
|
|
|
hres = ITypeLib_GetTypeInfoOfGuid(typelib[LibXml], get_riid_from_tid(tid), &ti);
|
2011-11-04 09:46:45 +01:00
|
|
|
if(FAILED(hres)) {
|
|
|
|
ERR("GetTypeInfoOfGuid failed: %08x\n", hres);
|
|
|
|
return hres;
|
|
|
|
}
|
2008-08-21 23:37:48 +02:00
|
|
|
}
|
|
|
|
|
2011-03-09 10:07:56 +01:00
|
|
|
if(InterlockedCompareExchangePointer((void**)(typeinfos+tid), ti, NULL))
|
|
|
|
ITypeInfo_Release(ti);
|
2008-08-21 23:37:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
*typeinfo = typeinfos[tid];
|
2012-11-29 13:32:38 +01:00
|
|
|
|
|
|
|
ITypeInfo_AddRef(typeinfos[tid]);
|
2008-08-21 23:37:48 +02:00
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
void release_typelib(void)
|
|
|
|
{
|
|
|
|
dispex_data_t *iter;
|
|
|
|
unsigned i;
|
|
|
|
|
|
|
|
while(!list_empty(&dispex_data_list)) {
|
|
|
|
iter = LIST_ENTRY(list_head(&dispex_data_list), dispex_data_t, entry);
|
|
|
|
list_remove(&iter->entry);
|
|
|
|
|
|
|
|
for(i=0; i < iter->func_cnt; i++)
|
|
|
|
SysFreeString(iter->funcs[i].name);
|
|
|
|
|
|
|
|
heap_free(iter->funcs);
|
|
|
|
heap_free(iter->name_table);
|
|
|
|
heap_free(iter);
|
|
|
|
}
|
|
|
|
|
|
|
|
for(i=0; i < sizeof(typeinfos)/sizeof(*typeinfos); i++)
|
|
|
|
if(typeinfos[i])
|
|
|
|
ITypeInfo_Release(typeinfos[i]);
|
|
|
|
|
2011-11-04 09:46:45 +01:00
|
|
|
for(i=0; i < sizeof(typelib)/sizeof(*typelib); i++)
|
|
|
|
if(typelib[i])
|
|
|
|
ITypeLib_Release(typelib[i]);
|
2011-11-17 09:53:01 +01:00
|
|
|
|
|
|
|
DeleteCriticalSection(&cs_dispex_static_data);
|
2008-08-21 23:37:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static void add_func_info(dispex_data_t *data, DWORD *size, tid_t tid, DISPID id, ITypeInfo *dti)
|
|
|
|
{
|
|
|
|
HRESULT hres;
|
|
|
|
|
|
|
|
if(data->func_cnt && data->funcs[data->func_cnt-1].id == id)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if(data->func_cnt == *size)
|
|
|
|
data->funcs = heap_realloc(data->funcs, (*size <<= 1)*sizeof(func_info_t));
|
|
|
|
|
|
|
|
hres = ITypeInfo_GetDocumentation(dti, id, &data->funcs[data->func_cnt].name, NULL, NULL, NULL);
|
|
|
|
if(FAILED(hres))
|
|
|
|
return;
|
|
|
|
|
|
|
|
data->funcs[data->func_cnt].id = id;
|
|
|
|
data->funcs[data->func_cnt].tid = tid;
|
|
|
|
|
|
|
|
data->func_cnt++;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int dispid_cmp(const void *p1, const void *p2)
|
|
|
|
{
|
2010-03-27 16:19:45 +01:00
|
|
|
return ((const func_info_t*)p1)->id - ((const func_info_t*)p2)->id;
|
2008-08-21 23:37:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static int func_name_cmp(const void *p1, const void *p2)
|
|
|
|
{
|
2010-03-27 16:19:45 +01:00
|
|
|
return strcmpiW((*(func_info_t* const*)p1)->name, (*(func_info_t* const*)p2)->name);
|
2008-08-21 23:37:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static dispex_data_t *preprocess_dispex_data(DispatchEx *This)
|
|
|
|
{
|
|
|
|
const tid_t *tid = This->data->iface_tids;
|
|
|
|
FUNCDESC *funcdesc;
|
|
|
|
dispex_data_t *data;
|
|
|
|
DWORD size = 16, i;
|
|
|
|
ITypeInfo *ti, *dti;
|
|
|
|
HRESULT hres;
|
|
|
|
|
|
|
|
TRACE("(%p)\n", This);
|
|
|
|
|
|
|
|
hres = get_typeinfo(This->data->disp_tid, &dti);
|
|
|
|
if(FAILED(hres)) {
|
|
|
|
ERR("Could not get disp type info: %08x\n", hres);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
data = heap_alloc(sizeof(dispex_data_t));
|
|
|
|
data->func_cnt = 0;
|
|
|
|
data->funcs = heap_alloc(size*sizeof(func_info_t));
|
|
|
|
list_add_tail(&dispex_data_list, &data->entry);
|
|
|
|
|
|
|
|
while(*tid) {
|
|
|
|
hres = get_typeinfo(*tid, &ti);
|
|
|
|
if(FAILED(hres))
|
|
|
|
break;
|
|
|
|
|
|
|
|
i=0;
|
|
|
|
while(1) {
|
|
|
|
hres = ITypeInfo_GetFuncDesc(ti, i++, &funcdesc);
|
|
|
|
if(FAILED(hres))
|
|
|
|
break;
|
|
|
|
|
|
|
|
add_func_info(data, &size, *tid, funcdesc->memid, dti);
|
|
|
|
ITypeInfo_ReleaseFuncDesc(ti, funcdesc);
|
|
|
|
}
|
|
|
|
|
2012-11-29 13:32:38 +01:00
|
|
|
ITypeInfo_Release(ti);
|
2008-08-21 23:37:48 +02:00
|
|
|
tid++;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(!data->func_cnt) {
|
|
|
|
heap_free(data->funcs);
|
|
|
|
data->funcs = NULL;
|
|
|
|
}else if(data->func_cnt != size) {
|
|
|
|
data->funcs = heap_realloc(data->funcs, data->func_cnt * sizeof(func_info_t));
|
|
|
|
}
|
|
|
|
|
|
|
|
qsort(data->funcs, data->func_cnt, sizeof(func_info_t), dispid_cmp);
|
|
|
|
|
|
|
|
if(data->funcs) {
|
|
|
|
data->name_table = heap_alloc(data->func_cnt * sizeof(func_info_t*));
|
|
|
|
for(i=0; i < data->func_cnt; i++)
|
|
|
|
data->name_table[i] = data->funcs+i;
|
|
|
|
qsort(data->name_table, data->func_cnt, sizeof(func_info_t*), func_name_cmp);
|
|
|
|
}else {
|
|
|
|
data->name_table = NULL;
|
|
|
|
}
|
|
|
|
|
2012-11-29 13:32:38 +01:00
|
|
|
ITypeInfo_Release(dti);
|
2008-08-21 23:37:48 +02:00
|
|
|
return data;
|
|
|
|
}
|
|
|
|
|
|
|
|
static dispex_data_t *get_dispex_data(DispatchEx *This)
|
|
|
|
{
|
|
|
|
if(This->data->data)
|
|
|
|
return This->data->data;
|
|
|
|
|
|
|
|
EnterCriticalSection(&cs_dispex_static_data);
|
|
|
|
|
|
|
|
if(!This->data->data)
|
|
|
|
This->data->data = preprocess_dispex_data(This);
|
|
|
|
|
|
|
|
LeaveCriticalSection(&cs_dispex_static_data);
|
|
|
|
|
|
|
|
return This->data->data;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline BOOL is_dynamic_dispid(DISPID id)
|
|
|
|
{
|
|
|
|
return DISPID_DYNPROP_0 <= id && id <= DISPID_DYNPROP_MAX;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline DispatchEx *impl_from_IDispatchEx(IDispatchEx *iface)
|
|
|
|
{
|
2011-02-23 23:15:47 +01:00
|
|
|
return CONTAINING_RECORD(iface, DispatchEx, IDispatchEx_iface);
|
2008-08-21 23:37:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI DispatchEx_QueryInterface(IDispatchEx *iface, REFIID riid, void **ppv)
|
|
|
|
{
|
|
|
|
DispatchEx *This = impl_from_IDispatchEx(iface);
|
|
|
|
|
|
|
|
return IUnknown_QueryInterface(This->outer, riid, ppv);
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI DispatchEx_AddRef(IDispatchEx *iface)
|
|
|
|
{
|
|
|
|
DispatchEx *This = impl_from_IDispatchEx(iface);
|
|
|
|
|
|
|
|
return IUnknown_AddRef(This->outer);
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI DispatchEx_Release(IDispatchEx *iface)
|
|
|
|
{
|
|
|
|
DispatchEx *This = impl_from_IDispatchEx(iface);
|
|
|
|
|
|
|
|
return IUnknown_Release(This->outer);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI DispatchEx_GetTypeInfoCount(IDispatchEx *iface, UINT *pctinfo)
|
|
|
|
{
|
|
|
|
DispatchEx *This = impl_from_IDispatchEx(iface);
|
|
|
|
|
|
|
|
TRACE("(%p)->(%p)\n", This, pctinfo);
|
|
|
|
|
|
|
|
*pctinfo = 1;
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI DispatchEx_GetTypeInfo(IDispatchEx *iface, UINT iTInfo,
|
2012-11-29 13:32:38 +01:00
|
|
|
LCID lcid, ITypeInfo **ppTInfo)
|
2008-08-21 23:37:48 +02:00
|
|
|
{
|
|
|
|
DispatchEx *This = impl_from_IDispatchEx(iface);
|
|
|
|
|
2012-11-29 13:32:38 +01:00
|
|
|
TRACE("(%p)->(%u %u %p)\n", This, iTInfo, lcid, ppTInfo);
|
2008-08-21 23:37:48 +02:00
|
|
|
|
2012-11-29 13:32:38 +01:00
|
|
|
return get_typeinfo(This->data->disp_tid, ppTInfo);
|
2008-08-21 23:37:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI DispatchEx_GetIDsOfNames(IDispatchEx *iface, REFIID riid,
|
|
|
|
LPOLESTR *rgszNames, UINT cNames,
|
|
|
|
LCID lcid, DISPID *rgDispId)
|
|
|
|
{
|
|
|
|
DispatchEx *This = impl_from_IDispatchEx(iface);
|
|
|
|
UINT i;
|
|
|
|
HRESULT hres;
|
|
|
|
|
|
|
|
TRACE("(%p)->(%s %p %u %u %p)\n", This, debugstr_guid(riid), rgszNames, cNames,
|
|
|
|
lcid, rgDispId);
|
|
|
|
|
|
|
|
for(i=0; i < cNames; i++) {
|
2011-02-23 23:15:47 +01:00
|
|
|
hres = IDispatchEx_GetDispID(&This->IDispatchEx_iface, rgszNames[i], 0, rgDispId+i);
|
2008-08-21 23:37:48 +02:00
|
|
|
if(FAILED(hres))
|
|
|
|
return hres;
|
|
|
|
}
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI DispatchEx_Invoke(IDispatchEx *iface, DISPID dispIdMember,
|
|
|
|
REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
|
|
|
|
VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
|
|
|
|
{
|
|
|
|
DispatchEx *This = impl_from_IDispatchEx(iface);
|
|
|
|
|
|
|
|
TRACE("(%p)->(%d %s %d %d %p %p %p %p)\n", This, dispIdMember, debugstr_guid(riid),
|
|
|
|
lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
|
|
|
|
|
2011-02-23 23:15:47 +01:00
|
|
|
return IDispatchEx_InvokeEx(&This->IDispatchEx_iface, dispIdMember, lcid, wFlags,
|
2008-08-21 23:37:48 +02:00
|
|
|
pDispParams, pVarResult, pExcepInfo, NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI DispatchEx_GetDispID(IDispatchEx *iface, BSTR bstrName, DWORD grfdex, DISPID *pid)
|
|
|
|
{
|
|
|
|
DispatchEx *This = impl_from_IDispatchEx(iface);
|
|
|
|
dispex_data_t *data;
|
|
|
|
int min, max, n, c;
|
|
|
|
|
|
|
|
TRACE("(%p)->(%s %x %p)\n", This, debugstr_w(bstrName), grfdex, pid);
|
|
|
|
|
|
|
|
if(grfdex & ~(fdexNameCaseSensitive|fdexNameEnsure|fdexNameImplicit))
|
|
|
|
FIXME("Unsupported grfdex %x\n", grfdex);
|
|
|
|
|
|
|
|
data = get_dispex_data(This);
|
|
|
|
if(!data)
|
|
|
|
return E_FAIL;
|
|
|
|
|
|
|
|
min = 0;
|
|
|
|
max = data->func_cnt-1;
|
|
|
|
|
|
|
|
while(min <= max) {
|
|
|
|
n = (min+max)/2;
|
|
|
|
|
|
|
|
c = strcmpiW(data->name_table[n]->name, bstrName);
|
|
|
|
if(!c) {
|
|
|
|
if((grfdex & fdexNameCaseSensitive) && strcmpW(data->name_table[n]->name, bstrName))
|
|
|
|
break;
|
|
|
|
|
|
|
|
*pid = data->name_table[n]->id;
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(c > 0)
|
|
|
|
max = n-1;
|
|
|
|
else
|
|
|
|
min = n+1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(This->dynamic_data) {
|
|
|
|
unsigned i;
|
|
|
|
|
|
|
|
for(i=0; i < This->dynamic_data->prop_cnt; i++) {
|
|
|
|
if(!strcmpW(This->dynamic_data->props[i].name, bstrName)) {
|
|
|
|
*pid = DISPID_DYNPROP_0 + i;
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if(This->data->vtbl && This->data->vtbl->get_dispid) {
|
|
|
|
HRESULT hres;
|
|
|
|
|
|
|
|
hres = This->data->vtbl->get_dispid(This->outer, bstrName, grfdex, pid);
|
|
|
|
if(hres != DISP_E_UNKNOWNNAME)
|
|
|
|
return hres;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(grfdex & fdexNameEnsure) {
|
2008-10-16 20:55:47 +02:00
|
|
|
dispex_dynamic_data_t *dynamic_data;
|
|
|
|
|
2008-08-21 23:37:48 +02:00
|
|
|
TRACE("creating dynamic prop %s\n", debugstr_w(bstrName));
|
|
|
|
|
2008-10-16 20:55:47 +02:00
|
|
|
if(This->dynamic_data) {
|
|
|
|
dynamic_data = This->dynamic_data;
|
|
|
|
}else {
|
|
|
|
dynamic_data = This->dynamic_data = heap_alloc_zero(sizeof(dispex_dynamic_data_t));
|
|
|
|
if(!dynamic_data)
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(!dynamic_data->buf_size) {
|
|
|
|
dynamic_data->props = heap_alloc(sizeof(dynamic_prop_t)*4);
|
|
|
|
if(!dynamic_data->props)
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
dynamic_data->buf_size = 4;
|
|
|
|
}else if(dynamic_data->buf_size == dynamic_data->prop_cnt) {
|
|
|
|
dynamic_prop_t *new_props;
|
|
|
|
|
|
|
|
new_props = heap_realloc(dynamic_data->props, sizeof(dynamic_prop_t)*(dynamic_data->buf_size<<1));
|
|
|
|
if(!new_props)
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
|
|
|
|
dynamic_data->props = new_props;
|
|
|
|
dynamic_data->buf_size <<= 1;
|
2008-08-21 23:37:48 +02:00
|
|
|
}
|
|
|
|
|
2008-10-16 20:55:47 +02:00
|
|
|
dynamic_data->props[dynamic_data->prop_cnt].name = heap_strdupW(bstrName);
|
|
|
|
VariantInit(&dynamic_data->props[dynamic_data->prop_cnt].var);
|
|
|
|
*pid = DISPID_DYNPROP_0 + dynamic_data->prop_cnt++;
|
2008-08-21 23:37:48 +02:00
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
TRACE("not found %s\n", debugstr_w(bstrName));
|
|
|
|
return DISP_E_UNKNOWNNAME;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI DispatchEx_InvokeEx(IDispatchEx *iface, DISPID id, LCID lcid, WORD wFlags, DISPPARAMS *pdp,
|
|
|
|
VARIANT *pvarRes, EXCEPINFO *pei, IServiceProvider *pspCaller)
|
|
|
|
{
|
|
|
|
DispatchEx *This = impl_from_IDispatchEx(iface);
|
|
|
|
IUnknown *unk;
|
|
|
|
ITypeInfo *ti;
|
|
|
|
dispex_data_t *data;
|
|
|
|
UINT argerr=0;
|
|
|
|
int min, max, n;
|
|
|
|
HRESULT hres;
|
|
|
|
|
|
|
|
TRACE("(%p)->(%x %x %x %p %p %p %p)\n", This, id, lcid, wFlags, pdp, pvarRes, pei, pspCaller);
|
|
|
|
|
2011-11-04 16:59:05 +01:00
|
|
|
if(This->data->vtbl && This->data->vtbl->invoke) {
|
|
|
|
hres = This->data->vtbl->invoke(This->outer, id, lcid, wFlags, pdp, pvarRes, pei);
|
|
|
|
if (hres != DISP_E_UNKNOWNNAME) return hres;
|
|
|
|
}
|
2008-08-21 23:37:48 +02:00
|
|
|
|
|
|
|
if(wFlags == DISPATCH_CONSTRUCT) {
|
|
|
|
FIXME("DISPATCH_CONSTRUCT not implemented\n");
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(is_dynamic_dispid(id)) {
|
|
|
|
DWORD idx = id - DISPID_DYNPROP_0;
|
|
|
|
VARIANT *var;
|
|
|
|
|
|
|
|
if(!This->dynamic_data || This->dynamic_data->prop_cnt <= idx)
|
|
|
|
return DISP_E_UNKNOWNNAME;
|
|
|
|
|
|
|
|
var = &This->dynamic_data->props[idx].var;
|
|
|
|
|
|
|
|
switch(wFlags) {
|
|
|
|
case INVOKE_PROPERTYGET:
|
2011-12-14 12:51:30 +01:00
|
|
|
V_VT(pvarRes) = VT_EMPTY;
|
2008-08-21 23:37:48 +02:00
|
|
|
return VariantCopy(pvarRes, var);
|
|
|
|
case INVOKE_PROPERTYPUT:
|
|
|
|
VariantClear(var);
|
|
|
|
return VariantCopy(var, pdp->rgvarg);
|
|
|
|
default:
|
|
|
|
FIXME("unhandled wFlags %x\n", wFlags);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
data = get_dispex_data(This);
|
|
|
|
if(!data)
|
|
|
|
return E_FAIL;
|
|
|
|
|
|
|
|
min = 0;
|
|
|
|
max = data->func_cnt-1;
|
|
|
|
|
|
|
|
while(min <= max) {
|
|
|
|
n = (min+max)/2;
|
|
|
|
|
|
|
|
if(data->funcs[n].id == id)
|
|
|
|
break;
|
|
|
|
|
|
|
|
if(data->funcs[n].id < id)
|
|
|
|
min = n+1;
|
|
|
|
else
|
|
|
|
max = n-1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(min > max) {
|
|
|
|
WARN("invalid id %x\n", id);
|
|
|
|
return DISP_E_UNKNOWNNAME;
|
|
|
|
}
|
|
|
|
|
|
|
|
hres = get_typeinfo(data->funcs[n].tid, &ti);
|
|
|
|
if(FAILED(hres)) {
|
|
|
|
ERR("Could not get type info: %08x\n", hres);
|
|
|
|
return hres;
|
|
|
|
}
|
|
|
|
|
2011-11-19 14:33:10 +01:00
|
|
|
hres = IUnknown_QueryInterface(This->outer, get_riid_from_tid(data->funcs[n].tid), (void**)&unk);
|
2008-08-21 23:37:48 +02:00
|
|
|
if(FAILED(hres)) {
|
|
|
|
ERR("Could not get iface: %08x\n", hres);
|
2012-11-29 13:35:19 +01:00
|
|
|
ITypeInfo_Release(ti);
|
2008-08-21 23:37:48 +02:00
|
|
|
return E_FAIL;
|
|
|
|
}
|
|
|
|
|
|
|
|
hres = ITypeInfo_Invoke(ti, unk, id, wFlags, pdp, pvarRes, pei, &argerr);
|
|
|
|
|
2012-11-29 13:32:38 +01:00
|
|
|
ITypeInfo_Release(ti);
|
2008-08-21 23:37:48 +02:00
|
|
|
IUnknown_Release(unk);
|
|
|
|
return hres;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI DispatchEx_DeleteMemberByName(IDispatchEx *iface, BSTR bstrName, DWORD grfdex)
|
|
|
|
{
|
|
|
|
DispatchEx *This = impl_from_IDispatchEx(iface);
|
2008-08-27 08:33:40 +02:00
|
|
|
TRACE("Not implemented in native msxml3 (%p)->(%s %x)\n", This, debugstr_w(bstrName), grfdex);
|
|
|
|
return E_NOTIMPL;
|
2008-08-21 23:37:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI DispatchEx_DeleteMemberByDispID(IDispatchEx *iface, DISPID id)
|
|
|
|
{
|
|
|
|
DispatchEx *This = impl_from_IDispatchEx(iface);
|
2008-08-27 08:33:40 +02:00
|
|
|
TRACE("Not implemented in native msxml3 (%p)->(%x)\n", This, id);
|
2008-08-21 23:37:48 +02:00
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI DispatchEx_GetMemberProperties(IDispatchEx *iface, DISPID id, DWORD grfdexFetch, DWORD *pgrfdex)
|
|
|
|
{
|
|
|
|
DispatchEx *This = impl_from_IDispatchEx(iface);
|
2008-08-27 08:33:40 +02:00
|
|
|
TRACE("Not implemented in native msxml3 (%p)->(%x %x %p)\n", This, id, grfdexFetch, pgrfdex);
|
2008-08-21 23:37:48 +02:00
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI DispatchEx_GetMemberName(IDispatchEx *iface, DISPID id, BSTR *pbstrName)
|
|
|
|
{
|
|
|
|
DispatchEx *This = impl_from_IDispatchEx(iface);
|
2008-08-27 08:33:40 +02:00
|
|
|
TRACE("Not implemented in native msxml3 (%p)->(%x %p)\n", This, id, pbstrName);
|
2008-08-21 23:37:48 +02:00
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI DispatchEx_GetNextDispID(IDispatchEx *iface, DWORD grfdex, DISPID id, DISPID *pid)
|
|
|
|
{
|
|
|
|
DispatchEx *This = impl_from_IDispatchEx(iface);
|
2008-08-27 08:33:40 +02:00
|
|
|
TRACE(" Not implemented in native msxml3 (%p)->(%x %x %p)\n", This, grfdex, id, pid);
|
2008-08-21 23:37:48 +02:00
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI DispatchEx_GetNameSpaceParent(IDispatchEx *iface, IUnknown **ppunk)
|
|
|
|
{
|
|
|
|
DispatchEx *This = impl_from_IDispatchEx(iface);
|
2008-08-27 08:33:40 +02:00
|
|
|
TRACE("Not implemented in native msxml3 (%p)->(%p)\n", This, ppunk);
|
2008-08-21 23:37:48 +02:00
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static IDispatchExVtbl DispatchExVtbl = {
|
|
|
|
DispatchEx_QueryInterface,
|
|
|
|
DispatchEx_AddRef,
|
|
|
|
DispatchEx_Release,
|
|
|
|
DispatchEx_GetTypeInfoCount,
|
|
|
|
DispatchEx_GetTypeInfo,
|
|
|
|
DispatchEx_GetIDsOfNames,
|
|
|
|
DispatchEx_Invoke,
|
|
|
|
DispatchEx_GetDispID,
|
|
|
|
DispatchEx_InvokeEx,
|
|
|
|
DispatchEx_DeleteMemberByName,
|
|
|
|
DispatchEx_DeleteMemberByDispID,
|
|
|
|
DispatchEx_GetMemberProperties,
|
|
|
|
DispatchEx_GetMemberName,
|
|
|
|
DispatchEx_GetNextDispID,
|
|
|
|
DispatchEx_GetNameSpaceParent
|
|
|
|
};
|
|
|
|
|
|
|
|
BOOL dispex_query_interface(DispatchEx *This, REFIID riid, void **ppv)
|
|
|
|
{
|
|
|
|
static const IID IID_UndocumentedScriptIface =
|
|
|
|
{0x719c3050,0xf9d3,0x11cf,{0xa4,0x93,0x00,0x40,0x05,0x23,0xa8,0xa0}};
|
2011-11-01 21:52:32 +01:00
|
|
|
static const IID IID_IDispatchJS =
|
|
|
|
{0x719c3050,0xf9d3,0x11cf,{0xa4,0x93,0x00,0x40,0x05,0x23,0xa8,0xa6}};
|
2008-08-21 23:37:48 +02:00
|
|
|
|
|
|
|
if(IsEqualGUID(&IID_IDispatch, riid)) {
|
|
|
|
TRACE("(%p)->(IID_IDispatch %p)\n", This, ppv);
|
2011-02-23 23:15:47 +01:00
|
|
|
*ppv = &This->IDispatchEx_iface;
|
2008-08-21 23:37:48 +02:00
|
|
|
}else if(IsEqualGUID(&IID_IDispatchEx, riid)) {
|
|
|
|
TRACE("(%p)->(IID_IDispatchEx %p)\n", This, ppv);
|
2011-02-23 23:15:47 +01:00
|
|
|
*ppv = &This->IDispatchEx_iface;
|
2011-11-01 21:52:32 +01:00
|
|
|
}else if(IsEqualGUID(&IID_IDispatchJS, riid)) {
|
|
|
|
TRACE("(%p)->(IID_IDispatchJS %p) returning NULL\n", This, ppv);
|
|
|
|
*ppv = NULL;
|
2008-08-21 23:37:48 +02:00
|
|
|
}else if(IsEqualGUID(&IID_UndocumentedScriptIface, riid)) {
|
|
|
|
TRACE("(%p)->(IID_UndocumentedScriptIface %p) returning NULL\n", This, ppv);
|
|
|
|
*ppv = NULL;
|
2009-08-12 12:47:26 +02:00
|
|
|
}else if (IsEqualGUID(&IID_IObjectIdentity, riid)) {
|
|
|
|
TRACE("IID_IObjectIdentity not supported returning NULL\n");
|
|
|
|
*ppv = NULL;
|
2008-08-21 23:37:48 +02:00
|
|
|
}else {
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(*ppv)
|
|
|
|
IUnknown_AddRef((IUnknown*)*ppv);
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2011-10-29 23:27:50 +02:00
|
|
|
void release_dispex(DispatchEx *This)
|
|
|
|
{
|
|
|
|
dynamic_prop_t *prop;
|
|
|
|
|
|
|
|
if(!This->dynamic_data)
|
|
|
|
return;
|
|
|
|
|
|
|
|
for(prop = This->dynamic_data->props; prop < This->dynamic_data->props + This->dynamic_data->prop_cnt; prop++) {
|
|
|
|
VariantClear(&prop->var);
|
|
|
|
heap_free(prop->name);
|
|
|
|
}
|
|
|
|
|
|
|
|
heap_free(This->dynamic_data->props);
|
|
|
|
heap_free(This->dynamic_data);
|
|
|
|
}
|
|
|
|
|
2008-08-21 23:37:48 +02:00
|
|
|
void init_dispex(DispatchEx *dispex, IUnknown *outer, dispex_static_data_t *data)
|
|
|
|
{
|
2011-02-23 23:15:47 +01:00
|
|
|
dispex->IDispatchEx_iface.lpVtbl = &DispatchExVtbl;
|
2008-08-21 23:37:48 +02:00
|
|
|
dispex->outer = outer;
|
|
|
|
dispex->data = data;
|
2011-10-28 22:43:00 +02:00
|
|
|
dispex->dynamic_data = NULL;
|
2008-08-21 23:37:48 +02:00
|
|
|
}
|