Jacek Caban : mshtml: Move get_typeinfo to dispex.c.

Alexandre Julliard julliard at winehq.org
Thu Apr 17 07:38:39 CDT 2008


Module: wine
Branch: master
Commit: be59368dd1176becfd582d0d959e16b23430b97d
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=be59368dd1176becfd582d0d959e16b23430b97d

Author: Jacek Caban <jacek at codeweavers.com>
Date:   Thu Apr 17 02:32:18 2008 +0200

mshtml: Move get_typeinfo to dispex.c.

---

 dlls/mshtml/dispex.c         |   55 ++++++++++++++++++++++++++++++++++++++++++
 dlls/mshtml/main.c           |   52 +--------------------------------------
 dlls/mshtml/mshtml_private.h |   15 ++++++-----
 3 files changed, 64 insertions(+), 58 deletions(-)

diff --git a/dlls/mshtml/dispex.c b/dlls/mshtml/dispex.c
index f665c8f..6596f76 100644
--- a/dlls/mshtml/dispex.c
+++ b/dlls/mshtml/dispex.c
@@ -31,6 +31,61 @@
 
 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)
 
 static HRESULT WINAPI DispatchEx_QueryInterface(IDispatchEx *iface, REFIID riid, void **ppv)
diff --git a/dlls/mshtml/main.c b/dlls/mshtml/main.c
index 0389833..1c52c5a 100644
--- a/dlls/mshtml/main.c
+++ b/dlls/mshtml/main.c
@@ -49,47 +49,6 @@ DWORD mshtml_tls = 0;
 
 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)
 {
     thread_data_t *thread_data;
@@ -107,16 +66,7 @@ static void thread_detach(void)
 static void process_detach(void)
 {
     close_gecko();
-
-    if(typelib) {
-        unsigned i;
-
-        for(i=0; i < sizeof(typeinfos)/sizeof(*typeinfos); i++)
-            if(typeinfos[i])
-                ITypeInfo_Release(typeinfos[i]);
-
-        ITypeLib_Release(typelib);
-    }
+    release_typelib();
 
     if(shdoclc)
         FreeLibrary(shdoclc);
diff --git a/dlls/mshtml/mshtml_private.h b/dlls/mshtml/mshtml_private.h
index 1bd4bb1..67e27a4 100644
--- a/dlls/mshtml/mshtml_private.h
+++ b/dlls/mshtml/mshtml_private.h
@@ -57,6 +57,12 @@ typedef struct ConnectionPoint ConnectionPoint;
 typedef struct BSCallback BSCallback;
 typedef struct nsChannelBSC nsChannelBSC;
 
+/* NOTE: make sure to keep in sync with dispex.c */
+typedef enum {
+    IHTMLWindow2_tid,
+    LAST_tid
+} tid_t;
+
 typedef struct {
     const IDispatchExVtbl  *lpIDispatchExVtbl;
 
@@ -524,13 +530,8 @@ HWND get_thread_hwnd(void);
 void push_task(task_t*);
 void remove_doc_tasks(const HTMLDocument*);
 
-/* typelibs */
-enum tid_t {
-    IHTMLWindow2_tid,
-    LAST_tid
-};
-
-HRESULT get_typeinfo(enum tid_t, ITypeInfo**);
+HRESULT get_typeinfo(tid_t,ITypeInfo**);
+void release_typelib(void);
 
 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);




More information about the wine-cvs mailing list