Commit be59368d authored by Jacek Caban's avatar Jacek Caban Committed by Alexandre Julliard

mshtml: Move get_typeinfo to dispex.c.

parent ed6a8acc
...@@ -31,6 +31,61 @@ ...@@ -31,6 +31,61 @@
WINE_DEFAULT_DEBUG_CHANNEL(mshtml); WINE_DEFAULT_DEBUG_CHANNEL(mshtml);
static ITypeLib *typelib;
static ITypeInfo *typeinfos[LAST_tid];
static REFIID tid_ids[] = {
&IID_IHTMLWindow2,
};
HRESULT get_typeinfo(tid_t tid, ITypeInfo **typeinfo)
{
HRESULT hres;
if(!typelib) {
ITypeLib *tl;
hres = LoadRegTypeLib(&LIBID_MSHTML, 4, 0, LOCALE_SYSTEM_DEFAULT, &tl);
if(FAILED(hres)) {
ERR("LoadRegTypeLib failed: %08x\n", hres);
return hres;
}
if(InterlockedCompareExchangePointer((void**)&typelib, tl, NULL))
ITypeLib_Release(tl);
}
if(!typeinfos[tid]) {
ITypeInfo *typeinfo;
hres = ITypeLib_GetTypeInfoOfGuid(typelib, tid_ids[tid], &typeinfo);
if(FAILED(hres)) {
ERR("GetTypeInfoOfGuid failed: %08x\n", hres);
return hres;
}
if(InterlockedCompareExchangePointer((void**)(typeinfos+tid), typeinfo, NULL))
ITypeInfo_Release(typeinfo);
}
*typeinfo = typeinfos[tid];
return S_OK;
}
void release_typelib(void)
{
unsigned i;
if(!typelib)
return;
for(i=0; i < sizeof(typeinfos)/sizeof(*typeinfos); i++)
if(typeinfos[i])
ITypeInfo_Release(typeinfos[i]);
ITypeLib_Release(typelib);
}
#define DISPATCHEX_THIS(iface) DEFINE_THIS(DispatchEx, IDispatchEx, iface) #define DISPATCHEX_THIS(iface) DEFINE_THIS(DispatchEx, IDispatchEx, iface)
static HRESULT WINAPI DispatchEx_QueryInterface(IDispatchEx *iface, REFIID riid, void **ppv) static HRESULT WINAPI DispatchEx_QueryInterface(IDispatchEx *iface, REFIID riid, void **ppv)
......
...@@ -49,47 +49,6 @@ DWORD mshtml_tls = 0; ...@@ -49,47 +49,6 @@ DWORD mshtml_tls = 0;
static HINSTANCE shdoclc = NULL; static HINSTANCE shdoclc = NULL;
static ITypeLib *typelib;
static ITypeInfo *typeinfos[LAST_tid];
static REFIID tid_ids[] = {
&IID_IHTMLWindow2
};
HRESULT get_typeinfo(enum tid_t tid, ITypeInfo **typeinfo)
{
HRESULT hres;
if(!typelib) {
ITypeLib *tl;
hres = LoadRegTypeLib(&LIBID_MSHTML, 4, 0, LOCALE_SYSTEM_DEFAULT, &tl);
if(FAILED(hres)) {
ERR("LoadRegTypeLib failed: %08x\n", hres);
return hres;
}
if(InterlockedCompareExchangePointer((void**)&typelib, tl, NULL))
ITypeLib_Release(tl);
}
if(!typeinfos[tid]) {
ITypeInfo *typeinfo;
hres = ITypeLib_GetTypeInfoOfGuid(typelib, tid_ids[tid], &typeinfo);
if(FAILED(hres)) {
ERR("GetTypeInfoOfGuid failed: %08x\n", hres);
return hres;
}
if(InterlockedCompareExchangePointer((void**)(typeinfos+tid), typeinfo, NULL))
ITypeInfo_Release(typeinfo);
}
*typeinfo = typeinfos[tid];
return S_OK;
}
static void thread_detach(void) static void thread_detach(void)
{ {
thread_data_t *thread_data; thread_data_t *thread_data;
...@@ -107,16 +66,7 @@ static void thread_detach(void) ...@@ -107,16 +66,7 @@ static void thread_detach(void)
static void process_detach(void) static void process_detach(void)
{ {
close_gecko(); close_gecko();
release_typelib();
if(typelib) {
unsigned i;
for(i=0; i < sizeof(typeinfos)/sizeof(*typeinfos); i++)
if(typeinfos[i])
ITypeInfo_Release(typeinfos[i]);
ITypeLib_Release(typelib);
}
if(shdoclc) if(shdoclc)
FreeLibrary(shdoclc); FreeLibrary(shdoclc);
......
...@@ -57,6 +57,12 @@ typedef struct ConnectionPoint ConnectionPoint; ...@@ -57,6 +57,12 @@ typedef struct ConnectionPoint ConnectionPoint;
typedef struct BSCallback BSCallback; typedef struct BSCallback BSCallback;
typedef struct nsChannelBSC nsChannelBSC; typedef struct nsChannelBSC nsChannelBSC;
/* NOTE: make sure to keep in sync with dispex.c */
typedef enum {
IHTMLWindow2_tid,
LAST_tid
} tid_t;
typedef struct { typedef struct {
const IDispatchExVtbl *lpIDispatchExVtbl; const IDispatchExVtbl *lpIDispatchExVtbl;
...@@ -524,13 +530,8 @@ HWND get_thread_hwnd(void); ...@@ -524,13 +530,8 @@ HWND get_thread_hwnd(void);
void push_task(task_t*); void push_task(task_t*);
void remove_doc_tasks(const HTMLDocument*); void remove_doc_tasks(const HTMLDocument*);
/* typelibs */ HRESULT get_typeinfo(tid_t,ITypeInfo**);
enum tid_t { void release_typelib(void);
IHTMLWindow2_tid,
LAST_tid
};
HRESULT get_typeinfo(enum tid_t, ITypeInfo**);
DEFINE_GUID(CLSID_AboutProtocol, 0x3050F406, 0x98B5, 0x11CF, 0xBB,0x82, 0x00,0xAA,0x00,0xBD,0xCE,0x0B); DEFINE_GUID(CLSID_AboutProtocol, 0x3050F406, 0x98B5, 0x11CF, 0xBB,0x82, 0x00,0xAA,0x00,0xBD,0xCE,0x0B);
DEFINE_GUID(CLSID_JSProtocol, 0x3050F3B2, 0x98B5, 0x11CF, 0xBB,0x82, 0x00,0xAA,0x00,0xBD,0xCE,0x0B); DEFINE_GUID(CLSID_JSProtocol, 0x3050F3B2, 0x98B5, 0x11CF, 0xBB,0x82, 0x00,0xAA,0x00,0xBD,0xCE,0x0B);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment