[前][次][番号順一覧][スレッド一覧]

ruby-changes:39829

From: nobu <ko1@a...>
Date: Mon, 21 Sep 2015 23:35:49 +0900 (JST)
Subject: [ruby-changes:39829] nobu:r51910 (trunk): win32ole.c: constified

nobu	2015-09-21 23:35:33 +0900 (Mon, 21 Sep 2015)

  New Revision: 51910

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=51910

  Log:
    win32ole.c: constified
    
    * ext/win32ole/win32ole.c (vtEventSink): constified.

  Modified files:
    trunk/ext/win32ole/win32ole_event.c
Index: ext/win32ole/win32ole_event.c
===================================================================
--- ext/win32ole/win32ole_event.c	(revision 51909)
+++ ext/win32ole/win32ole_event.c	(revision 51910)
@@ -48,7 +48,7 @@ struct IEventSinkVtbl { https://github.com/ruby/ruby/blob/trunk/ext/win32ole/win32ole_event.c#L48
 };
 
 typedef struct tagIEVENTSINKOBJ {
-    IEventSinkVtbl *lpVtbl;
+    const IEventSinkVtbl *lpVtbl;
     DWORD m_cRef;
     IID m_iid;
     long  m_event_id;
@@ -67,9 +67,23 @@ static ID id_events; https://github.com/ruby/ruby/blob/trunk/ext/win32ole/win32ole_event.c#L67
 
 VALUE cWIN32OLE_EVENT;
 
-static BOOL g_IsEventSinkVtblInitialized = FALSE;
-
-static IEventSinkVtbl vtEventSink;
+STDMETHODIMP EVENTSINK_QueryInterface(PEVENTSINK, REFIID, LPVOID*);
+STDMETHODIMP_(ULONG) EVENTSINK_AddRef(PEVENTSINK);
+STDMETHODIMP_(ULONG) EVENTSINK_Release(PEVENTSINK);
+STDMETHODIMP EVENTSINK_GetTypeInfoCount(PEVENTSINK, UINT*);
+STDMETHODIMP EVENTSINK_GetTypeInfo(PEVENTSINK, UINT, LCID, ITypeInfo**);
+STDMETHODIMP EVENTSINK_GetIDsOfNames(PEVENTSINK, REFIID, OLECHAR**, UINT, LCID, DISPID*);
+STDMETHODIMP EVENTSINK_Invoke(PEVENTSINK, DISPID, REFIID, LCID, WORD, DISPPARAMS*, VARIANT*, EXCEPINFO*, UINT*);
+
+static const IEventSinkVtbl vtEventSink = {
+    EVENTSINK_QueryInterface,
+    EVENTSINK_AddRef,
+    EVENTSINK_Release,
+    EVENTSINK_GetTypeInfoCount,
+    EVENTSINK_GetTypeInfo,
+    EVENTSINK_GetIDsOfNames,
+    EVENTSINK_Invoke,
+};
 
 void EVENTSINK_Destructor(PIEVENTSINKOBJ);
 static void ole_val2ptr_variant(VALUE val, VARIANT *var);
@@ -294,17 +308,6 @@ PIEVENTSINKOBJ https://github.com/ruby/ruby/blob/trunk/ext/win32ole/win32ole_event.c#L308
 EVENTSINK_Constructor(void)
 {
     PIEVENTSINKOBJ pEv;
-    if (!g_IsEventSinkVtblInitialized) {
-        vtEventSink.QueryInterface=EVENTSINK_QueryInterface;
-        vtEventSink.AddRef = EVENTSINK_AddRef;
-        vtEventSink.Release = EVENTSINK_Release;
-        vtEventSink.Invoke = EVENTSINK_Invoke;
-        vtEventSink.GetIDsOfNames = EVENTSINK_GetIDsOfNames;
-        vtEventSink.GetTypeInfoCount = EVENTSINK_GetTypeInfoCount;
-        vtEventSink.GetTypeInfo = EVENTSINK_GetTypeInfo;
-
-        g_IsEventSinkVtblInitialized = TRUE;
-    }
     pEv = ALLOC_N(IEVENTSINKOBJ, 1);
     if(pEv == NULL) return NULL;
     pEv->lpVtbl = &vtEventSink;

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]