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

ruby-changes:35110

From: suke <ko1@a...>
Date: Fri, 15 Aug 2014 20:36:23 +0900 (JST)
Subject: [ruby-changes:35110] suke:r47192 (trunk): * ext/win32ole/win32ole.c: seperate WIN32OLE_EVENT src from

suke	2014-08-15 20:36:12 +0900 (Fri, 15 Aug 2014)

  New Revision: 47192

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

  Log:
    * ext/win32ole/win32ole.c: seperate WIN32OLE_EVENT src from
      win32ole.c.
    * ext/win32ole/win32ole.h: ditto.
    * ext/win32ole/win32ole_event.c: ditto.
    * ext/win32ole/win32ole_event.h: ditto.
    * ext/win32ole/depend: ditto.

  Added files:
    trunk/ext/win32ole/win32ole_event.c
    trunk/ext/win32ole/win32ole_event.h
  Modified files:
    trunk/ChangeLog
    trunk/ext/win32ole/depend
    trunk/ext/win32ole/win32ole.c
    trunk/ext/win32ole/win32ole.h
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 47191)
+++ ChangeLog	(revision 47192)
@@ -1,3 +1,12 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Fri Aug 15 20:34:17 2014  Masaki Suketa <masaki.suketa@n...>
+
+	* ext/win32ole/win32ole.c: seperate WIN32OLE_EVENT src from
+	  win32ole.c.
+	* ext/win32ole/win32ole.h: ditto.
+	* ext/win32ole/win32ole_event.c: ditto.
+	* ext/win32ole/win32ole_event.h: ditto.
+	* ext/win32ole/depend: ditto.
+
 Fri Aug 15 19:38:00 2014  Koichi Sasada  <ko1@a...>
 
 	* iseq.c (rb_iseq_clone): Should not insert write barrier from
Index: ext/win32ole/win32ole.c
===================================================================
--- ext/win32ole/win32ole.c	(revision 47191)
+++ ext/win32ole/win32ole.c	(revision 47192)
@@ -26,13 +26,6 @@ https://github.com/ruby/ruby/blob/trunk/ext/win32ole/win32ole.c#L26
 const IID IID_IMultiLanguage2 = {0xDCCFC164, 0x2B38, 0x11d2, {0xB7, 0xEC, 0x00, 0xC0, 0x4F, 0x8F, 0x5D, 0x9A}};
 #endif
 
-#define OLEData_Get_Struct(obj, pole) {\
-    Data_Get_Struct(obj, struct oledata, pole);\
-    if(!pole->pDispatch) {\
-        rb_raise(rb_eRuntimeError, "failed to get Dispatch Interface");\
-    }\
-}
-
 #define WIN32OLE_VERSION "1.7.7"
 
 typedef HRESULT (STDAPICALLTYPE FNCOCREATEINSTANCEEX)
@@ -41,60 +34,7 @@ typedef HRESULT (STDAPICALLTYPE FNCOCREA https://github.com/ruby/ruby/blob/trunk/ext/win32ole/win32ole.c#L34
 typedef HWND (WINAPI FNHTMLHELP)(HWND hwndCaller, LPCSTR pszFile,
                                  UINT uCommand, DWORD dwData);
 typedef BOOL (FNENUMSYSEMCODEPAGES) (CODEPAGE_ENUMPROC, DWORD);
-typedef struct {
-    struct IEventSinkVtbl * lpVtbl;
-} IEventSink, *PEVENTSINK;
-
-typedef struct IEventSinkVtbl IEventSinkVtbl;
-
-struct IEventSinkVtbl {
-    STDMETHOD(QueryInterface)(
-        PEVENTSINK,
-        REFIID,
-        LPVOID *);
-    STDMETHOD_(ULONG, AddRef)(PEVENTSINK);
-    STDMETHOD_(ULONG, Release)(PEVENTSINK);
-
-    STDMETHOD(GetTypeInfoCount)(
-        PEVENTSINK,
-        UINT *);
-    STDMETHOD(GetTypeInfo)(
-        PEVENTSINK,
-        UINT,
-        LCID,
-        ITypeInfo **);
-    STDMETHOD(GetIDsOfNames)(
-        PEVENTSINK,
-        REFIID,
-        OLECHAR **,
-        UINT,
-        LCID,
-        DISPID *);
-    STDMETHOD(Invoke)(
-        PEVENTSINK,
-        DISPID,
-        REFIID,
-        LCID,
-        WORD,
-        DISPPARAMS *,
-        VARIANT *,
-        EXCEPINFO *,
-        UINT *);
-};
-
-typedef struct tagIEVENTSINKOBJ {
-    IEventSinkVtbl *lpVtbl;
-    DWORD m_cRef;
-    IID m_iid;
-    int m_event_id;
-    ITypeInfo *pTypeInfo;
-}IEVENTSINKOBJ, *PIEVENTSINKOBJ;
-
 VALUE cWIN32OLE;
-VALUE cWIN32OLE_EVENT;
-
-static VALUE ary_ole_event;
-static ID id_events;
 
 #if defined(RB_THREAD_SPECIFIC) && (defined(__CYGWIN__) || defined(__MINGW32__))
 static RB_THREAD_SPECIFIC BOOL g_ole_initialized;
@@ -133,22 +73,11 @@ static IMultiLanguage *pIMultiLanguage = https://github.com/ruby/ruby/blob/trunk/ext/win32ole/win32ole.c#L73
 #define pIMultiLanguage NULL /* dummy */
 #endif
 
-struct oledata {
-    IDispatch *pDispatch;
-};
-
-struct oleeventdata {
-    DWORD dwCookie;
-    IConnectionPoint *pConnectionPoint;
-    long event_id;
-};
-
 struct oleparam {
     DISPPARAMS dp;
     OLECHAR** pNamedArgs;
 };
 
-
 static HRESULT ( STDMETHODCALLTYPE QueryInterface )(IDispatch __RPC_FAR *, REFIID riid, void __RPC_FAR *__RPC_FAR *ppvObject);
 static ULONG ( STDMETHODCALLTYPE AddRef )(IDispatch __RPC_FAR * This);
 static ULONG ( STDMETHODCALLTYPE Release )(IDispatch __RPC_FAR * This);
@@ -166,10 +95,8 @@ NORETURN(static void failed_load_conv519 https://github.com/ruby/ruby/blob/trunk/ext/win32ole/win32ole.c#L95
 static void load_conv_function51932(void);
 #endif
 static UINT ole_init_cp(void);
-static char *ole_wc2mb(LPWSTR pw);
 static void ole_freeexceptinfo(EXCEPINFO *pExInfo);
 static VALUE ole_excepinfo2msg(EXCEPINFO *pExInfo);
-static void ole_msg_loop(void);
 static void ole_free(struct oledata *pole);
 static LPWSTR ole_mb2wc(char *pm, int len);
 static VALUE ole_ary_m_entry(VALUE val, LONG *pid);
@@ -178,7 +105,6 @@ static void * get_ptr_of_variant(VARIANT https://github.com/ruby/ruby/blob/trunk/ext/win32ole/win32ole.c#L105
 static void ole_set_safe_array(long n, SAFEARRAY *psa, LONG *pid, long *pub, VALUE val, long dim,  VARTYPE vt);
 static long dimension(VALUE val);
 static long ary_len_of_dim(VALUE ary, long dim);
-static void ole_val2ptr_variant(VALUE val, VARIANT *var);
 static VALUE ole_set_member(VALUE self, IDispatch *dispatch);
 static VALUE fole_s_allocate(VALUE klass);
 static VALUE create_win32ole_object(VALUE klass, IDispatch *pDispatch, int argc, VALUE *argv);
@@ -239,38 +165,6 @@ static VALUE ole_ptrtype2val(ITypeInfo * https://github.com/ruby/ruby/blob/trunk/ext/win32ole/win32ole.c#L165
 static VALUE fole_method_help(VALUE self, VALUE cmdname);
 static VALUE fole_activex_initialize(VALUE self);
 
-
-static long ole_search_event_at(VALUE ary, VALUE ev);
-static VALUE ole_search_event(VALUE ary, VALUE ev, BOOL  *is_default);
-static VALUE ole_search_handler_method(VALUE handler, VALUE ev, BOOL *is_default_handler);
-static void ole_delete_event(VALUE ary, VALUE ev);
-static void hash2ptr_dispparams(VALUE hash, ITypeInfo *pTypeInfo, DISPID dispid, DISPPARAMS *pdispparams);
-static VALUE hash2result(VALUE hash);
-static void ary2ptr_dispparams(VALUE ary, DISPPARAMS *pdispparams);
-static VALUE exec_callback(VALUE arg);
-static VALUE rescue_callback(VALUE arg);
-static HRESULT find_iid(VALUE ole, char *pitf, IID *piid, ITypeInfo **ppTypeInfo);
-static HRESULT find_coclass(ITypeInfo *pTypeInfo, TYPEATTR *pTypeAttr, ITypeInfo **pTypeInfo2, TYPEATTR **pTypeAttr2);
-static HRESULT find_default_source_from_typeinfo(ITypeInfo *pTypeInfo, TYPEATTR *pTypeAttr, ITypeInfo **ppTypeInfo);
-static HRESULT find_default_source(VALUE ole, IID *piid, ITypeInfo **ppTypeInfo);
-static void ole_event_free(struct oleeventdata *poleev);
-static VALUE fev_s_allocate(VALUE klass);
-static VALUE ev_advise(int argc, VALUE *argv, VALUE self);
-static VALUE fev_initialize(int argc, VALUE *argv, VALUE self);
-static VALUE fev_s_msg_loop(VALUE klass);
-static void add_event_call_back(VALUE obj, VALUE event, VALUE data);
-static VALUE ev_on_event(int argc, VALUE *argv, VALUE self, VALUE is_ary_arg);
-static VALUE fev_on_event(int argc, VALUE *argv, VALUE self);
-static VALUE fev_on_event_with_outargs(int argc, VALUE *argv, VALUE self);
-static VALUE fev_off_event(int argc, VALUE *argv, VALUE self);
-static VALUE fev_unadvise(VALUE self);
-static VALUE fev_set_handler(VALUE self, VALUE val);
-static VALUE fev_get_handler(VALUE self);
-static VALUE evs_push(VALUE ev);
-static VALUE evs_delete(long i);
-static VALUE evs_entry(long i);
-static VALUE evs_length(void);
-
 static void init_enc2cp(void);
 static void free_enc2cp(void);
 
@@ -791,7 +685,7 @@ ole_alloc_str(UINT size, void *arg) https://github.com/ruby/ruby/blob/trunk/ext/win32ole/win32ole.c#L685
     return ALLOC_N(char, size + 1);
 }
 
-static char *
+char *
 ole_wc2mb(LPWSTR pw)
 {
     return ole_wc2mb_alloc(pw, ole_alloc_str, NULL);
@@ -887,15 +781,6 @@ ole_initialize(void) https://github.com/ruby/ruby/blob/trunk/ext/win32ole/win32ole.c#L781
 }
 
 static void
-ole_msg_loop() {
-    MSG msg;
-    while(PeekMessage(&msg,NULL,0,0,PM_REMOVE)) {
-        TranslateMessage(&msg);
-        DispatchMessage(&msg);
-    }
-}
-
-static void
 ole_free(struct oledata *pole)
 {
     OLE_FREE(pole->pDispatch);
@@ -1365,74 +1250,6 @@ ole_val2variant(VALUE val, VARIANT *var) https://github.com/ruby/ruby/blob/trunk/ext/win32ole/win32ole.c#L1250
     }
 }
 
-static void
-ole_val2ptr_variant(VALUE val, VARIANT *var)
-{
-    switch (TYPE(val)) {
-    case T_STRING:
-        if (V_VT(var) == (VT_BSTR | VT_BYREF)) {
-            *V_BSTRREF(var) = ole_vstr2wc(val);
-        }
-        break;
-    case T_FIXNUM:
-        switch(V_VT(var)) {
-        case (VT_UI1 | VT_BYREF) :
-            *V_UI1REF(var) = NUM2CHR(val);
-            break;
-        case (VT_I2 | VT_BYREF) :
-            *V_I2REF(var) = (short)NUM2INT(val);
-            break;
-        case (VT_I4 | VT_BYREF) :
-            *V_I4REF(var) = NUM2INT(val);
-            break;
-        case (VT_R4 | VT_BYREF) :
-            *V_R4REF(var) = (float)NUM2INT(val);
-            break;
-        case (VT_R8 | VT_BYREF) :
-            *V_R8REF(var) = NUM2INT(val);
-            break;
-        default:
-            break;
-        }
-        break;
-    case T_FLOAT:
-        switch(V_VT(var)) {
-        case (VT_I2 | VT_BYREF) :
-            *V_I2REF(var) = (short)NUM2INT(val);
-            break;
-        case (VT_I4 | VT_BYREF) :
-            *V_I4REF(var) = NUM2INT(val);
-            break;
-        case (VT_R4 | VT_BYREF) :
-            *V_R4REF(var) = (float)NUM2DBL(val);
-            break;
-        case (VT_R8 | VT_BYREF) :
-            *V_R8REF(var) = NUM2DBL(val);
-            break;
-        default:
-            break;
-        }
-        break;
-    case T_BIGNUM:
-        if (V_VT(var) == (VT_R8 | VT_BYREF)) {
-            *V_R8REF(var) = rb_big2dbl(val);
-        }
-        break;
-    case T_TRUE:
-        if (V_VT(var) == (VT_BOOL | VT_BYREF)) {
-            *V_BOOLREF(var) = VARIANT_TRUE;
-        }
-        break;
-    case T_FALSE:
-        if (V_VT(var) == (VT_BOOL | VT_BYREF)) {
-            *V_BOOLREF(var) = VARIANT_FALSE;
-        }
-        break;
-    default:
-        break;
-    }
-}
-
 void
 ole_val2variant2(VALUE val, VARIANT *var)
 {
@@ -3695,10 +3512,10 @@ fole_respond_to(VALUE self, VALUE method https://github.com/ruby/ruby/blob/trunk/ext/win32ole/win32ole.c#L3512
     DISPID DispID;
     HRESULT hr;
     if(!RB_TYPE_P(method, T_STRING) && !RB_TYPE_P(method, T_SYMBOL)) {
-	rb_raise(rb_eTypeError, "wrong argument type (expected String or Symbol)");
+        rb_raise(rb_eTypeError, "wrong argument type (expected String or Symbol)");
     }
     if (RB_TYPE_P(method, T_SYMBOL)) {
-	method = rb_sym_to_s(method);
+        method = rb_sym_to_s(method);
     }
     OLEData_Get_Struct(self, pole);
     wcmdname = ole_vstr2wc(method);
@@ -3969,1070 +3786,6 @@ fole_activex_initialize(VALUE self) https://github.com/ruby/ruby/blob/trunk/ext/win32ole/win32ole.c#L3786
     return Qnil;
 }
 
-/*
- * Document-class: WIN32OLE_EVENT
- *
- *   <code>WIN32OLE_EVENT</code> objects controls OLE event.
- */
-
-static IEventSinkVtbl vtEventSink;
-static BOOL g_IsEventSinkVtblInitialized = FALSE;
-
-void EVENTSINK_Destructor(PIEVENTSINKOBJ);
-
-STDMETHODIMP
-EVENTSINK_QueryInterface(
-    PEVENTSINK pEV,
-    REFIID     iid,
-    LPVOID*    ppv
-    ) {
-    if (IsEqualIID(iid, &IID_IUnknown) ||
-        IsEqualIID(iid, &IID_IDispatch) ||
-        IsEqualIID(iid, &((PIEVENTSINKOBJ)pEV)->m_iid)) {
-        *ppv = pEV;
-    }
-    else {
-        *ppv = NULL;
-        return E_NOINTERFACE;
-    }
-    ((LPUNKNOWN)*ppv)->lpVtbl->AddRef((LPUNKNOWN)*ppv);
-    return NOERROR;
-}
-
-STDMETHODIMP_(ULONG)
-EVENTSINK_AddRef(
-    PEVENTSINK pEV
-    ){
-    PIEVENTSINKOBJ pEVObj = (PIEVENTSINKOBJ)pEV;
-    return ++pEVObj->m_cRef;
-}
-
-STDMETHODIMP_(ULONG) EVENTSINK_Release(
-    PEVENTSINK pEV
-    ) {
-    PIEVENTSINKOBJ pEVObj = (PIEVENTSINKOBJ)pEV;
-    --pEVObj->m_cRef;
-    if(pEVObj->m_cRef != 0)
-        return pEVObj->m_cRef;
-    EVENTSINK_Destructor(pEVObj);
-    return 0;
-}
-
-STDMETHODIMP EVENTSINK_GetTypeInfoCount(
-    PEVENTSINK pEV,
-    UINT *pct
-    ) {
-    *pct = 0;
-    return NOERROR;
-}
-
-STDMETHODIMP EVENTSINK_GetTypeInfo(
-    PEVENTSINK pEV,
-    UINT info,
-    LCID lcid,
-    ITypeInfo **pInfo
-    ) {
-    *pInfo = NULL;
-    return DISP_E_BADINDEX;
-}
-
-STDMETHODIMP EVENTSINK_GetIDsOfNames(
-    PEVENTSINK pEventSink,
-    REFIID riid,
-    OLECHAR **szNames,
-    UINT cNames,
-    LCID lcid,
-    DISPID *pDispID
-    ) {
-    ITypeInfo *pTypeInfo;
-    PIEVENTSINKOBJ pEV = (PIEVENTSINKOBJ)pEventSink;
-    pTypeInfo = pEV->pTypeInfo;
-    if (pTypeInfo) {
-	return pTypeInfo->lpVtbl->GetIDsOfNames(pTypeInfo, szNames, cNames, pDispID);
-    }
-    return DISP_E_UNKNOWNNAME;
-}
-
-static long
-ole_search_event_at(VALUE ary, VALUE ev)
-{
-    VALUE event;
-    VALUE event_name;
-    long i, len;
-    long ret = -1;
-    len = RARRAY_LEN(ary);
-    for(i = 0; i < len; i++) {
-        event = rb_ary_entry(ary, i);
-        event_name = rb_ary_entry(event, 1);
-        if(NIL_P(event_name) && NIL_P(ev)) {
-            ret = i;
-            break;
-        }
-        else if (RB_TYPE_P(ev, T_STRING) &&
-                 RB_TYPE_P(event_name, T_STRING) &&
-                 rb_str_cmp(ev, event_name) == 0) {
-            ret = i;
-            break;
-        }
-    }
-    return ret;
-}
-
-static VALUE
-ole_search_event(VALUE ary, VALUE ev, BOOL  *is_default)
-{
-    VALUE event;
-    VALUE def_event;
-    VALUE event_name;
-    int i, len;
-    *is_default = FALSE;
-    def_event = Qnil;
-    len = RARRAY_LEN(ary);
-    for(i = 0; i < len; i++) {
-        event = rb_ary_entry(ary, i);
-        event_name = rb_ary_entry(event, 1);
-        if(NIL_P(event_name)) {
-            *is_default = TRUE;
-            def_event = event;
-        }
-        else if (rb_str_cmp(ev, event_name) == 0) {
-            *is_default = FALSE;
-            return event;
-        }
-    }
-    return def_event;
-}
-static VALUE
-ole_search_handler_method(VALUE handler, VALUE ev, BOOL *is_default_handler)
-{
-    VALUE mid;
-
-    *is_default_handler = FALSE;
-    mid = rb_to_id(rb_sprintf("on%"PRIsVALUE, ev));
-    if (rb_respond_to(handler, mid)) {
-	return mid;
-    }
-    mid = rb_intern("method_missing");
-    if (rb_respond_to(handler, mid)) {
-	*is_default_handler = TRUE;
-	return mid;
-    }
-    return Qnil;
-}
-
-static void
-ole_delete_event(VALUE ary, VALUE ev)
-{
-    long at = -1;
-    at = ole_search_event_at(ary, ev);
-    if (at >= 0) {
-        rb_ary_delete_at(ary, at);
-    }
-}
-
-static void
-hash2ptr_dispparams(VALUE hash, ITypeInfo *pTypeInfo, DISPID dispid, DISPPARAMS *pdispparams)
-{
-    BSTR *bstrs;
-    HRESULT hr;
-    UINT len, i;
-    VARIANT *pvar;
-    VALUE val;
-    VALUE key;
-    len = 0;
-    bstrs = ALLOCA_N(BSTR, pdispparams->cArgs + 1);
-    hr = pTypeInfo->lpVtbl->GetNames(pTypeInfo, dispid,
-                                     bstrs, pdispparams->cArgs + 1,
-                                     &len);
-    if (FAILED(hr))
-	return;
-
-    for (i = 0; i < len - 1; i++) {
-	key = WC2VSTR(bstrs[i + 1]);
-        val = rb_hash_aref(hash, INT2FIX(i));
-	if (val == Qnil)
-	    val = rb_hash_aref(hash, key);
-	if (val == Qnil)
-	    val = rb_hash_aref(hash, rb_str_intern(key));
-        pvar = &pdispparams->rgvarg[pdispparams->cArgs-i-1];
-        ole_val2ptr_variant(val, pvar);
-    }
-}
-
-static VALUE
-hash2result(VALUE hash)
-{
-    VALUE ret = Qnil;
-    ret = rb_hash_aref(hash, rb_str_new2("return"));
-    if (ret == Qnil)
-	ret = rb_hash_aref(hash, rb_str_intern(rb_str_new2("return")));
-    return ret;
-}
-
-static void
-ary2ptr_dispparams(VALUE ary, DISPPARAMS *pdispparams)
-{
-    int i;
-    VALUE v;
-    VARIANT *pvar;
-    for(i = 0; i < RARRAY_LEN(ary) && (unsigned int) i < pdispparams->cArgs; i++) {
-        v = rb_ary_entry(ary, i);
-        pvar = &pdispparams->rgvarg[pdispparams->cArgs-i-1];
-        ole_val2ptr_variant(v, pvar);
-    }
-}
-
-static VALUE
-exec_callback(VALUE arg)
-{
-    VALUE *parg = (VALUE *)arg;
-    VALUE handler = parg[0];
-    VALUE mid = parg[1];
-    VALUE args = parg[2];
-    return rb_apply(handler, mid, args);
-}
-
-static VALUE
-rescue_callback(VALUE arg)
-{
-
-    VALUE error;
-    VALUE e = rb_errinfo();
-    VALUE bt = rb_funcall(e, rb_intern("backtrace"), 0);
-    VALUE msg = rb_funcall(e, rb_intern("message"), 0);
-    bt = rb_ary_entry(bt, 0);
-    error = rb_sprintf("%"PRIsVALUE": %"PRIsVALUE" (%s)\n", bt, msg, rb_obj_classname(e));
-    rb_write_error(StringValuePtr(error));
-    rb_backtrace();
-    ruby_finalize();
-    exit(-1);
-
-    return Qnil;
-}
-
-STDMETHODIMP EVENTSINK_Invoke(
-    PEVENTSINK pEventSink,
-    DISPID dispid,
-    REFIID riid,
-    LCID lcid,
-    WORD wFlags,
-    DISPPARAMS *pdispparams,
-    VARIANT *pvarResult,
-    EXCEPINFO *pexcepinfo,
-    UINT *puArgErr
-    ) {
-
-    HRESULT hr;
-    BSTR bstr;
-    unsigned int count;
-    unsigned int i;
-    ITypeInfo *pTypeInfo;
-    VARIANT *pvar;
-    VALUE ary, obj, event, args, outargv, ev, result;
-    VALUE handler = Qnil;
-    VALUE arg[3];
-    VALUE mid;
-    VALUE is_outarg = Qfalse;
-    BOOL is_default_handler = FALSE;
-    int state;
-
-    PIEVENTSINKOBJ pEV = (PIEVENTSINKOBJ)pEventSink;
-    pTypeInfo = pEV->pTypeInfo;
-    obj = evs_entry(pEV->m_event_id);
-    if (!rb_obj_is_kind_of(obj, cWIN32OLE_EVENT)) {
-        return NOERROR;
-    }
-
-    ary = rb_ivar_get(obj, id_events);
-    if (NIL_P(ary) || !RB_TYPE_P(ary, T_ARRAY)) {
-        return NOERROR;
-    }
-    hr = pTypeInfo->lpVtbl->GetNames(pTypeInfo, dispid,
-                                     &bstr, 1, &count);
-    if (FAILED(hr)) {
-        return NOERROR;
-    }
-    ev = WC2VSTR(bstr);
-    event = ole_search_event(ary, ev, &is_default_handler);
-    if (RB_TYPE_P(event, T_ARRAY)) {
-	handler = rb_ary_entry(event, 0);
-	mid = rb_intern("call");
-	is_outarg = rb_ary_entry(event, 3);
-    } else {
-	handler = rb_ivar_get(obj, rb_intern("handler"));
-	if (handler == Qnil) {
-	    return NOERROR;
-	}
-	mid = ole_search_handler_method(handler, ev, &is_default_handler);
-    }
-    if (handler == Qnil || mid == Qnil) {
-	return NOERROR;
-    }
-
-    args = rb_ary_new();
-    if (is_default_handler) {
-        rb_ary_push(args, ev);
-    }
-
-    /* make argument of event handler */
-    for (i = 0; i < pdispparams->cArgs; ++i) {
-        pvar = &pdispparams->rgvarg[pdispparams->cArgs-i-1];
-        rb_ary_push(args, ole_variant2val(pvar));
-    }
-    outargv = Qnil;
-    if (is_outarg == Qtrue) {
-	outargv = rb_ary_new();
-        rb_ary_push(args, outargv);
-    }
-
-    /*
-     * if exception raised in event callback,
-     * then you receive cfp consistency error.
-     * to avoid this error we use begin rescue end.
-     * and the exception raised then error message print
-     * and exit ruby process by Win32OLE itself.
-     */
-    arg[0] = handler;
-    arg[1] = mid;
-    arg[2] = args;
-    result = rb_protect(exec_callback, (VALUE)arg, &state);
-    if (state != 0) {
-	rescue_callback(Qnil);
-    }
-    if(RB_TYPE_P(result, T_HASH)) {
-	hash2ptr_dispparams(result, pTypeInfo, dispid, pdispparams);
-	result = hash2result(result);
-    }else if (is_outarg == Qtrue && RB_TYPE_P(outargv, T_ARRAY)) {
-	ary2ptr_dispparams(outargv, pdispparams);
-    }
-
-    if (pvarResult) {
-	VariantInit(pvarResult);
-        ole_val2variant(result, pvarResult);
-    }
-
-    return NOERROR;
-}
-
-PIEVENTSINKOBJ
-EVENTSINK_Constructor() {
-    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;
-    pEv->m_cRef = 0;
-    pEv->m_event_id = 0;
-    pEv->pTypeInfo = NULL;
-    return pEv;
-}
-
-void EVENTSINK_Destructor(
-    PIEVENTSINKOBJ pEVObj
-    ) {
-    if(pEVObj != NULL) {
-        OLE_RELEASE(pEVObj->pTypeInfo);
-        free(pEVObj);
-        pEVObj = NULL;
-    }
-}
-
-static HRESULT
-find_iid(VALUE ole, char *pitf, IID *piid, ITypeInfo **ppTypeInfo)
-{
-    HRE (... truncated)

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

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