ruby-changes:48716
From: suke <ko1@a...>
Date: Sat, 18 Nov 2017 11:53:44 +0900 (JST)
Subject: [ruby-changes:48716] suke:r60832 (trunk): * ext/win32ole/win32ole.c: use WIN32OLEQueryInterfaceError when failed
suke 2017-11-18 11:53:39 +0900 (Sat, 18 Nov 2017) New Revision: 60832 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=60832 Log: * ext/win32ole/win32ole.c: use WIN32OLEQueryInterfaceError when failed to query com interface. * ext/win32ole/win32ole_event.c: ditto. * ext/win32ole/win32ole_method.c: ditto. Modified files: trunk/ext/win32ole/win32ole.c trunk/ext/win32ole/win32ole_event.c trunk/ext/win32ole/win32ole_method.c Index: ext/win32ole/win32ole_method.c =================================================================== --- ext/win32ole/win32ole_method.c (revision 60831) +++ ext/win32ole/win32ole_method.c (revision 60832) @@ -83,7 +83,7 @@ ole_method_sub(VALUE self, ITypeInfo *pO https://github.com/ruby/ruby/blob/trunk/ext/win32ole/win32ole_method.c#L83 VALUE method = Qnil; hr = OLE_GET_TYPEATTR(pTypeInfo, &pTypeAttr); if (FAILED(hr)) { - ole_raise(hr, eWIN32OLERuntimeError, "failed to GetTypeAttr"); + ole_raise(hr, eWIN32OLEQueryInterfaceError, "failed to GetTypeAttr"); } for(i = 0; i < pTypeAttr->cFuncs && method == Qnil; i++) { hr = pTypeInfo->lpVtbl->GetFuncDesc(pTypeInfo, i, &pFuncDesc); @@ -148,7 +148,7 @@ olemethod_from_typeinfo(VALUE self, ITyp https://github.com/ruby/ruby/blob/trunk/ext/win32ole/win32ole_method.c#L148 VALUE method = Qnil; hr = OLE_GET_TYPEATTR(pTypeInfo, &pTypeAttr); if (FAILED(hr)) { - ole_raise(hr, eWIN32OLERuntimeError, "failed to GetTypeAttr"); + ole_raise(hr, eWIN32OLEQueryInterfaceError, "failed to GetTypeAttr"); } method = ole_method_sub(self, 0, pTypeInfo, name); if (method != Qnil) { @@ -308,7 +308,7 @@ ole_method_return_type(ITypeInfo *pTypeI https://github.com/ruby/ruby/blob/trunk/ext/win32ole/win32ole_method.c#L308 hr = pTypeInfo->lpVtbl->GetFuncDesc(pTypeInfo, method_index, &pFuncDesc); if (FAILED(hr)) - ole_raise(hr, eWIN32OLERuntimeError, "failed to GetFuncDesc"); + ole_raise(hr, eWIN32OLEQueryInterfaceError, "failed to GetFuncDesc"); type = ole_typedesc2val(pTypeInfo, &(pFuncDesc->elemdescFunc.tdesc), Qnil); pTypeInfo->lpVtbl->ReleaseFuncDesc(pTypeInfo, pFuncDesc); Index: ext/win32ole/win32ole.c =================================================================== --- ext/win32ole/win32ole.c (revision 60831) +++ ext/win32ole/win32ole.c (revision 60832) @@ -26,7 +26,7 @@ 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 WIN32OLE_VERSION "1.8.7" +#define WIN32OLE_VERSION "1.8.8" typedef HRESULT (STDAPICALLTYPE FNCOCREATEINSTANCEEX) (REFCLSID, IUnknown*, DWORD, COSERVERINFO*, DWORD, MULTI_QI*); @@ -2073,12 +2073,12 @@ fole_s_const_load(int argc, VALUE *argv, https://github.com/ruby/ruby/blob/trunk/ext/win32ole/win32ole.c#L2073 hr = pole->pDispatch->lpVtbl->GetTypeInfo(pole->pDispatch, 0, lcid, &pTypeInfo); if(FAILED(hr)) { - ole_raise(hr, rb_eRuntimeError, "failed to GetTypeInfo"); + ole_raise(hr, eWIN32OLEQueryInterfaceError, "failed to GetTypeInfo"); } hr = pTypeInfo->lpVtbl->GetContainingTypeLib(pTypeInfo, &pTypeLib, &index); if(FAILED(hr)) { OLE_RELEASE(pTypeInfo); - ole_raise(hr, rb_eRuntimeError, "failed to GetContainingTypeLib"); + ole_raise(hr, eWIN32OLEQueryInterfaceError, "failed to GetContainingTypeLib"); } OLE_RELEASE(pTypeInfo); if(!RB_TYPE_P(klass, T_NIL)) { @@ -3324,7 +3324,7 @@ fole_each(VALUE self) https://github.com/ruby/ruby/blob/trunk/ext/win32ole/win32ole.c#L3324 if (FAILED(hr)) { VariantClear(&result); - ole_raise(hr, eWIN32OLERuntimeError, "failed to get IEnum Interface"); + ole_raise(hr, eWIN32OLEQueryInterfaceError, "failed to get IEnum Interface"); } if (V_VT(&result) == VT_UNKNOWN) { @@ -3340,7 +3340,7 @@ fole_each(VALUE self) https://github.com/ruby/ruby/blob/trunk/ext/win32ole/win32ole.c#L3340 } if (FAILED(hr) || !pEnum) { VariantClear(&result); - ole_raise(hr, rb_eRuntimeError, "failed to get IEnum Interface"); + ole_raise(hr, eWIN32OLEQueryInterfaceError, "failed to get IEnum Interface"); } VariantClear(&result); @@ -3534,7 +3534,7 @@ fole_type(VALUE self) https://github.com/ruby/ruby/blob/trunk/ext/win32ole/win32ole.c#L3534 hr = pole->pDispatch->lpVtbl->GetTypeInfo( pole->pDispatch, 0, lcid, &pTypeInfo ); if(FAILED(hr)) { - ole_raise(hr, rb_eRuntimeError, "failed to GetTypeInfo"); + ole_raise(hr, eWIN32OLEQueryInterfaceError, "failed to GetTypeInfo"); } type = ole_type_from_itypeinfo(pTypeInfo); OLE_RELEASE(pTypeInfo); @@ -3568,7 +3568,7 @@ fole_typelib(VALUE self) https://github.com/ruby/ruby/blob/trunk/ext/win32ole/win32ole.c#L3568 hr = pole->pDispatch->lpVtbl->GetTypeInfo(pole->pDispatch, 0, lcid, &pTypeInfo); if(FAILED(hr)) { - ole_raise(hr, rb_eRuntimeError, "failed to GetTypeInfo"); + ole_raise(hr, eWIN32OLEQueryInterfaceError, "failed to GetTypeInfo"); } vtlib = ole_typelib_from_itypeinfo(pTypeInfo); OLE_RELEASE(pTypeInfo); @@ -3615,7 +3615,7 @@ fole_query_interface(VALUE self, VALUE s https://github.com/ruby/ruby/blob/trunk/ext/win32ole/win32ole.c#L3615 hr = pole->pDispatch->lpVtbl->QueryInterface(pole->pDispatch, &iid, &p); if(FAILED(hr)) { - ole_raise(hr, eWIN32OLERuntimeError, + ole_raise(hr, eWIN32OLEQueryInterfaceError, "failed to get interface `%s'", StringValuePtr(str_iid)); } @@ -3856,7 +3856,7 @@ fole_method_help(VALUE self, VALUE cmdna https://github.com/ruby/ruby/blob/trunk/ext/win32ole/win32ole.c#L3856 pole = oledata_get_struct(self); hr = typeinfo_from_ole(pole, &pTypeInfo); if(FAILED(hr)) - ole_raise(hr, rb_eRuntimeError, "failed to get ITypeInfo"); + ole_raise(hr, eWIN32OLEQueryInterfaceError, "failed to get ITypeInfo"); obj = create_win32ole_method(pTypeInfo, cmdname); Index: ext/win32ole/win32ole_event.c =================================================================== --- ext/win32ole/win32ole_event.c (revision 60831) +++ ext/win32ole/win32ole_event.c (revision 60832) @@ -942,7 +942,7 @@ ev_advise(int argc, VALUE *argv, VALUE s https://github.com/ruby/ruby/blob/trunk/ext/win32ole/win32ole_event.c#L942 &p); if (FAILED(hr)) { OLE_RELEASE(pTypeInfo); - ole_raise(hr, rb_eRuntimeError, + ole_raise(hr, eWIN32OLEQueryInterfaceError, "failed to query IConnectionPointContainer"); } pContainer = p; @@ -953,7 +953,7 @@ ev_advise(int argc, VALUE *argv, VALUE s https://github.com/ruby/ruby/blob/trunk/ext/win32ole/win32ole_event.c#L953 OLE_RELEASE(pContainer); if (FAILED(hr)) { OLE_RELEASE(pTypeInfo); - ole_raise(hr, rb_eRuntimeError, "failed to query IConnectionPoint"); + ole_raise(hr, eWIN32OLEQueryInterfaceError, "failed to query IConnectionPoint"); } pIEV = EVENTSINK_Constructor(); pIEV->m_iid = iid; @@ -961,7 +961,7 @@ ev_advise(int argc, VALUE *argv, VALUE s https://github.com/ruby/ruby/blob/trunk/ext/win32ole/win32ole_event.c#L961 (IUnknown*)pIEV, &dwCookie); if (FAILED(hr)) { - ole_raise(hr, rb_eRuntimeError, "Advise Error"); + ole_raise(hr, eWIN32OLEQueryInterfaceError, "Advise Error"); } TypedData_Get_Struct(self, struct oleeventdata, &oleevent_datatype, poleev); -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/