* ext/win32ole/win32ole.c (ole_invoke): pass WIN32OLE_RECORD variant

by reference when invoke OLE methods at first.

* ext/win32ole/win32ole.c (olerecord_set_ivar): release
  IRecordInfo interface before setting another IRecordInfo interface.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47001 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
suke 2014-07-30 12:35:15 +00:00
Родитель f29dae3541
Коммит 1889a5b274
2 изменённых файлов: 20 добавлений и 6 удалений

Просмотреть файл

@ -1,3 +1,11 @@
Wed Jul 30 21:29:39 2014 Masaki Suketa <masaki.suketa@nifty.ne.jp>
* ext/win32ole/win32ole.c (ole_invoke): pass WIN32OLE_RECORD variant
by reference when invoke OLE methods at first.
* ext/win32ole/win32ole.c (olerecord_set_ivar): release
IRecordInfo interface before setting another IRecordInfo interface.
Wed Jul 30 13:17:35 2014 Koichi Sasada <ko1@atdot.net> Wed Jul 30 13:17:35 2014 Koichi Sasada <ko1@atdot.net>
* gc.c: remove unused macros. * gc.c: remove unused macros.

Просмотреть файл

@ -143,7 +143,7 @@ const IID IID_IMultiLanguage2 = {0xDCCFC164, 0x2B38, 0x11d2, {0xB7, 0xEC, 0x00,
#define WC2VSTR(x) ole_wc2vstr((x), TRUE) #define WC2VSTR(x) ole_wc2vstr((x), TRUE)
#define WIN32OLE_VERSION "1.6.6" #define WIN32OLE_VERSION "1.6.7"
typedef HRESULT (STDAPICALLTYPE FNCOCREATEINSTANCEEX) typedef HRESULT (STDAPICALLTYPE FNCOCREATEINSTANCEEX)
(REFCLSID, IUnknown*, DWORD, COSERVERINFO*, DWORD, MULTI_QI*); (REFCLSID, IUnknown*, DWORD, COSERVERINFO*, DWORD, MULTI_QI*);
@ -3460,8 +3460,10 @@ set_argv(VARIANTARG* realargs, unsigned int beg, unsigned int end)
rb_ary_clear(argv); rb_ary_clear(argv);
while (end-- > beg) { while (end-- > beg) {
rb_ary_push(argv, ole_variant2val(&realargs[end])); rb_ary_push(argv, ole_variant2val(&realargs[end]));
if (V_VT(&realargs[end]) != VT_RECORD) {
VariantClear(&realargs[end]); VariantClear(&realargs[end]);
} }
}
return argv; return argv;
} }
@ -3585,8 +3587,6 @@ ole_invoke(int argc, VALUE *argv, VALUE self, USHORT wFlags, BOOL is_bracket)
if (rb_obj_is_kind_of(param, cWIN32OLE_VARIANT)) { if (rb_obj_is_kind_of(param, cWIN32OLE_VARIANT)) {
Data_Get_Struct(param, struct olevariantdata, pvar); Data_Get_Struct(param, struct olevariantdata, pvar);
VariantCopy(&op.dp.rgvarg[n], &(pvar->var)); VariantCopy(&op.dp.rgvarg[n], &(pvar->var));
} else if (rb_obj_is_kind_of(param, cWIN32OLE_RECORD)) {
ole_rec2variant(param, &op.dp.rgvarg[n]);
} else { } else {
ole_val2variant(param, &realargs[n]); ole_val2variant(param, &realargs[n]);
V_VT(&op.dp.rgvarg[n]) = VT_VARIANT | VT_BYREF; V_VT(&op.dp.rgvarg[n]) = VT_VARIANT | VT_BYREF;
@ -3642,9 +3642,11 @@ ole_invoke(int argc, VALUE *argv, VALUE self, USHORT wFlags, BOOL is_bracket)
} }
for(i = cNamedArgs; i < op.dp.cArgs; i++) { for(i = cNamedArgs; i < op.dp.cArgs; i++) {
n = op.dp.cArgs - i + cNamedArgs - 1; n = op.dp.cArgs - i + cNamedArgs - 1;
if (V_VT(&op.dp.rgvarg[n]) != VT_RECORD) {
VariantClear(&op.dp.rgvarg[n]); VariantClear(&op.dp.rgvarg[n]);
} }
} }
}
if (FAILED(hr)) { if (FAILED(hr)) {
/* retry after converting nil to VT_EMPTY */ /* retry after converting nil to VT_EMPTY */
@ -3678,6 +3680,9 @@ ole_invoke(int argc, VALUE *argv, VALUE self, USHORT wFlags, BOOL is_bracket)
param = rb_ary_entry(paramS, i-cNamedArgs); param = rb_ary_entry(paramS, i-cNamedArgs);
if (rb_obj_is_kind_of(param, cWIN32OLE_VARIANT)) { if (rb_obj_is_kind_of(param, cWIN32OLE_VARIANT)) {
ole_val2variant(param, &realargs[n]); ole_val2variant(param, &realargs[n]);
} else if ( rb_obj_is_kind_of(param, cWIN32OLE_RECORD) &&
V_VT(&realargs[n]) == VT_RECORD ) {
olerecord_set_ivar(param, V_RECORDINFO(&realargs[n]), V_RECORD(&realargs[n]));
} }
} }
set_argv(realargs, cNamedArgs, op.dp.cArgs); set_argv(realargs, cNamedArgs, op.dp.cArgs);
@ -9286,8 +9291,9 @@ olerecord_set_ivar(VALUE obj, IRecordInfo *pri, void *prec)
struct olerecorddata *pvar; struct olerecorddata *pvar;
Data_Get_Struct(obj, struct olerecorddata, pvar); Data_Get_Struct(obj, struct olerecorddata, pvar);
OLE_ADDREF(pri);
OLE_RELEASE(pvar->pri);
pvar->pri = pri; pvar->pri = pri;
OLE_ADDREF(pvar->pri);
hr = pri->lpVtbl->GetName(pri, &bstr); hr = pri->lpVtbl->GetName(pri, &bstr);
if (SUCCEEDED(hr)) { if (SUCCEEDED(hr)) {